text
stringlengths 28
935k
| meta
stringlengths 137
139
| red_pajama_subset
stringclasses 1
value |
---|---|---|
\section{Conclusions}
Human activity recognition (HAR) using wearables has created increasingly new opportunities for healthcare applications. We present a new HAR framework and demonstrate its effectiveness through significant performance improvements achieved over state-of-the-art and its generalizability by evaluations across four diverse benchmarks. In particular, we: $i$) enriched activity representations by exploiting latent correlations between sensor channels; $ii$) incorporated center-loss to alleviate dealing with intra-class variations of activities; and $iii$) augmented multi-channel time-series data with mixup for better generalization.
We believe that our work will provide new opportunities to further research in HAR using wearables.
\section{Experiments and Results} \label{sa_sec:experiments}
\begin{figure*}[t]%
\centering
\subfloat{\includegraphics[width=0.50\textwidth]{opp_dist-eps-converted-to.pdf}}%
\subfloat{\includegraphics[width=0.50\textwidth]{pamap2_dist-eps-converted-to.pdf}}\\
\subfloat{\includegraphics[width=0.50\textwidth]{skoda_dist-eps-converted-to.pdf}}%
\subfloat{\includegraphics[width=0.50\textwidth]{hospital_dist-eps-converted-to.pdf}}%
\caption{Benchmark HAR datasets investigated in this paper. We illustrate the activity categories covered and their corresponding distributions within each dataset.}%
\label{sa_fig:dist}%
\end{figure*}
\subsection{Benchmark Datasets}\label{sa_sub:datasets}
To validate our framework and provide empirical evidence of its generalizability, we employ four HAR benchmarks exhibiting great diversity in terms of the sensing modalities used and the activities to be recognized. We provide a brief description of the datasets in what follows.
\paragraph{Opportunity Dataset \protect\cite{Chavarriaga:2013}.}
This dataset is captured by multiple body-worn sensors. Four participants wearing the sensors were instructed to carry out naturalistic kitchen routines. The data is recorded at a frequency of 30~Hz and is annotated with 17 sporadic gestures as well as a \texttt{Null} class. Following \cite{bilstm}, the 79 sensor channels not indicating packet-loss are used. For evaluation, we use runs 4 and 5 from subjects 2 and 3 as the holdout test-set, run 2 from participant 1 as the validation-set, and the remaining data as the training-set.
\paragraph{PAMAP2 Dataset \protect\cite{pamap2}.} This dataset is aimed at recognition 12 diverse activities of daily life. Data was recorded over 52 channels with annotations covering prolonged household and sportive actions. Replicating \cite{bilstm}, we use runs 1 and 2 from subject 6 as the holdout test-set, runs 1 and 2 from subject 5 as the validation-set, and the remaining data for training.
\paragraph{Skoda Dataset \protect\cite{skoda}.} The dataset covers the problem of recognizing $10$ manipulating gestures of assembly-line workers in a manufacturing scenario. Following~\cite{ensemble}, we use the data recorded over 60 sensor channels collected from the right arm, utilize the first $80\%$ of each class for the training-set, the following $10\%$ for validation and the remainder as the test-set.
\paragraph{Hospital Dataset \protect\cite{fcn}.} This dataset is collected from 12 hospitalized older patients wearing an inertial sensor over their garment while performing 7 categories of activities. All the data is recorded at 10~Hz. Following~\cite{fcn}, data from the first eight subjects are used for training, the following three for testing, and the remaining for the validation set.
We summarize the list of covered activity categories and their corresponding distributions within each dataset in Fig.~\ref{sa_fig:dist}. As illustrated, while the prevalence of each activity category for PAMAP2 and Skoda datasets is quite balanced, we observe a significant distribution imbalance for Opportunity and Hospital datasets.
\subsection{Unified Evaluation Protocol}\label{sa_sec:eval}
To ensure a fair comparison, we directly adopt the evaluation protocol and metrics used in the recent literature~\cite{bilstm,ensemble,attention,role}. Where possible, sensor data are down-sampled to 33~Hz to achieve a consistent temporal resolution with the Opportunity dataset. Each sensor channel is normalized to zero mean and unit variance using the training data statistics. The training data is partitioned into segments using a sliding window of 24 samples (\textit{i.e.}, W=24) with 50\% overlap between adjacent windows. For a realistic setup, sample-wise evaluation is adopted to compare the performance on the test-set; thus, a prediction is made for every sample of the test sequence as opposed to every segment. Given the imbalanced class distributions in the datasets (see Figure~\ref{sa_fig:dist}), the mean F1-score
\begin{equation}
\textrm{F}_{m} = \frac{2}{\mathcal{C}}\sum_{c=1}^{\mathcal{C}}\frac{\textrm{precision}_{c}\times \textrm{recall}_{c}}{\textrm{precision}_{c}+ \textrm{recall}_{c}},
\end{equation}
is used as the evaluation metric to reflect the ability of the HAR model to recognize every activity category regardless of its prevalence in the collected data. Here, $\mathcal{C}$ denotes the number of activity classes, precision is defined as $\frac{\textrm{TP}}{\textrm{TP}+\textrm{FP}}$, and recall corresponds to $\frac{\textrm{TP}}{\textrm{TP}+\textrm{FN}}$, where $\textrm{TP}$, $\textrm{FP}$, and $\textrm{FN}$ respectively refer to the number of true positives, false positives and false negatives.
\begin{table}
\centering
\caption{A summary of hyper-parameter values selected per dataset. All other hyper-parameters were kept constant across all datasets.}\label{sa_tab:params}
\resizebox{0.6\columnwidth}{!}{%
\begin{tabular}{lcccc}
Hyper-parameter & Opportunity & PAMAP2 & Skoda & Hospital \\
\toprule
\toprule
Dropout ratio $p_{\textrm{feat}}$ & 0.5 & 0.9 & 0.5 & 0.5\\
Dropout ratio $p_{\textrm{cls}}$ & 0.5 & 0.5 & 0.0 & 0.5\\
Weighting coefficient $\gamma$ & $\textrm{3}\times{\textrm{10}}^{\textrm{-4}}$ & $\textrm{3}\times{\textrm{10}}^{\textrm{-3}}$ & $\textrm{3}\times{\textrm{10}}^{\textrm{-1}}$ & $\textrm{3}\times{\textrm{10}}^{\textrm{-1}}$ \\
\toprule
\end{tabular}%
}
\end{table}
\subsection{Implementation Details}
We implement our experiments using Pytorch~\cite{pytorch}. Our network is trained end-to-end for 300 epochs by back-propagating the gradients of the loss function based on mini-batches of size 256 and in accordance with the Adam~\cite{adam} update rule. The learning rate is set to $\textrm{10}^{\textrm{-3}}$ and decayed every 10 epochs by a factor of 0.9. For \textit{mixup} augmentation, we fix $\alpha$=0.8. All these hyper-parameters are kept constant across all datasets. For each dataset, we choose a dropout probability $p\in$\{0, 0.25, 0.5, 0.75, 0.9\} for the refined feature-maps ($p_{\textrm{feat}}$) and the feature vectors fed to the classifier ($p_{\textrm{cls}}$), and select the center-loss weighting coefficient $\gamma\in\textrm{3}\times$\{$\textrm{10}^{\textrm{-4}},\textrm{10}^{\textrm{-3}},\textrm{10}^{\textrm{-2}},\textrm{10}^{\textrm{-1}}$\}, as summarized in Table \ref{sa_tab:params}.
\subsection{Comparisons with the State-of-the-Art}\label{sa_sec:exp_comp}
\begin{table*}[t]
\centering
\caption{A comparison of sample-wise activity recognition performance based on class-averaged f1-scores on the holdout test sequences. The baseline results are quoted from \protect\cite{ensemble,attention}, except for (*) where the published code is used with our evaluation protocol.}\label{sa_tab:soa}
\begin{tabular}{lcccc}
HAR Model & Opportunity & PAMAP2 & Skoda & Hospital* \\
\toprule \toprule
LSTM Learner Baseline \cite{ensemble} & 65.9 & 75.6 & 90.4 & 62.7 \\
DeepConvLSTM \cite{deepconvlstm} & 67.2 & 74.8 & 91.2 & 62.8\\
b-LSTM-S \cite{bilstm} & 68.4 & 83.8 & 92.1 & 63.6\\
Dense Labeling \cite{fcn}* & 62.4 & 85.4 & 91.6 & 62.9 \\
Att. Model \cite{attention} & 70.7 & 87.5 & 91.3 & 64.1 \\
\toprule
\textbf{Ours} & \textbf{74.6} & \textbf{90.8} & \textbf{92.8} & \textbf{66.6} \\
\textbf{(Improvement over Runner-up)} & \textbf{(5.52\%) } & \textbf{(3.77\%)} & \textbf{(0.76\%)} & \textbf{(3.9\%)}
\end{tabular}%
\end{table*}
\begin{figure*}[tb]
\centering
\subfloat{\includegraphics[width=0.45\textwidth]{opp-eps-converted-to.pdf}}%
\subfloat{\includegraphics[width=0.43\textwidth]{pamap2-eps-converted-to.pdf}}\\
\subfloat{\includegraphics[width=0.46\textwidth]{skoda-eps-converted-to.pdf}}%
\subfloat{\includegraphics[width=0.39\textwidth]{hospital-eps-converted-to.pdf}}%
\caption{The confusion matrices highlighting the class-specific recognition performance for the testing splits of Opportunity, PAMAP2, Skoda, and Hospital HAR datasets. The vertical axis represents the ground-truth activity categories and the horizontal axis denotes the predicted activities.}
\label{sa_fig:cm}%
\end{figure*}
\subsubsection{Classification Measure.}
We compare our proposed framework against state-of-the-art HAR models on four standard benchmarks in Table \ref{sa_tab:soa}. As elucidated in Section \ref{sa_sec:eval}, every baseline generates sample-wise predictions on the entire holdout test sequence and the performance is judged based on the acquired class-averaged f1-score ($\textrm{F}_{m}$).
In Table \ref{sa_tab:soa}, we can see that the elements we introduced into our framework consistently yield significant recognition improvements over the state-of-the-art models. Interestingly, we observe the highest performance gain of 5.52\% on the Opportunity dataset characterized by $i$) the largest number of incorporated sensor channels; $ii$) the greatest diversity of the actions to recognize; and $iii$) the highest ratio of class imbalance. Our results highlight the significant contribution made by the integrated components in dealing with challenging activity recognition tasks. Notably, our framework still achieves for a moderate performance improvement on the \textit{performance saturated}~\cite{attention} Skoda dataset.
For further insights, we summarize the class-specific recognition results from our model by presenting confusion matrices for the four recognition tasks in Fig.~\ref{sa_fig:cm}. We can see that for Opportunity and Skoda datasets with the inclusion of a \texttt{Null} class in the annotations, most of the confusions occur in distinguishing between the ambiguous \texttt{Null} class and the activities of interest. This can be understood since the \texttt{Null} class represents an infinite number of irrelevant activity data for the HAR problem in hand; thus, explicitly modeling this unknown space is a difficult problem.
\subsubsection{Misalignment Measure}
In addition to the reported classification metrics, we further report on the explicitly designed misalignment measures of \textit{overfill/underfill, insertion,} and \textit{deletion}~\cite{ward} and provide comparisons with the state-of-the-art HAR model~\cite{attention} in Table \ref{sa_tab:misalignment}. These metrics characterize \textit{continuous} activity recognition performance and provide finer details on temporal prediction misalignment with respect to ground truth. Specifically:
\begin{itemize}
\item \textit{Overfill} and \textit{Underfill} indicate errors when the predicted start or end time of an activity are earlier or later than the ground-truth timings.
\item \textit{Insertion} errors refer to incorrectly predicting an activity when there is \texttt{Null} activity.
\item \textit{Deletion} represents wrongly predicting \texttt{Null} class when an activity exists.
\end{itemize}
Since some measures require the existence of \texttt{Null} class by definition, we report results on Opportunity and Skoda datasets. The quantitative results in Table \ref{sa_tab:misalignment} indicate the improved capability of our model to predict a continuous sequence of activity labels that more accurately aligns with ground-truth timings and better recognizes existence or absence of activities of interest.
Further, we visualize fragments of sensor recordings from these datasets in Fig. \ref{sa_fig:sequence} for qualitative assessment. The Skoda dataset includes repetitive execution of quality check gestures while the Opportunity dataset is characterized by short duration and sporadic activities. We present the ground-truth annotations (top rows), our model's softmax output probabilities (last rows) and the binarized sequence of predictions (middle rows) obtained after applying argmax operation on the soft scores for each time-step. At every time-step, we color-code and plot the output class probabilities for each activity category, where we observe a strong correspondence between the ground-truth annotations, activity duration and the predicted activity scores.
\begin{table}
\centering
\caption{Misalignment measures comparison. (*) denotes the best performing state-of-the-art recognition model \protect\cite{attention} according to Table \ref{sa_tab:soa}.}
\label{sa_tab:misalignment}%
\resizebox{0.5\textwidth}{!}{%
\begin{tabular}{lcc|cc}
& \multicolumn{2}{c}{Opportunity} & \multicolumn{2}{c}{Skoda} \\
Alignment Measures & Ours & SoA* & Ours & SoA* \\
\toprule
\toprule
Deletion ($\downarrow$) &\textbf{0.62} & 0.69 &\textbf{0.04} &\textbf{0.04} \\
Insertion ($\downarrow$) &\textbf{2.87} & 3.34 &\textbf{2.01} & 3.34 \\
Underfill/Overfill ($\downarrow$) &\textbf{3.71} & 4.15 &5.33 & \textbf{5.17} \\
True Positives ($\uparrow$) &\textbf{92.8} & 91.82 &\textbf{92.62} &91.45 \\
\end{tabular}%
}
\end{table}
\begin{figure*}[t]%
\centering
\subfloat[Opportunity Dataset]{\includegraphics[width=\textwidth]{sequence_opp.pdf}}%
\subfloat[Skoda Dataset]{\includegraphics[width=\textwidth]{sequence_skoda.pdf}}
\caption{A visualization of our networks' predictions on the holdout test fragments. Our proposed HAR model accurately localizes and classifies short duration gestures embodied in sequences of sensor signals captured by wearables. We visualize the model's predictions against the ground-truth annotations for sequence fragments of Opportunity and Skoda datasets which include a Null class label representing activities of non-interest.}
\label{sa_fig:sequence}%
\end{figure*}
\begin{table}
\centering
\caption{We investigate the contribution of integrated modules by conducting an ablation study on the Opportunity dataset.}\label{sa_tab:ablation}
\resizebox{0.5\textwidth}{!}{%
\begin{tabular}{lc}
HAR Model & $\textrm{F}_{m}$ \\
\toprule \toprule
DeepConvLSTM Baseline
& 67.2 \\
Ours (mixup)
& 70.7 \\
Ours (mixup + CenterLoss)
& 72.2 \\
Ours (mixup + AGE)
& 71.7 \\
Ours (mixup + CIE)
& 73.0 \\
Ours (mixup + CenterLoss + AGE)
& 72.3 \\
Ours (mixup + CenterLoss + CIE )
& 73.2 \\
Ours (mixup + CIE + AGE)
& 74.0 \\
\toprule
\textbf{Ours (mixup + CenterLoss + CIE + AGE ) } & \textbf{74.6}
\end{tabular}%
}
\end{table}
\subsection{Ablation Studies and Insights} \label{sa_sec:ablation}
Given that our proposed HAR model integrates several key ideas into a single framework, we conduct an ablation study on the Opportunity dataset to understand the contribution made by the various components for the human activity recognition task in Table~\ref{sa_tab:ablation}. For each ablated experiment, we remove specific modules of our framework and as a reference we include DeepConvLSTM---the backbone of our network as illustrated in Fig.~\ref{sa_fig:arch}.
Unsurprisingly, removing any component handicaps the HAR model and reduces performance (to 67.2\%---see DeepConvLSTM baseline performance) while incorporating all components together yields the highest performing HAR model (74.6\%---see \textsf{mixup+CenterLoss+CIE+AGE}).
Notably, the effectiveness of time-series data augmentation in regularizing HAR models can be realized as \textsf{mixup} alone results in a significant relative improvement of 5.2\% over the DeepConvLSTM Baseline (from 67.2\% to 70.7\%). The virtual multi-channel time-series data attained through in-between sample linear interpolations expand the training data and effectively improve the generalization of learned activity features to unseen test sequences.
As hypothesized, encouraging minimal intra-class variability of representations with \textit{center-loss} consistently improves the recognition performance for activities (\textsf{mixup+CenterLoss}). In addition, while both \textit{CIE} and \textit{AGE} modules allow learning better representations of activities reflected by the enhanced metrics for \textsf{mixup+CIE+AGE} compared to \textsf{mixup} (4.7\% relative improvement), we observe a larger performance gain when incorporating \textit{CIE} module as compared with \textit{AGE}; the former encodes the cross-channel sensor interactions with self-attention while the latter learns the relevance of time-steps with temporal attention. Presumably this is due to the fact that within the Opportunity challenge setup, the sequence of representations fed to the GRU is quite short in length (\textit{i.e.}, T=8) and therefore, the last hidden state alone captures most of the information relevant to the activity. In order to verify this, we extract the learned attention scores $\beta_t$ corresponding to the hidden states $(\mat{h}_t)_{t=1}^{\textrm{T}=8}$ of our GRU encoder and present an illustration for every activity category of Opportunity dataset in Fig.~\ref{sa_fig:ta}. In line with the observations made in \cite{attention}, the recurrent neural network progressively becomes more informed about the activity and thus, proportionally places higher attention on the few last hidden states with the last state dominating the attendance.
\begin{figure}[t]
\centering
\includegraphics[width=0.9\columnwidth]{temporal-eps-converted-to.pdf}
\caption{A visualization of discovered temporal attentions by our AGE module. The vertical axis represents the normalized attention scores and the horizontal axis denotes hidden states $(\mat{h}_t)_{t=1}^{\textrm{T}=8}$ of our GRU encoder.}
\label{sa_fig:ta}
\end{figure}
\begin{figure}[t]
\centering
\includegraphics[width=0.8\columnwidth]{sa_2.pdf}
\caption{A visualization of learned self-attention correlations by our CIE module. (a) Subject engaged in two activities, (b) discovered cross-channel correlations by our model selected for \textit{Right-hand used for} \texttt{drinking from cup} (dark shaded marks along the rows highlighted in green) and \textit{Upper-body bent during} \texttt{cleaning table} (dark shaded marks along the rows highlighted in blue) as shown in video snapshots recorded during the data collection process and shown in (a), and (c) highly attended sensor locations for each activity (color-coded) in the Opportunity dataset.}
\label{sa_fig:sa}
\end{figure}
On the other hand, we observed exploiting latent channel interactions to significantly improve activity representations as highlighted in ablation results in Table~\ref{sa_tab:ablation}. To visually explain the learned self-attention correlations from our proposed cross-channel encoder, we graph two segments associated with activity classes of \texttt{drinking from cup} and \texttt{cleaning table}. The CIE module consumes an input sequence and generates a normalized score matrix of size D$\times$D, corresponding to the attention between each pair of D=79 channels. In Fig.~\ref{sa_fig:sa}, we present the normalized self-attention scores, $\mat{a}\in\mathbb{R}^{\textrm{79}\times\textrm{79}}$ (attained from softmax operation) in Eq. \ref{sa_eq:att}, where each column in the attention matrix indicates the extent that a particular sensor channel attends to available sensor channels.
We observe a clear and meaningful focus on a subset of channels vital to the recognition of activities indicated by dark rows in the matrices. For example, we notice high attendance: \textit{i}) to the inertial measurement units (IMUs) on the right arm when \textit{right hand is being used for} \texttt{drinking from cup}; and \textit{ii}) to the IMUs placed on the back and left-upper arm when \textit{upper-body is bent during} \texttt{cleaning table}. Thus, the explicit modeling of sensor channel interactions not only leads to improved recognition performance as substantiated by our ablation study in Table~\ref{sa_tab:ablation}, but also facilitates visual explanation through interpretable scores.
\section{Introduction}\label{sa_sec:intro}
Wearable sensors provide an infrastructure-less multi-modal sensing method. Current trends point to a pervasive integration into our lives with wearables providing the basis for wellness and healthcare applications from rehabilitation, caring for a growing older population to improving human performance~\cite{sparsesense,mannini2017activity,Govercin2010UserReqFallDetect,healthapp,pd,roberto2018ponealarms,health1,health2,health3,health4,health5}. Fundamental to these applications is our ability to automatically and accurately recognize human activities from often tiny sensors embedded in wearables.
Wearables capture individuals' activity dynamics by continuously recording measurements through different sensor channels over time and generate \textit{multi-channel time-series} data streams. Consequently, the problem of human activity recognition (HAR) with wearables involves temporal localization and classification of actions embedded in the generated sequences. Adoption of deep neural networks for HAR has created pipelines for end-to-end learning of activity recognition models yielding state-of-the-art (SoA) performance \cite{deepconvlstm,bilstm,fcn,attention}.
\subsection{Problem and Motivations}
Despite progress towards end-to-end deep learning architectures for achieving state-of-the-art performance on HAR problems, we uncover key under explored dimensions with significant potential for improving the performance of the state-of-the-art frameworks:
\begin{itemize}
\item HAR data acquisition often involves recording of motion measurements over number of sensors and channels. Therefore, we can expect the capability of different sensor modalities and channels to capture and encode some activities better than others whilst having complex interactions between sensors, channels and activities. Thus, we hypothesize that learning to exploit the relationships between multi-channel sensor modalities and specific activities can contribute to learning enriched activity representations---\textit{this insight remains unstudied}.
\item Human actions, for example walking and walking up-stairs, exhibit significant intra-class variability and inter-class similarities. This suggests imposing optimization objectives for training that not only ensure class separability but also encourage compactness in the established feature space. However, \textit{the commonly adopted cross-entropy loss function does not jointly accommodate both objectives}.
\item Due to the laborious process of collecting annotated sequences with wearables, sensor HAR datasets are often small in size. While expanding training data with virtual samples has proved beneficial in achieving better generalization performance for computer vision tasks, \textit{data-agnostic augmentation of multi-modal sensor data streams remains less explored, while data augmentation in general remains under-utilized for HAR}.
\end{itemize}
\subsection{Our Contributions}
\begin{figure*}[tb]
\centering
\includegraphics[width=\linewidth]{arch_10.pdf}
\caption{An overview of our proposed HAR framework}
\label{sa_fig:arch}
\end{figure*}
Motivated by the opportunities to further HAR research, our \textit{key contribution} is to propose a \textit{new HAR framework} built upon multiple architectural elements and demonstrate its capability to realize new state-of-the-art performance that generalizes across multiple diverse wearable sensor datasets. We illustrate our framework in Fig.~\ref{sa_fig:arch} and summarize our key contributions below:
\begin{enumerate}
\item We propose and design a \textit{cross-channel interaction encoder} to incorporate a self-attention mechanism to learn to exploit the different capabilities of sensor modalities and latent interactions between multiple sensor channels capturing and encoding activities. The encoder module captures latent correlations between multi-sensor channels to generate self-attention feature maps to enrich the convolutional feature representations (\textbf{Section~\ref{sa_sec:cie}} and \textbf{Fig.~\ref{sa_fig:sa}}). Subsequently, we enhance this sequence of enriched features by an \textit{attentional GRU encoder} to capture the relevant temporal context (\textbf{Section~\ref{sa_sec:age}}).
\item In recognizing the intra-class variations of HAR activities, we incorporate the \textit{center-loss criterion} into our framework to encourage minimal intra-class representation differences whilst maximising inter-class differences to achieve more discriminative features (\textbf{Section~\ref{sa_sec:centerloss}}).
\item In recognizing the difficulty of multi-modal sensor data augmentation and the general under-utility of data augmentation methods in wearable HAR problems; we investigate and show the effectiveness and seamless integration of the recent data-agnostic \textit{mixup} method for multi-modal sensor data augmentation (\textbf{Section~\ref{sa_sec:mixup}}).
\item Under a unified evaluation protocol, our proposed framework achieves significant improvements against the state-of-the-art on four diverse HAR benchmarks and, thus, highlights the effectiveness and generalizability of our framework (\textbf{Section~\ref{sa_sec:exp_comp}}). Further, we share our insights through extensive quantitative and qualitative results as well as an ablation study to comprehensively demonstrate the contributions made by the architectural elements in our new HAR framework (\textbf{Section~\ref{sa_sec:ablation}}).
\end{enumerate}
\section{Our Proposed HAR Framework}\label{sa_sec:method}
The goal is to develop an end-to-end deep HAR model that directly consumes raw sensory data captured by wearables and seamlessly outputs precise activity classification decisions. In our framework, a network composed of 1D convolutional layers serves as the backbone feature extractor in order to automatically extract an initial feature representation for each sensory segment. Subsequently, we propose a two-staged refinement process to enrich the initial feature representations prior to classification that allows the model to $i$) effectively uncover and encode the underlying sensor channel interactions at each time-step, and $ii$) learn the relevant temporal context within the sequence of refined representations. Moreover, we encourage intra-class compactness of representations with center-loss while regularizing the network with mixup data augmentation during training. In what follows, we elaborate on the components of our framework, illustrated in Fig. \ref{sa_fig:arch}.
\subsection{1D Convolutional Backbone}
Following the sliding window segmentation, the input to the network is a slice of the captured time-series data $x\in\mathbb{R}^{\textrm{D}\times \textrm{W}}$, where $\textrm{D}$ denotes the number of sensor channels used for data acquisition and $\textrm{W}$ represents the choice for the window duration. For automatic feature extraction, the input is then processed by a convolutional backbone operating along the temporal dimension. Given the 1D structure of the adopted filters, progressively more abstract temporal representations are learned from nearby samples without fusing features in-between different sensor channels. Ultimately, the backbone yields a feature representation $\mat{x}\in\mathbb{R}^{\textrm{C}\times \textrm{D} \times \textrm{T}}$, where in each of the $\textrm{C}$ feature maps, the sensor channel dimension $\textrm{D}$ is preserved while the temporal resolution is down-sampled to $\textrm{T}$. Without loss of generality, in this paper we employ the convolutional layers of a state-of-the-art HAR model \cite{deepconvlstm} as the backbone feature extractor; the input segment is successively processed by four layers, each utilizing 64 one-dimensional filters of size 5 along the temporal axis with ReLU non-linearities.
\subsection{Cross-Channel Interaction Encoder (CIE)}\label{sa_sec:cie}
Accurate realization of fine-grained human actions using wearables is often associated with utilizing multitude of on-body sensing devices that capture activity data across multiple channels. Measurements captured by different sensor channels provide different views of the same undergoing activity and are thus, inherently binded together in an unobservable latent space. Accordingly, we seek to design an end-to-end trainable module that takes as input the initial convolutional feature-maps at each time-step, learns the interactions between any two sensor channels within the feature-maps, and leverages this overlooked source of information to enrich the sensory feature representations for HAR.
Motivated by the emerging successful applications of self-attention \cite{attentionis,nonlocal,selfgan} in capturing global dependencies by computing relations at any two positions of the input, here we design a \textit{Cross-Channel Interaction Encoder (CIE)} that adopts self-attention mechanism to effectively process the initial feature representations and uncover the latent channel interactions. To this end, we first compute the normalized correlations across all pairs of sensor channel features $\mat{x}_{t}^{d}$ and $\mat{x}_{t}^{d^\prime}$ using the embedded Gaussian function at each time-step $t$,
\begin{equation}\label{sa_eq:att}
\mat{a}_{t}^{d,d^{\prime}} = \frac{\exp\Big(f(\mat{x}_{t}^{d})^{\intercal}g(\mat{x}_{t}^{d^\prime})\Big)}{\sum_{d^\prime=1}^{\textrm{D}}\exp\Big(f(\mat{x}_{t}^{d})^{\intercal}g(\mat{x}_{t}^{d^{\prime}})\Big)},
\end{equation}
where $\mat{a}_{t}^{d,d^{\prime}}$ indicates the attendance of our model to the features of sensor channel $d^\prime$ when refining representations for sensor channel $d$. Subsequently, the extracted correlations are leveraged in order to compute the response for the $d^{\textrm{th}}$ sensor channel features $\mat{x}_t^d\in\mathbb{R}^{\textrm{C}}$ and generate the corresponding self-attention feature-maps $\mat{o}_{t}^{d}$ at each time-step
\begin{equation}
\mat{o}_{t}^{d} = v\Big(\sum_{d^\prime=1}^{\textrm{D}} \mat{a}_{t}^{d,d^{\prime}} h(\mat{x}_{t}^{d^\prime})\Big).
\end{equation}
Technically, the self-attention in the CIE module functions as a non-local operation which computes the response for sensor channel $d$ at each time-step by attending to all present sensor channels' representations in the feature-maps at the same time-step. In the above, $f$, $g$, $h$, and $v$ all represent linear embeddings with learnable weight matrices ($\in\mathbb{R}^{\textrm{C}\times\textrm{C}}$) that project feature representations into new embedding spaces where computations are carried out. Having obtained the self-attention feature-maps, the initial feature-maps are then added back via a residual link (indicated by $\bigoplus$ in Fig. \ref{sa_fig:arch}) to encode the interactions and generate the refined feature representations $\mat{r}_t$,
\begin{equation}
\mat{r}_t^{d} = \mat{o}_{t}^{d}+\mat{x}_t^{d}.
\end{equation}
With the residual connection in place, the model can flexibly decide to use or discard the correlation information. During training, the HAR model leverages the CIE module to capture the interactions between different sensor channels. The discovered correlations are encoded inside the self-attention weights and leveraged at inference time to help support the model's predictions.
\subsection{Attentional GRU Encoder (AGE)} \label{sa_sec:age}
As a result of employing the CIE module, the feature-maps generated at each time-step are now contextualized with the underlying cross-channel interactions. As shown in Fig. \ref{sa_fig:arch}, we vectorize these representations at each time-step to obtain a sequence of refined feature vectors $(\mat{r}_t\in\mathbb{R}^{\textrm{CD}})_{t=1}^{\textrm{T}}$ ready for sequence modeling. Given that not all time-steps equally contribute in recognition of the undergoing activities, it is crucial to learn the relevance of each feature vector in the sequence when representing activity categories. In this regard, applying attention layers to model the relevant temporal context of activities has proved beneficial in recent HAR studies \cite{attention}. Adopting a similar approach, we utilize a 2-layer \textit{attentional GRU Encoder (AGE)} to process the sequence of refined representations and learn soft attention weights for the generated hidden states $(\mat{h}_t)_{t=1}^{\textrm{T}}$. In the absence of attention mechanism in the temporal domain, classification decision would only be based on the last hidden state achieved after observing the entire sequence. By contrast, empowering the GRU encoder with attention alleviates the burden on the last hidden state and instead, allows learning a holistic summary $\mat{z}$ that takes into account the relative importance of the time-steps
\begin{equation}
\mat{z} = \sum_{t}\beta_t\mat{h}_{t},
\end{equation}
where $\beta_t$ denotes the computed attention weight for time-step $t$. Technically, attention values are obtained by first mapping each hidden state into a single score with a linear layer and then normalizing these scores across the time-steps with a softmax function.
\subsection{Center Loss Augmented Objective} \label{sa_sec:centerloss}
Intra-class variability and inter-class similarity are two fundamental challenges of HAR with wearables. The former phenomena occurs since different individuals may execute the same activity differently while the latter challenge arises when different classes of activities reflect very similar sensor patterns. To counter these challenges, the training objective should encourage the model to learn discriminative activity representations; \textit{i.e.}, representations that exhibit large inter-class differences as well as minimized intra-class variations.
Existing HAR architectures solely rely on the supervision signal provided by the cross-entropy loss during their training phase. While optimizing for this criteria directs the training process towards yielding inter-class separable activity features, it does not explicitly encourage learning intra-class compact representations. To boost the discriminative power of the deep activity features within the learned latent space, we propose to incorporate center-loss \cite{centerloss} for training our HAR model. The auxiliary supervision signal provided by center-loss penalizes the distances between activity representations and their corresponding class centers and thus, reduces intra-class feature variations. Formally, center-loss is defined as
\begin{equation}
\mathcal{L}_{c}=\frac{1}{2}\sum_{i=1}\|\mat{z}_{i}-\mat{c}_{y_i}\|^2_{2},
\label{sa_eq:loss_c}
\end{equation}
where $\mat{z}_i\in\mathbb{R}^\mathrm{z}$ denotes the deep representation for sensory segment $x_i$, and $\mat{c}_{y_i}\in\mathbb{R}^\mathrm{z}$ denotes the $y_i$th activity class center computed by averaging the features of the corresponding class. We enforce this criteria on the activity representations obtained from the penultimate layer of our network to effectively pull the deep features towards their class centers.
In each iteration of the training process, we leverage the joint supervision of cross-entropy loss together with center-loss to simultaneously update the network parameters and the class centers $\mat{c}_{y}$ in an end-to-end manner. Hence, the aggregated optimization objective is formulated as
\begin{equation}
\Theta^*=\arg\min_{\Theta}\mathcal{L}+\gamma\mathcal{L}_{\textrm{c}},
\label{eq:loss_all}
\end{equation}
where $\mathcal{L}$ represents the cross-entropy loss, $\gamma$ is the balancing coefficient between the two loss functions, and $\Theta$ denotes the collection of all trainable parameters.
\begin{figure*}[tb]
\centering
\includegraphics[width=0.6\linewidth]{mixup.pdf}
\caption{We leverage mixup data augmentation technique to generate virtual sequences during training. We interpolate in-between samples. Here, we visualize (a) a sequence of sensor data from the training split corresponding to the \texttt{lying} activity and its one-hot encoded label representation, (b) a training sensor data segment corresponding to the \texttt{walking} activity, and (c) a \textit{virtual} or generated sequence and its target label according to Eq.~\ref{eq:mixup} with a drawn $\lambda$ value of 0.64 (sampled from a Beta distribution). The visualized data corresponds to a subset of sensor channels in the PAMAP2 dataset~\cite{pamap2}.}
\label{sa_fig:mixup}
\end{figure*}
\subsection{Mixup Data Augmentation for HAR}\label{sa_sec:mixup}
Due to the laborious task of collecting annotated datasets from wearables, current HAR benchmarks are characterized by their limited sizes. Therefore, introducing new modules and increasing the network parameters without employing effective regularization techniques, makes the model prone to overfitting and endangers its generalization. In this regard, while extending the training data with augmented samples achieved by \textit{e.g.} slight rotations, scaling, and cropping has consistently led to improved generalization performance for computer vision applications, these methods are not applicable to multi-channel time-series data captured by wearables.
In this paper, we explore the effectiveness of a recently proposed data-agnostic augmentation strategy, namely \textit{mixup} \cite{mixup}, for time-series data in order to regularize our deep HAR model. This approach has demonstrated its potential in significantly improving the generalization of deep neural networks by encouraging simple linear behavior in-between training data. In addition, unlike existing augmentation approaches that are dataset dependent and thus require domain expert knowledge for effective adoption, mixup strategy is domain independent and simple to apply. In essence, mixup yields augmented virtual example $(\tilde{x},\tilde{y})$ through linear interpolation of training example pairs $(x_i,y_i)$ and $(x_j,y_j)$,
\begin{equation}
\begin{aligned}
\tilde{x} &=\lambda x_i + (1-\lambda)x_j \\
\tilde{y} &=\lambda y_i + (1-\lambda)y_j,
\end{aligned}
\label{eq:mixup}
\end{equation}
where $\lambda$ sampled from a Beta($\alpha$, $\alpha$) distribution is the mixing-ratio and $\alpha$ is the mixup hyper-parameter controlling the strength of the interpolation. Notably, mixup augmentation allows efficient generation of virtual examples on-the-fly by randomly picking pairs from the same minibatch in each iteration. In this work, we adopt mixup strategy to augment the time-series segments in each mini-batch and train the model end-to-end with the generated samples. We visually explain the augmentation process with an example in Fig. \ref{sa_fig:mixup}, where a pair of randomly drawn training data sequences are linearly interpolated to yield a novel virtual sequence.
\section{Related Work}
Traditionally, the standard activity recognition pipeline for time-series sensory data involved sliding window segmentation, manual hand-crafted feature design, and subsequent activity classification with classical machine learning algorithms \cite{bulling}. Studies along these line have extensively explored statistical~\cite{Bao:2004,Ravi:2005}, basis transform~\cite{Huynh:2005}, multi-level~\cite{Zhang:2012}, and bio-mechanical features~\cite{wickramasinghe2017sequence} coupled with the employment of shallow classifiers including support vector machines \cite{Bulling:2012}, decision trees \cite{Bao:2004}, joint boosting \cite{Lara:2012}, graphical models~\cite{ShinmotoTorres:2017CRF}, and multi-layer perceptrons \cite{Randell:2000}. While this manually tuned procedure has successfully acquired satisfying results for relatively simple recognition tasks, its generalization performance is limited by heavy reliance on domain expert knowledge to engineer effective features.
Over the past years, the emerging paradigm of deep learning has presented unparalleled performance in various research areas including computer vision, natural language processing and speech recognition \cite{Lecun:2015}. When applied to sensor-based HAR, deep learning allows for automated end-to-end feature extraction and thus, largely alleviates the need for laborious feature engineering procedures. Motivated by these, sensor-based human activity recognition has witnessed extensive and successful adoption of deep learning paradigms in diverse HAR application settings \cite{nabil,misra,roy}.
Pioneering studies in the field have explored Restricted Boltzmann Machines (RBMs) for automatic representation learning \cite{rbm1,alsheikh,pd,rbm2}. Recently, deep architectures based on convolutional neural networks (CNNs) have been predominantly leveraged to automate feature extraction from sensor data streams while mutually enhancing activity classification performance \cite{cnnmobile,multichannelcnn,cnnphone,cnnnew}. These studies typically employ a cascaded hierarchy of 1D convolution filters along the temporal dimensions to capture salient activity features at progressively more abstract resolutions. The acquired latent features are ultimately unified and mapped into activity class scores using a fully connected network. Taking a different approach, \cite{fcn} presents an efficient dense labeling architecture based on fully convolutional networks that allows making activity predictions for every sample of a sliding window segment.
Another popular architecture design for HAR adopts deep recurrent neural networks (RNNs) that leverage memory cells to directly model temporal dependencies between subsequent sensor samples. In particular, \cite{bilstm} investigates forward and bi-directional long short-term memory (LSTM) networks, and \cite{ensemble} explores ensemble of diverse LSTM learners to exploit the sequential nature of sensor data. Combining these concepts, \cite{deepconvlstm} proposes DeepConvLSTM by pairing convolutional and recurrent networks in order to model the temporal correlations at a more abstract representation level. In \cite{attention}, the recurrent network of DeepConvLSTM is expanded with attention layers to model the relevant temporal context of sensor data. We refer readers to \cite{survey} for a curated list of recent HAR studies with deep neural networks.
Despite the great progress in the field, we can see that the unique opportunities we discussed in Section~\ref{sa_sec:intro} for learning from multi-channel time-series data generated by body-worn sensors remain. Conventionally, the feature-maps generated by convolutional layers are trivially vectorized and fed to fully connected layers or recurrent networks to ultimately produce classification outcomes. However, such manipulation of the convolutional feature-maps fails to explicitly capture and encode the inter-channel interactions that can aid accurate recognition of activities. Moreover, regardless of the architectural designs, cross-entropy loss constitutes the common choice for supervised training of deep HAR models. Yet, this optimization objective alone does not cater for the need to achieve minimal intra-class compactness of feature representations \cite{centerloss} necessary to counter the significant intra-class variability of human activities. In addition, while data augmentation has shown great potential for regularizing deep neural networks in the computer vision domain, the effectiveness of data augmentation for multi-channel time-series data captured by wearables remains under-utilized for HAR. | {'timestamp': '2020-07-15T02:21:33', 'yymm': '2007', 'arxiv_id': '2007.07172', 'language': 'en', 'url': 'https://arxiv.org/abs/2007.07172'} | arxiv |
\subsection{Multi-task~\xspace Learning Complements Adversarial Training}
\label{sec:adv-train}
\begin{table}
\begin{center}
\label{exp:city-sig}
\scriptsize
\centering
\begin{tabular}{cl|c|ccc|c|ccc}
\toprule
& & \multicolumn{4}{c|}{SemSeg mIoU Score $\uparrow$} & \multicolumn{4}{c}{Depth Abs Error $\downarrow$} \\
\midrule
& & Baseline & \multicolumn{3}{c|}{Multi-task~\xspace Learning} & Baseline & \multicolumn{3}{c}{Multi-task~\xspace Learning}\\
& Training Tasks $\xrightarrow{}$ & s & sd & sA & sdA & d & ds & dA & dAs \\
\midrule
& Clean & 41.95 & 43.27 & \textbf{43.65} & 43.26 & 2.24 & \textbf{2.07} & 2.15 & 2.15\\
\midrule
\parbox[t]{3mm}{\multirow{4}{*}{\rotatebox[origin=c]{90}{Attacks}}}
& PGD50 & 19.73 & \textbf{22.08} & 20.45 & 21.93 & 2.85& \textbf{2.61} & 2.75 & 2.67 \\
& PGD100 & 19.63 & \textbf{21.96} & 20.31 & 21.83 & 2.85 & \textbf{2.61} & 2.75 & 2.67 \\
& MIM100 & 19.54 & \textbf{21.89} & 20.20 & 21.74 & 2.85 & \textbf{2.61} & 2.75 & 2.67\\
& Houdini100 & 17.05 & \textbf{19.45} & 17.36 & 19.16 & - & - & - & -\\
\bottomrule
\end{tabular}
\end{center}
\caption{\small{Adversarial robustness of adversarial training models under $L_{\infty}=4$ bounded attacks on Cityscapes~\xspace. Each column is a model trained on a different combination of tasks. ``s,''``d,''and``A''denote segmentation, depth, and auto-encoder respectively. $\uparrow$ indicates the higher, the better. The $\downarrow$ indicates the lower, the better. \textbf{Bold} shows the best performance of the same task for each row. Multi-task~\xspace learning improves both the clean performance and robustness upon single-task learning. }
} \label{tab:city-adv-multi}
\vspace{-4mm}
\end{table}
We study whether multi-task~\xspace learning helps adversarial robust training. We use DRN-22 on the Cityscapes~\xspace dataset, and train both single-task and multi-task~\xspace models for 200 epoch under the same setup. The single-task model follows the standard adversarial training algorithm, where we train the model on the generated single-task (segmentation) adversarial attacks. For the multi-task~\xspace adversarial training, we train it on the generated multi-task~\xspace attack images for both semantic segmentation and the auxiliary task. Details are in the supplementary material.
Table \ref{tab:city-adv-multi} shows that multi-task~\xspace learning improves the robust performance of both clean examples and adversarial examples, where segmentation mIoU improves by 2.40 points and depth improves by 8.4\%.
\section{Conclusion}
The widening deployment of machine learning in real-world applications calls for versatile models that solve multiple tasks or produce high-dimensional outputs. Our theoretical analysis explains that versatile models are inherently more robust than models with fewer output dimensions. Our experiments on real-world datasets and common computer vision tasks measure improvements in adversarial robustness under attacks. Our work is the first to connect this vulnerability with multi-task~\xspace learning and hint towards a new direction of research to understand and mitigate this fragility.
{
\textbf{Acknowledgements:} This work was in part supported by Amazon Research Award; NSF grant CNS-15-64055; NSF-CCF 1845893; NSF-IIS 1850069; ONR grants N00014-16-1- 2263 and N00014-17-1-2788; a JP Morgan Faculty Research Award; a DiDi Faculty Research Award; a Google Cloud grant; an Amazon Web Services grant. The authors thank Vaggelis Atlidakis, Augustine Cha, D\'idac Sur\'is, Lovish Chum, Justin Wong, and Shunhua Jiang for valuable comments.
}
\section{Experiments} \label{sec:eval}
We validate our analysis with empirical results on the Cityscapes~\xspace and the Taskonomy~\xspace datasets. We evaluate the robustness of multi-task~\xspace models against two types of attack: multi-task~\xspace attack (Section \ref{sec:multi-attack}) and single-task attacks (Section \ref{sec:single-attack}). We also conduct multi-task~\xspace learning experiments on adversarial training and show that they are complementary (Section \ref{sec:adv-train}).
\subsection{Datasets}
\textbf{Cityscapes~\xspace.} The Cityscapes~\xspace dataset \cite{Cityscapes} consists of images of urban driving scenes. We study three tasks: semantic segmentation, depth estimation, and image reconstruction. We use the full resolution ($2048 \times 1024$) for analyzing pre-trained state-of-the-art models. We resize the image to $680 \times 340$ to train our single task (baseline) and multi-task~\xspace models.\footnote{We use the same dimension for baselines and ours during comparison because input dimension impacts robustness \cite{first-order}.}
\begin{figure}[t!]
\centering
\includegraphics[width=1\textwidth]{figures/multi-task-attack-ECCV.pdf}
\vspace{-3em}
\caption{We show model predictions on Cityscapes under multi-task~\xspace attack. The single-task segmentation model misclassifies the `road' as `sidewalk' under attack, while the multi-task~\xspace model can still segment it correctly. The multi-task~\xspace models are more robust than the single-task trained model.}
\label{fig:city-visualization-multi-attck}
\end{figure}
\begin{figure*}[th]
\centering
\includegraphics[width=1\textwidth]{figures/multi-depth-ECCV.pdf}
\caption{We show depth predictions of multi-task~\xspace models under multi-task~\xspace attacks. To emphasize the differences, we annotated the figure with red boxes where the errors are particularly noticeable. The multi-task~\xspace trained model outperforms the single-task trained model under attack.}
\label{fig:city-visualization-multi-attck-depth}
\vspace{-5mm}
\end{figure*}
\noindent \textbf{Taskonomy~\xspace.} The Taskonomy~\xspace dataset \cite{taskonomy} consists of images of indoor scenes. We train on up to 11 tasks: semantic segmentation (s), depth euclidean estimation (D), depth zbuffer estimation (d), normal (n), edge texture (e), edge occlusion (E), keypoints 2D (k), keypoints 3D (K), principal curvature (p), reshading (r), and image reconstruction (A). We use the ``tiny'' version of their dataset splits \cite{Taskbank-split}. We resize the images to $256 \times 256$.
\subsection{Attack Methods}
We evaluate the model robustness with $L_{\infty}$ bounded adversarial attacks, which is a standard evaluation metric for adversarial robustness \cite{madry}. We evaluate with four different attacks:
\textbf{FGSM:} We evaluate on the Fast Gradient Sign Method (FGSM) \cite{corr/GoodfellowSS14}, which generates adversarial examples ${\bf x}_{adv}$ by ${\bf x}_{adv}={\bf x}+\epsilon \cdot \textrm{sign}(\nabla_{\bf x} \ell(F({\bf x}),y))$. It is a single step, non-iterative attack.
\textbf{PGD:} Following the attack setup for segmentation in \cite{RobustSeg}, we use the widely used attack PGD (Iteratively FGSM with random start \cite{madry}), set the number of iterations of attacks to $\min(\epsilon + 4, \lceil{1.25\epsilon}\rceil)$ and step-size $\alpha=1$. We choose the $L_{\infty}$ bound $\epsilon$ from $\{1, 2, 4, 8, 16\}$ where noise is almost imperceptible. Under $\epsilon=4$, we also evaluate the robustness using PGD attacks with $\{10, 20, 50, 100\}$ steps, which is a stronger attack compared to 5 steps attack used in \cite{RobustSeg}.
\textbf{MIM:} We also evaluate on MIM attack \cite{mim}, which adds momentum to iterative attacks to escape local minima and won the NeurIPS 2017 Adversarial Attack Competition.
\textbf{Houdini:}
We evaluate the semantic segmentation task with the state-of-the-art Houdini attack \cite{houdini}, which directly attacks the evaluation metric, such as the non-differentiable mIoU criterion (mean Intersection over Union).
We do not use the DAG~\cite{DAG} attack for segmentation because it is an unrestricted attack without controlling $L_{\infty}$ bound. For all the iterative attacks, the step size is 1.
\begin{figure}[t]
\centering
\subfloat[Vulnerability (Dim)]{\label{subfig:AdvDim}\includegraphics[width=0.3\textwidth, trim={0cm 0 0cm 0},clip]{figures/gradientl2norm_output_dim.pdf}}
\subfloat[Robust Accuracy]{\label{subfig:AccDim}\includegraphics[width=0.3\textwidth, trim={0cm 0 0cm 0},clip]{figures/robust_accuracy_output_dim.pdf}}
\subfloat[Vulnerability (Task)]{\label{fig:taskonomy_grad_bar}\includegraphics[width=0.3\textwidth]{figures/taskonomy_grad_bar.pdf}}
\caption{\small{The effect of output dimensionality and number of tasks on adversarial robustness. We analyzed the pre-trained DRN model on Cityscapes~\xspace (a,b), and a multi-task~\xspace model trained on Taskonomy~\xspace (c). The x-axis of (a,b) represents the output dimensionality, the x-axis of (c) shows the combination of multiple tasks. The y-axis of (a,c) is the L2 norm of the joint gradient and is proportional to the model's adversarial vulnerability. The y-axis of (b) is classification accuracy. The robust performances for (c) are shown in Fig \ref{fig:multiattack-taskonomy}. Increasing the output dimensionality or number of tasks improves the model's robustness.}}
\label{fig:city-drn-output-dim}
\vspace{-1mm}
\end{figure}
\subsection{Multi-task~\xspace Models Against Multi-task~\xspace Attack}
\label{sec:multi-attack}
\textbf{High Output Dimensionality as Multi-task~\xspace.} Our experiment first studies the effect of a higher number of output dimensions on adversarial robustness. As an example, we use semantic segmentation. The experiment uses a pre-trained Dilated Residual Network (DRN-105) \cite{Yu2016, Yu2017} model on the Cityscapes~\xspace dataset. To obtain the given output dimensionality, we randomly select a subset of pixels from the model output. We mitigate the randomness of the sampling by averaging the results over 20 random samples. Random sampling is a general dimension reduction method, which preserves the correlation and structure for high dimensional, structured data \cite{MC}. Figure \ref{subfig:AdvDim} shows that the model's vulnerability (as measured by the norm of the gradients) decreases as the number of output dimension increases, which validates Theorem \ref{th:1}.
\begin{figure}[h!]
\centering
\vspace{-5mm}
\subfloat[Segmentation mIoU $\uparrow$]{\label{aasxs}\includegraphics[width=0.35\textwidth, trim={0cm 0cm 0cm 0cm},clip]{figures/Semantic_Segmentation_multitask_line.pdf}}
\subfloat[Depth Abs Error $\downarrow$]{\label{aasxs}\includegraphics[width=0.35\textwidth, trim={0cm 0 0cm 0},clip]{figures/Depth_multitask_line.pdf}}
\\
\subfloat[Edge Detection MSE $\downarrow$]{\label{aasxs}\includegraphics[width=0.35\textwidth, trim={0cm 0 0cm 0},clip]{figures/Edge_Detection_multitask_line.pdf}}
\subfloat[Keypoints MSE $\downarrow$]{\label{aasxs}\includegraphics[width=0.35\textwidth, trim={0cm 0 0cm 0},clip]{figures/Keypoints_multitask_line.pdf}}
\caption{\small{Adversarial robustness against multi-task~\xspace attack on Taskonomy~\xspace dataset. The x-axis is the attack strength, ranging from no attack (clean) to the strongest attack ($\epsilon=16$ PGD). For each subfigure, the y-axis shows the performance of one task under multi-task~\xspace attack. $\uparrow$ means the higher, the better. $\downarrow$ means the lower, the better. The multi-task~\xspace model names are in the legend, we refer to the task by their initials, e.g., `sde' means the model is trained on segmentation, depth, and edge simultaneously. The \textcolor{blue}{blue} line is the single-task baseline performance, the other lines are multi-task~\xspace performance. The figures show that it is hard to attack all the tasks in a multi-task~\xspace model simultaneously. Thus multi-task~\xspace models are more robust against multi-task~\xspace attacks.}}
\label{fig:multiattack-taskonomy}
\vspace{-4mm}
\end{figure}
Besides the norm of gradient, we measure the performance under FGSM \cite{corr/GoodfellowSS14} and PGD \cite{madry} adversarial attacks, and show that it improves as output dimensionality increases (Figure \ref{subfig:AccDim}). Notice when few pixels are selected, the robustness gains are faster. This is because with fewer pixels: (1) the marginal gain of the inverse function is larger; and (2) the select pixels are sparse and tend to be far away and uncorrelated to each other. The correlation between the output pixels compounds as more nearby pixels are selected, which slows down the improvements to robustness. The results demonstrate that models with higher output dimension/diversity are inherently more robust against adversarial attacks, consistent with the observation in \cite{RobustSeg, houdini} and our Theorem \ref{th:1}.
\noindent \textbf{Number of Tasks.} We now consider the case where the number of tasks increases, which is a second factor that increases output dimensionality. We evaluate the robustness of multi-task~\xspace models on the Cityscapes~\xspace and Taskonomy~\xspace datasets. We equally train all the tasks with the shared backbone architecture mentioned in Section \ref{sec:adv_setting}. On Cityscapes~\xspace, we use DRN-105 model as the architecture for encoder and decoder; on Taskonomy~\xspace, we use Resnet-18 \cite{taskonomy}. Each task has its own decoder. For the Cityscapes~\xspace dataset, we start with training only the semantic segmentation task, then add the depth estimation and input reconstruction task. For the Taskonomy~\xspace dataset, following the setup in \cite{multi-task-onomy}, we start with only semantic segmentation, and add depth estimation, normal, keypoints 2D, edge texture, and reshading tasks to the model one by one. In our figures and tables, we refer to these tasks by the task's first letter.
Figure \ref{fig:taskonomy_grad_bar} shows the L2 norm of the joint gradient for many tasks, which measures the adversarial vulnerability. Overall, as we add more tasks, the norm of the joint gradient decreases, indicating improvement to robustness \cite{first-order}. The only exception is the depth estimation task, which we believe is due to the large range of values (0 to $+\infty$) that its outputs take. Empirically, a larger output range leads to a larger loss, which implies a larger gradient value.
\begin{figure}[t]
\centering
\includegraphics[width=1\textwidth]{figures/seg-single-attack-eccv.pdf}
\caption{ \small{Performance of single-task attack for multi-task~\xspace models trained on Cityscapes. We show segmentation under attack for single-task and three multi-task~\xspace models. The multi-task~\xspace trained model out-performs the single-task trained model.}}
\label{fig:city-visualization-single-attack}
\vspace{-5mm}
\end{figure}
\begin{table}[b]
\begin{center}
\label{exp:city-sig}
\scriptsize
\centering
\begin{tabular}{l|c|cc}
\toprule
& Baseline & \multicolumn{2}{c}{Multi-task~\xspace}\\
Training Tasks & s & sd & sdA \\
\midrule
Clean SemSeg $\uparrow$ & 44.77 & \textbf{46.53} & 45.82 \\
PGD SemSeg $\uparrow$ & 15.75 & 16.01 & \textbf{16.36} \\
\bottomrule
\end{tabular}
\quad
\begin{tabular}{l|c|cc}
\toprule
& Baseline & \multicolumn{2}{c}{Multi-task~\xspace}\\
Training Tasks & d & sd & sdA \\
\midrule
Clean Depth $\downarrow$ & 1.82 & \textbf{1.780} & \underline{1.96} \\
PGD Depth $\downarrow$ & 6.81 & 6.08 & \textbf{5.81}\\
\bottomrule
\end{tabular}
\end{center}
\caption{\small{The models' performances under multi-task~\xspace PGD attack and clean images on Cityscapes~\xspace using DRN-D-105 \cite{Yu2017} . The \textbf{bold} demonstrate the better performance for each row, \underline{underline} shows inferior results of multi-task~\xspace learning. The results show that multi-task~\xspace models are overall more robust under multi-task~\xspace attack.
}} \label{tab:city-multi-attack-all}
\end{table}
We additionally measure the robust performance on different multi-task~\xspace models under multi-task~\xspace attacks. Following the setup in \cite{RobustSeg}, we enumerate the $\epsilon$ of the $L_{\infty}$ attack from 1 to 16. Figure \ref{fig:multiattack-taskonomy} shows the robustness of multi-task~\xspace models using Taskonomy~\xspace, where the adversarial robustness of multi-task~\xspace models are better than single-task models, even if the clean performance of multi-task~\xspace models may be lower.
We also observe some tasks gain more robustness compared to other tasks when they are attacked together, which suggests some tasks are inherently harder to attack. Overall, the attacker cannot simultaneously attack all the tasks successfully, which results in improved overall robustness of multi-task~\xspace models. In Table \ref{tab:city-multi-attack-all}, we observe the same improvement on Cityscapes~\xspace. Qualitative results are shown in Figure \ref{fig:city-visualization-multi-attck} and Figure \ref{fig:city-visualization-multi-attck-depth}. Please see the supplemental material for additional results.
\begin{table}[ht]
\begin{center}
\label{exp:city-sig}
\scriptsize
\centering
\begin{tabular}{cl|c|ccc|c|ccc}
\toprule
& & \multicolumn{4}{c|}{SemSeg mIoU Score $\uparrow$} & \multicolumn{4}{c}{Depth Abs Error $\downarrow$} \\
\midrule
& & Baseline & \multicolumn{3}{c|}{Multi-task~\xspace Learning} & Baseline & \multicolumn{3}{c}{Multi-task~\xspace Learning}\\
& Training Tasks $\xrightarrow{}$ & s & sd & sA & sdA & d & ds & dA & dAs \\
& $\lambda_a$ & & 0.001 & 0.001 & 0.001 & & 0.1 & 0.1 & 0.01 \\
\midrule
&Clean & 48.58 & 48.61 & \textbf{49.61} & \underline{48.19} &1.799 & \textbf{1.792} & \underline{1.823} & 1.798 \\
\midrule
\parbox[t]{3mm}{\multirow{7}{*}{\rotatebox[origin=c]{90}{Attacks}}}
&FGSM & 26.35 & \underline{26.28} & \textbf{26.79} & 26.71 &3.16 & 3.01& \textbf{3.00} & 3.24 \\
&PGD10 & 13.04& 13.64& \textbf{14.76} &14.48 &6.96& 6.15& \textbf{6.03}& 6.59 \\
&PGD20& 11.41& 11.98&\textbf{12.79}& 12.73 &8.81& \textbf{7.70} &7.64& 8.38 \\
&PGD50 & 10.49& 10.95& 11.68 & \textbf{11.86} &10.23& \textbf{9.07}& 9.12& 9.81 \\
&PGD100 & 10.15& 10.51& 11.22& \textbf{11.52} &10.8& \textbf{9.69}& 9.74& 10.41 \\
&MIM100 & 9.90 & 10.17& 10.93& \textbf{11.24} & 12.04 &\textbf{10.72}& 10.97& 11.69\\
&Houdini100 & 5.04 & 5.14 & \textbf{6.24} & 6.21 & - &- & -& -\\
\bottomrule
\end{tabular}
\end{center}
\caption{\small{Model's robust performance under $L_{\infty}=4$ bounded single-task attacks on Cityscapes~\xspace. Each column is a DRN-22 model trained on a different combination of tasks, where ``s,''``d,''and``A''denote segmentation, depth, and auto-encoder, respectively. $\uparrow$ means the higher, the better. $\downarrow$ means the lower, the better. \textbf{Bold} in each row, shows the best performance under the same attack. Multi-task~\xspace learning models out-perform single-task models except for the \underline{underlined} ones. While nearly maintaining the performance on clean examples, multi-task~\xspace models are consistently more robust under strong adversarial attacks. }
} \label{tab:city-single-attack}
\end{table}
\subsection{Multi-task~\xspace Models Against Single-Task Attacks}
\label{sec:single-attack}
Following the setup for multi-task~\xspace learning in \cite{luong2015multitaskshare, Liu_2019_MTLshare, lee2019MTLgeneralization}, we train the multi-task~\xspace models using a main task and auxiliary tasks, where we use $\lambda=1$ for the main task and $\lambda_a$ for the auxiliary tasks. We then evaluate the robustness of the main task under single-task attacks. On Cityscapes~\xspace, the main and the auxiliary tasks share 16 layers of an encoding backbone network. The decoding network for each individual task has 6 layers. For all the models, we train for 200 epochs. For adversarial robustness evaluation, we use strong attacks including PGD100 and MIM100 for attacking the segmentation accuracy\footnote{Suffixed number indicates number of steps for attack}, and use 100 steps Houdini \cite{houdini} to attack the non-differentiable mIoU of the Segmentation model directly. We do not use Houdini to attack the depth because the L1 loss for depth is differentiable and does not need any surrogate loss.
The results in Table \ref{tab:city-single-attack} show that multi-task~\xspace learning improves the segmentation mIoU by 1.2 points and the performance of depth estimation by 11\% under attack, while maintaining the performance on most of the clean examples. Qualitative results are in Figure \ref{fig:city-visualization-single-attack}.
\begin{figure}[h!]
\centering
\subfloat[Performance Under Attack]{\label{aasxs}\includegraphics[width=1.0\textwidth]{figures/heatmap-eccv-attack.pdf}}
\\
\subfloat[Performance on Clean Examples]{\label{aasxs}\includegraphics[width=1.0\textwidth]{figures/heatmap-eccv-clean.pdf}}
\caption{\small{We consider models trained on two tasks. In each matrix, the rows show the first training task and the testing task. The columns show the auxiliary training task. The first column without color shows the absolute value for the baseline model (single-task). The middle colored columns show the relative improvement of multi-task~\xspace models over the single-task model in percentage. The last colored column shows the average relative improvement. We show results for both (a) adversarial and (b) clean performance. Multi-task~\xspace learning improves the performance on clean examples for 70/110 cases, and the performance on adversarial examples for 90/110 cases. While multi-task~\xspace training does not always improve clean performance, we show multi-task~\xspace learning provides more gains for adversarial performance.}}
\label{fig:attack-matrix-taskonomy}
\vspace{-5mm}
\end{figure}
On the Taskonomy~\xspace dataset, we conduct experiments on 11 tasks. Following the setup in \cite{multi-task-onomy}, we use ResNet-18 \cite{ResNet} as the shared encoding network, where each individual task has its own prediction network using the encoded representation. We train single-task models for each of the 11 tasks as baselines. We train a total of 110 multi-task~\xspace models --- each main task combined with 10 different auxilliary tasks --- for 11 main tasks. We evaluate both the clean performance and adversarial performance. $\lambda_a$ is either 0.1 or 0.01 based on the tasks. We use PGD attacks bounded with $L_{\infty} = 4$ with 50 steps, where the step size is 1. The attack performance plateaus for more steps. Figure \ref{fig:attack-matrix-taskonomy} shows the performance of the main task on both clean and adversarial examples. While maintaining the performance on clean examples (average improvement of 4.7\%), multi-task~\xspace learning improves 90/110 the models' performance under attacks, by an average of 10.23\% relative improvement. Our results show that one major advantage of multi-task~\xspace learning, which to our knowledge is previously unknown, is that it improves the model's robustness under adversarial attacks.
\section{Introduction} \label{sec:intro}
\begin{figure}[t]
\centering
\includegraphics[width=1\textwidth]{figures/Fig1.pdf}
\caption{We find that multi-task~\xspace models are more robust against adversarial attacks. Training a model to solve multiple tasks improves the robustness when one task is attacked. The middle and right column show predictions for single-task and multi-task~\xspace models when one task is adversarially attacked.}
\label{fig:intro}
\end{figure}
Deep networks obtain high performance in many computer vision tasks \cite{ResNet, Yu2017,FCN,depth}, yet they remain brittle to adversarial examples. A large body of work has demonstrated that images with human-imperceptible noise \cite{madry,cw,mim,JSMA} can be crafted to cause the model to mispredict. This pervasiveness of adversarial examples exposes key limitations of deep networks, and hampers their deployment in safety-critical applications, such as autonomous driving.
A growing body of research has been dedicated to answering what causes deep networks to be fragile to adversarial examples and how to improve robustness \cite{first-order,notbugbutfeature,TLA,madry,ALP,feature_denoising,ensemble,DefenseGAN,parseval,intriguing}. The investigations center around two factors: the training data and the optimization procedure. For instance, more training data -- both labeled and unlabeled -- improves robustness \cite{moredata,unlabeled}. It has been theoretically shown that decreasing the input dimensionality of data improves robustness \cite{first-order}. Adversarial training \cite{madry} improves robustness by dynamically augmenting the training data using generated adversarial examples. Similarly, optimization procedures that regularize the learning specifically with robustness losses have been proposed \cite{deepdefense,parseval}. This body of work suggests that the fragility of deep networks may stem from the training data and optimization procedure.
In this paper, we pursue a new line of investigation: how learning on multiple tasks affects adversarial robustness.
While previous work shows that multi-task~\xspace learning can improve the performance of specific tasks \cite{multi-task-caruana, multi-task-onomy}, we show that it increases robustness too. See Figure \ref{fig:intro}. Unlike prior work that trades off performance between natural and adversarial examples \cite{robustness_vs_accuracy}, our work improves adversarial robustness while also maintaining performance on natural examples.
Using the first order vulnerability of neural networks \cite{first-order}, we theoretically show that increasing output dimensionality -- treating each output dimension as an individual task -- improves the robustness of the entire model. Perturbations needed to attack multiple output dimensions cancel each other out. We formally quantify and upper bound how much robustness a multi-task~\xspace model gains against a multi-task~\xspace attack with increasing output dimensionality.
We further empirically show that multi-task~\xspace learning improves the model robustness for two classes of attack: both when a single task is attacked or several tasks are simultaneously attacked.
We experiment with up to 11 vision tasks on two natural image datasets, Cityscapes~\xspace~\cite{Cityscapes} and Taskonomy~\xspace~\cite{taskonomy}.
When all tasks are under attack, multi-task~\xspace learning increases segmentation robustness by up to 7 points and reduces the error of other tasks up to 60\% over baselines.
We compare the robustness of a model trained for a main task with and without an auxiliary task. Results show that, when the main task is under attack, multi-task~\xspace learning improves segmentation overlap by up to 6 points and reduces the error of the other tasks by up to 23\%. Moreover, multi-task~\xspace training is a complementary defense to adversarial training, and it improves both the clean and adversarial performance of the state-of-the-art, adversarially trained, single-task models. Code is available at \url{https://github.com/columbia/MTRobust}.
Overall, our experiments show that multi-task~\xspace learning improves adversarial robustness while maintaining most of the the state-of-the-art single-task model performance. While defending against adversarial attacks remains an open problem, our results suggest that current deep networks are vulnerable partly because they are trained for too few tasks.
\section{Theoretical Analysis
\label{sec:theory}
We present theoretical insights into the robustness of multi-task~\xspace models. A prevalent formulation of multi-task~\xspace learning work uses shared backbone network with task-specific branches \cite{luong2015multitaskshare, Liu_2019_MTLshare, lee2019MTLgeneralization}. We denote the multi-task~\xspace predictor as $F$ and each individual task predictor as $F_c$. Prior work \cite{first-order} showed that the norm of gradients captures the vulnerability of the model. We thus measure the multi-task~\xspace models' vulnerability with the same metric. Since we are working with deep networks, we assume all the functions here are differentiable. Details of all proofs are in the supplementary material.
\begin{definition}
Given classifier $F$, input ${\bf x}$, output target ${\bf y}$, and loss $\mathcal{L}({\bf x}, {\bf y}) = \ell(F({\bf x}), {\bf y})$, the feasible adversarial examples lie in a $p$-norm bounded ball with radius $r$, $B({\bf x}, r) := \{{\bf x}_{adv}, ||{\bf x}_{adv}-{\bf x}||_p<r\}$. Then adversarial vulnerability of a classifier over the whole dataset is
\[\mathbb{E}_{{\bf x}} [\Delta \mathcal{L}({\bf x}, {\bf y}, r)] = \mathbb{E}_{{\bf x}} [\max_{||\delta||_p < r}{|\mathcal{L}({\bf x},{\bf y}) - \mathcal{L}({\bf x}+\delta,{\bf y})|}]\]
\end{definition}
\noindent $\Delta \mathcal{L}$ captures the maximum change of the output loss from arbitrary input change $\delta$ inside the $p$-norm ball. Intuitively, a robust model should have smaller change of the loss given any perturbation of the input. Given the adversarial noise is imperceptible, i.e., $r \rightarrow 0$, we can approximate $\Delta \mathcal{L}$ with a first-order Taylor expansion \cite{first-order}.
\begin{lemma}
For a given neural network $F$ that predicts multiple tasks, the adversarial vulnerability is
\[\mathbb{E}_{{\bf x}} [\Delta \mathcal{L}({\bf x}, {\bf y}, r)] \approx \mathbb{E}_{{\bf x}}\left[||\partial_{{\bf x}} \mathcal{L}_{all}({\bf x}, \overline{{\bf y}})||_q \right] \cdot ||\delta||_p \propto \mathbb{E}_{{\bf x}}\left[||\partial_{{\bf x}} \mathcal{L}_{all}({\bf x}, \overline{{\bf y}})||_q \right] \]
\end{lemma}
\noindent where $q$ is the dual norm of $p$, which satisfies $\frac{1}{p} + \frac{1}{q} = 1$ and $1 \leq p \leq \infty$. Without loss of generality, let $p=2$ and $q=2$. Note that from equation \ref{sec:joint}, we get $\mathcal{L}_{all}({\bf x}, \overline{{\bf y}}) = \sum_{c=1}^{M}{\frac{1}{M} \mathcal{L}_c({\bf x}, {\bf y}_c)}$. Thus we get the following equation:
\begin{equation}\label{equ:lamma_remark}
\begin{split}
\partial_{{\bf x}} \mathcal{L}_{all}({\bf x}, \overline{{\bf y}}) = \partial_{{\bf x}} \sum_{c=1}^{M}{\frac{1}{M} \mathcal{L}_c({\bf x}, {\bf y}_c) }
= \frac{1}{M} \sum_{c=1}^{M}{\partial_{{\bf x}} \mathcal{L}_c({\bf x}, {\bf y}_c) }
\end{split}
\end{equation}
We denote the gradient for task $c$ as ${\bf r}_c$, i.e., ${\bf r}_c = \partial_{{\bf x}}\mathcal{L}_c({\bf x}, {\bf y}_c)$. We propose the following theory for robustness of different numbers of randomly selected tasks.
\begin{theorem}\label{th:2}
\textbf{(Adversarial Vulnerability of Model for Multiple Correlated Tasks)}
If the selected output tasks are correlated with each other such that the covariance between the gradient of task $i$ and task $j$ is $\mathrm{Cov}({\bf r}_i, {\bf r}_j)$, and the gradient for each task is i.i.d. with zero mean (because the model is converged), then adversarial vulnerability of the given model is proportional to
\[\sqrt{\frac{1 + \frac{2}{M} \sum_{i=1}^{M} \sum_{j=1}^{i-1} \frac{\mathrm{Cov}({\bf r}_i, {\bf r}_j)}{\mathrm{Cov}({\bf r}_i, {\bf r}_i)}}{M}}\]
where $M$ is the number of output tasks selected.
\end{theorem}
The idea is that when we select more tasks as attack targets, the gradients for each of the individual tasks on average cancels out with each other. We define the joint gradient vector ${\bf R}$ as follows:
\begin{equation*}
{\bf R} = \partial_{{\bf x}} \mathcal{L}_{all}({\bf x}, \overline{{\bf y}}) = \frac{1}{M} \sum_{c=1}^{M}{\partial_{{\bf x}}\mathcal{L}_c({\bf x}, {\bf y}_c)}
\end{equation*}
The joint gradient is the sum of gradients from each individual task. We then obtain the expectation of the $L_2$ norm of the joint gradient:
\begin{align*}
&\mathbb{E}(\Vert {\bf R} \rVert_2^2) = \mathbb{E}\left[\lVert\frac{1}{M} \sum_{i=1}^M{{\bf r}_i}\rVert_2^2\right]
= \frac{1}{M^2}\mathbb{E}\left[\sum_{i=1}^M{\lVert {\bf r}_i \rVert^2} + 2 \sum_{i=1}^M{\sum_{j=1}^i{{\bf r}_i {\bf r}_j}}\right] \\
&= \frac{1}{M^2}\left(\sum_{i=1}^M\mathbb{E}[\mathrm{Cov}({\bf r}_i, {\bf r}_i)] + 2 \sum_{i=1}^M{\sum_{j=1}^i\mathbb{E}[\mathrm{Cov}({\bf r}_i, {\bf r}_j)]}\right)
\end{align*}
\noindent The last equation holds due to the ${\bf 0}$ mean assumption of the gradient. For further details of the proof, please see the supplementary material.
\begin{corollary}\label{th:1}
\textbf{(Adversarial Vulnerability of Model for Multiple Independent Tasks)}
If the output tasks selected are independent of each other, and the gradient for each task is i.i.d. with zero mean, then the adversarial vulnerability of given model is proportional to $\frac{1}{\sqrt{M}}$, where $M$ is the number of independent output tasks selected.
\end{corollary}
Based on the independence assumption, all covariances becomes zero. Thus Theorem \ref{th:1} can be simplified as:
\begin{equation}
\begin{split}
\mathbb{E}[\lVert \partial_{{\bf x}} \mathcal{L}_{all}({\bf x}, \overline{{\bf y}})\rVert_2^2] = \mathbb{E}(\lVert {\bf R} \rVert_2^2)
= \frac{1}{M}\mathbb{E}{\lVert {\bf r}_i \rVert^2} = \frac{\sigma^2}{M} \propto \frac{1}{M}
\end{split}{}
\end{equation}{}
\begin{remark}
By increasing the number of output tasks $M$, the first order vulnerability~\cite{first-order} of network decreases. In the ideal case, if the model has an infinite number of uncorrelated tasks, then it is impossible to find an adversarial examples that fools all the tasks.
\end{remark}
\begin{remark}
Theorem 1 studies the robustness for multiple \textbf{correlated} tasks, which is true for most computer vision tasks. The independent tasks assumption in Corollary 1 is a simplified, idealistic instance of Theorem 1 that upper-bounds the robustness of models under multi-task~\xspace attacks. Together, Theorem 1 and Corollary 1.1 demonstrate that unless the tasks are 100\% correlated (the same task), multiple tasks together are more robust than each individual one.
\end{remark}
Our theoretical analysis shows that more outputs, especially if they are less correlated, improve the model's robustness against multi-task~\xspace attacks. Past work shows that segmentation is inherently robust \cite{RobustSeg, houdini} compared to classification. Our analysis provides a formal explanation to this inherent robustness because a segmentation model can be viewed as a multi-task~\xspace model (one task per pixel).
\section{Adversarial Setting} \label{sec:adv_setting}
The goal of an adversary is to ``fool'' the target model by adding human-imperceptible perturbations to its input. We focus on untargeted attacks, which are harder to defend against than targeted attacks \cite{EvalALP}.
We classify adversarial attacks for a multi-task~\xspace prediction model into two categories: adversarial attacks that fool more than one task at once (multi-task~\xspace attacks), and adversarial attacks that fool a specific task (single-task attacks).
\subsection{Multi-task~\xspace Learning Objective}
\noindent
\textbf{Notations.} Let ${\bf x}$ denote an input example, and ${\bf y}_c$ denote the corresponding ground-truth label for task $c$. In this work, we focus on multi-task~\xspace learning with shared parameters \cite{ubernet,multi-task-onomy, luong2015multitaskshare, Liu_2019_MTLshare, lee2019MTLgeneralization}, where all the tasks share the same ``backbone network'' $F(\cdot)$ as a feature extractor with task-specific decoder networks $D_c(\cdot)$.
The task-specific loss is formulated as:
\begin{equation}
\mathcal{L}_c({\bf x}, {\bf y}_c) = \ell(D_c(F({\bf x})), {\bf y}_c),
\end{equation}
\noindent where $\ell$ is any appropriate loss function. For simplicity, we denote $({\bf y}_1, ..., {\bf y}_M)$ as $\overline{{\bf y}}$, where $M$ is the number of tasks. The total loss for multi-task~\xspace learning is a weighted sum of all the individual losses:
\begin{equation}\label{sec:joint}
\mathcal{L}_{all}({\bf x}, \overline{{\bf y}}) = \sum_{c=1}^{M}{\lambda_c \mathcal{L}_c({\bf x}, {\bf y}_c)}
\end{equation}
\noindent For the simplicity of theoretical analysis, we set $\lambda_c=\frac{1}{M}$ for all $c=1,..., M$, such that $\sum_{c=1}^M \lambda_c = 1$. In our experiments on real-world datasets, we will adjust the $\lambda_c$ accordingly, following standard practice \cite{multi-task-onomy, lee2019MTLgeneralization}.
\subsection{Adversarial Multi-task~\xspace Attack Objective}
The goal of a multi-task~\xspace attack is to change multiple output predictions together. For example, to fool an autonomous driving model, the attacker may need to deceive both the object classification and depth estimation tasks. Moreover, if we regard each output pixel of a semantic segmentation task as an individual task, adversarial attacks on segmentation models need to flip multiple output pixels, so we consider them as multi-task~\xspace attacks. We also consider other dense output tasks as a variant of multi-task~\xspace, such as depth estimation, keypoints estimation, and texture prediction.
In general, given an input example ${\bf x}$, the objective function for multi-task~\xspace attacks against models with multiple outputs is the following:
\begin{equation}
\begin{split}
\mathop{\rm argmax}_{{\bf x}_{adv}} \mathcal{L}_{all}({\bf x}_{adv}, \overline{{\bf y}}) \quad
\text{s.t.} \quad ||{\bf x}_{adv}-{\bf x}||_p \leq r
\end{split}
\end{equation}
where the attacker aims to maximize the joint loss function by finding small perturbations within a $p$-norm bounded distance $r$ of the input example. Intuitively, a multi-task~\xspace attack is not easy to perform because the attacker needs to optimize the perturbation to fool each individual task simultaneously. The robustness of the overall model can be a useful property - for instance, consider an autonomous-driving model trained for both classification and depth estimation. If either of the two tasks is attacked, the other can still be relied on to prevent accidents.
\subsection{Adversarial Single-Task Attack Objective}
In contrast to a multi-task~\xspace attack, a single-task attack focuses on a selected target task. Compared with attacking all tasks at once, this type of attack is more effective for the target task, since the perturbation can be designed solely for this task without being limited by other considerations. It is another realistic type of attack because some tasks are more important than the others for the attacker. For example, if the attacker successfully subverts the color prediction for a traffic light, the attacker may cause an accident even if the other tasks predict correctly.
The objective function for single-task attack is formulated as:
\begin{equation}
\begin{split}
\mathop{\rm argmax}_{{\bf x}_{adv}} \mathcal{L}_c({\bf x}_{adv}, {\bf y}_c), \text{s.t.} ||{\bf x}_{adv} - {\bf x}||_p \leq r
\end{split}
\end{equation}{}
\noindent For any given task, this single-task attack is more effective than jointly attacking the other tasks. We will empirically demonstrate that multi-task~\xspace learning also improves model robustness against this type of attack in Section \ref{sec:eval}.
\section{Related Work}
We briefly review related work in multi-task~\xspace learning and adversarial attacks.
\textbf{Multi-task~\xspace Learning:}
Multi-task~\xspace learning \cite{multi-task-caruana,regularized_MTL,MTL_self_sup,TaskGroup_MTL, multi-task-onomy} aims to solve several tasks at once, and has been used to learn better models for semantic segmentation~\cite{att-e2e-mtl}, depth estimation~\cite{upnet}, key-point prediction~\cite{keypoints}, and object detection~\cite{SSD}. It is hypothesized that multi-task~\xspace learning improves the performance of select tasks by introducing a knowledge-based inductive bias \cite{multi-task-caruana}. However, multi-objective functions are hard to optimize, where researchers design architectures~\cite{onemodelforall, ubernet,task-expert, cross-stitch, liu2019multitask} and optimization procedures~\cite{gradnormMTL, mgda, sener2018multitask, gradientsurgery} for learning better multi-task~\xspace models. Our work complements this body of work by linking multi-task~\xspace learning to adversarial robustness.
\textbf{Adversarial Attacks:}
Current adversarial attacks manipulate the input \cite{intriguing,mim,costales2020live, RobustSeg, houdini, shen2019advspade, DAG, Metzen_2017} to fool target models. While attacking single output models~\cite{corr/GoodfellowSS14,BIM} is straightforward, Arnab et. al.~\cite{RobustSeg} empirically shows the inherent hardness of attacking segmentation models with dense output. Theoretical insight of this robustness gain, however, is missing in the literature. While past theoretical work showed the hardness of multi-objective optimization \cite{hardmultiobject, Multitask-influence}, we leverage this motivation and prove that multi-task~\xspace models are robust when tasks are simultaneously attacked. Our work contributes both theoretical and empirical insights on adversarial attacks through the lens of multi-task~\xspace learning.
\textbf{Adversarial Robustness:}
Adversarial training improves models' robustness against attacks, where the training data is augmented using adversarial samples \cite{corr/GoodfellowSS14, madry}. In combination with adversarial training, later works \cite{ALP,TLA,TRADES, feature_denoising} achieve improved robustness by regularizing the feature representations with additional loss, which can be viewed as adding additional tasks. Despite the improvement of robustness, adversarially trained models lose significant accuracy on clean (unperturbed) examples \cite{madry,TRADES, robustness_vs_accuracy}. Moreover, generating adversarial samples slows down training several-fold, which makes it hard to scale adversarial training to large datasets.
Past work revealed that model robustness is strongly connected to the gradient of the input, where models' robustness is improved by regularizing the gradient norm \cite{regularize-input-grad,deepdefense,parseval}. Parseval \cite{parseval} regularizes the Lipschitz constant---the maximum norm of gradient---of the neural network to produce a robust classifier, but it fails in the presence of batch-normalization layers. \cite{regularize-input-grad} decreases the input gradients norm. These methods can improve the model's robustness without compromising clean accuracy. Simon-Gabriel et al. \cite{first-order} conducted a theoretical analysis of the vulnerability of neural network classifiers, and connected gradient norm and adversarial robustness.
Our method enhances robustness by training a multi-task~\xspace model, which complements both adversarial training \cite{madry, TRADES} and existing regularization methods \cite{PED,regularize-input-grad,deepdefense,parseval}.
\section{Proof for Theoretical Analysis}
~~~~~ We present theoretical analysis to quantify how much multi-task learning improves model's overall adversarial robustness.
\begin{definition}
Given classifier $F$, input ${\bf x}$, output target ${\bf y}$, and loss $\mathcal{L}({\bf x}, {\bf y}) = \ell(F({\bf x}), {\bf y})$, the feasible adversarial examples lie in a $p$-norm bounded ball with radius $r$, $B({\bf x}, r) := \{{\bf x}_{adv}, ||{\bf x}_{adv}-{\bf x}||_p<r\}$. Then adversarial vulnerability of a classifier over the whole dataset is
\[\mathbb{E}_{{\bf x}} [\Delta \mathcal{L}({\bf x}, {\bf y}, r)] = \mathbb{E}_{{\bf x}} [\max_{||\delta||_p < r}{|\mathcal{L}({\bf x},{\bf y}) - \mathcal{L}({\bf x}+\delta,{\bf y})|}].\]
\end{definition}
\noindent $\Delta \mathcal{L}$ captures the change of output loss given a change in input. Intuitively, a robust model should have a smaller change in loss given a perturbation of the input. Given the adversarial noise is imperceptible, i.e., $r \rightarrow 0$, we can approximate $\Delta \mathcal{L}$ with a first-order Taylor expansion, where
\[|\mathcal{L}({\bf x},{\bf y}) - \mathcal{L}({\bf x}+\delta,{\bf y})| = |\partial_{{\bf x}} \mathcal{L}({\bf x}, {\bf y}) \delta + O(\delta)|
\]
\begin{lemma}
For a given neural network $F$ that predicts multiple tasks, the adversarial vulnerability is
\[\mathbb{E}_{{\bf x}} [\Delta \mathcal{L}({\bf x}, {\bf y}, r)] \approx \mathbb{E}_{{\bf x}}\left[||\partial_{{\bf x}} \mathcal{L}_{all}({\bf x}, \overline{{\bf y}})||_q \right] \cdot ||\delta||_p \propto \mathbb{E}_{{\bf x}}\left[||\partial_{{\bf x}} \mathcal{L}_{all}({\bf x}, \overline{{\bf y}})||_q \right] \]
\end{lemma}
\begin{proof}
According to the definition of dual norm:
\[ \Delta \mathcal{L} \approx \max_{||\delta||_p < r} |\partial_{{\bf x}} \mathcal{L}({\bf x}, {\bf y}) \delta | = ||\partial_{{\bf x}} \mathcal{L}_{all}({\bf x}, \overline{{\bf y}})||_q \cdot || \delta ||_p
\]
\[
\mathbb{E}_{{\bf x}}[\Delta \mathcal{L}] \approx \mathbb{E}_{{\bf x}}\left[||\partial_{{\bf x}} \mathcal{L}_{all}({\bf x}, \overline{{\bf y}})||_q \right] \cdot ||\delta||_p
\]
\noindent where $q$ is the dual norm of $p$, which satisfies $\frac{1}{p} + \frac{1}{q} = 1$ and $1 \leq p \leq \infty$.
Once given the $p$-norm bounded ball, i.e., $||\delta||_p $ is constant, we get
\[
\mathbb{E}_{{\bf x}}[\Delta \mathcal{L}] \propto \mathbb{E}_{{\bf x}}\left[||\partial_{{\bf x}} \mathcal{L}_{all}({\bf x}, \overline{{\bf y}})||_q \right]
\]
\end{proof}{}
\begin{theorem}\label{th:1}
\textbf{(Adversarial Vulnerability of Model for Multiple Correlated Tasks)}
If the selected output tasks are correlated with each other such that the covariance between the gradient of task $i$ and task $j$ is $\mathrm{Cov}(\bf{r}_i, \bf{r}_j)$, and the gradient for each task is i.i.d. with zero mean (because the model is converged), then adversarial vulnerability of the given model is proportional to
\[\frac{\sqrt{(1 + \frac{2}{M} \sum_{i=1}^{M} \sum_{j=1}^{i-1} \frac{\mathrm{Cov}(\bf{r}_i, \bf{r}_j)}{\mathrm{Cov}(\bf{r}_i, \bf{r}_i)})}}{\sqrt{M}} \]
where $M$ is the number of output tasks selected.
\end{theorem}
\begin{proof}
Denote the gradient for task $c$ as $\bf{r}_c$, i.e.,
\[
\bf{r}_c = \partial_{{\bf x}} \mathcal{L}_c({\bf x}, {\bf y}_c)
\]
We define the joint gradient vector ${\bf R}$ as follows:
\[
{\bf R} = \partial_{{\bf x}} \mathcal{L}_{all}({\bf x}, \overline{{\bf y}}) = \partial_{{\bf x}} \left(\frac{1}{M} \sum_{c=1}^{M}{\mathcal{L}_c({\bf x}, {\bf y}_c)}\right) = \frac{1}{M} \sum_{c=1}^{M}{\partial_{{\bf x}}\mathcal{L}_c({\bf x}, {\bf y}_c)} = \sum_{c=1}^{M} \bf{r}_c
\]
As we can see, the joint gradient is the sum of gradients from each individual task. Then we consider the expectation of the square of the $L_2$ norm of the joint gradient:
\[\mathbb{E}(\lVert {\bf R} \rVert_2^2) = \mathbb{E}\left(\lVert \frac{1}{M} \sum_{c=1}^M{\bf{r}_c}\rVert_2^2\right) = \frac{1}{M^2}\mathbb{E}\left(\sum_{c=1}^M{\lVert\bf{r}_c\rVert^2} + 2 \sum_{i=1}^M{\sum_{j=1}^{i-1}{\bf{r}_i \bf{r}_j}}\right)
\]
\[ \mathbb{E}(\Vert {\bf R} \rVert_2^2) = \frac{1}{M^2}\left(\sum_{i=1}^M\mathbb{E}{\lVert \bf{r}_i \rVert^2} + 2 \sum_{i=1}^M{\sum_{j=1}^i\mathbb{E}({\bf{r}_i \bf{r}_j})}\right)
\]
Since \[
\mathrm{Cov}(\bf{r}_i, \bf{r}_j) = \mathbb{E}(\bf{r}_i \bf{r}_j) - \mathbb{E}(\bf{r}_i)\mathbb{E}(\bf{r}_j)
\]
According to the assumption \[
\mathbb{E}(\bf{r}_j) = {\bf 0}
\]
We know
\[
\mathrm{Cov}(\bf{r}_i, \bf{r}_j) = \mathbb{E}(\bf{r}_i \bf{r}_j)
\]
Then we get
\[
\mathbb{E}(\lVert {\bf R} \rVert_2^2) = \frac{1}{M^2}\left(\sum_{i=1}^M\mathbb{E}({\mathrm{Cov}(\bf{r}_i, \bf{r}_i)}\right) + 2 \sum_{i=1}^M{\sum_{j=1}^i\mathbb{E}({\mathrm{Cov}(\bf{r}_i, \bf{r}_j)})} = \frac{1}{M^2}\left(\sum_{i=1}^M \sigma^2 + 2 \sum_{i=1}^M{\sum_{j=1}^i\mathbb{E}[{\mathrm{Cov}(\bf{r}_i, \bf{r}_j)}]}\right)
\]
\noindent where $\sigma^2 = \mathrm{Cov}(\bf{r}_i, \bf{r}_i)$
Thus, the adversarial vulnerability is:
\[
\mathbb{E}_{{\bf x}}[\Delta \mathcal{L}] \propto \mathbb{E}_{{\bf x}}\left[\lVert \partial_{{\bf x}} \mathcal{L}_{all}({\bf x}, \overline{{\bf y}})\rVert_2 \right]
= \frac{\sqrt{(1 + \frac{2}{M} \sum_{i=1}^{M} \sum_{j=1}^{i-1} \frac{\mathrm{Cov}(\bf{r}_i, \bf{r}_j)}{\mathrm{Cov}(\bf{r}_i, \bf{r}_i)})}}{\sqrt{M}}
\]
\end{proof}{}
For a special case where all the tasks are independent of each other, independent gradients with respect to the input are produced, we have the following corollary:
\begin{corollary}\label{th:1}
\textbf{(Adversarial Vulnerability of Model for Multiple Independent Tasks)}
If the output tasks selected are independent of each other, and the gradient for each task is i.i.d. with zero mean, then the adversarial vulnerability of given model is proportional to $\frac{1}{\sqrt{M}}$, where $M$ is the number of independent output tasks selected.
\end{corollary}
\begin{proof}
According to the independent assumption, we have
\[
\mathrm{Cov}(\bf{r}_i, \bf{r}_j) = 0
\]
Let $\sigma^2 = \mathrm{Cov}(\bf{r}_i, \bf{r}_i) $. Thus we get the adversarial vulnerability to be:
\[
\mathbb{E}_{{\bf x}}[\Delta \mathcal{L}] \propto \mathbb{E}_{{\bf x}}\left[||\partial_{{\bf x}} \mathcal{L}_{all}({\bf x}, \overline{{\bf y}})||_2 \right]
= \sqrt{ \frac{\sigma^2}{M}} \propto \frac{1}{\sqrt{M}}
\]
\end{proof}{}
\section{Visualization}
\section{Experimental Setup}
\subsection{Cityscapes~\xspace}
We train DRN-105 model and evaluate against multi-task attack. We follow the original architecture setup of the original DRN paper \cite{Yu2017}. We used 93 layers in the shared backbone encoder network, and 13 layers in the decoder branch for individual task prediction. We use a batch size of 24. We start with a learning rate of 0.01 and decrease the learning rate by a factor of 10 after every 100 epochs. We trained the model for 250 epochs.
We train multi-task model against single task attack using DRN-22 model. We use 18 layers in the shared backbone encoder network, and 9 layers in the decoder branch for individual task prediction. We use batch size of 32. We optimize with SGD, with learning rate of 0.01, then decrease it to 0.001 at 180 epoch. We train model for 200 epoch in total. We applied a weight decay of 0.0001 for all the models.
\subsection{Taskonomy~\xspace}
~~~~~ Taskonomy dataset \cite{taskonomy} consists of millions of indoor scenes with labels for multiple tasks, we use 11 tasks including semantic segmentation, depth estimation, 2D and 3D edge detection, normal vector estimation, reshading, 2D and 3D keypoint detection, Euclidean depth, auto-encoding, and principal curvature estimation. We use the publicly available Tiny version of dataset, which consists of 9464 images from 1500 rooms. We use examples from 80\% of the rooms as training data and examples from 20\% of the rooms as test data. Images from the same room are only contained in either the training set or the test set, and not in both. The quality of the model is measured by its ability to generalize to new rooms.
For learning a multi-task model for joint robustness, we follow the set up described in \cite{multi-task-onomy}. We train a ResNet-18 as the shared backbone encoder network for all the tasks. Each multi-task model consists of 1 to 6 different tasks. We use an input size of $512 \times 512$. We use an 8 layer decoder for each individual task prediction. Following the data preprocessing of \cite{multi-task-onomy}, we apply equal weights to all the tasks. Start from task "semantic segmentation" (s), we add tasks "depth" (d), "edge texture" (e), "keypoints 2d" (k), "normal" (n), and "reshading" (r). Thus we train 6 models `s,' `sd,' `sde,' `sdek,' `sdekn,' `sdeknr.' We also train `d,' `e,' `er,' `k,' `ks,' `ksd' tasks, so that we can analysis the trend of 4 tasks' performance after multitask learning. We use the same learning rate schedule for all the models --- SGD with learning rate 0.01 and momentum 0.99. We decrease the learning rate at 100 epoch by 10 times. We train all the models for 150 epoch. Results are shown in Figure 5 in the main paper.
\begin{table*}
\scriptsize
\centering
\begin{tabular}{c|c|cccccccccccc}
\toprule
\midrule
\multicolumn{13}{c}{PGD Adversarial} \\
& Baseline & SemSeg & DepthZ & Edge2D & Normal & Reshad & Key2D & Key3D & DepthE & AutoE & Edge3D & PCurve\\
\midrule
Semseg * & {13.360} & --- & \fbox{\textbf{19.320}} & \textbf{13.950} & \textbf{16.630} & \textbf{14.580} & \textbf{15.700} & \textbf{13.780} & \textbf{14.910} & \textbf{14.110} & \textbf{14.720} & \textbf{14.900} \\
DepthZ $(10^{-2})$ & {11.491} & \fbox{\textbf{4.712}} & --- & \textbf{6.780} & {11.617} & {12.412} & \textbf{11.120} & \textbf{8.358} & \textbf{10.498} & \textbf{4.981} & {12.230} & \textbf{5.035} \\
Edge2D $(10 ^ {-2})$ & {10.672} & \textbf{9.841} & \fbox{\textbf{9.363}} & --- & \textbf{9.546} & \textbf{9.943} & \textbf{9.732} & \textbf{9.654} & \textbf{9.714} & \textbf{9.941} & \textbf{9.978} & \textbf{10.095} \\
Normal $(10 ^ {-2})$ & {40.926} & \fbox{\textbf{35.171}} & {42.871} & \textbf{39.335} & --- & \textbf{40.501} & \textbf{39.462} & \textbf{39.930} & {42.071} & \textbf{35.726} & \textbf{37.070} & {41.212} \\
Reshad $(10 ^ {-2})$ & {57.900} & \fbox{\textbf{48.800}} & \textbf{57.800} & \textbf{55.000} & \textbf{56.500} & --- & \textbf{55.900} & \textbf{53.300} & {60.000} & {61.000} & \textbf{49.300} & \textbf{57.600} \\
Key2D $(10 ^ {-2})$ & {11.700} & \textbf{10.900} & \textbf{10.900} & \textbf{10.700} & \textbf{10.500} & \textbf{10.900} & --- & \textbf{11.000} & \textbf{10.600} & \textbf{11.000} & \textbf{10.800} & \fbox{\textbf{10.600}} \\
Key3D $(10 ^ {-2})$ & {49.700} & \fbox{\textbf{31.000}} & \textbf{49.600} & \textbf{50.800} & \textbf{45.900} & \textbf{42.200} & \textbf{43.800} & --- & {51.200} & \textbf{32.600} & {53.400} & {52.900} \\
DepthE $(10^{-3})$ & {4.850} & \textbf{3.530} & \textbf{3.390} & \textbf{3.250} & \textbf{4.270} & {5.670} & \textbf{3.670} & \textbf{3.730} & --- & \textbf{3.700} & \textbf{3.330} & \fbox{\textbf{2.930}} \\
AutoE $(10^{-2})$ & {59.300} & \fbox{\textbf{57.800}} & {60.300} & \textbf{58.300} & {62.300} & {59.400} & {59.300} & {60.700} & \textbf{58.200} & --- & {60.500} & {61.500} \\
Edge3D $(10^{-2})$ & {15.900} & \textbf{14.600} & \textbf{15.300} & {16.300} & \textbf{15.400} & \textbf{15.200} & \textbf{15.600} & {16.900} & \textbf{15.400} & \fbox{\textbf{12.600}} & --- & \textbf{14.800} \\
PCurve $(10^{-4})$ & {11.500} & \textbf{8.920} & \fbox{\textbf{8.900}} & \textbf{10.400} & \textbf{9.230} & \textbf{9.620} & \fbox{\textbf{8.900}} & \textbf{10.400} & \textbf{11.100} & \textbf{9.190} & \textbf{10.400} & --- \\
\toprule
\midrule
\multicolumn{13}{c}{Clean} \\
\midrule
SemSeg * & {43.190} & {---} & \textbf{46.300} & \textbf{46.180} & \fbox{\textbf{46.350}} & \textbf{46.240} & \textbf{45.440} & \textbf{45.620} & \textbf{44.690} & \textbf{44.500} & \textbf{45.320} & \textbf{44.490} \\
DepthZ $(10^{-2})$ & {2.852} & \fbox{\textbf{2.734}} & {---} & {3.880} & \textbf{2.846} & \textbf{2.505} & {2.874} & {3.562} & {3.339} & {3.171} & {3.088} & {4.690} \\
Edge2D $(10^{-2})$ & {3.384} & {3.922} & \textbf{3.382} & {---} & {3.507} & {3.435} & \textbf{3.330} & {3.522} & {3.433} & {3.574} & {3.569} & {3.454} \\
Normal $(10^{-2})$ & {6.997} & {7.181} & {7.093} & {7.006} & {---} & \textbf{6.989} & \textbf{6.990} & {7.182} & \textbf{6.940} & \fbox{\textbf{6.864}} & \textbf{6.931} & {7.141} \\
Reshad $(10^{-2})$ & {8.027} & \textbf{7.985} & {8.103} & \textbf{7.941} & \textbf{7.901} & {---} & {8.041} & \textbf{7.957} & \textbf{7.940} & \fbox{\textbf{7.890}} & {8.065} & {8.150} \\
Key2D $(10^{-2})$ & {4.156} & \textbf{4.116} & \textbf{3.897} & \fbox{\textbf{3.795}} & \textbf{3.865} & \textbf{4.147} & {---} & \textbf{3.944} & \textbf{3.857} & \textbf{3.823} & \textbf{3.850} & \textbf{3.878} \\
Key3D $(10^{-2})$ & {8.771} & \textbf{8.445} & \textbf{8.686} & \textbf{8.514} & \textbf{8.610} & \fbox{\textbf{8.318}} & \textbf{8.703} & {---} & \textbf{8.492} & \textbf{8.366} & \textbf{8.362} & \textbf{8.578} \\
DepthE $(10^{-3})$ & {6.373} & {6.575} & \textbf{5.946} & \textbf{6.350} & \textbf{6.236} & \textbf{5.802} & {6.418} & {6.470} & {---} & \textbf{5.948} & \fbox{\textbf{5.715}} & \textbf{6.251} \\
AutoE $(10^{-2})$ & {3.470} & {3.616} & {3.709} & {3.548} & {3.587} & {3.540} & {3.780} & {3.761} & {3.542} & {---} & {3.530} & {3.553} \\
Edge3D $(10^{-2})$ & {4.649} & {4.695} & \textbf{4.608} & {4.727} & \textbf{4.562} & {4.725} & \textbf{4.364} & \textbf{4.635} & \textbf{4.611} & \textbf{4.210} & {---} & \fbox{\textbf{3.703}} \\
PCurve $(10^{-4})$ & {8.017} & {8.360} & {8.184} & {8.353} & {8.541} & \fbox{\textbf{7.232}} & \textbf{7.733} & \textbf{7.725} & {8.153} & \textbf{7.854} & \textbf{7.732} & {---} \\
\bottomrule
\end{tabular}
\caption{ The absolute performance of all models trained on two tasks (Relative are shown in Figure 7 in the main paper). Each row in the first column lists the name of the main task. The second column (baseline) shows the performance of a model trained on a single task. The * in the row indicates the mIoU score for semantic segmentation, for which higher is better. The values in the other rows of the table show the l1 loss, for which lower is better. The $(10^{-n})$ in the first column indicates the unit for the error. `SemSeg' denotes `semantic segmentation,' `DepthZ' denotes `depth estimation,' `Edge2D' denotes `2D edge detection,' `Normal' denotes `Normal Vector estimation', `Reshad' denotes `Reshading,' `Key2D' denotes `2D Keypoint detection,' `Key3D' denotes `3D Keypoint detection,' `DepthE' denotes `Euclidean depth,' `AutoE' denotes `Auto Encoder,' `Edge3D' denotes `3D Edge detection,' `PCurve' denotes `Curvature estimation.'
Values superior to the baseline are \textbf{bold}, and the best performance for each row is in a \textbf{box}. The table lists the IoU (large is better) for the segmentation model, and error (small is better) for all the other tasks. We pair each selected model with 11 other models. All the models converge after training for 150 epochs. Overall, training on two tasks can help the individual task's adversarial robustness on \textbf{90/110} cases, while surpassing the baseline's performance on the clean examples on \textbf{70/110}. For instance, the adversarial robustness for the semantic segmentation and keypoints3D estimation is always improved by multi-task learning while the clean accuracy also improves. The results on 11 tasks support our claim that training on multiple tasks improves adversarial robustness.
} \label{seg:all_11_aux}
\end{table*}
\begin{table*}
\scriptsize
\centering
\begin{tabular}{c|cccccccccccc}
\toprule
\midrule
\multicolumn{12}{c}{$\lambda_a$} \\
& SemSeg & DepthZ & Edge2D & Normal & Reshad & Key2D & Key3D & DepthE & AutoE & Edge3D & PCurve\\
\midrule
Semseg * & 0 & 0.01 & 9.01 & 0.1 & 0.1 & 0.01 & 0.01 & 0.1 & 0.01 & 0.1 & 0.01\\
DepthZ & 0.1 & 0 & 0.1 & 0.01 & 0.1 & 0.1 & 0.01 & 0.1 & 0.1 & 0.1 & 0.01 \\
Edge2D & 0.1 & 0.1 & 0 & 0.1 & 0.1 & 0.01 & 0.1 & 0.1 & 0.01 & 0.01 & 0.1 \\
Normal & 0.1 & 0.01 & 0.1& 0 & 0.01& 0.1& 0.01 &0.1& 0.1& 0.01 &0.01 \\
Reshad & 0.01 &0.1 &0.01& 0.01& 0 &0.1 &0.01& 0.01 &0.1& 0.01& 0.1\\
Key2D & 0.1& 0.1& 0.01 &0.01& 0.01& 0& 0.01& 0.01 &0.01 &0.01& 0.1\\
Key3D & 0.1 &0.01& 0.1 &0.1 &0.1& 0.1& 0& 0.1& 0.1& 0.01& 0.01\\
DepthE & 0.1& 0.01& 0.01& 0.01 &0.01 &0.1 &0.01 &0& 0.01 &0.1& 0.1 \\
AutoE & 0.1 &0.01& 0.01 &0.1& 0.01& 0.1& 0.01 &0.1& 0 &0.01 &0.1 \\
Edge3D & 0.1& 0.01& 0.01& 0.01 &0.01& 0.1& 0.01& 0.01& 0.1 &0 &0.1 \\
PCurve & 0.1& 0.01& 0.1& 0.01 &0.01& 0.1& 0.01& 0.1& 0.01& 0.01& 0\\
\bottomrule
\end{tabular}
\caption{The $\lambda_a$ value for the auxiliary task for Figure 7 in the main paper.} \label{seg:all_11_aux_lam}
\end{table*}
For training robust models on select tasks, we use ResNet-18 as the shared encoder network. We select 11 tasks trained in pairs with each other, which results in 110 models. We study their robustness under a single-task attack. We follow the data processing in \cite{taskonomy}. For each task we considered, we try weights of 0.1 and 0.01 for the auxiliary task, and choose the weight that produces higher robust accuracy. The chosen $\lambda_a$ for the auxiliary tasks are shown in Table \ref{seg:all_11_aux_lam}. The selection of weights is important due to the complex interactions of different tasks \cite{MTLworkshop}. We follow the setup in \cite{taskonomy}, and subsample the image from 512 to 256 using linear interpolation. For segmentation, reshading, keypoint 3D, depth Euclidean, Auto Encoder, principle curvature, we use SGD, with learning rate 0.01 and decrease by 10 times at 140 epoch. For the other tasks we use adam, with learning rate 0.001 and decrease by 10 times at 120 and 140 epoch. Due to the inherent difference between different tasks, we use different optimizer for different tasks for better convergence. All the models are trained for 150 epoch. All the results are shown in Table \ref{seg:all_11_aux}. As we can see, learning versatile, multi-task models improves adversarial robustness on 90/110 tasks.
\subsection{Adversarial Training}
We present the details for multi-task adversarial training in Algorithm \ref{alg:1}. For single task model, we choose $S=\{\{T_m\}\}$. The algorithm is the same as the adversarial training procedure of Madry et. al. \cite{madry}. For multi-task model, we set $S = \{\{T_m\}, \{T_m, T^{(1)}_a, ..., \}\}$, thus the generated adversarial images under multi-task are more diversified compared with single-task models. In addition, all the adversarial examples are trained on multi-task loss function, where the auxiliary task can introduce useful knowledge for learning the robust main task. We use $\lambda=0.01$ for the auxiliary task. For all the task, we train using SGD optimizer with batch size of 32, for 200 epoch. We start with learning rate of 0.01, and decrease the learning rate by 10 times at 180 epoch. The experiment are conducted on Cityscapes dataset.
\begin{algorithm}[t]
\caption{Adversarial Training with Multi-task Learning}
\label{alg:1}
{\bf Input:} Initialized networks $F_i$, dataset $D$, main task $T_m$, auxiliary task $T^{(i)}_a$. Construct multi-task combination set $S = \{\{T_m\}, \{T_m, T^{(1)}_a, ..., \}\}$
{\bf Output:}
\begin{algorithmic}
\FOR{number of training epochs}
\FOR{number of iterations in each epoch}
\STATE Sample minibatch of $n$ images ${\bf x}$ from $D$.
\FOR{each task combination $S_t$ in $S$}
\STATE Let $\mathcal{L}_t({\bf x},{\bf y}) = \sum_{i} \lambda_i \ell(F_i({\bf x}), {\bf y}_i)$, where $i = 1, ..., \#(S_t)$, $T_i \in S_t$.
\STATE Compute adversarial attack images ${\bf x}_{adv}$
\begin{equation*}
\begin{aligned}
\mathop{\rm argmax}_{{\bf x}_{adv}} \mathcal{L}_t({\bf x}_{adv}, {\bf y}), \text{s.t.} ||{\bf x}_{adv} - {\bf x}||_p \leq r
\end{aligned}
\end{equation*}
\STATE Training the multi-task model using the generated attack image ${\bf x}_{adv}$ by optimizing the following loss function:
\begin{equation*}
\begin{aligned}
\min{\mathcal{L}_t({\bf x}, {\bf y})}
\end{aligned}
\end{equation*}
\ENDFOR
\ENDFOR
\ENDFOR
\RETURN Neural network model $F_i$
\end{algorithmic}
\end{algorithm}
| {'timestamp': '2020-09-14T02:05:43', 'yymm': '2007', 'arxiv_id': '2007.07236', 'language': 'en', 'url': 'https://arxiv.org/abs/2007.07236'} | arxiv |
\section*{Appendix}
\section{Definitions for Petri Nets and Unfoldings}
\label{app:pn}
In this section of the appendix we recall some definitions for safe Petri nets and unfoldings.
Let \(\pNet=(\pl,\tr,\fl,\init)\) be a safe Petri net.
Thus, every \emph{marking} \(M\) of \(\pNet\) is a set (rather than a multiset) of places, i.e., \(M\subseteq\pl\).
We define the \textit{preset} of a node~$x$ from $\pNet$
as $\pre{\pNet}{x} = \{y \in \pl \cup \tr \mid (y,x)\in\fl\}$
and the postset as $\post{\pNet}{x} = \{y \in \pl \cup \tr \mid (x,y)\in\fl\}$.
A transition \(t\in\tr\) is \emph{enabled} at a marking \(M\) iff \(\pre{\pNet}{t}\subseteq M\).
\emph{Firing} an enabled transition \(t\in\tr\) at a marking~\(M\)
yields the successor marking~\(M'=(M\setminus\pre{\pNet}{t})\cup\post{\pNet}{t}\).
We denote this \emph{firing relation} by \(M\firable{t} M'\).
The \emph{interleaving semantics} of a safe Petri net
has the \emph{reachable markings}
\(\reach(\pNet)=\init\cup\{M_n\subseteq\pl\with\exists t_1,\ldots,t_n\in\tr:\init\firable{t_1}M_1\firable{t_2}\cdots
\firable{t_n}M_n\}\)
as states and connects them according to the firing relation.
The following paragraphs introduce the \emph{unfolding} of a safe Petri net,
a \emph{true concurrency semantics} obtained by unfolding the behavior of the net into a tree.
The nodes of~\(\pNet\) can be partially ordered
by their causal dependencies.
For two nodes \(x,y\in\pl\cup\tr\) we call \(x\) a \emph{causal predecessor} of \(y\),
written \(x<y\),
iff \(x\,\fl^+\,y\) holds, i.e.,
\(y\) can be reached by following directed arcs from~\(x\).
We write \(x\leq y\) iff \(x<y\) or \(x=y\).
The nodes \(x\) and \(y\) are \emph{causally related} iff \(x\leq y\) or \(y\leq x\) holds.
They are in \emph{conflict}, written \(\conflict{x}{y}\),
iff there is a place \(p\in\pl\setminus\{x,y\}\) and two transitions \(t_1,t_2\in \post{\pNet}{p}\)
with \(t_1\neq t_2\) such that \(t_1\leq x\) and \(t_2\leq y\) holds.
If they are neither in conflict nor causally related,
we call the nodes \emph{concurrent}.
A set of places \(X\subseteq\pl\) is called \emph{concurrent} iff
all places are pairwise concurrent.
An \emph{occurrence net} is a Petri net \(\pNet=(\pl,\tr,\fl,\init)\)
which represents the occurrences of transitions with their conflicts
and causal dependencies with the following constraints:
(i)~\(\forall p\in\pl: |\pre{\pNet}{p}|\leq 1\),
(ii)~\(\forall t\in\tr: \neg(\conflict{t}{t})\),
(iii)~\(\forall x\in\pl\,\cup\,\tr: \neg(x<x)\),
(iv)~\(\forall x\in\pl\,\cup\,\tr: |\{y\in\pl\cup\tr\with y < x\}| < \infty\), and
(v)~\(\init=\{p\in\pl\with\pre{\pNet}{p}=\emptyset\}\).
Thus, each place has only one ingoing transition,
no transition is in self-conflict,
the flow relation is acyclic,
the relation \(<\) is well-founded, i.e., does not contain any infinitely decreasing sequence,
and the initial marking consists of exactly the places not having any predecessor.
We call an occurrence net a \emph{causal net}, when further each place has at most
one transition as successor, i.e., (vi)~\(\forall p\in\pl:|\post{\pNet}{p}|\leq 1\) holds.
Let \(\pNet_1=(\pl_1,\tr_1,\fl_1,\init_1)\) and \(\pNet_2=(\pl_2,\tr_2,\fl_2,\init_2)\)
be two Petri nets.
We call \(\pNet_1\) a \emph{subnet} of \(\pNet_2\) iff \(\pl_1\subseteq\pl_2\), \(\tr_1\subseteq\tr_2\),
\(\fl_1\subseteq\fl_2\), and \(\init_1=\init_2\) holds.
A \emph{homomorphism} from \(\pNet_1\) to \(\pNet_2\) is a mapping \(h:\pl_1\cup\tr_1\to\pl_2\cup\tr_2\)
satisfying the following constraints:
(i)~\(h(\pl_1)\subseteq \pl_2\) and \(h(\tr_1)\subseteq\tr_2\) and
(ii)~\(\forall t\in\tr_1: h(\pre{\pNet_1}{t})=\pre{\pNet_2}{h(t)}\wedge h(\post{\pNet_1}{t})=\post{\pNet_2}{h(t)}\),
with the component-wise application of the homomorphism to a set \(X\subseteq\pl_1\cup\tr_1\), i.e,
\(h(X)=\{h(x)\with x\in X\}\).
This means as homomorphism preserves the types of the nodes and the pre- and postconditions of the transitions.
We call \(h\) \emph{initial} iff also (iii)~\(h(\init_1)=\init_2\).
We assume the elements of a superscripted Petri net \(\pNet^X\)
implicitly to be superscripted accordingly, i.e., \(\pNet^X=(\pl^X,\tr^X,\fl^X,\init^X)\).
A \emph{branching process} \(\beta=(\pNet^U,\lambda^U)\) of a Petri net \(\pNet\) consists
of an occurrence net \(\pNet^U\) and a homomorphism \(\lambda^U:\pl^U\cup\tr^U\to\pl\cup\tr\) such that
\(\forall t_1,t_2 \in \tr^U : (\pre{\pNet}{t_1} = \pre{\pNet}{t_2} \wedge \lambda^U(t_1) = \lambda^U(t_2)) \Rightarrow t_1 = t_2\)
holds. This means \(\lambda^U\) is injective on transitions with the same preset.
We call \(\beta\) \emph{initial} iff \(\lambda^U\) is initial.
A branching process \(\beta_R=(\pNet^R,\rho)\) of \(\pNet\)
is called \emph{(concurrent) run} of \(\pNet\) iff \(\pNet^R\) is a causal net
and called an \emph{initial (concurrent) run} iff furthermore \(\rho\) is an initial homomorphism.
A run formalizes a single concurrent execution of the net.
For a function \(h\) let \(h\mid_X\) restrict the domain of \(h\) to the set \(X\).
A branching process \(\beta_1=(\pNet_1,\lambda_1)\) is called a \emph{subprocess} of
a branching process \(\beta_2=(\pNet_2,\lambda_2)\) iff \(\pNet_1\) is a subnet of \(\pNet_2\)
and \(\lambda_1={\lambda_2}\mid_{\pl_1\cup\tr_1}\).
An \emph{unfolding} of a net \(\pNet\)
is an initial branching process \(\beta=(\pNet^U,\lambda^U)\) of~\(\pNet\)
which has a transition \(t^U\) labeled with \(t\) whenever there is a transition \(t\in\tr\)
which can extend the unfolding:
\(\forall t\in\tr, C\subseteq\pl^U: C \text{ concurrent} \wedge \lambda^U(C)=\pre{\pNet}{t}\Rightarrow\exists t^U\in\tr^U:\pre{\pNet^U}{t^U}=C\wedge \lambda^U(t^U)=t\).
An unfolding is unique up to isomorphism.
Each run of \(\pNet\) is a subprocess of an unfolding \(\beta\).
We lift the transit relation of a Petri net with transits to any branching process \(\beta=(\pNet^U,\lambda^U)\)
and thereby obtain notions of \emph{runs} and \emph{unfoldings} for \emph{Petri nets with transits}.
The \emph{transit relation} \(\tfl^U\) of a branching process with transits \(\beta\)
of a Petri net with transits \(\pNet\) is defined as follows:
For any \(t\in\tr^U\), we define
\(\tfl^U(t) \subseteq (\pre{\pNet^U}{t} \cup \{\startfl\}) \times \post{\pNet^U}{t}\)
such that \((p,q)\in\tfl^U(t)\Leftrightarrow(\lambda^U(p),\lambda^U(q))\in\tfl(\lambda^U(t))\) holds for all \(p,q\in\pl^U\).
\section{Formal Definitions and Proofs of the Model Checking Procedure}
\label{app:defsAndProofs}
In this section of the appendix we provide the formal definitions and proofs for \refSection{mcFlowCTLStar}.
We fix a Petri net with transits \(\petriNetFl\) and a Flow-\ctlStarText{} formula~\(\phiRun\)
with \(n\in\N\) flow subformulas \({\flowFormula}_i=\A\,\ctlStarFormula_i\) with atomic
propositions \(\AP_i\) throughout the section.
We formally define the labeled Kripke structure of which the unwinding triggered by
a firing sequence corresponds to one flow tree of a run of \(\pNet\).
\begin{definition}[Kripke Structure]
\label{def:kripkeStructure}
We construct the labeled Kripke structure
\(\kripke_{(\pNet,\AP_i)}=(\AP,\katoms, \kstates,\kinit,\klab,\krelLab)\)
with
\begin{itemize}
\item the finite set of \emph{atomic propositions} \(\AP=\AP_i\),
\item the finite set of \emph{states} \(\kstates\subseteq((\tr\cap\AP)\times\pl)\cup\pl\),
\item the finite set of \emph{initial states} \(\kinit\subseteq \kstates\),
\item the \emph{labeling function} \(\klab: \kstates\to 2^{\AP}\),
\item the \emph{alphabet} \(\katoms=\tr\cup\{\stutterSymbol\}\),
\item the \emph{labeled transition relation} \(\krelLab\subseteq \kstates\times \katoms\times \kstates\).
\end{itemize}
The \emph{initial states} \(\kinit=\{(t,p)\in\tr\times\pl\with \exists t\in\tr\cap\AP: (\startfl,p)\in\tokenflow(t)\}\cup\{p\in\pl\with \exists t\in\tr\setminus\AP: (\startfl,p)\in\tokenflow(t)\}\)
correspond to all tuples of transitions \(t\in\AP\) and places (or only to the places) which start a data flow in \(\pNet\).\\
The \emph{labeling function} \(L\) labels the states with its components:
\(\forall(p,t)\in(\tr\cap\AP)\times\pl: \klab((t,p))=\{t,p\}\) and \(\forall p\in\pl: \klab(p)=\{p\}\).
The \emph{transition relation} is composed of two sets \(\krelLab=\krelLab'\cup \krelLab''\).
The relation \(\krelLab'\) connects the states with respect to the transits:
\begin{align*}
\krelLab'=& \{(p,t,q)\in \kstates\times\tr\times \kstates\with (p,q)\in\tokenflow(t)\wedge t\not\in\AP\} \\
\cup& \{(p,t,(t,q))\in \kstates\times\tr\times \kstates\with (p,q)\in\tokenflow(t)\wedge t\in\AP\} \\
\cup& \{((t',p),t,q)\in \kstates\times\tr\times \kstates\with (p,q)\in\tokenflow(t)\wedge t\not\in\AP\} \\
\cup& \{((t',p),t,(t,q))\in \kstates\times\tr\times \kstates\with (p,q)\in\tokenflow(t)\wedge t\in\AP\}.
\end{align*}
The relation \(\krelLab''\) adds \(\stutterSymbol\)-labeled loops to states \(s\in\pl\)
and \(\stutterSymbol\)-labeled edges between~\((t,p)\) and \(p\) states to allow for the stuttering of finite chains:
\(\krelLab''=\{(p,\stutterSymbol,p)\in \kstates\times\{\stutterSymbol\}\times \kstates\}\cup\{((t,p),\stutterSymbol,p)\in \kstates\times\{\stutterSymbol\}\times \kstates\}\). The \emph{states} \(\kstates\) are exactly the states reachable from the initial states.
We define the function \(\ksucc:\kstates\times\katoms\to2^\kstates\)
with \(\ksucc(s,l)=\{s'\in\kstates\with (s,l,s')\in\krelLab\}\)
returning all \(l\)-labeled successors of a state \(s\).
\end{definition}
For an alternating tree automaton created of a \ctlStarText{} formula \(\ctlStarFormula\)
and a labeled Kripke structure we define an alternating word automaton
accepting the sequences of transitions which flow trees satisfy \(\ctlStarFormula\).
The definition is very similar to \cite{DBLP:journals/jacm/KupfermanVW00},
we only apply the edge definition on each equally labeled group of transitions separately.
\begin{definition}[Product Automaton]
Given an alternating tree automaton \(\tree_{\D,\ctlStarFormula}=(2^\AP,\D,\treeStates,\treeRel,\treeInit,\treeFinal)\)
accepting exactly all \(\D\)-trees satisfying \(\ctlStarFormula\)
and a labeled Kripke structure \(\kripke_{(\pNet,\AP)}=(\AP,\katoms,\kstates,\kinit,\klab,\krelLab)\) created by \refDef{kripkeStructure}
with degrees in \(\D\).
The \emph{product automaton} \(\aba_{\neg\ctlStarFormula_i}=(\katoms,\kstates\times \treeStates,\abaRel, \kinit\times\{\treeInit\},\abaFinal)\)
of \(\tree_{\D,\ctlStarFormula}\) and \(\kripke_{(\pNet,\AP)}\) is defined with \(\abaRel\):\\
For every
\((s,q)\in\kstates\times\treeStates\),
\(l\in\katoms\),
\(\ksucc(s,l)\neq\emptyset\), and
\(\treeRel(q,\klab(s),\size{\ksucc(s,l)})=\theta\),
we have an edge \(\abaRel((s,q),l)=\theta'\),
where the positive Boolean formula \(\theta'\)
is obtained from \(\theta\)
by replacing the atoms \((c,q')\)
with \((\langle \ksucc(s,l)\rangle_c,q')\), where \(\langle \ksucc(s,l)\rangle_c\)
is the \(c\)-th value of the ordered list of successors.\\
The acceptance condition of \(\treeFinal\) is transferred to \(\abaFinal\) by preserving the type
and building the cross product of the acceptance set(s) with~\(\kstates\).
\end{definition}
\refLemma{sizeBuchiAutomaton} states that the size of the nondeterministic B\"uchi automata is single-exponential for specifications given in \ctlText{}
and double-exponential in specifications given in \ctlStarText{}.
\begin{proof}[Size of the B\"uchi Automaton (\refLemma{sizeBuchiAutomaton})]
The construction for a \ctlStarText{} formula \(\ctlStarFormula\) and
a set of directions \(\D\subset\N\) results
in a hesitant alternating automaton of size \(\oclass{\size{\D}\cdot2^{\size{\ctlStarFormula}}}\)
(for \ctlText{} only of size \(\oclass{\size{\D}\cdot\size{\ctlStarFormula}}\)) \cite{DBLP:journals/jacm/KupfermanVW00}.
In our case the set of directions is
\(\D=\{0,\ldots,\mathtt{max}\{\size{\ksucc(s,l)}-1 \with s\in\kstates\wedge l\in\katoms\}\).
This is maximally
\(\D\subseteq\{0,\ldots,\mathtt{max}\{\size{\post{\tfl}{p,t}}-1 \with p\in\pl\wedge t\in\post{\pNet}{p}\}\}\),
the maximum of all numbers of successor transits of any place \(p\in\pl\).
Hence, at most \(\size{\D}\leq\size{\pl}\).
The product automaton created from the Kripke structure with
\(\oclass{\size{\pNet}\cdot\size{\AP_i\cap\tr}+\size{\pNet}}\) states
and \(\oclass{\size{\pNet^3}}\) edges and the hesitant alternating automaton has
\(\oclass{\size{\pl}\cdot2^{\size{\ctlStarFormula}}\cdot(\size{\pNet}\cdot\size{\AP_i\cap\tr}+\size{\pNet})}
=\oclass{2^{\size{\ctlStarFormula}}\cdot\size{\pNet}^3}\) states
and \(\oclass{(2^{\size{\ctlStarFormula}}\cdot\size{\pNet}^3)\cdot(\size{\tr}+1)}\) edges
(for CTL \(\oclass{\size{\ctlStarFormula}\cdot\size{\pNet}^3}\) states
and \(\oclass{(\size{\ctlStarFormula}\cdot\size{\pNet}^3)\cdot(\size{\tr}+1)}\) edges).
Removing the alternation results in another exponent:
the states of \(\ba_{\lnot \ctlStarFormula_i}\) are in
\(\oclass{2^{2^{\size{\ctlStarFormula}}\cdot\size{\pNet}^3}\cdot 2^{2^{\size{\ctlStarFormula}}\cdot\size{\pNet}^3}}\)
(\(\oclass{2^{\size{\ctlStarFormula}\cdot\size{\pNet}^3}\cdot2^{\size{\ctlStarFormula}\cdot\size{\pNet}^3}}\) for \ctlText{}).
As \(\ba_{\lnot \ctlStarFormula_i}\) is a nondeterministic B\"uchi automaton, the edges of \(\ba_{\lnot \ctlStarFormula_i}\)
are in
\(\oclass{2^{2^{\size{\ctlStarFormula}}\cdot\size{\pNet}^3}\cdot\size{\tr}}\)
and in
\(\oclass{2^{\size{\ctlStarFormula}\cdot\size{\pNet}^3}\cdot\size{\tr}}\) for \ctlText{}.\hfill\qed
\end{proof}
We formally define the construction of a standard Petri net with inhibitor arcs from a Petri net with transits
and \(n\) B\"uchi automata.
\begin{definition}[Petri Net with Transits to Petri Net]
\label{def:pnwt2pn}
Given \(\pNet\) and the corresponding \(n\) B\"uchi automata \(\ba_{\lnot \ctlStarFormula_i}\).
We define the Petri net with inhibitor arcs \(\pNetMC=(\plMC,\trMC,\flMC,\inhibitorFlMC,\initMC)\) with
\begin{align*}
\plMC=\plMC_o\cup\bigcup_{i\in\{1,\ldots,n\}}\plMC_i,\qquad \trMC=\trMC_o\cup\bigcup_{i\in\{1,\ldots,n\}}\trMC_i\\
\flMC=\flMC_O\cup\flMC_C\cup\bigcup_{i\in\{1,\ldots,n\}}\flMC_i,\qquad \inhibitorFlMC={\inhibitorFlMC}_O\cup\bigcup_{i\in\{1,\ldots,n\}}{\inhibitorFlMC}_i
\end{align*}
and a partial labeling function \(\lambda:\trMC\to\tr\cup\{\stutterSymbol\}\) by:
\begin{itemize}
\item[(o)] The original part of the net is a copy of \(\pNet\) without the transits and with an additional activation place \(\act{o}\).
Furthermore, we use the places \(\normalMode\) and \(\stutteringMode\),
the switch \(t_{\normalMode\to\stutteringMode}\), and the stuttering transition \(t_\stutterSymbol\)
to allow for checking finite runs, in which case
we have to trigger the automata \(\ba_{\lnot \ctlStarFormula_i}\) infinitely often to handle the stuttering:
\begin{align*}
\plMC_O=&\pl\cup\{\act{o},\normalMode,\stutteringMode\},\\
\trMC_O=&\tr\cup\{t_{\normalMode\to\stutteringMode},t_\stutterSymbol\},\\
\flMC_O=&\fl\cup\{(\act{o},t)\with t\in\tr\}\cup\{(\normalMode,t_{\normalMode\to\stutteringMode}),(t_{\normalMode\to\stutteringMode},\stutteringMode),(\act{o},t_\stutterSymbol)\},\\
{\inhibitorFlMC}_O=&\inhibitorFlMC\cup\{(\stutteringMode,t)\with t\in\tr\}\cup\{(\normalMode,t_\stutterSymbol)\}
\end{align*}
\item[(sub)] For each B\"uchi automaton \(\ba_{\lnot \ctlStarFormula_i}=(\tr\cup\{\stutterSymbol\},Q,Q_0,E,F) \), we create the places, transition, and flows
to simulate the automaton.
The \emph{places} are the states of the automaton with
a special place \(\initsub_i\) for initially guessing the violating tree,
two places \(\subnet{\normalMode}_i\) and \(\subnet{\stutteringMode}_i\) for switching from normal to stuttering mode,
and an activation place \(\subnet{\act{t}}_i\) for each transition \(t\in\tr\),
and one \(\subnet{\act{\stutterSymbol}}_i\) for the global stuttering transitions:
\[\plMC_i=\{\initsub_i,\subnet{\normalMode}_i,\subnet{\stutteringMode}_i,\subnet{\act{\stutterSymbol}}_i\}\cup\{\subnet{s}_i \with s\in Q\}\cup\{\subnet{\act{t}}_i\with t\in\tr\}.\]
The \emph{transitions} consists of
\[\trMC_i=\{\subnet{t_{\normalMode\to\stutteringMode}}_i\}\cup\tr_{\startfl_i}\cup\tr_{E_i}\cup\tr_{\skipT_i}\cup\tr_{\stutterSymbol_i}\]
with
the switch from normal to stuttering mode \(\subnet{t_{\normalMode\to\stutteringMode}}_i\),
one transition for each initial flow chain:
\(\tr_{\startfl_i}=\{\subnet{t_p}_i\with t\in\tr\wedge (\startfl,p)\in\tokenflow(t)\}\),
one transition for each edge of \(\ba_{\lnot \ctlStarFormula_i}\):
\(\tr_{E_i}=\{\subnet{e}_i\with e\in E\}\),
one skipping transition \(\subnet{t_{\skipT}}_i\) for each transition \(t\in\tr\) to not trigger the automaton when
the transition does not extend the current chain:
\(\tr_{\skipT_i}=\{\subnet{t_{\skipT}}_i\with t\in\tr\}\), and
for each stuttering edge \(e=(s,\stutterSymbol,s')\) of \(\ba_{\lnot \ctlStarFormula_i}\)
there is one \emph{local} stuttering transition for each transition \(t\in\tr\) which is no label of a successor edge of the state \(s\)
to move the activation token to the next subnet, when this net is in stuttering mode, but not the global net:
\(\tr_{\stutterSymbol_i}=\{\subnet{t_{e_{\stutterSymbol}}}_i\with e=(s,\stutterSymbol,s')\in E \wedge t\in\tr\wedge \neg\exists(s,t,s'')\in E\}\).\\
The \emph{labeling} function labels every transition \(t\MC\in\trMC\) corresponding to a transition \(t\in\tr\) or the stuttering
with \(t\) or \(\stutterSymbol\), respectively:
\(\forall\subnet{t_p}_i\in\tr_{\startfl_i}:\lambda(\subnet{t_p}_i)=t\),
\(\forall\subnet{e}_i\in\tr_{E_i}:\lambda(\subnet{e}_i)=l\) with \(e=(s,l,s')\),
\(\forall\subnet{t_{\skipT}}_i\in\tr_{\skipT_i}:\lambda(\subnet{t_{\skipT}}_i)=t\), and
\(\forall\subnet{t_{e_\stutterSymbol}}_i\in\tr_{\stutterSymbol_i}:\lambda(\subnet{t_{e_\stutterSymbol}}_i)=t\).\\
The \emph{flows} connect each transition \(t\MC\in\trMC_i\setminus\tr_{\stutterSymbol_i}\) corresponding to a transition \(t\in\tr\)
with the normal mode
and the corresponding activation token \(\subnet{\act{t}}_i\):
\begin{align*}
{\flMC_\normalMode}_i=&\{(\subnet{\act{t}}_i,t\MC)\with t\MC\in\tr_i\setminus\tr_{\stutterSymbol_i}\wedge t\in\tr \wedge \lambda(t\MC)=t\},\\
{{\inhibitorFlMC}_\normalMode}_i=&\{(\subnet{\stutteringMode}_i,t\MC)\with t\MC\in\tr_i\setminus\tr_{\stutterSymbol_i}\wedge t\in\tr \wedge \lambda(t\MC)=t\}.
\end{align*}
The transitions for guessing a flow chain are connected to the corresponding initial state of \(\ba_{\lnot \ctlStarFormula_i}\):
\[\flMC_{\startfl_i}=\{(\initsub_i,\subnet{t_p}_i),(\subnet{t_p}_i,s_0)\with \subnet{t_p}_i\in\trMC_{\startfl_i}\wedge s_0\in Q_0\wedge (s_0=p\vee s=(t_p,p))\}.\]
The transitions corresponding to an edge of \(\ba_{\lnot \ctlStarFormula_i}\), move the tokens accordingly:
\[\flMC_{E_i}=\{(\subnet{s}_i,\subnet{e}_i),(\subnet{e}_i,\subnet{s'}_i)\with \subnet{e}_i\in\tr_{E_i} \wedge e=(s,\lambda(\subnet{e}_i),s')\}.\]
\emph{Skipping} is only allowed in situations where no corresponding transition is firable:
\[{\inhibitorFlMC}_{\skipT_i}=\{(\subnet{s}_i,\subnet{t_{\skipT}}_i)\with \subnet{t_{\skipT}}_i\in\tr_{\skipT_i}\wedge \exists (s,\lambda(\subnet{t_{\skipT}}_i),\cdot)\in E\}.\]
The \emph{stuttering} transitions are only allowed in the stuttering mode:
\({\inhibitorFlMC}_{\stutteringMode_i}=\{(\subnet{\normalMode}_i,t\MC)\with \lambda(t\MC)=\stutterSymbol\vee t\MC\in\tr_{\stutterSymbol_i}\}\),
the \emph{global} stuttering transitions move the active stuttering token
\({\flMC_{\stutteringMode_i}}^1=\{(\subnet{\act{\stutterSymbol}}_i,t\MC)\with t\MC\in\trMC_{E_i}\wedge\lambda(t\MC)=\stutterSymbol\}\),
the \emph{local} stuttering transitions move the corresponding active token
\({\flMC_{\stutteringMode_i}}^2=\{(\subnet{\act{t}}_i,t\MC)\with t\MC\in\tr_{\stutterSymbol_i}\wedge\lambda(t\MC)=t\}\)
and the state token according to the edge:
\({\flMC_{\stutteringMode_i}}^3=\{(\subnet{s}_i,\subnet{t_{e_\stutterSymbol}}_i),(\subnet{t_{e_\stutterSymbol}}_i,\subnet{s'}_i)\with
\subnet{t_{e_\stutterSymbol}}_i\in\tr_{\stutterSymbol_i}\wedge e=(s,\lambda(\subnet{e}_i),s')\}\).
With \(\flMC_{\stutteringMode_i}={\flMC_{\stutteringMode_i}}^1\cup{\flMC_{\stutteringMode_i}}^2\cup{\flMC_{\stutteringMode_i}}^3\),
the flows of the subnet are the union of the previous sets,
in addition to a nondeterministically switch from normal to stuttering mode:
\begin{align*}
\flMC_i=&{\flMC_\normalMode}_i\cup\flMC_{\startfl_i}\cup\flMC_{E_i}\cup\flMC_{\stutteringMode_i}\cup\{(\subnet{\normalMode}_i,\subnet{t_{\normalMode\to\stutteringMode}}_i),(\subnet{t_{\normalMode\to\stutteringMode}}_i,\subnet{\stutteringMode}_i)\},\\
{\inhibitorFlMC}_i=&{{\inhibitorFlMC}_\normalMode}_i\cup{\inhibitorFlMC}_{\skipT_i}\cup{\inhibitorFlMC}_{\stutteringMode_i}.
\end{align*}
\item[(con)] The nets are connected in a sequential manner:
\begin{align*}
\flMC_C=&\{(t,\subnet{\act{t}}_1)\with t\in\tr\}\cup\{(t_\stutterSymbol,\subnet{\act{\stutterSymbol}}_1)\}\\
\cup&\bigcup_{i\in\{1,\ldots,n-1\}}\{(t\MC,\subnet{\act{\stutterSymbol}}_{i+1})\with t\MC\in\trMC_i\wedge\lambda(t\MC)=\stutterSymbol \}\\
\cup&\bigcup_{i\in\{1,\ldots,n-1\}}\{(t\MC,\subnet{\act{t'}}_{i+1})\with t\MC\in\trMC_i \wedge \lambda(t\MC)=t\in\tr\}\\
\cup&\{(t\MC,\act{o})\with t\MC\in\trMC_n \wedge\lambda(t\MC)=l\in\tr\cup\{\stutterSymbol\}\}.
\end{align*}
\item[(in)] The initial marking is the original marking with the activation place for the original part and one place
for each subnet to start guessing the chain, and one for switching into the stuttering mode:
\[\initMC=\init\cup\{\act{o},\normalMode\}\cup\{\subnet{\normalMode}_i,\initsub_i\with i\in\{1,\ldots,n\}\}.\]
\end{itemize}
\end{definition}
The size of the constructed net is dominated by the nondeterministic B\"uchi automata
\(\ba_{\lnot \ctlStarFormula_i}=(\tr\cup\{\stutterSymbol\}, Q_i, I_i, E_i,F_i)\)
checking the \ctlStarText{} subformulas.
\begin{proof}[Size of the Constructed Net (\refLemma{sizeMCNet})]
For the number of places, we have \(\size{\plMC_O}=\size{\pl}+3\) and \(\size{\plMC_i}=4+\size{Q_i}+\size{\tr}\).
Hence, \(\size{\plMC}=\size{\pl}+3+(4+\size{\tr})\cdot n+\sum_{i=1}^n\size{Q_i}\).\\
For the number of transitions, we have \(\size{\trMC_O}=\size{\tr}+2\) and
the size of \(\trMC_i\) is in \(\oclass{1+\size{\tr}\cdot\size{\pl} + \size{E_i}+\size{\tr}+\size{Q_i}\cdot\size{\tr}}\)
because each state has a stuttering edge and maximally there is no other outgoing transition.
Hence, \(\size{\trMC}\) is in \(\oclass{\size{\tr}+2+(1+\size{\tr}\cdot\size{\pl} + \size{\tr})\cdot n+\sum_{i=1}^n\size{E_i}+\tr\cdot\sum_{i=1}^n\size{Q_i}}\).
For a double-exponential number of states \(Q_i\) and edges \(E_i\) for specifications \(\ctlStarFormula_i\) in \ctlStarText{} and
single-exponential for specifications in \ctlText{} (\refLemma{sizeBuchiAutomaton})
the size of the constructed net is in the respective classes.
\hfill\qed
\end{proof}
The size of the formula is dependent on the size of the net and therewith also dominated by
the nondeterministic B\"uchi automaton construction.
\begin{proof}[Size of the Constructed Formula (\refLemma{sizeFormula})]
The next and the until replacement introduces disjunctions over all transitions
of the net. Also, the skipping constraint uses nearly every transition.
Hence, the size of the formula depends on the number of transitions \(\trMC\) and
is therewith double-exponential for specifications in \ctlStarText{} and single-exponential
for specifications in \ctlText{}.
\hfill\qed
\end{proof}
The correctness of the transformation is based on the correctness of the Kripke structure and the automata constructions.
The constructed formula and the constructed net together ensure
the correct triggering of the automata.
\begin{proof}[Correctness of the Transformation (\refLemma{correctnessTransformation})]
The unwinding of the Kripke structure along each transition sequence of a run
creates trees corresponding to flow trees of the run.
The standard constructions yield the correspondence of the acceptance
of the automaton which we check with \(\lnot\ltlAlways\ltlEventually\bigvee_{b\in F} \subnet{b}_i\).
Because of the ``infinitely often'', we do not have to do anything special for the net structure.
By checking all runs of the net \(\pNetMC\) and the nondeterministic guessing of the violating
flow tree in each subnet we check all flow trees.
The run part of the formula is adequately substituted such that all elements
concerning the timeline (the \(\ltlUntil\) and the \(\ltlNext\) operator) regarding \(\pNet\)
are adapted such that the sequential steps are omitted regarding the timeline of \(\pNetMC\).
The open part of this construction is to check whether only correct runs
regarding the sequential triggering and stuttering of the subnets are allowed.\\
\emph{All nets in normal mode:} The original part \(\pNetMC_O\) can only
choose one transition~\(t\in\tr\) and move the active token to the first subnet.
The stuttering transition \(t_\stutterSymbol\) is not enabled due to the inhibitor arc to \(\normalMode\).
If in the current state of the subnet \(t\) can extend the tree, i.e.,
is the label of a successor arc of the state, the only transition fireable (apart from the switch)
is the corresponding transition in \(\tr_{E_i}\) (because of the inhibitor arcs for \(\tr_{\skipT_i}\)).
If not, only the corresponding skipping transition in \(\tr_{\skipT_i}\) is fireable and moves the token to the next subnet.
If the net wrongly chose to be in normal mode, i.e., this subnet could only fire skipping transitions,
the constraint
\(\neg\ltlEventually\ltlAlways((\bigvee_{t\in\trMC_i} t)\rightarrow(\bigvee_{t'\in\tr_{\skipT_i}} t'))\)
of the formula omits these runs.\\
\emph{Global stuttering:} If at some point the global net switches into the stuttering mode, only transition \(t_\stutterSymbol\)
is fireable anymore. This transition only activates the first net with the stutter token in \(\subnet{\act{\stutterSymbol}}_1\).
Since all but the global stuttering transitions depend on an active place corresponding to a transition
only the global stuttering transitions \(\subnet{e}_i\in\tr_{E_i}\) with \(e=(s,\stutterSymbol,s')\) are fireable.
Hence, when the net does not switch into the stuttering mode, the whole run is stuck and is not considered due to the
\((\ltlAlways\ltlEventually\act{o})\) constraint in the formula \(\phiRun\MC\).\\
\emph{Local stuttering:} If the global net is not in stuttering mode \(\stutteringMode\),
but some net \(\pNetMC_i\) is, then only the transitions in \(\tr_{\stutterSymbol_i}\)
are fireable. If the net wrongly chose to be in stuttering mode then it would stuck and again the constraint
\((\ltlAlways\ltlEventually\act{o})\) of the formula omits this run.
The run which never decides to track any tree for a subnet introduces no problems because the initial place \(\initsub_i\)
cannot be part of the B\"uchi places.
\hfill\qed
\end{proof}
The previous lemmata yield the final complexity results.
\begin{proof}[\refTheo{complexityMC}]
For a Petri net with transits \(\pNet\) and a Flow-\ctlStarText{} formula~\(\phiRun\),
\refLemma{sizeMCNet} and \refLemma{sizeFormula} yield the double-exponential size
of the constructed Petri net with inhibitor arcs \(\pNetMC\)
and the constructed formula \(\phiLTL\MC\) (the single-exponential size for the \ctlText{} fragment).
\refLemma{correctnessTransformation} yields the correctness.
Checking a safe Petri net against LTL can be seen as checking a Kripke structure of exponential size (due to the markings of the net).
Since this can be checked in linear time in the size of
the state space and in exponential time in the size of the formula \cite{DBLP:reference/mc/2018},
we obtain a triple-exponential algorithm for \ctlStarText{} formulas
and a double-exponential algorithm for \ctlText{} formulas in the size of the net and the formula.
\hfill\qed
\end{proof}
\subsection{Flow Formulas}
\tikzstyle{rectNode}=[rectangle,draw=black!75,fill=black!15,minimum size=4mm]
\begin{figure}[t]
\centering
\begin{subfigure}[t]{0.29\textwidth}
\centering
\resizebox{0.75\textwidth}{!}{
\begin{tikzpicture}
\node[rectNode] (a) {};
\node[rectNode, right=of a] (b) {\scriptsize\(\varphi\)};
\draw[thick, shorten >=1pt, ->,shorten <=1pt] (a) -- node[above]{\scriptsize\cmark} (b);
\end{tikzpicture}
}
\subcaption{Permission: $\A\ctlEF\varphi$}
\label{fig:rulePermission}
\end{subfigure}%
~
\begin{subfigure}[t]{0.29\textwidth}
\centering
\resizebox{0.75\textwidth}{!}{
\begin{tikzpicture}
\node[rectNode] (a) {};
\node[rectNode, right=of a] (b) {\scriptsize\(\varphi\)};
\draw[thick, shorten >=1pt, ->,shorten <=1pt] (a) -- node[above]{\scriptsize\xmark} (b);
\end{tikzpicture}
}
\subcaption{Prohibition: $\A\ctlAG\neg\varphi$}
\label{fig:ruleProhibition}
\end{subfigure}%
~
\begin{subfigure}[t]{0.42\textwidth}
\centering
\resizebox{0.825\textwidth}{!}{
\begin{tikzpicture}
\node[rectNode] (a) {};
\node[rectNode, right=of a] (b) {\scriptsize\(\varphi\)};
\node[rectNode, right=of b] (c) {\scriptsize\(\psi\)};
\draw[thick, shorten >=1pt, ->,shorten <=1pt] (a) -- node[above]{\scriptsize\cmark/\xmark} (b);
\draw[thick, shorten >=1pt, ->,shorten <=1pt] (b) -- node[above]{\scriptsize\xmark} (c);
\end{tikzpicture}
}
\subcaption{Blocking: $\A\ctlAG(\varphi\Rightarrow \ctlAG \neg \psi )$}
\label{fig:ruleBlocking}
\end{subfigure}%
\\
\begin{subfigure}[t]{0.39\textwidth}
\centering
\resizebox{0.825\textwidth}{!}{
\begin{tikzpicture}
\node[rectNode] (a) {};
\node[rectNode, right=of a] (b) {\scriptsize\(\varphi\)};
\node[rectNode, right=of b] (c) {\scriptsize\(\psi\)};
\draw[thick, shorten >=1pt, ->,shorten <=1pt] (a) -- node[above]{\scriptsize\cmark/\xmark} (b);
\draw[thick, shorten >=1pt, ->,shorten <=1pt] (b) -- node[above]{\scriptsize\cmark/\xmark} (c);
\draw[thick, shorten >=1pt, ->,shorten <=1pt] (a) edge[bend left=45] node[above,yshift=-0.5mm]{\scriptsize\xmark} (c);
\end{tikzpicture}
}
\subcaption{Way-pointing: $\A\ctlAR{\varphi}{\neg\psi}$}
\label{fig:ruleWaypointing}
\end{subfigure}%
~
\begin{subfigure}[t]{0.275\textwidth}
\centering
\resizebox{0.61\textwidth}{!}{
\begin{tikzpicture}
\node[rectNode] (a) {};
\node[rectNode, right=of a] (b) {\scriptsize\(\varphi\)};
\draw[thick, shorten >=1pt, ->,shorten <=1pt] (a) edge[bend left=45] node[above]{\scriptsize\emph{day}{:} \cmark/\xmark} (b);
\draw[thick, shorten >=1pt, ->,shorten <=1pt] (a) edge[bend right=45] node[below]{\scriptsize\emph{night}{:} \cmark} (b);
\end{tikzpicture}
}
\subcaption{Policy update:\\ $\A\ctlAG(\textit{time} \Rightarrow \ctlEF \varphi ) $}
\label{fig:ruleTimeChange}
\end{subfigure}%
~
\begin{subfigure}[t]{0.335\textwidth}
\centering
\resizebox{0.61\textwidth}{!}{
\begin{tikzpicture}
\node[rectNode] (a) {};
\node[rectNode, right=of a] (b) {\scriptsize\(\varphi\)};
\draw[thick, shorten >=1pt, ->,shorten <=1pt] (a) edge[bend left=45] node[above]{\scriptsize\emph{normal}{:} \xmark} (b);
\draw[thick, shorten >=1pt, ->,shorten <=1pt] (a) edge[bend right=45] node[below]{\scriptsize\emph{emergency}{:} \cmark/\xmark} (b);
\end{tikzpicture}
}
\subcaption{Emergency situation:\\ $\A\ctlAU{\ctlAG\neg\varphi}{\ctlNext \textit{emergency}} $}
\label{fig:ruleEmergency}
\end{subfigure}%
\caption{
Illustrations for standard properties of physical access control are depicted. Gray boxes represent rooms and arrows represent directions of doors that can be opened~(\cmark), closed~(\xmark), or are not affected by the property (\cmark/\xmark).
}
\label{fig:rules}
\end{figure}
Figure~\ref{fig:rules} illustrates six typical specifications for physical access control~\cite{DBLP:conf/csfw/TsankovDB16,DBLP:conf/est/GeepallaBD13}.
\noindent
{\bf Permission.}
Permission (cf.\ \refFig{rulePermission}) requires that a subformula $\varphi$ can be reached on one path ($\A \ctlEF \varphi $).
In our running example, permission can be required for the \emph{hall} and the \emph{lab}.
Permission can be extended as it requires reaching the subformula once.
Persistent permission then requires that, on all paths, the subformula $\varphi$ can be repeatedly reached on a path ($\A\ctlAG\ctlEF \varphi $).
\noindent
{\bf Prohibition.}
Prohibition (cf.\ \refFig{ruleProhibition}) requires that a subformula $\varphi$, for example representing a room, can never be reached on any path ($\A\ctlAG \neg \varphi $).
In our running example, closing the door to the \emph{kitchen} would satisfy prohibition for the \emph{kitchen}.
\noindent
{\bf Blocking.}
Blocking (cf.\ \refFig{ruleBlocking}) requires for all paths globally that, after reaching subformula $\varphi$, the subformula $\psi$ cannot be reached ($\A\ctlAG (\varphi \Rightarrow \ctlAG \neg \psi)$).
This can be used to allow a new employee to only enter one of many labs.
\noindent
{\bf Way-pointing.}
Way-pointing (cf.\ \refFig{ruleWaypointing}) ensures for all paths that subformula~$\psi$ can only be reached if $\varphi$ was reached before ($\A\ctlAR{\varphi}{\neg\psi}$).
This can be used to enforce a mandatory security check when entering a building.
\noindent
{\bf Policy update.}
A policy update (cf.\ \refFig{ruleTimeChange}) allows access to subformula $\varphi$ according to a time schedule ($\A\ctlAG(\textit{time} \Rightarrow \ctlEF \varphi ) $) with \emph{time} being a transition.
This can be used to restrict access during the night.
\noindent
{\bf Emergency.}
An emergency situation (cf.\ \refFig{ruleEmergency}) can revoke the prohibition of subformula~$\varphi$ at an arbitrary time ($\A\ctlAU{\ctlAG\neg\varphi}{\ctlNext\textit{emergency}} $) with \emph{emergency} being a transition.
An otherwise closed door could be opened to evacuate people.
The next operator $\ctlNext$ is necessary because of the ingoing semantics of Flow-\ctlStarText{}.
\subsection{Run Formulas}
Flow formulas require behavior on the maximal flow of people in the building.
Doors are assumed to allow passthrough in a fair manner.
Both types of assumptions are expressed in Flow-\ctlStarText{} as run formulas.
\noindent
{\bf Maximality.}
A run $\runPN$ is \emph{interleaving-maximal} if, whenever some transition is enabled, some transition will be taken:
$\runPN \models \ltlAlways( \bigvee_{t \in \transitions} \pre{}{t} \rightarrow
\bigvee_{t \in \transitions} \ltlNext t)$.
A run~$\runPN$ is \emph{concurrency-maximal} if, when a transition $t$ is from a moment on always
enabled, infinitely often a transition $t'$ (including $t$ itself) sharing a precondition with $t$
is taken:
$\runPN \models \bigwedge_{t \in \transitions}
( \ltlEventually \ltlAlways\, \pre{}{t} \rightarrow
\ltlAlways \ltlEventually \bigvee_{{\small\begin{array}{c}
p\in \pre{}{t},
t'\in \post{}{p}
\end{array}}} t')$.
\noindent
{\bf Fairness.}
A run $\runPN$ is \emph{weakly fair} w.r.t.\ a transition $t$ if, whenever $t$ is always enabled after some point, $t$ is taken infinitely often:
{\(\runPN \models \ltlEventually \ltlAlways\, \pre{}{t} \rightarrow
\ltlAlways \ltlEventually t\)}.\\
A run $\runPN$ is \emph{strongly fair} w.r.t.\ $t$ if, whenever $t$ is enabled infinitely often, $t$ is taken infinitely often:
{\(\runPN \models \ltlAlways \ltlEventually\, \pre{}{t} \rightarrow \ltlAlways \ltlEventually t\)}.
\subsection{\ltlText{} on Petri Net Unfoldings}
\label{sec:ltl}
We recall \ltlText{} with \emph{atomic propositions} \(\AP=\pl\cup\tr\) on a Petri net \(\petriNet\)
and define the semantics on runs and their firing sequences.
We use the \emph{ingoing} semantics, i.e.,
we consider the marking and the transition used to enter the marking,
and \emph{stutter} in the last marking for finite firing sequences.
\emph{Syntactically}, the set of \emph{linear temporal logic}~(LTL) formulas \(\mathtt{LTL}\) over \(\AP\)
is defined by
\(\phiLTL ::= \true \mid a \mid \lnot \phiLTL \mid \phiLTL_1 \land \phiLTL_2 \mid
\ltlNext \phiLTL \mid \phiLTL_1 \ltlUntil \phiLTL_2,\)
with \(a\in\AP\) and \(\ltlNext\)~being the \emph{next} and \(\ltlUntil\) the \emph{until} operator.
As usual, we use the propositional operators \(\vee\), \(\rightarrow\), and \(\leftrightarrow\),
the temporal operators \(\ltlEventually \phiLTL=\true\ltlUntil\phiLTL\) (the \emph{eventually} operator)
and \(\ltlAlways\phiLTL=\lnot\ltlEventually\lnot\phiLTL\) (the \emph{always} operator)
as abbreviations.
For a Petri net \(\pNet\), we define a \emph{trace} as a mapping \(\trace:\N\to2^\AP\).
The \(i\)-th suffix \(\trace^i:\N\to2^\AP\) is a trace defined by \(\trace^i(j)=\trace(j+i)\) for all \(j\in\N\).
To a (finite or infinite) covering firing sequence \(\firingSequence= M_0\firable{t_0}M_1\firable{t_1}M_2\cdots\)
of a run \(\runPN=(\pNet^R,\rho)\) of \(\pNet\), we associate
a trace \(\trace(\firingSequence):\N\to 2^\AP\) with
\(\trace(\firingSequence)(0) = \rho(M_0)\),
\(\trace(\firingSequence)(i) = \{ \rho(t_{i-1})\}\cup\rho(M_i) \) for all \(i\in\N\setminus\{0\}\) if \(\firingSequence\) is infinite
and
\(\trace(\firingSequence)(i) = \{ \rho(t_{i-1})\}\cup\rho(M_i)\) for all \(0 < i \leq n\), and
\(\trace(\firingSequence)(j) = \rho(M_n)\) for all \(j > n\) if \(\firingSequence=M_0\firable{t_0} \cdots \firable{t_{n-1}}M_n\)
is finite.
Hence, a trace of a firing sequence covering a run is an infinite sequence of states collecting the corresponding marking
and ingoing transition of \(\pNet\), which stutters on the last marking for finite sequences.
The \emph{semantics} of an LTL formula \(\phiLTL \in \mathtt{LTL}\) on a Petri net \(\pNet\)
is defined over the traces of the covering firing sequences of its runs:
\(\pNet \models_\mathtt{LTL}\phiLTL\) iff for all runs \(\runPN\) of \(\pNet:\ \runPN \models_\mathtt{LTL} \phiLTL\),
\(\runPN \models_\mathtt{LTL}\phiLTL\) iff for all firing sequences \(\firingSequence\) covering \(\runPN:\ \sigma(\firingSequence) \models_\mathtt{LTL} \phiLTL\),
\(\sigma \models_\mathtt{LTL}\true\),
\(\sigma \models_\mathtt{LTL}a\) iff \(a \in \sigma(0)\),
\(\sigma \models_\mathtt{LTL}\lnot\phiLTL\) iff not \(\sigma \models_\mathtt{LTL} \phiLTL\),
\(\sigma \models_\mathtt{LTL}{\phiLTL}_1 \land {\phiLTL}_2\) iff \(\sigma \models_\mathtt{LTL} {\phiLTL}_1\) and \(\sigma \models_\mathtt{LTL} {\phiLTL}_2\),
\(\sigma \models_\mathtt{LTL}\ltlNext\phiLTL\) iff \(\sigma^1 \models_\mathtt{LTL} \phiLTL \), and
\(\sigma \models_\mathtt{LTL}{\phiLTL}_1\ltlUntil{\phiLTL}_2\) iff there exists a \(j\ge 0\) with \(\sigma^j \models_\mathtt{LTL} {\phiLTL}_2\) and \(\sigma^i \models_\mathtt{LTL} {\phiLTL}_1\) holds for all \(0 \le i < j\) .
\subsection{\ctlStarText{} on Flow Chains}
\label{sec:ctlStar}
To specify the data flow of a Petri net with transits \(\petriNetFl\), we use the complete \emph{computation tree
logic~(\ctlStarText)}. The set of \ctlStarText{} formulas~\(\mathtt{CTL^*}\) over \(\AP=\pl\cup\tr\)
is given by the following \emph{syntax} of \emph{state formulas}:
\(
\stateFormula ::= a \mid \lnot\,\stateFormula \mid \stateFormula_1 \land \stateFormula_2 \mid \ctlExists\, \pathFormula
\)
where \(a \in \AP\), \(\stateFormula\), \(\stateFormula_1\), \(\stateFormula_2\) are state formulas,
and \(\pathFormula\) is a \emph{path formula} with the following \emph{syntax}:
\(
\pathFormula ::= \stateFormula \mid \lnot\,\pathFormula \mid \pathFormula_1 \land \pathFormula_2 \mid \ctlNext\,\pathFormula \mid \pathFormula_1 \ctlUntil\, \pathFormula_2
\)
where~\(\stateFormula\) is a state formula and \(\pathFormula\), \(\pathFormula_1,\), \(\pathFormula_2\) are path formulas.
We use the propositional operators
\(\vee\), \(\rightarrow\), \(\leftrightarrow\),
the path quantifier \(\ctlAll\pathFormula=\lnot\ctlExists\lnot\pathFormula\),
and the temporal operators \(\ctlFinally\pathFormula=\true\,\ctlUntil\,\pathFormula\),
\(\ctlGlobally\pathFormula=\lnot\ctlFinally\lnot\pathFormula\), \(\pathFormula_1\ctlRelease\pathFormula_2=\lnot(\lnot\pathFormula_1\ctlUntil\lnot\pathFormula_2)\)
as abbreviations.
To a (finite or infinite) flow chain suffix \(\flowChain=t_0,p_0,t_1,p_{1},t_{2},\ldots\)
of a run \(\runPN=(\pNet^R,\rho)\) of \(\pNet\), we associate
a trace \(\trace(\flowChain):\N\to\mathcal{S}=\{\{t,p\},\{p\} \with p\in\pl^R\wedge t\in\tr^R\}\)
with \(\trace(\flowChain)(i) = \{t_i,p_i\}\) for all \(i\in\N\) if \(\flowChain\) is infinite
and
\(\trace(\flowChain)(i) = \{t_i,p_i\}\) for all \(i \leq n\), and
\(\trace(\flowChain)(j) = \{p_n\}\) for all \(j > n\) if \(\flowChain=t_0,p_0,t_1,p_{1},\ldots,t_{n},p_n\)
is finite.
Hence, a trace of a flow chain suffix is an infinite sequence of states collecting
the current place and ingoing transition of the flow chain,
which stutters on the last place \(p\) of a finite flow chain suffix.
We define \(\trace_\stutterSymbol(\{p\})(i)=\{p\}\) for all \(i\in\N\)
to stutter on the last place of a finite flow chain suffix.
The \emph{semantics} of a computation tree logic formula \(\ctlStarFormula\in\mathtt{CTL^*}\) is evaluated
on a given run \(\runPN=(\pNet^R,\rho)\) of the Petri net with transits \(\pNet\) and a state \(s\in\mathcal{S}\)
of a trace \(\trace(\flowChain)\) of a flow chain suffix \(\flowChain\) or the trace itself:
\[
\begin{array}{lll}
\runPN, s \satCTLStar a &\ \text{iff}\ & a \in \rho(s) \\[1mm]
\runPN, s \satCTLStar \lnot\, \stateFormula &\ \text{iff}\ & \text{not}\ \runPN, s \satCTLStar \stateFormula \\[1mm]
\runPN, s \satCTLStar \stateFormula_1 \land \stateFormula_2 &\ \text{iff}\ & \runPN, s\satCTLStar\stateFormula_1 \ \text{and}\ \runPN,s\satCTLStar\stateFormula_2 \\[1mm]
\runPN, s \satCTLStar \ctlExists\,\pathFormula &\ \text{iff}\ & \text{there \emph{exists} some flow chain suffix } \flowChain=t_0,p_0,\ldots \text{ of }\runPN\\[1mm]
&&\text{with } p_0\in s\text{ such that }\runPN,\trace(\flowChain)\satCTLStar\pathFormula\text{ holds for } s\not\subseteq\pl\\[1mm]
&&\text{and } \runPN,\trace_\stutterSymbol(s)\satCTLStar\pathFormula\text{ holds for } s\subseteq\pl\\[1mm]
\hline\\[-3mm]
\runPN,\trace \satCTLStar \stateFormula &\ \text{iff}\ & \runPN, \sigma(0) \satCTLStar \stateFormula\\[1mm]
\runPN,\trace \satCTLStar \lnot\, \pathFormula &\ \text{iff}\ & \text{not}\ \runPN, \trace \satCTLStar \pathFormula \\[1mm]
\runPN,\trace \satCTLStar \pathFormula_1 \land \pathFormula_2 &\ \text{iff}\ & \runPN,\trace\satCTLStar\pathFormula_1\ \text{and}\ \runPN,\trace\satCTLStar\pathFormula_2\\[1mm]
\runPN,\trace \satCTLStar \ctlNext\,\pathFormula &\ \text{iff}\ & \runPN,\trace^1 \satCTLStar \pathFormula \\[1mm]
\runPN,\trace\satCTLStar\pathFormula_1\ctlUntil\, \pathFormula_2 &\ \text{iff}\ & \text{there exists some } j\ge 0 \text{ with } \runPN,\trace^j \satCTLStar \pathFormula_2\text{ and} \\[1mm]
&&\text{for all } 0 \le i < j \text{ the following holds: } \runPN,\sigma^i \satCTLStar \pathFormula_1
\end{array}
\]
with atomic propositions \(a\in\mathit{AP}\), state formulas \(\stateFormula, \stateFormula_1\), and \(\stateFormula_2\), and path formulas \(\pathFormula,\pathFormula_1\), and \(\pathFormula_2\).
Note that since the formulas are evaluated on the runs of~\(\pNet\),
the branching is in the transitions and not in the places of \(\pNet\).
\subsection{Flow-\ctlStarText{}}
\label{sec:flowCTLStar}
Like in \cite{DBLP:conf/atva/FinkbeinerGHO19}, we use Petri nets with transits to enable reasoning
about two separate timelines.
Properties defined on the run of the system concern the \emph{global} timeline and
allow to reason about the global behavior of the system like its general control or fairness.
Additionally, we can express requirements about the individual data flow like the access possibilities of people in buildings.
These requirements concern the \emph{local} timeline of the specific data flow.
In Flow-\ctlStarText{}, we can reason about these two parts
with \ltlText{} in the \emph{run} and with \ctlStarText{} in the \emph{flow} part of the formula. This is
reflected in the following \emph{syntax}:
\[
\phiRun ::= \phiLTL \mid \phiRun_1 \land \phiRun_2
\mid \phiRun_1 \lor \phiRun_2
\mid \phiLTL \rightarrow \phiRun
\mid \A\,\ctlStarFormula
\]
where \(\phiRun\), \(\phiRun_1\), \(\phiRun_2\) are Flow-\ctlStarText{} formulas,
\(\phiLTL\) is an \ltlText{} formula,
and \(\ctlStarFormula\) is a \ctlStarText{} formula.
We call \(\flowFormula=\A\,\ctlStarFormula\) \emph{flow formulas}
and all other subformulas \emph{run formulas}.
The \emph{semantics} of a Petri net with transits \(\petriNetFl\) satisfying a Flow-\ctlStarText{} formula \(\phiRun\)
is defined over the covering firing sequences of its runs:
\[
\begin{array}{lll}
\pNet \models \phiRun &\ \text{iff}\ & \text{for all runs } \runPN \text{ of }\pNet: \runPN\models \phiRun \\[1mm]
\runPN \models \phiRun &\ \text{iff}\ & \text{for all firing sequences } \firingSequence \text{ covering } \runPN: \ \runPN, \sigma(\firingSequence) \models \phiRun\\[1mm]
\runPN,\sigma\models \phiLTL &\ \text{iff}\ & \sigma\satLTL\phiLTL\\[1mm]
\runPN,\sigma\models \phiRun_1 \land \phiRun_2 &\ \text{iff}\ & \runPN,\sigma\models\phiRun_1 \ \text{and}\ \runPN,\sigma\models\phiRun_2 \\[1mm]
\runPN,\sigma\models \phiRun_1 \lor \phiRun_2 &\ \text{iff}\ & \runPN,\sigma\models\phiRun_1 \ \text{or}\ \runPN,\sigma\models\phiRun_2 \\[1mm]
\runPN,\sigma\models \phiLTL \rightarrow \phiRun &\ \text{iff}\ & \runPN,\sigma\models\phiLTL \ \text{implies}\ \runPN,\sigma\models\phiRun\\[1mm]
\runPN,\sigma\models \A\,\ctlStarFormula &\ \text{iff}\ & \text{for all flow chains }\flowChain\text{ of }\runPN:\runPN,\sigma(\flowChain) \satCTLStar\ctlStarFormula
\end{array}
\]
Due to the covering of the firing sequences and the maximality constraint of the
flow chain suffixes, every behavior of the run is incorporated.
The operator~\(\A\) chooses flow chains rather than flow trees
as our definition is based on the common semantics of \ctlStarText{}
over paths.
Though it suffices to find one of the possibly infinitely many flow trees for each flow formula to
invalidate the subformula, checking the data flow while the control changes the system
complicates the direct expression of the model checking problem within a finite model.
In \refSection{mcFlowCTLStar}, we introduce a general reduction method
for a model with a finite state space.
\subsection{Automaton Construction for Flow Formulas}
\label{sec:automatonConstruction}
In Step 1, we create for each flow subformula \(\A\,\ctlStarFormula_i\) of \(\phiRun\) with atomic propositions \(\AP_i\)
a nondeterministic B\"uchi automaton \(\ba_{\neg\ctlStarFormula_i}\)
which accepts a sequence of transitions of a given run if the corresponding flow tree
satisfies \(\neg\ctlStarFormula_i\).
This construction has four steps:
\begin{enumerate}
\item[(i)] Create the labeled Kripke structure \(\kripke_{(\pNet,\AP_i)}\) which, triggered by transitions \(t\in\tr\),
tracks every flow chain of \(\pNet\). Each path corresponds to a flow chain.
\item[(ii)] Create the alternating tree automaton \(\tree_{\lnot \ctlStarFormula_i}\)
for the negation of the \ctlStarText{} formula \(\ctlStarFormula_i\) and the set of directions
\(\D\subseteq\{0,\ldots,\mathtt{max}\{\size{\post{\tokenflow}{p,t}}-1 \with p\in\pl \wedge t\in\post{\pNet}{p}\}\}\)
which accepts all \(2^{\AP_i}\)-labeled trees with nodes of degree in \(\D\) satisfying \(\lnot \ctlStarFormula_i\) \cite{DBLP:journals/jacm/KupfermanVW00}.
\item[(iii)] Create the alternating word automaton \(\aba_{\lnot \ctlStarFormula_i}=\tree_{\lnot \ctlStarFormula_i}\times\kripke_{(\pNet,\AP_i)}\) like in~\cite{DBLP:journals/jacm/KupfermanVW00}.
\item[(iv)] Alternation elimination for \(\aba_{\lnot\ctlStarFormula_i}\) yields the nondeterministic B\"uchi automaton \(\ba_{\lnot \ctlStarFormula_i}\)~\cite{DBLP:journals/tcs/MiyanoH84,DBLP:conf/lpar/DaxK08}.
\end{enumerate}
Step~(ii) and Step~(iv) are well-established constructions.
For Step~(iii), we modify the construction of \cite{DBLP:journals/jacm/KupfermanVW00}
by applying the algorithm for the groups of equally labeled edges.
By this, we obtain an alternating word automaton with the alphabet \(A=\tr\cup\{\stutterSymbol\}\)
of the labeled Kripke structure rather than an alternating word automaton over a 1-letter alphabet.
This allows us to check whether the, by the input transition dynamically created, system
satisfies the \ctlStarText{} subformula~\(\ctlStarFormula_i\).
Step (i) of the construction creates the labeled Kripke structure~\(\kripke_{(\pNet,\AP_i)}=(\AP,S,S_0,L,A,R)\)
with a set of \emph{atomic propositions} \(\AP=\AP_i\),
a finite set of \emph{states} \(S=((\tr\cap\AP)\times\pl)\cup\pl\),
the \emph{initial states} \(S_0\subseteq S\),
the \emph{labeling function} \(L: S\to 2^{\AP}\),
the \emph{alphabet} \(A=\tr\cup\{\stutterSymbol\}\),
and the \emph{labeled transition relation} \(R\subseteq S\times A\times S\).
The Kripke structure serves (in combination with the tree automaton)
for checking the satisfaction of a flow tree of a given run.
Hence, the states track the current place of the considered chain of the tree
and additionally, when the transition extending the chain into the place occurs in the formula,
also this ingoing transition.
The initial states \(S_0\) are either the tuples of transitions \(t_j\) and places \(p_j\)
which start a flow chain, i.e., all \((t_j,p_j)\in\tr\times\pl\) with \((\startfl,p_j)\in\tokenflow(t_j)\)
when \(t_j\in\AP\) or only the place \(p_j\) otherwise.
The labeling function \(L\) labels the states with its components.
The transition relation \(R\) connects the states with respect to the transits,
connects each state \((t,p)\in\kstates\) with \(\stutterSymbol\)-labeled edges
to the state \(p\in\kstates\),
and loops with \(\stutterSymbol\)-labeled edges in states \(s\in\pl\)
to allow for the stuttering of finite chains.
\begin{lemma}[Size of the Kripke Structure]
\label{lem:sizeKripkeStructure}
The constructed Kripke structure \(\kripke_{(\pNet,\AP_i)}\) has \(\oclass{\size{\AP_i\cap\tr}\cdot\size{\pNet}+\size{\pNet}}\) states
and \(\oclass{\size{\pNet^3}}\) edges.
\end{lemma}
Note that the number of edges stems from the number of transits \((p,t,q)\in\pl\times\tr\times\pl\)
used in the Petri net with transits \(\pNet\).
The size of the B\"uchi automaton is dominated by the tree automaton construction
and the removal of the alternation. Each construction adds one exponent for \ctlStarText{}.
\begin{lemma}[Size of the B\"uchi Automaton]
\label{lem:sizeBuchiAutomaton}
The size of the B\"uchi automaton~\(\ba_{\lnot \ctlStarFormula_i}\)
is in \(\oclass{2^{2^{\size{\ctlStarFormula}}\cdot\size{\pNet}^3}}\)
for specifications \(\ctlStarFormula_i\) in \ctlStarText{} and in
\(\oclass{2^{\size{\ctlStarFormula}\cdot\size{\pNet}^3}}\) for specifications in \ctlText{}.
\end{lemma}
\subsection{From Petri Nets with Transits to Petri Nets}
\label{sec:pnwt2pn}
In Step 2, we construct for the Petri net with transits \(\pNet\) and the B\"uchi automata~\(\ba_{\neg\ctlStarFormula_i}\)
for each flow subformula \({\flowFormula}_i=\A\,\ctlStarFormula_i\) of \(\phiRun\),
a Petri net \(\pNetMC\) by composing a copy of \(\pNet\) (without transits), denoted by \(\pNetMCO\),
to subnets \(\pNetMCSub{i}\) corresponding to \(\ba_{\neg\ctlStarFormula_i}\)
such that each copy is sequentially triggered when a transition of \(\pNetMCO\) fires.
The subnet \(\pNetMCSub{i}\), when triggered by transitions \(t\in\tr\),
guesses nondeterministically the violating flow tree of the operator \(\A\)
and simulates \(\ba_{\neg\ctlStarFormula_i}\).
Thus, a token from the initially marked place \(\initsub_i\) is moved
via a transition for each transition \(t\in\tr\) starting a flow chain
to the place corresponding to the initial state of \(\ba_{\neg\ctlStarFormula_i}\).
For each state \(s\) of \(\ba_{\neg\ctlStarFormula_i}\), we have a place~\(\subnet{s}_i\),
and, for each edge \((s,l,s')\), a transition labeled by \(l\)
which moves the token from \(\subnet{s}_i\) to \(\subnet{s'}_i\).
There are two kinds of stutterings: \emph{global} stuttering for finite
runs and \emph{local} stuttering for finite flow chains.
To guess the starting time of both stutterings,
there is an initially marked place \(\normalMode\), a place \(\stutteringMode\),
and a transition which can switch from \emph{normal} to \emph{stuttering} mode
for the global stuttering in~\(\pNetMCO\) and for the local stutterings in each subnet \(\pNetMC_i\)
(denoted by \(\subnet{\normalMode}\),\(\subnet{\stutteringMode}\)).
The original transitions of~\(\pNetMCO\) and the transitions of a subnet \(\pNetMC_i\) corresponding to
a transition \(t\in\tr\) depend on the normal mode.
The \(\stutterSymbol\)-labeled transitions (used for global stuttering)
of the subnet depend on the stuttering mode.
To enable local stuttering, we add, for each edge \(e=(s,\stutterSymbol,s')\) of \(\ba_{\neg\ctlStarFormula_i}\),
a transition \(t\MC\) for each transition \(t\in\tr\) for which no edge \((s,t,s'')\) exists in \(\ba_{\neg\ctlStarFormula_i}\).
These transitions depend on the stuttering mode and move the token according to
their corresponding edge~\(e\).
The original part \(\pNetMCO\) and the subnets \(\pNetMCSub{i}\) are
connected in a sequential manner.
The net \(\pNetMCO\) has an initially marked activation place \(\act{o}\) in the preset of each transition,
the subnets have one activation place \(\subnet{\act{t}}\) in the preset of every
transition \(t\MC\) corresponding to a transition \(t\in\tr\) (normal as well as stuttering).
The transitions move the activation token to the corresponding places of the next subnet (or back to \(\pNetMCO\)).
To ensure the continuation even though the triggering transition does not extend the current flow tree
(e.g., because it is a concurrent transition of the run),
there is a skipping transition for each transition \(t\in\tr\) which moves the activation token
when none of the states having a successor edge labeled with \(t\) are active.
For the global stuttering, each subnet has an activation place \(\subnet{\act{\stutterSymbol}}_i\),
in which an additional transition \(t_\stutterSymbol\) in \(\pNetMCO\) puts the active token
if the stuttering mode of \(\pNetMCO\) is active.
Each \(\stutterSymbol\)-labeled transition of the subnets moves this token to the next subnet (or back to \(\pNetMCO\)).
By that, we can check the acceptance of each \(\ba_{\neg\ctlStarFormula_i}\)
by checking if the subnet infinitely often reaches any places corresponding
to a B\"uchi state of \(\ba_{\neg\ctlStarFormula_i}\).
This and only allowing to correctly guess the time point of the stutterings
is achieved with the formula described in \refSection{flowCTLStar2LTL}.
A formal definition is given in \refDef{pnwt2pn} in App.~\ref{app:defsAndProofs}.
The size of the constructed Petri net is dominated by the respective single- or double-exponential size
of the nondeterministic B\"uchi automata.
\begin{lemma}[Size of the Constructed Net]
\label{lem:sizeMCNet}
The constructed Petri net with inhibitor arcs \(\pNetMC\) for a Petri net with transits \(\pNet\) and
\(n\) nondeterministic B\"uchi automata
\(\ba_{\lnot \ctlStarFormula_i}=(\tr\cup\{\stutterSymbol\}, Q_i, I_i, E_i,F_i)\)
has \(\oclass{\size{\pNet}\cdot n + \size{\pNet} +\sum_{i=1}^n\size{Q_i}}\)
places and \(\oclass{\size{\pNet}^2\cdot n + \size{\pNet}+\sum_{i=1}^n\size{E_i}+\size{\pNet}\cdot\sum_{i=1}^n\size{Q_i}}\)
transitions.
\end{lemma}
\subsection{From Flow-\ctlStarText{} Formulas to \ltlText{} Formulas}
\label{sec:flowCTLStar2LTL}
The formula transformation from a given Flow-\ctlStarText{} formula \(\phiRun\)
and a Petri net with transits \(\pNet\) into an \ltlText{} formula (Step 3)
consists of three parts:
First, we substitute the flow formulas \({\flowFormula}_i=\A\,\ctlStarFormula_i\)
with the acceptance check of the corresponding automaton \(\ba_{\neg\ctlStarFormula_i}\), i.e.,
we substitute \({\flowFormula}_i\) with \(\lnot\ltlAlways\ltlEventually\bigvee_{b\in F_i} \subnet{b}_i\)
for the B\"uchi states \(F_i\) of \(\ba_{\neg\ctlStarFormula_i}\).
Second, the sequential manner of the constructed net \(\pNetMC\) requires an adaptation of the
run part of \(\phiRun\).
For a subformula \(\phiLTL_1\ltlUntil\phiLTL_2\) with transitions \(t\in\tr\) as atomic propositions
or a subformula \(\ltlNext\,\phiLTL\) in the run part of \(\phiRun\),
the sequential steps of the subnets have to be skipped.
Let \(\trMC_O\) be the transition of the original copy~\(\pNetMC_O\),
\(\trMC_i\) the transitions of the subnet \(\pNetMC_i\),
\(\tr_{\skipT_i}\) the transitions of the subnet \(\pNetMC_i\)
which skip the triggering of the automaton in the normal mode, and
\(t_{\normalMode\to\stutteringMode}\) the transition switching \(\pNetMC_O\) from normal to stuttering mode.
Then, because of the ingoing semantics, we can can select all states corresponding
to the run part with \(\mathtt{M}=\bigvee_{t\in\trMC_O\setminus\{t_{\normalMode\to\stutteringMode}\}} t\) together with the
initial state \(\mathtt{i}=\neg\bigvee_{t\in\trMC} t\).
Hence, we replace each subformula \(\phiLTL_1\ltlUntil\phiLTL_2\)
containing transitions \(t\in\tr\) as atomic propositions with
\(((\mathtt{M}\vee\mathtt{i})\rightarrow\phiLTL_1)\ltlUntil((\mathtt{M}\vee\mathtt{i})\rightarrow\phiLTL_2)\)
from the inner- to the outermost occurrence.
For the next operator, the second state is already the correct next state of the initial state
also in the sense of the global timeline of \(\phiLTL\MC\).
For all other states belonging to the run part (selected by the until construction above),
we have to get the next state and then skip all transitions of the subnet.
Thus, we replace each subformula \(\ltlNext\, \phiLTL\) with
\(\mathtt{i}\rightarrow\ltlNext\,\phiLTL
\wedge
\neg\mathtt{i}\rightarrow\ltlNext(\bigvee_{t\in\trMC\setminus\trMC_O}t\ltlUntil\bigvee_{t'\in\trMC_O}t'\wedge\phiLTL)\)
from the inner- to the outermost occurrence.
Third, we have to ensure the correct switching into the stuttering mode.
By \(\mathtt{skip_i}=\neg\ltlEventually\ltlAlways((\bigvee_{t\in\trMC_i} t)\rightarrow(\bigvee_{t'\in\tr_{\skipT_i}} t'))\)
a subnet is enforced to switch into its stuttering mode if necessary.
If it wrongly selects the time point of the global stuttering, the run stops.
Hence, we obtain the formula
\(\phiLTL\MC=(\left(\ltlAlways\ltlEventually\act{o}\right)\wedge\bigwedge_{i\in\{1,\ldots,n\}}\mathtt{skip_i})\rightarrow\phiLTL\)
by only selecting the runs where the original part is infinitely often activated
and each subnet chooses its stuttering mode correctly.
Since the size of the formula depends on the size of the constructed Petri net~\(\pNetMC\),
it is also dominated by the B\"uchi automaton construction.
\begin{lemma}[Size of the Constructed Formula]
\label{lem:sizeFormula}
The size of the constructed formula \(\phiLTL\MC\) is double-exponential for specifications given in \ctlStarText{} and single-exponential
for specifications in \ctlText{}.
\end{lemma}
We can show that the construction of the net and the formula adequately fit together
such that the additional sequential steps of the subnets are skipped in the formula
and the triggering of the subnets simulating the B\"uchi automata as well as the stuttering
is handled properly.
\begin{lemma}[Correctness of the Transformation]
\label{lem:correctnessTransformation}
For a Petri net with transits \(\pNet\)
and a Flow-\ctlStarText{} formula \(\phiRun\),
there exists a safe Petri net \(\pNetMC\) with inhibitor arcs
and an LTL formula \(\phiRun\MC\)
such that \(\pNet\models\phiRun\) iff \(\pNetMC\satLTL\phiRun\MC\).
\end{lemma}
The complexity of the model checking problem of Flow-\ctlStarText{} is dominated by the
automata constructions for the \ctlStarText{} subformulas.
The need of the alternation removal (Step (iv) of the construction)
is due to the checking of branching properties
on structures chosen by linear properties.
In contrast to standard \ctlStarText{} model checking on a static Kripke structure,
we check on Kripke structures dynamically created for specific runs.
\begin{theorem}
\label{theo:complexityMC}
A safe Petri net with transits \(\pNet\) can be checked against a Flow-\ctlStarText{} formula \(\phiRun\) in
triple-exponential time in the size of \(\pNet\) and \(\phiRun\).
For a Flow-\ctlText{} formula \(\phiRun'\), the model checking algorithm runs in double-exponential time in
the size of \(\pNet\) and \(\phiRun'\).
\end{theorem}
Note that a single-exponential time algorithm for Flow-LTL is presented in \cite{DBLP:conf/atva/FinkbeinerGHO19}.
\section{Introduction}
\label{sec:intro}
\input{introduction}
\section{Motivating Example}
\label{sec:motivation}
\input{motivatingExample}
\section{Petri Nets with Transits}
\label{sec:petri-nets}
\input{petriNetWithTransits}
\section{Flow-\ctlStarText{} for Petri Nets with Transits}
\label{sec:FlowCTLStar}
We define the new logic \emph{Flow-\ctlStarText{}} to reason
about the Petri net behavior and the data flow individually.
Properties on the selection of runs and the general behavior of the net
can be stated in \ltlText{}, requirements on the data flow in \ctlStarText{}.
\input{flowCTLStar}
\section{Example Specifications}
\label{sec:applications}
\input{applications}
\section{Model Checking Flow-\ctlStarText{} on Petri Nets with Transits}
\label{sec:mcFlowCTLStar}
\input{mcFlowCTLStar}
\section{Related Work}
\label{sec:related-work}
\input{relatedWork}
\section{Conclusion}
\label{sec:conclusion}
\input{conclusion}
\bibliographystyle{splncs04}
| {'timestamp': '2020-07-15T02:22:51', 'yymm': '2007', 'arxiv_id': '2007.07235', 'language': 'en', 'url': 'https://arxiv.org/abs/2007.07235'} | arxiv |
\section{Introduction}
\label{sec:introduction}
The high dimensionality of modern data introduces significant challenges in descriptive and exploratory data analysis. These challenges gave rise to extensive work on dimensionality reduction aiming to provide low dimensional representations that preserve or uncover intrinsic patterns and structures in processed data. A common assumption in such work is that high dimensional measurements are a result of (often nonlinear) functions applied to a small set of latent variables that control the observed phenomena of interest, and thus one can expect an appropriate embedding in low dimensions to recover a faithful latent data representation. While classic approaches, such as principal component analysis (PCA)~\cite{pearson1901} and classical multidimensional scaling (MDS)~\cite{cox2008multidimensional}, construct linear embeddings, more recent attempts mostly focus on nonlinear dimensionality reduction. These approaches include manifold learning kernel methods and deep learning autoencoder methods, each with their own benefits and deficiencies.
Kernel methods for manifold learning cover some of the most popular nonlinear dimensionality reduction methods, dating back to the introduction of Isomap~\cite{tenenbaum2000global} and Locally Linear Embedding (LLE)~\cite{roweis2000nonlinear}. These two methods proposed the notion of data manifolds as a model for intrinsic low dimensional geometry in high dimensional data. The manifold construction in both cases is approximated by a local neighborhood graph, which is then leveraged to form a low-dimensional representation that preserves either pairwise geodesic distances (in the case of Isomap) or local linearity of neighborhoods (in LLE). The construction of neighborhood graphs to approximate manifold structures was further advanced by Laplacian eigenmaps~\cite{belkin2002laplacian} and diffusion maps \cite{coifman2006diffusion}, together with a theoretical framework for relating the captured geometry to Riemannian manifolds via the Laplace-Beltrami operators and heat kernels. These approaches that, until recently, dominated manifold learning can collectively be considered as spectral methods, since the embedding provided by them is based on the spectral decomposition of a suitable kernel matrix that encodes (potentially multiscale) neighborhood structure from the data. They are also known as kernel PCA methods, as they conceptually extend the spectral decomposition of covariance matrices used in PCA, or that of a Gram (inner product) matrix used in classic MDS.
Recent work in dimensionality reduction has focused on visualization for data exploration. Spectral methods are generally unsuitable for such tasks because, while their learned representation has lower dimension than the original data, they tend to embed data geometry in more dimensions than can be conveniently visualized (i.e., $\gg 2$ or 3). This is typically due to the orthogonality constraint and linearity of spectral decompositions with respect to the initial dimensionality expansion of kernel constructions~\cite{moon2019visualizing,haghverdi2016diffusion}. This led to the invention of methods like t-SNE (t-Distributed Stochastic Neighbor Embedding) \cite{maaten2008visualizing}, UMAP (Uniform Manifold Approximation and Projection) \cite{UMAP2018}, and PHATE (Potential of Heat-diffusion for Affinity-based Transition Embedding) \cite{moon2019visualizing}. These methods embed the data by preserving pairwise relationships between points and can be viewed as generalizations of metric and non-metric MDS. These methods and their extensions have been used in applications such as single cell genomics~\cite{moon2019visualizing,amir2013visne,sgier2016flow,macosko2015highly,becht2019dimensionality,zhao2020single,karthaus2020regenerative,baccin2019combined}, visualizing time series~\cite{duque2019}, visualizing music for a recommendation system~\cite{van2013deep}, and analyzing the internal representations in neural networks~\cite{2019Gigante,horoi2020low}. However, these and spectral methods typically provide fixed latent coordinates for the input data. Thus, they do not provide a natural embedding function to perform out-of-sample extension (OOSE). This shortcoming is usually tackled by employing geometric harmonics \cite{coifman2006geometric}, Nystr\"om extension \cite{williams2001using}, or a landmark approach \cite{vladymyrov2013locally}.
In contrast, Autoencoders (AEs) are a different paradigm for non-linear dimensionality reduction. First introduced in \cite{rumelhart1986learning}, this non-convex and parametric approach has gained more attention in recent years, especially due to the computational and mathematical advances in the field enabling the efficient implementation and training of neural networks. In contrast to kernel methods, AEs learn a parametric function and are thus equipped with a natural way to perform OOSE, as well as an inverse mapping from the latent to the input space. Despite these properties, AEs usually fail to accurately recover the geometry present in the data. This not only restricts their desirability to perform exploratory data analysis, e.g. via low-dimensional visualization, but can also lead to bad reconstructions over certain regions of the data, as we show in this work.
Motivated by the complementary advantages provided by AE and kernel methods, we introduce Geometry regularized autoencoders (GRAE), a general framework which splices the well-established machinery from kernel methods to recover a sensible geometry with the parametric structure of AEs. Thus we gain the benefits of both methods, furnishing kernel methods with efficient OOSE and inverse mapping, and providing the autoencoder with a geometrically driven representation. To achieve this, GRAE introduces a regularization on the latent representation of the autoencoder, guiding it towards a representation previously learned by a kernel method.
In this paper we focus our presentation using PHATE \cite{moon2019visualizing} as our preferred method for finding a sensible geometry.
Nevertheless, our general formulation can also be easily implemented with other methods such as UMAP.
Our main contributions are as follows:
\begin{enumerate*}
\item We present a general approach to leverage traditional dimensionality reduction and manifold learning methods, providing them with a natural OOSE and an invertible mapping.
\item By introducing the geometric regularization, the reconstruction error of the Autoencoder decreases in many cases, suggesting that the previously learned geometry leads to a better representation for reconstruction.
\item We show how our method can be implemented in a big data setting, which is a common limitation in related work.
\end{enumerate*}
\section{Related Work}
\label{sec:related_work}
\paragraph{Manifold learning}
Manifold learning methods for dimensionality reduction typically assume data lie on a low dimensional manifold $\mathcal{M}$ immersed in the high dimensional ambient space. Therefore they aim to map points from $\mathcal{M}$ to a low dimensional Euclidean space that encodes or reveals its intrinsic geometry. However, in practice, such methods only consider a finite set of data points $x_{1}, \ldots, x_{n} \in \mathbbm{R}^\mathcal{D}$ (for $\mathcal{D}$ dimensional ambient space), assumed to be sampled from $\mathcal{M}$, and optimize a fixed set of low dimensional points $y_{1}, \ldots, y_{n} \in \mathbbm{R}^d$ (for $d \ll D$) such that the Euclidean relations between pairs $(y_i,y_j)$ will reflect intrinsic nonlinear relations between the corresponding $(x_i,x_j)$. Recent manifold learning kernel methods typically follow the framework introduced in \cite{snepaper} and further extended by t-SNE \cite{maaten2008visualizing}, which are themselves generalization of the metric MDS algorithm, whereby the coordinates in the latent space are optimized by gradient descent to recreate the pairwise similarities (as defined by a kernel) in the input space. Intuitively, the use of a kernel which outputs high similarities for close neighbors enables the capture of the curvature of the underlying manifold in the ambient space. t-SNE, for instance, uses normalized Gaussian similarities in the input space and t-distributed similarities in the latent space. The embedding is optimized so as to minimize the Kullback-Leibler divergence between both distributions.
UMAP \cite{UMAP2018} was introduced as an improvement of t-SNE, with claims of improved preservation of global features and better run times. Specifically, the cost function of t-SNE is replaced by cross-entropy and similarities between objects in the input space are computed based on the smooth nearest neighbor distances, that is: $v_{j|i}= exp((-d(x_i, x_j) - p_i) /\sigma_i)$, where $p_i$ is the distance between $x_i$ and its nearest neighbor, $\sigma_i$ is the bandwidth and $d$ is a distance, not necessarily Euclidean. In contrast with t-SNE, UMAP does not normalize similarities and relies on an approximation of the neighborhoods using the Nearest-Neighbor-Descent algorithm of \cite{dong2011efficient}. The UMAP implementation further distinguishes itself from t-SNE by not restricting the embedded space to two or three dimensions.
Recently, the claim that UMAP improves over t-SNE in preserving global structure has been challenged in \cite{kobak2019umap}. The authors attribute the better global structure commonly obtained by UMAP to the differences between both methods in the initialization procedure. Typically t-SNE uses a random initialization, whereas UMAP uses Laplacian eigenmaps as its starting point. They showed that nearly identical results can be obtained by also initializing t-SNE with Laplacian eigenmaps.
\paragraph{Autoencoders}
PCA naturally provides an extendable and (approximately) invertible embedding function, but falls short in capturing non-linear mappings. To see this, recall that the embedding function is constructed using a matrix $M$ with orthogonal columns consisting of principal components (PCs) such that $M M^T$ is a projection operator, thus acting as an identity on a hyperplane spanned by the PCs. Then, the embedding is given by the linear function $\hat{x} = M^T x$ and its inverse (on the embedded space) is given by $M \hat{x} = M M^T x \approx x$, where the approximation quality (i.e. reconstruction error) serves as the optimization target for computing the PCs in $M$.
To generalize this construction to nonlinear embedding functions over a data manifold $\mathcal{M}$, autoencoders (AEs) replace $M$ by an encoder function $f: \mathcal{M} \xrightarrow{} \mathbbm{R}^d$ and $M^T$ by a decoder function $f^{\dagger}: \mathbbm{R}^d \xrightarrow{} \mathcal{M}$, which is an approximate inverse of $f$. Both functions are parametrized by a neural network and trained via a reconstruction loss to ensure the composite function $f^{\dagger} \circ f$ acts as an identity on data sampled from $\mathcal{M}$. By considering datasets in matrix notation (i.e., with rows as datapoints), the AE optimization is generally formulated as
\begin{align}
\label{eq:AE}
\operatorname*{arg\ min}_{f,f^{\dagger}}\mathcal{L}(f,f^{\dagger}) = \mathcal{L}_{r}(X, f^{\dagger}(f(X))),
\end{align}
where $f,f^{\dagger}$ are understood to be applied separately to each row in their input matrix (yielding corresponding output data points organized in matrix form), and $\mathcal{L}_{r}$ denotes a loss function that measures the discrepancy between the original and reconstructed data points (commonly MSE). It is common to select $d < \mathcal{D}$, forcing the autoencoder to find a representation in latent codes of dimension $d$ while retaining as much information for reconstruction as possible. In this case the autoencoder is \textit{undercomplete}. Under this formulation, instead of learning new coordinates for the input data, we learn an embedding function $f$ and an inverse function $f^{\dagger}$. If $f$ is a linear function, the network will project onto the same subspace spanned by the principal components in PCA~\cite{baldi1989neural}.
\paragraph{Regularized autoencoders}
The vanilla AE formulation in (\ref{eq:AE}) has been extended for many purposes by adding regularization as a prior on the function space of $f$ and $f^{\dagger}$. Denoising AEs \cite{vincent2008extracting} are widely used to find good latent representations and perform feature extraction, exploiting the flexibility provided by neural networks (e.g. \cite{supratak2014feature,liu2014feature}). Contractive autoencoders (CAE) \cite{rifai2011contractive} penalize the Frobenius norm of the Jacobian of the encoder $f$, encouraging a more robust representation around small perturbations from the training data. When dealing with a high dimensional latent space (e.g., the \textit{overcomplete} case), sparse autoencoders \cite{ng2011sparse} are particularly useful, introducing a sparsity constraint that forces the network to learn significant features in the data. Extensions to produce generative models, such as variational autoencoders (VAE) \cite{kingma2013auto}, regularize the latent representation to match a tractable probability distribution (e.g., isotropic multivariate Gaussian), from which it is possible to sample over a continuous domain to generate new points.
More closely related to our work, some attempts to impose geometrically driven regularizations on the latent space have been proposed over the past two decades. Stacked Similarity-Aware Autoencoders, for instance, enforce a cluster prior based on pseudo-class centroids to increase subsequent classification performance \cite{chu2017stacked}.
A relatively new implementation called Diffusion Nets~\cite{mishne2019diffusion} encourages the AE embedding to learn the geometry from Diffusion Maps (DM)~\cite{coifman2006diffusion}, a manifold learning algorithm. This approach combines an MSE loss in the embedding coordinates with the so-called eigenvector constraint to learn the diffusion geometry. Diffusion Nets inherits some of the inherent issues of Diffusion Maps. Perhaps most importantly, they inherit its inability as a spectral method to ensure significant representation of the data on a fixed lower dimension, due to the natural orthogonality imposed among the diffusion coordinates~\cite{moon2019visualizing}. Therefore, effective use of Diffusion Nets may require the network architecture
to be determined from the numerical rank of the diffusion affinity kernel used in DM. This, in turn, would limit the capabilities of this approach in data exploration (e.g., visualization), while in contrast PHATE (and UMAP) can specifically optimize a chosen dimension (e.g., 2D or 3D). Moreover, as a spectral method, DM itself\footnote{We note that the DM runtime (relative to UMAP) is equivalent to that of Laplacian eigenmaps reported in~\cite{UMAP2018}, as the algorithmic difference between these spectral methods is negligible~\cite{coifman2006diffusion}.} tends to be more computationally expensive than PHATE (which we use in this work, see Sec. \ref{sec:GRAE}) or UMAP~\cite{moon2019visualizing,UMAP2018}.
The formulation of Diffusion Nets is closely related to Laplacian autoencoders (LAE)~\cite{jia2015laplacian} and Embedding with Autoencoder Regularization (EAER)~\cite{yu2013embedding}. Both of these methods include a regularization term that penalizes inaccurate preservation of neighborhood relationships in the original space:
\begin{multline}
\operatorname*{arg\ min}_{f,f^\dagger}\mathcal{L}(f,f^\dagger) = \mathcal{L}_{r}(X, f^\dagger(f(X)))\\ + \lambda\sum_{i < j}^{n}\mathcal{L}'(f(x_{i}),f(x_{j}), \phi_{ij}).
\label{lae}
\end{multline}
For instance, in EAER the second term can be the classical MDS objective $\sum_{i < j}^{n} (\|f(x_{i})- f(x_{j})\| - d_{ij})^{2}$ where $d_{ij}$ is a given distance computed in the input space. It can also be margin-based, where embedding distances between neighbors are penalized if not 0, while distances between non-neighbors are penalized if not above a certain margin. Finally, $\mathcal{L'}$ can take the form $\sum_{i < j}^{n} \|f(x_{i})- f(x_{j})\|^{2}\phi_{ij}$, where $\phi_{ij}$ are computed using the weighted edges in an adjacency graph. This gives the objective function of Laplacian eigenmaps. LAE employs a similar loss term, but goes further by adding a second order term including the Hessian of $f$.
Another interesting approach derived from manifold learning methods can be found in \cite{pai2019dimal}. The authors aimed to replicate Isomap's objective function by using a SIAMESE network architecture trained over the pairwise geodesic distances. Their method, however, scales quadratically in the number of landmarks selected for training.
Recently, topological autoencoders (TAE) \cite{moor2019topological} were proposed which include a regularization based on a topological signature of the input data. The topology of a manifold can be characterized by \textit{homology groups}, which, depending on their dimension, represent various topological features such as the number of disconnected components or the number of cycles on the manifold that cannot be deformed into each another. When data are sampled from a manifold, such topological features can be approximately derived from a $\varepsilon$-ball neighborhood graph of the data. Persistent homology \cite{edelsbrunner2008persistent,barannikov1994framed} was introduced as a means to identify the topological signature of manifolds based on how long topological features persist when progressively increasing the $\varepsilon$-ball of the neighborhood graph up to a point where the graph is fully-connected (topological features with a short $\varepsilon$ lifespan are attributed to noise). TAE thus penalizes discrepancies between the topological signatures of the input space and the latent space.
\paragraph{Out of sample extension}
Manifold learning algorithms are typically based on the eigendecomposition of a kernel matrix (Diffusion Maps) or a stochastic optimization of the latent coordinates (metric MDS, UMAP). Therefore, in constrast to neural networks, they do not provide a general embedding function that operates on, or provides a representation of, the entire manifold $\mathcal{M}$. Thus these methods are not applicable to arbitrary input points in $\mathbbm{R}^\mathcal{D}$, which we would ideally want to project onto the learned manifold. To address this shortcoming, a parametric version of t-SNE using a neural network approach was proposed in \cite{van2009learning} where a multi-step training procedure is used to optimize the t-SNE objective with a neural network.
Another well-known solution to the lack of OOSE is the Nystr\"{o}m extension \cite{bengio2004out} and its improvements, such as geometric harmonics \cite{coifman2006geometric}, which approximate an empirical function over new points using linear combinations of the eigenvectors of a kernel matrix computed on the training set. Let $X = \{x_1, ... , x_m\}$ be the training set used to compute the initial kernel matrix $K$ with kernel function $k(\cdot, \cdot)$. Then a new point $x'$ can be extended to the learned latent space using the eigenvectors $\psi_i$ of $K$ with eigenvalues $\lambda_i$ as follows: $\hat{\psi_i}(x') \approx \frac{1}{\lambda_i}\sum\limits_{j=1}^{m}k(x_j, x')\psi_j(x_j)$.
One can thus project a function on the eigenvectors of $K$ and then extend to new points using the new approximated eigenvectors. However, this approach has several drawbacks \cite{mishne2019diffusion}. Given $n$ training points (resulting in $K$ being $n\times n$), extending a function to $m$ points requires us to compute $m$ new kernel rows leading to a time complexity of $\mathcal{O}(nm)$. Furthermore, the empirical function must be within the interpolation range of the kernel, which requires bandwidth tuning.
Other methods, perform OOSE by a linear combination of training points (the ``landmarks'') close to the new points in the input space \cite{vladymyrov2013locally}, as in PHATE~\cite{moon2019visualizing} and landmark MDS~\cite{silva2003global}. UMAP takes a similar approach to OOSE by initializing latent coordinates of new points in the latent space based on their affinities with training points in the input space. The new layout is then optimized by gradient descent following the same optimization scheme as the main algorithm, using the embeddings of training points as reference.
All of these approaches require the training points, or a subset, to be stored in memory with their embeddings as a proxy for the target function, which can quickly become inconvenient given a large dataset or lead to a loss in embedding quality due to subsampling or the use of landmarks. Moreover, they do not provide a straightforward approximation of the inverse function, which is critical in assessing how well the information is preserved in the embedded space. As such, they are not directly comparable to GRAE and other AE based models, which present a native approximation of the inverse and only need to store the weights and biases of the network to perform OOSE, thus having memory requirements independent of the size of the training set.
\section{Geometry-regularized autoencoder}
\label{sec:GRAE}
\subsection{Learning embedding functions}
In this work, we aim to learn a data manifold geometry to find an appropriate embedding function $f : \mathcal{M} \to \mathbbm{R}^d$, rather than just a fixed point-cloud embedding. This contrast can be seen, for example, by considering the classic PCA and MDS methods. While both of these methods can be shown analytically to extract equivalent (or even the same) linear embeddings from data, MDS only assigns coordinates to fixed input points (similar to the described manifold learning methods), while PCA provides an embedding function (albeit linear) defined by a projection operator on principal components. Here, we aim to establish a similar equivalence in nonlinear settings by providing an alternative to popular manifold learning approaches that constructs an embedding function (as a nonlinear successor of PCA) and also yields representations that capture an intrinsic geometry similar to that of established kernel methods (seen as successors of MDS).
\subsection{Extendable and invertible embedding with autoencoders}
The AE formulation presented (\ref{eq:AE}) departs from manifold learning approaches as it lacks an explicit condition to recover geometrical interactions between observations. To fill that gap, we propose a general framework called GRAE (Geometry regularized autoencoders) which explicitly penalizes misguided representations in the latent space from a geometric perspective. Thus, we add a soft constraint in the bottleneck of the autoencoder as follows:
\begin{align}
\label{eq:GRAE}
\operatorname*{arg\ min}_{f,f^{\dagger}}\mathcal{L}(f,f^{\dagger}) = \mathcal{L}_{r}(X, f^{\dagger}(f(X))) + \lambda\mathcal{L}_{g}(f(X), \mathcal{E}).
\end{align}
The $\mathcal{L}_g$ term in (\ref{eq:GRAE}) is the geometric loss, penalizing the discrepancy between the latent representation and the embedding $\mathcal{E}$ previously learned by a manifold learning algorithm. Specifically, given an embedding of training points $\mathcal{E} = \{e_{1}, e_{2}, \ldots, e_{n}\}$, we define the geometric loss as $\mathcal{L}_{g}(f(X), \mathcal{E}) = \sum_{i=1}^{n} \|e_{i} - f(x_{i})\|^{2}$.
The parameter $\lambda\geq 0$ determines how strongly the latent space of the AE should match the embedding $\mathcal{E}$. Thus the network will implicitly force the latent space of the autoencoder to preserve the relationships learned by the manifold learning technique, resulting in a non-linear embedding function $f$ and its inverse $f^\dagger$ that are consistent with sensible geometric properties. This regularization can be applied with any manifold learning approach, whether it be Isomap, t-SNE, etc. The resulting latent space will then inherit the corresponding strengths and weaknesses of the selected approach.
\subsection{Geometric regularization with diffusion manifold learning}
To generate $\mathcal{E}$ in this work, we use PHATE~\cite{moon2019visualizing} as it has proven to preserve long-range relationships (global structure) in a low-dimensional representation beyond the capabilities of spectral methods such as Laplacian eigenmaps, Diffusion Maps, LLE, and Isomap, especially when the dimension $d$ is required to be 2 or 3 for visualization. PHATE is built upon diffusion geometry \cite{coifman2006diffusion,nadler2006diffusion}. PHATE first computes an $\alpha-$decay kernel with an adaptive bandwidth, which captures local geometry while remaining robust to density changes. The kernel matrix is normalized to obtain a probability transition matrix $P$ (diffusion operator) between every pair of points. Various scales of the geometry can then be uncovered by computing a $t$-step random walk over $P$, with a higher $t$ implying more diffusion, pushing transition probabilities to a more global scale.
The parameter $t$ is automatically chosen by studying the entropy of a distribution over the eigenvalues of $P$ (known as the von Neumann Entropy) as $t$ increases. Typically, the first few $t$-steps lead to a sharp drop in the entropy, which is thought in \cite{moon2019visualizing} to be the process of denoising the transition probabilities, whereas later steps will reduce entropy at a lower rate, thus, slowly losing meaningful information in the structure. Subsequently PHATE computes the so-called potential distances $D'_{t}$, which have proven to be adequate distances between the transition probabilities encoded in $P^{t}$. Finally, metric MDS is applied to $D'_{t}$ to optimally preserve the potential distances in a low-dimensional representation. Fig. ~\ref{fig:diagram} shows an overview of GRAE using the PHATE embedding.
\begin{figure}[!b]
\centering
\includegraphics[width=0.45\textwidth,trim=45pt 80pt 82pt 25pt,clip]{diagram.png}
\caption{\textbf{Overview of GRAE on the Faces dataset~\cite{tenenbaum2000global}}. Geometric regularization is applied to enforce similarity between GRAE and PHATE embeddings. The vanilla AE embedding (top right) is included for reference.}
\label{fig:diagram}
\end{figure}
\subsection{$\lambda$ parameter updating}
While we expect $\mathcal{E}$ to be a good reference for the latent space on most problems, the ideal value for $\lambda$ can vary significantly depending on the dataset. Indeed, setting $\lambda$ too low prevents the encoder from learning a good geometry while setting it too high might be detrimental to reconstruction quality. To avoid the need to tune $\lambda$, we developed an update schedule for the parameter $\lambda$, which is set to a high value at the beginning of training and is progressively relaxed as follows:
\begin{align}
\label{eq:schedule}
\lambda \leftarrow \frac{-\lambda_{\text{max}}\text{exp}((epoch-N_{e}/2)*\alpha)}{1+ \text{exp}((epoch-N_{e}/2)*\alpha)} + \lambda_{\text{max}},
\end{align}
where $\alpha$ can be adjusted to change the steepness of the relaxing curve. The bigger its value, the closer the update schedule resembles a step function. In practice we set $\alpha = 0.2$. $N_{e}$ and $\lambda_{\text{max}}$ are the total number of epochs and the initial $\lambda$ value, respectively. Roughly speaking, this schedule allows the AE to focus on good latent space geometry during the first half of training and then refine the embedding according to reconstruction imperatives during the second half. We observe empirically that this approach is more robust than using a constant $\lambda$ value, as illustrated in Fig.~\ref{fig:schedule}.
\begin{figure}[!t]
\centering
\includegraphics[width=0.4\textwidth]{lambda_relax.png}
\caption{\textbf{$\lambda$ relaxation.} \textbf{A)} Plot of (\ref{eq:schedule}). \textbf{B)} GRAE latent space visualizations with three different $\lambda$ schemes on two problems~: the Swiss Roll and the Teapot (see subsection \ref{subsec:setup} for details), where we expect dimensionality reduction methods to respectively uncover a rectangular plane and a circular structure. We observe that the optimal $\lambda$ value is low for Swiss Roll (left) and high for Teapot (right). Relaxing $\lambda$ (center) allows us to recover the expected geometry on both problems with the same hyperparameter value. }
\label{fig:schedule}
\end{figure}
\subsection{Embedding-based optimization}
Most methods introduced in Section \ref{sec:related_work} rely on jointly minimizing the reconstruction loss and the regularizing loss during training. We instead choose to precompute $\mathcal{E}$ for three reasons. First, typical optimization objectives based on manifold learning, such as those used by Diffusion Nets, EAER and parametric t-SNE, require a pairwise affinity matrix which needs to be accessible during training and entails a memory cost of scale $\mathcal{O}(n^2)$. While our approach needs a similar matrix to precompute $\mathcal{E}$, only the latter needs to be retained for training the AE architecture, with a memory requirement of $\mathcal{O}(nd)$ where $d$ is the latent space dimension and typically $d << n$. Other methods, such as TAE, do not require computing such a matrix on the whole dataset, but instead rely on computing distance matrices over mini-batches. Given a mini-batch B of size $p$, this approach leads to $\mathcal{O}(p^2)$ additional operations for every gradient step when compared to typical AE training. The GRAE loss, for its part, only requires computing the euclidean distance between $x_i \in \mathcal{B}$ and its target $e_i \in \mathcal{E}$, which is $\mathcal{O}(p)$. Overall, this optimization approach is better for big data applications given the complexity of competing methods.
Second, the optimization techniques employed for some dimensionality reduction methods can be superior in performance than a neural network optimization. For instance, PHATE uses the SMACOF algorithm to perform MDS over the potential distances matrix. In practice, we find that this finds a better optimum than stochastic gradient descent or its variants.
Finally, we depart from previous methods by providing a more general approach. In many applications, there may not be strong reasons for imposing a particular relationship in the geometric loss that resembles a loss function from a specific kernel method. Any approach employed to find $\mathcal{E}$, whether it be PHATE, Isomap, t-SNE, LLE, etc., is already performing an optimization to its particular loss function, imposing the preservation of its desired geometric relationships in the data. Thus, GRAE will implicitly enforce such a relationship.
\subsection{Big data applications}
Here we present an extension of GRAE combined with PHATE that is especially suitable for managing large data (see Fig.~\ref{fig:procrustes_extension}). We propose to partition the data in mini-batches $\mathcal{B} = \{B_{1}, B_{2}, \ldots, B_{N}\}$ each containing common observations $\bm{X_{c}}$ and unique observations $\bm{X_{i}}$. Thus, $B_{i} = \{\bm{X_{c}} \cup \bm{X_{i}}\}$.
Then, we apply PHATE to each mini-batch, which produces an embedding $\mathcal{E}_{i}= \{\mathcal{E}^{\bm{X_{c}}} \cup \mathcal{E}^{\bm{X_{i}}}\}$.
Since each embedding might vary in orientation, scale and reflection with respect to the others, we apply the Procrustes method \cite{wang2008manifold} among the common points to extract a linear transformation, which is then applied to the whole mini-batch embedding. This allows us to consistently combine all embeddings. Clearly, such final embedding is not as refined as computing PHATE for the whole dataset, and some local information is lost. Fortunately, GRAE is able to refine the discrepancies, generating near similar embeddings whether $\mathcal{E}$ is generated by computing PHATE over the whole data, or by the Procrustes transformations over mini-batches. This makes the computation complexity linear with respect to the number of mini-batches.
\begin{figure}[!t]
\centering
\includegraphics[width=0.49\textwidth]{proc_final_grae.png}
\caption{\textbf{Scalable GRAE.} Overview of GRAE applied to 200,000 observations of iPSC data (see Section \ref{subsec:datasets}). \textbf{A)} Multiple mini-batch embeddings, each of which share some common observations. \textbf{B)} Combined embedding using the Procrustes method to align the mini-batch embeddings. \textbf{C)} GRAE embedding using (\textbf{B}) as $\mathcal{E}$ in the geometric loss. \textbf{D)} PHATE embedding computed over the whole data set. \textbf{E)} GRAE embedding using (\textbf{D}) as $\mathcal{E}$ in the geometric regularization. Although both approaches produce near similar embeddings, the mini-batch approach takes around 850 seconds to be computed and scales linearly. In contrast, PHATE applied to the whole data takes around 3894 seconds and scales quadratically.}
\label{fig:procrustes_extension}
\end{figure}
\section{Results}
\label{sec:results}
In this section, we experimentally compare GRAE\footnote{Source code is available at \url{https://github.com/KevinMoonLab/GRAE}} with a standard AE, Diffusion nets~\cite{mishne2019diffusion}, TAE~\cite{moor2019topological}, EAER-Margin~\cite{yu2013embedding} and UMAP~\cite{UMAP2018} on 6 different problems using a two-dimensional latent space. The motivation behind such a low-dimensional latent space is two-fold : to visualize the geometry of the latent space, and to offer a challenging dimensionality reduction task. Training is unsupervised and ground truths are only used for visualizing and scoring embeddings.
\subsection{Experimental setup}
\label{subsec:setup}
\label{subsec:datasets}
\paragraph{Compared methods}
A comparison with a standard AE was required to measure improvements in latent space geometry and reconstruction quality. We selected the remaining regularized autoencoders (EAER-Margin\footnote{While EAER also introduces loss terms based on Laplacian Eigenmaps and MDS, the margin-based loss performed best according to their benchmarks.}, TAE and Diffusion Nets) based on the similar goal of their objective functions and the geometric loss defined in this work, which is to introduce more structure in the latent space via a prior driven by geometry or topology. While other contributions have been made to improve representation learning with autoencoders, we do not think they are directly comparable to our approach nor relevant given our experimental setup. Some methods, such as Denoising and Sparse Autoencoders, do not explicitly regularize the structure of the latent space, which limits their utility for data exploration and visualization. In fact, they can be used in tandem with our geometric loss (and other compared methods) since their objectives are unlikely to conflict with the goal of achieving good latent space geometry. Other methods that do impose a prior on the latent space can be unsuitable for general manifold learning. For example, the VAE Gaussian prior, while useful for generative sampling, is inadequate to model the true manifold of many real-life datasets.
We finally include UMAP~\cite{UMAP2018} as a baseline to compare our approach to a ``pure'' manifold learning algorithm. This choice is motivated by the presence of a native extension to new points in UMAP's implementation as well as an inverse transform from the latent space back to the input space based on linear combinations of nearest neighbors, thus offering a natural comparison to autoencoders over all the relevant metrics. We did not benchmark parametric t-SNE \cite{van2009learning} given the absence of an invertible mapping and the fact that UMAP is similar to t-SNE from an algorithmic standpoint and provides qualitatively similar embeddings at a lower computational cost.
\paragraph{Datasets}
We perform comparisons on 6 datasets. The first one is the classic manifold problem known as ``Swiss Roll'' where data points are lying on a two dimensional plane ``rolled'' in a three dimensional ambient space. Classical approaches such as PCA or MDS typically fail to recover the non linear geometry of the data, as they rely on pairwise Euclidean distances instead of the true geodesic distances along the curvature of the roll. We generated 10,000 points on the Swiss Roll using the \texttt{scikit-learn} library. The manifold is then stretched and rotated to achieve unit variance.
Two datasets focus on full object rotations, where samples lie on circular manifolds. One problem is derived from the MNIST dataset~\cite{lecun2010mnist}, where three digits are picked randomly and rotated 360 times at one-degree intervals, for a total of 1080 images. Another one is known as the Teapot problem \cite{weinberger2004learning}, in which 400 RGB images of size 76 x 128 feature a rotating textured teapot.
We benchmark methods on two additional image datasets. The first one ("Object Tracking") was created with a 16~x~16 small character moving on a 64~x~64 background. Approximately 2000 RGB images were generated and Gaussian noise was added to the background to increase difficulty. The intrinsic manifold consists of the plane spanned by the x and y character coordinates on the background. The second is known as the UMIST Faces dataset \cite{graham1998characterising}, where different views (over a 90$^{\circ}$ interval) of the faces of 20 different subjects are shown in 575 gray scale images of size 112 x 92.
The final dataset consists of single-cell mass cytometry data showing iPSC reprogramming of mouse
embryonic fibroblasts (hereinafter, "iPSC") as introduced in \cite{zunder2015continuous}. The data show the expression of 33 markers in 220,450 embryonic cells at various stages of development. We know from \cite{moon2019visualizing} that cells, while initially similar, eventually specialize into two different groups, leading to a two-branch Y-shaped manifold. The only known ground truth in this case is the age of the cell when measured.
\paragraph{Architecture and hyperparameters}
We use the same AE architecture for all autoencoder-based models, which consists, in the case of Swiss Roll and iPSC, of 3 fully-connected hidden layers in the encoder and in the decoder with a 2D latent space, producing the following sequence of neurons: 800-400-200-2-200-400-800. For the image datasets, the first layer is replaced by two convolutional layers with max pooling and the last layer of the decoder is substituted for two deconvolution layers. We apply ReLU activations on all of the layers except in the bottleneck and the output of the decoder. To prevent over-fitting, we include an L2 penalization with a \textit{weight-decay} parameter equal to 1. We use a learning rate of .0001 and a batch size of 128, except for Diffusion Nets, which do not support mini-batches. Neural networks are trained for 200 epochs on the Swiss Roll and iPSC data and for 800 epochs on remaining datasets. MSE is used for the reconstruction error in the objective function. For GRAE, $\lambda_{max}$ was set to 100. Similarly, $\lambda$ was set to 100 for TAE and EAER-Margin. We also used a 100 multiplier on the eigenvector constraint of Diffusion Nets, as suggested in their paper. As for hyperparameters specific to PHATE (for computing the GRAE $\mathcal{E}$), UMAP and Diffusion maps (for Diffusion Nets), they were minimally tuned for each problem to achieve decent 2D visualizations.\footnote{We note however, that tuning Diffusion maps on some problems, most notably UMIST, proved to be much harder than tuning PHATE or UMAP.}
\subsection{Qualitative evaluation}
\label{subsec:qualitative}
\begin{figure}[!ht]
\centering
\includegraphics[width=.485\textwidth]{7_datasets.png}
\caption{\textbf{Latent space visualizations.} Latent representations learned in a fully unsupervised manner by all considered methods on 6 datasets. Training points are grey scale and testing points are colored according to a known ground truth factor. Only GRAE recovers a sensible geometry for all problems.}
\label{fig:plots}
\end{figure}
We first qualitatively evaluate GRAE and the other methods by visualizing the embedding layer after training as seen in in Fig.~\ref{fig:plots}. We first notice that GRAE recovers a sensible geometry for all problems while other methods fail at basic tasks such as uncoiling the Swiss Roll, disentangling the Rotated Digits, showing the coordinate plane on Object Tracking or recovering a circular structure on Teapot.
Only GRAE and Diffusion Nets show the two expected branches of the iPSC manifold. UMAP also shows good geometry in general, but tears the overall structure of the manifold on the Swiss Roll and iPSC problems despite their known continuous natures. TAE and EAER-Margin generally show embeddings similar to those produced by the AE, albeit with more sparsity. Finally, no method shows a clear global structure on the UMIST Faces problem, which is expected given that images were taken from 20 different subjects, but we still note that GRAE and UMAP demonstrate better local structure.
\subsection{Quantitative evaluation}
\label{subsec:quantitative}
\begin{table}[htbp]
\caption{Quantitative Evaluations of Methods}
\centering
\resizebox{.49\textwidth}{!}{
\begin{tabular}{|c|c|c|c|r|}
\hline & & \multicolumn{3}{|c|}{\textbf{Metrics}}\\
\cline{3-5}
\textbf{Dataset} & \textbf{Model} & \textbf{\textit{$\boldsymbol{R^2}$}} & \textbf{\textit{ MSE}} & \textbf{\textit{Rel. MSE}} \\
\hline
\multirow{6}{*}{Swiss Roll} & GRAE & \color[HTML]{2F781E}{\ul \textbf{0.9762 (1)}} & \color[HTML]{2F781E}{\ul \textbf{0.0034 (1)}} & \color[HTML]{2F781E}{\ul \textbf{-83.8 \% (1)}} \\
& AE & \color[HTML]{A5A600}0.5136 (3) & \color[HTML]{C69B00}0.0210 (4) & \color[HTML]{C69B00}0.0 \% (4) \\
& EAER-Margin & \color[HTML]{D70b0B}0.3746 (6) & \color[HTML]{D87D00}0.0246 (5) & \color[HTML]{D87D00}17.1 \% (5) \\
& TAE & \color[HTML]{C69B00}0.4905 (4) & \color[HTML]{A5A600}0.0196 (3) & \color[HTML]{A5A600}-6.7 \% (3) \\
& Diffusion Nets & \color[HTML]{D87D00}0.4257 (5) & \color[HTML]{D70b0B}0.0546 (6) & \color[HTML]{D70b0B}160.0 \% (6) \\
& UMAP & \color[HTML]{699010}\textbf{0.8455 (2)} & \color[HTML]{699010}\textbf{0.0042 (2)} & \color[HTML]{699010}\textbf{-80.0 \% (2)} \\
\hline
\multirow{6}{*}{Rotated Digits} & GRAE & \color[HTML]{699010}\textbf{0.9829 (2)} & \color[HTML]{2F781E}{\ul \textbf{0.0027 (1)}} & \color[HTML]{2F781E}{\ul \textbf{-69.3 \% (1)}} \\
& AE & \color[HTML]{A5A600}0.3757 (3) & \color[HTML]{A5A600}0.0088 (3) & \color[HTML]{A5A600}0.0 \% (3) \\
& EAER-Margin & \color[HTML]{D87D00}0.3181 (5) & \color[HTML]{699010}\textbf{0.0061 (2)} & \color[HTML]{699010}\textbf{-30.7 \% (2)} \\
& TAE & \color[HTML]{C69B00}0.3359 (4) & \color[HTML]{C69B00}0.0101 (4) & \color[HTML]{C69B00}14.8 \% (4) \\
& Diffusion Nets & \color[HTML]{D70b0B}0.2530 (6) & \color[HTML]{D87D00}0.0300 (5) & \color[HTML]{D87D00}240.9 \% (5) \\
& UMAP & \color[HTML]{2F781E}{\ul \textbf{0.9845 (1)}} & \color[HTML]{D70b0B}0.0653 (6) & \color[HTML]{D70b0B}642.0 \% (6) \\
\hline
\multirow{6}{*}{Teapot} & GRAE & \color[HTML]{2F781E}{\ul \textbf{0.9989 (1)}} & \color[HTML]{699010}\textbf{0.0032 (2)} & \color[HTML]{699010}\textbf{-62.4 \% (2)} \\
& AE & \color[HTML]{D70b0B}0.2079 (6) & \color[HTML]{C69B00}0.0085 (4) & \color[HTML]{C69B00}0.0 \% (4) \\
& EAER-Margin & \color[HTML]{C69B00}0.2526 (4) & \color[HTML]{2F781E}{\ul \textbf{0.0027 (1)}} & \color[HTML]{2F781E}{\ul \textbf{-68.2 \% (1)}} \\
& TAE & \color[HTML]{D87D00}0.2287 (5) & \color[HTML]{D87D00}0.0097 (5) & \color[HTML]{D87D00}14.1 \% (5) \\
& Diffusion Nets & \color[HTML]{A5A600}0.9933 (3) & \color[HTML]{A5A600}0.0038 (3) & \color[HTML]{A5A600}-55.3 \% (3) \\
& UMAP & \color[HTML]{699010}\textbf{0.9981 (2)} & \color[HTML]{D70b0B}0.0160 (6) & \color[HTML]{D70b0B}88.2 \% (6) \\
\hline
\multirow{6}{*}{UMIST Faces} & GRAE & \color[HTML]{A5A600}0.9371 (3) & \color[HTML]{2F781E}{\ul \textbf{0.0092 (1)}} & \color[HTML]{2F781E}{\ul \textbf{-35.7 \% (1)}} \\
& AE & \color[HTML]{D70b0B}0.9040 (6) & \color[HTML]{D87D00}0.0143 (5) & \color[HTML]{D87D00}0.0 \% (5) \\
& EAER-Margin & \color[HTML]{D87D00}0.9298 (5) & \color[HTML]{699010}\textbf{0.0108 (2)} & \color[HTML]{699010}\textbf{-24.5 \% (2)} \\
& TAE & \color[HTML]{2F781E}{\ul \textbf{0.9426 (1)}} & \color[HTML]{A5A600}0.0118 (3) & \color[HTML]{A5A600}-17.5 \% (3) \\
& Diffusion Nets & \color[HTML]{699010}\textbf{0.9407 (2)} & \color[HTML]{C69B00}0.0128 (4) & \color[HTML]{C69B00}-10.5 \% (4) \\
& UMAP & \color[HTML]{C69B00}0.9348 (4) & \color[HTML]{D70b0B}0.0292 (6) & \color[HTML]{D70b0B}104.2 \% (6) \\
\hline
\multirow{6}{*}{Object Tracking} & GRAE & \color[HTML]{699010}\textbf{0.9298 (2)} & \color[HTML]{2F781E}{\ul \textbf{0.0410 (1)}} & \color[HTML]{2F781E}{\ul \textbf{-6.6 \% (1)}} \\
& AE & \color[HTML]{D70b0B}0.3658 (6) & \color[HTML]{D87D00}0.0439 (5) & \color[HTML]{D87D00}0.0 \% (5) \\
& EAER-Margin & \color[HTML]{D87D00}0.4124 (5) & \color[HTML]{699010}\textbf{0.0429 (2)} & \color[HTML]{699010}\textbf{-2.3 \% (2)} \\
& TAE & \color[HTML]{C69B00}0.4369 (4) & \color[HTML]{A5A600}0.0434 (3) & \color[HTML]{A5A600}-1.1 \% (3) \\
& Diffusion Nets & \color[HTML]{A5A600}0.7806 (3) & \color[HTML]{C69B00}0.0435 (4) & \color[HTML]{C69B00}-0.9 \% (4) \\
& UMAP & \color[HTML]{2F781E}{\ul \textbf{0.9890 (1)}} & \color[HTML]{D70b0B}0.0855 (6) & \color[HTML]{D70b0B}94.8 \% (6) \\
\hline
\multirow{6}{*}{iPSC} & GRAE & \color[HTML]{699010}\textbf{0.2620 (2)} & \color[HTML]{699010}\textbf{0.7440 (2)} & \color[HTML]{699010}\textbf{1.0 \% (2)} \\
& AE & \color[HTML]{D70b0B}0.0919 (6) & \color[HTML]{2F781E}{\ul \textbf{0.7366 (1)}} & \color[HTML]{2F781E}{\ul \textbf{0.0 \% (1)}} \\
& EAER-Margin & \color[HTML]{C69B00}0.1305 (4) & \color[HTML]{C69B00}0.7721 (4) & \color[HTML]{C69B00}4.8 \% (4) \\
& TAE & \color[HTML]{D87D00}0.1296 (5) & \color[HTML]{A5A600}0.7603 (3) & \color[HTML]{A5A600}3.2 \% (3) \\
& Diffusion Nets & \color[HTML]{A5A600}0.2571 (3) & \color[HTML]{D70b0B}1.1060 (6) & \color[HTML]{D70b0B}50.1 \% (6) \\
& UMAP & \color[HTML]{2F781E}{\ul \textbf{0.3609 (1)}} & \color[HTML]{D87D00}0.7741 (5) & \color[HTML]{D87D00}5.1 \% (5) \\
\hline
\end{tabular}
}
\label{tab:metrics}
\end{table}
\paragraph{Metrics}
We report a quantitive assessment of all considered methods in Table \ref{tab:metrics}. We score models on two tasks: i) recovering ground truth factors in a meaningful way in the latent space and ii) reconstructing samples from the latent space back to the input space adequately.
Reconstruction quality is assessed using the MSE between the input and the reconstruction. Disentanglement of the latent factors is assessed by fitting a linear regression to predict said factors, using the embedding coordinates as regressors. High-quality embeddings should indeed be indicative of the data generating process and represent ground truth factors adequately, subject to a simple transformation.\footnote{For circular manifolds (Teapot, Rotated Digits), we center the manifolds before switching to polar coordinates and use the resulting angles as predictors. Furthermore, we align angle 0 of the ground truth and the embedded points to mitigate a "spin" in the embedding, which would break the linear relationship.} We report the resulting $R^2$ of the linear model to measure the strength of the relationship between the embeddings and a given ground truth factor.\footnote{On datasets with cluster structure (UMIST, Rotated Digits) where points are unlikely to lie on a connected manifold, we partition the embedding according to ground truth class labels, fit linear regressions independently on each part and report the average $R^2$ over all partitions.} If more than one factor exists, an $R^2$ score is computed for each factor and the average is shown.
All metrics were computed on a test split to benchmark how well the considered methods generalize to new data points. On Swiss Roll, the test split consists of a thin middle slice of 250 points that is removed from the training split to study how various methods would behave when required to generalize to out-of-distribution data. On the remaining datasets, 20 \% of samples are sampled and set aside for testing. We report the average of 10 runs using different train-test splits.
\paragraph{Discussion}
We report quantitative results in Table \ref{tab:metrics}. Echoing its convincing visualizations, GRAE quantitatively recovers the latent factors by being first or runner-up on the $R^2$ metrics on all problems. Only UMAP, a pure manifold learning algorithm, proves to be a stable competitor in that regard while other autoencoders with manifold learning or topological components generally fail to disentangle the latent factors. Overall, our results suggest that GRAE provides a more faithful representation with superior ability to reveal latent structure and variables in data.
While GRAE, UMAP and Diffusion Nets do recover the known ground truth factor on the iPSC data (i.e. age of the cells) better than the AE, we note that this factor offers an imperfect overview of the data manifold and many other latent factors are likely at play. Furthermore, no considered method manages to improve the AE reconstruction performance. A possible explanation is that gene measurements on single-cell data can be noisy, leading to a relatively high MSE even if the global structure of the manifold is correctly reconstructed (in other words, the decoder does not model the noise). We explore the matter of noise and the GRAE iPSC embedding in more depth in Section \ref{subsec:iPSC}.
With respect to the goal of providing invertible embeddings, some methods typically fail to consistently match the reconstruction error of vanilla AE, which is expected given that they do not specifically account for this metric when inverting latent coordinates (UMAP), or that they are driven by other objectives that may dominate their training over reconstruction terms (TAE and Diffusion Nets). GRAE, on the other hand, surprisingly improves reconstruction on five benchmarks; most notably on the Swiss Roll, Rotated Digits, UMIST and Teapot. We provide further study of this property in the following subsection.
\paragraph{Performance} Some compared methods showed limitations while running our benchmarks, especially on larger problems like iPSC. The algorithm presented in EAER had to be improved to support mini-batch training. Such an improvement was not as straightforward for Diffusion Nets because of the eigenvector constraint, which requires the full dataset and the associated affinity matrix to be held in GPU memory for training. In this case, subsampling the training set on the Teapot, Object Tracking, and UMIST problems was necessary to run experiments on the same hardware\footnote{Experiments were executed using \texttt{Python} 3.6.9 and \texttt{Torch} 1.5.0 for deep learning components. We used author implementations for UMAP (0.4.3) and PHATE (1.0.4). We used our own implementations of EAER-Margin and Diffusion Nets. As for TAE, we reused the original source code for the topological soft constraint and adapted it to our AE architecture. We ran everything with an \textit{AMD Ryzen 5 3600 6-Core CPU @ 4.20GHz}, 32 GB of available RAM, and an \textit{NVIDIA GeForce 2600 Super} GPU with 8 GB of memory.} used to fit other methods. In the case of iPSC, in addition to subsampling, we had to fit Diffusion Nets on a CPU to meet the higher memory requirements. While TAE supports mini-batches natively, we noticed a large increase in computation time, making it by far the slowest method on all problems.
\subsection{Impact of geometric regularization on reconstruction quality}
\label{subsec:reconstruction}
\begin{figure}[tb!]
\centering
\includegraphics[width = 0.49\textwidth]{histogram_1_mnist.png}
\caption{\textbf{Reconstructing latent space interpolations with GRAE.} \textbf{A)}~Distributions of errors of two rotated digits averaged over ten runs for AE vs GRAE. Dashed lines represent the 1st and 3rd quartiles, and solid lines represent the median. We notice that AE is more unstable than GRAE, having a heavier tail, since it fails completely to reconstruct certain images, while GRAE typically presents lighter tails. \textbf{B)} Typical embeddings produced for AE and GRAE. Blue points represent a subsample of the training data (subsampling only done for visualization purposes). Black points are the generated points on the latent space via interpolation. Red colored points in the AE embedding represent the 20 interpolated points with the highest reconstruction error. We observe that bad reconstruction typically occurs in sparse regions or crossing lines, i.e., in regions with poorly learned geometry.}
\label{fig:errors_dist}
\end{figure}
\begin{figure}[t!]
\centering
\includegraphics[trim = 0 0 0 0, clip,width=0.5\textwidth]{grae_ipsc3.png}
\caption{ \textbf{GRAE applied to the iPSC data} \cite{zunder2015continuous}. \textbf{A)} GRAE embedding of the iPSC data, and newly generated points across one of the branches. \textbf{B)} Newly generated points alongside their closest original observations in the embedding space. Both are colored by their ordering in the branch from the beginning of the branch to its tip. \textbf{C)} Pair plots for selected marker interactions in GRAE's reconstruction of the ambient space, compared against their closest original observations processed with MAGIC. Both show similar trends in most cases. \textbf{D)} Pearson correlation for each of the marker expressions between the data denoised by MAGIC and the GRAE reconstructions. Lack of correlation may indicate that neither GRAE nor MAGIC recovered a linear relationship. \textbf{E)} Pair plots in the input space of the raw original closest observations to the newly generated data. We observe that there is no clear interaction between markers and no clear expression trend across the time-progression in the branch. }
\label{fig:ipsc_exp}
\end{figure}
Based on the GRAE reconstruction errors (Table~\ref{tab:metrics}), we observe that GRAE improves the MSE of the decoder, despite adding a regularization term that deteriorates the reconstruction error global minimum. A possible explanation is that some latent space shifts caused by geometric regularization (e.g. forcing a circle on Teapot, uncoiling the Swiss Roll) actually drive gradient descent out of the local MSE minima in which vanilla AE falls. Indeed, most AE embeddings in Fig.~\ref{fig:plots} show structural overlaps where points from different regions of the original data manifold share the same latent space coordinates, meaning the encoder function $f$ is not injective and hence not invertible. By enforcing better geometry, GRAE appears to favor injective encoder mappings which, assuming bijectivity on the manifold, should facilitate learning of the inverse function $f^{\dagger}$, leading to the better reconstructions.
Additionally, the regularization generates a more stable reconstruction over the whole dataset, especially in those regions where the autoencoder produces inaccurate geometry in the latent space. To support these claims, we conduct an experiment on two rotated MNIST digits (Fig. \ref{fig:errors_dist}), generating a full rotation for each of the digits and removing in-between observations as the test set. After training GRAE on the remaining observations, we interpolate over consecutive observations in the embedding space i.e., consecutive angle rotations in the training set. Then we compute the reconstruction error between the generated points via interpolation with the previously removed in-between observations.
This experiment shows that learning accurate geometry from the data can be useful to generate new points on the latent space via interpolation over adjacent observations. Such points can then be fed to the decoder, generating a more faithfully reconstructed geodesic trajectory between points on the manifold in the ambient space in comparison to AE.
\subsection{iPSC data case study}
\label{subsec:iPSC}
Finally, we present a case study showing the capabilities of GRAE to recover marker interactions in induced pluripotent stem cell (iPSC) mass cytometry data \cite{zunder2015continuous}. We show our experimental outline in Fig.~\ref{fig:ipsc_exp}. Mass cytometry data is noisy (Fig.~\ref{fig:ipsc_exp}D) and marker expression interactions are difficult to extract from the raw data. This issue can be tackled with methods such as MAGIC \cite{van2018recovering}. MAGIC is a powerful diffusion-based approach that performs data imputation and denoising. It has been shown to be particularly useful to recover gene-gene interactions in complicated single-cell RNA-sequencing datasets. Thus, we choose to compare GRAE's reconstructed ambient space with the MAGIC transformation of the raw data. Figure~\ref{fig:ipsc_exp}(C,E) shows how GRAE is able to denoise the data, and recover gene markers interactions from the raw data in a similar way as MAGIC. We notice that large discrepancies between MAGIC and GRAE only occur when neither MAGIC nor GRAE capture clear interactions, as shown in the bottom-right subplot in Fig.~\ref{fig:ipsc_exp}C.
\section{Conclusion}
\label{sec:conclusion}
We proposed geometry regularized autoencoder (GRAE), a general parametric framework to enhance autoencoders' latent representation by taking advantage of well-established manifold learning methods. By imposing a geometrical soft constraint on the bottleneck of the autoencoder, we demonstrated empirically how GRAE can achieve good visualizations and good latent representations on several performance metrics compared to AE and other methods motivated by geometry. Furthermore, GRAE is equipped with an inverse mapping that often produces a better reconstruction than AE. While the primary focus of this work is on using PHATE embeddings to regularize the bottleneck, we leave to future work the study of other manifold learning algorithms as constraints for learning AE representations with better geometry and the benefits they bring in terms of visualizations, reconstruction, and data generation.
\balance
\bibliographystyle{IEEEtran}
\section{Introduction}
\documentclass{article}
\PassOptionsToPackage{numbers}{natbib}
\usepackage[preprint]{neurips_2020}
\usepackage{natbib}
\bibliographystyle{unsrtnat}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{url}
\usepackage{booktabs}
\usepackage{amsfonts}
\usepackage{nicefrac}
\usepackage{microtype}
\usepackage{color}
\usepackage{graphicx}
\usepackage{float}
\usepackage{caption}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{multirow}
\usepackage{adjustbox}
\usepackage[normalem]{ulem}
\usepackage{algorithmic}
\usepackage{algorithm}
\usepackage{bbm}
\usepackage{wrapfig}
\usepackage[table]{xcolor}
\usepackage[normalem]{ulem}
\useunder{\uline}{\ul}{}
\title{Rapport de Projet d'Informatique - IFT3150 }
\author{%
Sacha Morin \\
Département d'informatique et de recherche opérationnelle \\
Universit\'{e} de Montr\'{e}al;
Mila -- Institut Québécois d'Intelligence Artificielle \\
\texttt{[email protected]}\\
\And
Supervisé par Guy Wolf \\
Département de mathématiques et de statistique \\
Universit\'{e} de Montr\'{e}al;
Mila -- Institut Québécois d'Intelligence Artificielle \\
\texttt{[email protected]}\\
}
\begin{document}
\maketitle
\thispagestyle{empty}
\section{Introduction}
\label{sec:introduction}
J'ai eu la chance de compléter un stage en apprentissage profond avec le professeur Guy Wolf à l'été 2020 et je présente ici le rapport du projet intitulé \textit{Extendable and invertible manifold learning with geometry regularized autoencoders} (ci-après, "\textbf{GRAE}"), ayant mené à une première tentative de publication à NeurIPS en juin 2020. Le travail sur GRAE a été complété en collaboration avec Andrés Duque et Kevin Moon de Utah State University.
Nous débuterons par un bref récapitulatif de GRAE tel que soumis en juin dernier suivi d'une section sur les nouvelles pistes explorées au cours de l'été. Une dernière section discutera de l'implémentation et de l'équipement utilisé pour compléter les expériences.
\section{GRAE}
\label{sec:grae}
GRAE est d'abord et avant tout un autoencodeur \cite{rumelhart1986learning}, c'est-à-dire un réseau de neurones ayant pour objectif d'apprendre la fonction identité sur les données (autrement dit, on pousse le modèle à avoir pour sortie exactement ce qui est donné en entrée). Dans la plupart des cas, les autoencodeurs auront un goulot d'étranglement ("\textit{bottleneck}") de dimension beaucoup plus faible que les données initiales et l'objectif sera de "reconstruire" les données après le goulot. Un autoencodeur peut donc servir à réduire la dimensionalité des données en retenant la représentation des données dans l'espace du goulot d'étranglement (plus communément appelé "l'espace latent"). Cette approche est particulièrement populaire car, lorsque combinée à des fonctions d'activation adéquates sur les couches du réseau (ReLu, bien souvent), elle permet d'effectuer une réduction non-linéaire des données, ce qui peut être plus intéressant que, disons, des techniques linéaires classiques comme PCA \cite{pearson1901}.
Une autre approche à la réduction non-linéaire des données est l'apprentisage de variétés ("\textit{manifold learning}"), qui suppose que les données, même en haute dimension, reposent en fait sur une variété géométrique dont la dimension intrinsèque est plus faible. On pensera par exemple à un ruban (2D) enroulé et suspendu dans un espace ambiant 3D. Il est effectivement possible de trouver une fonction exprimant correctement cette variété en 2 dimensions (voir Figure \ref{fig:swissroll}).
\begin{figure}[H]
\centering
\includegraphics{swiss_roll.png}
\caption{Le \textit{Swiss Roll}, un exemple classique d'apprentissage de variété. On peut constater que la distance géodésique entre deux points (lire, "le long de la variété") est généralement plus élevée que la distance euclidienne. Une approche naïve qui consisterait à préserver la distance euclidienne ne permettrait pas de bien dérouler la variété et de découvrir la structure sous-jacente des données. Image prise du cours CMU-10715 donné par Barnabás Póczos. }
\label{fig:swissroll}
\end{figure}
Les algorithmes reposant sur cette hypothèse visent généralement à encoder les voisinages des différents points, ce qui servira à approximer la structure de la variété. Une présentation exhaustive de toutes les méthodes d'apprentissage de variété dépasse l'objet de ce rapport, mais il faut savoir que ces méthodes, bien qu'elles offrent une réduction de dimension avec des fondements géométriques solides, ne sont généralement pas paramétriques. En d'autres mots, le résultat retourné est une représentation en basse dimension pour chaque point d'entraînement et non un modèle paramétrisé pouvant être utilisé pour transformer de nouvelles données.
La géométrie apportée par les techniques d'apprentissage de variété pourrait tout de même servir à améliorer les autoencodeurs et c'est d'ailleurs l'objectif de GRAE. Les autoencodeurs font en effet généralement fi de la variété discutée ci-haut et apprenent une représentation en faible dimension qui est peu structurée et donne peu d'information sur les données (Voir les visualisations produites par l'autoencodeur à la Figure \ref{fig:plots}, qui manquent généralement de structure).
GRAE introduit donc plus de structure dans l'espace latent de l'autoencodeur en le forcant à imiter une représentation apprise par un algorithme d'apprentissage de variété (dans notre cas, PHATE \cite{moon2019visualizing}). Je réfère le lecteur à notre article \cite{duque2020extendable} pour une discussion plus détaillée sur le modèle et les résultats. Je reproduis tout de même ici un sommaire du modèle (Figure \ref{fig:diagram}), des visualisations ( Figure \ref{fig:plots}) ainsi que les principales mesures de performance sur différents problèmes (Table \ref{tab:metrics}).
En résumé, nous avons observé que la régularisation géométrique aidait non seulement à produire de meilleures visualisations, mais permettait aussi d'améliorer l'objectif classique des autoencodeurs, c'est-à-dire l'erreur de reconstruction, sur les trois problèmes considérés. Qui plus est, les représentations apprises tendaient à démêler les variables latentes derrière la génération des données. À titre d'exemple, dans le problème de \textit{Faces} (illustré à la Figure \ref{fig:diagram}), chaque image peut être vue comme une fonction des angles de rotation horizontales et verticales du visage. Le jeu de données a donc réellement seulement deux degrés de liberté. Nos mesures montrent que les deux axes de la représentation apprise par GRAE sont fortement corrélées avec les angles de rotation du visage. GRAE retrouve donc bel et bien les variables latentes derrière le processus de génération des données.
\begin{figure}
\centering
\includegraphics[width=0.9\textwidth,trim=45pt 80pt 82pt 25pt,clip]{diagram.png}
\caption{Présentation de GRAE sur le jeu de données \textit{Faces} tel qu'introduit dans \cite{tenenbaum2000global}. Notre régularization géométrique (dénoté $L_g$) sert à maintenir la similarité entre la représentation dans le \textit{bottleneck} de GRAE et une représentation apprise par PHATE. Une représentation apprise par un autoencodeur "vanille" est ajoutée en haut à droite à des fins de comparaison. }
\label{fig:diagram}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=\textwidth,trim = 170pt 75pt 130pt 65pt,clip]{3_datasets.png}
\caption{Représentations latentes apprises par les différentes méthodes considérées sur les jeux de données \textit{Swiss Roll} (haut), \textit{Faces} (milieu) et \textit{Rotated Digits} (bas). Le \textit{Swiss Roll} et \textit{Faces} sont présentés aux figures \ref{fig:swissroll} et \ref{fig:diagram} respectivement. De son côté, \textit{Rotated Digits} est constitué de rotations de 3 images distinctes de nombre. Le nombre à côté de GRAE indique la force de la régularisation géométrique appliquée. Les points en gris sont les points d'entraînement et les points colorés sont des points de test. On voit que seul GRAE récupère une géométrie raisonnable sur les trois problèmes.}
\label{fig:plots}
\end{figure}
\begin{table}
\resizebox{\textwidth}{!}{\begin{tabular}{|cc|c|cc|cc|c|}
\cline{3-8}
\multicolumn{1}{l}{~} & \multicolumn{1}{l|}{~} & Distance & \multicolumn{2}{c|}{Pearson (Rank)} & \multicolumn{2}{c|}{Spearman (Rank)} & MSE \\
\multicolumn{1}{c}{Dataset} &
\multicolumn{1}{c|}{Model} & Corr. (Rank) & Naive & ICA & Naive & ICA & (Rank) \\
\hline
\multirow{7}{*}{Swiss Roll} & Autoencoder & \color[HTML]{D70b0B}0.093 (7) & \color[HTML]{D70b0B}0.260 (7) & \color[HTML]{D96300}0.608 (6) & \color[HTML]{D70b0B}0.270 (7) & \color[HTML]{D96300}0.611 (6) & \color[HTML]{B6A100}0.014 (4) \\
& GRAE (10) & \color[HTML]{2F781E}{\ul \textbf{0.962 (1)}} & \color[HTML]{2F781E}{\ul \textbf{0.980 (1)}} & \color[HTML]{2F781E}{\ul \textbf{0.980 (1)}} & \color[HTML]{2F781E}{\ul \textbf{0.987 (1)}} & \color[HTML]{2F781E}{\ul \textbf{0.983 (1)}} & \color[HTML]{2F781E}{\ul \textbf{0.005 (1)}} \\
& GRAE (50) & \color[HTML]{4D8418}\textbf{0.955 (2)} & \color[HTML]{4D8418}\textbf{0.979 (2)} & \color[HTML]{4D8418}\textbf{0.977 (2)} & \color[HTML]{4D8418}\textbf{0.985 (2)} & \color[HTML]{4D8418}\textbf{0.980 (2)} & \color[HTML]{4D8418}\textbf{0.010 (2)} \\
& GRAE (100) & \color[HTML]{879C06}0.953 (3) & \color[HTML]{879C06}0.977 (3) & \color[HTML]{879C06}0.976 (3) & \color[HTML]{879C06}0.982 (3) & \color[HTML]{879C06}0.979 (3) & \color[HTML]{879C06}0.011 (3) \\
& TAE (1000) & \color[HTML]{D96300}0.155 (6) & \color[HTML]{D96300}0.278 (6) & \color[HTML]{D69400}0.627 (5) & \color[HTML]{D96300}0.287 (6) & \color[HTML]{D69400}0.633 (5) & \color[HTML]{D69400}0.019 (5) \\
& Diffusion Nets & \color[HTML]{D69400}0.336 (5) & \color[HTML]{D69400}0.394 (5) & \color[HTML]{D70b0B}0.443 (7) & \color[HTML]{D69400}0.309 (5) & \color[HTML]{D70b0B}0.388 (7) & \color[HTML]{D70b0B}0.584 (7) \\
& UMAP & \color[HTML]{B6A100}0.791 (4) & \color[HTML]{B6A100}0.912 (4) & \color[HTML]{B6A100}0.916 (4) & \color[HTML]{B6A100}0.873 (4) & \color[HTML]{B6A100}0.890 (4) & \color[HTML]{D69400}0.019 (5) \\
\hline\hline
\multirow{7}{*}{Faces} & Autoencoder & \color[HTML]{D70b0B}0.040 (7) & \color[HTML]{D70b0B}0.253 (7) & \color[HTML]{D70b0B}0.295 (7) & \color[HTML]{D70b0B}0.233 (7) & \color[HTML]{D70b0B}0.300 (7) & \color[HTML]{4D8418}\textbf{0.019 (2)} \\
& GRAE (10) & \color[HTML]{D69400}0.691 (5) & \color[HTML]{B6A100}0.642 (4) & \color[HTML]{B6A100}0.642 (4) & \color[HTML]{B6A100}0.629 (4) & \color[HTML]{D69400}0.628 (5) & \color[HTML]{2F781E}{\ul \textbf{0.017 (1)}} \\
& GRAE (50) & \color[HTML]{4D8418}\textbf{0.725 (2)} & \color[HTML]{4D8418}\textbf{0.729 (2)} & \color[HTML]{4D8418}\textbf{0.735 (2)} & \color[HTML]{4D8418}\textbf{0.732 (2)} & \color[HTML]{4D8418}\textbf{0.740 (2)} & \color[HTML]{4D8418}\textbf{0.019 (2)} \\
& GRAE (100) & \color[HTML]{B6A100}0.718 (4) & \color[HTML]{2F781E}{\ul \textbf{0.758 (1)}} & \color[HTML]{2F781E}{\ul \textbf{0.763 (1)}} & \color[HTML]{2F781E}{\ul \textbf{0.763 (1)}} & \color[HTML]{2F781E}{\ul \textbf{0.769 (1)}} & \color[HTML]{D69400}0.020 (5) \\
& TAE (1000) & \color[HTML]{D96300}0.067 (6) & \color[HTML]{D96300}0.269 (6) & \color[HTML]{D96300}0.304 (6) & \color[HTML]{D96300}0.244 (6) & \color[HTML]{D96300}0.304 (6) & \color[HTML]{4D8418}\textbf{0.019 (2)} \\
& Diffusion Nets & \color[HTML]{879C06}0.719 (3) & \color[HTML]{879C06}0.684 (3) & \color[HTML]{879C06}0.686 (3) & \color[HTML]{879C06}0.697 (3) & \color[HTML]{879C06}0.703 (3) & \color[HTML]{D96300}0.024 (6) \\
& UMAP & \color[HTML]{2F781E}{\ul \textbf{0.854 (1)}} & \color[HTML]{D69400}0.633 (5) & \color[HTML]{D69400}0.636 (5) & \color[HTML]{D69400}0.628 (5) & \color[HTML]{B6A100}0.649 (4) & \color[HTML]{D70b0B}0.205 (7) \\
\hline\hline
\multirow{7}{*}{Rotated Digits} & Autoencoder & n/a & n/a & n/a & n/a & n/a & \color[HTML]{D69400}0.020 (5) \\
& GRAE (10) & n/a & n/a & n/a & n/a & n/a & \color[HTML]{2F781E}{\ul \textbf{0.016 (1)}} \\
& GRAE (50) & n/a & n/a & n/a & n/a & n/a & \color[HTML]{4D8418}\textbf{0.017 (2)} \\
& GRAE (100) & n/a & n/a & n/a & n/a & n/a & \color[HTML]{4D8418}\textbf{0.017 (2)} \\
& TAE (1000) & n/a & n/a & n/a & n/a & n/a & \color[HTML]{B6A100}0.019 (4) \\
& Diffusion Nets & n/a & n/a & n/a & n/a & n/a & \color[HTML]{D96300}0.026 (6) \\
& UMAP & n/a & n/a & n/a & n/a & n/a & \color[HTML]{D70b0B}0.056 (7) \\
\hline
\end{tabular}}
\bigskip
\caption{Principales mesures utilisées dans \cite{duque2020extendable} pour quantifier la qualité des différentes représentations apprises par GRAE et les autres modèles comparés. La première mesure est la corrélation entre la matrice de distances euclidiennes des points dans la représentation et la même matrice dans l'espèce des coordonnées intrinsèques (les coordonnées sur le ruban dans le cas de \textit{Swiss Roll} et les angles de rotation dans le cas de \textit{Faces}). Les colonnes Pearson et Spearman indiquent la corrélation moyenne entre les axes des représentations et les axes intrinsèques (après avoir trouvé l'alignement optimal et ignoré le signe). Les colonnes ICA indiquent un traitement ICA de la représentation avant le calcul, ce qui est plus permissif à l'égard des rotations aléatoires dans la représentation (voir des explications plus détaillées dans \cite{duque2020extendable}). La dernière colonne montre l'erreur de reconstruction de l'autoencodeur. Les mesures de corrélation sont omises sur \textit{Rotated Digits}, car ce problème ne dispose pas d'un \textit{ground truth} en deux dimensions, contrairement aux deux autres problèmes. On note que GRAE améliore l'erreur de reconstruction sur les trois problèmes et que les axes de ses représentations sont fortement corrélés avec les variables latentes.}
\label{tab:metrics}
\end{table}
Le stage a été dédié non seulement au développement de GRAE, mais aussi à la communication scientifique entourant le modèle, ce qui a mené à la rédaction de l'article suscité \cite{duque2020extendable} ainsi que d'un poster et d'une vidéo pour le \textit{Montreal AI Symposium}, joints au présent rapport.
\section{Nouveaux développements}
\label{sec:new}
Après avoir soumis une première version de l'article de GRAE, nous avons explorer plusieurs pistes pour améliorer le modèle et démontrer son utilité. Les principaux axes de recherche sont résumés ici.
\subsection{Nouvelles données}
Il faut admettre que les données sur lesquels le modèle a été initialement testé sont simples et constituent des exemples de \textit{toy datasets}. Nous avons donc effectué de nouvelles expériences sur de nouveaux jeux de données, sur lesquels nous observons des résultats similaires à ceux présentés dans le papier.
Le premier jeu de données est intitulé \textit{Teapot} et est composé d'images 76x101 d'une théière en rotation (Figure \ref{fig:teapot}). Tout comme dans le problème de \textit{Rotated Digits}, GRAE retrouve une structure circulaire qui correspond intuitivement à une transformation de rotation (donc qui revient éventuellement au point de départ).
Nous observons une réduction de l'erreur de reconstruction d'environ 50 \% sur les données de test en comparaison avec un autoencodeur sans la régularisation géométrique. Nous avons aussi tenté une expérience sur ce jeu de données où la régularisation géométrique est maintenue pendant seulement la première moitié de l'entraînement. La deuxième moitié se fait seulement en fonction de l'erreur de reconstruction. Nous observons une amélioration significative de l'erreur de reconstruction autant sur les données d'entraînement que sur les données de test (voir Tableau \ref{tab:teapot_rec}). Il semblerait que notre approche aide l'optimisation de l'objectif de reconstruction et permette à l'optimisateur de sortir du minimum local dans lequel l'autoencodeur classique tombe. La deuxième moitié permet ensuite de rafiner la structure trouvée (ici, un cercle) en fonction de l'objectif de reconstruction afin de trouver un meilleur minimum. Nous prévoyons tester des expériences similaires sur d'autres jeux de données.
\begin{table}
\centering
\begin{tabular}{ |c|c|c|c|c|}
\hline
& \multicolumn{2}{|c|}{Entraînement} & \multicolumn{2}{|c|}{Test}\\
\hline
Modèle & Erreur & Vs. AE & Erreur & Vs. AE \\
\hline
\hline
AE & 0.002867 & 0.00 \% & 0.007135 & 0.00 \% \\
\hline
GRAE (100) & 0.002862 & -0.19 \% & 0.003359 & -52.92 \% \\
\hline
Soft GRAE (100) & 0.000967 & -66.27 \% & 0.001435 & -79.89 \% \\
\hline
\end{tabular}
\bigskip
\caption{Étude de l'erreur de reconstruction sur le problème \textit{Teapot}. \textit{Soft GRAE} dénote un entraînement où la régularisation géométrique avec $\lambda = 100$ est seulement appliquée durant la première moitié de l'entraînement. Nous voyons ici clairement un avantage autant du côté des données d'entraînement que des données de test. Ceci montre que non seulement la régularisation géométrique aide à mieux généraliser, mais semble aussi aider l'optimisation même.}
\label{tab:teapot_rec}
\end{table}
\begin{figure}
\centering
\includegraphics[width=\textwidth]{teapot.png}
\caption{Représentations latentes apprises sur le problème \textit{Teapot}. La couleur représente l'angle de rotation de l'objet.}
\label{fig:teapot}
\end{figure}
Nous avons ensuite testé l'algorithme sur un problème d'\textit{Object Tracking}, où un personnage 16x16 est déplacé sur un arrière-plan fixe 64x64 (Figure \ref{fig:tracking}). On peut observer visuellement que la représentation représente bien la "grille" des coordonnées x et y de l'objet sur l'arrière plan. En raison des relativement bons résultats de la réduction de dimension, nous prévoyons rendre le problème plus difficile en utilisant des images en plus haute résolution et en ajoutant du bruit dans l'arrière plan.
\begin{figure}
\centering
\includegraphics[width=\textwidth]{tracking.png}
\caption{Représentations latentes apprises sur le problème d'\textit{Object Tracking}. La couleur représente un des deux axes de déplacement. GRAE et UMAP retrouve bien la grille des coordonnées x et y de l'objet.}
\label{fig:tracking}
\end{figure}
Un autre problème intéressant est celui appelé \textit{Embryoid Body Differentiation}, composé d'environ 18 000 marqueurs d'expression génétique calculés sur 16 000 différentes cellules souches sur une période de 27 jours (la collecte d'information se faisait à tous les 3 ou 4 jours). L'objectif est d'étudier la spécialisation des cellules souches dans le temps. La réduction de dimension est présentée à la Figure \ref{fig:eb}. La représentation des cellules apprise par GRAE montre ce qui est attendu sur le plan biologique. En effet, les jeunes cellules souches (bleu foncé) sont relativement regroupées, ce qui témoigne de leur profil génétique similaire dû à leur absence de spécialisation. Plus le temps avance (vers le rouge foncé), plus on observe une certaine variance dans la représentation et l'apparition de branches, qui correspondent aux différentes fonctions que les cellules souches commencent à prendre. Les représentations apprises par l'autoencodeur et UMAP ne montrent pas une telle structure. On remarque par ailleurs avec les couleurs que l'axe horizontal est fortement corrélé avec l'âge des cellules.
\begin{figure}
\centering
\includegraphics[width=\textwidth]{EB.png}
\caption{Représentations latentes apprises sur le problème d'\textit{Embryoid Body Differentiation}. La couleur représente l'âge des cellules. Dans les représentations de GRAE, on observe une évolution progressive des jeunes cellules souches (bleues foncées, regroupées) vers les plus vieilles (rouges foncées, spécialisées sur différentes branches).}
\label{fig:eb}
\end{figure}
Ces expériences préliminaires montrent donc que GRAE a un certain potentiel sur des problèmes plus complexes et nous sommes actuellement en train de concevoir de nouvelles expériences afin d'améliorer l'article.
\subsection{Convolutions}
GRAE n'utilisait initialement que des couches linéaires (\textit{fully-connected}). Or, plusieurs des problèmes considérés sont des images et il va de soi qu'utiliser des réseaux convolutifs \cite{lecun1998gradient} dans la structure de l'autoencodeur serait intéressant. En résumé, une convolution est une transformation linéaire appliquée sur une tuile de l'image (3x3 par exemple). On définit plusieurs convolutions qui sont appliquées ainsi sur toutes les tuiles de l'image, menant à des modèles qui sont beaucoup mieux adaptés à l'interdépendance pouvant exister entre différents pixels à proximité.
Les modules pour utiliser GRAE avec des convolutions ont été écrits. Pour l'instant, les convolutions ne semblent pas substantiellement améliorer la performance du modèle et l'écart relatif avec l'autoencodeur classique (lui-aussi augmenté avec des convolutions) reste le même.
\subsection{\textit{Siamese Networks}}
Il faut souligner ici que PHATE calcule d'abord une distance de potentielle (voir \cite{duque2020extendable} et \cite{moon2019visualizing} pour plus de détails) entre les observations et calcule ensuite une représentation où la distance euclidienne respecte cette distance de potentielle. GRAE est régularisé avec cette représentation.
Il existe cependant une classe de modèle, les réseaux "Siamois", où le modèle prend en entrée deux observations et doit apprendre une distance donnée (Figure \ref{fig:siamese}). Le choix de distance dépend de l'application du modèle. Nous considérons la possibilité d'utiliser directement l'architecture "Siamoise" avec les distances de potentielle de PHATE au lieu de régulariser une représentation. Une telle approche éviterait de devoir optimiser une représentation avec PHATE et permettrait de combiner différents sous-ensembles de données à partir de leurs matrices de distance de potentielle (qui est invariante aux symmétries et rotations, contrairement à une représentation apprise par PHATE).
Encore une fois, les modules pour le modèle "Siamois" sont préparés et nous en sommes à étudier ses propriétés.
\begin{figure}
\centering
\includegraphics[width=.4\textwidth]{siamese.jpeg}
\caption{Diagramme d'un \textit{Siamese network}. Dans notre cas, la fonction de coût par constrate serait remplacée par les distances de potentielles apprises par PHATE. Source de l'image : https://hackernoon.com/one-shot-learning-with-siamese-networks-in-pytorch-8ddaab10340e} .
\label{fig:siamese}
\end{figure}
\section{Implémentation et matériel}
Le projet est entièrement rédigé en Python. J'ai personnellement codé les expériences et le modèle, exception faite de celles concernant Diffusion Nets, un compétiteur. Le projet a débuté dans un notebook sur Google Colab. Vu l'ampleur inattendue du code source, la plupart des modules encore utilisés ont été migrés vers un projet Python et le suivi du projet se fera dorénavant sur \textit{Github}.
Le projet a substantiellement contribué à ma maîtrise de la librairie \textit{Pytorch}, servant à écrire les modèles d'apprentissage profond. GRAE (et ses variantes convolutives et siamoises) m'ont permis d'explorer plusieurs facettes de la librairie et d'améliorer le développement orienté objet.
Il a aussi été nécessaire de concevoir le calcul des mesures de performance. Les mesures dites "unsupervised" (Tableau 1 dans notre article) sont largement inspirées de \cite{moor2019topological} et le code source associé aussi. Les mesures "supervised" (Tableau 2 de l'article et Tableau \ref{tab:metrics} du présent rapport) sont du code original. Elles visent à déterminer dans quelle mesure les axes de GRAE et des modèles compétiteurs correspondent aux variables latentes derrière les données (voir une discussion plus détaillée à ce sujet dans la section \ref{sec:grae}). En termes plus techniques, le module de mesure est en fait une liaison entre les différentes fonctions de corrélation de \textit{scikit-learn} afin de les appliquer aux représentations apprises par GRAE et ses compétiteurs.
Les expériences de l'article ont bénéficié de CUDA afin d'accélérer l'apprentissage des réseaux de neurones au moyen d'un GPU. Les modèles pour l'article original ont été entraînés sur un GPU \textit{NVIDIA Tesla P-100} avec un CPU \textit{Intel(R) Xeon(R) 2.30GHz} et 13 GB de RAM sur un nuage de Google. Les nouvelles expériences seront roulées sur une unité comprenant une \textit{NVIDIA GeForce 2060}, un CPU \textit{AMD Ryzen 5 3600 4.2GHz} et 32 GB de Ram.
\section{Conclusion}
Le projet a été une excellente opportunité d'appronfondir mes connaissances en apprentissage automatique et de mieux comprendre les algorithmes d'apprentissage de variétés. J'aurai d'ailleurs la chance de continuer mon travail sur le projet cet automne et je suis particulièrement enthousiaste à l'idée de travailler sur les nouveaux axes de recherche présentés dans la Section \ref{sec:new}.
\newpage
| {'timestamp': '2020-11-24T02:23:43', 'yymm': '2007', 'arxiv_id': '2007.07142', 'language': 'en', 'url': 'https://arxiv.org/abs/2007.07142'} | arxiv |
\section{Introduction \& Related Work}
Music, one of the most important inventions of human being, has an extremely hugh market with billion-level listeners.
Music is connected with emotion expression and language-independent, making it being one of the most intuitive and simplest ways of human communication.
Creating music from scratch is a challenging work even for professional composers. Remarkably, popular and classical music generation using \textit{deep learning} algorithms and \textit{large-scale} MIDI files have achieved promising results during recent years. Main stream approaches include modelling music note sequences by borrowing ideas from language modelling in natural language processing field.
A melody and arrangement generation framework for pop music was proposed in \cite{xiaoiceband2018wxc}. First, a chord-based rhythm and melody cross-generation model, employing recurrent neural networks (RNNs) such as gated recurrent units (GRUs) \cite{cho-etal-2014-learning}, was used to generate melody with chord progressions. Then, a multi-instrument co-arrangement model using updated GRUs was designed for multi-task learning for multi-track music arrangement.
DeepBach \cite{deepbach2017} was a graphical model aiming at modelling polyphonic music and specifically hymn-like pieces through employing RNNs. Later, DeepJ was proposed in \cite{deepj2018} for style-specific music generating. Biaxial long short term memory (LSTM) \cite{hochreiter1997long,biaxial-lstm2017} was trained using piano roll note representations, for three major classical periods (baroque, classical, and romantic). DeepJ is capable of composing music conditioned on a specific mixture of composer styles. We take this model as one of our baselines and compare the differences of data representation and music dynamic sequential learning.
Compared with RNNs such as LSTMs or GRUs, Transformer \cite{NIPS2017_7181_transformer}, a sequence model based on (multi-head) self-attention mechanism, is more parallelizable for both training and inferring, and more interpretable. Transformer has achieved compelling results in tasks that require maintaining long-range coherence, such as neural machine translation \cite{NIPS2017_7181_transformer}, pre-training language models \cite{devlin-etal-2019-bert}, text-to-speech synthesis \cite{DBLP:journals/corr/abs-1809-08895}, and speech recognition \cite{DBLP:journals/corr/abs-1904-11660}.
Employing Transformer with relative attention mechanism \cite{shaw-etal-2018-self}, Music Transformer \cite{music-transformer-2018} was proposed for generating piano music with long-term structure. As depicted in Figure \ref{figure:note_4tuple}, performance events with absolute time intervals were employed for note sequence representation. In musical composition and performance, relative timing directly expressed by note-values is critically important.
That is, we prefer the model learns from \emph{music scores} written by composers, instead of \emph{performance events} played by real-world players.
NoteTuple \cite{transformer-nade-2018} groups a note's attributes as one event. However, the TIME\_SHIFT used in performance events still brings hard-coding to the target of relative timing. In this paper, we propose a further \emph{relative} note representation method that projects tempo information into note representation, resulting a 4-tuple time-valued note representation which includes former note on to current note on, current note on to note off, pitch and velocity.
In particular, we are interested in generating extremely long music of hour level. We select Transformer-XL \cite{dai-etal-2019-transformer} which models extremely long (language) sequences by segment-level recurrences and relative position encoding. Different from \cite{donahue2019lakhnes}'s multi-instrumental music generation with event-based representation using transformer-XL, our proposal is to duplicate one Transformer-XL into four independently and jointly trained modules, taking our 4-tuple time-valued note sequences as inputs. Thanks to these time-valued data representation and four Transformer-XL networks trained in a joint way, our framework generates significantly better and hour-level longer music than three state-of-the-art baselines including Music Transformer, DeepJ, and single sequence-based Transformer-XL, evaluated automatically and manually. We extremely generated a continuous 36-hour music, with a stable high-level of note-density\footnote{Our full-version generated MIDI examples can be found at {https://pan.baidu.com/s/1i8pE7jEuWuWZy1DhW6XeJg} with code ckhv; and {https://drive.google.com/file/d/1VRoKY-INJ\_x1bte8SdTzvLao05uaZlIq/view?usp=sharing}.}.
\section{Data Representation}\label{section:data-representation}
\begin{figure}
\centering
\includegraphics[width=8.0cm]{./figures/figure_note_example_4tuple2.eps}
\caption{Illustration of our 4-tuple note representation.}
\label{figure:note_4tuple}
\end{figure}
We present a note by a 4-tuple $\langle on2on$, $on2off$, $pitch$, $velocity\rangle$. Here, $on2on$ and $on2off$ respectively stand for the \emph{note value} of from former note's on (start) to current note's on and from current note's on to its off (end). In addition, $pitch$ and $velocity$ are read from MIDI files directly using existing MIDI processing packages such as pretty\_midi\footnote{\url{http://craffel.github.io/pretty-midi/}} \cite{pretty-midi2014}.
Figure \ref{figure:note_4tuple} illustrates the differences of between our 4-tuple note representation (B and C) and Music Transformer's \cite{music-transformer-2018} performance event representation (A). There is a velocity-80 $C$ Major chord arpeggiated with the sustain pedal active under tempo of 120 beats per minute (bpm). At the 2.0-second mark, the pedal is released, ending all of the three notes. At the 3-second mark, an $F$ quarter note is played at velocity 100 for 1 second under a tempo of 60 bpm.
Suppose that the tempo for Figure \ref{figure:note_4tuple} is 120. The $on2on$ for the first note with pitch of 60 is 0. Its $on2off$ is computed by $2.0\times 120/(60\times4)=1.0$, where 2.0 is the two seconds that this note is on, 120 is the tempo, 60 for 60 seconds per minute, and 4 for the reciprocal of $1/4$ note (crotchet). Through this way, we list the 4-tuple representations of these four notes at B. In addition, as shown in C in Figure \ref{figure:note_4tuple}, we project these float representations of $on2on$ and $on2off$ into integers by producing them with 384=$128\times 3$. Note that 3 is introduced here for covering tritone cases.
In our 23-hour experiment data, the maximum integer reaches to 3,840, as long as ten tritones. Generally, the major difference is that we use these integer-style time values instead of TIME\_SHIFT as employed in Music Transformer \cite{music-transformer-2018}. Our usage of time-valued notes aligns with note values natural usage in music book score.
In addition, TIME\_SHIFT can possibly cause the confusion of time value information. That is, if we use the absolute time intervals to represent notes, then (1) one note can correspond to different time intervals and (2) one time interval can also correspond to different notes, under different tempo. The generated music is less user-friendly for composers' post-editing. Furthermore, in the performance event sequence, NOTE\_ON and NOTE\_OFF of various notes are mixed together which breaks the independences of notes and causes losing of time value information. Intuitively speaking, NOTE\_ON and NOTE\_OFF are alike brackets and should always be paired in one sequence for training. However, this is not guaranteed by event-length based sequence segmenting. Since the start and end time of each note are obtained by computing NOTE\_ON and NOTE\_OFF based on TIME\_SHIFT. As will be shown in our experiments, this computing process is problematic and frequently causes unstable rhythm (Figure \ref{figure:note-seq-compare}), especially during (10-minute and longer) long-time music generation.
Piano roll representation of notes is used in DeepJ \cite{deepj2018} as a ``dense'' representation of MIDI music. A piece of music is a $N\times T$ binary matrix where $N$ is the number of playable notes and $T$ is the number of time steps. Considering the difference in holding a note versus replaying a note, note play and replay (i.e., when a note is re-attacked immediately after the note ends, with no time steps in between successive plays) are utilized jointly to define note representation. However, piano roll is not dense since there are so many zeros in the play/replay matrices: only a few notes are attacked during each time step and all others are zero. It is further not easy to employ piano roll representation for sequential learning for music notes' ``language modelling''.
\section{Transformer-XL Training with Four Sequences of Time-valued Notes}\label{section:4transformer-xl}
\subsection{Transformer-XL}
Transformer-XL\footnote{{https://github.com/kimiyoung/transformer-xl}} \cite{dai-etal-2019-transformer} was designed to enable Transformer \cite{NIPS2017_7181_transformer} to learn dependency (of among language words or music notes in this paper) beyond a fixed length without disrupting temporal coherence. It consists of two updates, a segment-level recurrence mechanism and a positional encoding scheme. These allow Transformer-XL not only capturing longer-term dependency but also resolving the language/music context fragmentation problem. Motivated by its outstanding performance in terms of language modelling, we adapt this framework for music generation through learning a ``language model'' by using time-valued \emph{notes} instead of words as the fundamental units.
Formally, let $\textbf{s}_{\tau-1}=[x_{\tau-1,1}$, $\cdots$, $x_{\tau-1,L}]$ be the $(\tau-1)$-th segment with length $L$ (e.g., $L$ notes in music and $L$ words in natural language),
$\textbf{h}_{\tau-1}^{n-1}\in \mathbb{R}^{L\times d}$ is the $(n-1)$-th layer (e.g., in Transformer) hidden state sequence for $s_{\tau-1}$ in which $d$ is the hidden dimension. Then, for the next segment $\textbf{s}_{\tau}$, the hidden state of its $n$-th hidden layer is computed by:
\begin{align}
\tilde{\textbf{h}}_{\tau}^{n-1} & = [\text{SG}(\textbf{h}_{\tau-1}^{n-1})\circ \textbf{h}_{\tau}^{n-1}]; \label{eq:h_recurrent}\\
\textbf{q}_{\tau}^{n},\textbf{k}_{\tau}^{n},\textbf{v}_{\tau}^{n} & = \textbf{h}_{\tau}^{n-1}\textbf{W}_q^\top, \tilde{\textbf{h}}_{\tau}^{n-1}\textbf{W}_{k,(E)}^{\top}, \tilde{\textbf{h}}_{\tau}^{n-1}\textbf{W}_v^{\top}; \\
\textbf{h}_{\tau}^{n} & = \text{Transformer-Layer}(\textbf{q}_{\tau}^{n},\textbf{k}_{\tau}^{n},\textbf{v}_{\tau}^{n}). \label{eq:transformer_layer}
\end{align}
Here, the function $\text{SG}(\cdot)$ stands for stop gradient, i.e., the gradient of $\textbf{h}_{\tau-1}^{n-1}$ will not be updated basing on the next segments. The notation $[\textbf{h}_u\circ \textbf{h}_v]$ means the concatenation of two hidden sequences along the length dimension to extend the context. $\textbf{W}_{q,k,v}$ stand for trainable model parameters. Compared with Transformer \cite{NIPS2017_7181_transformer}, the major update here is the usage of $\textbf{h}_{\tau-1}^{n-1}$, previous segment's hidden state sequence of $(n-1)$-th layer, for computing an interim sequence $\tilde{\textbf{h}}_{\tau}^{n-1}$ and its further usage for computing the \textit{extended-context enhanced} sequences $\textbf{k}_{\tau}^{n}$ and $\textbf{v}_{\tau}^{n}$, to be retrieved by the query sequence $\textbf{q}_{\tau}^{n}$.
Transformer-XL applies this recurrent mechanism as defined in these equations alike $\textbf{h}_{\tau}^{n}$=$\text{recurrent}(\textbf{h}_{\tau-1}^{n-1},\textbf{h}_{\tau}^{n-1})$ to every two consecutive segments of a corpus. This essentially creates a segment-level recurrence in the hidden states of various transformer layers. As a result, the contextual information is allowed to go way beyond just two segments.
In the standard Transformer, the attention score between a query $q_i=(\textbf{E}_{x_i}+\textbf{U}_i)$ (i.e., embedding vector $\textbf{E}_{x_i}$ adds with $i$-th \textit{absolute} position encoding $\textbf{U}_i$) and a key vector $k_j=(\textbf{E}_{x_j} + \textbf{U}_j)$ within the same segment can be decomposed as:
\begin{equation}
\textbf{A}_{i,j}^{\text{abs}}=q_i^{\top}k_j=\left(
\textbf{E}_{x_i}^{\top} + \textbf{U}_i^{\top}
\right)\textbf{W}_q^{\top}\textbf{W}_k
\left(
\textbf{E}_{x_j} + \textbf{U}_j
\right).
\end{equation}
The shortage of absolute position encoding $\textbf{U}$ is that it is not able to distinguish the difference of one same position appearing in different segments. Following the idea of relative positional encoding \cite{shaw-etal-2018-self}, a relative distance $\textbf{R}_{i-j}$ is introduced to describe the relative positional embedding between $q_i$ and $k_j$. Here, $\textbf{R}$ is a sinusoid encoding matrix alike the one used in \cite{NIPS2017_7181_transformer} without learnable parameters. The relative attention score is then computed by:
\begin{equation}
\textbf{A}_{i,j}^{\text{rel}}=\left(
\textbf{W}_q\textbf{E}_{x_i} + u:v
\right)^{\top}
\left(
\textbf{W}_{k,E}\textbf{E}_{x_j} + \textbf{W}_{k,R}\textbf{R}_{i-j}
\right).
\end{equation}
Two trainable vectors $u,v\in\mathbb{R}^d$ are used to replace $\textbf{U}_i\textbf{W}_q$ and are respectively used for multiplying with $\textbf{W}_{k,E}\textbf{E}_{x_j}$ and $\textbf{W}_{k,R}\textbf{R}_{i-j}$. In addition, $\textbf{W}_k$ is deliberately separated into two weight matrices $\textbf{W}_{k,E}$ and $\textbf{W}_{k,R}$ for respectively producing content-based and position-based key vectors.
Then, the $n$-th ($n$ ranges over 1 to $N$) Transformer-Layer used in Equation \ref{eq:transformer_layer} by employing relative position encoding mechanism is computed by:
\begin{align}
\textbf{A}_{\tau,i,j}^{\text{rel},n}&=\left(
{\textbf{q}_{\tau,i}^{n}} + u:v
\right)^{\top}
\left(
\textbf{k}_{\tau,j}^{n} + \textbf{W}_{k,R}^{n}\textbf{R}_{i-j}
\right); \\
\textbf{a}_{\tau}^n & = \text{Masked-Softmax}(\textbf{A}_{\tau}^{\text{rel},n})\textbf{v}_{\tau}^n; \label{eq:masked-softmax}\\
\textbf{o}_{\tau}^n & = \text{LayerNorm}(\text{Linear}(\textbf{a}_{\tau}^n)+\textbf{h}_{\tau}^{n-1}); \label{eq:add-norm-1}\\
\textbf{b}_{\tau}^n & = \text{Positionwise-Feed-Forward}(\textbf{o}_{\tau}^n); \label{eq:feed-forward}\\
\textbf{h}_{\tau}^n & = \text{LayerNorm}(\text{Linear}(\textbf{b}_{\tau}^n)+\textbf{b}_{\tau}^{n})\label{eq:add-norm-2}.
\end{align}
\subsection{Joint Training}
\begin{figure*}
\centering
\includegraphics[width=15cm]{./figures/figure_4transformerxl.eps}
\caption{Our proposed framework with four transformer-xl networks.}
\label{figure:4transformerxl}
\end{figure*}
Figure \ref{figure:4transformerxl} depicts our framework that leverages four Transformer-XL networks,
corresponding to $on2on$, $on2off$, $pitch$, and $velocity$ in the 4-tuple time-valued notes. The first layer embeds these four sequences.
Then, $on2on$ and $on2off$'s embedded sequences are sent to $pitch$ and $velocity$ for including of time value information of notes. In addition, $pitch$'s embedded sequences are sent to $velocity$ as well to provide an influence. Next, $pitch$ and $velocity$ concatenate their own embedded sequences with external sequences. The vector dimension of each position in the sequence will be thrice for $pitch$ and fourfold for $velocity$.
We additionally employ a linear layer for dimension resizing before sending them to the memory sensitive blocks of Transformer-XL. Typically, each block mainly contain two components, a masked relative multi-head self-attention with memory (from former segment) and a position-wise feed forward layer. This block is repeated $N$ (e.g., 6 in the original Transformer \cite{NIPS2017_7181_transformer}) times. After these $N$ blocks for the four Transformer-XL, we employ a linear layer and softmax function to compute probabilities (i.e., normalized scores) of predicted sequences. We finally compute cross entropy loss for each sequence and add them up for the target loss optimizing.
In particular, the ``masked relative multi-head attention with memory'' block is computed by Equation \ref{eq:h_recurrent} to \ref{eq:masked-softmax}. Then, a residual function is defined in Equation \ref{eq:add-norm-1} for ``add \& norm''. The next ``add \& norm'' residual layer is defined in Equation \ref{eq:add-norm-2} for the position-wise feed forward layer.
In our proposed framework, the four sequences have relations in two places. First, concatenation of time valued $on2on$ and $on2off$ embedded sequences to $pitch$ and $velocity$. Second, joint loss which sums up the losses of the four sequences. The motivation of our designing is to both ensure the relative \textit{independence} of each sequence's development and the mixed \textit{influence} of from time-valued notes to pitch and velocity.
\section{Experiments \& Evaluations}\label{section:experiments}
\subsection{Data}
We collect 374 piano MIDI files from the web\footnote{\url{http://www.piano-midi.de/}}, which are hand-made from composers' \emph{piano music scores} with correct tempo information instead of players' performances\footnote{Such as the MAESTRO dataset in {https://magenta.tensorflow.org/datasets/maestro} with unchanged tempo information due to automatic transcribing from wav files to MIDI.} during periods of baroque, classical, and romantic. In the baroque period, Bach's fugue and prelude are mainly included. Classical period mainly contains products written by Beethoven, Mozart, Brahms, and Haydn. For the romantic period, we collect composers such as Chopin, Liszt, Mendelssohn, Schubert, and Tschaikovsky. Table \ref{table_data_midi} lists statistical information of our train, validation, and test sets.
\begin{table}
\begin{center}
\begin{tabular}{l|r|r|r}
\hline
& train & validation & test \\
\hline\hline
\# MIDI files & 299 & 34 & 41 \\
\# baroque & 69 & 8 & 10 \\
\# classical & 86 & 10 & 11 \\
\# romantic & 144 & 16 & 20 \\
length (hours) & 18.18 & 2.82 & 2.44 \\
\hline
\end{tabular}
\end{center}
\caption{Statistical information of 3 data sets. }\label{table_data_midi}
\end{table}
\subsection{Experiment Setups}
We perform our experiments under a NVIDIA P40 GPU card, with Tensorflow 1.13.1\footnote{\url{https://www.tensorflow.org/}} running under cuda 10.0 and cudnn 7.5.0. We implement our joint training framework (Figure \ref{figure:4transformerxl}) basing on Transformer-XL. The number of Transformer layers is 6, the number of heads is 8 with a dimension of 64. Embedding and hidden layer dimensions are identical to be 512. The dropout ratio is set to be 0.1. Memory length is 1,024. We use Adam algorithm \cite{kingma2014method} to optimize our networks. We retrain DeepJ\footnote{\url{https://github.com/calclavia/DeepJ}} with piano roll inputs, Music Transformer\footnote{{https://github.com/tensorflow/magenta/tree/master/ magenta/models/score2perf}} and single-sequence Transformer-XL both with performance event inputs, all using our 23-hour datasets.
\subsection{Subjective Evaluations}
For human evaluations, we separate all participants into two groups, professional composers and non-composers. Participants in the professional group are people who hold education degrees in music composition or electronic music composition and production, including Central Conservatory of Music, Shanghai Conservatory of Music, Communication University of China, Eastman School of Music, Berklee School of Music, Peabody Institute of JHU, and Steinhardt of NYU.
\subsubsection{Human or AI test}
Following \cite{deepbach2017}, we first design a ``Human or AI'' test for all participants. We prepared a mixed music collection with 5 music compositions composed by professional human composers and 11 pieces composed by our model for people to judge whether they are composed by humans or by AI. 39 professional composers were asked to rate for each music piece they heard from the music composition theory aspect while 61 non-composers were asked to rate by their subjective feelings. Our rating scale has five levels (points 1 to 5) including nonsense, basic, good, high-level, and masterpiece.
In order to avoid participants being affected by some other aspects such as musical instrument timbre and recording reverbs, all of the testing music whatever composed by human or AI are MIDI files and were exported from the same virtual piano (i.e., Logic's Steinway Grand Piano). Also, we limited the length of each music piece to be around 30 seconds, and every participant was asked to listen to 16 pieces. We limited the listening time to avoid auditory fatigue.
\begin{table}
\begin{center}
\begin{tabular}{l|r|r|r|r}
\hline
& It's Human & It's AI & Avg. & Avg. \\
& All (Pro.) & All (Pro.) & Pro. & All \\
\hline
Human & 218 (98) & 282 (97) & \textbf{3.24} & 3.01 \\
AI & \textbf{411 (132)} & \textbf{689} (\textbf{300}) & 2.94 & \textbf{3.11} \\
\hline
\end{tabular}
\end{center}
\caption{Human vs. AI evaluation results. }\label{table_human_or_ai}
\end{table}
The comparison results are listed in Table \ref{table_human_or_ai}. Among professional composers, the average human music compositions are scored higher than that of AI. However, among all participants, our AI music is scored higher (3.11 vs 3.01) than that of the real human pieces which demonstrates that our AI music composition quality is reasonably close to the quality of human composers. Even some of the pieces transcends humans' work according to some single ratings. Interestingly, for all evaluators, human composers' music are judged to be AI-made in a dominate way.
\subsubsection{Pairwise Comparison}
Our second test is to compare the perceived sample quality with three baseline models. We carried out listening tests comparing the baseline Music Transformer (MusicT), DeepJ, and single sequence-based Transformer-XL (1-seq txl). Our model is denoted as Mtxl. Participants (15 composers and 30 non-composers) were presented with two musical excerpts that were generated from two different models but were given the same priming note. Then the participants were asked to rate which one they preferred more. We generated 7 samples each model with a different prime, and compared them to three other models. In addition, we asked every participant to rank the reason of choice from four musical aspects: melody, harmony, rhythm, and emotion.
\begin{table}
\begin{center}
\begin{tabular}{l|r|r}
\hline
Mtxl vs DeepJ (30 sec.) & Mtxl & DeepJ \\
\hline
Professional group & \textbf{64} & 34 \\
Overall votes & \textbf{158} & 143 \\
\hline\hline
Mtxl vs 1-seq txl (30 sec.) & Mtxl & 1-seq txl \\
\hline
Professional group & \textbf{55} & 36 \\
Overall votes & \textbf{172} & 129 \\
\hline\hline
Mtxl vs MusicT (30 sec.) & Mtxl & MuiscT \\
\hline
Professional group & 29 & \textbf{69} \\
Overall votes & 110 & \textbf{163} \\
\hline
Mtxl vs MusicT (10 min.) & Mtxl & MuiscT \\
\hline
Professional group & \textbf{59} & 39 \\
Overall votes & \textbf{124} & 72 \\
\hline
\end{tabular}
\end{center}
\caption{Scores of votes for the four comparisons. }\label{table_human_eva_res}
\end{table}
The results are shown in Table \ref{table_human_eva_res}. Our music significantly exceeds ($p<0.01$) the ones generated by DeepJ, 1-seq txl, and 10-minute music of MusicT. People prefer the music generated by Music Transformer the most only at the case of 30-second music. The major reason collected from composer evaluators is that, the more ``humanistic'' music generated by Music Transformer is due to their unstable tempo and extremely long notes which make the music feel impressionism and have a natural reverb sounds similar to adding the sustain pedal.
Fine-grained comparison is depicted in Figure \ref{figure:why-us}. According to the data we collected from the pairwise comparison test, melody and rhythm are generally weighted higher than harmony and emotion. The results align with Table \ref{table_human_eva_res}: except MusicT of 30-sec., our model achieved significantly better ($p<0.01$) results than DeepJ and 1-seq txl. When we compare Mtxl and 10-min. MusicT, we observe that our melody and rhythm are significantly better ($p<0.01$). There is a tie-situation in terms of harmony and emotion, reflecting requirements of future work on improving these two aspects.
\begin{figure}
\centering
\includegraphics[width=7.8cm]{./figures/figure_why_us2.eps}
\caption{Fine-grained pairwise comparison.}
\label{figure:why-us}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=7.5cm]{./figures/figure_note_seq_compare.eps}
\caption{10-minute note sequence comparison of MusicT (up side) and MTxl (bottom side).}
\label{figure:note-seq-compare}
\end{figure}
For stability evaluation, we pairwise compare the long-time music (10-min.) generated by MusicT and Mtxl. We randomly generated 7 music pieces by each model with the same priming, and extracted the last 30 seconds from each piece. In Table \ref{table_human_eva_res}, our model performs significantly better ($p<0.01$) and is thus more stable in longer-time music generation of MusicT's extremely long notes). For example, in longer-time music, huge number of extremely long notes are generated by Music Transformer but only a few are really attacked and can be heard by human in later stages of music, as illustrated in Figure \ref{figure:note-seq-compare}.
Inspired by AI generated music, composers can further edit and modify it for specific emotional expression. For instance, Music Transformer and Single-sequence based Transformer-XL generate beaming-sixteenth-like notes yet with unstable tempo, which sounds weird. Therefore, the disadvantages of these two baselines include: due to the fact that notes are not being quantized to grids, it would be more difficult for people to generate music with specific time signatures, and also modify, set MIDI controllers and rearrange the music. In contrast, people can modify the music generated by our model because all our notes have been quantized into time-valued notes properly. More importantly, we can generate music of whatever time signatures we want with our approach.
\subsection{Objective Evaluations}
\begin{figure}
\centering
\subfigure[density comparison (600 seconds)]
{
\begin{minipage}{8cm}
\centering
\includegraphics[width=7.5cm]{./figures/figure_density_dis.eps}
\end{minipage}
}
\subfigure[pitch distribution comparison]
{
\begin{minipage}{8cm}
\centering
\includegraphics[width=7.2cm]{./figures/figure_pitch_distribution.eps}
\end{minipage}
}
\caption{Density and pitch distribution comparison}
\label{figure:density-compare}
\end{figure}
We calculate the densities (Figure \ref{figure:density-compare}) of notes using 4$\times$100 samples, 100 from each system. The density is defined to be the number of note-on per window size (5 seconds). As the generated sequences become longer and longer, the densities of Music Transformer and single-sequence Transformer-XL drop seriously. One main reason is the accumulated difficulty of NOTE\_ON and NOTE\_OFF matching for long sequences. As an intuitive comparison, our model can keep its stable note density. In fact, we generated a 36-hour sample, its density keeping to be sustainable. In addition, we compare pitch scattering (Figure \ref{figure:density-compare}) during pitch of 60 to 71. Our model's pitch distribution is the closest to the original dataset, reflecting the strong learning ability of our framework.
\subsection{Some Observations in Music Characteristics}
\subsubsection{Chord-like Progressions}
\begin{figure}
\centering
\includegraphics[width=7.8cm]{./figures/figure_song_example_1.eps}
\caption{Example of Chord-like progression.}
\label{figure:example-chord-like-progression}
\end{figure}
As shown in Figure \ref{figure:example-chord-like-progression}, we find that our model has learned some chord progression modes from original data.
Here, the Tonic-to-Dominant chord progression, one of the most commonly used progressions, has been observed in numerous generated pieces. This successive chord progression also resulted in a tonal transposition from C major to D major.
\subsubsection{Well-adjusted Dynamics and Rhythm Patterns}
What surprised us is that the dynamic control by ``independent'' velocity performed well in our results. Few notes have abrupt velocity such as a sudden high or a sudden low. The velocity was mostly changing gradually with a tender ascending and descending. Also, between sections, there are some whole-group contrasts in velocity which are quite similar to the emotional contrast between music movements. Moreover, the velocity ascends and descends along with the rising pitches and the falls, commonly used in real music compositions. In a quarter note-long example (Figure \ref{figure:example-2-rhythm-patterns}\footnote{{https://www.youtube.com/watch?v=V8XSCojvaas}}), besides some common combinations such as single quarter note, beaming eighth notes, one eighth plus two sixteenth, beaming sixteenth notes, there are syncopated patterns, notes with dots and ties and appropriate rests.
\begin{figure}
\centering
\includegraphics[width=7.8cm]{./figures/figure_song_example_2.eps}
\caption{Rhythm patterns example.}
\label{figure:example-2-rhythm-patterns}
\end{figure}
\section{Conclusion}\label{section:conclusion}
We have described our Transformer-XL based piano music generation framework and experiments. Motived by training from composers' music book scores instead of players' performance events, we leverage four sequences of time-valued notes, former note on to current note on, current note on to its note off, pitch, and velocity. We first proposed this novel note representation method which projects each note in MIDI files into a 4-tuple. Then, four Transformer-XL networks are jointly trained by taking these four sequences as inputs with shared embedding concatenations and accumulated cross entropy loss. Through training on a 23-hour piano MIDI dataset, our framework generates significantly better and hour-level stably longer music than three state-of-the-art baselines, Music Transformer, DeepJ, and single sequence-based Transformer-XL, evaluated automatically and manually.
Our multi-sequence learning framework for music is scalable and can be further enriched by additional information, such as tempo sequences, emotions and music genres for enhancing the expressive ability of the generated music. We take these as our future work.
\bibliographystyle{acl_natbib}
| {'timestamp': '2020-07-15T02:23:03', 'yymm': '2007', 'arxiv_id': '2007.07244', 'language': 'en', 'url': 'https://arxiv.org/abs/2007.07244'} | arxiv |
\section{Introduction}
\IEEEPARstart{E}{nergy} efficiency has emerged as a key performance indicator in the design of wireless communication systems, due to operational, economic, and environmental concerns \cite{buzzi2016survey}. Device-to-device (D2D) communication has been proposed as a promising technology to increase energy efficiency (EE), which allows new peer-to-peer communication service by leveraging the proximity and reuse gains \cite{jiang2015energy}.
\par
Reconfigurable intelligent surface (RIS) is designed to improve the propagation environment and enhance wireless communications, and has attracted much attention recently \cite{8959174,8941126,huang2019reconfigurable}. Specifically, RIS is a meta-surface with a large number of passive reflecting elements. Each element can induce a phase shift to the incident signal independently. All elements cooperatively perform the reflect beamforming. Unlike the conventional amplify-and-forward (AF) relay, the RIS forwards the incident signals using passive reflection beamforming, which reduces the energy consumption of the system. These characteristics make the RIS technology attractive from an energy efficiency standpoint \cite{huang2019reconfigurable}.
\par
In this letter, we propose a RIS-assisted D2D communication network with a full-frequency reuse to support D2D users, which is assisted by some RISs. The EE maximization problem is formulated to optimize the RIS phase shifts and the transmit powers under phase-shift, maximum power and minimum transmission rate constraints. We divide the non-convex problem into two subproblems, which are passive beamforming and power control. The two subproblems can be optimized alternately. We first rewrite the passive beamforming at RIS based on the Lagrangian dual transform \cite{shen2018fractional}, and solve this subproblem based on the fractional programming \cite{shen2018fractional}. Then, we transform the power control subproblem in a fractional form into an equivalent optimization problem in a subtractive form, which is solvable by the Dinkelbach method \cite{dinkelbach1967nonlinear}. The two subproblems are solved iteratively until convergence, yielding a suboptimal solution for the joint optimization problem. Numerical results have verified the effectiveness of the proposed algorithm, which can significantly improve the energy efficiency of the D2D network.
\section{System Model}
In this letter, we consider the RIS-aided D2D communication network with full-frequency reuse to support D2D users. Without loss of generality, we assume that there are $L$ D2D links in the network, assisted by geographically separated $M$ RISs, where the $m$-th RIS, denoted by $\textrm{RIS}_{m}$, has $N_{m}$ elements. We assume that the power of the signals reflected by the RIS for two or more times can be ignored due to significant path loss. Besides, we assume that all the channels experience quasi-static flat-fading, and the channel state information (CSI) can be estimated by using the existing channel estimation methods, such as in \cite{8879620}.
\begin{comment}
\begin{figure}[H]
\centering
\includegraphics[scale=0.6]{1.png}
\caption{RIS aided D2D communication}
\label{4}
\end{figure}
\end{comment}
\par
Denote by $h_{ij}\in \mathbb{C}$ the channel coefficient from transmitter $i$ to receiver $j$. The channel coefficient vectors from transmitter $i$ to $\textrm{RIS}_{m}$ and from receiver $j$ to $\textrm{RIS}_{m}$ are denoted by $\mbf{g}_{i}^{m}\in \mathbb{C}^{ N_{m}\times 1}$ and $\mbf{f}_{j}^{m}\in \mathbb{C}^{ N_{m}\times 1}$, respectively. Let $N=\sum_{m=1}^{M}N_m$ be the total number of reflecting elements. The channel coefficient vectors from transmitter $i$ to RISs and from receiever $j$ to RISs are denoted by $\mbf{g}_{i}\in \mathbb{C}^{ N\times 1}$ and $\mbf{f}_{j}\in \mathbb{C}^{ N\times 1}$, respectively. A simple scenario with one RIS and two D2D pairs is shown in Fig. \ref{f1}.
\begin{figure}[h]
\centering
\includegraphics[scale=0.7]{1.pdf}
\caption{The RIS-aided D2D communication network with one RIS and two D2D pairs.}
\label{f1}
\end{figure}
\par
The phase-shift matrix of the RISs is denoted by a diagonal matrix $\mbf{\Theta}=\sqrt{\eta} \operatorname{diag}\left(\boldsymbol{\theta}\right)$, where $\boldsymbol{\theta}=[\theta_{1}, \cdots, \theta_{N}]^{H}$, $|\theta_{n}|=1$ and $\eta \in (0,1)$.
\par
Denote by $x_{i}$ the transmit data symbol to user $i$. The received signal of receiver $l$ is given by
\begin{equation}
y_{l}=\sum_{i=1}^{L} (h_{il}+f_{l}^{T}\mathbf{\Theta}g_{i}) x_{i}+w_{l},
\end{equation}
where $w_{l} \sim \mathcal{C} \mathcal{N}\left(0, \sigma^{2}\right)$ is the additive white Gaussian noise (AWGN) at the $l$-th receiver. Denote by $p_{l}$ as the transmit power of D2D link $l$. The signal-to-interference-plus-noise ratio (SINR) of link $l$ is expressed as
\begin{equation}
z_{l}=\frac{|h_{l l}+ f_{l}^{T}\mathbf{\Theta}g_{l}|^{2}p_{l}} {\sum_{i \neq l,i=1}^{L} |h_{i l}+f_{l}^{T}\mathbf{\Theta}g_{i}|^{2} p_{i}+\sigma^{2}}.
\end{equation}
Then, the achievable sum rate of the system is given by
\begin{equation}
\mathcal{R} = \sum_{l=1}^{L} \log _{2}\left(1+z_{l}\right).
\end{equation}
\par
The total power consumption contains D2D users' transmit power $\mbf{p}$, circuit power $P_{c}$ and the RISs' power. The RISs' power consumption depends on the type and the resolution of its individual elements \cite{huang2019reconfigurable}. Elements with $b$-bit resolution can perform $b$-bit phase shifting on the impinging signal. The power consumption of the RISs with $N$ reflecting elements can be written as
\begin{equation}
P_{\mathrm{RIS}}=N P(b),
\end{equation}
where $P(b)$ denotes the power consumption of each element having $b$-bit resolution. Thus, the toal power consumption can be expressed as
\begin{equation}
\mathcal{P}_{\text {total }}=\sum_{l=1}^{L}\left( p_{l}+2P_{c}\right)+NP(b).
\end{equation}
\par
We define the ratio between the achievable sum rate and the total power consumption as the energy efficiency (EE). The energy efficiency is maximized by jointly optimizing the transmit power $\mbf{p}$ and the phase-shift matirx $\mbf{\Theta}$, subject to RIS’s phase-shift, maximum power and minimum transmission rate constraints. Thus, the problem can be formulated as
\begin{subequations} \label{P1}
\begin{align}
\max_{\mbf{p}, \mbf{\Theta}} \quad & {\mathrm{EE}}=\frac{ \sum_{l=1}^{L} \log _{2}\left(1+z_{l}\right)}{\sum_{l=1}^{L} p_{l}+2L P_{c}+N P(b)} & \\
\mbox{s.t.}\quad
&\log _{2}\left(1+z_{l}\right) \geq R_{\min , l} \quad \forall l=1,2, \ldots, L & \\
&0 \leq p_{l} \leq P_{\max } \quad \forall l=1,2, \ldots, L\\
& {\left|\theta_{n}\right|=1 \quad \forall n=1,2, \ldots, N}.&
\end{align}
\end{subequations}
It is difficult to obtain the optimal solution to this problem due to its nonconvex objective function and constant-modulus constraints. In the next section, an efficient algorithm is proposed to obtain a suboptimal solution to this problem.
\section{Energy Efficiency Maximization} \label{section3}
In this section, we adress the energy efficiency maximization problem of the RIS-aided D2D system. We divide the problem (6) into two subproblems, i.e., the passive beamforming and the power control, respectively. Then, the power control and passive beamforming can be optimized alternately.
\subsection{Optimizing $\boldsymbol{\Theta}$ for Given $\mbf{p}$}
For a fixed $\mbf{p}$, the problem (\ref{P1}) reduces to
\begin{align} \label{P2}
\max_{ \boldsymbol{\Theta}} \quad &~ \sum_{l=1}^{L} \log _{2}\left(1+z_{l}\right) \notag \\
\mbox{s.t.}\quad &(6b),(6d).
\end{align}
\par
We apply the the Lagrangian dual transform \cite{guo2019weighted} to (\ref{P2}), with the new objective function given by
\begin{equation}
\begin{aligned}
f(\boldsymbol{\Theta},\boldsymbol{\beta})=\sum_{l=1}^{L} \log _{2}&~\left(1+\beta_{l}\right) -\sum_{l=1}^{L} \beta_{l} \\
&+\sum_{l=1}^{L} \frac{(1+\beta_{l})|h_{l l}+ f_{l}^{T}\mathbf{\Theta}g_{l}|^{2}p_{l}}{\sum_{i=1}^{L} |h_{i l}+f_{l}^{T}\mathbf{\Theta}g_{i}|^{2} p_{i}+\sigma^{2}},
\end{aligned}
\end{equation}
where $\boldsymbol{\beta}$ refers to a set of auxiliary variables. We propose to optimize $\boldsymbol{\beta}$ and $\boldsymbol{\Theta}$ alternately. For a fixed $\boldsymbol{\Theta}$, the optimal $\beta_{l}$ is
\begin{equation}
\beta_{l}^{\circ}=\frac{|h_{l l}+ f_{l}^{T}\mathbf{\Theta}g_{l}|^{2}p_{l}} {\sum_{i \neq l,i=1}^{L} |h_{i l}+f_{l}^{T}\mathbf{\Theta}g_{i}|^{2} p_{i}+\sigma^{2}}.
\end{equation}
Then, for a fixed $\boldsymbol{\beta}$, optimizing $\boldsymbol{\Theta}$ is reduced to
\begin{align} \label{P3}
\max_{ \boldsymbol{\Theta}} \quad & f_{1}(\boldsymbol{\Theta})=\sum_{l=1}^{L}\frac{(1+\beta_{l})|h_{l l}+ f_{l}^{T}\mathbf{\Theta}g_{l}|^{2}p_{l}}{\sum_{i=1}^{L} |h_{i l}+f_{l}^{T}\mathbf{\Theta}g_{i}|^{2} p_{i}+\sigma^{2}}& \notag \\
\mbox{s.t.}\quad
&(6b),(6d).&
\end{align}
\par
The problem (\ref{P3}) can be solved by using the FP method. Define $\mathbf{A}_{il}=diag(f_{l})g_{i}\sqrt{p_{i}}$ and $b_{il}=h_{il}\sqrt{p_{i}}$. Using the quadratic transform proposed in \cite{shen2018fractional}, $f_{1}(\boldsymbol{\Theta})$ is reformulated as
\begin{equation} \label{obj1}
\begin{aligned}
f_{2}(\boldsymbol{\theta},\boldsymbol{\varepsilon})=\sum_{l=1}^{L} 2\sqrt{1+\beta_{l}}&~\mathbf{Re}\{
\varepsilon_{l}^{*}\boldsymbol{\theta^{\mathbf{H}}}\mathbf{A}_{ll}+\varepsilon_{l}^{*}b_{ll}
\}\\
&-\sum_{l=1}^{L}|\varepsilon_{l}|^{2} (\sum_{i=1}^{L}|b_{il}+\boldsymbol{\theta^{\mathbf{H}}}\mathbf{A}_{il}|^{2}+\sigma^{2}).
\end{aligned}
\end{equation}
\par
We optimize $\boldsymbol{\theta}$ and $\boldsymbol{\varepsilon}$ alternately. The optimal $\varepsilon_{l}$ can be obtained by letting $\partial f_{2}/ \partial \varepsilon_{l}=0$, yielding
\begin{equation}
\varepsilon_{l}^{\circ}=\frac{\sqrt{1+\beta_{l}}(b_{ll}+\boldsymbol{\theta^{\mathbf{H}}}\mathbf{A}_{ll})}{\sum_{i=1}^{L}|b_{il}+\boldsymbol{\theta^{\mathbf{H}}}\mathbf{A}_{il}|^{2}+\sigma^{2}}.
\end{equation}
\par
Then the remaining problem is to optimize $\boldsymbol{\theta}$ for a given $\boldsymbol{\varepsilon}$. By simplifying (\ref{obj1}), the optimization problem for $\boldsymbol{\theta}$ is represented as
\begin{align} \label{P4}
\max_{ \boldsymbol{\theta}} \quad & f_{3}(\boldsymbol{\theta})= -\boldsymbol{\theta}^\mathbf{H}\mathbf{U}\boldsymbol{\theta}+2\textbf{Re}\{\boldsymbol{\theta}^\mathbf{H}\mbf{v} \}+C \notag \\
\mbox{s.t.}\quad
&(6b),(6d),&
\end{align}
where
\begin{equation}
\mathbf{U}=\sum_{l=1}^{l}\left|\varepsilon_{l}\right|^{2} \sum_{i=1}^{L} \mathbf{A}_{il} \mathbf{A}_{il}^{\mathrm{H}}
\end{equation}
\begin{equation}
\mbf{v}=\sum_{l=1}^{L}\left(\sqrt{\beta_{l}+1} \varepsilon_{l}^{*} \mathbf{A}_{ll}-\left|\varepsilon_{l}\right|^{2} \sum_{i=1}^{l} b_{il}^{*} \mathbf{A}_{il}\right),
\end{equation}
\begin{comment}
\begin{equation}
C=\sum_{l=1}^{L}\left(2 \sqrt{\beta_{l}+1} \operatorname{Re}\left\{\varepsilon_{l}^{*} b_{ll}\right\}-\left|\varepsilon_{l}\right|^{2}\left(\sigma^{2}+\sum_{i=1}^{L}\left|b_{il}\right|^{2}\right)\right)
\end{equation}
\end{comment}
and $C$ is a constant. Since $\mbf{A}_{il}\mbf{A}_{il}^{\mathrm{H}}$ for all $i$ and $l$ are positive-definite matrices, $\mathbf{U}$ is a positive-definite matrix and $f_{3}(\boldsymbol{\theta})$ is a quadratic concave functions of $\boldsymbol{\theta}$. Problem (\ref{P4}) is non-convex and inhomogeneous due to the non-convexity of the quadratic constraints and the unit modulus constraints. Letting $\boldsymbol{\bar{\theta}^{\mbf{H}}}=[\boldsymbol{\theta^\mbf{H}}, 1]$ and $\mbf{Q}=\boldsymbol{\bar{\theta}}\boldsymbol{\bar{\theta}^\mbf{H}}$, and dropping the rank-one constraint of $\mathbf{Q}$, problem (\ref{P4}) can be rewritten as
\begin{subequations} \label{P5}
\begin{align}
\max_{ \mathbf{Q}} \quad & \operatorname{Tr}(\mathbf{\bar{U}} \mathbf{Q}) & \\
\mbox{s.t.}\quad
&\gamma_{l}^{\min }\left(\sum_{i \neq l}^{L}\left(\operatorname{Tr}\left(\mbf{R}_{i, l} \mathbf{Q}\right)+\left|b_{il}\right|^{2}\right)+\sigma^{2}\right) &\notag\\
&\leq \operatorname{Tr}\left(\mbf{R}_{l, l} \mathbf{Q}\right)+\left|b_{ll}\right|^{2}, \forall l, l=1, \ldots, L& \\
& \mathbf{Q}_{n, n}=1, \forall n=1, \ldots, N+1&\\
&\mathbf{Q} \succcurlyeq 0,&
\end{align}
\end{subequations}
where,
\par
$\mbf{R}_{i, l}=\left[\begin{array}{cc}
\mbf{A}_{il} \mbf{A}_{il}^{\mathrm{H}} & \mbf{A}_{il} b_{il}^{*} \\
b_{il} \mbf{A}_{il}^{\mathrm{H}} & 0
\end{array}\right]$, $\mathbf{\bar{U}}=\left[\begin{array}{cc}
\mathbf{U}& \mbf{-v}\\
\mbf{-v}^{\mathrm{H}} & 0
\end{array}\right]$.
\par
We can solve problem (\ref{P5}) via CVX \cite{cvx}. Then the standard Gaussian randomization can be used to obtain a feasible rank-one solution. We summarize the optimization method for $\mathbf{\Theta}$ with a fixed $\mbf{p}$ in Algorithm 1.
\begin{algorithm}[H]
\vspace{0.2mm}
\caption{\textbf{\!:} \vspace{0.15mm} Optimizing $\boldsymbol{\Theta}$ for Given $\mbf{p}$ }
\textbf{\,Initialization:} Initialize $\boldsymbol{\Theta}^{(0)}$ to a feasible value, $i=0$.
\begin{algorithmic}[1]
\State Update the auxiliary variable $\beta_{l}^{i}$ by (9).
\\ Update the auxiliary variable $\epsilon_{l}^{i}$ by (12).
\\Update $\boldsymbol{\Theta}^{(i)}$ by solving (\ref{P5}) together with Gaussian randomization.
\\Repeat setps 1-3 until the value of $\boldsymbol{\Theta}$ converges.
\end{algorithmic}
\textbf{\,Output:} $\boldsymbol{\Theta}^{(i)}$
\end{algorithm}
\subsection{Optimizing $\mbf{p}$ for Given $\boldsymbol{\Theta}$}
For a fixed $\boldsymbol{\theta}$, the problem (\ref{P1}) reduces to
\begin{align} \label{P6}
\max_{\mbf{p}} \quad&\frac{ \sum_{l=1}^{L} \log _{2}\left(1+z_{l}\right)}{\sum_{l=1}^{L} p_{l}+2L P_{c}+N P(b)} & \notag \\
\mbox{s.t.}\quad
&(6b),(6c).&
\end{align}
Problem (\ref{P6}) is a non-concave FP problem. From \cite{dinkelbach1967nonlinear}, we define a new optimization problem as
\begin{align} \label{P7}
\max_{\mbf{p}} \quad&~F(\lambda) & \notag \\
\mbox{s.t.}\quad
&(6b),(6c),&
\end{align}
where $\lambda$ is a non-negative parameter, and
\begin{equation} \label{obj2}
F(\lambda)={\sum_{l=1}^{L} \log _{2}\left(1+z_{l}\right)}-\lambda({\sum_{l=1}^{L} p_{l}+2L P_{c}+N P(b)}).
\end{equation}
$F(\lambda)$ is continuous and strictly monotonically decreasing in $\lambda$ and has a unique root $\lambda^{*}$. The optimal solution $\mbf{p^{*}}$ of problem (\ref{P6}) is the same as that of problem (\ref{P7}) with $\lambda=\lambda^{*}$, where $\lambda^{*}$ can be obtained by using the Dinkelbach method \cite{dinkelbach1967nonlinear}.
\par
The key of the method is to solve problem (\ref{P7}) for a given $\lambda$. To be specific, (\ref{obj2}) can be rewritten as
\begin{equation}
F(\lambda)=f_{1}(\mbf{p})-f_{2}(\mbf{p})
\end{equation}
where
\begin{equation}
\begin{aligned}
f_{1}(\mbf{p})=\sum_{l=1}^{L}\log_{2}(\sum_{i=1}^{L}&~|h_{il}+f_{l}\boldsymbol{\Theta}g_{i}|^{2}p_{i}+\sigma^{2})\\
&-\lambda \sum_{i=1}^{L}p_{i}-\lambda(2LP_{c}+NP(b))
\end{aligned}
\end{equation}
\begin{equation}
f_{2}(\mbf{p})=\sum_{l=1}^{L}\log_{2}(\sum_{i=1,i\neq l}^{L}|h_{il}+f_{l}\boldsymbol{\Theta}g_{i}|^{2}p_{i}+\sigma^{2}).
\end{equation}
Clearly, $f_{1}(\mbf{p})$ and $f_{2}(\mbf{p})$ are concave. Hence, the objective function of (\ref{P7}) is the difference of two concave functions. Constraints in (6b) are also the difference of two concave functions, which are
\begin{equation}
c_{1,l}(\mbf{p})-c_{2,l}(\mbf{p}) \geq R_{\min , l} \quad \forall l=1,2, \ldots, L
\end{equation}
where
\begin{align}
c_{1,l}(\mbf{p})=\log_{2}(\sum_{i=1}^{L}|h_{il}+f_{l}\boldsymbol{\Theta}g_{i}|^{2}p_{i}+\sigma^{2})
\end{align}
\begin{align}
c_{2,l}(\mbf{p})=\log_{2}(\sum_{i=1,i\neq l}^{L}|h_{il}+f_{l}\boldsymbol{\Theta}g_{i}|^{2}p_{i}+\sigma^{2}).
\end{align}
\par
Consequently, problem (\ref{P7}) is a difference of convex (DC) programming problem. We apply the DC algorithm \cite{tao1997convex} to obtain a suboptimal solution of problem (18).
\begin{comment}
We summarize the optimization method for $\mbf{\Theta}$ with a fixed $\mbf{p}$ in Algorithm 2.
\begin{algorithm}[H]
\vspace{0.2mm}
\caption{\textbf{\!:} \vspace{0.15mm} Optimizing $\mbf{p}$ for Given $\boldsymbol{\theta}$}
\textbf{\,Initialization:} Set tolerance $\epsilon$, $s=1$, $\lambda_{s}=0$.
\begin{algorithmic}[1]
\State Obtain $\mbf{p}_{s}$ by solving problem (18) with DCA.\\
Update $\lambda_{s}$ by (6a).\\
If $|F(\lambda_{s})| \geq \epsilon$, set $s=s+1$.\\
Repeat steps 1-3 until $F(q_{s})| < \epsilon$.
\end{algorithmic}
\textbf{\,Output:} $\mbf{p}_{s}$
\end{algorithm}
\end{comment}
\section{Numerical Result}
In this section, numerical results are provided to demonstrate the validity of the proposed algorithm. We consider a RIS-aided D2D network with multiple single-antenna D2D users, which are assumed randomly and uniformly placed in the $200m \times 200m$ rectangular. And there are four RISs in the rectangular. The distance between D2D users is 20-40m. The baseband channels of the RIS-user link, user-RIS link, and user-user link are modeled as Rician fading channels with Rician factor $\beta =2$. The background noise at the receivers is $\sigma^{2}=-117$ dBm. We set the path-loss constant $k=10^{-3}$, the path-loss exponent $\chi=4$. Circuit power at each user $P_{C}=15$ dBm. RIS reflection efficiency $\eta=0.8$. All presented results are obtained by averaging over 1000 independent channel realizations.
\par
We compare the performance of the proposed algorithm with two baselines. Baseline 1 is the energy efficiency optimized by power control without the aid of RIS. Baseline 2 is the energy efficiency optimized by optimal power control with the aid of RISs. We adopt the Branch and Bound method to obtain the optimal power control \cite{yang2016energy}. Fig. 2 illustrates the energy efficiency of different power parameters $P(b)$ with respect to the size of $N$ of RIS. As we can see, significant performance gains are achieved by joint power control and RISs' passive beamforming optimization. Typical power consumption values of each RIS element are 1.5, 4.5, 6, and 7.8 mW for 3-, 4-, 5-, and 6-bit resolution \cite{ribeiro2018energy}. As the number of quantized bits increases, the energy efficiency decreases gradually. Although high-bit RIS will improve the spectral efficiency of the network, its high power consumption leads to the decrease of energy efficiency.
\begin{figure}[h]
\centering
\includegraphics[scale=0.5]{4.pdf}
\caption{The energy efficiency versus the number of RIS elements for $L=10$, $P_{max}=0.1$ W, $R_{min}=0$ bps/Hz}
\label{4}
\end{figure}
\par
Particularly, EE performance increases as $N$ increases. However, for a large $N$, EE starts decreasing. This is because for a large $N$, RISs' improvement in spectrum efficiency is no longer enough to compensate for the decrease in system energy efficiency caused by high power consumption. So, there exists an optimal number $N$ of RIS elements. Besides, the energy efficiency tends to decrease firstly and then increase. This is because when $N$ is too small, there will be little improvement in spectral efficiency with the assistance of the RISs. However, the power consumption of the RISs results in the decrease of energy efficiency.
\begin{figure}[t]
\centering
\includegraphics[width=4.5cm,height=4.5cm]{5.pdf}\,\includegraphics[width=4.5cm,height=4.5cm]{6.pdf}\\
\vspace{-2.5mm}
\caption{(a) The energy efficiency versus $P_{max}$ for $L=10$, $N=80$; (b) The failure rate versus $P_{max}$ for $L=10$, $N=80$.}
\label{fig1}
\end{figure}
\par
The effect of the different values of $R_{min}$ and EE performances versus $P_{max}$ in dBm is depicted in Fig. 3. For the cases where the design problems turned out to be infeasible, EE is set to zero, corresponding to a communication failure. Fig. 3(a) compares the EE with the different minimum rate $R_{min}$. When $R_{min}=0$, EE increases to a fixed value as the power limit $P_{max}$ increases. For the higher $R_{min}$, EE will increase to a lower fixed value. Fig. 3(b) compares the failure rate with the different minimum rate $R_{min}$. Similarly, for the higher $R_{min}$, the failure rate will reduce to a higher fixed value. At this moment, increasing $P_{max}$ does not improve efficiency or reduce failure rate.
\section{Conclusion}
In this letter, the RIS technique was applied to enhance the energy efficiency of D2D communication network. To maximize the energy efficiency, we proposed a joint power control and RISs' passive beamforming optimization algorithm for obtaining the high-quality suboptimal solution. Simulation results demonstrated that the assistance of the RISs is beneficial to substantially improve the energy efficiency of the D2D communication network.
\renewcommand\refname{References}
\bibliographystyle{IEEEtran}
| {'timestamp': '2020-06-19T02:10:26', 'yymm': '2006', 'arxiv_id': '2006.10320', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10320'} | arxiv |
\section{Design and Implementation}
\input{Design/overview}
\input{Design/operators}
\input{Design/canonicalize}
\input{Design/legalize}
\input{Design/schedules}
\subsection{QNN Legalize Pass}
QNN optimization passes, just like Relay passes, allow graph transformations. However, the key difference is that QNN passes have quantization context, \emph{e.g.}, QNN conv2d operators have scale and zero points for the input tensors. The quantization context is helpful to perform hardware-specific graph-IR transformations to satisfy the data type restrictions imposed by the hardware instruction set. We call this pass QNN Legalize pass. Legalization is a common compilation pass that transforms an IR for a specific platform to use the instructions natively supported by the platform. QNN Legalize pass allows developers to easily perform these quantization-aware platform-specific graph optimizations. Its backbone is built on existing Relay infrastructure that allows customization of graph optimization for hardware platforms.
For example, TFLite pre-quantized graphs have $uint8 \times uint8$ inputs for the quantized conv2d operator. However, Intel VNNI instructions-based platforms impose $uint8$ $\times$ $int8$ data type requirement. QNN Legalize pass bridges this gap in a developer-friendly manner by allowing one to insert a requantize operator before the second operand of conv2d, converting the data type from \texttt{uint8} to \texttt{int8}. For ARMv8-based devices, on the other hand, we observe that LLVM performs better code generation if the input tensors are of \texttt{int16} datattype instead of \texttt{int8} datatype, and utilizes fast \texttt{int16} multiply-accumulate instruction ($vmlal$). Therefore, QNN Legalize performs a graph transformation to insert data type upcasting before both operands of the QNN conv2d operator, changing the QNN conv2d input data type to \texttt{int16}.
\subsection{QNN Operators and Framework Parsers}
\label{subsec:ops}
QNN operators act as wrappers, i.e., a developer simply defines how a QNN operator can be represented as a sequence of existing Relay operators. As a result, a developer does not have to add any loop-level tensor IR description of any new QNN operator. This developer provided sequence is used by the QNN Canonicalize pass to convert QNN operators to sequences of Relay-only operators.
In order to narrow down the set of QNN operators to support, we first collected quantized operators from the most widely used frameworks - TFLite, MXNet and PyTorch. We observed that the same operator name can mean different computation manners for different frameworks. For example, TFLite quantized conv2d operator performs \texttt{int8} convolution, requantization of output tensor, ReLU and bias addition in a single operator. The quantized conv2d operator of MXNet goes one step further in aggressive fusion, fusing residual addition operations and folding batch normalization.
To address this computation boundary mismatch, we came up with suitable QNN operators to express different computations for all the mainstream frameworks and all their quantized operators. When necessary, we created finer-grain QNN operators. Essentially, one framework quantized operator can map to a sequence of one or many QNN/Relay operators. We illustrate this idea with the help of an example of conversion of TFLite quantized conv2d operator in Figure~\ref{fig:tflite_conv2d}.
We use a sequence of QNN conv2d, Relay bias\_add, Relay clip and QNN requantize operator to parse the TFLite quantized conv2d operator. We define QNN conv2d computation such that it only handles the quantized tensors and adjustments for zero points as shown in Equation~\ref{eq:conv2d_terms}. For scale handling, we created another QNN operator called requantize, which is extensively used in quantized models to convert one quantized tensor with some scale and zero point to another quantized tensor with another scale and zero point (more details in Section~\ref{subsec:passes}).
A developer, in a similar manner, can follow the computation of a quantized framework operator and can represent it as a sequence of Relay operators with low effort. We added support for different types of quantization approaches in this manner. After the infrastructure was in place, we found that implementing weight per-channel quantization took less than a week of developer effort with QNN dialect requiring no extra work in tensor IR.
\begin{figure}
\centering
\includegraphics[width=0.48\textwidth]{./figures/tflite_conv2d.pdf}
\caption{Example of TFLite quantized conv2d operator parsing - TFLite con2d has multiple operators fused internally. We parse it to a sequence of QNN and existing Relay operators - QNN conv2d followed by Relay bias\_add. Then the tensor values are clipped by pre-defined output minimum and maximum values. Finally, we call the QNN requantize operator to go back to int8 datatype.}
\label{fig:tflite_conv2d}
\vspace{-4mm}
\end{figure}
\subsection{TVM Schedules for Integer Operators}
\label{subsec:schedules}
As shown in Figure~\ref{fig:overview}, after Relay optimization passes have been applied, each fused operator is then lowered to machine code via TVM tensor IR. For many simple operators, like addition or ReLU, that do not have any data reuse, there is not much room for further optimization in addition to relying on off-the-shelf code generators like LLVM/NVCC to get performant machine code. However, operators like conv2d or matmul (matrix multiplication) require specific tensor IR optimizations (also known as a compute and schedule implementation in the context of TVM) to efficiently exploit data reuse. This optimization effort needs to be done for every platform due to drastic architectural differences.
QNN infrastructure quickly shifts the developer focus to only those operators that need extra attention due to integer computations. For example, we can reuse existing TVM schedules for integer pooling, vector addition, ReLU etc. This is in contrast to frameworks, where a new quantized operator (which handles scale and zero points internally) need to be implemented separately. For the operators significantly affected by the integer computation, we can write specific schedules for them to utilize the fast integer instructions provide by the hardware to get desirable performance. We present our observations regarding the usage of these instructions across both server and edge devices.
\noindent \emph{\textbf{Intel VNNI}} - TVM relies on off-the-shelf code generators to generate good quality code. However in some cases, it might be difficult for LLVM to use the right instructions automatically. For example, Intel VNNI instruction performs a vector dot-product of 4 \texttt{int8} values and accumulate them into \texttt{int32}, potentially achieve 4$\times$ speedup over \texttt{fp32} computation. However, by now LLVM is still unable to detect this macro pattern from LLVM IR to replace with proper Intel VNNI instructions. Therefore, in this case a developer can directly embed the LLVM intrinsics in the TVM tensor IR. We used this feature to write high performance TVM schedules for integer convolution operators for Intel CPUs.
\noindent \emph{\textbf{ARM Edge Devices}} - In contrast to Intel VNNI, the Raspberry Pi edge devices, based on ARMv8 architecture, do not have hardware support for fast \texttt{int8} dot product instruction. However, ARMv8 ISA has a fast \texttt{int16} multiply-accumulate instruction ($vmlal$) that can perform dot product of 2 16-bit values and accumulate in 32-bit. We observe that LLVM picks up the $vmlal$ instructions for code generation if the input tensors are of \texttt{int16} datatype instead of \texttt{int8}. Therefore, we use QNN Legalize pass to insert the up-casting operations before the QNN conv2d operators for ARMv8-based devices.
\noindent \emph{\textbf{Nvidia GPUs}} - Similar to Intel VNNI, Nvidia has a DP4A instruction to speedup 8-bit integer computation. Recently, Nvidia has also introduced tensor cores to achieve even further speedup. In this work, we leverage the already existing Nvidia DP4A TVM schedule. Note that given TVM abstractions, in future, a developer can just focus on the TVM schedule for convolution using Tensor Cores, and easily replace the DP4A schedule with the new schedule. Writing TVM schedule using Tensor Core is beyond the scope of this paper.
Overall, QNN is designed to augment DL compilers, in our case, Apache TVM, to deploy pre-quantized models efficiently across many hardware devices with low developer effort. In cases where we need extra attention due to specific integer instructions, QNN can still reduce a significant portion of developer's time and effort by reusing the existing TVM infrastructure
\subsection{QNN Canonicalization Pass}
\label{subsec:passes}
Figure~\ref{fig:overview} shows how TVM stack iteratively optimizes the QNN graph after framework parsing is complete. There are two QNN optimization passes - QNN Canonicalize and QNN Legalize. Note that a developer can add more QNN optimization passes if necessary. In this paper, we discuss above two passes which we found sufficient to support a variety of hardware platforms. In this subsection, we discuss QNN Canonicalize. We will discuss QNN Legalize in the next section.
QNN Canonicalize pass converts QNN ops into a sequence of Relay operators using the lowering sequence defined by the developer. Therefore, QNN Canonicalize pass acts as a boundary after which graph-level quantization context is absent, and we reuse existing Relay and tensor-level infrastructure. QNN provides infrastructure where a developer can specify the lowering of a QNN operator to a sequence of Relay operators. This has to be done on an operator-by-operator basis. The difficulty of lowering varies between operators. Here, we show examples of canonicalizing three operators - QNN pooling, QNN conv2d and QNN requantize. The operators are chosen to give a flavor of complexity and share low-level observations and insights about operator designs.
\noindent \textbf{QNN Pooling Operator} - QNN pooling operator canonicalization requires simple lowering. All the framework quantized pooling operators have the same scale and zero point for pooling input and output tensors. This simplifies lowering for quantized pooling as shown below:
\begin{equation}
\begin{split}
B_{fp32} & = AvgPool(A_{fp32}) \\
scale * (Q_B - zp) & = scale * AvgPool(Q_A - zp) \\
Q_B & = AvgPool(Q_A) \\
\end{split}
\end{equation}
\noindent We can skip scale and zero point handling (as they are equal) and just perform average pooling operation. In the pooling operation, we have to be careful about rounding during division and upcast the inputs to \texttt{int16} to avoid overflow/underflow while accumulation.
\noindent \textbf{QNN Convolution Operator} - As mentioned in Section~\ref{subsec:ops}, we only handle convolution of quantized tensors and adjustments due to zero points (no scale handling) in QNN conv2d operator. As shown earlier in Equation~\ref{eq:conv2d_terms}, QNN conv2d operator can be decomposed into four terms. Each term can be represented using Relay operators. Term 1 is simply Relay conv2d over quantized int8 input tensors. Term 2 can be lowered by performing a reduce sum operation on weight tensor across c, r, s dimension. Term 3 performs a sliding window reduction on input data quantized tensor, which can be represented by pool2d, reduce sum and multiplication operator. And term 4 is just a multiplication of constants.
We have to be careful about zero points because \texttt{fp32} number $0.0$ is represented by $zero\_point$ in the quantized tensor (which can also be inferred from Equation~\ref{eq:quant}). Therefore, padding a quantized input tensor in QNN conv2d translates to padding the tensor with $zero\_point$. We also have to take care of reshapes to match tensor shapes or allow broadcasting whenever possible. We further observe that term 2 and term 4 are compile-time constants - term 2 is dependent on the weight tensor, which is constant for DNN inference. Specifically, the final QNN-to-Relay canonicalization is shown in Figure~\ref{fig:qnn_conv2d}.
\begin{figure}
\centering
\includegraphics[width=0.48\textwidth]{./figures/qnn_conv2d.pdf}
\caption{QNN Conv2D canonicalization - QNN Conv2d is lowered across the four terms as described in Equation~\ref{eq:conv2d_terms}. Reshape and cast operators are added to ensure that tensor shapes and data type match while combining the terms. Compile-time constant terms - Term 2 and Term 4 - are subtracted first to perform constant folding.}
\label{fig:qnn_conv2d}
\vspace{-5mm}
\end{figure}
An alternative lowering can be similar to QNN pooling, where we first subtract zero points and then perform conv2d over subtracted tensors as shown in Equation~\ref{eq:conv2d}. However, in this case the tensors have to be upcast to \texttt{int16} before subtracting zero points, causing the final convolution to happen on \texttt{int16} tensors instead of \texttt{int8} tensors. For devices that have fast \texttt{int8} datatype computation support, like Intel VNNI and Nvidia DP4A, this prevents us from using the relevant \texttt{int8} instructions. However for ARMv8 that has a fast \texttt{int16} multiply-accumulate instruction, this lowering gives better performance. QNN Legalize pass, described later, allows this customization for different hardware platforms.
\noindent \textbf{QNN Requantize Operator} - QNN conv2d operator is typically followed by a requantize operator (also shown in Figure~\ref{fig:tflite_conv2d}). Requantize operator changes one quantized tensor representation to another, i.e, we represent the input quantized tensor with new scale and zero point. This can be mathematically written as follows, where $Q_A$ and $Q_B$ are input and output quantized tensors respectively.
\begin{equation}
\begin{split}
scale_B * (Q_B - zp_B) = scale_A * (Q_A - zp_a) \\
Q_B = [(scale_A/scale_B) * (Q_A - zp_a)] + zp_B\\
\end{split}
\label{eq:conv2d_4}
\end{equation}
\noindent Note that scales here are of \texttt{fp32} data type, leading to a floating point multiplication of requantize scale and quantized tensor, which later will have to be converted back to integer data type. This back-and-forth data type conversion can cause severe performance degradation. To solve this problem, we borrow the idea from TFLite requantize operation~\cite{tflite} to use a fixed point multiplication as a proxy for floating point multiplication. An important detail in the implementation is the rounding of fixed point multiplication. Different frameworks choose different rounding methods, which results in minor end-to-end model accuracy differences as shown in the evaluation later.
\subsection{Deploying QNN across Frameworks}
First of all, we evaluate the effectiveness of QNN in achieving a wide framework coverage. Since each framework has its own preferred choice of quantization approach (asymmetric, symmetric, per-channel), we simultaneously evaluate the ability of QNN to represent different quantization approaches. Specifically, we compare the accuracy of pre-quantized models achieved by the frameworks and QNN-augmented TVM stack. We measure the accuracy over 10k images from the Imagenet validation dataset~\cite{imagenet} and show the findings in Table \ref{tab:mxnet}.
\begin{table}
\begin{tabular}{|l|l|l|l|l|}
\hline
\multirow{2}{*}{Quantized Model} & \multicolumn{2}{l|}{Top1 Accuracy (\%)} & \multicolumn{2}{l|}{Top5 Accuracy (\%)} \\ \cline{2-5}
& Baseline & QNN-TVM & Baseline & QNN-TVM \\ \hline
\multicolumn{5}{c}{MXNet Pre-quantized Models}\\ \hline
resnet-18 & 69.76 & 69.86 & 89.02 & 89.05 \\ \hline
resnet-50 & 76.13 & 76.16 & 92.6 & 92.73 \\ \hline
resnet-50-v1b & 76.66 & 76.56 & 92.6 & 92.6 \\ \hline
resnet-101 & 77.13 & 76.97 & 93.06 & 93.09 \\ \hline
resnet-152 & 75.99 & 75.75 & 92.52 & 92.12 \\ \hline
inception-v3 & 77.84 & 77.28 & 93.52 & 93.32 \\ \hline
inception-bn & 71.96 & 71.79 & 90.38 & 90.25 \\ \hline
mobilenet-v1 & 71.27 & 71.13 & 90.09 & 90.16 \\ \hline
mobilenet-v2 & 70.35 & 70.14 & 89.45 & 89.52 \\ \hline
\multicolumn{5}{c}{TFLite Pre-quantized Models}\\ \hline
inception-v1 & 70.1 & 69.6 & 89.8 & 89.5 \\ \hline
inception-v2 & 73.5 & 73.3 & 91.4 & 91.3 \\ \hline
inception-v3 & 77.5 & 77.3 & 93.7 & 93.6 \\ \hline
inception-v4 & 79.5 & 79.6 & 93.90 & 94.2 \\ \hline
mobilenet-v1 & 70.0 & 70.1 & 89.0 & 89.0 \\ \hline
mobilenet-v2 & 70.8 & 70.9 & 89.9 & 90.1 \\ \hline
\multicolumn{5}{c}{PyTorch Pre-quantized Models}\\ \hline
resnet-18 & 69.49 & 69.63 & 88.67 & 88.47 \\ \hline
resnet-50 & 75.88 & 75.84 & 92.64 & 92.67 \\ \hline
inception-v3 & 77.65 & 77.28 & 93.36 & 93.18 \\ \hline
googlenet & 69.59 & 69.37 & 89.34 & 89.28 \\ \hline
mobilenet-v2 & 70.43 & 70.61 & 89.48 & 89.44 \\ \hline
\end{tabular}
\caption{QNN achieves accuracy parity across all the mainstream frameworks -- MXNet, TFLite and PyTorch -- pre-quantized models.}
\label{tab:mxnet}
\end{table}
\begin{comment}
\begin{table}[h]
\begin{tabular}{|l|l|l|l|l|}
\hline
\multirow{2}{*}{Quantized Model} & \multicolumn{2}{l|}{TFLite Accuracy} & \multicolumn{2}{l|}{TVM Accuracy} \\ \cline{2-5}
& Top1 (\%) & Top5 (\%) & Top1 (\%) & Top5 (\%) \\ \hline
inception-v1 & 70.1 & 89.8 & 69.6 & 89.5 \\ \hline
inception-v2 & 73.5 & 91.4 & 73.3 & 91.3 \\ \hline
inception-v3 & 77.5 & 93.7 & 77.3 & 93.6 \\ \hline
inception-v4 & 79.5 & 93.90 & 79.6 & 94.2 \\ \hline
mobilenet-v1 & 70.0 & 89.0 & 70.1 & 89.0 \\ \hline
mobilenet-v2 & 70.8 & 89.9 & 70.9 & 90.1 \\ \hline
\end{tabular}
\caption{QNN achieves accuracy parity on TFLite hosted pre-quantized models. TFLite models are quantized using asymmetric per-tensor quantization scheme.}
\label{tab:tflite}
\end{table}
\begin{table}[h]
\begin{tabular}{|l|l|l|l|l|}
\hline
\multirow{2}{*}{Quantized Model} & \multicolumn{2}{l|}{PyTorch Accuracy} & \multicolumn{2}{l|}{TVM Accuracy} \\ \cline{2-5}
& Top1 (\%) & Top5 (\%) & Top1 (\%) & Top5 (\%) \\ \hline
resnet-18 & 69.49 & 88.67 & 69.63 & 88.47 \\ \hline
resnet-50 & 75.88 & 92.64 & 75.84 & 92.67 \\ \hline
inception-v3 & 77.65 & 93.36 & 77.28 & 93.18 \\ \hline
googlenet & 69.59 & 89.34 & 69.37 & 89.28 \\ \hline
mobilenet-v2 & 70.43 & 89.48 & 70.61 & 89.44 \\ \hline
\end{tabular}
\caption{QNN achieves accuracy parity with MXNet, TFLite and PyTorch pre-quantized models.}
\label{tab:pytorch}
\end{table}
\end{comment}
We observe that QNN achieves accuracy parity for all pre-quantized models across the frameworks with minor differences. As explained in Section~\ref{subsec:passes}, these differences mainly attribute to the rounding operations in fixed point multiplication of the requantize operator. Different frameworks use different rounding methods, leading to small differences in final accuracy.
\subsection{QNN Comparison with Frameworks}
Next, we compare the performance between QNN and frameworks of executing pre-quantized models. As shown in Table~\ref{tab:frameworks}, frameworks do not have efficient pre-quantized model execution support for all hardware platforms. Therefore, we execute all the hosted pre-quantized models for each framework on the hardware platforms it supports, and compare the performance with the same models compiled and executed by QNN-augmented TVM. Therefore, this evaluation compares our work against the best available baseline. We do not show comparison on GPU platforms, because TFLite and PyTorch do not support pre-quantized model execution on GPUs, while MXNet supports but with suboptimal performance~\cite{mxnet_jun}.
\noindent \boldhdr{MXNet Framework} MXNet framework presents the best baseline for Intel CPUs because it relies on Intel DNNL that has hand-written x86 assembly implementations. For example, Intel DNNL uses Intel VNNI instructions to achieve high performance for \texttt{int8} data type convolution or matrix multiplication operators. The performance of executing quantized models on Nvidia GPUs in MXNet framework is under-optimized, and MXNet does not have a backend to generate high performance ARM machine code. Therefore, we can not compare QNN with MXNet on Nvidia and ARM platforms but just focus on Intel CPUs.
Figure~\ref{fig:best_baseline_mxnet} summarizes the end-to-end performance comparison between MXNet and our solution. Overall, we observe QNN-\texttt{int8} achieves 1.09$\times$ speedup against MXNet on Intel Cascade Lake CPU, with a maximum of 1.43$\times$ for inception-bn. We observe slowdown for resnet-50, and resnet-50\_v1b models. We suspect this is because Intel DNNL has customized the optimization for resnet models due to their popularity. However, for other less popular models, we observe significant speedup.
\begin{figure}
\centering
\includegraphics[width=0.48\textwidth]{./figures/best_baseline_mxnet.pdf}
\caption{MXNet vs QNN - QNN achieves an average speedup of 1.09$\times$ against highly hand-tuned Intel DNNL execution of pre-quantized models. The red cross signifies that MXNet does not have good support of running pre-quantized models on ARM and Nvidia devices.}
\label{fig:best_baseline_mxnet}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=0.48\textwidth]{./figures/best_baseline_tflite.pdf}
\caption{TFLite vs QNN - Currently QNN is on average 15\% slower than TFLite for pre-quantized models on ARM devices because of hand-written tuned assembly implementations for operators. The red cross signifies that TFLite does not have good support of running pre-quantized models on Intel and Nvidia devices.}
\label{fig:best_baseline_tflite}
\vspace{-6mm}
\end{figure}
\noindent \boldhdr{TFLite Framework} TFLite framework has been designed to mainly focus on edge devices. TFLite uses hand-tuned implementation for \texttt{int8} operator on ARM devices. However, given its scope, TFLite does not have good performance on Intel CPUs and Nvidia GPUs. For example, we observe that our solution is over 10$\times$ faster on Intel Cascade Lake CPUs against TFLite execution for resnet-50 model. Therefore, we do not show comparison of QNN-augmented TVM with TFLite on Intel and Nvidia devices. In this experiment, we measure the performance of QNN-augmented TVM and TFLite execution for all TFLite pre-quantized models on Raspberry Pi4.
The findings of this experiment are shown in Figure~\ref{fig:best_baseline_tflite}, demonstrating as QNN-augmented TVM speedup against TFLite performance. We observe that TFLite is faster than QNN-augmented TVM for all cases. Overall, QNN-augmented TVM is 14\% (or 1.16$\times$) slower than TFLite on average. This is because of hand-tuned assembly implementations for \texttt{int8} conv2d and depthwise operators in TFLite. With the help of improving \texttt{int8} ARM schedules which is out of scope of this paper, we should be able to close this gap.
\begin{figure}
\centering
\includegraphics[width=0.48\textwidth]{./figures/best_baseline_pytorch.pdf}
\caption{PyTorch vs QNN - QNN achieves $7.85\times$ speedups on Intel Cascade Lake against PyTorch-FBGEMM. PyTorch-QNNPACK does not support multi-threading on Raspberry Pi4. QNN is 20\% slower on average for single thread and 2.95$\times$ faster for four threads execution.}
\label{fig:best_baseline_pytorch}
\vspace{-6mm}
\end{figure}
\noindent \boldhdr{PyTorch Framework} PyTorch relies on hand-written assembly implementations - FBGEMM~\cite{fbgemm} for Intel CPUs and on QNNPACK~\cite{qnnpack} for ARM mobile devices - to achieve high performance for pre-quantized models. PyTorch does not have any support for executing pre-quantized models efficiently on Nvidia GPUs. In this experiment, we measure end-to-end performance of PyTorch and QNN-augmented TVM for all hosted PyTorch pre-quantized models on Intel Cascade Lake CPU and ARM Raspberry Pi4. The findings of this experiment are shown in Figure~\ref{fig:best_baseline_pytorch}, demonstrating speedup of QNN-augmented TVM normalized to PyTorch performance.
We observe that QNN-augmented TVM achieves high speedups across all the models against PyTorch-FBGEMM execution on Intel Cascade lake servers, with up to 12.2$\times$ for resnet-18 and an average of 7.85$\times$. PyTorch community could work on improving these numbers, but in general, it highlights the effectiveness of QNN-augmented TVM in quickly achieving high performance.
We found that PyTorch does not use multiple threads for QNNPACK on non-Android or iOS devices including Raspberry Pi4. Therefore, we show comparison with TVM single thread performance in addition to TVM four threads performance. We observe that, similar to our findings with TFLite, there is room of improvement for better ARM schedules overall. Overall, QNN is 20\% slower in the single-thread apples-to-apples comparison but 2.95$\times$ faster if all four cores are used.
\section{Evaluation}
This section evaluates our proposed QNN solution by answering the following questions:
\begin{enumerate}[leftmargin=*]
\item As a sanity check, is QNN able to compile pre-quantized models to achieve similar model accuracy numbers compared to the framework solutions?
\item What is the performance of QNN-compiled pre-quantized models, in comparison to the original models in \texttt{fp32}?
\item Can QNN get the on-par, if not better, performance on pre-quantized models compared to the framework solutions while covering more hardware platforms than frameworks?
\item How does QNN perform in compiling a newly designed pre-quantized model?
\end{enumerate}
\input{Evaluation/methodology}
\input{Evaluation/accuracy}
\input{Evaluation/performance}
\input{Evaluation/best_baseline}
\input{Evaluation/keyword}
\subsection{QNN Effectiveness on a New Model}
Lastly, we present a scenario where we use QNN to compile and execute a new unseen pre-quantized model. Our new model is an in-house built keyword detection model, which is executed on a resource-constrained edge device, to detect specific keywords or triggers in human speech. Typically, these models are executed very frequently on the device to capture the keywords. Therefore, it is imperative to have both low latency and resource utilization for this model so that we can co-execute other applications on the same device simultaneously.
To reduce the latency, we employed framework quantization to quantize the model and then compiled the model for ARM Cortex A53 (Raspberry Pi3) edge device using QNN-augmented TVM (QNN-\texttt{int8}). For evaluation, our baseline is the \texttt{fp32} model compiled and executed via TVM (TVM-\texttt{fp32}). We observe that, without any extra developer efforts, QNN-\texttt{int8} was 2.0$\times$ and 2.7$\times$ faster than TVM-\texttt{fp32} for single-threaded and multi-threaded execution (4 threads), while achieving 50\% total runtime memory footprint reduction and no accuracy loss. This shows that a QNN-augmented deep learning compiler is effective in rapidly deploying new models on new devices with low developer efforts.
\subsection{Deploying QNN Across Server and Edge Devices}
QNN is designed to enable efficient deployment of pre-quantized models across a variety of hardware platforms with different types of computing capabilities. In this subsection, we evaluate QNN effectiveness in performance speedup and memory footprint reduction, when it is deployed across our server and edge devices.
\begin{figure}
\centering
\includegraphics[width=0.48\textwidth]{./figures/money.pdf}
\caption{QNN on Server - QNN takes advantage of fast \texttt{int8} instructions to achieve significant speedup against TVM \texttt{fp32} tuned baseline for both Intel Cascade lake and Nvidia T4 servers.}
\label{fig:money_server}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=0.48\textwidth]{./figures/money_edge.pdf}
\caption{QNN at edge - QNN enables easy deployment across the edge devices as well. We see performance speedup for both in-order (A53) and out-of-order (A72) ARM cores. The red cross shows that \texttt{fp32} resnet-152 model execution was out of memory, while QNN \texttt{int8} execution succeeded.}
\label{fig:money_edge}
\vspace{-5mm}
\end{figure}
\begin{figure*}
\centering
\includegraphics[width=\textwidth]{./figures/memory.pdf}
\caption{Breakdown of runtime memory footprint across weights and intermediate feature maps. Intermediate feature also play a considerable role in deciding the total memory footprint reduction. For Intel and Nvidia servers, QNN-\texttt{int8} reduces the total memory footprint by 67-74\%. For ARM, we currently upcast weights to \texttt{int16} to use ARM fast $vmlal$ instruction, resulting in 50\% (or 2$\times$) footprint reduction.}
\label{fig:memory}
\vspace{-5mm}
\end{figure*}
\noindent \boldhdr{Performance Improvements} In this experiment, we compile the original MXNet models (in \texttt{fp32}) and their counterpart pre-quantized model (in \texttt{int8}) using QNN-augmented TVM stack. We execute each compiled model for 2000 images (batch size 1) and measure the average end-to-end latency. We also perform auto-tuning~\cite{autotvm} to ensure high performance for both original and pre-quantized models.
We compare the performance of TVM-compiled original models (referred to as TVM-\texttt{fp32}) and QNN-augmented TVM-compiled MXNet pre-quantized models (referred to as QNN-\texttt{int8}). There are two reasons for choosing this baseline. First, no framework can run across all the platforms we are targeting, making TVM-\texttt{fp32} a good baseline. Second, MXNet has the largest number of available pre-quantized models amongst all the frameworks, enabling wider model coverage evaluation. The same observation applies to pre-quantized models of TFLite and PyTorch. We present the results for server-class platforms and edge-devices in Figure \ref{fig:money_server} and Figure \ref{fig:money_edge} respectively. We observe very low standard deviation amongst 2000 runs, and therefore omit the error bars in the barplots.
For servers, we observe significant performance improvements for both Intel Cascade Lake CPU and Nvidia T4 GPU servers as shown in Figure \ref{fig:money_server}. Both processors have support for fast \texttt{int8} dot-product operations - Intel VNNI and Nvidia DP4A instructions. We also observe lower than expected speedup for resnet-152 and mobilenet models. For resnet-152, MXNet decided to keep the batch normalization operator in \texttt{fp32} to retain accuracy, causing frequent data type conversions and hurting performance. For mobilenet models, TVM stack currently lacks good depthwise convolution schedules (kernel implementation) using fast \texttt{int8} instructions. Overall, we observe that QNN-\texttt{int8} achieves an average speedup of 2.35$\times$ and 2.13$\times$ for Intel Cascade Lake CPU and Nvidia T4 GPU respectively compared to TVM-\texttt{fp32}.
Similarly for edge devices, we observe significant speedups as shown in Figure~\ref{fig:money_edge}. In contrast to servers, our edge devices do not have fast \texttt{int8} instructions, leading to lower speedups than observed in servers. However, these devices have fast $int16$ multiply-accumulate instructions ($vmlal$). We observe that LLVM generates highly vectorized and vector register-packed code using $vmlal$ instructions, efficiently utilizing convolution data reuse and achieving better performance than \texttt{fp32} models. Additionally, we observe that TVM-\texttt{fp32} resnet-152 model goes out of memory due to large weight size in Pi3 (shown by cross in the figure). QNN-\texttt{int8} on the other hand, due to smaller memory footprint, can execute the model. Similar to servers, mobilenet models observe sub-optimal performance due to the lack of good TVM schedules for depthwise convolution operator. Overall, QNN-\texttt{int8} achieves an average speedup of 1.35$\times$ and 1.40$\times$ for ARM Raspberry Pi3 and Pi4 respectively compared to TVM-\texttt{fp32}.
Note that, although mobilenet models show lower than expected performance speedup, QNN allows developers to just focus on implementing better TVM schedules for depthwise convolution operator, while reusing the existing TVM infrastructure for both graph- and tensor-level optimizations, enabling rapid deployment with less developer efforts.
\noindent \boldhdr{Memory Footprint Reduction} In this experiment, we evaluate QNN effectiveness in reducing the runtime memory footprint. We compare the total runtime memory footprint for TVM-\texttt{fp32} and QNN-\texttt{int8} models for all the hosted MXNet models across all hardware platforms. We present the findings in Figure~\ref{fig:memory}, showing QNN-\texttt{int8} total memory footprint as a percentage of total TVM-\texttt{fp32} footprint. We also break down total memory footprint into 2 categories - weights (also known as parameters) and intermediate feature maps (also known as activations or intermediate outputs). In contrast to prior works that only show weight memory footprint reduction~\cite{tflite, quant1}, we analyze total memory footprint.
We observe that different models have different memory footprint reduction depending on the contribution of intermediate feature maps to total memory footprint. As opposed to weights that have been pre-quantized to \texttt{int8} and achieve close to 4$\times$ memory footprint reduction, the intermediate features maps that can also be in \texttt{int32} data type, observe less than 4$\times$ memory reduction. For example, mobilenet models have larger contribution of intermediate feature maps, overall reducing the footprint to 33\% (or 3$\times$ footprint reduction).
We also observe that in edge devices, weights of QNN-\texttt{int8} see only 50\% memory footprint reduction (much less than expected 75\% or 4$\times$). This is because we upcast the weights to \texttt{int16} to use ARM fast \texttt{int16} multiply-accumulate $vmlal$ instruction. Note that this overhead is unavoidable. TVM stack runs a constant evaluation pass that converts the \texttt{int8} pre-quantized weights to \texttt{int16} at compile-time. If we disable constant evaluation optimization pass and keep the weights in \texttt{int8}, the tensor with upcast weights in \texttt{int16} datatype will still be the part of total memory footprint, still keeping the total memory footprint same. Therefore, we measure total memory footprint to accurately assess the total memory footprint reduction.
\subsection{Experimental Setup}
\label{sec:methodology}
\noindent \boldhdr{Frameworks} We evaluate QNN across all the available pre-quantized models in TFLite (version 1.13)~\cite{tflite_models}, MXNet (version 1.6)~\cite{mxnet_models} and PyTorch (version 1.4)~\cite{pytorch_models}. We implement QNN on top of open-source Apache TVM (version 0.6)~\cite{tvm}. Note that different frameworks support different sets of pre-quantized models as listed in Table~\ref{tab:frameworks}, while QNN-augmented TVM is able to compile all of them.
\noindent \boldhdr{Server Platforms} We evaluate QNN on two server platforms on Amazon EC2 - Intel 24-core Xeon Cascade Lake CPU equipped at EC2 C5.12xlarge instance and Nvidia T4 GPU at EC2 G4.xlarge instance. Both processors have hardware support for speeding up $int8$ computations - Intel VNNI and Nvidia DP4A instructions. The Nvidia T4 GPU also has recently introduced Tensor Cores. However, for this evaluation we only use DP4A instructions. Using Tensor Cores is an orthogonal effort to this paper (refer to Section~\ref{subsec:schedules}).
\noindent \boldhdr{Edge Devices} We evaluate QNN on two popular edge devices - Raspberry Pi3 (in-order ARM Cortex A53) and Raspberry Pi4 (out-of-order ARM Cortex A72). In contrast to our server platforms, Raspberry Pi devices do not have any fast $int8$ computation instructions. Instead, they have 16-bit multiply-accumulate instructions ($vmlal$) that leads to better data packing in registers.
\section{Conclusion}
In this paper, we offer a universal solution to the challenge of efficiently executing pre-quantized models from a variety of frameworks across a variety of hardware platforms while keeping developer effort low. We note that most deep learning frameworks help developers quantize models but fall short at supporting the efficient execution of models on multiple platforms. This is due to the tight coupling of framework operators and back-end hardware libraries, which hinders the use of quantization. We tackle the problem using the notion of a deep learning compiler enhanced with a new graph-level dialect called Quantized Neural Network (QNN). The QNN dialect provides a quantization context that can augment any existing deep learning compiler (\emph{e.g.} Apache TVM, Glow, XLA). QNN simplifies the effort of efficiently executing pre-quantized models on variety of hardware devices. We observe that our QNN-augmented deep learning compiler achieves speedups of 2.35$\times$, 2.15$\times$, 1.35$\times$ and 1.40$\times$ on Intel Xeon Cascade Lake CPUs, Nvidia Tesla T4 GPUs, ARM Cortex-A CPUs on Raspberry Pi3 and Pi4 respectively relative to \texttt{fp32} execution. QNN also achieves comparable performance against the state-of-the-art framework's solutions for executing pre-quantized models while providing much better coverage of hardware platforms.
\section{Introduction}
\label{sec:intro}
\subsection{Background}
\label{sec:intro:back}
The effectiveness of deep learning in image processing and natural language processing tasks has led to the development of a growing number of applications that run deep learning models on a wide range of systems, from cloud-scale clusters to resource-limited edge-devices~\cite{bert, resnet, fb, tpu}. The widespread use of deep learning frameworks such as Tensorflow~\cite{tf}, PyTorch~\cite{pytorch} and MXNet~\cite{mxnet} drives the applications of deep learning. These frameworks enable model developers to quickly build, train, and deploy models on many hardware platforms. The frameworks provide a set of operators, where each operator represents a mathematical computation, e.g., convolution2D (referred to as conv2d), ReLU (rectified linear unit), batch normalization etc. These operators are typically converted to machine code using a hardware-specific library, e.g., Intel DNNL~\cite{mkl} and Nvidia CuDNN~\cite{cudnn}.
In general, deep learning models require substantial compute and memory resources~\cite{fb, tpu}, which can burden even powerful servers leave alone low-power edge devices. Researchers have implemented various techniques -- algorithms, software, hardware -- to reduce the compute and memory burden~\cite{mobilenet, tpu, tflite} of deep learning models to simplify their development and deployment~\cite{jiang2018efficient,wang2019unified}.
Among these techniques, quantization is a promising and well-studied approach. Quantization represents floating point 32-bit (\texttt{fp32}) numbers, which are used frequently in the deep learning models, with integer 8-bits (\texttt{int8})\cite{tflite, quant1, quant2}, reducing the memory footprint by a factor of four. The most widely-used form of integer quantization is uniform quantization~\cite{tflite}, where an \texttt{fp32} tensor ($A_{fp32}$) is represented with a quantized \texttt{int8} tensor ($Q_A$) along with quantization attributes - scale ($scale_A$) and zero point ($zp_A$) as shown below
\begin{equation}
A_{fp32} = scale_A * (Q_A - zp_A)
\label{eq:quant}
\end{equation}
\noindent Quantization enables a model to consume fewer compute and memory resources while keeping its accuracy close to that of the unquantized model (where the inputs and parameters are represented in \texttt{fp32}). We have observed that \texttt{int8} quantization is most widely used in the real world because (1) prior works have shown that \texttt{int8} representation works well empirically in preserving model accuracy~\cite{tflite, quant1, quant2}; (2) popular hardware platforms like Intel CPUs, Nvidia GPUs, and ARM CPUs are introducing low-level instructions support to perform \texttt{int8} data type computation efficiently.
As a result, deep learning frameworks have of late started to implement uniform \texttt{int8} quantization. Most of these efforts have focused on retaining accuracy~\cite{tflite, quant1, quant2}. For example, instead of scalar scale in Equation 1, we can use per-channel scale to get more fine-grained quantization~\cite{tflite_whitepaper}. Similarly, we can use symmetric or asymmetric quantization based on the value of zero points and choose a suitable performance-accuracy trade-off~\cite{tflite}.
However, there is very little focus on the broad deployment and efficient execution of these framework-quantized models (hereafter referred to as \emph{pre-quantized models}) on a variety of platforms (server and edge). This paper tackles the challenges associated with model inference. Specifically, this paper presents a universally applicable approach to execute pre-quantized models from deep learning frameworks (e.g. TFLite, MXNet, PyTorch) efficiently on a variety of hardware platforms (e.g. Intel CPUs, Nvidia GPUs, ARM CPUs).
\subsection{Quantization in Deep Learning Frameworks}
\label{sec:intro:framework}
Adding support for the execution of pre-quantized models in each deep learning framework is not an efficient use of developer time. First, there are several popular frameworks in widespread use, which means that the same effort must be duplicated across multiple frameworks. Second, a model is trained and quantized in a framework, it can only run in the same framework on the hardware that the framework supports; i.e. an MXNet model quantized on Intel CPUs cannot run in TFLite on ARM CPUs. Third, a framework typically handles quantization by adding new quantized operators, e.g., TFLite has quantized operators such as quantized\_conv2d, quantized\_add. However, adding quantized operators to a framework does not automatically enable the framework to execute pre-quantized models efficiently. There are several obstacles facing a framework.
\begin{itemize}[leftmargin=*]
\item \boldhdr{Lack of Kernel Library Support} Frameworks typically rely on high-performance kernel libraries (e.g. Intel DNNL and Nvidia CuDNN) to process computationally-intensive operators. When a new operator is added to the framework, the kernel libraries integrated with the framework must add corresponding support this new operator. Without that support, the quantized model either cannot run well or cannot run at all.
\item \boldhdr{Per-operator Overhead} Operators in the framework are tightly coupled. The best use of a new operator requires corresponding rules and updates across the framework optimization toolchain. For example, one might want to fuse quantized conv2d with a requantize operator.
\item \boldhdr{Diverse Hardware Platforms} Most critically, the hardware platforms have varying levels of support for quantization. Each platform often has specific requirements for these new operators, e.g., Intel CPUs with x86 architecture prefer the input data types of the quantized conv2d to be $uint8 \times int8$ due to the Intel Vector Neural Network Instructions (VNNI) requirement~\cite{vnni}. Similarly, CPUs in ARMv8 architecture have special instructions to accelerate the \texttt{int16} multiply-accumulate, while ARMv8.2 CPUs introduce DOT instruction to directly speed up \texttt{int8} multiply-accumulate~\cite{dot}. These requirements percolate up to the framework operators, making it difficult for a framework to support many hardware platforms evenly.
\end{itemize}
\noindent In a nutshell, the quantization mechanism in deep learning frameworks ensures the accuracy of quantized models but is insufficient to ensure their efficiency on a variety of hardware platforms. The lack of a framework-agnostic toolchain capable of executing pre-quantized models on a variety of hardware platforms limits their deployment at scale.
\subsection{Quantization in Deep Learning Compilers}
\label{sec:intro:dlc}
The emergence of deep learning compilers (hereafter referred to as DL compilers) such as Apache TVM~\cite{tvm}, Facebook Glow~\cite{glow} and Google XLA\cite{xla}, has re-framed the challenge of deploying deep learning models on various hardware platforms. A DL compiler typically converts a model expressed in a framework-specific representation into a common intermediate representation (IR). The DL compiler then successively lowers the graph from the graph-level to the tensor-level. In the graph-level IR, the compiler optimizes the computation graph of the model. In the tensor-level IR, it optimizes the loop structure of tensor operators, which represent the vertices of the computation graph. After successive optimizations, the DL compiler eventually lowers the model to the machine code of a hardware platform using established low-level code generation modules such as LLVM and NVCC. Therefore, compared to deep learning frameworks, deep learning compilers are more effective at handling the multiplicity of front-ends (frameworks) and back-ends (hardware platforms), thereby simplifying the deployment of deep learning models~\cite{tvm,liu2019optimizing}.
However, current work on DL compilers is based mostly on the \texttt{fp32} data type. Although some compilers support the generation and optimization of quantized operators~\cite{cowan2020automatic,glow}, none have focused on compiling and executing pre-quantized models. If a quantized operator is added naively to a deep learning compiler, the new operator must be added across all the IRs. In the graph-level, we need new rules for these new operators. In the tensor-level, we need new computations and possibly new kernel implementations for each platform. The effort could be mitigated somewhat by the overlap between \texttt{fp32} and quantized operator kernel implementation. Nevertheless, the naive approach to adding quantized operators to the compiler would severely limit the pace at which quantization could be applied to deep learning models.
\subsection{Quantized Neural Network Dialect}
This paper proposes \emph{QNN} (Quantized Neural Network) as a graph-level IR dialect that can augment any deep learning compiler. This approach offers an end-to-end solution to read a pre-quantized model and run it across a variety of hardware platforms while reusing most of the existing DL compiler infrastructure. QNN dialect acts as a slightly higher-level IR on top of graph-level IR, specifically designed for handling quantized networks. We add new operators in QNN dialect, but we do not define any graph- or tensor-level optimizations for them. Instead, these operators are lowered to a sequence of DL compiler's existing operators, which already have well-defined graph- and tensor-level optimizations. QNN operators represent quantization constructs at a higher level than the DL compiler's graph-level IR, making QNN a quantization-aware IR.
QNN dialect, therefore, enables reuse of almost all of the existing infrastructure, allowing us to quickly add new hardware platforms, and to focus on kernel implementation of only those operators that are affected significantly by the integer operations (like using VNNI instructions for Intel x86). Additionally, we can define new QNN dialect optimization passes to transform the graph to suit a particular hardware platform, e.g., adding a QNN requantize operator before QNN conv2d to satisfy Intel VNNI \texttt{uint8 x int8} data type requirements. By reusing existing DL compiler infrastructure, QNN dialect reduces the developer efforts needed to efficiently execute pre-quantized models on many hardware platforms. We implemented QNN dialect on top of the open-source deep learning compiler Apache TVM\footnote{https://tvm.apache.org/}.
Specifically, the contributions of this paper are
\begin{itemize}[leftmargin=*]
\item \boldhdr{QNN Dialect} QNN dialect, a graph-level IR dialect designed to complement deep learning compilers, enables the efficient execution of pre-quantized models on a variety of hardware platforms without cumbersome manual efforts.
\item \boldhdr{Quantization-aware Graph Optimizations} We augment QNN with quantization-aware graph level optimization mechanisms, enabling the graph to meet the requirements imposed by different instruction sets (like $uint8$ x $int8$ for Intel VNNI).
\item \boldhdr{Comprehensive Real System Evaluation} We demonstrate that using QNN along with the corresponding graph optimizations, we can compile pre-quantized models from TFLite, MXNet and PyTorch on Intel CPUs, Nvidia GPUs and ARM CPUs equipped on both servers and edge devices and achieve state-of-the-art performance.
\end{itemize}
Experiments show that, with the assistance of QNN, a deep learning compiler, specifically Apache TVM, is able to take pre-quantized models defined in TFLite, MXNet and PyTorch, and execute them efficiently on different hardware platforms, with an average speedup of 2.35$\times$, 2.15$\times$ on Intel Xeon Cascade Lake and Nvidia T4 servers, and 1.35$\times$ and 1.40$\times$ on ARM Raspberry Pi3 and Pi4 edge devices, compared to tuned TVM \texttt{fp32} baseline. Generalizability aside, QNN achieves performance comparable to the best state-of-the-art solutions provided by the deep learning frameworks, while also providing better hardware platform coverage than the frameworks. To the best of our knowledge, this is the first unified effort to enable DL compilers for a comprehensive quantized deep learning models support. We have open sourced the QNN work\footnote{https://tvm.apache.org/docs/tutorials/frontend/deploy\_prequantized.html}, which is also used in production.
\begin{comment}
The rest of the paper is organized as follows. \yida{Save this part to the last}
\end{comment}
\section{Problem Setting}
\label{sec:setting}
\subsection{Challenges}
\label{sec:setting:challenges}
Quantization is an essential technique for reducing the compute and memory demand on hardware by replacing the compute data type from \texttt{fp32} to lower-bit integers such as \texttt{int8}. There is an acute need for a software mechanism that can enable developers to take advantage of quantization \emph{easily and rapidly with as little developer effort as possible}. However, building such a mechanism requires that we overcome three major challenges:
\noindent \boldhdr{Multiple Frameworks} Developers build neural networks in the framework with which they are most comfortable. In practice today, developers in academia and industry use a variety of frameworks to produce pre-quantized models. Therefore, a good solution must be able to handle models from multiple frameworks.
\noindent \boldhdr{Multiple Quantization Approaches} In Section~\ref{sec:intro:back} we briefly discussed various quantization approaches (e.g. symmetric, asymmetric, per-channel, etc.) that developers can choose according to the needs of their application. A good solution must be expressive enough to represent different types of quantization approaches.
\noindent \boldhdr{Multiple Hardware Platforms} Finally, a good solution must be able to run pre-quantized models on a variety of devices across a wide range of compute capabilities. Wherever available, the solution must provide the ability to use fast integer instructions such as Intel VNNI or Nvidia DP4A instructions.
Currently, developers extend the functionality of deep learning frameworks to process quantized models. In Section~\ref{sec:intro:framework}, we argued that frameworks have tight coupling of operators and back-end hardware libraries. This leads to operators that are atomic, i.e., they are not decomposable, making it difficult to efficiently execute them on many platforms. We further substantiate this in Table~\ref{tab:frameworks} showing that frameworks have either limited quantization support or limited hardware support. Therefore, existing deep learning frameworks do not present a good solution to tackle all three challenges.
\begin{table}
\begin{tabular}{lllll}
\hline
\multicolumn{1}{|l|}{Quantization Approaches} &
\multicolumn{1}{l|}{TFLite} &
\multicolumn{1}{l|}{MXNet} &
\multicolumn{1}{l|}{PyTorch} &
\multicolumn{1}{l|}{QNN} \\ \hline
\multicolumn{1}{|l|}{Asymmetric Quantization} &
\multicolumn{1}{l|}{\cmark} &
\multicolumn{1}{l|}{} &
\multicolumn{1}{l|}{\cmark} &
\multicolumn{1}{l|}{\cmark} \\ \hline
\multicolumn{1}{|l|}{Symmetric Quantization} &
\multicolumn{1}{l|}{\cmark} &
\multicolumn{1}{l|}{\cmark} &
\multicolumn{1}{l|}{\cmark} &
\multicolumn{1}{l|}{\cmark} \\ \hline
\multicolumn{1}{|l|}{Per-channel Quantization} &
\multicolumn{1}{l|}{\cmark} &
\multicolumn{1}{l|}{\cmark} &
\multicolumn{1}{l|}{\cmark} &
\multicolumn{1}{l|}{\cmark} \\ \hline
&
&
&
&
\\ \hline
\multicolumn{1}{|l|}{Hardware Platforms} &
\multicolumn{1}{l|}{TFLite} &
\multicolumn{1}{l|}{MXNet} &
\multicolumn{1}{l|}{PyTorch} &
\multicolumn{1}{l|}{QNN} \\ \hline
\multicolumn{1}{|l|}{Nvidia GPU} &
\multicolumn{1}{l|}{} &
\multicolumn{1}{l|}{{\cmark}} &
\multicolumn{1}{l|}{} &
\multicolumn{1}{l|}{\cmark} \\ \hline
\multicolumn{1}{|l|}{Intel CPU} &
\multicolumn{1}{l|}{} &
\multicolumn{1}{l|}{\cmark} &
\multicolumn{1}{l|}{\cmark} &
\multicolumn{1}{l|}{\cmark} \\ \hline
\multicolumn{1}{|l|}{ARM CPU} &
\multicolumn{1}{l|}{\cmark} &
\multicolumn{1}{l|}{} &
\multicolumn{1}{l|}{\cmark} &
\multicolumn{1}{l|}{\cmark} \\ \hline
\end{tabular}
\caption{Frameworks have different degrees of support for uniform $int8$ quantization. More importantly, they do not support all available hardware platforms with good performance. Our solution is designed to eliminate the complexity and effort of supporting all quantization approaches across a variety of hardware platforms with good performance.}
\label{tab:frameworks}
\vspace{-5mm}
\end{table}
\subsection{Observations}
While the state-of-the-art framework-based approaches fail to tackle the challenges of executing pre-quantized models efficiently, the emerging crop of deep learning compilers is promising. DL compilers typically have a framework-agnostic graph-level intermediate representation (IR). We can convert a model from any framework to this IR, solving the first challenge of framework multiplicity. We can also use different types of quantization approaches in a DL compiler, which addresses the second challenge. Finally, DL compilers rely on established code generators like LLVM and NVCC to cover a broad range of hardware platforms, solving the third challenge.
However, an ideal solution must address all these challenges without burdening the developer with extra effort. Because DL compilers were originally designed to compile models in \texttt{fp32} data type, they don't support quantized operators and the corresponding optimizations. As mentioned in Section~\ref{sec:intro:dlc}, simply adding new quantized operators requires a lot of effort across both graph- and tensor-level IRs. This again severely limits how rapidly we can deploy quantized models on to various hardware platforms.
In solving this problem, our key observation is that the computation of a quantized operator can be easily represented as a sequence of simpler operators (in contrast to frameworks where the quantized operators are atomic and cannot be decomposed). We illustrate this with an example of a quantized conv2d operator below, in which $\circ$ denotes a convolution computation.
\begin{equation}
\begin{split}
C_{fp32} & = A_{fp32} \circ B_{fp32} \\
& = [scale_A * (Q_A- zp_A)] \circ [scale_B * (Q_B - zp_B)] \\
& = scale_A* scale_B * Q_C
\end{split}
\label{eq:conv2d}
\end{equation}
\noindent In Equation~\ref{eq:conv2d}, $A_{fp32}$, $B_{fp32}$ are input tensors and $C_{fp32}$ is the conv2d output tensor, all in \texttt{fp32} data type. We first replace the \texttt{fp32} tensors with quantized tensors using Equation~\ref{eq:quant} and then expand the computation. Further, we observe in Equation~\ref{eq:conv2d_terms} that quantized conv2d can be further broken down into four terms. Here, $k$, $c$, $r$ and $s$ represent output channels, input channels, filter height, and filter width respectively, and $n$, $h$, $w$ represent batch size, output height, and output width respectively. We will show the exact sequence of operations in Section \ref{subsec:passes}.
\begin{equation}
\begin{split}
Q_C(n, k, h, w) & = \sum_{c, r, s} Q_A(n, c, h + r, w + s) * Q_B(k, c, r, s)\\
& - \sum_{c, r, s} zp_A * Q_B(k, c, r, s) \\
& - \sum_{c, r, s} zp_B * Q_A(n, c, h + r, w + s) \\
& + \sum_{c, r, s} zp_A * zp_B
\end{split}
\label{eq:conv2d_terms}
\end{equation}
We observe that all the quantized operators can be easily decomposed to simpler, existing operators. In contrast, frameworks have a tight coupling between operators and back-end libraries that prevents such decomposition. Although the decomposition of quantized operators increases the size of the computation graph initially, \emph{we can now reuse the graph- and tensor-level optimizations that the DL compilers provide for models in \texttt{fp32} data type}. For example, we can reuse the graph fusion optimization pass to find and fuse a sequence of operators because we already have the fusion rules for existing operators. Similarly at the tensor-level, we can reuse optimized kernel implementations for many simple operators like integer addition or multiplication, and rely on code generators like LLVM/NVCC, significantly reducing developer effort.
The little effort that developers do spend can be focused on the operators that need attention due to the \texttt{int8} data type. For example, for Intel CPUs, a developer can focus on writing graph-level optimizations to satisfy its $uint8 \times int8$ data type requirement and write kernel implementations using Intel VNNI instructions for quantized conv2d operator. Similarly, for ARMv8, one can focus only on graph- and tensor-level optimizations to use the fast \texttt{int16} multiply-accumulate instructions. The rest of the graph- and tensor-level optimizations can be left to the DL compiler infrastructure.
Based on these observations, our solution is the Quantized Neural Networks (QNN), a graph-level dialect with quantization context that simplifies the efficient execution of pre-quantized models on a variety of hardware platforms as shown in Table~\ref{tab:frameworks}. The QNN dialect enables developers to define a quantized operator simply as a sequence of existing DL compiler operators. Additionally, it allows graph-level optimizations with quantization context to help satisfy the data type requirements imposed by the instruction sets. Therefore, augmented by QNN, DL compilers can make use of quantization across multiple hardware platforms.
\section{Related Work}
\noindent \boldhdr{8-bit Integer Quantization} 8-bit integer quantization is the most widely adopted quantization technique because of prevalence of \texttt{int8} data type computation support in the commodity hardware platforms. 8-bit integer quantization has also been shown to retain model accuracy with relatively less efforts compared to more aggressive quantization. TFLite 8-bit integer quantization, designed primarily for ARM-based edge devices, was one of the first large-scale effort and set the industry standard for integer quantization~\cite{Jacob_2018_CVPR}. There is a large body of prior work to retain model accuracy for quantization, which can be broken into two categories - Post-training quantization and Quantization-aware training~\cite{mxnet-mkl, nvidia-talk, tflite}. Post-training quantization starts from an already trained \texttt{fp32} model and uses calibration on a cross-validation dataset to find suitable quantization parameters~\cite{mxnet-mkl,nvidia-talk}. Research has shown that post-training quantization achieves good accuracy for 8-bit quantization. More aggressive quantization requires quantization-aware training. Our approach can leverage all of these research to get a pre-quantized model, and eases its deployment on many hardware platforms.
\begin{comment}
\noindent \boldhdr{Low-bit Quantization}\yida{Remove this paragraph if we run out of space.} There is a large body of prior work to perform more aggressive integer quantization, restricting the data type length to lower than 8-bits (even 1 or 2 bits)~\cite{binaryconnect, xnornet, ternary, DBLP:journals/corr/HanMD15, DBLP:journals/corr/LengLZJ17, DBLP:journals/corr/MellempudiKM0KD17, DBLP:journals/corr/ZhouYGXC17, DBLP:journals/corr/ZhouNZWWZ16, DBLP:journals/corr/ZhuHMD16}. Typically, these networks require quantization-aware training to gain some of the accuracy lost because of very low precision. However, we found that these pre-quantized models are not able to achieve performance improvements on commodity hardware because of lack of good support for lower than 8-bit computation. Additionally, these models sometimes observe large accuracy loss, making them unsuitable for user-facing applications. However, recently Nvidia GPUs added support for high-performance \texttt{int4} computation in Tensor Core, making the lower-bit quantization practical from hardware support standpoint. Our proposed QNN is able to support \texttt{int4} quantization as long as the corresponding high-performance compute kernels are ready. All the other parts are reusable as per our design.
\end{comment}
\noindent \boldhdr{Deep Learning Frameworks} Deep learning frameworks, like Tensorflow, PyTorch and MXNet, have been at the forefront of deep learning revolution. These frameworks rely on pre-built backend hardware libraries for high-performance machine code - Intel DNNL~\cite{dnnl}, Nvidia CuDNN~\cite{cudnn} and ARM ACL~\cite{acl}. These backend libraries have hand-optimized kernel implementations to achieve high performance on different platforms. Most of these frameworks use \texttt{int8} quantization to support lightweight model inference on commodity hardware. A user also has a choice of using symmetric, asymmetric or per-channel quantization approaches to find a suitable performance-accuracy tradeoff. However, as shown in Table~\ref{tab:frameworks}, frameworks are not well suited to deploy the models across many hardware platforms. QNN dialect is designed to leverage the extensive work done by the frameworks in quantizing the models and retaining accuracy, and solve the challenges to ease the deployment of pre-quantized models on many platforms with low developer efforts.
\noindent \boldhdr{Deep Learning Compilers} Deep learning compilers have gained popularity in past few years to design a flexible approach for optimizing and deploying deep learning models. Some of the DL compilers support optimization and code generation for multiple hardware platforms - Apache TVM~\cite{tvm}, Glow~\cite{glow} and XLA~\cite{xla}. On the other hand, there are compilers focusing on only one class of hardware platforms - Intel nGraph~\cite{ngraph}, ARM NN~\cite{armnn} and Nvidia TensorRT~\cite{nvidia, cudnn}. There has also been recent efforts in improving the compiler design for supporting deep learning hardware accelerators, for example, in Apache TVM~\cite{tvm}, Glow~\cite{glow}, PlaidML~\cite{plaidml} with stripe IR~\cite{stripe} and MLIR~\cite{mlir}. Quantization support in deep learning compilers has picked up pace very recently and therefore good support is limited to the compilers focusing on a single class of hardware platform - nGraph, TensorRT and ARM NN. This limitation prevents us from rapidly deploying models on many platforms with single unified toolchain. Our work on the QNN dialect is designed to complement the existing DL compilers to solve this challenge. We observe that QNN-augmented DL compiler compiles pre-quantized models from multiple frameworks, supports different types of quantization approaches and enables deployment on many hardware platforms with low developer efforts.
| {'timestamp': '2020-06-19T02:07:11', 'yymm': '2006', 'arxiv_id': '2006.10226', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10226'} | arxiv |
\section{In Model}
Under the independence assumption for each bond and the conditional independence for each atom given the bonds, the probability of sampling a molecule $M$ from $\mathcal{M}$ is:
\begin{equation}
\begin{aligned}
P_{\mathcal{M}}(M) &= P_{\mathcal{B}}(B) P_{\mathcal{A|B}}(A|B) \\
&=\prod_{l=1}^{c} \prod_{i<j}^{n\times n} P_{\theta_\mathcal{B}}(l, i, j)^{B(l,i,j)} \prod_{i=1}^{n} \prod_{r=1}^{k} P_{\theta_\mathcal{A|B}}(i, r | B)^{A(i,r)}
\end{aligned}
\end{equation}
where $P_{\theta_\mathcal{B}}(l, i, j)$ represents the probability of the bond between atom $i$ and $j$ being type $l$ and $P_{\theta_\mathcal{A|B}}(i, r | B)$ is the conditional probability of the atom $i$ being type $r$ given the bonds $B$. The $\theta_\mathcal{B}$ and $\theta_\mathcal{A|B}$ are learnable modelling parameters.
\section{Experiments}
\label{sec:app:exp}
We validate our Theorem~\ref{theorem:main} and the Corollary~\ref{corollary:main} together with parameter inference and simulation algorithms on both synthetic and real-world datasets by answering the following questions:
\begin{compactitem}
\item Can the dynamical systems generate cross-sectional distributions predicted by our theorem?
\item Can we learn the parameters of the generated distributions?
\item Can we recover the generative dynamics from its cross-sectional distributions?
\item What are the plausible generative dynamics of a wide range of real-world datasets?
\end{compactitem}
Moreover, to the best of our knowledge, there is no such a theorem serving as our baselines which describies the relationships between a dynamical system and the distribution of its cross-sectional states.
\subsection{Synthetic data}
\begin{table}[!htb]
\footnotesize
\centering
\caption{Experiment Configurations. Generative dynamics and their cross-sectionally generated distributions.}
\begin{tabular}{l c c c c }
\toprule
& \makecell{ \textbf{Dynamics}\\ $ \frac{d x_i(t)}{dt}|_{x_0} $ } & \makecell{\textbf{PDF} \\$ f(x)$}&\textbf{\makecell{Parameters}} \\
\midrule
Exponential & $\frac{1}{\beta t} $& $\beta e^{\beta x}$ & $\beta = 0.01$\\
Power Law & $ \frac{x_i(t) + \Delta}{\alpha t}$ & $\alpha \Delta^\alpha x^{-(\alpha+1)}$ &\makecell{ $\alpha = 1.5$ \\ $\Delta=1$}\\
\bottomrule
\end{tabular}
\label{tab:syn_exp}
\end{table}
\mytag{Experiment setup.} Table~\ref{tab:syn_exp} lists the ground-truth setting with three differential equations to capture three different underlying generative dynamics, whose cross-sectional distribution follows exponential distribution (narrow-tailed), power-law distribution (heavy-tailed), and heavy-tailed mixture distribution respectively predicted by the Theorem~\ref{theorem:main}. For each dynamical system, we set $E[N(t|\lambda_t)] = 10^6$ agents in the time interval $(0, 10^6]$, namely $\mathscr{P}(t | \lambda_p) = \{t_1, ..., t_i, ...| 0 < t_1 \le...\le t_i \le ..\le t \}$ where $t = 10^6$ and $ \lambda_t=1$. The $10^6$ agents change their states according to dynamics $ \frac{d x_i(t)}{dt}|_{x_0=0}$ as shown in Table~\ref{tab:syn_exp} and we observe their cross-sectional states at time $t = 10^6$.
\mytag{Results.} The dynamics indeed generate cross-sectional observations with predicted distributions by the Theorem~\ref{theorem:main}.
As shown in Fig.~\ref{fig:syn_exp} a-c, the distribution of generated states (purple dots) fits the ground truth distribution (red lines) exactly for all the model configurations, ranging from narrow-tailed distribution (Fig.~\ref{fig:syn_exp1}), fat-tailed distribution(Fig.~\ref{fig:syn_exp2}), to mixture of fat-tailed distributions (Fig.~\ref{fig:syn_exp3}).
\subsection{Empirical data}
We examine a wide range of real-world dataset...
Notations in probability theory, survival analysis, point process \cite{aalen2008survival} and dynamical systems /differential equations \cite{barabasi2016network} are used:
\begin{itemize}
\item {\it Probability theory:}
Let $X$ be a random variable generated from a cumulative distribution function $F(X \le x) = \int^x_{x_0}f(s) ds = 1 - S(X > x)$, and we observe $n$ data samples $x_1$, ..., $x_n$. Here we assume the $F(X)$ is absolutely continuous.
The $f(x)$ and $S(x) = 1 - F(x)$ are the probability density function and the survival function (or complementary cumulative distribution function) of the $X$ respectively.
\item {\it Survival analysis:}
The hazard function $\lambda(x)$ of the $X$ is defined as:
\begin{equation}
\footnotesize
\label{equ:hazard}
\lambda(x) = \lim_{\Delta x \to 0^+} \frac{Pr(x \le X < x + \Delta x | X \ge x)}{\Delta x} = \frac{f(x)}{S(x)} \ ,
\end{equation} interpreted as the the probability of $X$ sampled with value $x^+$ conditional on $X$ not being sampled with value smaller than $x$.
We define $\Lambda(x) = \int^x_{x_0}\lambda(s) ds$ as the cumulative hazard function. Due to the fact that $\Lambda(x)$ is monotonically increasing, thus $\Lambda(x)$ is invertable and we define $\Lambda^{-1} : \mathscr{R^+} \to \mathscr{R} $, $ \Lambda^{-1}(\Lambda(x)) = x$. Similarly, we can define $F^{-1} : \mathscr{R^+} \to \mathscr{R} $, $ F^{-1}(F(x)) = x$.
\item {\it Point process:}
We use $\mathscr{P}(t | \lambda_p) = \{t_1, ..., t_i, ...| 0 < t_1 \le...\le t_i \le ..\le t \}$ to denote a Poisson point process until time $t$ with the occurrence time $t_i$ of event $i$, and intensity rate $\lambda_p > 0$.
\end{itemize}
\subsection{Proposed Theorem and Corollary}
Our main theorem gives the generative dynamics of an arbitrary distribution function $F(x)$ as follows:
\begin{theorem}\label{theorem:main}
Given a dynamical system $\mathscr{D}(t) = \{x_i(t) > 0| \frac{d x_i(t)}{dt}, \\ x_i{(t_i)} = x_0; i = 1, 2, ... \}$ consisting of agent $i$ who arrives in the system at time $t_i$ according to a Poisson process $\mathscr{P}(t | \lambda_p) = \{t_1, ..., t_i,....| 0 < t_1 \le...\le t_i \le ... \le t \}$ , the state of agent $i$ changes according to a differential equation $\frac{d x_i(t)}{dt}|_{x_0}$ with initial value $x_0$, and the cross-sectional states of $\mathscr{D}(t)$ at time point $t$, namely $ x(t) = \{x_1(t ), ..., x_i(t),... \}$, follows the distribution $F(x(t))$ if and only if $\ \frac{d x_i(t)}{dt}|_{x_0} = \frac{d F^{-1}(1-\frac{t_i}{t})}{dt}$.
\end{theorem}
\subsection{Proof}
\label{sec:app:si_proof}
\begin{lemma}\label{lemma:poisson} \cite{daley2003introduction}
Given a Poisson process $\mathscr{P}(t | \lambda_p) = \{t_1, ..., t_i, ...| 0< t_1 \le...\le t_i \le ..\le t \}$ with $N(t|\lambda_t) = n$, then the probability density function of a random event time $t_i$ given the total time $t$ is $f(t_i) = \frac{1}{t}$, indicating a uniform distribution on $(0, t]$.
\end{lemma}
\begin{proof}
The joint probability density function of random variables $t_i, i = 1, ..., n $ is:
\begin{equation}
\footnotesize
\begin{aligned}
\label{equ:poissonuni}
&Pr(t_i < T_i \le t_i + \delta_i, i = 1, ..., n | N(t) = n) = \\
&\left[\dfrac{\splitdfrac{Pr(N(t_i + \delta_i) - N(t_i) = 1, N(t_{j+1}) - N(t_{j} + \delta_{j}) = 0,
}{i = 1,...,n, j = 0, ...,n, t_0 = 0, \delta_0 = 0) }}
{Pr( N(t) = n)}\right]\\
&= \frac{\prod_{i = 1}^{n} \lambda_p \delta_i e^{-\lambda_p \delta_i} e^{-\lambda_p (t-\sum_{i=1}^{n}\delta_i)}}{e^{-\lambda_p t }(\lambda_p t)^n / n!} = \frac{n!}{t^n} \prod_{i = 1}^{n} \delta_i,
\end{aligned}
\end{equation}
and thus:
\begin{equation}
\footnotesize
\begin{aligned}
\label{equ:poissonuni}
&f(t_i, i = 1, ..., n | N(t) = n) \\
&= \lim _{t_i \to 0, i = 1,...,n} \frac{Pr(t_i < T_i \le t_i + \delta_i, i = 1, ..., n | N(t) = n) }{\prod_{i = 1}^{n} \delta_i} \\
&= \frac{n!}{t^n}, \\
\end{aligned}
\end{equation} where $0 < t_1 \le ...\le ti \le ... \le t$. For the order statistics $t_i, i = 1, ..., n$, $f(t_i) = \frac{1}{t}$.
\end{proof}
\begin{table*}[!htb]
\centering
\caption{Generative performance on QM9}
\begin{tabular}{l c c c c c c c}
\toprule
& \textbf{\% Validity} & \textbf{\% Novelty} & \textbf{\% Uniqueness} & \textbf{\% Reconstruct} & \textbf{\% N.U.V.} & \textbf{\% Uniqueness2} \\
\midrule
\textbf{MoFlow} & $96.04\pm0.45$ & $98.39\pm0.24$ & $98.42\pm0.29$ &$100$ & $93.00\pm0.43$& $94.52\pm0.49$\\
\textbf{GraphNVP} & $83.1\pm0.5$ & $58.2\pm1.9$ & $99.2\pm0.3$ &$100$ & $47.97$& $82.43$\\
\bottomrule
\end{tabular}
\label{tab:app:qm9}
\end{table*}
\section{Introduction}
\label{sec:intro}
Drug discovery aims at finding candidate molecules with desired chemical properties for clinical trials, which is a long (10-20 years) and costly (\$0.5-\$2.6 billion) process with a high failure rate \cite{paul2010improve,avorn20152}. Recently, deep graph generative models have demonstrated their big potential to accelerate the drug discovery process by exploring large chemical space in a data-driven manner \cite{jin2018junction,zhavoronkov2019deep}. These models usually first learn a continuous latent space by encoding\footnote{In this paper, we use inference, embedding or encoding interchangeably to refer to the transformation from molecular graphs to the learned latent space, and we use decoding or generation for the reverse transformation.} the training molecular graphs and then generate novel and optimized ones through decoding from the learned latent space guided by targeted properties \cite{gomez2018automatic,jin2018junction}.
However, it is still very challenging to generate novel and chemically-valid molecular graphs with desired properties since: a) the scale of the chemical space of drug-like compounds is $10^{60}$ \cite{mullard2017drug} but the scale of possibly generated molecular graphs by existing methods are much smaller, and
b) generating molecular graphs that have both multi-type nodes and edges and follow bond-valence constraints
is a hard combinatorial task.
Prior works leverage different deep generative frameworks for generating molecular SMILES codes \cite{weininger1989smiles} or molecular graphs, including variational autoencoder (VAE)-based models \cite{kusner2017grammar,dai2018syntax,simonovsky2018graphvae,ma2018constrained,liu2018constrained,bresson2019two,jin2018junction}, generative adversarial networks (GAN)-based models \cite{de2018molgan,you2018graph}, and autoregressive (AR)-based models \cite{popova2019molecularrnn,you2018graph}.
In this paper, we explore a different deep generative framework, namely the normalizing flow \cite{dinh2014nice,madhawa2019graphnvp,kingma2018glow} to generate molecular graphs. Compared with above three frameworks, the flow-based models are the only one which can memorize and exactly reconstruct all the input data, and at the same time have the potential to generate more novel, unique and valid molecules, which implies its potential capability of deeper exploration of the huge chemical space. To our best knowledge, there have been three flow-based models proposed for molecular graph generation. The GraphAF \cite{shi2020graphaf} model is an autoregressive flow-based model that achieves state-of-the-art performance in molecular graph generation. GraphAF generates molecules in a sequential manner by adding each new atom or bond followed by a validity check. GraphNVP \cite{madhawa2019graphnvp} and GRF \cite{honda2019graph} are proposed for molecular graph generation in a one-shot manner. However, they cannot guarantee chemical validity and thus show poor performance in generating valid and novel molecules.
In this paper, we propose a novel deep graph generative model named MoFlow\ to generate molecular graphs. Our MoFlow\ is the first of its kind which not only generates molecular graphs efficiently by invertible mapping at one shot, but also has a chemical validity guarantee. More specifically, to capture the combinatorial atom-and-bond structures of molecular graphs, we propose a variant of the Glow model \cite{kingma2018glow} to generate bonds (multi-type edges, e.g., single, double and triple bonds), a novel \textit{graph conditional flow} to generate atoms (multi-type nodes, e.g. C, N etc.) given bonds
by leveraging graph convolutions, and finally assemble atoms and bonds into a valid molecular graph which follows bond-valence constraints.
We illustrate our modelling framework in Figure~\ref{fig:model}. Our MoFlow\ is trained by exact and tractable likelihood estimation, and one-pass inference and generation can be efficiently utilized for molecular graph optimization.
We validate our MoFlow\ through a wide range of experiments from molecular graph generation, reconstruction, visualization to optimization. As baselines, we compare the state-of-the-art VAE-based model \cite{jin2018junction}, autoregressive-based models \cite{you2018graph,popova2019molecularrnn}, and all three flow-based models \cite{madhawa2019graphnvp,honda2019graph, shi2020graphaf}.
As for memorizing input data, MoFlow\ achieves $100\%$ reconstruction rate. As for exploring the unknown chemical space, MoFlow\ outperforms above models by generating more novel, unique and valid molecules (as demonstrated by the N.U.V. scores in Table~\ref{tab:qm9} and~\ref{tab:zinc}). MoFlow\ generates $100\%$ chemically-valid molecules when sampling from prior distributions. Furthermore, if without validity correction, MoFlow\ still generates much more valid molecules than existing models (validity-without-check scores in Table~\ref{tab:qm9} and~\ref{tab:zinc}). For example, the state-of-the-art autoregressive-flow-based model GraphAF \cite{shi2020graphaf} achieves $67\%$ and $68\%$ validity-without-check scores for two datasets while MoFlow\ achieves $96\%$ and $82\%$ respectively, thanks to its capability of capturing the chemical structures in a holistic way.
As for chemical property optimization, MoFlow\ can find much more novel molecules with top drug-likeness scores than existing models (Table~\ref{tab:topqed} and Figure~\ref{fig:topqed}). As for constrained property optimization, MoFlow\ finds novel and optimized molecules with the best similarity scores and second best property improvement (Table~\ref{tab:plogp}).
It is worthwhile to highlight our contributions as follows:
\begin{compactitem}
\item {\bf Novel MoFlow\ model:}
our MoFlow\ is one of the first flow-based graph generative models which not only generates molecular graphs at one shot by invertible mapping but also has a validity guarantee. To capture the combinatorial atom-and-bond structures of molecular graphs, we propose a variant of Glow model for bonds (edges) and a novel graph conditional flow for atoms (nodes) given bonds, and then assemble them into valid molecular graphs.
\item {\bf State-of-the-art performance:} our MoFlow\ achieves many state-of-the-art results w.r.t. molecular graph generation, reconstruction, optimization, etc., and at the same time our one-shot inference and generation are very efficient, which implies its potentials in deep exploration of huge chemical space for drug discovery.
\end{compactitem}
The outline of this paper is:
survey (Sec.~\ref{sec:related}), proposed method (Sec.~\ref{sec:mp} and \ref{sec:model}), experiments (Sec.~\ref{sec:exp}), and conclusions (Sec.~\ref{sec:conclusion}). In order to promote reproducibility, our codes and datasets are open-sourced at \url{https://github.com/calvin-zcx/moflow}.
\section{Related Work}
\label{sec:related}
\mytag{Molecular Generation.}
Different deep generative frameworks are proposed for generating molecular SMILES or molecular graphs. Among the variational autoencoder (VAE)-based models \cite{kusner2017grammar,dai2018syntax,simonovsky2018graphvae,ma2018constrained,liu2018constrained,bresson2019two,jin2018junction}, the JT-VAE \cite{jin2018junction} generates valid tree-structured molecules by first generating a tree-structured scaffold of chemical substructures and then assembling substructures according to the generated scaffold.
The MolGAN \cite{de2018molgan} is a generative adversarial networks (GAN)-based model but shows very limited performance in generating valid and unique molecules. The autoregressive-based models generate molecules in a sequential manner with validity check at each generation step. For example, the MolecularRNN \cite{popova2019molecularrnn} sequentially generates each character of SMILES and the GCPN \cite{you2018graph} sequentially generates each atom/bond in a molecular graphs.
In this paper, we explore a different deep generative framework, namely the normalizing flow models \cite{dinh2014nice,madhawa2019graphnvp,kingma2018glow}, for molecular graph generation, which have the potential to memorize and reconstruct all the training data and generalize to generating more valid, novel and unique molecules.
\noindent \mytag{Flow-based Models.}
The (normalizing) flow-based models try to learn mappings between complex distributions and simple prior distributions through invertible neural networks and such a framework has good merits of exact and tractable likelihood estimation for training, efficient one-pass inference and sampling, invertible mapping and thus reconstructing all the training data etc. Examples include NICE\cite{dinh2014nice}, RealNVP\cite{dinh2016density}, Glow\cite{kingma2018glow} and GNF \cite{liu2019graph} which show promising results in generating images or even graphs \cite{liu2019graph}. See latest reviews in \cite{papamakarios2019normalizing,kobyzev2019normalizing} and more technical details in Section~\ref{sec:mp}.
To our best knowledge, there are three flow-based models for molecular graph generation. The GraphAF \cite{shi2020graphaf} is an autoregressive flow-based model which achieves state-of-the-art performance in molecular graph generation. The GraphAF generates molecular graphs in a sequential manner with validity check when adding any new atom or bond. The GraphNVP \cite{madhawa2019graphnvp} and GRF \cite{honda2019graph} are proposed for molecular graph generation in a one-shot manner. However, they have no guarantee for chemical validity and thus show very limited performance in generating valid and novel molecular graphs.
Our MoFlow\ is the first of its kind which not only generates molecular graphs efficiently by invertible mapping at one shot but also has a validity guarantee. In order to capture the atom-and-bond composition of molecules, we propose a variant of Glow\cite{kingma2018glow} model for bonds and a novel graph conditional flow for atoms given bonds, and then combining them with a post-hoc validity correction. Our MoFlow\ achieves many state-of-the-art results thanks to capturing the chemical structures in a holistic way, and our one-shot inference and generation are more efficient than sequential models.
\section{Model Preliminary}
\label{sec:mp}
\mytag{The flow framework.} The flow-based models aim to learn a sequence of invertible transformations $f_{\Theta}=f_L \circ ... \circ f_1$ between complex high-dimensional data $X \sim P_\mathcal{X}(X)$ and $Z \sim P_\mathcal{Z}(Z)$ in a latent space with the same number of dimensions where the latent distribution $P_\mathcal{Z}(Z)$ is easy to model (e.g., strong independence assumptions hold in such a latent space). The potentially complex data in the original space can be modelled by the \textbf{change of variable formula} where $Z=f_{\Theta}(X)$ and:
\begin{equation}
\small
P_{\mathcal{X}}(X)=P_{\mathcal{Z}}(Z) \mid \det (\frac{\partial Z}{\partial X}) \mid.
\end{equation}
To sample $\tilde{X}\sim P_\mathcal{X}(X)$ is achieved by sampling $\tilde{Z} \sim P_\mathcal{Z}(Z)$ and then to transform $\tilde{X} = f_{\Theta}^{-1} (\tilde{Z})$ by the reverse mapping of $f_{\Theta}$.
Let $Z = f_{\Theta}(X) = f_L \circ ... \circ f_1 (X)$, \ $H_l = f_l (H_{l-1})$ where $f_l$ ($l = 1, ... L \in \mathbb{N^+}$) are invertible mappings, $H_{0}=X$, $H_{L}=Z$ and $P_\mathcal{Z}(Z)$ follows a standard isotropic Gaussian with independent dimensions. Then we get the log-likelihood of $X$ by the change of variable formula as follows:
\begin{equation}
\small
\begin{aligned}
\log P_{\mathcal{X}}(X) &=\log P_{\mathcal{Z}}(Z) + \log \mid \det (\frac{\partial Z}{\partial X}) \mid \\
&=\sum_i \log P_{\mathcal{Z}_i}(Z_i) + \sum_{l=1}^{L}\log \mid \det (\frac{\partial f_l}{\partial H_{l-1}}) \mid
\end{aligned}
\end{equation} where $P_{\mathcal{Z}_i}(Z_i)$ is the probability of the $i^{th}$ dimension of $Z$ and $f_{\Theta}=f_L \circ ... \circ f_1$ is an invertible deep neural network to be learnt. Thus, the exact-likelihood-based training is tractable.
\mytag{Invertible affine coupling layers.} However, how to design a.) an invertible function $f_{\Theta}$ with b.) expressive structures and c.) efficient computation of the Jacobian determinant are nontrivial. The NICE\cite{dinh2014nice} and RealNVP \cite{dinh2016density} design an affine coupling transformation $Z = f_{\Theta}(X):\mathbb{R}^{n} \mapsto \mathbb{R}^{n}$:
\begin{equation}
\small
\begin{aligned}
Z_{1:d} &= X_{1:d} \\
Z_{d+1:n} &= X_{d+1:n} \odot e^{S_{\Theta}(X_{1:d})} + T_{\Theta}(X_{1:d}),
\end{aligned}
\end{equation} by splitting $X$ into two partitions $X = (X_{1:d}, X_{d+1:n})$. Thus, a.) the invertibility is guaranteed by:
\begin{equation}
\small
\begin{aligned}
X_{1:d} &= Z_{1:d} \\
X_{d+1:n} &= (Z_{d+1:n} - T_{\Theta}(Z_{1:d})) / e^{S_{\Theta}(Z_{1:d})},
\end{aligned}
\end{equation}
b.) the expressive power depends on arbitrary neural structures of the \textbf{{S}cale function} $S_{\Theta}:\mathbb{R}^{d} \mapsto \mathbb{R}^{n-d}$ and the \textbf{{T}ransformation function} $T_{\Theta}:\mathbb{R}^{d} \mapsto \mathbb{R}^{n-d}$ in the affine transformation of $X_{d+1:n}$, and c.) the Jacobian determiant can be computed efficiently by $\det (\frac{\partial Z}{\partial X})=\exp{(\sum_j S_{\Theta}(X_{1:d})_j)}$.
\mytag{Splitting Dimensions.}
The flow-based models, e.g., RealNVP \cite{dinh2016density} and Glow \cite{kingma2018glow}, adopt
\mytag{squeeze operation} which compresses the spatial dimension $X^{c \times n \times n}$ into $X^{(ch^2) \times \frac{n}{h} \times \frac{n}{h}}$ to make more channels and then split channels into two halves for the coupling layer. A deep flow model at a specific layer transforms unchanged dimensions in the previous layer to keep all the dimensions transformed.
In order to learn an optimal partition of $X$, Glow \cite{kingma2018glow} model introduces an \mytag{ invertible $1 \times 1$ convolution} $: \mathbb{R}^{c \times n \times n} \times \mathbb{R}^{c \times c} \mapsto \mathbb{R}^{c \times n \times n}$
with learnable convolution kernel $W \in \mathbb{R}^{c \times c}$ which is initialized as a random rotation matrix. After the transformation $Y = \text{invertible $1 \times 1$ convolution}(X, W)$, a fixed partition $Y = (Y_{1:\frac{c}{2}, :, :}, Y_{\frac{c}{2}+1:n, :, :})$ over the channel $c$ is used for the affine coupling layers.
\mytag{Numerical stability by actnorm.}
In order to ensure the numerical stability of the flow-based models, \mytag{actnorm layer} is introduced in Glow \cite{kingma2018glow} which normalizes dimensions in each channel over a batch by an affine transformation with learnable scale and bias. The scale and the bias are initialized as the mean and the inverse of the standard variation of the dimensions in each channel over the batch.
\section{Proposed {\bf MoFlow\ } Model}
\label{sec:model}
In this section, we first define the problem and then introduce our \underline{Mo}lecular \underline{Flow} (MoFlow) model in detail. We show the outline of our MoFlow\ in Figure~\ref{fig:model} as a roadmap for this section.
\begin{figure}[!tb]
\vspace{-0.1in}
\centering
\includegraphics[width=0.52\textwidth]{Fig/framework2.pdf}
\vspace{-0.2in}
\caption{
The outline of our MoFlow. A molecular graph $M$ (e.g. Metformin) is represented by a feature matrix $A$ for atoms and adjacency tensors $B$ for bonds. Inference:
the graph conditional flow (GCF) $f_{\mathcal{A|B}}$ for atoms (Sec.~\ref{sec:model:gcf}) transforms $A$ given $B$ into conditional latent vector $Z_{A|B}$, and the Glow $f_{\mathcal{B}}$ for bonds (Sec.~\ref{sec:model:glow}) transform $B$ into latent vector $Z_B$. The latent space follows a spherical Gaussian distribution. Generation: the generation process is the reverse transformations of previous operations, followed by a validity correction (Sec.~\ref{sec:model:validity}) procedure which ensures the chemical validity. We summarize MoFlow\ in Sec.~\ref{sec:model:all}. Regression and optimization:
the mapping $y(Z)$ between latent space and molecular properties are used for
molecular graph optimization and property prediction
(Sec.~\ref{sec:exp:opt}, Sec.~\ref{sec:exp:copt}).
\label{fig:model}}
\vspace{-0.1in}
\end{figure}
\subsection{Problem Definition: Learning a Probability Model of Molecular Graphs}
\label{sec:model:problem}
Let $\mathcal{M}=\mathcal{A} \times \mathcal{B} \subset \mathbb{R}^{n \times k} \times \mathbb{R}^{c \times n \times n}$ denote the set of $\mathcal{M}$olecules which is the Cartesian product of the $\mathcal{A}$tom set $\mathcal{A}$ with at most $n \in \mathbb{N^+}$ atoms belonging to $k \in \mathbb{N^+}$ atom types and the $\mathcal{B}$ond set $\mathcal{B}$ with $c\in \mathbb{N^+}$ bond types. A molecule $M=(A,B) \in \mathcal{A} \times \mathcal{B}$ is a pair of an atom matrix $A \in \mathbb{R}^{n \times k}$ and a bond tensor $B \in \mathbb{R}^{c \times n \times n}$.
We use one-hot encoding for the empirical molecule data where
$A (i, k) = 1$ represents the atom $i$ has atom type $k$, and $B (c, i, j)=B (c, j, i)=1$ represents a type $c$ bond between atom $i$ and atom $j$. Thus, a molecule $M$ can be viewed as an undirected graph with multi-type nodes and multi-type edges.
Our primary goal is to learn a molecule generative model $P_{\mathcal{M}} (M)$ which is the probability of sampling any molecule $M$ from $P_{\mathcal{M}}$.
In order to capture the combinatorial atom-and-bond structures of molecular graphs,
we decompose the $P_{\mathcal{M}} (M)$ into two parts:
\begin{equation}\small
P_{\mathcal{M}}(M)=P_{\mathcal{M}}((A,B)) \approx P_{\mathcal{A|B}}(A|B; \theta_\mathcal{A|B}) P_{\mathcal{B}}(B;\theta_\mathcal{B})
\end{equation}
where
$P_{\mathcal{M}}$ is the distribution of molecular graphs,
$P_{\mathcal{B}}$ is the distribution of bonds (edges) in analogy to modelling multi-channel images , and
$P_{\mathcal{A|B}}$ is the conditional distribution of atoms (nodes) given the bonds by leveraging graph convolution operations. The $\theta_\mathcal{B}$ and $\theta_\mathcal{A|B}$ are learnable modelling parameters.
In contrast with VAE or GAN based frameworks, we can learn the parameters by exact maximum likelihood estimation (MLE) framework by maximizing:
\begin{equation}\small
\argmax_{\theta_\mathcal{B}, \theta_\mathcal{A|B}} \ \mathbb{E}_{M=(A,B) \sim p_{\mathcal{M}-data}} [\log P_{\mathcal{A|B}}(A|B; \theta_\mathcal{A|B}) + \log P_{\mathcal{B}}(B;\theta_\mathcal{B})]
\end{equation}
Our model thus consists of two parts, namely a \emph{graph conditional flow for atoms} to learn the atom matrix conditional on the bond tensors and
a \emph{flow for bonds} to learn bond tensors. We further learn a mapping between the learned latent vectors and molecular properties to regress the graph-based molecular properties, and to guide the generation of optimized molecular graphs.
\subsection{Graph Conditional Flow for Atoms}
\label{sec:model:gcf}
Given a bond tensor $B \in \mathcal{B} \subset \mathbb{R}^{c \times n \times n}$, our goal of the atom flow is to generate the right atom-type matrix $A \in \mathcal{A} \subset \mathbb{R}^{n \times k} $ to assemble valid molecules $M=(A,B) \in \mathcal{M} \subset \mathbb{R}^{n \times k + c \times n \times n} $. We first define \mytag{$\mathcal{B} $-conditional flow} and \mytag{graph conditional flow} $f_{\mathcal{A|B}}$ to transform $A$ given $B$ into conditional latent variable ${Z_{A|B}} = f_{\mathcal{A|B}} (A|B)$ which follows isotropic Gaussian $P_{\mathcal{{Z_{A|B}}}}$.
We can get the conditional probability of atom features given the bond graphs $P_{\mathcal{A|B}}$ by a conditional version of the change of variable formula.
\subsubsection{$\mathcal{B} $-Conditional Flow and Graph Conditional Flow}
\begin{definition} {\mytag{$\mathcal{B} $-conditional flow}:}
A \mytag{$\mathcal{B} $-conditional flow} \newline $Z_{A|B} | B = f_{\mathcal{A|B}}(A | B)$ is an invertible and dimension-kept mapping
and there exists reverse transformation $f_{\mathcal{A|B}}^{-1}(Z_{A|B}|B)=A|B$ where $f_{\mathcal{A|B}} \text{ and } f_{\mathcal{A|B}}^{-1}: \mathcal{A} \times \mathcal{B} \mapsto \mathcal{A}\times \mathcal{B}$.
\end{definition}
The condition $B \in \mathcal{B}$ keeps fixed during the transformation. Under the independent assumption of $\mathcal{A}$ and $\mathcal{B}$, the Jacobian of $f_{\mathcal{A|B}}$ is:
\begin{equation}\small
\begin{aligned}
\frac{\partial f_{\mathcal{A|B}}}{\partial (A,B)} = \begin{bmatrix}
\frac{\partial f_{\mathcal{A|B}}}{\partial A} & \frac{\partial f_{\mathcal{A|B}}}{\partial B}\\
0 & \mathbb{1}_B
\end{bmatrix},
\end{aligned}
\end{equation}
the determiant of this Jacobian is $\det \frac{\partial f_{\mathcal{A|B}}}{\partial (A,B)} = \det \frac{\partial f_{\mathcal{A|B}}}{\partial A}$, and thus the \textit{conditional version of the change of variable formula} in the form of log-likelihood is:
\begin{equation} \small
\begin{aligned}
\log P_\mathcal{A|B} (A | B) = \log P_{\mathcal{Z_{A|B}}}(Z_{A|B}) + \log \mid \det \frac{\partial f_{\mathcal{A|B}}}{\partial A} \mid.
\end{aligned}
\end{equation}
\begin{definition} {\mytag{Graph conditional flow}:}
A graph conditional flow is a $\mathcal{B} $-conditional flow $Z_{A|B} | B= f_{\mathcal{A|B}}(A|B)$ where $B \in \mathcal{B} \subset \mathbb{R}^{c \times n \times n}$ is the adjacency tenor for edges with $c$ types and $A \in \mathcal{A} \subset \mathbb{R}^{n \times k}$ is the feature matrix of the corresponding $n$ nodes.
\end{definition}
\begin{figure}[!tb]
\vspace{-0.2in}
\centering
\includegraphics[width=0.35\textwidth]{Fig/cgflow.pdf}
\vspace{-0.15in}
\caption{
Graph conditional flow $f_{\mathcal{A|B}}$ for the atom matrix. We show the details of one invertible graph coupling layer and a multiscale structure consists of a cascade of $L$ layers of such graph coupling layer. The graphnorm is computed only once.
\label{fig:cgflow}}
\vspace{-0.15in}
\end{figure}
\subsubsection{Graph coupling layer} We construct aforementioned invertible mapping $f_{\mathcal{A|B}}$ and $f_{\mathcal{A|B}}^{-1}$ by the scheme of the affine coupling layer. Different from traditional affine coupling layer, our coupling transformation relies on graph convolution \cite{sun2019graph} and thus we name such a coupling transformation as a \textbf{graph coupling layer}.
For each graph coupling layer, we split input $A \in \mathbb{R}^{n \times k}$ into two parts $A=(A_1, A_2)$ along the $n$ row dimension, and we get the output $Z_{A|B} = (Z_{A_1|B}, Z_{A_2|B}) = f_{\mathcal{A|B}}(A|B)$ as follows:
\begin{equation}\small
\begin{aligned}
Z_{A_1|B} &= A_{1} \\
Z_{A_2|B} &= A_{2} \odot \text{Sigmoid}(S_{\Theta}(A_{1}| B)) + T_{\Theta}(A_{1}| B)
\end{aligned}
\end{equation}
where $\odot$ is the element-wise product. We deign the scale function $S_{\Theta}$ and the transformation function $T_{\Theta}$ in each graph coupling layer by incorporating \textbf{graph convolution} structures. The bond tensor $B \in \mathbb{R}^{c \times n \times n}$ keeps a fixed value during transforming the atom matrix $A$. We also apply the masked convolution idea in \cite{dinh2016density} to the graph convolution in the graph coupling layer.
Here, we adopt Relational Graph Convolutional Networks (R-GCN) \cite{schlichtkrull2018modeling} to build {graph convolution layer} \textbf{graphconv} as follows:
\begin{equation}\small
\begin{aligned}
\text{graphconv}(A_1) = \sum_{i=1}^{c} \hat{B_i}(M\odot A)W_i + (M \odot A)W_0
\end{aligned}
\end{equation}
where $\hat{B_i} = D^{-1}B_i$ is the normalized adjacency matrix at channel $i$, $D = \sum_{c,i}B_{c,i,j}$ is the sum of the in-degree over all the channels for each node, and $M \in \{0,1\}^{n \times k}$ is a binary mask to select a partition $A_1$ from A. Because the bond graph is fixed during graph coupling layer and thus the graph normalization, denoted as \textbf{graphnorm}, is computed only once.
We use multiple stacked graphconv->BatchNorm1d->ReLu layers with a multi-layer perceptron (MLP) output layer to build the graph scale function $S_{\Theta}$ and the graph transformation function $T_{\Theta}$. What's more, instead of using exponential function for the $S_{\Theta}$ as discussed in Sec.~\ref{sec:mp}, we adopt Sigmoid function for the sake of the numerical stability of cascading multiple flow layers.
The reverse mapping of the graph coupling layer $f_{\mathcal{A|B}}^{-1}$ is:
\begin{equation}
\small
\begin{aligned}
A_{1} &= Z_{A_1|B} \\
A_{2} &= (Z_{A_2|B} - T_{\Theta}(Z_{A_1|B}| B))/ \text{Sigmoid}(S_{\Theta}(Z_{A_1|B} | B)).
\end{aligned}
\end{equation}
The logarithm of the Jacobian determiant of each graph coupling layer can be efficiently computed by:
\begin{equation}
\small
\begin{aligned}
\log \mid \det (\frac{\partial f_{\mathcal{A|B}}}{\partial A}) \mid=\sum_j \log \text{Sigmoid}(S_{\Theta}(A_1 | B))_j
\end{aligned}
\end{equation}
where $j$ iterates each element. In principle, we can use arbitrary complex graph convolution structures for $S_{\Theta}$ and $T_{\Theta}$ since the computing of above Jacobian determinant of $f_{\mathcal{A|B}}$ does not involve in computing the Jacobian of $S_{\Theta}$ or $T_{\Theta}$.
\subsubsection{Actnorm for 2-dimensional matrix}
For the sake of numerical stability, we design a variant of invertible actnorm layer \cite{kingma2018glow} for the 2-dimensional atom matrix, denoted as \textbf{actnorm2D} (activation normalization for 2D matrix), to normalize each row, namely the feature dimension for each node, over a batch of 2-dimensional atom matrices. Given the mean $\mu \in \mathbb{R}^{n \times 1}$ and the standard deviation $\sigma^2 \in \mathbb{R}^{n \times 1}$ for each row dimension, the normalized input follows $\hat{A} = \frac{A-\mu}{\sqrt{\sigma^2 + \epsilon}}$ where $\epsilon$ is a small constant, the reverse transformation is $A = \hat{A} * \sqrt{\sigma^2 + \epsilon} + \mu$, and the logarithmic Jacobian determiant is:
\begin{equation}
\small
\begin{aligned}
\log \mid \det \frac{\partial \textbf{actnorm2D}}{\partial X} \mid = \frac{k}{2}\sum_i^{n}\mid \log({\sigma^2_i + \epsilon}) \mid
\end{aligned}
\end{equation}
\subsubsection{Deep architectures}
We summarize our deep graph conditional flow in Figure~\ref{fig:cgflow}. We stack multiple graph coupling layers to form graph conditional flow.
We alternate different partition of $A=(A_1, A_2)$ in each layer to transform the unchanged part of the previous layer.
\subsection{Glow for Bonds}
\label{sec:model:glow}
The bond flow aims to learn an invertible mapping $f_{\mathcal{B}}: \mathcal{B} \subset \mathbb{R}^{c \times n \times n} \mapsto \mathcal{B} \subset \mathbb{R}^{c \times n \times n}$ where the transformed latent variable $Z_B = f_{\mathcal{B}} (B)$ follows isotropic Gaussian. According to the change of variable formula, we can get the logarithmic probability of bonds by $\log P_{\mathcal{B}}(B)=\log P_{\mathcal{Z_B}}(Z_B) + \log \mid \det (\frac{\partial f_{\mathcal{B}}}{\partial B}) \mid$ and generating bond tensor by reversing the mapping $\tilde{B} = f_{\mathcal{B}}^{-1} (\tilde{Z})$ where $\tilde{Z} \sim P_{\mathcal{Z}}(Z)$. We can use arbitrary flow model for the bond tensor and we build our bond flow $f_{\mathcal{B}}$ based on a variant of Glow \cite{kingma2018glow} framework.
We also follow the scheme of affine coupling layer to build invertible mappings.
For each affine coupling layer, We split input $B \in \mathbb{R}^{c \times n \times n}$ into two parts $B=(B_1, B_2)$ along the channel $c$ dimension, and we get the output $Z_B=(Z_{B_1}, Z_{B_2})$ as follows:
\begin{equation}
\small
\begin{aligned}
Z_{B_1} &= B_{1} \\
Z_{B_2} &= B_{2} \odot \text{Sigmoid}(S_{\Theta}(B_{1})) + T_{\Theta}(B_{1}) .
\end{aligned}
\end{equation}
And thus the reverse mapping $f_{\mathcal{B}}^{-1}$ is:
\begin{equation}
\small
\begin{aligned}
B_{1} &= Z_{B_1} \\
B_{2} &= (Z_{B_2} - T_{\Theta}(Z_{B_1}))/ \text{Sigmoid}(S_{\Theta}(Z_{B_1})).
\end{aligned}
\end{equation}
Instead of using exponential function as scale function, we use the Sigmoid function with range $(0,1)$ to ensure the numerical stability when stacking many layers. We find that exponential scale function leads to a large reconstruction error when the number of affine coupling layers increases. The scale function $S_{\Theta}$ and the transformation function $T_{\Theta}$ in each affine coupling layer can have arbitrary structures. We use multiple $3\times3$ conv2d->BatchNorm2d->ReLu layers to build them. The logarithm of the Jacobian determiant of each affine coupling is
\begin{equation}
\small
\begin{aligned}\log \mid \det (\frac{\partial Z_B}{\partial B}) \mid=\sum_j \log \text{Sigmoid}(S_{\Theta}(B_1))_j.
\end{aligned}
\end{equation}
\begin{figure}[!tb]
\vspace{-0.3in}
\centering
\includegraphics[width=0.35\textwidth]{Fig/glow.pdf}
\label{fig:syn_exp1}
\vspace{-0.15in}
\caption{
A variant of Glow $f_{\mathcal{B}}$ for bonds' adjacency tensors.
\label{fig:glow}}
\vspace{-0.3in}
\end{figure}
In order to learn optimal partition and ensure model's stability and learning rate, we also use the
invertible $1 \times 1$ convolution layer and
actnorm layer adopted in the Glow.
In order to get more channels for masking and transformation, we \mytag{squeeze} the spatial size of $B$ from $\mathbb{R}^{c \times n \times n}$ to $\mathbb{R}^{(c*h*h) \times \frac{n}{h} \times \frac{n}{h}}$ by a factor $h$ and apply the affine coupling transformation to the squeezed data. The reverse \mytag{unsqueeze} operation is adopted to the output.
We summarize our bond flow in Figure~\ref{fig:glow}.
\subsection{Validity Correction}
\label{sec:model:validity}
Molecules must follow the valency constraints for each atom, but assembling a molecule from generated bond tensor and atom matrix may lead to chemically invalid ones. Here we define the valency constraint for the $i^{th}$ atom as:
\begin{equation}
\small
\begin{aligned}
\sum_{c,j} c\times B(c,i,j) \le \text{Valency}(\text{Atom}_i) + Ch
\end{aligned}
\end{equation}
where $B \in \{0,1\}^{c\times n \times n}$ is the one-hot bond tensor over $c \in \{1,2,3\}$ order of chemical bonds (single, double, triple) and $Ch \in \mathbb{N}$ represents the formal charge. Different from existing valency constraints defined in \cite{you2018graph, popova2019molecularrnn}, we consider the effect of formal charge which may introduce extra bonds for the charged atoms. For example, ammonium [NH4]$^+$ may have 4 bonds for N instead of 3. Similarly, S$^+$ and O$^+$ may have 3 bonds instead of 2. Here we only consider $Ch=1$ for N$^+$, S$^+$ and O$^+$ and make $Ch=0$ for other atoms.
In contrast with the existing reject-sampling-based validity check adopted in the autoregressive models \cite{you2018graph, popova2019molecularrnn}, we introduce a new post-hoc validity correction procedure
after generating a molecule $M$ at once: 1) check the valency constraints of $M$; 2) if all the atoms of $M$ follows valecny constraints, we return the largest connected component of the molecule $M$ and end the procedure; 3) if there exists an invalid atom $i$, namely $\sum_{c,j} c \times B(c,i,j) > \text{Valency}(\text{Atom}_i) + Ch$, we sort the bonds of $i$ by their order and delete $1$ order for the bond with the largest order; 4) go to step 1). Our validity correction procedure tries to make a minimum change to the existing molecule and to keep the largest connected component as large as possible.
\subsection{Inference and Generation}
\label{sec:model:all}
We summarize the inference (encoding) and generation (decoding) of molecular graphs by our MoFlow\ in Algorithm~\ref{alg:inference} and Algorithm~\ref{alg:generate} respectively. We visualize the overall framework in Figure~\ref{fig:model}. As shown in the algorithms, our MoFlow\ have merits of exact likelihood estimation/training, one-pass inference, invertible and one-pass generation, and chemical validity guarantee.
\begin{algorithm}[!h]
\footnotesize
\SetAlgoLined
\textbf{Input:} $f_\mathcal{A|B}$: graph conditional flow for atoms, $f_\mathcal{B}$: glow for bonds, $A$: atom matrix, $B$: bond tensor, $P_{\mathcal{Z_*}}$: isotropic Gaussian distributions.\\
\textbf{Output:}
$Z_M$:latent representation for atom $M$,
$\log P_\mathcal{M}(M)$: logarithmic likelihood of molecule $M$. \\
\quad $Z_B = f_\mathcal{B}(B)$ \\
\quad $\log P_{\mathcal{B}}(B)=\log P_{\mathcal{Z_B}}(Z_B) + \log \mid \det (\frac{\partial f_{\mathcal{B}}}{\partial B}) \mid$ \\
\quad $\hat{B} = \text{graphnorm(B)}$ \\
\quad $Z_{A|B} = f_\mathcal{A|B}(A|\hat{B})$ \\
\quad $ \log P_\mathcal{A|B} (A | B) = \log P_{\mathcal{Z_{A|B}}}(Z_{A|B}) + \log \mid \det (\frac{\partial f_{\mathcal{A|B}}}{\partial A} )\mid $ \\
\quad $Z_M = (Z_{A|B}, Z_B)$\\
\quad $\log P_{\mathcal{M}} (M) = \log P_\mathcal{B}(B) + \log P_\mathcal{A|B}(A|B)$ \\
\quad \textbf{Return:} $Z_M$, $\log P_\mathcal{M}(M)$\\
\caption{Exact Likelihood Inference (Encoding) of Molecular Graphs by MoFlow\ \label{alg:inference}}
\end{algorithm}
\begin{algorithm}[!h]
\footnotesize
\SetAlgoLined
\textbf{Input:} $f_\mathcal{A|B}$: graph conditional flow for atoms, $f_\mathcal{B}$: glow for bonds,
$Z_M$:latent representation of molecule $M$ or sampling from a prior Gaussian,
validity-correction: validity correction rules.\\
\textbf{Output:} $M$: a molecule\\
\quad $(Z_{A|B}, Z_B) = Z_M$\\
\quad $B = f_\mathcal{B}^{-1}(Z_B)$ \\
\quad $\hat{B} = \text{graphnorm(B)}$ \\
\quad $A = f_\mathcal{A|B}^{-1}(Z_{A|B}|\hat{B})$ \\
\quad $M = \text{validity-correction}(A,B)$\\
\quad \textbf{Return:} $M$\\
\caption{Molecular Graph Generation (Decoding) by the Reverse Transformation of MoFlow\ \label{alg:generate}}
\end{algorithm}
\section{Experiments}
\label{sec:exp}
Following previous works \cite{jin2018junction,shi2020graphaf}, we validate our MoFlow\ by answering following questions:
\begin{compactitem}
\item \mytag{Molecular graph generation and reconstruction (Sec.~\ref{sec:exp:generation}):}
Can our MoFlow\ memorize and reconstruct all the training molecule datasets? Can our MoFlow\ generalize to generate novel, unique and valid molecules as many as possible?
\item \mytag{Visualizing continuous latent space (Sec.~\ref{sec:exp:viz}):}
Can our MoFlow\ embed molecular graphs into continuous latent space with reasonable chemical similarity?
\item \mytag{Property optimization (Sec.~\ref{sec:exp:opt}):}
Can our MoFlow\ generate novel molecular graphs with optimized properties?
\item \mytag{Constrained property optimization (Sec.~\ref{sec:exp:copt}):}
Can our MoFlow\ generate novel molecular graphs with the optimized properties and at the same time keep the chemical similarity as much as possible?
\end{compactitem}
\mytag{Baselines.}
We compare our MoFlow\ with: a) the state-of-the-art VAE-based method JT-VAE \cite{jin2018junction} which captures the chemical validity by encoding and decoding a tree-structured scaffold of molecular graphs; b) the state-of-the-art autoregressive models GCPN \cite{you2018graph} and MolecularRNN (MRNN)\cite{popova2019molecularrnn} with reinforcement learning for property optimization, which generate molecules in a sequential manner; c) flow-based methods GraphNVP \cite{madhawa2019graphnvp} and GRF \cite{honda2019graph} which generate molecules at one shot and the state-of-the-art autoregressive-flow-based model GraphAF \cite{shi2020graphaf} which generates molecules in a sequential way.
\mytag{Datasets.}
We use two datasets QM9 \cite{ramakrishnan2014quantum} and ZINC250K \cite{irwin2012zinc} for our experiments and summarize them in Table~\ref{tab:data}. The QM9 contains $133,885$ molecules with maximum $9$ atoms in $4$ different types, and the ZINC250K has $249,455$ drug-like molecules with maximum $38$ atoms in $9$ different types. The molecules are kekulized by the chemical software RDKit \cite{landrum2006rdkit} and the hydrogen atoms are removed. There are three types of edges, namely single, double, and triple bonds, for all molecules. Following the pre-processing procedure in \cite{madhawa2019graphnvp}, we encode each atom and bond by one-hot encoding, pad the molecules which have less than the maximum number of atoms with an virtual atom, augment the adjacency tensor of each molecule by a virtual edge channel representing no bonds between atoms, and dequantize \cite{madhawa2019graphnvp,dinh2016density} the discrete one-hot-encoded data by adding uniform random noise $U[0,0.6]$ for each dimension,
leading to atom matrix $A\in \mathbb{R}^{9\times5}$ and bond tensor $B\in \mathbb{R}^{4 \times 9\times 9}$ for QM9, and $A\in \mathbb{R}^{38\times10}$ and
$B\in \mathbb{R}^{4 \times 38\times 38}$ for ZINC250k.
\begin{table}[!htb]
\vspace{-0.15in}
\small
\centering
\caption{Statistics of the datasets.}
\vspace{-0.05in}
\begin{tabular
{ l p{1.2cm} p{1.2 cm} p{1.2cm} p{1.2cm} p{1.2cm} }
\toprule
\bf{} & \bf{\#Mol. Graphs} & \bf{Max. \#Nodes} & \bf{\#Node Types} & \bf{\#Edge Types}\\
\midrule
QM9 & 133,885 & 9 & 4+1 & 3+1 \\
ZINC250K & 249,455 & 38 & 9+1 & 3+1 \\
\bottomrule
\end{tabular}
\label{tab:data}
\vspace{-0.1in}
\end{table}
\mytag{{\bf MoFlow\ } Setup.}
To be comparable with one-shot-flow baseline GraphNVP \cite{madhawa2019graphnvp}, for the ZINC250K, we adopt $10$ coupling layers and $38$ graph coupling layers for the bonds' Glow and the atoms' graph conditional flow respectively. We use two $3*3$ convolution layers with $512,512$ hidden dimensions in each coupling layer.
For each graph coupling layer, we set one relational graph convolution layer with $256$ dimensions followed by a two-layer multilayer perceptron with $512,64$ hidden dimensions.
As for the QM9, we adopt $10$ coupling layers and $27$ graph coupling layers for the bonds' Glow and the atoms' graph conditional flow respectively. There are two 3*3 convolution layers with $128,128$ hidden dimensions in each coupling layer, and one graph convolution layer with $64$ dimensions followed by a two-layer multilayer perceptron with $128,64$ hidden dimensions in each graph coupling layer.
As for the optimization experiments, we further train a regression model to map the latent embeddings to different property scalars (discussed in Sec.~\ref{sec:exp:opt} and \ref{sec:exp:copt}) by a multi-layer perceptron with 18-dim linear layer -> ReLu -> 1-dim linear layer structures. For each dataset, we use the same trained model for all the following experiments.
\mytag{Empirical Running Time.}
Following above setup, we implemented our MoFlow\ by Pytorch-1.3.1 and trained it by Adam optimizer \cite{kingma2014adam} with learning rate $0.001$, batch size $256$, and $200$ epochs for both datasets on $1$ GeForce RTX 2080 Ti GPU and 16 CPU cores.
Our MoFlow\ finished $200$-epoch training within $22$ hours ($6.6$ minutes/epoch) for ZINC250K and $3.3$ hours ($0.99$ minutes/epoch) for QM9. Thanks to efficient one-pass inference/embedding, our MoFlow\ takes negligible $7$ minutes to learn an additional regression layer trained in $3$ epochs for optimization experiments on ZINC250K. In comparison, as for the ZINC250K dataset, GraphNVP \cite{madhawa2019graphnvp} costs $38.4$ hours ($11.5$ minutes/epoch) by our Pytorch implementation for training on ZINC250K with the same configurations, and the estimated total running time of GraphAF \cite{shi2020graphaf} is $124$ hours ($24$ minutes/epoch) which consists of the reported $4$ hours for a generation model trained by $10$ epochs and estimated $120$ hours for another optimization model trained by $300$ epochs. The reported running time of JT-VAE \cite{jin2018junction} is roughly $24$ hours in \cite{you2018graph}.
\subsection{Generation and Reconstruction}
\label{sec:exp:generation}
\begin{table*}[!htb]
\small
\centering
\caption{Generation and reconstruction performance on QM9 dataset. }
\vspace{-0.1in}
\begin{tabular}{l c c c c c c }
\toprule
& \textbf{\% Validity} & \textbf{\% Validity w/o check} & \textbf{\% Uniqueness} & \textbf{\% Novelty} & \textbf{\% N.U.V.} & \textbf{\% Reconstruct}\\
\midrule
GraphNVP \cite{madhawa2019graphnvp} & $83.1\pm0.5$ & n/a & $99.2\pm0.3$& $58.2\pm1.9$ & $47.97$ & $100$\\
GRF \cite{honda2019graph}& $84.5\pm 0.70$ & n/a & $66.0\pm1.15$& $58.6\pm 0.82$ & $32.68$ &$100$\\
GraphAF \cite{shi2020graphaf}& $100$ & $67$& $94.51$ & $88.83$ & $83.95$ &$100$\\
\midrule
\textbf{MoFlow} & $\mathbf{100.00\pm0.00}$ & $\mathbf{96.17\pm0.18}$ & $\mathbf{99.20\pm0.12}$ & $\mathbf{98.03\pm0.14}$ & $\mathbf{97.24\pm0.21}$ & $\mathbf{100.00\pm0.00}$ \\
\bottomrule
\end{tabular}
\label{tab:qm9}
\end{table*}
\begin{table*}[!htb]
\small
\centering
\caption{Generation and reconstruction performance on ZINC250K dataset.
}
\vspace{-0.1in}
\begin{tabular}{l c c c c c c }
\toprule
& \textbf{\% Validity} & \textbf{\% Validity w/o check} & \textbf{\% Uniqueness} & \textbf{\% Novelty} & \textbf{\% N.U.V.} & \textbf{\% Reconstruct}\\
\midrule
JT-VAE \cite{jin2018junction} & $100$ & n/a & $100$& $100$ & $100$ & $76.7$\\
GCPN \cite{you2018graph} & $100$ & $20$ & $99.97$& $100$ & $99.97$ & n/a\\
MRNN \cite{popova2019molecularrnn}& $100$ & $65$ & $99.89$ & $100$ & $99.89$ & n/a\\
GraphNVP \cite{madhawa2019graphnvp} & $42.6\pm1.6$ & n/a & $94.8\pm0.6$& $100$ & $40.38$ & $100$\\
GRF \cite{honda2019graph} & $73.4\pm 0.62$ & n/a & $53.7\pm 2.13$& $100$ & $39.42$ &$100$\\
GraphAF \cite{shi2020graphaf}& $100$ & $68$& $99.10$ & $100$ & $99.10$ &$100$\\
\midrule
\textbf{MoFlow} & $\mathbf{100.00\pm0.00}$ & $\mathbf{81.76\pm0.21}$ & $\mathbf{99.99\pm0.01}$ & $\mathbf{100.00\pm0.00}$ & $\mathbf{99.99\pm0.01}$ & $\mathbf{100.00\pm0.00}$ \\
\bottomrule
\end{tabular}
\label{tab:zinc}
\end{table*}
\mytag{Setup.} In this task, we evaluate our MoFlow\ 's capability of generating novel, unique and valid molecular graphs, and if our MoFlow\ can reconstruct input molecular graphs from their latent representations. We adopted the widely-used metrics, including: \textbf{Validity} which is the percentage of chemically valid molecules in all the generated molecules, \textbf{Uniqueness} which is the percentage of unique valid molecules in all the generated molecules, \textbf{Novelty} which is the percentage of generated valid molecules which are not in the training dataset, and \textbf{Reconstruction} rate which is the percentage of molecules in the input dataset which can be reconstructed from their latent representations. Besides, because the novelty score also accounts for the potentially duplicated novel molecules, we propose a new metric \textbf{N.U.V.} which is the percentage of \underline{N}ovel, \underline{U}nique, and \underline{V}alid molecules in all the generated molecules. We also compare the validity of ablation models if not using validity check or validity correction, denoted as \textbf{Validity w/o check} in \cite{shi2020graphaf}.
The prior distribution of latent space follows a spherical multivariate Gaussian distribution
$\mathcal{N}(0, {(t \sigma)}^2 \mathbf{I})$ where $\sigma$ is the learned standard deviation and the hyper-parameter $t$ is the temperature for the reduced-temperature generative model \cite{parmar2018image, kingma2018glow,madhawa2019graphnvp}. We use $t=0.85$ in the generation for both QM9 and ZINC250K datasets, and $t=0.6$ for the ablation study without validity correction. To be comparable with the state-of-the-art baseline GraphAF\cite{shi2020graphaf}, we generate $10,000$ molecules, i.e., sampling $10,000$ latent vectors from the prior and then decode them by the reverse transformation of our MoFlow. We report the the mean and standard deviation of results over 5 runs.
As for the reconstruction, we encode all the molecules from the training dataset into latent vectors by the encoding transformation of our MoFlow\ and then reconstruct input molecules from these latent vectors by the reverse transformation of MoFlow.
\mytag{Results.} Table~\ref{tab:qm9} and Table~\ref{tab:zinc} show that our MoFlow\ outperfoms the state-of-the-art models on all the six metrics for both QM9 and ZINC250k datasets.
Thanks to the invertible characteristic of the flow-based models, our MoFlow\ builds an one-to-one mapping from the input molecule $M$ to its corresponding latent vector $Z$, enabling $100\%$ reconstruction rate as shown in Table~\ref{tab:qm9} and Table~\ref{tab:zinc}. In contrast, the VAE-based method JT-VAE and the autoregressive-based method GCPN and MRNN can't reconstruct all the input molecules. Compared with the one-shot flow-based model GraphNVP and GRF, by incorporating validity correction mechanism, our MoFlow\ achieves $100\%$ validity, leading to significant improvements of the validity score and N.U.V. score for both datasets. Specifically, the N.U.V. score of MoFlow\ are $2$ and $3$ times as large as the N.U.V. scores of GraphNVP and GRF respectively in Table~\ref{tab:qm9}.
Even without validity correction, our MoFlow\ still outperforms
the validity scores of GraphNVP and GRF by a large margin.
Compared with the autoregressive flow-based model GraphAF, we find
our MoFlow\ outperforms GraphAF
by additional $16\%$ and $0.8\%$ with respect to N.U.V scores for QM9 and ZINC respectively, indicating that our MoFlow\ generates more novel, unique and valid molecules. Indeed, MoFlow\ achieves better uniqueness score and novelty score compared with GraphAF for both datasets. What's more, our MoFlow\ without validity correction still outperforms GraphAF without the validity check by a large margin w.r.t. the validity score (validity w/o check in Table~\ref{tab:qm9} and Table~\ref{tab:zinc}) for both datasets, implying the superiority of capturing the molecular structures in a holistic way by our MoFlow\ over autoregressive ones in a sequential way.
In conclusion, our MoFlow\ not only memorizes and reconstructs all the training molecular graphs, but also generates more novel, unique and valid molecular graphs than existing models, indicating that our MoFlow\ learns a strict superset of the training data and explores the unknown chemical space better.
\subsection{Visualizing Continuous Latent Space}
\label{sec:exp:viz}
\begin{figure*}[!th]
\vspace{-0.2in}
\centering
\includegraphics[width=.6\textwidth]{Fig/zinc_int.pdf}
\vspace{-0.1in}
\caption{
Visualization of learned latent space by our MoFlow. Top: Visualization of the grid neighbors of a seed molecule in the center, which serves as the baseline for measuring similarity. Bottom: Interpolation between two seed molecular graphs and the left one is the baseline molecule for measuring similarity. Seed molecules are highlighted in red boxs and they are randomly selected from ZINC250K.
\label{fig:zincint}}
\end{figure*}
\mytag{Setup.} We examine the learned latent space of our MoFlow\ , denoted as $f$, by visualizing the decoded molecular graphs from a neighborhood of a latent vector in the latent space. Similar to \cite{kusner2017grammar, jin2018junction}, we encode a seed molecule $M$ into $Z=f(M)$ and then grid search two random orthogonal directions with unit vector $X$ and $Y$ based on $Z$, then we get new latent vector by $Z' = Z + \lambda_X*X + \lambda_Y*Y$ where $\lambda_X$ and $\lambda_Y$ are the searching steps. Different from VAE-based models, our MoFlow\ gets decoded molecules efficiently by the one-pass inverse transformation $M'=f^{-1}(Z')$. In contrast, the VAE-based models such as JT-VAE need to decode each latent vectors $10-100$ times and autoregressive-based models like GCPN, MRNN and GraphAF need to generate a molecule sequentially.
Further more, we measure the chemical similarity between each neighboring molecule and the centering molecule. We choose Tanimoto index \cite{bajusz2015tanimoto} as the chemical similarity metrics and indicate their similarity values by a heatmap. We further visualize a linear interpolation between two molecules to show their changing trajectory
similar to the interpolation case between images \cite{kingma2018glow}.
\mytag{Results.} We show the visualization of latent space in Figure~\ref{fig:zincint}. We find the latent space is very smooth and the interpolations between two latent points only change a molecule graph a little bit. Quantitatively, we find the chemical similarity between molecules majorly correspond to their Euclidean distance between their latent vectors, implying that our MoFlow\ embeds similar molecular graph structures into similar latent embeddings. Searching in such a continuous latent space learnt by our MoFlow\ is the basis for molecular property optimization and constraint optimization as discussed in the following sections.
\vspace{-0.1in}
\subsection{Property Optimization}
\label{sec:exp:opt}
\mytag{Setup.}
The property optimization task aims at generating novel molecules with the best Quantitative Estimate of Druglikeness (QED) scores \cite{bickerton2012quantifying} which measures the drug-likeness of generated molecules. Following the previous works \cite{you2018graph,popova2019molecularrnn}, we report the best property scores of novel molecules discovered by each method.
We use the pre-trained MoFlow, denoted as $f$, in the generation experiment to encode a molecule $M$ and get the molecular embedding $Z = f(M)$, and further train a multilayer perceptron to regress the embedding $Z$ of the molecules to their property values $y$. We then search the best molecules by the gradient ascend method, namely $Z' = Z + \lambda * \frac{d y}{ dZ}$ where the $\lambda$ is the length of the search step. We conduct above gradient ascend method by $K$ steps.
We decode the new embedding $Z'$ in the latent space to the discovered molecule by reverse mapping $M' = f^{-1}(Z')$. The molecule $M'$ is novel if $M'$ doesn't exist in the training dataset.
\begin{table}[!h]
\vspace{-0.1in}
\footnotesize
\centering
\caption{Discovered novel molecules with the best QED scores. Our MoFlow\ finds more molecules with the best QED scores. More results in Figure~\ref{fig:topqed}.}
\vspace{-0.1in}
\begin{tabular
{ l p{1.2cm} p{1.2 cm} p{1.2cm} p{1.2cm} p{1.2cm} }
\toprule
\bf{Method} & \bf{1st} & \bf{2nd} & \bf{3rd} & \bf{4th}\\
\midrule
ZINC (Dataset) & 0.948 & 0.948 & 0.948 & 0.948 \\
\midrule
JT-VAE & 0.925 & 0.911 & 0.910 & -\\
GCPN & 0.948 & 0.947 & 0.946 & -\\
MRNN & 0.948 & 0.948 & 0.947 & -\\
GraphAF & 0.948 & 0.948 & 0.947 & 0.946\\
\midrule
\bf{MoFlow\ } & \bf{0.948} & \bf{0.948} & \bf{0.948} & \bf{0.948}\\
\bottomrule
\end{tabular}
\label{tab:topqed}
\vspace{-0.2in}
\end{table}
\begin{figure}[!h]
\vspace{-0.25in}
\small
\centering
\includegraphics[width=.4\textwidth]{Fig/top_qed2.pdf}
\label{fig:syn_exp1}
\vspace{-0.1in}
\caption{
Illustration of discovered novel molecules with the best druglikeness QED scores.
\label{fig:topqed}}
\vspace{-0.1in}
\end{figure}
\mytag{Results.}
We report the discovered novel molecules sorted by their QED scores in Table~\ref{tab:topqed}. We find previous methods can only find very few molecules with the best QED score ($=0.948$). In contrast, our MoFlow\ finds much more novel molecules which have the best QED values than all the baselines. We show more molecular structures with top QED values in Figure~\ref{fig:topqed}.
\vspace{-0.1in}
\subsection{Constrained Property Optimization}
\label{sec:exp:copt}
\mytag{Setup.}
The constrained property optimization aims at finding a new molecule $M'$ with the largest similarity score $sim(M,M')$ and the largest improvement of a targeted property value $y(M') - y(M)$ given a molecule $M$. Following the similar experimental setup of \cite{jin2018junction,you2018graph}, we choose Tanimoto similarity of Morgan fingerprint \cite{rogers2010extended} as the similarity metrics, the penalized logP (plogp) as the target property, and $M$ from the $800$ molecules with the lowest plogp scores in the training dataset of ZINC250K.
We use similar gradient ascend method as discussed in the previous subsetion to search for optimized molecules.
An optimization succeeds if we find a novel molecule $M'$ which is different from $M$ and $y(M') - y(M) \ge 0$ and $sim(M,M') \ge \delta$ within $K$ steps where $\delta$ is the smallest similarity threshold to screen the optimized molecules.
\mytag{Results.} Results are summarized in Table~\ref{tab:plogp}. We find that our MoFlow\ finds the most similar new molecules at the same time achieves very good plogp improvement. Compared with the state-of-the-art VAE model JT-VAE, our MoFlow\ achieves much higher similarity score and property improvement, implying that our model is good at interpolation and learning continuous molecular embedding. Compared with the state-of-the-art reinforcement learning based method GCPN and GraphAF which is good at generating molecules step-by-step with targeted property rewards, our model MoFlow\ achieves the best similarity scores and the second best property improvements. We illustrate one optimization example in Figure~\ref{fig:copt} with very similar structures but a large improvement w.r.t the penalized logP.
\begin{table}[!tb]
\vspace{-0.05in}
\scriptsize
\centering
\caption{Constrained optimization on Penalized-logP}
\vspace{-0.1in}
\begin{tabular}{l c c c c c c c}
\toprule
& \multicolumn{3}{c}{JT-VAE} & \multicolumn{3}{c}{GCPN}\\
\cmidrule(l){2-4} \cmidrule(l){5-7}
$\delta$ & \textbf{Improvement} & \textbf{Similarity} & \textbf{Success} & \textbf{Improvement} & \textbf{Similarity} & \textbf{Success} \\
\midrule
\textbf{0.0} & $ 1.91\pm 2.04$ & $ 0.28\pm 0.15$ & $97.5\%$ &$ 4.20\pm 1.28$ & $ \mathbf{0.32\pm 0.12}$& $100\%$\\
\textbf{0.2} & $ 1.68\pm 1.85$ & $ 0.33\pm 0.13$ & $97.1\%$ &$4.12 \pm 1.19$ & $ 0.34 \pm 0.11$& $100\%$\\
\textbf{0.4} & $0.84 \pm 1.45$ & $0.51 \pm 0.10$ & $83.6\%$ &$2.49 \pm 1.30$ & $ 0.48\pm 0.08$& $100\%$\\
\textbf{0.6} & $ 0.21\pm 0.71$ & $ 0.69\pm 0.06$ & $46.4\%$ &$0.79 \pm 0.63$ & $ 0.68\pm 0.08$& $100\%$\\
\midrule
& \multicolumn{3}{c}{GraphAF} & \multicolumn{3}{c}{\textbf{MoFlow\ }}\\
\cmidrule(l){2-4} \cmidrule(l){5-7}
$\delta$ & \textbf{Improvement} & \textbf{Similarity} & \textbf{Success} & \textbf{Improvement} & \textbf{Similarity} & \textbf{Success} \\
\midrule
\textbf{0.0} & $ 13.13\pm 6.89$ & $0.29 \pm 0.15$ & $100\%$ &$ 8.61\pm 5.44$ & $0.30 \pm 0.20 $ & $98.88\%$\\
\textbf{0.2} & $ 11.90\pm 6.86$ & $ 0.33\pm 0.12$ & $100\%$ &$7.06 \pm 5.04$ & $\mathbf{0.43 \pm 0.20 }$& $96.75\%$\\
\textbf{0.4} & $ 8.21\pm 6.51$ & $0.49 \pm 0.09$ & $99.88\%$ &$4.71 \pm4.55 $ & $ \mathbf{0.61\pm0.18} $& $85.75\%$\\
\textbf{0.6} & $4.98 \pm 6.49$ & $0.66 \pm 0.05$ & $96.88\%$ &$ 2.10\pm 2.86$ & $ \mathbf{0.79\pm 0.14}$& $58.25\%$\\
\bottomrule
\bottomrule
\end{tabular}
\label{tab:plogp}
\end{table}
\begin{figure}[!t]
\vspace{-0.1in}
\centering
\includegraphics[width=0.4\textwidth]{Fig/copt.pdf}
\vspace{-0.1in}
\caption{
An illustration of the constrained optimization of a molecule leading to an improvement of $+16.48$ w.r.t the penalized logP and with Tanimoto similarity $0.624$. The modified part is highlighted.
\label{fig:copt}}
\vspace{-0.1in}
\end{figure}
\section{Conclusion}
\label{sec:conclusion}
In this paper, we propose a novel deep graph generative model MoFlow\ for molecular graph generation. Our MoFlow\ is one of the first flow-based models which not only generates molecular graphs at one-shot by invertible mappings but also has a validity guarantee.
Our MoFlow\ consists of a variant of Glow model for bonds, a novel graph conditional flow for atoms given bonds, and then combining them with post-hoc validity corrections.
Our MoFlow\ achieves state-of-the-art performance on molecular generation, reconstruction and optimization.
For future work, we try to combine the advantages of both sequential generative models and one-shot generative models to generate chemically feasible molecular graphs. Codes and datasets are open-sourced at \url{https://github.com/calvin-zcx/moflow}.
\small{
\section*{Acknowledgement}
This work is supported by NSF IIS 1716432, 1750326, ONR N00014-18-1-2585, Amazon Web Service (AWS) Machine Learning for Research Award and Google Faculty Research Award.
} | {'timestamp': '2020-06-19T02:03:14', 'yymm': '2006', 'arxiv_id': '2006.10137', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10137'} | arxiv |
\section*{Abstract}
The chest X-Ray (CXR) is the one of the most common clinical exam used to diagnose thoracic diseases and abnormalities. The volume of CXR scans generated daily in hospitals is huge. Therefore, an automated diagnosis system able to save the effort of doctors is of great value.
At present, the applications of artificial intelligence in CXR diagnosis usually use pattern recognition to classify the scans. However, such methods rely on labeled databases, which are costly and usually have large error rates.
In this work, we built a database containing more than 12,000 CXR scans and radiological reports, and developed a model based on deep convolutional neural network and recurrent network with attention mechanism. The model learns features from the CXR scans and the associated raw radiological reports directly; no additional labeling of the scans are needed. The model provides automated recognition of given scans and generation of reports.
The quality of the generated reports was evaluated with both the CIDEr scores and by radiologists as well. The CIDEr scores are found to be around 5.8 on average for the testing dataset. Further blind evaluation suggested a comparable performance against human radiologist.
\section*{Introduction}
The chest X-Ray (CXR) is one of the most common diagnostic techniques for respiratory system. It iss quick and inexpensive, and yields low radiation. The volume of daily CXR scans in hospitals is huge and their examination and interpretation consume lots of time and effort of radiologists. Therefore, it is desirable to develop an automated system that is able to examine and interpret CXR radiographs automatically. Moreover, an automated system may help reduce inter-observer variations due to the factors including individual experience, quality of the radiograph, time and personality type \cite{tudor1997assessment}. The adoption of an automated system will \b{lead} to a more standardized terminology and treatment, and benefit the collaborations between different parties. The system may further evoke new applications such as remote diagnosis, self-service diagnosis and so on.
Previously, many works focused on automated classification of the CXR scans. These works are usually based on variants of Convolutional Neural Networks (CNN) and supervised learning \cite{Rajpurkar2017CheXNet,Ypsilantis2017Learning,Pesce2017Learning,islam2017abnormality,Yao2017Learning,Yan2018Weakly,Guan2018Diagnose,Rubin2018Large}. However, at least two problems hinder the practical applications of automated systems in hospital. First, the sensitivity and false positive rates of these classification approaches seem to be saturated. Further improvement may need significant increase the amount and quantity of labeled samples, which are very expensive in the medical field. Second, the decision strategy underlying these systems has not been well understood, making it difficult to track the errors and gain the trust of doctors and patients.
In this work, we developed a model based on deep recurrent neural networks with attention mechanism that learns from CXR images and the raw radiological reports simultaneously. The deep neural networks have shown great potential in characterizing and classifying complex data in a broad range of fields \cite{goodfellow2016deep,Silver2016Mastering,Hui2015RNA}.
After training with our database, the neural network is able to automatically generate radiological reports for given scans. Our work has the following novel features.
First, the training of our model is only weakly supervised; the model directly learns from the image and the raw radiological reports stored in the hospital database; no further classification and labeling of the images by human is required. That is, in contrast to most machine learning models. This feature greatly facilitates the acquisition of data and training of large-scale models. Second, instead of a simple classification of the case into one or several disease categories, the output of our model is a descriptive report regarding different conditions of the chest; the output is directly readable for patients. Third, the implementation of the attention mechanism adds another level of understanding of how the model works, facilitating debugging and optimizing of the model.
In the following sections, we describe the model architecture, training and testing procedures, and the performance evaluated with the CIDEr scores and by human radiologists.
\section*{Methods}
\subsection{The architecture of the network}
Figure \ref{fig1} shows the overall architecture of the neural network. During training, the neural network reads in both CXR images and the raw radiological reports, and outputs human readable texts. The output is then compared with the ground truth to calculate the loss function, which is minimized with the gradient back-propagation technique. After training, the model is able to automatically generate reports for given CXR images.
\begin{figure}[h]
\centering
\includegraphics[width=1\textwidth]{fig1-model.jpg}
\caption{The architecture of the whole network. During training, the inputs are the CXR image and the associated text report. The image is encoded by the CNN module and fed to the LSTM with attention mechanism for generating text report.}
\label{fig1}
\end{figure}
The design of the model architecture was inspired by the pioneer work of Xu et al. \cite {xu2015show}, where they developed an RNN to generate captions for daily images, such as those in Flickr and MS COCO databases. The model is also similar to those by Zhang et al. \cite{Zhang2017Mdnet} and Wang et al. \cite{Wang2018TieNet} in terms of the purpose of automatically generating medical reports. However, the architecture of our model was redesigned to better fit the organization of our database.
The model contains a 121-layer Densely Connected Convolutional Network (DenseNet) \cite{Huang2017Densely}, which is used as a visual information encoder to extract features from the input images. The encoder is composed of four blocks; each block contains several convolutional layers, each takes all preceding feature-maps as inputs. The blocks are connected by transition layers. According to Huang et al., DenseNets alleviate the vanishing gradient problem, strengthen feature propagation, encourage feature reuse, and substantially reduce the number of parameters \cite{Huang2017Densely}. Compared with many other CNNs, they converge faster and are appropriate for smaller datasets. Therefore, DenseNets are suitable for medical images. The output of the last layer of the DenseNet block is fed to the Long Short-Term Memory (LSTM) network to generate descriptions for the given CXR image.
The LSTM network \cite{Hochreiter1997Long} is adopted to generate texts for the given CXR image word by word. At each step, it reads the output of the last layer of the DenseNet block and the previous generated word, and outputs the next word. In detail, our LSTM implementation follows that of \cite{zaremba2014recurrent}, i.e.,
\begin{equation}
\left( {\begin{array}{*{20}{l}}
{{{\rm{i}}_t}}\\
{{{\rm{f}}_t}}\\
{{{\rm{o}}_t}}\\
{{{\rm{g}}_t}}
\end{array}} \right) = \left( {\begin{array}{*{20}{c}}
\sigma \\
\sigma \\
\sigma \\
{\tanh }
\end{array}} \right){W_{h,e + c + h}}\left( {\begin{array}{*{20}{c}}
{E{y_{t - 1}}}\\
{{V_{gav}}}\\
{{h_{t - 1}}}
\end{array}} \right),
\end{equation}
\begin{equation}
{c_t} = {{\rm{f}}_t} \bigodot {c_{t - 1}} + {i_t} \bigodot {g_t},
\end{equation}
\begin{equation}
{h_t} = {o_t} \bigodot \tanh ({c_t}),
\end{equation}
where $i_t$, $f_t$, $c_t$, $o_t$, $h_t$ are the input, forget, memory, output and hidden gates of the LSTM, respectively. $W$ is the weight matrix, $\sigma$ the logistic sigmoid function, $V_{gav}$ the global average of DenseNet output, $y_{t-1}$ the previous generated word, and $E$ is an embedding matrix. The symbol $\bigodot$ denotes element-wise multiplication. The subscript $h$ is the size of the hidden states, $e$ the vocabulary size, and $c$ is the channel number of the output of DenseNet.
Attention mechanism has been widely adopted in visual image processing since it improves the model performance and adds a level of understanding of how the model works. It mimics the human visual attention mechanism by learning to focus on a certain image region. Specifically, a soft attention mechanism is implemented in the model, which calculates a set of weights conditioning on the image representation and on the hidden state. These weights are multiplied with the output vectors of the DenseNet to get a weighted representation of the image, which is then utilized by the recurrent neural network to generate descriptions. The corresponding equations are
\begin{equation}
{\alpha _t} = {\rm softmax}({W_{p,h}}{h_t} + {W_{1,c}}V),
\end{equation}
\begin{equation}
{C_t} = V{\alpha _t},
\end{equation}
\begin{equation}
{{\bf{y}}_t} \sim {{\bf{p}}_t} \propto {\rm{exp}}\left( {{{\rm{W}}_{e,h}}{{\rm{h}}_t}{\rm{ + }}{{\rm{W}}_{e,c}}{{\rm{C}}_t}} \right),
\end{equation}
where $\alpha _t$ is the attention weight, $V$ the output of DenseNet, $C_t$ the weighted context vector, $\bf{p}_t$ the probability distribution of the words, and $\bf{y}_t$ is the predicted word sampled from $\bf{p}_t$.
The loss function is the cross entropy between the ground truth and the prediction distributions of the texts,
\begin{equation}
loss({\bf{p}},{\bf{y}}) = - \frac{1}{l}\sum\nolimits_{j = 1}^l {log\left( {{{\bf{p}}_j}({{y}_j})} \right)},
\end{equation}
where $\bf{p_j}$ is the probability distribution predicted at the $j$-th step, ${y_j}$ the index of the $j$-th word in the ground truth text, and $l$ the length of the text.
\subsection{Datasets}
All the chest X-ray scans and the associated radiological reports were provided by Nanjing Drum Tower Hospital. In total the dataset contains 12, 219 images and the same number of reports in Chinese language. All reports were investigated by one expert (of attending doctor level or above) and double checked by another expert (of associate chief physician level or above). The dataset was randomly split into three sets, 80\% samples for training, 10\% for validating, and 10\% for testing. Figure \ref{fig2} shows some examples randomly taken from the dataset.
\begin{figure}[!ht]
\centering
\includegraphics[width=1\textwidth]{fig2-datasets.jpg}
\caption{Four samples chosen from the dataset. Note the English description is translated from Chinese by human.}
\label{fig2}
\end{figure}
Since there are no blanks between Chinese words, the python module jieba \cite{jieba} was used for text segmentation. After processing all the radiological reports in the dataset, a vocabulary of size 424 was obtained. The words were represented with one-hot-vectors. The words that appeared less than three times were represented with a special token $<$nou$>$. Two other special tokens were $<$start$>$ and $<$end$>$, indicating the beginning and ending of the reports, respectively.
\subsection{Training Procedures}
Transferring learning technique was employed to speed up the convergence of training. Specifically, the 121-layer DenseNet was pre-trained with the ChestX-ray8 dataset released in September 2017 \cite{Wang2017ChestX} for a classification task in a supervised way. The training procedure was similar to that in \cite{Rajpurkar2017CheXNet}. The ChestX-ray8 dataset contains 110k chest x-ray images and 14 types of diseases labels. The resulted weights were then transferred to the encoder module of the model. In the training process that followed, the parameters in the first two dense blocks were fixed while that in the others were fine-tuned by the gradient back-propagation algorithm.
During training, the original x-ray images were resized to 256*256 pixels and then processed with histogram equalization to increase the contrast. The size of the hidden unit of LSTM was set to 512 and the embedding size was 256. Adam optimizer was used for the optimization process. The learning rate of the DenseNet was set to $1.0 \times 10^{-4}$ and that of the LSTM was set to $5.0 \times 10^{-4}$.
\subsection{Evaluation metrics}
In order to evaluate for image $I_i$ how well a generated sentence $c_i$ matched the consensus of a set of descriptions $S_i=\{s_{i1}, ..., s_{im}\}$, the Consensus-based Image Description Evaluation score (CIDEr) \cite{Vedantam2015CIDEr} was used.
To calculate the CIDEr score, the Term Frequency Inverse Document Frequency (TF-IDF) weighting ${g_k}({s_{ij}})$ for each $n$-gram $\omega_k$ in the sentence $s_{ij}$ was first calculated as
\begin{equation}
{g_k}({s_{ij}}) = \frac{{h_k}({s_{ij}})}{{\sum _{\omega l \in \Omega }}{h_l}({s_{ij}})}\log \left( {\frac{{\left| I \right|}}{\sum\nolimits_{{I_{p \in I}}} {\min (1,\sum\nolimits_q {{h_k}({s_{pq}})} )} }} \right),
\end{equation}
where $h_k({s_{ij}})$ is the number of times an $n$-gram $\omega_k$ occurs in the sentence $s_{ij}$, $\Omega $ the vocabulary of all $n$-grams and $I$ the set of all images in the dataset.
Then the CIDEr$_n$ score for $n$-grams of length $n$ was calculated as
\begin{equation}
{\rm CIDEr}_n(c_i,S_i) = \frac{1}{m}\sum\nolimits_j {\frac{{{g^n}({c_i}) \cdot {g^n}({s_{ij}})}}{{\left\| {{g^n}({c_i})} \right\|\left\| {{g^n}({s_{ij}})} \right\|}}},
\end{equation}
where $g^n(s_{ij})$ is a vector formed by $g_k(s_{ij})$ corresponding to all $n$-grams of length n. $g^n(c_i)$ is similarly defined for the generated sentence $c_i$.
At last, the CIDEr score was calculated as the average over all $n$-grams,
\begin{equation}
{\rm CIDEr}(c_i,S_i) = \frac{1}{N} \sum_{n=1}^N {\rm CIDEr}_n (c_i,S_i).
\end{equation}
\section*{Results}
Figure \ref{fig3}(a) shows the losses of the training and validation datasets as a function of the training epoch. It can be seen that the training loss keeps decreasing, while the validation loss saturates at about the 10{\it th} epoch, indicating that the generalization ability of the model reaches its maximum. Therefore, the parameters obtained at the 10{\it th} epoch are used by the model to generate the results in the following sections.
Figure \ref{fig3}(b) shows the calculated CIDEr values for the testing dataset as a function of epoch. Note that for the testing set, the ground truth sentences were not used when generating the descriptions; they were only used to evaluate the descriptions after their generation. The Beam Search technique \cite{Sutskever2014Sequence} was used to generate multiple sentences for a given CXR image, and each sentence was assigned a preference probability. The top three sentences with the highest probabilities were recorded. Their CIDEr values were calculated against the ground truth and the highest one was used to calculate the curve shown in Fig. \ref{fig3}(b).
According to the figure, the average CIDEr value of the testing set increases as a function of the epoch, and saturates around 5.8 at the 10{\it th} epoch.
\begin{figure}[!ht]
\begin{center}
\includegraphics[width=0.48\textwidth]{fig3a-loss.eps}
\includegraphics[width=0.48\textwidth]{fig3b-cider.eps}
\caption{(a) The losses of the training and validation datasets as a function of epoch. (b) The CIDEr values of the testing dataset as a function of epoch.}
\label{fig3}
\end{center}
\end{figure}
Fig. \ref{fig4}. shows several examples of the generated descriptions. For each scan, the top three predictions given by the model are shown, labeled as Pd1, Pd2, and Pd3, respectively, in the decreasing order of the preference probability. More examples are given in the supplemental materials. Fig. \ref{fig4}(a) shows a normal case with increased lung markings in both lungs. The model correctly recognizes the situation and generates descriptions with ``increased lung markings in both lungs'' in Pd1 and Pd3; while in Pd2, the model says ``no obvious abnormalities''. Fig. \ref{fig4}(b) shows the scan of a patient with chronic bronchitis and inflammation, concluded based on the image as well as on the medical history. The model reports ``increased lung markings'' in Pd1 and Pd2, and directly gives ``bronchitis'' in Pd3, which is amazing since the model has no information of the medical history. Fig. \ref{fig4}(c) is a case with pleural effusion on the right side. The model identifies the symptom and correctly generates report for it. For the case in Fig. \ref{fig4}(d), the model correctly recognizes the increased size of the heart and also assumes the image to be a postoperative view. It is not known whether the model draws this conclusion based on the thin and bright strips near the heart region.
\begin{figure}[htbp]
\begin{center}
\includegraphics[width=0.78\textwidth]{fig4-show.jpg}
\caption{Several examples of the chest x-ray scans in the testing dataset and the corresponding descriptions generated automatically by the model. The descriptions are in Chinese and translated to English by human for the presentation purpose. The descriptions labeled by Gt are ground truth, and those labeled by Pd1, Pd2, and Pd3 are the top three descriptions based on their probabilities.
\label{fig4}
}
\end{center}
\end{figure}
Figure \ref{fig5} shows the alignment of generated words with the relevant parts of the CXR images. In general, the alignments are consistent with human intuition. The alignments are enabled by the attention mechanism and provide another level of understanding of how the network works. They also facilitate debugging of the results.
\begin{figure}[!ht]
\centering
\includegraphics[scale=0.6]{fig5-att.jpg}
\caption{Attention over time. As the network generates words step by step, its attention changes to different parts of the image, mimicking the visual behavior of human.}
\label{fig5}
\end{figure}
The quality of the automatically generated reports were also evaluated by human experts. The procedure was as follows.
100 CXR scans were randomly extracted from the testing dataset and fed one by one to the neural network to generate reports. Another 100 CXR scans and the corresponding raw reports, which were written by human radiologists, were randomly extracted from the same dataset. These 200 scans and the associated reports were put together, shuffled and sent to experts for human inspection. Two radiologists (of associate chief physician level) were invited to examine the images and assess the quality of the associated reports, without knowing the origin of the reports - from human or machine. This was to prevent possible bias, either to human or to machine. The radiologists gave scores from 1 to 5 for each report, according to the standard as follows. An report with all conditions identified and accurately described was scored 5; an report with major conditions identified correctly but minor problems outside chest missed was scored 4, e.g., scoliosis, foreign matter in vitro; an report with major conditions identified correctly but minor problems inside the chest missed was scored 3, e.g., old lesions, fibrous stripes, post thoracic surgery, aortic calcification; if major conditions were identified but described inaccurately, a score 2 was given; If major conditions were missed or identified incorrectly, the score would be 1.
Figure \ref{fig6} shows the score distributions for two groups of reports. It can be seen that for both groups, the majority are scored 5. For the group of reports given by human, 77\% are scored 5; while for the reports from the model, 72\% are scored 5. At the level of score 4, these two numbers are 9\% and 14\%, respectively. If we assume the scores of 4 or above are acceptable, then both groups have 86\% falling in this range, suggesting that the neural network is able to generate reports with quality comparable with that of human experts.
\begin{figure}[!ht]
\centering
\includegraphics[width=10cm,height=7cm]{fig6-comparison.eps}
\caption{Comparison of the quality of two groups of reports. In total there are 200 reports, half given by radiologists and half by the model. The quality of each report is measured by a score from 1 to 5, given by two radiologists independently without knowing the origin of the reports, from human or from the model.}
\label{fig6}
\end{figure}
\section*{Discussion and Conclusion}
In summary, we developed a scheme that is able to automatically generate radiological reports/descriptions for given CXR, based on a deep convolutional neural network and an recurrent neural network with attention mechanism. We built a database containing more than 12,000 CXR scans and trained the model, and then evaluated the quality of the generated descriptions. The comparison between the generated descriptions and the ground truth gave a CIDEr value of 5.8.
We also blended the generated descriptions with that given by radiologists, and invited other radiologists to score them. It was found that among the reports given by radiologists, 77\% received the highest score 5; while for the reports generated by the model, 72\% were scored 5. For the reports with score 4, the percentages were 9\% and 14\%, respectively. Therefore, the model is able to generate reports with high quality comparable to that of radiologists, and has the potential to be significantly improved as more training data are available.
The model developed here has some particular features. First, it learns from the raw radiological reports and is able to directly utilize the huge volume of CXR data generated in the hospital; no additional labeling work is required. This feature is particular useful since the acquisition of relevant annotations/labels is very expensive in the medical field.
Second, the model outputs description for a given CXR image instead of classifying it into a disease category. The consideration for this design is as follows. In clinical practice, it is not always feasible to draw solid conclusions on underlying diseases solely based on CXR images. For example, prominent/increased lung markings likely indicate an infection, chronic bronchitis, interstitial lung disease, heart failure, or normal aging. In case of such a symptom is observed, it is more appropriate to just describe the symptom, instead of giving a classification of diseases. The model is designed to follow this strategy. Moreover, this model behavior is similar to what radiologists usually do in their daily practice.
However, the model still requires improvement. Since the model is an end-to-end architecture that directly learns from reports and also generates reports, it does not explicitly give classification results. This makes it difficult to quantitatively evaluate the model performance. Currently we rely on human inspection for this purpose. We are dealing with this problem by adding a classification module in the neural network.
We believe the automated AI system developed in this work is useful and will greatly reduce the labor of doctors in the near future.
\section*{Ethics Committee Approvement}
The usage the above described chest X-ray data for this study has been approved by the Ethics Committee of Drum Tower Hospital, Nanjing University, under the document number 2019-100-01.
\section*{Role of the Funding Source}
The funding source has no influence on the scientific program and no role in the writing of this report or in the decision to submit it for publication.
\section*{Conflict of interests}
The authors declare no conflict of interests.
\section{References}
\bibliographystyle{elsarticle-num-names}
| {'timestamp': '2020-06-19T02:11:06', 'yymm': '2006', 'arxiv_id': '2006.10347', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10347'} | arxiv |
\section{Introduction}
\vspace{-8pt}
Modern enterprises generate a huge amount of data. This data is then used to make many business-critical and often mission-critical decisions. However ensuring consistency and correctness of the database records is a challenging task. With passage of time, errors can creep into these datasets, some being out-of-date, inexact, or incorrect. Besides human error, a major source of errors is the following. Often that database is accumulated from multiple different sources. This can lead to the same physical entity having multiple different records in the database. This severely affects the quality of the downstream analytics. The increasing demand to ingest and to acquire large number of heterogeneous data source via inexpensive connectors has been the driving force behind many studies in the field of entity consolidation and data integration \cite{bruggemann1998one,dong2009truth,dong2018data,dong2012less,heidari2019approximate,li2014confidence,li2012truth,yin2008truth}.
A common approach to solve the data integrity problem in the aforementioned paragraph is the following. Given a dataset, first detect all the records which correspond to the same real-world entity. This problem is referred to as data dedupliction or record deduplication \cite{chu2016distributed,deng2017unsupervised,elmagarmid2006duplicate,getoor2012entity}. Once the entities are detected, the next challenge is to merge the records of the same entity (possibly conflicting) into one single record. This is referred to as \textit{Record Fusion} and is the focus of this paper. The problem of merging records corresponding to the same entity has been extensively studied in the database community and also referred to as \textit{the golden record problem} or the \textit{data fusion problem} \cite{dong2009truth,dong2012less,li2012truth,yin2008truth}. Fig. \ref{fig:exampletab} gives a small toy example of the record fusion problem. We will refer back to this during the paper as a suggestive example for some of our algorithms.
\begin{figure}
\centering
\includegraphics[width=0.7\columnwidth]{example.pdf}
\caption{An example dataset where the records have been gathered from multiple sources. There are three entities or clusters. The correct value for each attribute is shown in \textbf{Bold}. Each row of the database makes a claim about the actual value for this real-word entity. However, pieces of information that are gathered from different sources can be conflicting. For instance, the first source of cluster $c_3$ claims that the Amazon headquarters is located in state "WA", while, the last source claims that the state of the entity is "New York". In the record fusion problem, we want to resolve such conflicts and obtain the correct values for the attributes of each real-world entity.}
\label{fig:exampletab}
\vspace{-10pt}
\end{figure}
Previous approaches to tackle the record fusion problem make use of source information. In such situations, for every record, on top of the cluster identities the source that generated the tuple is also known. These works then build models to estimate the \say{trustworthiness} of the different sources \cite{dong2013compact,wu2011framework,yin2008truth,yin2011semi,dong2009truth}. For example, in some instances, a limited ground truth is used for calculating an initial estimation of the sources \say{trust score}\cite{dong2009integrating,galland2010corroborating}. However, reliably estimating the trustworthiness of a source is non-trivial. Furthermore, it is unclear that estimating trustworthiness of a source is the only signal that determines how the records should be merged. In some scenarios, all sources might be equally good/bad and theses source-dependant methods reduce to simple majority voting.
Moreover, in many real-world scenarios, we may not have explicit source information altogether. In such scenarios, current approaches either use techniques like heuristic aggregation rules, majority vote, or involve humans to resolve conflicts via learned transformations \cite{deng2017unsupervised,heidari2019holodetect}. We show experimentally that na\"ive methods like choosing the value provided by the majority vote of sources often lead to inaccurate and unreliable results (see Section \ref{exp:e2e}). Human-in-the-loop approaches have multiple challenges, including (1)~they can be prohibitively expensive and time-consuming depending on the number of clusters, and the difficulty of resolving conflicts; and (2)~they often assume users do not make mistakes, or they need to involve multiple voters introducing new types of conflicts that needs additional resolution mechanisms.
In this paper, we show how to use a principled machine learning approach to solve the record fusion problem taking into account all available signals (statistical properties and constraints). We propose a learning framework for record fusion based on weak supervision \cite{hoffmann2011knowledge,ratner2017snorkel}; our framework automatically fuses records by leveraging all related information, i.e., integrity constraints, and quantitative statistics, and source information if available. We show that our approach is able to fuse records when source information is unavailable with an average precision $\sim$94\%; an improvement of $\sim 45\%$ over previous approaches, also obtaining an average precision of $\sim$98\%; an improvement of over $\sim 20\%$ from previous approaches, when source information is available.
\vspace{-4pt}
\subsection{Technical challenges and contributions}
\vspace{-7pt}
Our ML-approach addresses multiple technical challenges with concrete contributions. We highlight these challenges and solutions in the following sections.
\vspace{-8pt}
\subsubsection*{Feature representation}
\vspace{-8pt}
A characteristic of record fusion is homogeneity within an entity and heterogeneity across entities. Hence, any feature design methodology needs to take this into account. As a concrete example, consider the database in Fig. \ref{fig:exampletab} and lets focus on the first column `Company Name'. For each entity, the values for the first column are similar (`Google', `Google Inc.' ) but are very different when compared against that column values across entities, for example `Amzn', `Microsoft' etc. Hence, na\"ive representations like one-hot encoded strings or even \textit{word2vec} representations are not likely to be able to uncover the relationship that governs which value is correct across that particular entity.
To address this issue, we design representation models that capture various characteristics of the data that providing a rich input to a model. Attribute-level features which capture the distributions governing the values and format of the cell attribute. Tuple-level features capture the joint distribution of different attributes and perform weak predictions for possible values of each cell of final dataset. Dataset-level features capture a distribution that governs the compatibility of tuples and values in the dataset $D$. Section \ref{sec:featuredesign} provides details of each of these steps.
\vspace{-8pt}
\subsection*{Model construction and Training Data Generation}
\vspace{-8pt}
Another property of the record fusion domain is the heterogeneity across different attributes. That is each, column of the database is very different from other columns and sometimes has its own unique format (e.g., Addresses, Zip codes, Webpages see Fig. \ref{fig:exampletab}). Representing all these different features in a single domain is a challenge. A learning algorithm which tries to predict the correct value of cells over the range of all possible values with heterogeneous formats is deemed to fail or require prohibitively large number of data points. To tackle this problem, we propose to learn a different classifier for each attribute. Hence, our learning framework outputs $c$ different classifiers where $c$ is the number of columns in the dataset.
Once the features are constructed, we use a stage-wise additive model to learn a classifier. First, we learn a softmax classifier using our original featurized dataset. While it is possible to use this classifier to make predictions, we construct deeper models using non-linear features using a greedy stage-wise approach. More concretely, we use the predictions from the previous stage to construct a new feature set for current stage which comprises of the original features and also the `dynamic features' from the previous step. We again learn a logistic regression classifier using these sets of features. We repeat this process for a fixed number of steps.
While the approach described in the previous items is sufficient for a comprehensive treatment of the record fusion problem. We go one step further and also \textbf{add data augmentation} amidst this mix so that our models are more robust. We discuss more about it in Section \ref{sec:learningalgorithm} and appendix. Adding a data-augmentation at $10\%$ seems to be the most effective in improving classifier accuracy.
Finally, we evaluate our framework on multiple real-world datasets, where we demonstrate its ability to determine the correct values for real-world entities, and we show that probabilistic inferences with sufficient training data are a valid modelling tool for the record fusion problem (Section~\ref{sec:exp}).
\vspace{-5pt}
\section{Preliminaries}
\label{sec:GR}
\vspace{-8pt}
A relational database is a set of records $D = \{d_1, \ldots, d_n\}$ such that each record (or tuple) $d_i = (d_{i1}, \ldots, d_{ic})$ has $c$ attributes or columns. For all $i$, let $d_{ij}\in R_j$. We say that the database $D$ has a schema $S = \{R_1, \ldots, R_c\}$. Each $d_{ij}$ represents a cell in the database $D$.
A clustering $\mc C$ of the relational dataset $D$ is a partition of its records into disjoint sets. That is $\mc C = \{E_1, \ldots, E_p\}\}$ where $E_k \cap E_{k'} = \varnothing$ and $\cup E_k = D$. We also say that the $E_1, \ldots, E_p$ are the set of $p$ entities for the dataset. For each $i$, we define $Id(i) := k$ if and only if $d_i \in E_k$. In this paper, we assume that the true cluster identities are known for all the records in the database. For each $1 \le k \le p$ and for each $1 \le j \le c$, define $E_{kj} = \{d_{ij} : d_i \in E_k\}$. That is, $E_{kj}$ represents the set of all possible values for the $k^{th}$ entity on the $j^{th}$ column.
Let $G=\{g_1,\dots,g_p\}$ be a data set with schema $S$ that contains the correct label of clusters in $\mc C$. For each row $g_i=\{g_{i1},\dots,g_{ic}\}\in G$ that corresponds to cluster $c_i\in \mc C$ and attribute $R_j\in S$, $g_{ij}$ is a $\rho_j$-dimensional one-hot vector that represent the correct values, where $d^j = \max_i E_{i j}$.
Besides $D$, we are provided with a labels set $G_T\subset G$. $g_{ij}$ is given for all attribute $R_j\in S$ and every Tuple $g_i\in G_T$, and also, optionally, a set of data rules as in form of denial constraints (Def. \ref{def:dc}) $\Sigma$ might provided. We define $G_U=G\backslash G_T$ as the set of unknown labels. We are now ready to define the record fusion problem.
\begin{definition}[Record Fusion]
\label{def1}
\noindent Let $D$ be a relational database with schema $S$. Let $\mc C$ be the set of entities of the database, and $E_{kj}$ be the set of all possible values of the $k^{th}$ entity for the $j^{th}$ attribute. The goal is for each cell in $G_U$, output a probability distribution over $E_{kj}$ that determines the correct label.
\end{definition}
To solve the record fusion problem, we use the following strategy. From the given database, we learn classifiers $h_1, \ldots, h_c$ for each of the attributes in the database. Before we introduce our framework in more detail, it is useful to define the label dimension which will be used later.
\begin{definition}[Label dimension]
The label dimension is the maximum number of records that correspond to a particular attribute.
$ \rho _j := \max_{k} |E_{kj}|$
\end{definition}
Let $D_j = \{d_{ij} : 1 \le i \le n\}$. That is $D_j$ is the set of all values of $j^{th}$ column of the database. For each $d_{ij} \in D_j$, we first convert it into a feature vector $v_{ij}$. The classifier $f_j$ is then trained on the dataset $Z_j = \{(v_{ij}, l_{ij}) : 1 \le i \le n\}$ where $l_{ij}$ is an $\rho_j$-dimensional one-hot encoded vector that represents the ground truth. More precisely, let $d_{ij} \in E_{kj}$ and the ground truth value for $j^{th}$ column in the $k^{th}$ entity be given by the $q^{th}$ element in $E_{kj}$. Then $l_{ij}$ has a one in the $q^{th}$ index and zero on all the other dimensions. We will also frequently use the notation $X_j = \{v_{ij} : 1 \le i \le n\}$ to denote the features set and $y_j = \{l_{ij} : 1 \le i \le n\}$ to denote the label set. Under this notation, $Z_j = (X_j, y_j)$. For cells in $G_U$ in the first iteration, we assign majority vote as their weak labels. That is we put one in the dimension that has the maximum frequency and zero in all other dimensions, and if we have more than one maximum frequency, we select one randomly. In the next iterations, we use prediction of the model in the previous iteration.
To conclude, we construct featurized datasets $Z_1, \ldots, Z_j, \ldots, Z_c$ for each of the attributes of the database. Using these datasets, we are then able to train classifiers $h_1, \ldots, h_c$. In the next section, we describe our featurization step in detail.
\vspace{-5pt}
\section{Feature design}
\label{sec:featuredesign}
\vspace{-8pt}
Our featurization strategy can be be broadly divided into three components; attribute-based, record-level and database-level. Attribute-level features introduce signals specific to that particular cell while the other two aim to capture more global signals. Finally, we combine the features obtained through all the three strategies into a single vector. Next, we give a more detailed description of each of these strategies. Note that formal algorithmic descriptions are included with the appendix (Section \ref{sec:features}).
\vspace{-4pt}
\subsection{Attribute-level Features}
\label{sec:attrfeat}
\vspace{-7pt}
Attribute-level features use three strategies. The first is also referred to as a \textit{format model} which aims to capture the variations governing the style or format of the values. Here, each character is replaced by a special token depending on its type. Like, all alphabets are replaced by a token `A', all numbers by token `N' etc. The original string is then represented as a vector in an $n$-gram model. In this paper, we fixed $n=2$. For example, `Google' would be represented as `AAAAAA' while `Google Inc.' would be represented as `AAAAAASAAAS' and similarly for other cells. After this transformation, each string is represented as a vector which represents the count of the different $n$-grams in the string ($[5, 0, 0, 0], [7, 2, 1, 0]$). Second Strategy is Running cluster-value feature. As our model uses an iterative algorithm, this signal captures the compatibility of the attribute value in a mention with the running cluster value (after inference). For each possible value, we have a flag that indicates if it was the predicted value in an earlier iteration. In the first iteration, the current Running cluster-value feature is zero for each possible value as we do not want to give more weight to the decision of the majority vote. Character and token sequence, the third strategy, makes use of an embedding matrix $M$ which maps all values of the $j^{th}$ column into an euclidean space. Given a cell $d_{ij}$, we compute its distance to the entity average representation and include this value in the feature vector. Next, lets take a look at the record-based featurization strategy.
\vspace{-4pt}
\subsection{Record-level features}
\label{sec:recfeat}
\vspace{-7pt}
Record-level features capture the `relationship' of that particular attribute with other attributes in its record (row). We have two signals. For the first signal, we include the counts of pairs of attributes. This is also referred to as \textit{co-occurrence} counts. As an example, if the value ``New York" in attribute \textit{City} appeared more often with ``United States" of attribute ``Country", the record-level signals should reveal this effect. As we have multiple values for each attribute, we use the values that are predicted in a previous iteration for each attribute in our calculations. This feature is updated in every iteration. Finally, it should be noted that we use one co-occurrence feature per pair of attributes. \textit{Vote model} as another signal, captures how often the cell entry $d_{ij}$ occurs amongst rows within its own entity. Next, we take a look at the dataset-level featurization strategies.
\vspace{-4pt}
\subsection{Database-level Features}
\label{sec:datafeat}
\vspace{-7pt}
The first strategy that we use here is to include something called a \textit{source information}. In many record fusion applications, different rows (or records) come from different sources. Assume that there are $k$ different sources, where $k$ is known a priori. Different sources have different levels of `trust'. Hence, the knowledge of whether that cell came from a particular source is relevant to determine the `correctness' of that cell. We include source information in our features as a $k$-dimensional one-hot vector. Note that, in some cases, source information might be unavailable. In those cases, we ignore this feature and include other features.
The next information that might be available is a set of data rules in form of denial constraints \cite{livshits2020approximate}. Before, we discuss how we capture this information, lets formally define a denial constraint.
\begin{definition}[Denial constraint]
Given a database $D$ with $c$ attributes and schema $S$. A denial constraint is a rule with the format $\phi : \forall d_\alpha, d_\beta, d_\gamma,\dots\in D, \neg(P_1\wedge\dots\wedge P_m)$ where $P_i$ is of the form $v_1\phi v_2$ or $v_1\phi C$ with $v_1,v_2\in d_x.A$, $x\in
\{\alpha,\beta,\gamma,\dots\}$, $A\in S$, $C$ is a constant, and $\phi \in \{=,\ne,\ge,\le,<,>\}$.
\label{def:dc}
\end{definition}
For example, the data rule $Zip \implies City$ can be presented as $\neg(d_i.Zip=d_j.Zip\wedge d_i.City\ne d_j.City)$ for $d_i,d_j\in D$. This means that any two rows in the database which have the same entry for the attribute `Zip' should also have same entry for the attribute `City'. Note that the converse need not be true. That is, there can be two rows with the same value for the column `City' but have different zip codes. Denial constraints are the most general form of rules in first order logic. For each cell $d_{ij}$, we look at the number of denial constraints that involve the $j^{th}$ column. For each of these constraints, we count the number of violations of that denial constraint assuming that the current record $d_i$ is indeed correct. We include this information in the feature vector and call it \textit{constraint violation}.
As a final strategy, we include neighbourhood-based features which makes use of the embedding matrix $M$ (used earlier in the attribute-level features too) and another embedding matrix $Q$. The matrix $Q$ is able to map an entire record (or row) into an euclidean space. For each row, we combine the embeddings obtained from $M$ and $Q$ into one joint attribute-record mapping. We compute the average of such mappings across the entity and compute the distance of the current vector from the average.
All the strategies are described in detailed in Algs. \ref{alg:attributeFeatures}, \ref{alg:recordFeatures} and \ref{alg:databaseFeatures} in the appendix. For every cell, $d_{ij}$ the complete featurization strategy is to call the three algorithms to obtain three vectors. We then combine (or concatenate) these three vectors to obtain the final representation for that cell.
\vspace{-5pt}
\section{Learning Algorithm}
\label{sec:learningalgorithm}
\vspace{-8pt}
Section \ref{sec:featuredesign} enables us to construct training datasets $Z_j$ for all columns in our database. Recall, that $X_j = \{v_{ij} : 1 \le i \le n \}$ is the set of all features corresponding to the $j^{th}$ column while $y_j = \{l_{ij}\}$ is the set of $\rho_j$-dimensional one-hot encoded ground truth vectors and we use $Z_j = (X_j, y_j) = \{(v_{ij}, l_{ij}) : 1 \le i \le n\}$ for training the model. Our goal is to learn a mapping $f_j$ from the set $X_j$ to the set $y_j$.
Since each $f_j$ outputs a $\rho_j$-dimensional one-hot vector, we can view this as a multi-class classification problem. While the training phase can use some of the standard frameworks from supervised learning. The prediction phase can not use the standard approach due to the peculiarities of our problem.
More precisely, observe that each entity $E_k$ at the column $j$ has size $\rho_j\le \rho$. However, this does not present a problem during training as a one-hot vector of dimension $|E_{kj}|$ can be trivially extended to dimension $\rho_j$. However, during the inference phase, a vector of dimension $\rho_j$ needs to be mapped back to a dimension $|E_{kj}|$ to get the predictions for that cell. We will address this problem in Section \ref{section:inferenceAlgorithm}. But before that we first describe our training algorithm.
\begin{algorithm}
\small
\SetAlgoLined
\KwIn{
Training dataset $Z = (X, y)$ where $y_i \in \{0,1\}^\rho$. Let $I_U$ determines indices of rows in $G_U$. Let $y_T$ be the labels in $G_T$. $f$ be the function that does all featurization in Section \ref{sec:featuredesign}. $\#$iterations $T$.
}
\KwOut{Classifier $h$}
\vspace{10pt} Define $X^{[0]} := X$.\\
Let $h^{[0]}$ be the softmax classifier obtained by training on $(X^{[0]}, y)$\\
\vspace{5pt}\For{$t=1$ to $T$}{
$y^{[t]}_U=\{y^{[t]}_i=h^{[t-1]}(X^{[t-1]}):\forall i\in I_U\}$ \\
$y^{[t]}=y_T\cup y^{[t]}_U$\\
Define $X^{[t]} = f(X^{[t-1]}, y^{[t]})$\\
Let $h^{[t]}$ be the softmax classifier obtained by training on $(X^{[t]}, y^{[t]})$
}
\vspace{5pt}\textbf{return} $h^{[T]}$
\caption{Stage-wise additive learning}
\label{alg:il}
\end{algorithm}
Given a training set $Z = (X, y)$ such that $X \in \mb R^b$ and $y \in \{1, \ldots, \rho\}$. A softmax classifier outputs a function $f: X \rightarrow [0, 1]^{\rho}$ according to the following rule.
$$f(x) = softmax(W x) =: \hat y$$
where $W$ is a learned matrix of size $b \times \rho$.
Alg. \ref{alg:il} describes the training procedure for any one of the datasets $Z_j$. We repeat Alg. \ref{alg:il} $c$ times to get classifiers $h_1, \ldots, h_c$. For a particular $Z = (X, y)$, the algorithm works as follows. We first learn a softmax classifier $h^{[0]}$ over the entire dataset $X$. We then use the output $h_0(x)$ to make better prediction for unlabeled data and concatenate it training data labels $y^{[1]}$. Then we update the dynamic feature vectors, the ones that need labels to be computed. More precisely, $X^{[1]} = \{f(x_i^{[0]}, y_i^{[1]}) : x_i \in X\}$ is constructed by the output of the classifier $h_0$ for unlabeled data which is better estimation than maximum frequency that we used in first iteration. Then, these new set of feature vectors $X^{[1]}$ and labels $y^{[1]}$ are used to train a softmax classifier. We repeat this process iteratively for $T$ steps. At each intermediate step $t$, we have that $X^{[t]} = \{f(x_i^{[t-1]}, y_i^{[t]}) : x_i \in X\}$ is constructed by the output of the previous step for unlabeled cells. These features in fact induce a \emph{deep-learning-like} framework where at each stage, we are adding non-linear transformations from the previous stage. However, unlike deep models, we do not train the previous layers but those are fixed to the values we learned before. Due to space constraints, this discussion is only included with the appendix (Section \ref{sec:deep}). We finally output $h_T$. At each stage, we use a multi-class softmax as a classifier. Other choices for classification function are possible, namely multi-class logisitic regression \cite{kleinbaum2002logistic}, decision trees \cite{shalev2014understanding} etc. In this paper, we stuck with the choice of softmax regression as it gave good empirical performance as shown in the experiments sections.
In some record fusion applications, it might not be possible to get a large set of labelled entities. In such situations, augmenting the training set with additional points might be very helpful. Even in cases where we have a large number of training examples, data augmentation can prove to be helpful. We generate and add artificial entities from existing entities using standard transformation techniques. The output is a set of additional clusters that are legitimate to be used for training. Due to space constraints the details of data augmentation are included in the appendix. (Section \ref{sec:augment}).
\vspace{-4pt}
\subsection{Inferencing with Variable Domain Size}
\label{section:inferenceAlgorithm}
\vspace{-7pt}
During inference, our goal is to predict the correct value for each column for each of the entities $E_k$. We have two different type of inference. For a column $j$, we have learned a classifier $f_j$ which outputs a $\rho_j$-dimensional vector for each cell. If the $E_k$ is part of $G_U$ then $y^{[T]}_U$ is the prediction. But if $E_k\not\in \mc C$, we first use $h_0, \ldots, h_T$ to obtain the feature vector of the cells in $E_k$. Then, for each of the $|E_k|$ values for the $j^{th}$ column, we can use our classifier to obtain $|E_k|$ different $\rho_j$-dimensional vectors. Now, we have two problems. The first is \textit{ how to fuse the $|E_k|$ predictions of the clusters into a single output?}. The second question is given a $\rho_j$-dimensional output \textit{how to do we use that to get one value for that cell?}
Both of these questions can be answered in several different ways. For the first question, our approach is to simply take an average of all the different vectors to obtain a single vector. Other more sophisticated approaches are possible but for now this gave us a good empirical performance. Again, for the second question, we choose the index which has the maximum value for the probability vector amongst the first $|E_k|$ indices and ignored the output values in indices from $|E_k|+1$ up to $\rho_j$ this analogous to re-normalize the distribution over the first $|E_k|$ indices and then take the maximum from that range. Again, instead of an $\argmax$ other probabilistic approaches like selecting an index with probability proportional to its value is possible. But the simple approach gave good empirical performance as shown by our extensive experiments.
\vspace{-2pt}
\section{Experiments}
\label{sec:exp}
\vspace{-1pt}
We evaluate our record fusion framework using real datasets with various rules. We answer the following questions: (1) how well does record fusion framework work as data fusion system compared to the state-of-the-art data fusion systems when the source information of the entries is known.
\begin{table}
\vspace{-15pt}
\center
\scriptsize
\caption{Datasets used in our experiments.}
\label{tab:datasets}
\begin{threeparttable}
\begin{tabular}{|c|c|c|c|c|}
\hline
{\bf Dataset} & {\bf Size} & {\bf Clusters} & {\bf Attributes} & {\bf \# Sources}\\ \hline
Flight & 57222 & 2313 & 6 & 37 \\
Stock 1 & 113379 & 2066 & 10 & 55 \\
Stock 2 & 107260 & 1954 & 8 & 55 \\
Weather & 43003 & 13689 & 6 & 11 \\
Address & 3287 & 494 & 6 & N/A\tnote{*} \\
\hline
\end{tabular}
\begin{tablenotes}
\item[*] N/A = Address dataset basically has been generated without sources.
\end{tablenotes}
\end{threeparttable}
\vspace{-10pt}
\end{table}
(2) how well does it perform when the source of entries are not available compared to \cite{deng2017unsupervised} and Majority Vote. (3) what is the impact of different representation contexts on data fusion. (4) how well our cluster augmentation and iterative algorithm can solve the problem of learning from noisy and incomplete data. We use five benchmark datasets with different domain properties and usage described in Table~\ref{tab:datasets}. We compare our approach, referred to as $HF_S$ when we have sources and $HF_W$ when sources are unavailable, against several the-state-of-art methods. (see Appendix Section \ref{exp:setup} for more details).
\begin{table*}[]
\center
\scriptsize
\caption{Precision's Median, Average, and Variance of different methods for different datasets.}
\label{tab:endres}
\begin{threeparttable}
\begin{tabular}{c c|c c c c c c| c c c}
\shortstack{Dataset\\ ($\mathcal{T}$ size)}& Prec & $HF_S$ & Count & ACCU & CATD & SSTF & SlimFast & $HF_W$ & MV & USTL+MV \\ \hline \hline
\multirow{3}{*}{\shortstack{Flight\\ (5\%)}} & Med & \bf 0.998 & 0.901 & 0.878 & 0.952 & 0.739 & 0.220 & \bf 0.959 & 0.296 & 0.305\\
& Avg & 0.998 & 0.882 & 0.892 & 0.939 & 0.732 & 0.241 & 0.947 & 0.176 & 0.337\\
& StE & $3.4 \times10^{-4}$ & $0.0$ & 0.005 & 0.013 & 0.021 & 0.003 & 0.008 & 0.202 & 0.105\\ \hline
\multirow{3}{*}{\shortstack{Stock 1\\ (5\%)}} & Med & \bf 0.997 & 0.815 & 0.906 & 0.971 & 0.688 & 0.323 & \bf 0.985 & 0.051 & 0.050\\
& Avg & 0.997 & 0.862 & 0.917 & 0.941 & 0.632 & 0.343 & 0.989 & 0.035 & 0.062\\
& StE & 0.002 & 0.021 & 0.014 & 0.023 & 0.005 & 0.006 & 0.003 & 0.024 & 0.034\\\hline
\multirow{3}{*}{\shortstack{Stock 2\\ (5\%)}} & Med & \bf 0.988 & 0.840 & 0.853 & 0.823 & 0.779 & 0.767 & \bf 0.938 & 0.765 & 0.856\\
& Avg & 0.991 & 0.825 & 0.812 & 0.737 &0.652 & 0.795 & 0.935 & 0.782 & 0.856\\
& StE & 0.014 & 0.006 & 0.013 & 0.009 &0.031 & 0.028 & 0.013 & 0.064 & 0.107\\ \hline
\multirow{3}{*}{\shortstack{Weather\\ (5\%)}} & Med & \bf 0.997 & 0.909 & 0.702 & 0.706 & 0.537 & 0.517 & \bf 0.794 & 0.721 & 0.738\\
& Avg & 0.992 & 0.849 & 0.762 & 0.707 & 0.613 & 0.541 & 0.787 & 0.741& 0.732\\
& StE & 0.004 & 0.018 & 0.009 & 0.017 & 0.011 & 0.003 & 0.021 & 0.060 & 0.023\\ \hline
\multirow{3}{*}{\shortstack{Address\\ (10\%)}} & Med & n/a\tnote{*} & n/a & n/a & n/a & n/a & n/a & \bf 0.912 & 0.817 & 0.822\\
& Avg & n/a & n/a & n/a & n/a & n/a & n/a & 0.899 & 0.740 & 0.780\\
& StE & n/a & n/a & n/a & n/a & n/a & n/a & 0.019 & 0.231 &0.183\\ \hline \\
\end{tabular}
\vspace{-8pt}
\begin{tablenotes}
\item[*] n/a = Address dataset basically has no source information, so source-needed algorithms cannot be executed.
\end{tablenotes}
\end{threeparttable}
\vspace{-4pt}
\end{table*}
\vspace{-4pt}
\subsection{End-to-End Performance}
\label{exp:e2e}
\vspace{-7pt}
Table~\ref{tab:endres} summarizes the precision's Median, Average, and Variance of methods and as it shows, our method consistently outperforms all other methods. For {\it Flight},{\it Stock 1}, {\it Stock 2}, and {\it Weather}, we set the amount of training data to be $5\%$ of the total dataset. For Address, we set the percentage of training data to be $10\%$ (corresponding to 40 clusters) since Address is small.
In the no sources information case, we see improvements of 70 points for {\it Flight} and {\it Stock 1}. More importantly, we find that our method is able to achieve low standard error in all datasets despite the different cluster and true record representation distribution in each dataset. This is something that seems challenging for prior data fusion methods and reduce their results consistency and reliability. Despite the fact that source information is an important factor for other algorithms, $HF_W$ can obtain high precision.
This is because $HF_W$ models estimates the actual data distribution by extracting source signatures using attribute correlation from datasets. For instance, for {\it Address}, we see that \emph{MV} can find many of the true record representations---it has high precision---indicating that most true record representations correspond to statistical frequency. Overall, our method achieves an average precision of $91\%$ without sources information, and an average precision of $99\%$ when sources information available across these diverse datasets, while the performance of competing methods varies significantly and they are not consistent on all datasets.
\begin{figure*}
\centering
\makebox[\textwidth][c]
{\includegraphics[width=1.1\textwidth]{ablationsinglebig.pdf}}
\vspace{-10pt}
\caption{Ablation studies to evaluate the effect of different representation models.}
\label{fig:singAblation}
\vspace{-10pt}
\end{figure*}
\vspace{-4pt}
\subsection{Representation Ablation Study}
\vspace{-7pt}
We perform an ablation study to evaluate the effect of different representation models on the quality of our system. Specifically, we compare the performance of $HF_W$ when all representation models are used versus variants of $HF_W$, where a set of representation models is removed at a time.
\vspace{-10pt}
\paragraph{Single Representation Effect:} In Figure \ref{fig:singAblation}, we report the precision of the different variants as well as the original $HF_W$. It is shown that removing any feature has an impact on the quality of predictions of our model. More importantly, we find that different representation models have a different impact on various datasets. For instance, the most significant drop for {\it Stock1} and {\it Weather} is achieved when the co-occurrence model is removed, while for {\it Flight} and {\it Address}, the highest drop is achieved when the voting model is removed.
Therefor, the representation models that we considered have a positive impact on the performance of our system. As it can be seen in Figure \ref{fig:singAblation}, for example, in dataset {\it Fight}, we see that removing \emph{Running-cluster value} representation from model has the minimum impact on the performance, and if we see the parameters of this representation after it trained, they have values that almost ignore the impact of this signal.
\vspace{-10pt}
\paragraph{Group Contexts Effect}
Figure \ref{fig:groupAblation} shows the effect of a group of representation models corresponding to different contexts. Removing any contexts group has an impact on the quality of predictions of our model. Furthermore, for datasets that have various properties, different context groups have the most prominent effect on the performance of $HF_W$. This validates our design of considering representation models from different contexts. Therefore, it is necessary to leverage cluster representations that are informed by different contexts to provide robust and high-quality data fusion solutions.
\begin{figure}
\centering
\begin{minipage}{.4\textwidth}
\centering
\captionsetup{width=.9\linewidth}
\includegraphics[width=\linewidth]{gablation.pdf}
\captionof{figure}{Ablation studies to evaluate the effect of different representation model groups.}
\label{fig:groupAblation}
\end{minipage}%
\begin{minipage}{.3\textwidth}
\centering
\captionsetup{width=.9\linewidth}
\includegraphics[width=\linewidth]{itereffect.pdf}
\captionof{figure}{The effect of increasing the number of clusters via data augmentation.}
\label{fig:iter}
\end{minipage}%
\begin{minipage}{.3\textwidth}
\centering
\captionsetup{width=.9\linewidth}
\includegraphics[width=\linewidth]{rob.pdf}
\captionof{figure}{The effect of increasing the number of clusters via data augmentation.}
\label{fig:rob}
\end{minipage}
\vspace{-20pt}
\end{figure}
\vspace{-4pt}
\subsection{Effects of Iterations on Performance}
\vspace{-7pt}
In this experiment, we validate the importance of the iterative process to improve learning performance. Figure \ref{fig:iter} shows the results of \emph{HF} for a various number of iterations. The results validate that as the number of iterations increases, we were able to get more accurate predictions. This observation has significant meaning for the performance of \emph{HF} as getting more accurate predictions in each iteration results in recalculating the dynamic features more accurately in each round. For instance, in Weather, \emph{HF} was able to achieve precision less than $0.7$ with only one iteration; however, after $15$ iterations, the precision was improved over $10$ points. Therefore, the recurrent process is an effective approach for calculating accurately dynamic features.
\vspace{-4pt}
\subsection{The Augmentation Process Robustness}
\vspace{-7pt}
Figure \ref{fig:rob} shows the performance of the augmentation process for different training data sizes. In summary, we find that the augmentation is robust and can achieve high precision even if the training data consist only $0.2\%$ of the clusters in the dataset.
\vspace{-5pt}
\section{Conclusion}
\label{sec:conc}
\vspace{-8pt}
We introduce a machine learning framework for {\it record fusion}, which the underlying challenge in two well-known classical problems: {\it data fusion} \cite{dong2009integrating,dong2013compact,rekatsinas2017slimfast} and {\it golden record} \cite{deng2017unsupervised}. We learn rich data representation models, and resolve the training data shortage via data augmentation. We iteratively obtain and apply a model that can predict the correct label for unlabeled data. Our proposal outperformed previously proposed models, especially for the absence of source information.
\section{Broader Impact}
Record fusion is the main technology in almost all entity resolution and knowledge reconciliation efforts, which are crucial steps in building large scale knowledge bases and knowledge graphs. These consistent knowledge bases are powering many important downstream applications, including question answering and training large machine learning models. The arms race to construct these knowledge graphs among all major tech companies such as Google, Microsoft, and Amazon is a strong evidence on the impact of record fusion solutions. Most current record fusion methods are even simple methods to estimate the reliability of sources, or complicated and hard-to-maintain rule-based engines that do not scale with web-scale knowledge graphs. We believe that our proposal to automate record fusion, while taking into account all previous approaches as signals/features, provides a principled, holistic and an extensible solution that scales well to modern large knowledge graphs. We are currently in talks to deploy this proposal with major knowledge graph creators.
\vspace{1em}
{\fontsize{15}{100}\selectfont \textbf{Appendix}}
\begin{appendix}
\section{Related Work}
\label{sec:rel}
Several pieces of research have been done on combining data from multiple sources. Bleiholder et al. \cite{bleiholder2006conflict} surveyed existing strategies for resolving inconsistencies in structured data. The data fusion methods can be categorized into four main regimes:
\begin{itemize}
\item \textbf{Na\"ive method}: In this method, all sources have a vote, and the correct value for each object is decided by choosing the value that has maximum votes among all the conflicting values.
\item \textbf{Source-based}: The main goal of these methods is to calculate how accurate each source is. More specifically, the votes of the sources do not have the same "weight." The importance of each vote depends on the quality of the source.
\item \textbf{Relation-based} These methods use the main idea of Source-based methods. They also consider the correlation between the sources (e.g., if a pair of sources copy from each other).
\item \textbf{Transformation-based} These methods reduce cluster size by transforming values to each other and use human-in-the-loop to fuse remained set.
\end{itemize}
In the field of discovering dependencies between data sources, many works have been done as well. In \cite{dong2009integrating}, Dong et al. applied Bayesian analysis to decide on dependencies between sources. In \cite{dong2010global}, Dong et al. also consider various types of copying on different data items. Moreover, the authors in \cite{dong2009truth} explore the idea of integrating data and determining the way the sources are interacting with each other by examining the update history of the sources.
Besides, there has been a lot of research in the field of evaluating trustworthiness resulting in algorithms such as {\it PageRank} which assigns trust based on link analysis and TrustFinder\cite{yin2008truth} which decides about the importance of a source based on its behavior in a P2P network. Moreover, in \cite{dong2012less}, Dong et al. examine the problem of selecting a subset of sources before integration. The authors claim that by choosing only the sources that can be beneficial for their algorithm, they can achieve higher performance than by using all the available sources and data.
Furthermore, in \cite{pasternack2010knowing}, Pasternack and Roth solve the data fusion problem by creating an iterative model. The main idea of their fact-finding algorithm was to incorporate prior knowledge from the users into their process, to integrate data from conflicting claims.
In \cite{rekatsinas2017slimfast}, Rekatsinas et al. propose the SLiMFast framework to solve the data fusion problem as a learning and inference problem over discriminative probabilistic graphical models. The method of this paper is also the first that came with guarantees on its error rate for the estimation of the source accuracy.
Finally, in \cite{deng2017unsupervised} human-in-the loop is used to solve entity consolidation; instead of using sources, the system simulates source information for entity resolution by asking information from an oracle. To the best of our knowledge, this is the only method that can work without source information.
\subsection{Deduplication process}
Since the input of record fusion problem is the output cluster of deduplication process, we give the following example.
\begin{example}
Figure \ref{fig:example2} shows a tabular data containing tuple id's, person names, occupation, and address and illustrates the task of a typical deduplication approach. Deduplication produces a table with the clustering of those records, where each cluster refers to the same real-world entities. The process of finding the true records for entities is called \say{golden record problem}. In this setting, there is no information about sources, as all records might have come from the same source.
\begin{figure}[h]
\centering
\includegraphics[width=\columnwidth]{example2.pdf}
\caption{ A typical deduplication task.}
\label{fig:example2}
\end{figure}
\end{example}
\section{Feature design}
\label{sec:features}
Regarding to the feature design described in Section \ref{sec:featuredesign}, we have Alg \ref{alg:attributeFeatures} for Attribute-Level features \ref{sec:attrfeat}, Alg \ref{alg:recordFeatures} for Record-Level features \ref{sec:recfeat}, and Alg \ref{alg:databaseFeatures} for Database-Level features \ref{sec:datafeat}.
\begin{algorithm}
\SetAlgoLined
\KwIn{Database $D$.\\
\hspace{35pt}Cell $d_{ij}$ with row $i$ and column $j$ such that $Id(i) = k$.\\
\hspace{33pt} Set $E_{kj}$ of all possible values for the $k^{th}$ entity on the $j^{th}$ column.\\
\hspace{33pt} An embedding matrix $M$ which maps all elements in $E_{kj}$ to a vector in $\mb R^m$.\\
}
\vspace{5pt}\KwOut{Vector $v_{ij}$ representing the attribute-level features for $d_{ij}$.}
\vspace{10pt} Map $d_{ij}$ is a string $t_{ij}$ over the alphabet $\{A, N, S\}$\;
\ForEach{character $c$ in $d_{ij}$}{
If $c$ is a letter then map $c$ to `A' \;
If $c$ is a number then map $c$ to `N' \;
If $c$ is a space character then map $c$ to `S' \;
}
Let $u_{ij}$ be the nine dimensional vector representing the counts of all $2$-grams of $p_{ij}$\;
\ForEach{$d'_{ij}$ in $E_{kj}$}{
Compute the $m$-dimensional embedding of $d'_{ij}$ using the matrix $M$. Denote it by $a'_{ij}$ \;
}
Compute the average of the embeddings and denote by $a$.\;
Let $w_{ij} = dist(a_{ij}, a)$\;
Make $\rho_j$-dimensional vector $x_{ij}$ of zeros\;
\If{$\neg$(first iteration)}{
Use the model prediction in previous iteration and put one in corresponding dimension in $x_{ij}$\;
}
\vspace{5pt}\textbf{return} $v_{ij} := [u_{ij}, w_{ij}, x_{ij}]$
\caption{Attribute-level features}
\label{alg:attributeFeatures}
\end{algorithm}
\begin{algorithm}[h]
\SetAlgoLined
\KwIn{Database $D$.\\
\hspace{36pt}Cell $d_{ij}$ with row $i$ and column $j$ such that $Id(i) = k$.\\
\hspace{33pt} Set $E_k$. All rows corresponding to the $k^{th}$ entity. \\
}
\vspace{5pt}\KwOut{Vector $v_{ij}$ representing the record-based features for $d_{ij}$.}
\vspace{10pt} \ForEach{column $j' \neq j$}{
Let $n_{j'}$ be the number of occurrences of $(d_{ij}, d_{ij'})$ over $E_k$\;
Let $m_{j'}$ be the number of occurrences of $d_{ij'}$ over attribute $j'$ in $E_k$\;
}
Let $u_{ij} = [\ldots, \frac{n_{j'}}{m_{j'}}, \ldots]$ be the $c-1$ dimensional vector representing the co-occurrence counts of the given attribute $d_{ij}$\;
Let $w_{ij} = \frac{t}{|E_k|}$where $t$ is the number of occurrences of $d_{ij}$ over $E_{kj}$ \;
\vspace{5pt}\textbf{return} $v_{ij} := [u_{ij}, w_{ij}]$
\caption{Record-level features}
\label{alg:recordFeatures}
\end{algorithm}
\begin{algorithm}[h]
\SetAlgoLined
\KwIn{Database $D$.\\
\hspace{36pt}Source matrix $S$ of size $n \times k$. (Optional)\\
\hspace{36pt}Cell $d_{ij}$ with row $i$ and column $j$ such that $Id(i) = k$.\\
\hspace{33pt} Set $E_k$ of all rows belonging to the $k^{th}$ entity. \\
\hspace{33pt} Set $\Sigma_j$ of denial constraints for the $j^{th}$ column.\\
\hspace{33pt} An embedding matrix $M$ which maps all elements of the $j^{th}$ column to $\mb R^m$.\\
\hspace{33pt} An embedding matrix $Q$ which maps all rows to $\mb R^q$.
}
\vspace{5pt}\KwOut{Vector $v_{ij}$ representing the database-level features for $d_{ij}$.}
\vspace{10pt} \ForEach{row $d_{i'} \in E_k$}{
Compute the $q$-dimensional embedding for $d_{i'}$ using matrix $Q$. Call it $a_{i'}$\;
Compute the $m$-dimensional embedding for $d_{i'j}$using matrix $M$. Call it $b_{i'j}$\;
Let $n_{i'} = [a_{i'}, b_{i'j}]$
}
Let $n = avg(n_{i'})$ be the average embedding vector \;
Let $u_{ij} = dist(n_i, n)$\;
\vspace{5pt} Let $w_{ij} = []$ \\
\ForEach{$\sigma \in \Sigma_j$}{
Compute $x = |\{ \text{rows make violation with row i w.r.t. }\sigma\}|$. That is compute the number of violations of the constraint $\sigma$ assuming the value $d_{ij}$ is correct\;
$w_{ij}.append( x)$
}
Let $S_i$ be the $k$-dimensional vector indicating the source information for the $i^{th}$ row.\\
\vspace{5pt}\textbf{return} $v_{ij} := [u_{ij}, w_{ij}, S_i]$
\caption{Dataset-level features}
\label{alg:databaseFeatures}
\end{algorithm}
\section{Learning algorithm}
\subsection{Relation to iterative learning}
Another way to view Alg. \ref{alg:il} is through the framework of iterative learning or `dynamic' features. Consider the original set of features in the data $X$. To this set of features, we have a set of dynamic vectors. Denote the new dataset by $X'$. If $X_S$, the static part of $X$ has dimension $\nu$ and the dynamic parts of $X$ has $\psi$ then $X$ and $X'$ have dimension $\nu + \psi$. The $\psi$-dimensional vector represents the set of dynamic features. We initialize the dynamic features by the all zero vector. Observe that Alg. \ref{alg:il} is identical to the algorithm with dynamic features as stated in the corollary below.
\begin{algorithm}
\small
\SetAlgoLined
\KwIn{
Training dataset $Z' = (X', y)$. \\
\hspace{35pt} Number of iterations $T$.
}
\KwOut{Classifier $h: X' \rightarrow y'$}
\vspace{10pt} Let the dynamic features of $X$ be equal to zero.\\
\vspace{5pt}\For{$t=1$ to $T$}{
Let $h_t$ be the softmax classifier obtained by training on $(X', y)$\\
Let $y'$ be the set of new labels, that keep the training set label and update the rest\\
Let the new features of $X'$ be equal to $f(X',y')$. \\
}
\vspace{5pt}\textbf{return} $h_T$
\caption{Iterative learning with dynamic features}
\label{alg:ilAlternate}
\end{algorithm}
\begin{corollary}
Given $Z = (X, y)$ such that $y \in \{1, \ldots, \rho\}$. Let $X' = (X_S, \mb 0_{\psi})$ where $\mb 0_{\psi}$ denotes the $\psi$-dimensional vector of all zeros. Consider an iterative version of softmax classification on the set $Z' = (X', y)$ defined in Alg. \ref{alg:ilAlternate}. Then, the Alg. \ref{alg:il} is identical to the formulation in Alg. \ref{alg:ilAlternate} with dynamic features.
\end{corollary}
\subsection{Relation to deep learning}
\label{sec:deep}
In the previous sections, we saw how our algorithm can be viewed as a stagewise model or a model with dynamic set of features. In this section, we look at another interpretation; namely, its relation to deep learning. At each stage, our model does the following computation.
\begin{align*}
& y^{[t]}_U=\{y^{[t]}_i=h^{[t-1]}(X^{[t-1]}):\forall i\in I_U\}\\
& y^{[t]}=y_T\cup y^{[t]}_U \\
& X^{[t]} \enspace=\enspace f(X^{[t-1]}, y^{[t]}) \enspace \text{where we have that }\\
&h_{t-1}(X^{[t-1]}) \enspace =\enspace softmax(\thinspace W_{t-1} \enspace X^{[t-1]} \thinspace)
\end{align*}
Note that in standard deep learning architectures, $X^{[t]} = \zeta_{t-1}(X^{[t-1]})$. In our architecture, we also concatenate it with the original set of features $X_S$. While in deep learning the number of hidden states is varied and is a hyper-parameter, in this framework the number of `hidden states' is fixed at $\psi + \nu$ (the sum of dimension of dynamic and static vectors).
Another important distinction is regarding the training algorithm. The standard deep networks are trained with backpropogation which updates the weights of all the layers of the network in one backward pass. In this case, we train the network in a greedy manner. We first train the first layer of the network by using the softmax loss on its output. The learned weights are then used to compute the input features of the next layer. And then the process is repeated. Observe that this corresponds to `freezing' the weights of the previous layers and only training the weights of the current layer. We refer to this way of training as \textit{greedy-layerwise} training.
\begin{figure}
\centering
\begin{tikzpicture}
\draw (0.5,1) node[circle,draw]{};
\draw [loosely dotted](0.5,1.5) node{} -- (0.5,3.5) node{};
\draw (0.5,4) node[circle,draw]{};
\draw (0.5,5) node[circle,draw]{};
\draw (0.5,6) node[circle,draw]{};
\draw (0,0.5) node{} -- (0,4.5) node{}-- (1,4.5) node{} -- (1,0.5) node{} --cycle;
\draw (0.5,0) node{$X^{[t-1]}$};
\draw (3.5,1) node[circle,draw]{};
\draw [loosely dotted](3.5,1.5) node{} -- (3.5,3.5) node{};
\draw (3.5,4) node[circle,draw]{};
\draw (3.5,5) node[circle,draw]{};
\draw (3.5,6) node[circle,draw]{};
\draw (3,0.5) node{} -- (3,4.5) node{}-- (4,4.5) node{} -- (4,0.5) node{} --cycle;
\draw (3.5,0) node{$X^{[t]}$};
\draw (6.5,1) node[circle,draw]{};
\draw [loosely dotted](6.5,1.5) node{} -- (6.5,3.5) node{};
\draw (6.5,4) node[circle,draw]{};
\draw (6.5,5) node[circle,draw]{};
\draw (6.5,6) node[circle,draw]{};
\draw (6,0.5) node{} -- (6,4.5) node{}-- (7,4.5) node{} -- (7,0.5) node{} --cycle;
\draw (6.5,0) node{$X^{[t+1]}$};
\draw (0.5,1) node{} -- (3.5, 5) node{};
\draw (0.5,1) node{} -- (3.5, 6) node{};
\draw (0.5,6) node{} -- (3.5, 5) node{};
\draw (0.5,6) node{} -- (3.5, 6) node{};
\draw (0.5,5) node{} -- (3.5, 5) node{};
\draw (0.5,5) node{} -- (3.5, 6) node{};
\draw (0.5,4) node{} -- (3.5, 5) node{};
\draw (0.5,4) node{} -- (3.5, 6) node{};
\draw (3.5,1) node{} -- (6.5, 5) node{};
\draw (3.5,1) node{} -- (6.5, 6) node{};
\draw (3.5,6) node{} -- (6.5, 5) node{};
\draw (3.5,6) node{} -- (6.5, 6) node{};
\draw [loosely dotted](2,3.75) node{} -- (2,4.25) node{};
\draw [loosely dotted](5,4) node{} -- (5,5) node{};
\end{tikzpicture}
\caption{ The nodes in the box represent the original set of features $X$. The two nodes outside represent the `dynamic features'. At every layer $t$, non-linear function of the features of the previous layer are added to the model. Compared to traditional deep learning, in this case the original set of input features are always passed to next layer.}
\label{fig:deep}
\vspace{-20pt}
\end{figure}
The logical steps are illustrated in Fig. \ref{fig:deep}. The input features are shown in the box and are copied through all the layers of the network. The nodes outside the boxes correspond to the `dynamic' features which have a dimension of $\psi$. Each layer first computes a linear mapping of the features of the previous layer using the computation $W X^{[t-1]}$. Then a non-linearity (in this case a softmax function) is applied to the linear map. Hence, deeper and deeper layers represent more and more complex non-linear transformations of the original input space.
\section{Data Augmentation}
\label{sec:augment}
In the previous sections, we described our featurization techniques and the learning algorithm. Together they are sufficient as a learning framework for the record fusion problem. However, in this section we go a step further and also propose a data augmentation mechanism.
In some record fusion applications, it might not be possible to get a large set of labelled entities. In such situations, augmenting the training set with additional points might be very helpful. Even in cases where we have a large number of training examples, data augmentation can prove to be helpful in the following way. Recall that the domain of record fusion suffers from the homogeneity versus heterogeneity problem. That is, all the entities are quite `different' from one another while records within the same entity (or cluster) are `similar'. In such cases, a data augmentation approach introduces clusters which are similar to existing clusters and enables better model generalization.
\begin{algorithm}
\SetAlgoLined
\KwIn{
Database $D$.
}
\KwOut{Augmented entities $\hat E_1, \ldots, \hat E_o$}
\vspace{5pt}Select a `source entity' $E_s \in D$ uniformly at random. \\
\ForEach{cell $d_{ij} \in E_s$ which does not belong to the ground truth}{
Use Alg. \ref{alg:stringToAlphabet} to map $d_{ij}$ to another string $g_{ij}$ over the alphabet $\Lambda$.\\
Select a `target entity' $E_t \in D$ and then select row $d_{i'} \in E_t$ uniformly at random.\\
Using the same procedure as above, map $d_{i'j}$ to $g_{i'j}$.\\
Compute $b$, the longest common sub-string between $g_{ij}$ and $g_{i'j}$. \\
Use the reverse mapping (Alg. \ref{alg:stringToAlphabet}) to map $b$ back to the augmented string $\hat d_{ij}$. \\
Add $\hat d_{ij}$ to the augmented entity $\hat E$
}
Repeat the above procedure to get $o$ augmented entities.
\caption{Entity augmentation}
\label{alg:data_aug}
\end{algorithm}
Our data augmentation procedure is described in Alg. \ref{alg:data_aug}. Before we discuss the procedure in greater detail, lets first introduce some notation.
\begin{definition}[Format alphabet]
Let $\mc S_1$ be the set of all the letters of the English alphabets (small case and capitalized). Let $\mc S_2 = \{s \in S_1^+ : |s| > 1\}$ be the set of all strings of letters of length greater than one. Similarly, let $\mc T_1 = \{0, \ldots, 9\}$ and $\mc T_2 = \{s \in T_1^+ : |s| > 1\}$. Also denote by $\mc U = \{space, \#, \$, ? , \ldots\}$ the set of `special' characters. Define the set of symbols $$\Lambda = \{\mc S_1, \mc S_2, \mc T_1, \mc T_2\} \bigcup_{s \in \mc U} s$$
\end{definition}
Given a string in our database, we map it to the set of symbols $\Lambda$. Roughly, this captures the `format' of the input string. For example, consider that the cell of a database has the value \textit{`New York-\#401H3'}. Our mapping algorithm will map it to the string \textit{$\mc S_2 space \mc S_2 \# \mc T_2 \mc S_1\mc T_1$}. Inuitively, this captures the format that the input contains a letters followed by a space followed by letters etc. In this way we represent the source string $d$ as a format string $g$. Next, we repeat the same procedure to get the target format string $g'$ from the target string $d'$. This gives us information that the source string could also have the format $g'$ instead of $g$. Hence, our augmentation procedure involves `editing' the string $d$ to obtain another string $\hat d$ such that the format of $\hat d$ is the same as $g'$. Thus by repeating this process for all the cells of the entity, we obtain the augmented entity $\hat E$.
Two details are missing from the discussion in the above paragraph. Firstly, how the mapping algorithm works and secondly how to `edit' a given string with format $g$ to match another format $g'$. Lets look at the former first. The editing or augmentation step then follows from that.
\begin{algorithm}
\SetAlgoLined
\KwIn{ String $d$.}
\KwOut{
String $g \in \Lambda^+$ which is mapping onto the format space.\\
\hspace{38pt} $\tau^{-1}$ which maps each character of $g$ to a substring of $d$.
}
\vspace{5pt} Let $g = \emptyset$\\
\ForEach{character $c \in d$}{
If $c$ is an english alphabet letter, add $\mc S_1$ to $g$.\\
Else if $c$ is a number, add $\mc T_1$ to $g$.\\
Else add $c$ to $g$.
}
Change $g$ by replacing all consecutive occurences of $\mc S_1$ of length greater than one by $\mc S_2$. \\
Similarly, replace all consecutive occurences of $\mc T_1$ of length greater than one by $\mc T_2$. \\
\ForEach{character $f \in g$}{
Let $\tau^{-1} (f)$ be the substring in $d$ which mapped to $f$.
}
Return $g$ and $\tau^{-1}$.
\caption{Format mapping}
\label{alg:stringToAlphabet}
\end{algorithm}
The algorithm works by first mapping the given string to another string over the alphabet $\{\mc S_1, \mc U_1\} \cup_{s \in \mc U} s$. We then map all consecutive occurences of $\mc S_1$ to $\mc S_2$. For example, let the source string be $d = $\textit{`New York-\#401H3'}. Then, $d$ is first mapped to \textit{$\mc S_1\mc S_1\mc S_1space\mc S_1\mc S_1\mc S_1\mc S_1-\#\mc T_1\mc T_1\mc T_1\mc S_1\mc T_1$}. In the second step, all the consecutive occurences of $\mc S_1$ and $\mc T_1$ are mapped to $\mc S_2$ and $\mc T_2$ respectively. Hence, the final format representation for $d$ is $g = \mc S_2 space \mc S_2-\#\mc T_2 \mc S_1 \mc T_1$. The mapping $\tau^{-1}$ keeps track that the first $\mc S_2$ corresponds to the string \textit{`New'}, the seconf $\mc S_2$ corresponds to \textit{`York'} and so on.
Once the mapping algorithm is known, the `editing' or augmentation process is fairly straightforward. Let the target string be $d' = $\textit{`Toronto-\#21LG'} which maps to the format $g' = \mc S_2-\#\mc T_2 \mc S_2$. In this case the longest common sub-string between $g$ and $g'$ is $\mc S_2-\#\mc T_2$. Using the (inverse) mapping $\tau^{-1}$, this gives back the augmented string as $\hat d = $\textit{York-\#401}. And this is added as a cell to the corresponding augmented entity.
\section{Experiments}
\subsection{Experimental Setup}
\label{exp:setup}
We describe the datasets, metrics, and settings that we use in our experiments. We use five benchmark datasets with different domain properties and usage described in Table~\ref{tab:datasets}.
\begin{table*}
\center
\small
\caption{ Data augmentation performance for various amounts of training data $\mathcal{T}$.}
\label{tab:tdaug}
\begin{tabular}{c l|c c c c c c c}{}
Dataset & $\mathcal{T}$ & $HF_{w/o AUG}$& 0.05 & 0.1& 0.3&0.5&0.7&1\\ \hline \hline
\multirow{3}{*}{Flight} & 5\% & 0.779 & 0.869 & 0.919&\bf 0.958 & 0.949 & 0.946 & 0.928\\
& 10\% & 0.802 & 0.893 & 0.924&\bf 0.967& 0.956 & 0.950 & 0.937\\ \hline
\multirow{3}{*}{Stock 1} & 5\% & 0.826 & 0.942 & \bf 0.985&0.928 & 0.939 & 0.920 & 0.914\\
& 10\% &0.843 & 0.966 &\bf 0.992&0.957 & 0.942 & 0.934 & 0.944\\ \hline
\multirow{3}{*}{Stock 2} & 5\% & 0.825&\bf 0.923 & 0.913&0.902 & 0.903 & 0.903 & 0.901\\
& 10\% &0.853 &\bf 0.938 & 0.928&0.924 & 0.923 & 0.915 & 0.913\\ \hline
\multirow{3}{*}{Weather} & 5\% & 0.737 & 0.749 & \bf 0.798&0.763 & 0.755 & 0.749 &0.760\\
& 10\% & 0.770 & 0.782 &\bf 0.805&0.790 & 0.774 & 0.766 & 0.763\\ \hline
\multirow{3}{*}{Address} & 5\% & 0.837 & 0.874 & 0.904&0.903 & \bf 0.913 & 0.912 & 0.904\\
& 10\% & 0.869 & 0.904 & 0.915&0.914 &\bf 0.930 & 0.927 & 0.910\\ \hline
\end{tabular}
\vspace{-10pt}
\end{table*}
\textit{Stock 1 and 2} contain data from $55$ stock sources from popular financial aggregators such as \emph{Yahoo! Finance}, \emph{Google Finance}, and \emph{MSN Money}, official stock-market websites such as \emph{NASDAQ}, and financial-news websites such as \emph{Bloomberg} and \emph{MarketWatch}. \emph{Stock 1} contains 2066 objects (clusters) and the ground truth is created by assuming that \emph{NASDAQ} always provides the correct value. \emph{Stock 2} contains 1954 objects and the ground truth is created by taking the majority value provided by five stock data providers \cite{li2012truth}.
\textit{Flight} is a benchmark dataset that contains $37$ sources from the flight domain. The sources include $3$ airline websites (\emph{AA}, \emph{UA}, Continental), $8$ airport websites (such as \emph{SFO}, \emph{DEN}), and $26$ third-party websites, including \emph{Orbitz}, \emph{Travelocity}, etc. The dataset focused on $2313$ flights departing from or arriving at the hub airports of the three airlines (\emph{AA}, \emph{UA}, and Continental). Each cluster is a specific flight on a particular day \cite{li2012truth}. The ground truth was created by taking the majority value of three sources, including the source \emph{AA}, which always has the correct value.
\textit{Weather} is collected for $30$ major USA cities from $11$ websites about every $45$ minutes. We consider \emph{(city, time)} as the key. There are in total $33$ collections in a day, thus the dataset contains $990$ clusters. The attributes are manually mapped, and there are $6$ distinct attributes.
The ground truth is created by taking the majority value provided by all the sources.
\textit{Address} reflects applications for discretionary funding to be allocated by the New York City Council. For each record, we select attributes that represent legal information, address and geographical properties of location. The minimum size of each cluster is two and the ground truth has been extracted from \emph{ISBNsearch} organization website. An interesting feature of the \emph{Address} dataset is that it does not contain any source information.
These datasets are used as standard benchmarks for data fusion algorithms. Notice that we are given data rules (denial constraints) only for \textit{Weather} and \textit{Address} datasets. (see Figure \ref{fig:rob})
We compare our approach, referred to as $HF_S$ when we have sources and $HF_W$ when sources are unavailable, against several data fusion methods. First, we consider five baseline data fusion models that they need sources information: \textit{Counts}: This corresponds to Na\"ive Bayes. Source accuracies are estimated as the fraction of times a source provides the correct value for an object in ground truth. \textit{ACCU}: This is the Bayesian data fusion method introduced by Dong et al. \cite{dong2009integrating} (without source copying). \textit{CATD}: A fusion method introduced by Li et al. \cite{li2014confidence} and extends source reliability scores with confidence intervals to account for sparsity in source observations. \textit{SSTF}: This data fusion method by Yin et al. \cite{yin2011semi} leverages semi-supervised graph learning to exploit the presence of ground truth data. \textit{SlimFast}: A data fusion framework by Rekatsinas et al. \cite{rekatsinas2017slimfast} based on statistical learning over discriminative probabilistic models.
We also compare to two approaches that require no sources information. \textit{Majority Vote (MV)}: In each cluster-attribute, we consider the maximum frequency value as the true record representation. \textit{USTL+MV}: This entity consolidation method, which was introduced by Dong et al. \cite{deng2017unsupervised}, uses human-in-the-loop to request user to verify the equivalence of records, and minimizes the number of queries by transforming values in an unsupervised way. Then the \emph{Majority Vote} can be used to obtain correct records.
\begin{table*}[t]
\center
\small
\caption{ Iterative algorithm performance for various amounts of training data $\mathcal{T}$.}
\label{tab:tditer}
\begin{tabular}{c l|c c c c c}{}
Dataset/Aug & $\mathcal{T}$ & 1& 2 & 5& 10&15\\ \hline \hline
\multirow{3}{*}{Flight/0.3} & 5\% & 0.682 & 0.712 & 0.853& 0.930 & \bf 0.953\\
& 10\% & 0.707 & 0.725 &0.881& 0.944& \bf 0.966\\ \hline
\multirow{3}{*}{Stock 1/0.5} & 5\% & 0.813 & 0.859 & 0.928&0.966 &\bf 0.984\\
& 10\% &0.834 & 0.865& 0.933&0.969 &\bf 0.991\\ \hline
\multirow{3}{*}{Stock 2/0.05} & 5\% & 0.746& 0.763 & 0.808&0.899 &\bf 0.923\\
& 10\% &0.764 & 0.784 & 0.843&0.911 &\bf 0.937\\ \hline
\multirow{3}{*}{Weather/0.1} & 5\% & 0.694 & 0.713 & 0.770&0.785 &\bf 0.797\\
& 10\% & 0.714 & 0.742 & 0.784&0.799 &\bf 0.807 \\ \hline
\multirow{3}{*}{Address/0.5} & 5\% & 0.710 & 0.749 & 0.843&0.896 &\bf 0.912\\
& 10\% & 0.721 & 0.754 & 0.888&0.907 &\bf 0.929\\ \hline
\end{tabular}
\vspace{-15pt}
\end{table*}
\vspace{3pt}\noindent{\bf Evaluation Setup:} To measure precision, we use Precision (P) defined as the fraction of true record representation predictions that are correct. For training, we split the available ground truth into three disjoint sets: (1)~a training set $T$, used to find model parameters; (2)~a validation set, which is used for hyper parameter tuning; and (3)~a test set, which is used for evaluation. To evaluate different dataset splits, {\em we perform $50$ runs with different random seeds for each experiment}. To ensure that we maintain Precision, we report the median performance. The mean performance along with standard error measurements are also reported. {\em Seeds are sampled at the beginning of each experiment, and hence, a different set of random seeds can be used for different experiments.} We use {\it ADAM}~\cite{kingma2014adam} as the optimization algorithm for all learning-based model and train all models for 500 epochs with a batch-size of ten examples. We run Platt Scaling for 50 epochs. All experiments were executed on a 12-core Intel(R) Xeon(R) CPU E5-2603 v3 @ 1.60GHz with 64GB of RAM running Ubuntu 14.04.3 LTS.
\begin{figure}[ht]
\centering
\vspace{-5pt}
\includegraphics[width=0.5\linewidth]{augeffect.pdf}
\caption{The effect of increasing the number of clusters via data augmentation.}
\vspace{-5pt}
\label{fig:aug}
\end{figure}
\subsection{Labeled Data Size Effect}
In these experiments, we evaluate the effect of the size of the training data on the performance of the augmentation policy and the iterative algorithm.
\subsubsection{Effect on Augmentation Performance}
Table \ref{tab:tdaug} shows the data augmentation performance for various amounts of training data. In all datasets, increasing the size of training data from $5\%$ to $10\%$ increase the performance. Moreover, in most datasets, the size of the labeled data does not affect the best augmentation ratio. Only in the {\it Address}, we see that to achieve the best precision, the augmentation ratio is $0.7$ when we have $5\%$ of the dataset as training data in contrast with the $0.5$ ratios when the training data are the $10\%$ of the dataset. This is likely behavior is due to the fact that {\it Address} is generally small, thus by using only $5\%$ as training data, our augmentation algorithm needs to create more augmented clusters for training.
\subsubsection{Effect on Iterative Algorithm Performance}
In Table \ref{tab:tditer}, the iterative algorithm performance for various amounts of training data can be observed. As was expected, the increase in training data enhances the performance of the iterative algorithm. It can also be observed that \emph{HF} needs at least 15 iterations in order to converge to the best precision independently of the training size.
\subsection{Effects of Augmentation on Performance}
We evaluate the effectiveness of data augmentation to counteract the lack of training data. Figure \ref{fig:aug} shows that using data augmentation yields high-quality record fusion models for datasets with varying sizes and properties (as they were described in section \ref{exp:setup}). Hence, data augmentation is robust to different domains of properties.
We also evaluate the effect of excessive data augmentation: We manually set the ratio between the initial clusters and the lately generated cluster in the final training examples and use augmentation to materialize this ratio. Our results are reported in Figure \ref{fig:aug}. We see that peak performance is achieved when the ratio between the two types of clusters is about 10\% to 30\% for all datasets.We can conclude that data augmentation is an effective and robust way to counteract the lack of enough training data.
\section{Record Fusion System Overview}
\begin{center}
\begin{figure*}
\centering
\makebox[\textwidth][c]{\includegraphics[width=1.12\textwidth]{overview-fin.pdf}}
\caption{Overview of Record Fusion with Augmentation.}
\label{fig:overview}
\end{figure*}
\end{center}
An overview of how the different modules are connected is shown in Figure \ref{fig:overview}. First, Module 1 augments training data with additional artificial clusters. Then, Module 2 grounds the representation model of our record fusion model. Subsequently, the representation model is connected with the multi-class classifier model in Module 3, after generating record representation, the model gets feedback from Module 4, and so it changes the representation and the predictions.
\end{appendix}
\bibliographystyle{abbrv}
| {'timestamp': '2020-06-19T02:06:20', 'yymm': '2006', 'arxiv_id': '2006.10208', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10208'} | arxiv |
\section{Introduction} \label{sec:intro}
\IEEEPARstart{A}{s} a fundamental task in computer vision, visual object tracking has received lots of attention over the last decades.
It plays an important role in many applications such as autonomous driving, robotics, human-computer interaction, etc.
In generic visual tracking, the target is arbitrary with only the initial bounding box available.
With such limited prior information, the tracker is still highly required to both model the target appearance and distinguish the negative samples on the fly, which is challenging due to the blurry boundary between appearance changes of the target itself and unforeseen similar distractors.
\begin{figure}[t]
\centering
\includegraphics[width=8.3cm]{op_example.pdf}
\includegraphics[width=8.8cm]{op_plot.pdf}
\caption{{\bf Top}: the tracking results of SiamRPN++ \cite{siamrpn++}, ATOM \cite{ATOM}, and our approach on the \emph{Bolt2} video. Note that the prior motion model is removed in these methods. {\bf Bottom}: the per-frame overlap between the tracking results and ground-truth bounding box on the \emph{Bolt2}. Without the cosine window, previous methods tend to switch between the target and distractors (e.g., $ 5 $-th and $ 75 $-th frame), while ours steadily tracks the target without drift.}
\label{fig:1}
\end{figure}
Recently, thanks to the strong representational power of deep CNN models, a simple two-stream template matching based Siamese pipeline \cite{SiamFC, SINT} has been proved effective in visual tracking, even without the online model update.
However, as reported in the Visual Object Tracking (VOT) challenge \cite{VOT2018}, the robustness of Siamese trackers still has a margin with the discriminative trackers equipped with an update mechanism.
In the latest literature \cite{DiMP,SiameseUpdate}, substantial attentions have been cast to the updatable deep trackers with superior discrimination capability.
Despite the rapid advances, in the tracking and updating stages, how to distinguish similar distractor objects from the target and effectively leverage these hard negative samples to boost the model discrimination capability still leaves exploration space.
There exist vast uninformative samples that can be easily distinguished without much effort (i.e., easy sample), while a handful of distracting examples heavily mislead the tracker, enlarging the error accumulation and causing the tracking failures (Figure~\ref{fig:1}).
These unexpectedly emerged distractors, even though being the minority, have a non-trivial effect on degrading the tracking performance, and deserve to be carefully checked \emph{online} for robust tracking.
In this paper, we propose a cascaded regression tracker, which consists of two sequential stages with different regression models for high-performance visual tracking.
In the first stage, we employ an efficient convolutional regression \cite{ATOM} to densely predict all the searching locations, which filters out plentiful easy samples.
In the second stage, we only consider the remaining ambiguous candidates and propose a discrete sampling based ridge regression for further discrimination.
The ridge regressor performs as an alternative of the fully-connected layer but exhibits superior efficiency thanks to its closed-form solution.
These two stages complement each other as follows.
The dense prediction with the convolutional regressor in the first stage \cite{ATOM} covers a large search area, while its model tends to be disturbed by an overwhelming number of easy samples.
In contrast, the second-stage regressor trained using the carefully selected hard samples naturally avoids the class-imbalance issue and yields better discrimination on distractors, while its sampling manner fails to perfectly cover the search area and will increase the computational cost when drawing plentiful candidates.
By virtue of such a dense-to-discrete and coarse-to-fine two-tier verification, these two stages contribute to a superior robust tracking system.
More importantly, both of them allow to update the corresponding models, achieving the \emph{online} adaptability.
During online tracking, to enhance the tracker discrimination, we employ the hard negative mining \cite{example-based_HNM,felzenszwalb2009object_HNM} for the second stage.
Moreover, we dynamically reweigh the training samples based on their reconstruction errors in an adaptive ridge regression formula, forcing the second-stage regressor to focus more on valuable samples.
Benefited from the high robustness, the second-stage regressor is able to re-detect the lost target when the first stage fails to confidently track the target, and search a large region without excessively worrying about the risk of tracking drift.
As a consequence, our framework differs from most existing short-term trackers typically focusing on a limited search region with a prior cosine window to penalize the far-away distractors (e.g., Siamese trackers \cite{SiamFC,SiamRPN}).
It is worth mentioning that our method shows outstanding performance on \emph{both} short-term and long-term tracking datasets without adding additional sophisticated modules thanks to our excellent online discrimination capability.
We summarize the contributions of our work as follows:
\begin{itemize}
\setlength{\parskip}{0pt}
\item We propose a discrete sampling based ridge regression, which can flexibly absorb the online hard samples and is efficient to learn under a closed-form formula. Furthermore, we propose a cascaded regression tracker, which achieves favorable robustness via a dense-to-discrete large-scale search and a coarse-to-fine two-tire verification.
\item To improve the online distractor discrimination, we propose an adaptive ridge regression to further exploit the valuable samples selected by the hard negative mining technique \cite{example-based_HNM,felzenszwalb2009object_HNM}. With the merit of promising discrimination, the second-stage regressor also serves as an effective re-detection module to complement the first stage.
\item We extensively evaluate the proposed method on 11 short-term and long-term tracking benchmarks including OTB-2013 \cite{OTB-2013}, OTB-2015 \cite{OTB-2015}, Temple-Color \cite{TempleColor128}, UAV123 \cite{UAV123}, VOT2018 \cite{VOT2018}, VOT2019 \cite{VOT2019}, NfS \cite{NFSdataset}, TrackingNet \cite{2018trackingnet}, LaSOT \cite{LaSOT}, UAV20L \cite{UAV123}, and OxUvA \cite{2018longtermBenchmark}. The proposed approach exhibits state-of-the-art performance on prevalent datasets with a real-time speed.
\end{itemize}
In the following of the paper, we first survey related works in Section \ref{sec:related}. Then, we elaborate the proposed cascaded framework in Section \ref{sec:method}. After that, we evaluate our method with extensive experiments in Section \ref{sec:experiments}. Finally, we conclude this work in Section \ref{sec:conclusion}.
\section{Related Work} \label{sec:related}
In recent years, the Siamese network has gained significant popularity in visual tracking, which deals with the tracking task by searching for the image region most similar to the initial template \cite{SiamFC,SINT}.
The GOTURN algorithm \cite{GOTURN} adopts a Siamese pipeline to regress the target bounding box.
By introducing the RPN module \cite{SiamRPN,DaSiamRPN}, ensemble learning \cite{SASiam}, attention mechanism \cite{RASNet}, and target-aware formulation \cite{TADT}, the Siamese trackers gain substantial improvements.
Besides visual tracking, similar ideas such as one-shot learning \cite{caelles2017one-shotSegmentation} and online adaptation scheme \cite{voigtlaender2017onlineSegmentation} are widely explored in the video object segmentation task.
Without video annotations, the unsupervised deep tracking framework is explored in UDT \cite{UDT}.
In \cite{siamrpn++}, SiamRPN++ adopts a deeper backbone network to achieve superior performance.
By switching multiple Siamese trackers using an agent network, POST tracker \cite{POST} achieves a good balance of accuracy and efficiency.
Recently, model update mechanisms are incorporated with the Siamese network \cite{GCT,Dsiam,MemTrack,SiameseUpdate}.
However, these approaches mainly focus on the template adaptation and still fail to exploit the background context.
Since most Siamese trackers ignore the informative negative samples for discrimination enhancement, they tend to drift when similar distractors appear.
Recently, the cascaded framework has been investigated within the Siamese tracking framework \cite{CRPN,SPM}.
SPM \cite{SPM} combines the SiamRPN with a relation network to further classify the candidates. C-RPN \cite{CRPN} utilizes cascaded region proposal networks for accurate target localization.
Nevertheless, they do not involve the online model update. The overlook of online emerged samples heavily limits the performance.
In other words, how to take advantage of the hard negative samples to distinguish potential distractors in future frames is ignored in the recent cascaded frameworks.
Compared with them, the main distinction of this work is that our cascaded framework is built on two complementary regression models, both of which are able to absorb the online samples for the persistent model update.
\begin{figure*}[t]
\centering
\includegraphics[width=18.1cm]{main4.pdf}
\caption{{\bf Top}: an overview of our cascaded regression tracker. In the first stage, we employ a convolutional regression for dense response prediction. In the second stage, a discrete sampling based ridge regression is designed to discriminate the ambiguous candidates. {\bf Bottom}: online model update for the second-stage regressor. Based on the tracking result, only hard negative samples are selected to update the memory buffer. Besides, the training samples in the buffer are dynamically reweighed for adaptive regressor learning.}
\label{fig:main}
\end{figure*}
Another popular tracking family is the regression based approach, which generally regresses a large Region of Interest (RoI) to a response map for target localization.
The Correlation Filter (CF) solves the ridge regression in the Fourier domain, showing extremely attractive efficiency \cite{KCF,DSST,HCF,CSR-DCF,target_response_CF,SCT,ACFN,Context-AwareCorrelationFilter,MCCT,C-COT}.
To alleviate the unwanted boundary effect, regularization terms \cite{ASRCF,SRDCF,STRCF} and background-aware formulation \cite{BACF} are proposed.
ECO tracker \cite{ECO} introduces a factorized convolution operator, a generative sample space model, and the sparse update strategy to further boost the efficiency of correlation tracking.
Recently, by jointly compressing and transferring the heavyweight feature extractors in deep CF trackers, CPU real-time efficiency is also feasible \cite{CF-VGG}.
Besides CF, with the recent astonishing development of deep learning, convolutional regression gains an increasing attention in visual tracking \cite{CREST,DSLT,ATOM,DiMP}.
In these approaches, a CNN kernel is learned to convolve with the RoI feature for response generation, which effectively avoids the boundary effect in CF.
Unfortunately, this convolutional formulation does not have a closed-form solution, and needs the gradient back-propagation to learn the filter.
Besides, the large RoI size in the regression approach brings in the class-imbalance issue.
In CREST \cite{CREST}, residual terms are incorporated into the convolutional regression to cope with the target appearance changes.
DSLT \cite{DSLT} introduces shrinkage loss to balance the training samples in the convolutional regression.
To accelerate the kernel learning process, ATOM \cite{ATOM} exploits the conjugate gradient in the deep learning framework.
The recent DiMP approach \cite{DiMP} proposes an iteratively optimized discriminative model for classification and trains the whole framework in an end-to-end manner.
Despite the recent progress, the discrimination capability in regression trackers, especially for hard distractors, still leaves room for improvement.
In contrast to the aforementioned regression methods that generate a dense prediction, previous discriminative trackers learn a binary classifier to classify the discretely sampled candidates for tracking (e.g., MDNet \cite{MDNet}).
In spite of their shallow backbone networks and limited discrete samples (e.g., 256 candidates per frame), by an effective model update with hard negative mining, these approaches \cite{MDNet,RTMDNet,VITAL} still exhibit impressive robustness on various tracking benchmarks, suggesting the importance of online learning.
Our proposed approach is partially inspired by the above observations to retain both the dense and discrete predictions in a coarse-to-fine manner.
Hard negative mining, as a powerful technique in object detection \cite{example-based_HNM,felzenszwalb2009object_HNM}, has been successfully equipped into some discrete sampling based visual trackers such as MDNet \cite{MDNet}.
However, existing regression based trackers fail to effectively explore the hard negative samples since they train the regression model using densely sampled candidates and generally equally weigh them.
The recent ATOM tracker \cite{ATOM} reduces the training weights of easy samples to focus on the valuable negative samples to some extent, but we observe that it still struggles to distinguish hard distractors.
In this work, our first stage densely searches a large RoI to generate high-quality proposals, while the second stage is more flexible in the model update and hard negative mining to better distinguish the hard negative samples.
Even though aiming at predicting discrete samples, unlike \cite{MDNet,RTMDNet,VITAL} that leverage fully-connected layers for classification, we learn an efficient closed-form solver in the feed-forward pass without back-propagation, potentially alleviating the overfitting issue due to much fewer parameters to be optimized online.
By design, we absorb the strength of both regression trackers and discrete sampling based tracking-by-detection approaches to form a unified cascaded tracking framework.
Our method is also motivated by the two-stage framework in object detection (e.g., faster RCNN \cite{FasterRCNN}), which has witnessed tremendous success in recent years.
Differently, we exploit two regression models specially designed for the online tracking task with an incremental model update.
\section{Methodology} \label{sec:method}
In Figure~\ref{fig:main} (top), we show an overview of the proposed cascaded tracker. In the first stage, a convolutional regressor densely predicts the target location over a large RoI.
Then, the ambiguous proposals are fed to the second regression stage for further discrimination.
Under such a dense-to-discrete and coarse-to-fine verification, the proposed tracking framework achieves favorable tracking robustness.
In Figure~\ref{fig:main} (bottom), we exhibit the online update process of the second-stage regression model.
By virtue of the hard negative mining and an adaptive ridge regression formulation, the learned regressor is readily ready for distinguishing hard distractors.
In the following, we first review the regression based tracking in Section~\ref{review regression tracking} for the sake of completeness.
In Section~\ref{discrete ridge regression}, we present our discrete sampling based ridge regression and provide a detailed analysis in comparison with the previous methods.
Then, in Section~\ref{online tracking}, we depict the cascaded regression tracking and re-detection mechanism.
Finally, we introduce the details of the online model update in Section~\ref{model update}.
\subsection{Revisiting Regression Tracking} \label{review regression tracking}
In this subsection, we briefly review the correlation filter and convolutional regression.
{\flushleft \bf Correlation Filter.} The correlation filter (CF) \cite{DSST,KCF} tackles visual tracking by solving the following regression problem:
\begin{equation}\label{eq1}
\min_{{\bf W}_{\text{CF}}}\|{\bf X}\star{{\bf W}_{\text{CF}}}-{{\bf Y}_{\text{G}}}\|^{2}_{2} + \lambda\|{{\bf W}_{\text{CF}}}\|^{2}_{2},
\end{equation}
where $ \star $ denotes the circular correlation, $ \lambda $ is a regularization parameter that controls overfitting, $ {\bf X}\in\mathbb{R}^{M\times N\times C} $ is the feature map of the RoI patch, $ {\bf Y}_{\text{G}}\in\mathbb{R}^{M\times N} $ is the Gaussian-shaped label, and $ {{\bf W}_{\text{CF}}}\in\mathbb{R}^{M\times N\times C} $ is the desired correlation filter.
Let $ \bf A $ denote the data matrix that contains all the circulant shifts of the base feature representation $ \bf X $. Then, the circular correlation $ {\bf X}\star{{\bf W}_{\text{CF}}} $ is equal to $ {\bf A}{{\bf W}_{\text{CF}}} $, and the filter $ {\bf W}_{\text{CF}} $ has the following closed-form solution \cite{rifkin2003regularized,KCF,bertinetto2018meta}:
\begin{equation}\label{eq2}
{{\bf W}_{\text{CF}}} = ({\bf A}^{\mathrm{T}}{\bf A}+\lambda {\bf I})^{-1}{\bf A}^{\mathrm{T}}{{\bf Y}_{\text{G}}},
\end{equation}
where $ \bf I $ is the identity matrix. Due to the circulant structure of $ \bf A $, it can be diagonalized via $ {\bf A}={\bf F}~\text{diag}(\hat{\bf X})~{\bf F}^{\mathrm{H}} $, where $ \hat{\bf X} $ is the Discrete Fourier Transform (DFT) of $ \bf X $, $\bf F $ is the DFT matrix and $ {\bf F}^{\mathrm{H}} $ is the Hermitian transpose of $ \bf F $.
Therefore, Eq.~\ref{eq2} results in a very efficient element-wise multiplication solution in the Fourier domain without matrix inversion.
Please refer to \cite{KCF} for more details.
{\flushleft \bf Convolutional Regression.} The convolutional regression \cite{CREST,DSLT,ATOM} considers the following minimization problem:
\begin{equation}\label{eq3}
\min_{{\bf W}_{\text{Conv}}} \|{\bf X}\ast {{\bf W}_{\text{Conv}}} - {{\bf Y}_{\text{G}}}\|^{2}_{2} + \lambda\|{{\bf W}_{\text{Conv}}}\|^{2}_{2}.
\end{equation}
Different from the circular correlation in Eq.~\ref{eq1}, the $ \ast $ operation in Eq.~\ref{eq3} denotes the standard multi-channel convolution, which is the core component in CNNs.
Without a closed-form formula, the solution of Eq.~\ref{eq3} can be optimized via the standard gradient descent as follows:
\begin{equation}\label{solution of eq3}
{\bf W}_{\text{Conv}}^{i+1} = {\bf W}_{\text{Conv}}^{i} - \alpha \nabla {\cal L}({\bf W}_{\text{Conv}}^{i}),
\end{equation}
where $ \alpha $ is the learning rate of the gradient descent and $ {\cal L}(\cdot) $ denotes regression error presented in Eq.~\ref{eq3}.
Given the feature map $ {\bf X}\in\mathbb{R}^{M\times N\times C} $, the learned filter (or convolutional kernel) $ {{\bf W}_{\text{Conv}}}\in\mathbb{R}^{m\times n\times C} $ regresses the feature map $ \bf X $ to the desired Gaussian label $ {\bf Y}_{\text{G}} $.
Note that the correlation filter $ {{\bf W}_{\text{CF}}} $ in Eq.~\ref{eq1} has the same spatial size with $ \bf X $, while the convolutional filter $ {{\bf W}_{\text{Conv}}} $ requires to be smaller than $ \bf X $, i.e., $ m<M,~n<N $, as shown in Figure~\ref{fig:comparison} (b).
\subsection{Discrete Sampling based Ridge Regression} \label{discrete ridge regression}
In the CF and convolutional regression, the learned filters regress the RoI to a dense response map.
This continuous prediction generally brings in the class-imbalance issue \cite{DSLT}, where plentiful uninformative samples will overwhelm the valuable ones in the filter training.
Actually, there is no need to limit ourselves to the dense prediction in a regression scheme.
To focus on the hard samples, we propose a simple, flexible yet effective Discrete Sampling based Ridge Regression (DSRR).
The \emph{discrete} lies in two aspects: (1) The training data are sampled discretely (Figure~\ref{fig:comparison} (c)), which is similar to the classic classification based tracking approach \cite{MDNet}.
By carefully selecting the training samples, the learned filter pays more attention to the hard negative samples and naturally avoids the class-imbalance issue.
(2) The label is discrete (binary) instead of the soft Gaussian shape, which introduces the label margin between positive and hard negative samples.
As shown in Figure~\ref{fig:comparison} (c), the learned discrete ridge regressor can be interpreted as a fully-connected layer with a single node, but provides a fast solution in a single pass to learn the model instead of learning with time-consuming back-propagation.
\begin{figure}[t]
\centering
\includegraphics[width=8.7cm]{comparison.pdf}
\caption{Illustration of correlation filter, convolutional regression, and our discrete sampling based ridge regression.}
\label{fig:comparison}
\end{figure}
To train this regressor, we represent each sample by a high-dimensional feature embedding via a CNN mapping function $ \varphi({\bf X}, {\bf B}_i) $, whose inputs consist of the base feature map $ \bf X $ and the $ i $-th sample's bounding box $ {\bf B}_i\in\mathbb{R}^{4} $.
These training samples are discretely sampled with binary labels, representing the target or background.
As shown in Figure~\ref{fig:main}, the mapping function $ \varphi(\cdot) $ first refines the backbone feature $ \bf X $ through two convolutional layers, and further generates the feature embedding via an RoI pooling operation followed by a fully-connected layer.
Then we assemble these feature embeddings to form the data matrix $ {\bf D}=[\varphi({\bf X},{\bf B}_1), \cdots,\varphi({\bf X},{\bf B}_P)]^{\mathrm{T}} \in\mathbb{R}^{P\times L} $, which contains $ P $ embeddings and each of them is $ L$-dimensional.
Based on the overlap ratios between candidates' boxes $ {\bf B} $ and ground-truth box, these feature embeddings are assigned by positive or negative labels. Leveraging data matrix $ \bf D $ and its binary label $ {\bf Y}_{\text{B}} $, the discrete sampling based ridge regressor $ {\bf W}_{\text{DSRR}} $ can be obtained by solving the following minimization problem:
\begin{equation}\label{eq4}
\min_{{\bf W}_{\text{DSRR}}}\|{\bf D} {{\bf W}_{\text{DSRR}}} -{{\bf Y}_{\text{B}}}\|^{2}_{2} + \lambda\|{{\bf W}_{\text{DSRR}}}\|^{2}_{2},
\end{equation}
where $ {\bf Y}_{\text{B}}\in\mathbb{R}^{P} $ is the binary label.
{\flushleft \bf Primal Domain.} Since Eq.~\ref{eq4} still follows the standard ridge regression, similar to Eq.~\ref{eq2}, it has the closed-form solution $ {\bf W}_\text{DSRR} = ({\bf D}^{\mathrm{T}}{\bf D}+\lambda {\bf I})^{-1}{\bf D}^{\mathrm{T}}{{\bf Y}_{\text{B}}} $.
Compared with the solution to CF, the main advantage is that this data matrix $ \bf D $ no longer contains fake (cyclically shifted) samples, while the tradeoff is that the Fourier domain solution becomes unfeasible.
In the above solution, the main computational burdern lies in the matrix inverse, whose time complexity is $ O(L^3) $ for the matrix $ ({\bf D}^{\mathrm{T}}{\bf D}+\lambda {\bf I})\in \mathbb{R}^{L\times L}$.
{\flushleft \bf Dual Domain.}
Eq.~\ref{eq4} can also be solved in the dual domain, where the regressor $ {\bf W}_\text{DSRR} $ is expressed by a linear combination of the samples, i.e., $ {\bf W}_\text{DSRR} ={\bf D}^{\mathrm{T}}\bm{\alpha}$.
The variables under optimization are thus $ \bm{\alpha} $ instead of $ {\bf W}_{\text{DSRR}} $.
The dual variables $ \bm{\alpha} $ can be solved by $ \bm{\alpha} = ({\bf D}{\bf D}^{\mathrm{T}}+\lambda {\bf I})^{-1}{{\bf Y}_{\text{B}}} $ \cite{rifkin2003regularized}.
Therefore, the ridge regressor can be computed in the dual domain as follows:
\begin{equation}\label{Eq5}
{\bf W}_\text{DSRR} = {\bf D}^{\mathrm{T}}\bm{\alpha} = {\bf D}^{\mathrm{T}}({\bf D}{\bf D}^{\mathrm{T}}+\lambda {\bf I})^{-1}{{\bf Y}_{\text{B}}}.
\end{equation}
Since $ ({\bf D}{\bf D}^{\mathrm{T}} + \lambda {\bf I})\in \mathbb{R}^{P\times P}$, the matrix inverse in Eq.~\ref{Eq5} has the time complexity of $ O(P^3) $ instead of $ O(L^3) $ in primal domain, which relates to the sample number $ P $ instead of feature dimension $ L $. Thanks to the limited number of hard examples, a small $ K $ is generally practicable.
While in case of a low feature dimension $ L $, the primal domain solution will be more efficient.
Overall, depending on the sizes of $ L $ and $ P $, we can always find a good efficiency balance between the primal and dual solutions.
{\flushleft \bf Offline Training.} In the training stage, we aim to learn a CNN function $ \varphi(\cdot) $ to ensure the learned feature representation suitable for the designed ridge regression.
To this end, we adopt a Siamese-like pipeline in the training stage, where the template branch is utilized to learn the ridge regressor while the search branch is used to generate plentiful test candidates for loss computation.
In the large Region of Interest (RoI), we randomly draw plentiful samples.
The positive and negative samples are collected following the ratio of 1~$:$~3, which have $ \geqslant$~0.7 and $ \leqslant $~0.5 overlap ratios with ground-truth bounding boxes, respectively.
In our experiment, the total sample number is 400 in each frame, i.e., 100 positive samples and 300 negative samples.
Instead of using the prototype $ \varphi(\cdot) $ in Figure~\ref{fig:main} for simplicity, to achieve better performance, we exploit the multi-scale feature representations from both $ \mathrm{Block3} $ and $ \mathrm{Block4} $ of the ResNet-18 \cite{ResNet} as the inputs of two individual $ \varphi(\cdot) $ networks.
The Precise RoI Pooling ($ \mathrm{PrPool} $) \cite{IoUNet} is utilized in $ \varphi(\cdot) $ to crop the $ \mathrm{Block3} $ and $ \mathrm{Block4} $ features, whose output sizes are 5$\times$5 and 3$\times$3, respectively.
The following fully-connected layer maps the pooled features to a 256-dimensional feature vector.
Finally, the $ \mathrm{Block3} $ and $ \mathrm{Block4} $ feature vectors are concatenated along the channel dimension as the 512-dimensional output feature embedding.
Thanks to the closed-form solution of ridge regression, it can be embedded as a differentiable layer for end-to-end training.
Leveraging the regressor $ {\bf W}_\text{DSRR} $ learned via template branch, the regression scores of the test candidates in the search branch can be calculated by $ {\bf Y}_\text{Test} = {\bf D}_\text{Test}{\bf W}_\text{DSRR} $.
To train the network $ \varphi(\cdot) $, we adopt the standard $ L_2 $ loss as the training objective: $ \ell = \|{\bf Y}_\text{Test}- {\bf Y}_\text{GT}\|^{2}_{2} $, where $ {\bf Y}_\text{GT} $ is the ground-truth binary label of the test samples.
After offline training, $ \varphi(\cdot) $ is fixed in the tracking stage.
\begin{figure}[t]
\centering
\includegraphics[width=7.3cm]{cascade_example.pdf}
\caption{Tracking examples of the proposed cascaded framework. In the first stage, we select top three peaks as the high-quality proposals, which are further checked via the second stage. If the first stage fails to predict confidently, we draw plentiful candidates in the second stage for target re-detection.}
\label{fig:tracking instance}
\end{figure}
{\flushleft \bf Connection with Related Methods.}
We compare the CF, convolutional regression, and our discrete sampling based ridge regression in the following 4 aspects.
(1) {\bf Efficiency.} Convolutional regression typically requires gradient back-propagation to learn the filter.
CF exploits the closed-form solution in the Fourier domain, showing extremely attractive efficiency.
The proposed DSRR also has a closed-form solution, yielding satisfactory efficiency.
(2) {\bf Label.} Both CF and convolutional regression predict dense response scores. In contrast, our approach considers discrete proposals, which is flexible to focus on the hard examples and eliminate the class-imbalance issue.
(3) {\bf Effectiveness.} The performance of CF is heavily limited by the boundary effect, i.e., the data matrix $\bf A $ consists of plentiful fake samples. In contrast, the convolutional regression and our DSRR are learned using \emph{real} samples.
(4) {\bf Flexibility.} The CF can only detect the RoI with a fixed size (Figure~\ref{fig:comparison}). In contrast, the convolutional regression and DSRR are more flexible, which can be applied to the RoI of any size and explore a larger area when necessary (e.g., target out-of-view).
Considering the above characteristics, we choose the convolutional regression and discrete ridge regression as the first and second stages in our approach, respectively.
Our discrete ridge regression also shares partial similarity with the classification based approach (MDNet \cite{RTMDNet}). The main distinction is that we learn a closed-form solver to \emph{regress} the proposals instead of leveraging several fully-connected (FC) layers to \emph{classify} them, which is much more efficient via a feed-forward computation without back-propagation to update the FC parameters.
\subsection{Online Tracking} \label{online tracking}
{\flushleft \bf Cascaded Regression Tracking.}
Before tracking, we first learn the aforementioned two regressors using the initial frame.
For the first stage, instead of adopting the stochastic gradient descent (SGD) to learn the convolutional filter, we follow Danelljan \emph{et al.} \cite{ATOM} to use Newton-Gaussian descent as the optimization strategy for fast convergence, and learn a 4$ \times$4 kernel to regress the Gaussian response map.
To learn the second-stage regressor, based on the initial ground-truth label, we crop the positive and negative samples following a ratio of 1~$:$~3 to form the data matrix.
Then, the discrete ridge regressor $ {\bf W}_\text{DSRR} $ is obtained by the primal or dual solution, depending on the sample number and feature dimension. In the initial few frames, the sample number is smaller than the feature dimension (i.e., $P < L$), and we choose the dual domain. With the arrival of new frames, if $ P > L$, we switch to the primal domain.
\begin{figure}[t]
\centering
\includegraphics[width=8.6cm]{hard_negative_mining.pdf}
\caption{An illustration of the hard negative mining and sample reweigh for the proposed adaptive ridge regression learning.}
\label{fig:hard_negative}
\end{figure}
During online tracking, in each frame, top-3 peaks in the first stage's score map are selected, and the corresponding proposals are fed to the network $ \varphi(\cdot) $ to generate the feature embeddings.
These ambiguous proposals are further checked by the second-stage regressor, as shown in Figure \ref{fig:tracking instance}.
Finally, we equally combine the prediction scores of these two stages, and select the highest proposal as the current target.
After target localization, we utilize the IoU predictor proposed in \cite{ATOM} to further refine the target scale.
{\flushleft \bf Cascaded Re-detection.}
As a common strategy in many visual trackers \cite{DiMP,ATOM,MDNet}, we set two reliability thresholds $ \tau_1 $ and $ \tau_2 $ for the two regressors, respectively.
In case that the first stage cannot confidently predict the target, i.e., the highest response score is lower than $ \tau_1 $, we sample abundant candidates (512 per frame) and leverage the second-stage regressor for re-detection, as shown in Figure \ref{fig:tracking instance}.
If the confidence score of the re-detected target exceeds $ \tau_2 $, we regard it as the target. Otherwise, we keep the target position as in the previous frame.
Since the backbone features are shared, this re-detection process and the following model update only involve a slight computational burden.
\subsection{Online Model Update} \label{model update}
{\flushleft \bf Hard Negative Mining.}
Model update is the core component for discriminating the online distractors.
To alleviate the corruption of the memory buffer, we only collect the training samples in reliable frames.
Here, a \emph{reliable} frame represents that both two regressors predict confidently, i.e., their estimated scores exceed $ \tau_1 $ and $ \tau_2 $, respectively.
The first stage is incrementally updated by the Gauss-Newton descent using newly collected RoI samples following \cite{ATOM}. The second stage is expected to distinguish ambiguous samples.
To this end, we discretely draw two times of the desired negative samples and select only half of them with a high regression score, as shown in Figure~\ref{fig:hard_negative}.
These hard training samples are added to the buffer for the model update.
\begin{algorithm}[t]
\caption{Online Model Update}
\begin{algorithmic}[1]
\State \textbf{Input}: Video sequence and initial ground-truth.
\State Initialize two regressors $ {\bf W}_\text{Conv} $ and $ {\bf W}_\text{DSRR} $.
\State Initialize the reliable frame buffer $ {\cal T}=\{1\} $.
\For{$t=2 $ \textbf{to} $N$}
\State Conduct cascaded regression tracking; \Comment{{\small Section 3.3}}
\If{current result is reliable}
\State Collect the current RoI region $ {\cal R}_{t} $; \Comment{{\small first stage}}
\State Draw pos/neg samples $ {\cal S}^{+}_{t} $ and $ {\cal S}^{-}_{t} $; \Comment{{\small second stage}}
\State Drop $ 50\% $ easy negative samples from $ {\cal S}^{-}_{t} $;
\State $ {\cal T}\leftarrow {\cal T}\cup\{t\} $; \Comment{ {\small merge the reliable frame} }
\If{$ |{\cal T}|> \gamma $} \Comment{ {\small maintain a fixed buffer size } }
\State $ {\cal T}\leftarrow {\cal T}\setminus\{\text{min}_{k\in{\cal T}}k\} $; \Comment{{\small drop the oldest index}}
\EndIf
\EndIf
\If{$ t $ \text{mod} 10 $==$ 0 } \Comment{ {\small sparse model update}}
\State Update $ {\bf W}_\text{Conv} $ using $ {\cal R}_{k\in{\cal T}} $; \Comment{{\small first stage}}
\State Update $ {\bf W}_\text{DSRR} $ using $ {\cal S}^{+/-}_{k\in{\cal T}} $; \Comment{{\small second stage}}
\EndIf
\EndFor
\end{algorithmic}
\label{code1}
\end{algorithm}
{\flushleft \bf Adaptive Ridge Regression.}
For the second stage, under consistent model update, the ambiguity degrees of different training samples dynamically change.
Therefore, we further assign a weight $ \beta_i $ to each training sample $ \varphi({\bf X},{\bf B}_i) $ in the memory buffer.
As a result, the discrete ridge regression is re-formulated as follows:
\begin{equation}\label{eq6}
\min_{{\bf W}_{\text{DSRR}}} \sum_i \beta_i\|{\varphi({{\bf X}, {\bf B}_i})} {{\bf W}_{\text{DSRR}}} -{y_i}\|^{2}_{2} + \lambda\|{{\bf W}_{\text{DSRR}}}\|^{2}_{2}.
\end{equation}
By defining a weight matrix $ {\bf M} = [\sqrt{\beta_1},\cdots,\sqrt{\beta_P}]^{\mathrm{T}} $, Eq.~\ref{eq6} can be converted into the matrix form as follows:
\begin{equation}\label{eq6_new}
\min_{{\bf W}_{\text{DSRR}}} \| {\bf M} \odot {\bf D} {{\bf W}_{\text{DSRR}}} -{\bf M} \odot {\bf Y}_{\text{B}}\|^{2}_{2} + \lambda\|{{\bf W}_{\text{DSRR}}}\|^{2}_{2}.
\end{equation}
As a result, the the solution to Eq.~\ref{eq6} can be computed by
\begin{equation}\label{eq7}
{\bf W}_\text{DSRR} = (\widetilde{\bf D}^{\mathrm{T}}\widetilde{\bf D}+\lambda {\bf I})^{-1}\widetilde{\bf D}^{\mathrm{T}}{\widetilde{{\bf Y}_{\text{B}}}} = \widetilde{\bf D}^{\mathrm{T}}(\widetilde{\bf D}\widetilde{\bf D}^{\mathrm{T}}+\lambda I)^{-1}{\widetilde{{\bf Y}_\text{B}}},
\end{equation}
where $ \widetilde{\bf D} = {\bf M}\odot {\bf D} $, $ \widetilde{{\bf Y}_{\text{B}}} = {\bf M}\odot {\bf Y}_\text{B} $, and $ \odot $ is the element-wise product.
We empirically define the weight matrix $ \bf M $ as the reconstruction error of the sample label by previous ridge regressor, as follows:
\begin{equation}\label{eq10}
{\bf M} = \text{norm}\left({\bf Y}_\text{B} - {\bf D}{\bf W}^{t-1}_\text{DSRR}\right) \cdot P,
\end{equation}
where $ {\bf W}^{t-1}_\text{DSRR} $ is the ridge regressor in the previous frame, $ \text{norm}({\bf x}) = {\bf x} / \|{\bf x}\|_1 $ denotes $L_1$ normlization, and $ P $ is the total sample number in the data matrix.
Intuitively, Eq.~\ref{eq10} normalizes the reconstruction errors of different samples and then rescales the weights to ensure the summation of $ \bf M $ equals to $ P $.
A large prediction error means the corresponding sample performs as a hard one for the previously learned $ {\bf W}^{t-1}_\text{DSRR} $, which deserves more attention in the current learning.
In our experiments, a new discrete regressor is learned every 10 frames, and is updated to the previous model in a moving average manner: $ {\bf W}^{t}_\text{DSRR} = (1-\eta){\bf W}^{t-1}_\text{DSRR} + \eta{\bf W}_\text{DSRR} $.
An overview of the above model update process is presented in Algorithm~\ref{code1}.
\section{Experiments} \label{sec:experiments}
\subsection{Implementation Details}
In offline training, we freeze all the weights of the backbone network (ResNet-18 \cite{ResNet}) and adopt a multi-task training strategy to train the network $ \varphi(\cdot) $ and IoU predictor.
Note that the inputs of IoU predictor and ridge regression are different. Following ATOM \cite{ATOM}, the IoU predictor leverages the samples that have a certain overlap with the ground-truth box (at least 0.1). In contrast, our ridge regression branch utilizes the aforementioned positive and negative samples to learn the discriminative model.
The input RoI region is 5 times of the target size and is further resized to 288$ \times $288.
We utilize the training splits of LaSOT \cite{LaSOT}, TrackingNet \cite{2018trackingnet}, GOT-10k \cite{GOT10k}, and COCO \cite{COCO} for offline training.
The model is trained for 50 epochs with 1000 iterations per epoch and 36 image pairs per batch.
The ADAM optimizer \cite{ADAM} is employed with an initial learning rate of 0.01, and use a decay factor 0.2 for every 15 epochs.
The first-stage regressor uses ResNet-18 $ \mathrm{Block3} $ features as in ATOM, while the second-state regressor and the IoU predictor takes both $ \mathrm{Block3} $ and $ \mathrm{Block4} $ backbone features as input.
In online tracking, to update the second-stage regressor, we collect 30 positive and 90 hard negative samples per reliable frame, and maintain a buffer for the last 30 frames.
The learning rate $ \eta $ of the second stage is 0.2.
The reliability thresholds $ \tau_1 $ and $ \tau_2 $ are set to 0.25 and 0.4, respectively.
We denote our \underline{CA}scaded \underline{RE}gression method as {CARE} in the following experiments.
Our tracker is implemented in Python using PyTorch, and operates about 25 frames per second (FPS) on a single Nvidia GTX 1080Ti GPU.
We evaluate our method on each benchmark 3 times and report the average performance.
\subsection{Ablation Experiments}
We utilize the OTB-2015 \cite{OTB-2015}, UAV123 \cite{UAV123}, and LaSOT testing set \cite{LaSOT}, with total 503 videos, to comprehensively verify the effectiveness of our framework.
{\flushleft \bf Cascaded Framework.}
In Table~\ref{table:ablation study}, we compare the performance of each single stage and their cascaded combination.
Note that we draw 512 samples per frame if the second stage is tested alone, aiming to obtain satisfactory performance.
From Table~\ref{table:ablation study}, we can observe that the first and second stages almost perform identically.
The main reason is that the convolutional regression is not discriminative enough, while the discrete sampling strategy fails to well cover a large search region.
By combining them in a cascaded manner, superior performance can be obtained.
For example, on OTB-2015, our final cascaded tracker outperforms the first and second stages by 3.0\% and 3.1\%, respectively.
On the recent large-scale dataset LaSOT, our final framework surpasses the first stage by 3.0\% in AUC.
Note that the first stage in our framework is adopted from the ATOM, which already achieves a high performance level on various challenging datasets.
Under the same backbone network and bounding box regression manner (i.e., IoUNet), our performance gains can be attributed to the superior discrimination capability of our cascaded framework.
As for the tracking speed, with the abundant candidates (512 samples per frame), the second-stage regressor is less efficient than the first stage.
In contrast, our cascaded framework achieves a balanced speed and outstanding performance, which only slightly reduces the first-stage efficiency but notably outperforms it in tracking accuracy.
\setlength{\tabcolsep}{2pt}
\begin{table}[t]
\scriptsize
\begin{center}
\caption{Analysis of each component in our method. We first compare the performance of the first stage, second stage and their cascaded combination. Then, we analyze the second stage by adding re-detection mechanism and adaptive ridge regression (ADRR). The performance is verified on OTB-2015, UAV123, and LaSOT in terms of the area-under-curve (AUC) score of success plot.} \label{table:ablation study}
\begin{tabular*}{8.5 cm} {@{\extracolsep{\fill}}lcccc|ccc|c}
\hline
&First &Second & Re-detection & ADRR & OTB-2015 & UAV123 &LaSOT & Speed \\
&Stage &Stage & & & \cite{OTB-2015} & \cite{UAV123} &\cite{LaSOT} & FPS \\
\hline
&$\checkmark$ & & & &67.5 &63.3 &51.7 &{\bf 30}\\
& &$\checkmark$ & & &68.0 &62.1 &49.3 &20\\
&$\checkmark$ &$\checkmark$ & &&69.2 &64.4 &53.7 &27\\
\hline
&$\checkmark$ &$\checkmark$ &$\checkmark$ &&69.5 &65.0 &54.1 &25\\
&$\checkmark$ &$\checkmark$ &$\checkmark$ &$\checkmark$&{\bf 70.5} &{\bf 65.4} &{\bf 54.7} &25\\
\hline
\end{tabular*}
\end{center}
\end{table}
{\flushleft \bf Target Re-detection.}
As discussed in Section~\ref{online tracking}, our second-stage regressor also acts as a re-detection module due to its high discrimination.
As shown in Table~\ref{table:ablation study}, with additional performance improvements, the re-detection mechanism further exploits the potential of the second stage.
{\flushleft \bf Adaptive Ridge Regression.}
Online model update plays a vital role in our framework. Based on the collected hard samples in the memory buffer, to better concentrate on the valuable ones, we propose an adaptive ridge regression that dynamically reweighs the training samples.
As illustrated in Table~\ref{table:ablation study}, our adaptive ridge regression (ADRR) steadily improves the tracking accuracy.
Besides, it is worth mentioning that our ADRR is extremely efficient with a negligible computational cost.
\subsection{Comparison with State-of-the-art Methods}
We compare our proposed CARE tracker with the recent state-of-the-art trackers on 11 challenging tracking benchmarks including OTB-2013 \cite{OTB-2013}, OTB-2015 \cite{OTB-2015}, UAV123 \cite{UAV123}, LaSOT \cite{LaSOT}, VOT2018 \cite{VOT2018}, VOT2019 \cite{VOT2019}, TrackingNet \cite{2018trackingnet}, Temple-Color \cite{TempleColor128}, UAV20L \cite{UAV123}, Need for Speed \cite{NFSdataset}, and OxUvA \cite{2018longtermBenchmark}.
{\flushleft \bf OTB-2013 \cite{OTB-2013}.} OTB-2013 is a widely evaluated tracking dataset with 50 videos. Figure \ref{fig:otb-50-100} (left) shows the success plot on the OTB-2013.
On this dataset, our method achieves an AUC score of 72.0\%, outperforming all previous state-of-the-art trackers such as VITAL \cite{VITAL} and ECO \cite{ECO}.
Note that the top-performing trackers on this benchmark cannot operate at a real-time speed, e.g., the speeds of VITAL and MDNet are only 1 FPS by using fully-connected layers for candidate classification, while ours is real-time since our closed-form regressor is free of gradient back-propagation.
Compared with other state-of-the-art trackers with the same ResNet backbone (e.g., ATOM), our approach exhibits competitive efficiency with a speed of about 25 FPS.
\begin{figure}[t]
\centering
\includegraphics[width=4.3cm]{CARE_OTB50.pdf}
\includegraphics[width=4.3cm]{CARE_OTB100.pdf}
\caption{Success plots on the OTB-2013 \cite{OTB-2013} (left) and OTB-2015 \cite{OTB-2015} (right) datasets. The legend shows the AUC score. The proposed CARE method outperforms all the comparison trackers.}
\label{fig:otb-50-100}
\end{figure}
{\flushleft \bf OTB-2015 \cite{OTB-2015}.}
OTB-2015 benchmark extends OTB-2013 with additional 50 videos, resulting in 100 videos in total.
Figure \ref{fig:otb-50-100} (right) shows the success plot over 100 videos on the OTB-2015.
Our method achieves an AUC score of 70.5\% on this benchmark, surpassing the recently proposed SiamRPN++ \cite{siamrpn++}, ECO \cite{ECO}, and VITAL \cite{VITAL} trackers.
Compared with the recent single-stage regression trackers such as ATOM \cite{ATOM} and DiMP-18 \cite{DiMP}, our CARE method outperforms them by 3.4\% and 4.3\% in terms of AUC score, respectively.
Note that DiMP-18 is the recently proposed regression method with discriminative model learning, which represents the state-of-the-art performance on several datasets.
{\flushleft \bf UAV123 \cite{UAV123}.}
This dataset includes 123 aerial videos collected by a low-attitude UAV platform.
Therefore, UAV123 focuses on evaluating visual trackers in the UAV scenarios with small and fast-moving targets.
Figure \ref{fig:uav-lasot} (left) illustrates the success plot of the state-of-the-art trackers including SiamRPN++, ATOM, and DiMP-18.
Compared with the recent remarkable approaches, our method achieves the best result.
Especially, our approach shows an AUC score of 65.4\%, outperforming SiamRPN++, ATOM, and DiMP-18 by 4.1\%, 1.9\%, and 2.0\% AUC score, respectively.
Since our approach is equipped with the same backbone network and IoU predictor compared with ATOM and DiMP-18, our performance advantage verifies the superiority of the proposed cascaded tracking framework.
\begin{figure}[t]
\centering
\includegraphics[width=4.3cm]{CARE_UAV.pdf}
\includegraphics[width=4.3cm]{CARE_LaSOT.pdf}
\caption{Success plots on the UAV123 \cite{UAV123} (left) and LaSOT \cite{LaSOT} (right) datasets. The legend shows the AUC score. The proposed CARE method outperforms all the comparison trackers.}
\label{fig:uav-lasot}
\end{figure}
{\flushleft \bf LaSOT \cite{LaSOT}.} LaSOT is a recent large-scale tracking dataset including 1200 videos, which is more challenging than the previous short-term benchmarks with an average of 2500 frames per video.
We evaluate our approach on the test set of 280 videos.
Except for the top-performing trackers like MDNet and VITAL on this dataset, we also include the recent C-RPN \cite{CRPN}, SiamRPN++, ATOM, and DiMP-18 for comparison.
The success plot on LaSOT is shown in Figure~\ref{fig:uav-lasot} (right).
On this dataset, our approach achieves an AUC score of 54.7\%, outperforming the previous best method on this benchmark (i.e., MDNet) by a considerable margin of 15.0\% AUC score.
Compared with the recent C-RPN, SiamRPN++, ATOM, and DiMP-18, our CARE surpasses them by 9.2\%, 5.1\%, 3.3\%, and 1.2\% in AUC, respectively.
\begin{figure}[t]
\centering
\includegraphics[width=8.6cm]{vot.pdf}
\caption{Expected average overlap (EAO) graph with trackers ranked from right to left. Our method obviously outperforms all the participants on the VOT2018 \cite{VOT2018}.}
\label{fig:vot}
\end{figure}
\setlength{\tabcolsep}{2pt}
\begin{table}[t]
\scriptsize
\begin{center}
\caption{Comparison with recent state-of-the-art trackers on the VOT2018 \cite{VOT2018} in terms of robustness (R), accuracy (A), and expected average overlap (EAO).} \label{table:vot}
\begin{tabular*}{8.6 cm} {@{\extracolsep{\fill}}lcccccccc}
\hline
~ & SPM &C-RPN &DWSiam &SiamMask & SiamRPN++ &ATOM &DiMP-18 &{\bf CARE} \\
~ & \cite{SPM} &\cite{CRPN} &\cite{deeperwiderSiamFC} &\cite{SiamMask} &\cite{siamrpn++} &\cite{ATOM} &\cite{DiMP} & \\
\hline
~R &0.30 &- &- &0.276 &0.234 &0.204 &{\bf \color{red} 0.182} &{\bf \color{blue} 0.201}\\
~A &0.58 &- &- &{\bf \color{red} 0.609} &{\bf \color{blue} 0.600} &0.590 &0.594 &0.597\\
~EAO &0.338 &0.289 &0.301 &0.380 &{\bf \color{red}0.414} &0.401 &0.402 &{\bf \color{blue} 0.410} \\
\hline
~FPS &110 &32 &150 &55 &35 &30 &46 &25 \\
\hline
\end{tabular*}
\end{center}
\end{table}
\setlength{\tabcolsep}{2pt}
\begin{table}[t]
\scriptsize
\begin{center}
\caption{Comparison with recent state-of-the-art trackers on the VOT2019 \cite{VOT2019} in terms of robustness (R), accuracy (A), and expected average overlap (EAO).} \label{table:vot19}
\begin{tabular*}{8.5 cm} {@{\extracolsep{\fill}}lccccccc}
\hline
~ & SPM &SiamMask &SiamMask-E & SiamRPN++ &ATOM &SiamDW &{\bf CARE} \\
~ & \cite{SPM} &\cite{SiamMask} &\cite{chen2019SiamMaskRotated} &\cite{siamrpn++} &\cite{ATOM} &\cite{deeperwiderSiamFC} & \\
\hline
~R &0.507 &0.461 &0.487 &0.482 &{\bf \color{blue} 0.411} &0.467 &{\bf \color{red} 0.343} \\
~A &0.577 &0.594 &{\bf \color{red} 0.652} &0.599 &{\bf \color{blue} 0.603} &0.600 &0.601 \\
~EAO &0.275 &0.287 &0.309 &0.285 &0.292 &{\bf \color{blue} 0.299} &{\bf \color{red} 0.323} \\
\hline
~FPS &110 &55 &50 &35 &30 &- &25 \\
\hline
\end{tabular*}
\end{center}
\end{table}
\begin{figure*}
\centering
\includegraphics[width=4.4cm]{LASOT_VC.pdf}
\includegraphics[width=4.4cm]{LASOT_RO.pdf}
\includegraphics[width=4.4cm]{LASOT_ARC.pdf}
\includegraphics[width=4.4cm]{LASOT_DEF.pdf}
\includegraphics[width=4.4cm]{LASOT_FM.pdf}
\includegraphics[width=4.4cm]{LASOT_FO.pdf}
\includegraphics[width=4.4cm]{LASOT_ILL.pdf}
\includegraphics[width=4.4cm]{LASOT_LR.pdf}
\includegraphics[width=4.4cm]{LASOT_MB.pdf}
\includegraphics[width=4.4cm]{LASOT_OV.pdf}
\includegraphics[width=4.4cm]{LASOT_PO.pdf}
\includegraphics[width=4.4cm]{LASOT_SV.pdf}
\caption{Attribute-based evaluation on the LaSOT benchmark \cite{LaSOT} including viewpoint change, rotation, aspect ration change, deformation, fast motion, full occlusion, illumination variation, low resolution, motion blur, out-of-view, partial occlusion, and scale variation. The legend shows the AUC score of the comaprison tracker.}
\label{fig:lasot-attribute}
\end{figure*}
In Figure~\ref{fig:lasot-attribute}, we further provide the attribute evaluation on the LaSOT benchmark \cite{LaSOT}.
On this large-scale dataset, our approach shows good results on fast motion, out-of-view, and viewpoint change.
On the above attributes, our method even surpasses the recently remarkable DiMP-18 tracker \cite{DiMP} by a large margin, which can be attributed to the strong discrimination of our second stage.
Our second-stage regressor further checks the ambiguous candidates and serves as a re-detection module, which significantly improves the tracking performance on the challenging scenarios such as fast motion, out-of-view, and target occlusion.
Besides, our method outperforms its baseline method ATOM \cite{ATOM} in all attributes on the LaSOT dataset.
In particular, our method significantly outperforms ATOM in viewpoint change, low resolution, and partial occlusion by 8.2\%, 4.7\%, and 4.3\%, respectively, which demonstrates the effectiveness of our second stage for cascaded verification.
Since our framework mainly focuses on the target re-identification and re-detection, in the attributes such as aspect ratio change and scale variation, our method is less effective and slightly improves the baseline.
\setlength{\tabcolsep}{2pt}
\begin{table*}[t]
\scriptsize
\begin{center}
\caption{Comparison with state-of-the-art trackers on the TrackingNet \cite{2018trackingnet} test set in terms of precision, normalized precision, and success (AUC score of the success plot).} \label{table:trackingnet}
\begin{tabular*}{18.0 cm} {@{\extracolsep{\fill}}lcccccccccccccccc}
\hline
~ &BACF &Staple &Staple-CA &CSR-DCF &ECOhc &ECO &SiamFC &CFNet &MDNet &UPDT &DaSiamRPN &SPM &C-RPN & ATOM &DiMP-18 &{\bf CARE}\\
~ &\cite{BACF} &\cite{Staple} &\cite{Context-AwareCorrelationFilter} &\cite{CSR-DCF} &\cite{ECO} &\cite{ECO} &\cite{SiamFC} &\cite{CFNet} &\cite{MDNet} &\cite{UPDT} &\cite{DaSiamRPN} &\cite{SPM} &\cite{CRPN} &\cite{ATOM} &\cite{DiMP} &\\
\hline
~Precision &46.1 &47.0 &46.8 &48.0 & 47.6 &49.2 &53.3 &53.3 &56.5 &55.7 &59.1 &66.1 &61.9 &64.8 &{\bf \color{blue} 66.6} &{\bf \color{red} 66.7} \\
~Norm. Prec. &58.0 &60.3 &60.5 &62.2 &60.8 &61.8 &66.3 &65.4 &73.3 &70.2 &73.3 &77.8 &74.6 &77.1 &{\bf \color{blue} 78.5} &{\bf \color{red} 79.0} \\
~Success &52.3 &52.8 & 52.9 &53.4 &54.1 &55.4 &57.1 &57.8 &63.8 &61.1 &63.8 &71.2 &66.9 &70.3 &{\bf \color{red} 72.3} &{\bf \color{blue} 71.8}\\
\hline
~Speed (FPS) &35 &70 &55 &18 &45 &8 &86 &55 &1 &- &{\bf \color{red} 160} &{\bf \color{blue} 110} &32 &30 &46 &25\\
\hline
\end{tabular*}
\end{center}
\end{table*}
\setlength{\tabcolsep}{2pt}
\begin{table*}[t]
\scriptsize
\begin{center}
\caption{Comparison with state-of-the-art trackers on the UAV-20L \cite{UAV123}, Temple Color \cite{TempleColor128}, and Need for Speed \cite{NFSdataset} datasets. The evaluation metric is the AUC score of the success plot.} \label{table:TC_NFS}
\begin{tabular*}{18.0 cm} {@{\extracolsep{\fill}}lccccccccccccccc}
\hline
~ &KCF &DSST &SRDCF &HCF &SiamFC &CFNet &ECOhc &MDNet &C-COT &ECO &SiamRPN &SiamRPN++ & ATOM &DiMP-18 &{\bf CARE}\\
~ &\cite{KCF} &\cite{DSST} &\cite{SRDCF} &\cite{HCF} &\cite{SiamFC} &\cite{CFNet} &\cite{ECO} &\cite{MDNet} &\cite{C-COT} &\cite{ECO} &\cite{SiamRPN} &\cite{siamrpn++} &\cite{ATOM} &\cite{DiMP} &\\
\hline
~UAV20L \cite{UAV123} &19.8 &27.0 &34.3 &- &39.9 &34.9 &- &- &- &43.5 &45.4 &56.1 &55.4 &{\bf \color{blue} 57.1} &{\bf \color{red} 60.3} \\
~TC128 \cite{TempleColor128} &38.4 &40.6 &50.9 &48.2 &50.5 &45.6 &56.1 &56.3 &58.3 &59.7 &- &56.2 &59.3 &{\bf \color{blue} 60.6} &{\bf \color{red} 61.2} \\
~NfS \cite{NFSdataset} &21.7 &28.0 &35.1 &29.5 &- &- &- &42.2 &- &46.6 &- &50.0 &58.4 &{\bf \color{red} 61.0} & {\bf \color{blue} 60.5} \\
\hline
~Speed (FPS) &{\bf \color{red} 270} &45 &5 &12 &86 &55 &45 &1 &0.3 &8 &{\bf \color{blue} 160} &35 &30 &46 &25 \\
\hline
\end{tabular*}
\end{center}
\end{table*}
\setlength{\tabcolsep}{2pt}
\begin{table}[t]
\scriptsize
\begin{center}
\caption{Comparison with state-of-the-art trackers on the OxUvA \cite{2018longtermBenchmark} dataset in terms of true positive rate (TPR), true negative rate (TNR), and maximum geometric mean (MaxGM). MaxGM is the final evaluation metric.} \label{table:OxUvA}
\begin{tabular*}{8.7 cm} {@{\extracolsep{\fill}}lcccccccccccc}
\hline
~&MDNet &LCT &TLD &SiamFC+R &MBMD &SPLT &{\bf CARE}\\
~ &\cite{MDNet} &\cite{LCT} &\cite{TLD} &\cite{SiamFC} &\cite{MBMD} &\cite{SkimmingPerusalTracking} &\\
\hline
~MaxGM &0.343 &0.396 &0.431 &0.454 &0.544 &{\bf \color{blue} 0.622} &{\bf \color{red} 0.749} \\
~TPR & 0.472 &0.292 &0.208 &0.427 &{\bf \color{red} 0.609} &0.498 &{\bf \color{red} 0.609} \\
~TNR & 0 &0.537 &{\bf \color{blue} 0.895} &0.481 &0.485 &0.776 &{\bf \color{red} 0.922} \\
\hline
\end{tabular*}
\end{center}
\end{table}
{\flushleft \bf VOT2018 \cite{VOT2018}.} VOT2018 dataset contains 60 challenging videos for short-term tracking evaluation, which will reset the tracker to the ground-truth position when tracking failure occurs. On this benchmark, trackers are evaluated by the Expected Average Overlap (EAO), which considers both accuracy (average overlap over successful frames) and robustness (failure rate).
From Figure \ref{fig:vot}, we can observe that our approach outperforms all the participants on the VOT2018.
Compared with the recent state-of-the-art approaches, our approach still exhibits satisfactory results.
As shown in Table \ref{table:vot}, our method surpasses the recent regression based methods such as ATOM and DiMP-18 with a relative gain of 2.2\% and 2.0\% in terms of EAO, respectively.
Compared with the cascaded Siamese trackers including SPM \cite{SPM} and C-RPN \cite{CRPN}, our method significantly outperforms them thanks to our online adaptation capability.
Among all the compared trackers, only SiamRPN++ slightly outperforms ours, which adopts a deeper ResNet-50 as the backbone network.
{\flushleft \bf VOT2019 \cite{VOT2019}.} VOT2019 is the recently released challenging benchmark, which replaces 12 easy videos in VOT2018 \cite{VOT2018} by 12 more difficult videos.
Therefore, the EAO scores of the state-of-the-art trackers such as SiamRPN++ drop sharply.
We compare our approach with the representative approaches in Table~\ref{table:vot19}.
Compared with the SiamRPN++ \cite{siamrpn++} and SiamDW \cite{deeperwiderSiamFC} with deeper ResNet-50, our method with a ResNet-18 obviously surpasses them.
The ATOM \cite{deeperwiderSiamFC} is a top-performing single-stage regression tracker, while ours outperforms it with a relative gain of 6.5\% in terms of EAO.
{\flushleft \bf TrackingNet \cite{2018trackingnet}.} The recent TrackingNet benchmark contains more than 30K videos with more than 14 million dense bounding box annotations. The videos are collected on the YouTube, providing large-scale high-quality data for assessing visual trackers in the wild.
We evaluate our method on the test set of the recently released large-scale TrackingNet dataset, which consists of 511 videos.
Note that the recent trackers already achieve outstanding AUC scores of more than 70\%, which means the improvement room on this dataset is limited.
As shown in Table~\ref{table:trackingnet}, the proposed tracker achieves a normalized precision score of 79.0\% and a success score of 71.8\%, which is comparable or superior to previous state-of-the-art trackers such as ATOM and DiMP-18.
{\flushleft \bf Need for Speed \cite{NFSdataset}.}
NfS dataset contains 100 challenging videos with fast-moving targets, which aims at evaluating the tracking robustness in object fast-moving scenarios.
We evaluate our approach on the 30 FPS version of NfS.
The AUC scores of comparison approaches are shown in Table \ref{table:TC_NFS}.
Since the search range is limited in SiamRPN++, its performance is relatively unsatisfactory (10.5\% lower than ours in AUC).
The state-of-the-art DiMP-18 and ATOM represent the top performance on this dataset. Our method is comparable with DiMP-18 and outperforms ATOM by 2.1\% AUC.
{\flushleft \bf Temple-Color \cite{TempleColor128}.} Temple-Color benchmark is a challenging dataset consisting of 128 color videos.
In Table \ref{table:TC_NFS}, we show the AUC score of state-of-the-art trackers on this benchmark.
Compared with the SiamRPN++ with ResNet-50, our method outperforms it by a large margin of 5.0\% AUC score.
The recent single-stage regression tracker ATOM and DiMP yield AUC scores of 59.3\% and 60.6\%, respectively.
The proposed approach also outperforms the recent single-stage regression tracker ATOM and DiMP-18 by 1.9\% and 0.6\% AUC score, respectively.
\setlength{\tabcolsep}{2pt}
\begin{table*}[t]
\scriptsize
\begin{center}
\caption{Comparison results of state-of-the-art deep trackers with different backbone networks. By adoping a deeper backbone network, our CARE tracker gains further performance improvement and is comparable with the recent state-of-the-art DiMP-50 approach \cite{DiMP}.} \label{table:res50}
\vspace{-0.0in}
\begin{tabular*}{17.8 cm} {@{\extracolsep{\fill}}lcccccccccccc}
\hline
~ &Backbone Network &OTB2015 \cite{OTB-2015} &TC128 \cite{TempleColor128} &UAV123 \cite{UAV123} &NfS \cite{NFSdataset} &VOT2018 \cite{VOT2018} &VOT2019 &LaSOT \cite{LaSOT} & TrackingNet \cite{2018trackingnet} &Speed\\
~ & &AUC score &AUC score &AUC score & AUC score &EAO score &EAO score &AUC score & Success score &FPS\\
\hline
~DaSiamRPN \cite{DaSiamRPN} &AlexNet &65.8 &- &58.6 &- &0.326 &- &41.5 &63.8 &{\bf \color{red} 160} \\
~C-RPN \cite{CRPN} &AlexNet &66.3 &- &- &- &0.289 &- &45.5 &66.9 &32\\
~SPM \cite{SPM} &AlexNet &68.7 &- &- &- &0.338 &0.275 &- &71.2 &{\bf \color{blue} 110}\\
\hline
~ATOM \cite{ATOM} &ResNet-18 &67.1 & 59.3 & 63.5 &58.4 & 0.401 &0.292 &51.4 &70.3 &30\\
~DiMP-18 \cite{DiMP} &ResNet-18 &66.2 &60.6 & 63.4 &61.0 &0.402 &- & 53.5 &72.3 &46\\
~{\bf CARE-18 (Ours)} &ResNet-18 & {\bf \color{blue} 70.5} &61.2 &{\bf \color{red} 65.4} &60.5 &0.410 &0.323 &54.7 &71.8 &25\\
\hline
~SiamRPN++ \cite{siamrpn++} &ResNet-50 &69.6 &56.2 &61.3 &50.0 &0.414 &0.285 &49.6 &73.3 &35\\
~DiMP-50 \cite{DiMP} &ResNet-50 &68.4 &{\bf \color{blue} 61.5} &64.5 &{\bf \color{blue} 62.0} &{\bf \color{red} 0.440} &{\bf \color{red} 0.379} &{\bf \color{red} 56.9} & {\bf \color{blue} 74.0} &40\\
~{\bf CARE-50 (Ours)} &ResNet-50 & {\bf \color{red} 71.2} &{\bf \color{red} 61.7} &{\bf \color{blue} 64.6} &{\bf \color{red} 62.3} &{\bf \color{blue} 0.427} &{\bf \color{blue} 0.353} &{\bf \color{blue} 56.1} & {\bf \color{red} 74.2} &21\\
\hline
\end{tabular*}
\end{center}
\vspace{-0.0in}
\end{table*}
{\flushleft \bf UAV20L \cite{UAV123}.} This is a long-term tracking benchmark consisting of 20 long UAV videos with an average length of 2934 frames.
Our second-stage regressor ensures the tracking robustness and helps re-detect the lost target. As a result, our method significantly surpasses previous methods such as ATOM, DiMP-18, and SiamRPN++ (Table \ref{table:TC_NFS}).
{\flushleft \bf OxUvA \cite{2018longtermBenchmark}.} This is a recent large-scale long-term tracking benchmark with 366 videos. The targets in OxUvA undergo frequent partial/full occlusion and out of view. On this dataset, the visual trackers are required to predict the target state (presence or absence) in each frame.
We test our method on the test set of 166 videos. The comparison results are shown in Table~\ref{table:OxUvA}.
We do not add any additional mechanisms (e.g., global search) and merely use the reliability thresholds to predict the target presence/absence.
Note that the recently proposed Skimming-Perusal method (SPLT) \cite{SkimmingPerusalTracking} leads the top performance on this dataset, which is specially designed for long-term tracking with a local-global search.
Without bells and whistles, our approach outperforms SPLT by a relative gain of 20.4\% in terms of MaxGM, showing the importance of online discrimination learning.
The prior motion model (e.g., cosine window) in short-term trackers heavily limits their long-term performance.
Benefited from strong discrimination, our tracker is free of the motion model (e.g., cosine window) and simultaneously handles short-term and long-term scenarios.
\subsection{Performance with a Deeper Backbone Network}
For fair comparison, in this section, we compare our method with state-of-the-art trackers with the same backbone network.
In our approach, we follow ATOM \cite{ATOM} and use a shallow backbone network of ResNet-18 for high efficiency.
By adopting the deeper ResNet-50 \cite{ResNet}, our CARE approach obtains further performance improvements and still maintains a near real-time speed of about 21 FPS on a single Nvidia GTX 1080Ti GPU.
In Table~\ref{table:res50}, we include the recent SiamRPN++ \cite{siamrpn++} and DiMP-50 \cite{DiMP} for comparison, both of which leverage the deep ResNet-50 model.
From the results in Table~\ref{table:res50}, we can observe that our CARE-50 steadily outperforms SiamRPN++ and is comparable with the recent DiMP-50.
It is worth mentioning that DiMP-50 represents the current state-of-the-art tracker in various tracking benchmarks.
\section{Conclusion} \label{sec:conclusion}
In this paper, we propose a conceptually simple yet effective discrete sampling based ridge regression, which performs as an alternative of the fully-connected layers to discriminate the candidates, but exhibits promising efficiency under a closed-form solution.
Its high flexibility allows the incorporation of hard negative mining as well as our proposed adaptive ridge regression to enhance online discrimination.
We further complement it with the convolutional regression to develop a cascaded framework for robust visual tracking.
The first stage enables a fast and dense search, while the second stage guarantees distractor discrimination.
The proposed method exhibits outstanding results on several challenging benchmarks with a real-time speed.
\bibliographystyle{IEEEtran}
| {'timestamp': '2020-06-19T02:10:43', 'yymm': '2006', 'arxiv_id': '2006.10336', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10336'} | arxiv |
\section{2pt}{0.1em}{0pt}
\usepackage{array,multirow}
\usepackage{lipsum}
\makeatletter
\title{An Empirical Comparison of GANs and\\ Normalizing Flows for Density Estimation}
\author{%
Tianci Liu\\
Purdue University\\
\texttt{[email protected]}
\And
Jeffrey Regier\\
University of Michigan\\
\texttt{[email protected]}
}
\begin{document}
\maketitle
\begin{abstract}
Generative adversarial networks (GANs) and normalizing flows are both approaches to density estimation that use deep neural networks to transform samples from an uninformative prior distribution to an approximation of the data distribution. There is great interest in both for general-purpose statistical modeling, but the two approaches have seldom been compared to each other for modeling non-image data. The difficulty of computing likelihoods with GANs, which are implicit models, makes conducting such a comparison challenging. We work around this difficulty by considering several low-dimensional synthetic datasets. An extensive grid search over GAN architectures, hyperparameters, and training procedures suggests that no GAN is capable of modeling our simple low-dimensional data well, a task we view as a prerequisite for an approach to be considered suitable for general-purpose statistical modeling. Several normalizing flows, on the other hand, excelled at these tasks, even substantially outperforming WGAN in terms of Wasserstein distance---the metric that WGAN alone targets. Scientists and other practitioners should be wary of relying on WGAN for applications that require accurate density estimation.
\end{abstract}
\section{Introduction}
Generative adversarial networks (GANs) and normalizing flows can be seen as alternative approaches: both are flexible generative models that, in contrast to both variational autoencoders and traditional ``shallow'' Bayesian models, do not assume that either the likelihood or the prior has a simple parametric form.
This flexibility makes both approaches appealing for modeling complex scientific data. GANs in particular have caught the attention of scientists~\citep{mustafa2019cosmogan, Choi2017GeneratingMD,10.1093/jamia/ocy142}.
To date, however, GANs have been validated primarily using image data.
Little research exists investigating whether GANs are suitable for general statistical modeling, as would be required for scientific applications.
Performance metrics used to assess GANs thus far have unfortunately only revealed half the story: they measure whether the data GANs generate are realistic (i.e., precision) but not whether the fitted GAN model has support for held-out samples (i.e., recall). The difficulty associated with measuring recall stems from the intractability of the likelihood GANs assign to high-dimensional data---a well known limitation of implicit models~\cite{lucic2018are}.
Synthetic low-dimensional data, on the other hand, offers us the potential to establish a negative result. Using these data, we can accurately assess the performance of both GANs and flows. We study the performance of both GANs and flows on synthetic univariate data from mixture data (Section~\ref{data}). Although accurately learning distributions of univariate data is not sufficient for scientific modeling, it is a necessary condition for a tool to be reliable.
Even with univariate data, measuring performance is not trivial. We confront subtle issues of selecting kernel density estimation bandwidth, and present a low-variance estimator for Wasserstein distance between low dimension distributions (Section~\ref{metrics}). The visualization methods we develop allow us to demonstrate several distinct failure modes of GANs.
An additional challenge of establishing negative results with respect to GANs in general is their diversity: there are hundreds of different GAN algorithms, each of which can be combined with numerous tricks and tweaks, implying an exponential number of combinations. Using eight NVIDIA GeForce RTX 2080 Ti GPUs, and weeks of runtime, we systematically search these combinations. For WGAN, we experiment with gradient penalties, spectral normalization, batch normalization, cyclic learning rates, ResNet architectures, various layer widths, different noise distributions, and additional tuning parameters (Section~\ref{methods}). We also experiment extensively with normalizing flows.
GANs failed to learn even basic structures in our synthetic data, whereas some normalizing flows modeled the data well~(Section~\ref{results}).
Surprisingly, normalizing flows outperform WGANs even in terms of the metric that only WGAN targets: minimizing Wasserstein-1 distance.
The implications of these experiments, conducted solely with low-dimensional data, may not generalize to higher dimensions; hence, good performance on these experiments should be viewed necessary---but not sufficient---for a method to be suitable for general-purpose density estimation.
Scientists and other practitioners should be wary of relying on WGAN for applications that require accurate density estimation (Section~\ref{discussion}).
\section{Synthetic data}
\label{data}
We developed two synthetic datasets for evaluating GANs and normalizing flows.
Both datasets are univariate. To avoid confounding our results with issues of data efficiency and overfitting, which are beyond the scope of this work, we make the size of both datasets effectively infinite by drawing fresh data at every step.
\subsection{Unimodal dataset}
\label{data: gum}
One data model we consider is a two-component univariate mixture with equal means, specified by the following generative process:
\begin{align}
y &\sim \mathrm{Bernoulli}(p) \\
x \mid y=0 &\sim \mathrm{Uniform}(\mu - r\sigma, \mu + r\sigma) \\
x \mid y=1 &\sim \mathrm{Gaussian}(\mu, \sigma^2).
\end{align}
Here $y$ is an unobserved random variable and $x$ is the data.
We set $p = 0.75, \mu=5, \sigma=0.1, r=5$.
Figure~\ref{fig:experiment} (a) shows this density.
The density has several qualitative aspects we expect a good model to recover: sharply changing density at 4.5 and 5.5, and a bell-shaped mode symmetry around 5.
\subsection{Multimodal dataset}
\label{data: mgum}
We also consider a mixture of unimodal distributions with unequal means, as specified by the following generative process:
\begin{align}
z &\sim \mathrm{Categorical}(\sfrac{1}{K}, \dots, \sfrac{1}{K}) \\
y \mid z=k &\sim \mathrm{Bernoulli}(p) \\
x \mid y=0 &\sim \mathrm{Uniform}(\mu_k - r\sigma, \mu_k + r\sigma) \\
x \mid y=1 &\sim \mathrm{Gaussian}(\mu_k, \sigma^2).
\end{align}
Here $x$ is the data and $y$ and $z$ are unobserved random variables, used only to facilitate data generation.
We set $K = 8$, $p = 0.5$, $\sigma=2$, and $r=1.5$.
For $k=1,\ldots,K$, we set $\mu_k=10k$.
Figure~\ref{fig:experiment} (e) shows this density. We designed this density to have multiple modes, with non-negligible density between them. Compared to our unimodal mixture, our multimodal mixture has narrower modes with sharper boundaries.
The density has several qualitative aspects that we would expect a good model to recover: the correct number of modes, the correct high and low density areas, equal densities at the modes, and equal densities within the low-probability regions between modes.
\vspace{10px}
\section{Metrics}
\label{metrics}
Evaluating the quality of GANs is not trivial because the density of GAN generators cannot be evaluated directly---generators can only be sampled.
Our strategy is to first draw a large number of samples from the generator.
Because our data is low-dimensional, we can attain high sample density.
Then, we compute two metrics---one qualitative and the other quantitative--using these samples.
\subsection{Kernel density estimation}
Kernel density estimation (KDE) lets us visualize the GAN density and compare it qualitatively to the normalizing flow density and the true data generating density. However, KDE can be inaccurate if the bandwidths are chosen improperly: too large and the GAN appears smoother than it is, too small and the GAN density incorrectly appears to be highly variable. Either case can mask the extent to which a GAN captures structure in the true data distribution.
We strike a good balance by using a large sample size ($100,000$), and by choosing a bandwidth such that each band contains, on average, $500$ samples, where $500$ is chosen to approximately maximize the likelihood of held-out data.
\vspace{10px}
\subsection{Wasserstein-1 distance}
Wasserstein-1 distance, also known as Earth-Mover distance, measures the difference between two distributions. Wasserstein-1 distance is an especially interesting distance for our research questions because it is the objective function that WGAN targets.
While computing Wasserstein-1 distance in general requires solving a constraint optimization, for univariate data it can be readily estimated to high precision~\citep{ramdas2015wasserstein,panaretos2019statistical}.
Suppose $X$ (resp. $Y$) is a random variable following $\mathbb{P}_X$ (resp. $\mathbb{P}_Y$).
Let $x$ (resp. $y$) denote i.i.d. samples with size $n$ (resp. $m$) of $X$ (resp. $Y$) and let $\hat{F}_X $ (resp. $\hat{F}_Y$) be the empirical cumulative distribution function based on $x$ (resp. $y$). Then, Wasserstein-1 distance can be estimated with
\begin{align}
\label{directw1}
W_1(\mathbb{P}_X, \mathbb{P}_Y)
&\approx \sum_{t \in x \cup y} |\hat{F}_X(t) - \hat{F}_Y(t)|.
\end{align}
This formula provides a convenient method of validating the predictions of a GAN critic $c$~\citep{arjovsky2017wasserstein, wgan-gp}, which estimates the Wasserstein-1 distance as
\begin{align}
\label{criticw1}
W_1(\mathbb{P}_X, \mathbb{P}_Y)
&\approx \frac{1}{n}\sum_{i=1}^{n} c(x_i) - \frac{1}{m}\sum_{j=1}^{m} c(y_j).
\end{align}
\section{Methods}
\label{methods}
\begin{figure}
\centering
\includegraphics[width=\textwidth]{images/exp-hn-small.jpg}
\caption{Density plots for our datasets and the models fitted to them. The top row pertains to the univariate dataset and the bottom row to the multivariate dataset. The leftmost column shows the data distributions. The other columns show the distributions learned by three density estimation algorithms: WGAN, FFJORD, and Gaussianization Flows.
}
\label{fig:experiment}
\end{figure}
We initially set out to demonstrate a positive result: that GANs are versatile statistical tools.
As evidence to the contrary accumulated, we embarked on the more challenging task of showing a negative result of some generality by searching large numbers of permutations of GAN types, architectures, and training techniques.
For normalizing flows, a positive result emerged fairly soon, so it was not necessary to try many combinations of flow training techniques and flow architectures.
\subsection{Methods for training GANs}
We considered the original GAN~\citep{goodfellow2014generative} at first, but focused on the Wasserstein GAN (WGAN) after it became apparent the former would not adequately model our data.
Prior work establishes that WGAN is among the best performing GANs if architectures are well-chosen~\citep{rosca2018distribution, lucic2018are,dinh2017density}.
The WGAN hyperparameters can be divided into two sets based on whether they determine network architecture or training strategy.
The former includes activation functions, width, and depth, as well as different ways to initialize weights---namely, uniform and Xavier~\citep{pmlr-v9-glorot10a}. We also considered both fully connected and ResNet architectures~\citep{resnet}. For the generator, we considered both Gaussian and uniform priors of various dimensions, as well as batch normalization~\citep{batch_norm}. For the critic, we explored gradient penalties~\citep{wgan-gp} and spectral normalization~\citep{miyato2018spectral}, and consider different strengths for both regularizers.
The WGAN hyperparameters dictating the training strategy include optimizer learning rate, weight decay, and both coefficients for Adam~\citep{adam}. We also considered cyclic learning rates~\citep{cycliclr} following some failure modes we observed.
We also experimented with various numbers of critic updates per generator update.
Exhaustive grid searching on such a large search space is prohibitively expensive. We approximate an exhaustive grid search with random search~\citep{10.5555/2188385.2188395} through ASHA~\citep{li2018massively}, which leverages early stopping scheduler of parallel hyperparameter tuning, to study the performances of different combinations.
\subsection{Methods for training flows}
We first considered Masked Autoregressive Flow~\citep{papamakarios2017masked}, Inverse Autoregressive Flow~\citep{NIPS2016_6581}, RealNVP~\cite{dinh2017density} and Planar flows~\cite{pmlr-v37-rezende15}. For univariate data such as ours, however, these flows have just two learnable scalar parameters. With so few learnable parameters, the capacity of such flows is limited for univariate data, so we did not consider them further.
Our experiments with flows focused instead on Free-form Jacobian of Reversible Dynamics (FFJORD)~\citep{grathwohl2018scalable}
and Gaussianization Flows (GF)~\citep{Meng2020GaussianizationF}.
The former, FFJORD, is a continuous flow based on an ordinary differential equation.
The latter, GF, stacks two types of learnable transformations: a linear transformation to rotate data such that correlations between different dimensions is minimized, and a non-linear transformation to learn each marginal distributions separately by composing inverse Gaussian CDF with a mixture of logistic distributions. The first type of transformation was unnecessary for our univariate data.
We did not run a grid search to find optimal parameters for either FFJORD or GF.
Instead, we used the same architectures and training strategies from~\citet{grathwohl2018scalable} and~\citet{Meng2020GaussianizationF}.
\section{Results}
\label{results}
We evaluated WGAN, FFJORD and Gaussianization Flows on both our synthetic datasets.
The results reported for WGAN are always for models tuned with extensive hyperparameter optimization.
Typically spectral normalization led to the best results for WGAN.
We consider the experimental results both qualitatively and quantitatively.
\subsection{Qualitative}
Figure~\ref{fig:experiment} is a key result of ours that shows the dataset densities (ground truth) and the learned densities. Only the best performing WGAN is shown. Even the best WGAN failed to reconstruct key qualitative features of the datasets.
On the unimodal dataset, WGAN assigned too much mass in both regions around the boundaries of data distribution's support, as well as at the mode of the data distribution. Further, WGAN failed to capture the symmetry and bell-shaped structure. On the multimodal dataset, WGAN recovered all modes and gaps between modes. However, WGAN misrepresented the local structure of the individual modes (e.g., the symmetry), as well as the relative densities of the modes, which should have been equal.
Both types of normalizing flows, in contrast, recovered both the local and global structure of the data distributions.
GF appears to be slightly more accurate than FFJORD.
\subsection{Quantitative}
Table~\ref{table:experiment} summarizes the quantitative performances on two datasets in terms of the Wasserstein-1 distance, as estimated by Equation~\ref{directw1}. Surprisingly, both flows outperformed the best WGAN in terms of Wasserstein-1 distance---a metric that only WGAN targets.
The best performing WGAN for unimodal data used spectral normalization to constrain the Lipschitz constant of the critic,
whereas for multimodal data, a gradient penalty worked better than spectral normalization.
Many of the modifications of the WGAN that we thought might help did not.
We report results for several of these modifications in Table~\ref{table:wgan}.
We made some progress in understanding why WGAN does not perform better.
Because our data is low dimensional, Equation~\ref{directw1}, gives us low variance (and unbiased) estimates of the Wasserstein-1 distance.
The WGAN critic computes Wasserstein distance differently, using Equation~\ref{criticw1}.
When WGAN converged, the Wasserstein-1 distance estimated by the critic often severely underestimated the true Wasserstein-1 distance.
Surprisingly, in some cases, the critic estimate of the Wasserstein-1 distance was negative.
Without reliable estimates from the critic of the distance between the data distribution and the model/generator density at the current iterate,
there is no sound basis for updates to the generator.
\begin{table}[ht!]
\caption{\textbf{Wasserstein-1 distance} between fitted models and the targeted data distributions (i.e., our unimodal dataset and our multimodal dataset), as estimated by Equation~\ref{directw1}.
\textbf{Lower is better.}
}
\label{table:experiment}
\begin{center}
\begin{small}
\begin{sc}
\begin{tabular}{lcc}
\toprule
{} & Unimodal Data & Multimodal Data \\
\midrule
Wasserstein GAN & 0.0087 & 0.4814
\\ FFJORD & 0.0066 & 0.289
\\Gaussianization Flows & \textbf{0.0035} & \textbf{0.138}
\\
\bottomrule
\end{tabular}
\end{sc}
\end{small}
\end{center}
\end{table}
\begin{table}[ht!]
\caption{\textbf{Wasserstein-1 distance} between fitted WGANs and the targeted data distributions, as estimated by Equation~\ref{directw1}.
\textbf{Lower is better.}
``Baseline'' is our best model: WGAN with either spectral normalization or gradient penalty, optimally tuned.
``With uniform prior'' substitutes a uniform prior for a Gaussian prior.
``With cyclic LR'' introduces a cyclic learning rate.
``With dropout'' adds dropout regularization.
``With ResNet'' uses residual blocks in the generator and the critic.
}
\label{table:wgan}
\begin{center}
\begin{small}
\begin{sc}
\begin{tabular}{lcc}
\toprule
{} & Unimodal Data & Multimodal Data \\
\midrule
\textit{baseline} & \textbf{0.0087} & \textbf{0.4814}
\\\textit{with uniform prior} & 0.0490 & 0.6648
\\ \textit{with cyclic LR} & 0.0491 & 0.7664
\\ \textit{with dropout} & 0.1171 & 1.0461
\\ \textit{with ResNet} & 0.1827 & 0.7238
\\
\bottomrule
\end{tabular}
\end{sc}
\end{small}
\end{center}
\end{table}
\subsection{Runtime}
Gaussianization Flows was by far the fastest model to train, requiring just 1.5 hours.
FFJORD required nearly two weeks to converge on our multimodal dataset. However, this extreme runtime may have in part been due to an issue with the reference implementation, which caused the ODE solver to run more slowly with each iteration.
WGAN with spectral normalization and 100 critic updates per generator update required around two days per run.
Hundreds of runs were necessary to find good hyperparameters.
\section{Discussion}
\label{discussion}
We developed synthetic datasets, reporting metrics, and a model-search methodology for evaluating both GANs and normalizing flows. Our results are surprising: GANs failed to learn key qualitative aspects of both unimodal and multimodal data. Quantitatively, normalizing flows outperformed the Wasserstein GAN in terms of the very metric that only latter targets: Wasserstein-1 distance. These negative results echo some concerns raised in~\citet{rosca2018distribution}.
There are caveats to our results. First, the lessons from low-dimensional data may not generalize to higher dimensional settings. However, for applications that require good recall, including many scientific applications, these results from low-dimensional data are enough to raise serious doubts about the performance of GANs in high dimensions, where there is no rigorous way to detect that an implicit model has poor recall. Good performance on our benchmarks is a necessary but not sufficient condition for a method to be a reliable at general-purpose density estimation.
Another caveat to our work is that establishing a general negative result requires exhaustively searching an infinite number of GANs, including GAN variants that have not yet been invented. We tested many but not all GAN variants. We invite others to test additional GAN variants using our benchmarking software, which is publicly available at \url{https://github.com/lliutianc/gan-flow}.
As it stands, however, scientists and other practitioners should be wary of relying on GANs to accurately estimate densities.
| {'timestamp': '2021-12-15T02:24:20', 'yymm': '2006', 'arxiv_id': '2006.10175', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10175'} | arxiv |
\section{Introduction}
\label{sec:1}
The cryptographic properties of vector boolean functions, or \textbf{S-boxes}, are thoroughly examined by introducing a rich list of desirable parameters an S-box should have in order to guarantee an acceptable resistance to sophisticated cryptographic attacks such as, for example, linear cryptanalysis \cite{Linear}\cite{ATT3}, differential cryptanalysis \cite{ATT1}, boomerang attack \cite{ATT4} or interpolation attack \cite{Interpolation}. Furthermore, S-boxes are widely used in modern cryptographic algorithms like AES \cite{AES}, Whirlpool \cite{Whirlpool}, Camellia \cite{Camellia} and many others.
Despite the rich variety of proposed methods for S-boxes generation, we mainly focus on S-box constructions benefiting from the study of chaos, to further analyze their actual resistance to linear cryptanalysis.
In Section \ref{sec:2} we introduce the definitions of some basic cryptographic characteristics used to measure the cryptographic strength of a given S-box.
In Section \ref{sec:3} we show that the actual nonlinearity value, or \textbf{NL}, of the majority of chaotic functions-based (\textbf{CF}-based) published S-boxes differs from the average nonlinearity value originally announced. This discrepancy is based on the fact that the aforementioned papers consider the average nonlinearity of the S-box coordinates only, or \textbf{ACNV}, ignoring the rest of the S-box components in the process. In Section \ref{sec:4}, we propose an algorithm, which significantly outperforms all previously published S-boxes in terms of ACNV. During our experiments, we repeatedly reached S-boxes with ACNV of 114. We want to emphasize, that ACNV greater than 112.0, to the best of our knowledge, was never achieved in the literature.
In Section \ref{sec:5}, we demonstrate the efficiency of the proposed algorithm by optimizing the ACNV of some popular S-boxes. Thus, we show that the starting state of the optimization routines is negligible. Having this in mind, the competitiveness of S-boxes generated by exploiting chaos structures, at least in the context of S-box nonlinearity optimization problem, is arguable. The same observation was made in \cite{ozkaynak2020effect}.
Then, in Section \ref{sec:bandits}, we translate the S-box ACNV optimization problem to the multi-armed bandit problem, which allow us to further improve our results by reaching an ACNV of 114.5 - a value significantly larger than those known in literature.
\section{Preliminaries}
\label{sec:2}
Let $B = \{0,1\}$. A \textbf{Boolean function} $f(x)$ of $n$ variables $x_1, \cdots,x_n$ is a mapping $f : B^n \mapsto B$ from $n$ binary inputs $x=(x_1,x_2,\cdots,x_n) \in B^n$ to one binary output $y = f(x) \in B$.
\begin{definition}[Algebraic Normal Form -- ${ANF}_f$]
The algebraic normal form of an $n$-variable Boolean function $f(x)$ is given by the following equation: \[ {ANF}_f = a_0 \oplus a_1x_1 \oplus a_2x_2 \oplus a_{1,2,\cdots,n}x_1x_2 \cdots x_n, \] where the coefficients $a_{i \cdots j} \in B = \{0,1\}$.
\end{definition}
A linear Boolean function $f$ is a function with specific algebraic normal form $ANF_f$, s.t. no term with algebraic degree greater than 1 exists. A more formal definition follows:
\begin{definition}[Linear Boolean Function]
Any $n$-variable Boolean function of the form: $$l_w(x) = <w,x> = w_1x_1 \oplus w_2x_2 \oplus \cdots \oplus w_{n}x_{n},$$ where $w, x \in B^n$, is called a linear Boolean function.
\end{definition}
An $n$-binary input into $m$-binary output mapping $S : B^n \Leftrightarrow B^m$, which assigns some $y = (y_1, y_2, \cdots , y_m) \in B^m$ by $S(x) = y$ to each $x = (x_1, x_2, \cdots, x_n) \in B^n$, is called an ($n \times m$) substitution table (\textbf{S-box}) and is denoted by $S(n, m)$.
An S-box $S(n, m)$ is said to be \textbf{bijective}, if it maps each input $x \in B^n$ to a distinct output $y = S(x) \in B^m$ and all possible $2^m$ outputs are present. For example, the $(n,n)$ bijective S-boxes are Boolean permutations on $F_2^n$, where $F_2$ is a finite field with two elements.
An S-box $S(n, m)$ can be bijective only when $n = m$. Clearly, a bijective S-box $S(n, n)$ represents a permutation of its $2^n$ inputs, since each input is mapped to a distinct output and all possible $2^n$ outputs are present. In this way, $S(n, n)$ will be reversible, that is, there is a mapping from each distinct output to its corresponding input.
\begin{definition}[Look-up Table]
The \textbf{look-up table LUT} of an S-box $S(n, m)$ is a ($2^n \times m$) binary matrix $S_{LUT}$, which rows consist of all outputs of $S(n,m)$, corresponding to all possible $2^n$ inputs ordered lexicographically.
\[ S = \begin{bmatrix}
f_1(0,0,...,0) & f_2(0,0, ...,0) & ... & & f_m(0,0,...,0)\\
f_1(0,0,...,1) & f_2(0,0,...,1) & \cdots & & f_m(0,0,...,1) \\
\vdots & \vdots & \vdots & & \vdots \\
f_1(1,1, ... ,0) & f_2(1,1, ... ,0) & \cdots & & f_m(1,1, ..., 0) \\
f_1(1,1,...,1) & f_2(1,1,...,1) & \cdots & & f_m(1,1,...,1)
\end{bmatrix} \]
We define each column of $S_{LUT}$ as \textbf{coordinate} of S. All linear combinations of coordinates of S are called \textbf{components} of S.
\end{definition}
\begin{definition}[Linear Approximation Table]
The linear approximation table of an S-box $S(n, m)$, denoted by $S_{LAT}$, is a $(2^n \times 2^m)$ table, which entries are given by: ${S}_{LAT}[X][Y] = 2^{n-1}-d_H(X,Y)$, where $Y$ is a linear combination of the coordinates of the current S-box, $X$ is the consequent linear function with length $n$ and $d_H(X,Y)$ denotes the Hamming distance between $X$ and $Y$.
\end{definition}
The linear approximation table of a given S-box S(n,n) reveals the actual correlation between the components of S and all linear Boolean functions sharing the same dimension n.
\begin{definition}[S-box Nonlinearity]
\label{def:S-boxNonlinearity}
The nonlinearity of an S-box $S(n, m)$ is defined as $S_{NL} = 2^{n-1} - max\left( \{abs(w_i) \}\right),$ where $\left \{ w_i \right \}$ is the set of all elements in the LAT, excluding the first row and the first column.
\end{definition}
Lower values of nonlinearity could be exploited by the family of linear cryptanalysis attacks. Having this in mind, higher nonlinearity value is a desirable S-box property.
Each S-box is uniquely defined by its LUT. Therefore, if we translate each row of the LUT as decimal number, we can obtain a unique decimal representation of the S-box denoted by \textbf{DLUT}.
\section{Chaos-based S-box constructions}
\label{sec:3}
The methods involved in CF S-box constructions are manifold. For example, chaos function combined with travelling salesman problem \cite{ahmad2016efficient}, chaotic substitution box design \cite{ahmad2014new}, 1D chaotic map combined with $\beta$-Hill climbing \cite{alzaidi2018new}, chaotic map combined with sine-cosine optimization \cite{alzaidi2018sine}, chaotic system with multiple attractors \cite{lai2018new}, chaotic map combined with heuristics \cite{belazi2017efficient}, one-dimensional discrete chaotic map \cite{lambic2018s}, hyperchaotic systems \cite{peng2016novel} \cite{al2018new}, spatiotemporal chaotic dynamics \cite{liu2018novel}, chaotic map combined with genetic algorithms \cite{wang2012novel}, chaotic logistic maps combined with bacterial foraging optimization \cite{tian2017chaotic} and many others (see Table \ref{tab:summaryResults}). Usually, the best candidate of each method is further compared to others in terms of important cryptographic properties like nonlinearity, differential uniformity \cite{carlet2010vectorial} and strict avalanche criterion (SAC) \cite{forrie1988strict}. The majority of authors emphasize on the ACNV of their best candidate. In Table \ref{tab:comparison8} the coordinate nonlinearities of several S-box candidates achieved by some CF-based methods are presented. A more detailed overview is given in Table \ref{tab:summaryResults}.
The actual nonlinearity of an S-box is calculated by the minimum nonlinearity of all the components of the S-box. For example, let us take an arbitrary S-box $F(5,5)$ with $F_{LUT} = [f0,f1,f2,f3,f4]$. Each column of $F_{LAT}$ is determined by some linear combination of coordinates of $F$, sorted lexicographically, from left to right, by the binary representation of the column index, zero-filled to 5. Let $F_{LAT}[i]$ denotes the $i$-th column of $F_{LAT}$. Then, for example, the $F_{LAT}[11]$ column holds the nonlinear characteristics of the Boolean function $f_1 \oplus f_3 \oplus f_4$, while $F_{LAT}[4]$ holds the nonlinear characteristics of the Boolean function $f_3$. In Figure \ref{fig:1} the coordinate decomposition of $F_{LAT}$ is visualized. Each coordinate is associated with distinct color. The number of segments in each column corresponds to the number of terms in the respective linear combination of coordinates. Since $F_{LAT}[0]$ is the trivial linear combination (all coefficients are equal to zero), we leave the first column of Figure \ref{fig:1} colorless. For technical reasons and better illustration, the coordinate decomposition example is based on a $(5,5)$ S-box. However, it is applicable to S-boxes of any dimension.
\begin{figure*}
\centering
\includegraphics[width=\textwidth]{DIMIT1.pdf}
\caption{Coordinate decomposition of a $(5,5)$ S-box LAT}
\label{fig:1}
\end{figure*}
As defined in Definition \ref{def:S-boxNonlinearity}, we seek the maximum absolute value $v$ of all the elements in S-box $S(n,n)$ LAT, to find the nonlinearity of $S$, i.e. $S_{NL} = 2^{n-1} - v$.
In Table \ref{tab:comparisonNL} the actual nonlinearity of each S-box from Table \ref{tab:comparison8} is calculated. The deviations observed are due to the fact that the designers consider the nonlinearity values of coordinates only (the non-segmented columns in the $(8,8)$ coordinate decomposition).
In the context of block ciphers, a low nonlinearity S-box value is associated with the cipher linear cryptanalysis resistance \cite{matsui1993linear}\cite{ATT3}\cite{heys2002tutorial}.
\begin{table}
\centering
\caption{Comparison of nonlinearity of some CF-based $(8,8)$ S-boxes}
\label{tab:comparison8}
\scalebox{0.9}{
\begin{tabular}{rllllllll}
& \multicolumn{8}{c}{} \\
Method & $f_1$ & $f_2$ & $f_3$ & $f_4$ & $f_5$ & $f_6$ & $f_7$ & $f_8$ \\
\noalign{\smallskip}\hline\noalign{\smallskip}
Ahmad \cite{ahmad2016efficient} & 108 & 110 & 110 & 108 & 106 & 106 & 106 & 106 \\
Ahmad \cite{ahmad2014new} & 104 & 106 & 106 & 104 & 102 & 108 & 106 & 106 \\
Al Solami \cite{al2018new} & 108 & 110 & 108 & 108 & 106 & 110 & 108 & 110 \\
Alzaidi \cite{alzaidi2018new} & 110 & 112 & 110 & 110 & 110 & 110 & 110 & 110 \\
Alzaidi \cite{alzaidi2018sine} & 110 & 110 & 110 & 110 & 110 & 108 & 110 & 108 \\
Belazi \cite{belazi2017efficient} & 106 & 106 & 106 & 104 & 108 & 102 & 106 & 104 \\
Lai \cite{lai2018new} & 104 & 110 & 104 & 108 & 104 & 104 & 106 & 104 \\
Liu \cite{liu2018novel} & 108 & 102 & 104 & 104 & 102 & 104 & 106 & 106 \\
Lambic \cite{lambic2018s} & 106 & 106 & 106 & 106 & 106 & 108 & 108 & 106 \\
Peng \cite{peng2016novel} & 102 & 102 & 104 & 104 & 102 & 100 & 106 & 102 \\
Tian \cite{tian2017chaotic} & 106 & 106 & 110 & 108 & 106 & 108 & 108 & 108 \\
\noalign{\smallskip}\hline
\end{tabular}}
\end{table}
\begin{table}
\begin{center}
\caption{Real nonlinearity values (NL) of the S-boxes given in Table \ref{tab:comparison8}}
\label{tab:comparisonNL}
\scalebox{1}{
\begin{tabular}{rllrc}
\hline
Method & min & max & ACNV & NL \\
\noalign{\smallskip}\hline\noalign{\smallskip}
Ahmad \cite{ahmad2016efficient} & 106 & 110 & 107.5 & 90 \\
Ahmad \cite{ahmad2014new} & 102 & 108 & 105.25 & 94\\
Al Solami \cite{al2018new} & 106 & 110 & 108.5 & 94 \\
Alzaidi \cite{alzaidi2018new} & 110 & 112 & 110.25 & 96 \\
Alzaidi \cite{alzaidi2018sine} & 108 & 110 & 109.5 & 94 \\
Belazi \cite{belazi2017efficient} & 102 & 108 & 105.25 & 88 \\
Lai \cite{lai2018new} & 104 & 110 & 105.5 & 92 \\
Liu \cite{liu2018novel} & 102 & 108 & 104.5 & 96 \\
Lambic \cite{lambic2018s} & 106 & 108 & 106.5 & 94 \\
Peng \cite{peng2016novel} & 100 & 102 & 102.75 & 88 \\
Tian \cite{tian2017chaotic} & 106 & 110 & 107.5 & 92 \\
\noalign{\smallskip}\hline
\end{tabular}}
\end{center}
\end{table}
\section{Alternative construction}
\label{sec:4}
As we have shown in the previous section, the average value of the nonlinearities of the coordinates of a given S-box $S$ doesn't correspond to the the actual nonlinearity of $S$. However, from the designer perspective, if a higher value of ACNV is desirable, a new heuristic construction is suggested.
In general, if we want to improve the nonlinearity of a given bijective S-box $S(n,n)$, a strategy of lowering the absolute value of coefficients in $S_{LAT}$ makes sense. Moreover, the elements of each column of $S_{LAT}$ are entangled by the Parceval's theorem \cite{meier1989nonlinearity}. Let's denote as $C_i$ the array composed of the elements of $S_{LAT}[i]$. Since we want to lower the nonlinearities of coordinates of $S$ only, an evaluating function $E(S)$ is created, s.t. $ E(S) = \sum_{p=0}^{n-1}\sum_{x \in C_{2^p}} { \lvert x \rvert ^ {M}},$ where $M$ denotes a magnitude of our choice. The restriction $x \in C_{2^p}$ narrows down the set of possible columns of $S_{LAT}$ to be optimized, in terms of nonlinearity, to the set of coordinates of $S$. As example, in case of a $S(5,5)$ S-box, the evaluation function threats as significant the elements inside the colored columns of $S_{LAT}$ illustrated in Figure \ref{fig:2}.
By using stochastic\footnote{hill climbing without neighborhood search} hill climbing as heuristic function, starting from arbitrary pseudo-random S-box construction and by using $E(S)$, algorithm \ref{algo} is proposed.
\begin{algorithm}[H]
\caption{}\label{algo}
\begin{algorithmic}[1]
\State $s\gets R(n)$ \Comment{the function R(n) generates pseudo-random bijective S-box $S(n,n)$}
\Repeat
\State $sdupl\gets s$
\State \Call{RT}{sdupl} \Comment{the function RT(S) make a random transposition in $S$}
\If{$\Call{E}{sdupl} < \Call{E}{s}$}
\State $s\gets sdupl$
\EndIf
\Until{STOP condition is reached} \Comment{reaching $\frac{n(n-1)}{4}$ cycles}
\end{algorithmic}
\end{algorithm}
Given an S-box $S(n,n)$, and by using just one transposition, we can reach a total of ${n\choose 2}$ S-boxes. Let denote this set as $S^T$. We further define a set $S^I$, s.t. $W \in S^I \iff W \in S^T \land E(W) < E(S)$. In case $\lvert S^I \rvert = 1$, and we are allowed to randomly pick $ \frac{\lvert S^T \rvert} {2}$ elements from $S^T$, the probability some of the picked elements to belong to $S^I$ is $\frac{1}{2}$. The threshold value of the stop condition in Algorithm \ref{algo} is constructed on this observation.
\begin{figure}
\centering
\includegraphics[width=0.5\textwidth]{DIMIT2.pdf}
\caption{Columns of interest of a $(5,5)$ S-box LAT}
\label{fig:2}
\end{figure}
\section{Results Part I}
\label{sec:5}
By using a magnitude of $10$, we repeatedly generated S-boxes with high coordinate nonlinearities. During our experiments, we have tried various magnitude values. However, larger or smaller values of the magnitude are respectively too aggressive or too tolerant to the largest elements of the S-box LAT.
In Figure \ref{fig:Sc_raw} the DLUT, in a hexadecimal format, of an optimized S-box $S_c(8,8)$ is presented. The first row and column of the table correspond respectively to the first and second half of the input in hexadecimal format. For example, the input \textbf{11110101}, equal to \textbf{f5}, is transformed by $S_c$ to \textbf{5d}. The characteristics of $S_c$ are summarized in Tables \ref{tab:proposed8} and \ref{tab:proposedNL}.
In \cite{tanyildizi2019new}, Table 5, a summary on the CF-based S-box constructions found in the literature is presented (an updated version of it is to be found in Table \ref{tab:summaryResults}). We significantly outperform all of them in terms of ACNV and SAC, reaching the optimal SAC value of 0.5.
We further launched the algorithm on some popular (8,8) S-box constructions. However, because of the non deterministic nature of the optimization process, it is difficult to match a given S-box input $S_{start}$, which is to be optimized, with the final optimized S-box $S_{end}$. To achieve such matching, we have restricted the algorithm of changing the first 16 elements of $S_{start}$. This allows us to further demonstrate the flexibility of the optimization process. Furthermore, since the first 16 elements of $S_{start}$ and $S_{end}$ are always shared, $S_{end}$ can be successfully matched to $S_{start}$.
In Figures \ref{fig:S_AES_opt} and \ref{fig:S_Whirl_opt}, an optimized by algorithm \ref{algo} versions of Rijndael \cite{AES} and Whirlpool \cite{Whirlpool} S-boxes are presented. The colored cells represent those elements of the corresponding S-box, which were not modified during the optimization process. Furthermore, in Figures \ref{fig:S_Fantomas_opt} and \ref{fig:S_Skipjack_opt}, the optimized versions of Fantomas \cite{grosso2014ls} and Skipjack \cite{Skipjack} S-boxes are given.
All of the aforementioned S-boxes are optimized to the ACNV of 114.0. Algorithm \ref{algo} was implemented with the built-in tools provided by the open-source mathematical software system SageMath \cite{developers2016sagemath}.
\begin{figure}
\centering
\begin{tikzpicture}[scale=0.7, every node/.style={anchor=base,text depth=.4ex,text height=1ex,text width=2ex, scale=0.7}]
\matrix (A) [matrix of nodes, nodes={draw}, font=\ttfamily, row 1/.style={nodes={fill=gray!50}}, column 1/.style={nodes={fill=gray!50}}]
{ & 00 & 01 & 02 & 03 & 04 & 05 & 06 & 07 & 08 & 09 & 0a & 0b & 0c & 0d & 0e & 0f \\
00 & |[fill=matchColorAES!50]| 63 & |[fill=matchColorAES!50]| 7c & |[fill=matchColorAES!50]| 77 & |[fill=matchColorAES!50]| 7b & |[fill=matchColorAES!50]| f2 & |[fill=matchColorAES!50]| 6b & |[fill=matchColorAES!50]| 6f & |[fill=matchColorAES!50]| c5 & |[fill=matchColorAES!50]| 30 & |[fill=matchColorAES!50]| 01 & |[fill=matchColorAES!50]| 67 & |[fill=matchColorAES!50]| 2b & |[fill=matchColorAES!50]| fe & |[fill=matchColorAES!50]| d7 & |[fill=matchColorAES!50]| ab & |[fill=matchColorAES!50]| 76 \\
10 & c2 & 92 & |[fill=matchColorAES!50]| c9 & |[fill=matchColorAES!50]| 7d & fb & |[fill=matchColorAES!50]| 59 & |[fill=matchColorAES!50]| 47 & |[fill=matchColorAES!50]| f0 & |[fill=matchColorAES!50]| ad & c4 & c0 & ae & c8 & |[fill=matchColorAES!50]| a4 & 3a & a8 \\
20 & |[fill=matchColorAES!50]| b7 & |[fill=matchColorAES!50]| fd & |[fill=matchColorAES!50]| 93 & |[fill=matchColorAES!50]| 26 & |[fill=matchColorAES!50]| 36 & |[fill=matchColorAES!50]| 3f & fa & |[fill=matchColorAES!50]| cc & |[fill=matchColorAES!50]| 34 & |[fill=matchColorAES!50]| a5 & |[fill=matchColorAES!50]| e5 & |[fill=matchColorAES!50]| f1 & |[fill=matchColorAES!50]| 71 & |[fill=matchColorAES!50]| d8 & b5 & 11 \\
30 & |[fill=matchColorAES!50]| 04 & |[fill=matchColorAES!50]| c7 & 33 & |[fill=matchColorAES!50]| c3 & |[fill=matchColorAES!50]| 18 & |[fill=matchColorAES!50]| 96 & |[fill=matchColorAES!50]| 05 & 9c & |[fill=matchColorAES!50]| 07 & |[fill=matchColorAES!50]| 12 & 88 & e1 & |[fill=matchColorAES!50]| eb & 2f & |[fill=matchColorAES!50]| b2 & 35 \\
40 & |[fill=matchColorAES!50]| 09 & 82 & |[fill=matchColorAES!50]| 2c & 1b & 19 & |[fill=matchColorAES!50]| 6e & 1a & |[fill=matchColorAES!50]| a0 & 42 & |[fill=matchColorAES!50]| 3b & |[fill=matchColorAES!50]| d6 & bb & |[fill=matchColorAES!50]| 29 & e2 & 27 & 85 \\
50 & |[fill=matchColorAES!50]| 53 & |[fill=matchColorAES!50]| d1 & 20 & |[fill=matchColorAES!50]| ed & 10 & |[fill=matchColorAES!50]| fc & 31 & 4b & |[fill=matchColorAES!50]| 6a & |[fill=matchColorAES!50]| cb & |[fill=matchColorAES!50]| be & |[fill=matchColorAES!50]| 39 & 8e & |[fill=matchColorAES!50]| 4c & |[fill=matchColorAES!50]| 58 & ef \\
60 & |[fill=matchColorAES!50]| d0 & 8f & a2 & f7 & |[fill=matchColorAES!50]| 43 & 0d & 23 & 84 & 46 & e9 & 03 & 7e & |[fill=matchColorAES!50]| 50 & 38 & |[fill=matchColorAES!50]| 9f & 2a \\
70 & |[fill=matchColorAES!50]| 51 & |[fill=matchColorAES!50]| a3 & |[fill=matchColorAES!50]| 40 & cf & 83 & |[fill=matchColorAES!50]| 9d & 28 & f3 & bd & |[fill=matchColorAES!50]| b6 & de & |[fill=matchColorAES!50]| 21 & 00 & |[fill=matchColorAES!50]| ff & f5 & |[fill=matchColorAES!50]| d2 \\
80 & |[fill=matchColorAES!50]| cd & d4 & |[fill=matchColorAES!50]| 13 & ee & 5d & |[fill=matchColorAES!50]| 97 & |[fill=matchColorAES!50]| 44 & |[fill=matchColorAES!50]| 17 & 0c & |[fill=matchColorAES!50]| a7 & 7f & |[fill=matchColorAES!50]| 3d & |[fill=matchColorAES!50]| 64 & 5f & 5b & |[fill=matchColorAES!50]| 73 \\
90 & 41 & a1 & |[fill=matchColorAES!50]| 4f & dd & |[fill=matchColorAES!50]| 22 & aa & |[fill=matchColorAES!50]| 90 & 80 & 45 & ec & f8 & |[fill=matchColorAES!50]| 14 & db & |[fill=matchColorAES!50]| 5e & |[fill=matchColorAES!50]| 0b & 9b \\
a0 & |[fill=matchColorAES!50]| e0 & 7a & 6d & |[fill=matchColorAES!50]| 0a & |[fill=matchColorAES!50]| 49 & |[fill=matchColorAES!50]| 06 & |[fill=matchColorAES!50]| 24 & |[fill=matchColorAES!50]| 5c & ca & |[fill=matchColorAES!50]| d3 & |[fill=matchColorAES!50]| ac & 66 & |[fill=matchColorAES!50]| 91 & |[fill=matchColorAES!50]| 95 & |[fill=matchColorAES!50]| e4 & 32 \\
b0 & |[fill=matchColorAES!50]| e7 & 9a & |[fill=matchColorAES!50]| 37 & 79 & |[fill=matchColorAES!50]| 8d & |[fill=matchColorAES!50]| d5 & |[fill=matchColorAES!50]| 4e & |[fill=matchColorAES!50]| a9 & |[fill=matchColorAES!50]| 6c & |[fill=matchColorAES!50]| 56 & |[fill=matchColorAES!50]| f4 & |[fill=matchColorAES!50]| ea & |[fill=matchColorAES!50]| 65 & 72 & af & |[fill=matchColorAES!50]| 08 \\
c0 & |[fill=matchColorAES!50]| ba & |[fill=matchColorAES!50]| 78 & |[fill=matchColorAES!50]| 25 & |[fill=matchColorAES!50]| 2e & |[fill=matchColorAES!50]| 1c & |[fill=matchColorAES!50]| a6 & |[fill=matchColorAES!50]| b4 & |[fill=matchColorAES!50]| c6 & |[fill=matchColorAES!50]| e8 & dc & |[fill=matchColorAES!50]| 74 & |[fill=matchColorAES!50]| 1f & 5a & bc & |[fill=matchColorAES!50]| 8b & |[fill=matchColorAES!50]| 8a \\
d0 & |[fill=matchColorAES!50]| 70 & |[fill=matchColorAES!50]| 3e & b1 & e6 & |[fill=matchColorAES!50]| 48 & 02 & |[fill=matchColorAES!50]| f6 & |[fill=matchColorAES!50]| 0e & |[fill=matchColorAES!50]| 61 & 75 & |[fill=matchColorAES!50]| 57 & |[fill=matchColorAES!50]| b9 & |[fill=matchColorAES!50]| 86 & |[fill=matchColorAES!50]| c1 & |[fill=matchColorAES!50]| 1d & |[fill=matchColorAES!50]| 9e \\
e0 & e3 & b8 & |[fill=matchColorAES!50]| 98 & 15 & |[fill=matchColorAES!50]| 69 & |[fill=matchColorAES!50]| d9 & 4a & |[fill=matchColorAES!50]| 94 & da & |[fill=matchColorAES!50]| 1e & |[fill=matchColorAES!50]| 87 & f9 & |[fill=matchColorAES!50]| ce & |[fill=matchColorAES!50]| 55 & 3c & |[fill=matchColorAES!50]| df \\
f0 & |[fill=matchColorAES!50]| 8c & 81 & |[fill=matchColorAES!50]| 89 & 4d & |[fill=matchColorAES!50]| bf & 62 & 52 & |[fill=matchColorAES!50]| 68 & 60 & |[fill=matchColorAES!50]| 99 & |[fill=matchColorAES!50]| 2d & |[fill=matchColorAES!50]| 0f & |[fill=matchColorAES!50]| b0 & |[fill=matchColorAES!50]| 54 & b3 & |[fill=matchColorAES!50]| 16 \\
};
\end{tikzpicture}
\caption{An optimized AES S-box using Algorithm \ref{algo}}
\label{fig:S_AES_opt}
\end{figure}
\begin{figure}
\centering
\begin{tikzpicture}[scale=0.7, every node/.style={anchor=base,text depth=.4ex,text height=1ex,text width=2ex, scale=0.7}]
\matrix (A) [matrix of nodes, nodes={draw}, font=\ttfamily, row 1/.style={nodes={fill=gray!50}}, column 1/.style={nodes={fill=gray!50}}]
{ & 00 & 01 & 02 & 03 & 04 & 05 & 06 & 07 & 08 & 09 & 0a & 0b & 0c & 0d & 0e & 0f \\
00 & |[fill=matchColorWhirl!50]| 18 & |[fill=matchColorWhirl!50]| 23 & |[fill=matchColorWhirl!50]| c6 & |[fill=matchColorWhirl!50]| e8 & |[fill=matchColorWhirl!50]| 87 & |[fill=matchColorWhirl!50]| b8 & |[fill=matchColorWhirl!50]| 01 & |[fill=matchColorWhirl!50]| 4f & |[fill=matchColorWhirl!50]| 36 & |[fill=matchColorWhirl!50]| a6 & |[fill=matchColorWhirl!50]| d2 & |[fill=matchColorWhirl!50]| f5 & |[fill=matchColorWhirl!50]| 79 & |[fill=matchColorWhirl!50]| 6f & |[fill=matchColorWhirl!50]| 91 & |[fill=matchColorWhirl!50]| 52 \\
10 & f8 & 46 & ae & 1f & df & 5d & 0d & 83 & ca & 28 & e0 & ec & 22 & 6d & |[fill=matchColorWhirl!50]| fe & 2a \\
20 & 53 & 67 & |[fill=matchColorWhirl!50]| 37 & f4 & 3f & d0 & 2d & ce & 38 & 59 & 2b & 0c & c9 & e3 & |[fill=matchColorWhirl!50]| 6b & b1 \\
30 & 9d & 5b & |[fill=matchColorWhirl!50]| 10 & 26 & |[fill=matchColorWhirl!50]| cb & bc & da & 73 & e6 & 33 & |[fill=matchColorWhirl!50]| 41 & 09 & 34 & |[fill=matchColorWhirl!50]| 7d & fc & 98 \\
40 & 92 & dd & 74 & 35 & bb & ab & 5f & |[fill=matchColorWhirl!50]| 9e & c8 & 5c & a7 & 8d & af & 4c & 81 & 3b \\
50 & 19 & 32 & 0b & |[fill=matchColorWhirl!50]| 71 & 8f & 89 & 13 & 63 & c2 & 51 & 4a & 21 & |[fill=matchColorWhirl!50]| 9a & 0a & 06 & 04 \\
60 & 93 & |[fill=matchColorWhirl!50]| 0f & |[fill=matchColorWhirl!50]| d5 & 82 & ba & |[fill=matchColorWhirl!50]| cd & 1e & 84 & |[fill=matchColorWhirl!50]| ff & |[fill=matchColorWhirl!50]| 7a & 85 & 47 & e1 & c1 & |[fill=matchColorWhirl!50]| 1a & e4 \\
70 & 6c & |[fill=matchColorWhirl!50]| 54 & c3 & f3 & 60 & ad & 8c & 5e & 1c & 44 & 02 & dc & 1b & |[fill=matchColorWhirl!50]| a1 & a3 & |[fill=matchColorWhirl!50]| 3d \\
80 & b5 & |[fill=matchColorWhirl!50]| 00 & ed & 2f & 78 & d9 & 9f & 49 & 17 & 69 & |[fill=matchColorWhirl!50]| 6a & f7 & 31 & 77 & |[fill=matchColorWhirl!50]| 30 & |[fill=matchColorWhirl!50]| ef \\
90 & 2e & d1 & |[fill=matchColorWhirl!50]| a2 & |[fill=matchColorWhirl!50]| ea & fb & 9b & 97 & 40 & d8 & 9c & 55 & |[fill=matchColorWhirl!50]| 4d & f2 & |[fill=matchColorWhirl!50]| 75 & 27 & |[fill=matchColorWhirl!50]| 8a \\
a0 & eb & 86 & 5a & fa & 42 & ee & |[fill=matchColorWhirl!50]| a8 & b7 & f1 & 57 & 29 & 80 & 90 & 12 & |[fill=matchColorWhirl!50]| 39 & 65 \\
b0 & cf & 3c & 76 & f0 & 7b & 61 & 62 & 03 & 11 & 45 & 20 & 16 & |[fill=matchColorWhirl!50]| 43 & |[fill=matchColorWhirl!50]| c7 & bf & d6 \\
c0 & 05 & 4e & 4b & 1d & db & b3 & |[fill=matchColorWhirl!50]| 7e & f6 & 72 & 66 & de & a5 & e7 & f9 & 7f & b2 \\
d0 & 25 & b0 & be & 50 & 68 & 70 & bd & 07 & d3 & |[fill=matchColorWhirl!50]| 6e & |[fill=matchColorWhirl!50]| c4 & e5 & 3e & b9 & 8e & |[fill=matchColorWhirl!50]| a9 \\
e0 & 8b & 94 & 08 & 15 & cc & aa & fd & b4 & c5 & 58 & a0 & 56 & 2c & 0e & |[fill=matchColorWhirl!50]| 14 & c0 \\
f0 & 24 & |[fill=matchColorWhirl!50]| 3a & ac & 99 & e9 & |[fill=matchColorWhirl!50]| b6 & d4 & 95 & 48 & a4 & 88 & e2 & d7 & 7c & 64 & 96 \\
};
\end{tikzpicture}
\caption{An optimized Whirlpool S-box using Algorithm \ref{algo}}
\label{fig:S_Whirl_opt}
\end{figure}
\begin{figure}
\centering
\begin{tikzpicture}[scale=0.7, every node/.style={anchor=base,text depth=.4ex,text height=1ex,text width=2ex, scale=0.7}]
\matrix (A) [matrix of nodes, nodes={draw}, font=\ttfamily, row 1/.style={nodes={fill=gray!50}}, column 1/.style={nodes={fill=gray!50}}]
{ & 00 & 01 & 02 & 03 & 04 & 05 & 06 & 07 & 08 & 09 & 0a & 0b & 0c & 0d & 0e & 0f \\
00 & |[fill=matchColorFantomas!50]| 1e & |[fill=matchColorFantomas!50]| 75 & |[fill=matchColorFantomas!50]| 5f & |[fill=matchColorFantomas!50]| e1 & |[fill=matchColorFantomas!50]| 99 & |[fill=matchColorFantomas!50]| fc & |[fill=matchColorFantomas!50]| 89 & |[fill=matchColorFantomas!50]| 2f & |[fill=matchColorFantomas!50]| 86 & |[fill=matchColorFantomas!50]| ee & |[fill=matchColorFantomas!50]| f1 & |[fill=matchColorFantomas!50]| 7b & |[fill=matchColorFantomas!50]| 23 & |[fill=matchColorFantomas!50]| 52 & |[fill=matchColorFantomas!50]| 10 & |[fill=matchColorFantomas!50]| 94 \\
10 & 4f & 59 & 2c & 8b & f8 & |[fill=matchColorFantomas!50]| 42 & 30 & 00 & 6e & 84 & 35 & 70 & a0 & c3 & 34 & 6f \\
20 & 4e & 41 & 01 & 78 & 8f & |[fill=matchColorFantomas!50]| a8 & 07 & |[fill=matchColorFantomas!50]| 6c & 62 & af & 7f & |[fill=matchColorFantomas!50]| 22 & |[fill=matchColorFantomas!50]| 60 & 79 & 90 & ec \\
30 & 68 & |[fill=matchColorFantomas!50]| f4 & c4 & |[fill=matchColorFantomas!50]| 32 & 1d & 8c & 0e & ce & de & |[fill=matchColorFantomas!50]| 3f & 44 & 1f & 40 & 98 & |[fill=matchColorFantomas!50]| 43 & d6 \\
40 & e7 & cc & e0 & e6 & d1 & 9a & 1a & b3 & 28 & 1c & 7c & 0c & b9 & |[fill=matchColorFantomas!50]| c0 & 71 & 21 \\
50 & cb & 11 & 9e & |[fill=matchColorFantomas!50]| e3 & 48 & cd & e9 & 57 & f5 & 63 & 36 & 1b & b8 & bf & 9d & a7 \\
60 & 61 & d7 & f3 & |[fill=matchColorFantomas!50]| a9 & 12 & fd & |[fill=matchColorFantomas!50]| c1 & b7 & 8e & |[fill=matchColorFantomas!50]| a6 & 6b & 66 & |[fill=matchColorFantomas!50]| 72 & 64 & 85 & d5 \\
70 & |[fill=matchColorFantomas!50]| 4b & 7e & 67 & 3c & 65 & 17 & ba & 4a & |[fill=matchColorFantomas!50]| 97 & 29 & 83 & 6a & ae & f0 & e4 & 2e \\
80 & 77 & 74 & e8 & 2a & |[fill=matchColorFantomas!50]| ac & 95 & 3a & a2 & 3d & fa & 50 & 58 & ea & 9f & 93 & 33 \\
90 & b5 & 5c & 06 & |[fill=matchColorFantomas!50]| 51 & a3 & |[fill=matchColorFantomas!50]| 76 & 7a & 80 & bd & 16 & 39 & 0a & 03 & 73 & d0 & |[fill=matchColorFantomas!50]| 05 \\
a0 & f9 & b0 & 55 & 2d & b2 & 49 & f7 & |[fill=matchColorFantomas!50]| 19 & c6 & 45 & |[fill=matchColorFantomas!50]| d2 & d8 & 5d & f2 & 87 & ed \\
b0 & da & eb & 91 & ca & 3b & 47 & cf & |[fill=matchColorFantomas!50]| fb & c7 & dc & f6 & a4 & df & fe & b1 & |[fill=matchColorFantomas!50]| 09 \\
c0 & 0f & 0d & 2b & 26 & 14 & ff & 4d & |[fill=matchColorFantomas!50]| bc & |[fill=matchColorFantomas!50]| 02 & 81 & b4 & be & 15 & c5 & d4 & 27 \\
d0 & |[fill=matchColorFantomas!50]| 88 & 04 & 82 & c8 & 46 & e5 & 24 & c2 & 9b & 7d & 8d & d9 & 38 & 6d & ef & |[fill=matchColorFantomas!50]| a1 \\
e0 & dd & |[fill=matchColorFantomas!50]| 69 & |[fill=matchColorFantomas!50]| 5a & 54 & 9c & 53 & 25 & 20 & 5b & db & 37 & 5e & ab & 56 & 0b & 4c \\
f0 & 13 & 3e & 8a & d3 & ad & 31 & 08 & 96 & a5 & 18 & b6 & e2 & aa & 92 & c9 & bb \\
};
\end{tikzpicture}
\caption{An optimized Fantomas S-box using Algorithm \ref{algo}}
\label{fig:S_Fantomas_opt}
\end{figure}
\begin{figure}
\centering
\begin{tikzpicture}[scale=0.7, every node/.style={anchor=base,text depth=.4ex,text height=1ex,text width=2ex, scale=0.7}]
\matrix (A) [matrix of nodes, nodes={draw}, font=\ttfamily, row 1/.style={nodes={fill=gray!50}}, column 1/.style={nodes={fill=gray!50}}]
{ & 00 & 01 & 02 & 03 & 04 & 05 & 06 & 07 & 08 & 09 & 0a & 0b & 0c & 0d & 0e & 0f \\
00 & |[fill=matchColorSkipjack!50]| a3 & |[fill=matchColorSkipjack!50]| d7 & |[fill=matchColorSkipjack!50]| 09 & |[fill=matchColorSkipjack!50]| 83 & |[fill=matchColorSkipjack!50]| f8 & |[fill=matchColorSkipjack!50]| 48 & |[fill=matchColorSkipjack!50]| f6 & |[fill=matchColorSkipjack!50]| f4 & |[fill=matchColorSkipjack!50]| b3 & |[fill=matchColorSkipjack!50]| 21 & |[fill=matchColorSkipjack!50]| 15 & |[fill=matchColorSkipjack!50]| 78 & |[fill=matchColorSkipjack!50]| 99 & |[fill=matchColorSkipjack!50]| b1 & |[fill=matchColorSkipjack!50]| af & |[fill=matchColorSkipjack!50]| f9 \\
10 & 5a & 6b & 69 & 0a & 0f & 27 & |[fill=matchColorSkipjack!50]| ca & 2f & |[fill=matchColorSkipjack!50]| 52 & |[fill=matchColorSkipjack!50]| 95 & c3 & 0d & |[fill=matchColorSkipjack!50]| 4e & a0 & c5 & 2c \\
20 & 8a & 12 & 38 & 6e & bb & d9 & c8 & e2 & cd & 02 & 7e & 5f & f1 & 87 & 19 & 8f \\
30 & |[fill=matchColorSkipjack!50]| 96 & fe & 2d & de & b2 & 6f & b6 & ac & 0c & |[fill=matchColorSkipjack!50]| ae & |[fill=matchColorSkipjack!50]| e5 & 7c & |[fill=matchColorSkipjack!50]| f7 & 43 & aa & 2a \\
40 & b9 & f3 & |[fill=matchColorSkipjack!50]| 7b & 1e & eb & 9a & cf & 73 & |[fill=matchColorSkipjack!50]| ee & 61 & |[fill=matchColorSkipjack!50]| 1a & a9 & 50 & 9b & ff & |[fill=matchColorSkipjack!50]| b8 \\
50 & 76 & 39 & 92 & 7f & 3a & 8c & |[fill=matchColorSkipjack!50]| bf & 14 & 60 & |[fill=matchColorSkipjack!50]| 58 & |[fill=matchColorSkipjack!50]| 80 & e1 & |[fill=matchColorSkipjack!50]| 66 & |[fill=matchColorSkipjack!50]| 0b & 86 & |[fill=matchColorSkipjack!50]| 90 \\
60 & 1f & 91 & 62 & ed & |[fill=matchColorSkipjack!50]| 33 & a6 & |[fill=matchColorSkipjack!50]| 65 & e0 & 67 & d4 & 82 & d6 & |[fill=matchColorSkipjack!50]| 6d & |[fill=matchColorSkipjack!50]| 98 & e6 & 74 \\
70 & e8 & 44 & 93 & |[fill=matchColorSkipjack!50]| c2 & |[fill=matchColorSkipjack!50]| b0 & fc & 9d & 6a & 81 & fa & 56 & 42 & 4d & 05 & |[fill=matchColorSkipjack!50]| 4a & 5c \\
80 & d8 & 5d & df & a4 & |[fill=matchColorSkipjack!50]| 49 & 1d & 9e & 16 & 4c & |[fill=matchColorSkipjack!50]| d2 & be & 00 & ba & c6 & 47 & 53 \\
90 & 84 & c0 & 55 & 3f & 1c & c7 & d5 & a2 & 88 & 34 & |[fill=matchColorSkipjack!50]| dc & |[fill=matchColorSkipjack!50]| c9 & 7d & 3c & |[fill=matchColorSkipjack!50]| 31 & 20 \\
a0 & d3 & 2e & e9 & 28 & 9c & 8e & 23 & ce & dd & 94 & 85 & a5 & 22 & 79 & a8 & |[fill=matchColorSkipjack!50]| 40 \\
b0 & 30 & |[fill=matchColorSkipjack!50]| 4b & e4 & 1b & |[fill=matchColorSkipjack!50]| d1 & 89 & a7 & |[fill=matchColorSkipjack!50]| 3b & 11 & c1 & fd & 36 & e7 & cc & |[fill=matchColorSkipjack!50]| 5b & 64 \\
c0 & 9f & |[fill=matchColorSkipjack!50]| 04 & a1 & 51 & 97 & 13 & 26 & |[fill=matchColorSkipjack!50]| f0 & |[fill=matchColorSkipjack!50]| 29 & db & cb & 7a & 75 & 8b & 77 & d0 \\
d0 & 3d & |[fill=matchColorSkipjack!50]| ef & |[fill=matchColorSkipjack!50]| bc & 70 & 71 & 63 & |[fill=matchColorSkipjack!50]| 37 & 2b & |[fill=matchColorSkipjack!50]| ec & 41 & da & 24 & ad & 8d & |[fill=matchColorSkipjack!50]| 10 & 18 \\
e0 & 01 & b5 & 54 & 07 & 35 & |[fill=matchColorSkipjack!50]| 4f & b7 & c4 & |[fill=matchColorSkipjack!50]| 32 & 17 & b4 & fb & 72 & 06 & ab & 0e \\
f0 & |[fill=matchColorSkipjack!50]| 5e & |[fill=matchColorSkipjack!50]| 6c & 68 & f2 & |[fill=matchColorSkipjack!50]| 57 & |[fill=matchColorSkipjack!50]| 25 & f5 & |[fill=matchColorSkipjack!50]| e3 & |[fill=matchColorSkipjack!50]| bd & 08 & 3e & 03 & 45 & |[fill=matchColorSkipjack!50]| 59 & ea & |[fill=matchColorSkipjack!50]| 46 \\
};
\end{tikzpicture}
\caption{An optimized Skipjack S-box using Algorithm \ref{algo}}
\label{fig:S_Skipjack_opt}
\end{figure}
\begin{figure}[]
\centering
\begin{tikzpicture}[scale=0.7, every node/.style={anchor=base,text depth=.4ex,text height=1ex,text width=2ex, scale=0.7}]
\matrix (A) [matrix of nodes, nodes={draw}, font=\ttfamily, row 1/.style={nodes={fill=gray!50}}, column 1/.style={nodes={fill=gray!50}}]
{ & 00 & 01 & 02 & 03 & 04 & 05 & 06 & 07 & 08 & 09 & 0a & 0b & 0c & 0d & 0e & 0f \\
00 & ab & f0 & 5e & 3f & fa & e2 & 6f & 8e & 3c & 36 & 30 & db & 29 & 73 & da & 45 \\
10 & 87 & f9 & 60 & 3b & bf & a4 & c7 & 0c & a9 & c0 & f3 & cb & 68 & ff & ee & a6 \\
20 & 90 & 57 & f2 & 77 & ef & c2 & 78 & b7 & 94 & 32 & e6 & 4d & 53 & 6d & 26 & 98 \\
30 & c1 & 2c & 2a & 9a & 12 & 2b & ea & e8 & 17 & 7c & 5c & 6e & 50 & d9 & f6 & 88 \\
40 & 83 & 69 & 5a & 67 & af & b9 & 1a & b8 & 8a & d4 & b4 & a0 & cc & e1 & 24 & c6 \\
50 & be & 1f & a1 & 51 & 9f & 64 & 4e & 4f & 2f & 85 & 6b & 76 & 86 & 35 & 4b & ed \\
60 & 81 & 84 & 39 & 13 & 62 & c3 & 9e & dc & d0 & 66 & 5f & 44 & de & 1c & bd & 34 \\
70 & 1d & 1e & 2d & 6c & a2 & 46 & 97 & c5 & 37 & 61 & a3 & 56 & fe & f7 & d5 & 38 \\
80 & ce & 05 & 09 & 18 & aa & fc & 91 & 28 & 9b & 10 & e9 & 0b & 71 & dd & e7 & 23 \\
90 & 7f & 72 & 59 & 6a & 43 & fd & d1 & e4 & f8 & 0d & 55 & 74 & c8 & f5 & 27 & 65 \\
a0 & 93 & c4 & 19 & 49 & 00 & 20 & 3d & 2e & a8 & d3 & 01 & 7d & 25 & 0e & f4 & 33 \\
b0 & 02 & 04 & 0a & 14 & 16 & ae & 31 & 11 & cf & 79 & 8f & d8 & 8b & d7 & ca & b3 \\
c0 & bb & 3e & 0f & 92 & df & 40 & 4c & cd & ac & 22 & 5b & a5 & bc & f1 & 75 & 89 \\
d0 & 96 & b1 & e3 & d2 & 7a & 1b & 70 & 58 & 03 & 47 & 80 & 9c & 06 & ba & c9 & 54 \\
e0 & ad & 41 & 99 & 48 & 7e & 3a & 95 & e0 & ec & 07 & 63 & 7b & b2 & 21 & b0 & 4a \\
f0 & 8d & d6 & 15 & fb & 9d & 5d & 8c & 42 & 08 & b6 & eb & a7 & b5 & e5 & 52 & 82 \\
};
\end{tikzpicture}
\caption{An optimized S-box $S_c(8,8)$ using Algorithm \ref{algo}}
\label{fig:Sc_raw}
\end{figure}
\begin{table}
\centering
\caption{Nonlinearities of $S_c$ by coordinates}
\label{tab:proposed8}
\scalebox{0.9}{
\begin{tabular}{rllllllll}
& \multicolumn{8}{c}{} \\
Method & $f_1$ & $f_2$ & $f_3$ & $f_4$ & $f_5$ & $f_6$ & $f_7$ & $f_8$ \\
\noalign{\smallskip}\hline\noalign{\smallskip}
this work & 114 & 114 & 114 & 114 & 114 & 114 & 114 & 114 \\
\noalign{\smallskip}\hline
\end{tabular}}
\end{table}
\begin{table}
\begin{center}
\caption{SAC, Coordinate-average and final nonlinearity of $S_c$}
\label{tab:proposedNL}
\scalebox{1}{
\begin{tabular}{rllccc}
\hline
Method & min & max & ACNV & SAC & NL \\
\noalign{\smallskip}\hline\noalign{\smallskip}
this work & 114 & 114 & 114 & 0.5000000 & 96 \\
\noalign{\smallskip}\hline
\end{tabular}}
\end{center}
\end{table}
\section{S-box as multi-armed bandits}
\label{sec:bandits}
The space of bijective S-boxes is vast. For example, in the case of (8,8) S-boxes, we have a total of $256! \approx 2^{1684}$ different bijective S-boxes. Despite algorithm \ref{algo} efficiency in finding S-boxes with better ACNV, we had never reached an ACNV greater than 114. However, we have found out that the multi-armed bandit problem \cite{berry1985bandit}\cite{katehakis1987multi}\cite{li2016art}\cite{li2016collaborative} is closely related to the nonlinearity optimization problem.
Each bijective S-box $S(n,n)$ can be represented as a collection of $n$ bandits, such that each bandit uniquely corresponds to some of the $n$ coordinates of $S$. The arms of each bandit could be associated with the operation of applying a single transposition in $S$, while the profit of our action could be measured with the fitness function presented in Algorithm \ref{algo}.
Associating each one of the possible $n \choose {2}$ transposition of elements of $S$ DLUT to some distinct arm in each bandit is a trivial and non-working model - at the end, the bandits would be indistinguishable. Having this in mind, the following model is constructed:
\begin{itemize}
\item{\textbf{Property I}: Since each bandit uniquely corresponds to some coordinate of $S$, each bandit arm is restricted to initiate a transposition of two bits inside a column of $S_{LUT}$ only (instead of a transposition of any two elements in $S_{DLUT}$).}
\item{\textbf{Property II}: To keep the bijective property of $S$, in case an arm of some bandit is activated, the set of all distinct ${2^n \choose 2}$ bit transpositions in a given coordinate of $S_{LUT}$ is restricted to a subset of transpositions with a size of $2^{n-1}$.}
\end{itemize}
The restriction introduced in \textbf{Property II} is motivated by the following observations:
\begin{enumerate}
\item{\textbf{Existence}: If $b_1b_2 \cdots b_i \cdots b_n$ is a row from $S_{LUT}$, flipping the bit $b_i$ will result in \textbf{some} other row $R = b_1b_2 \cdots \overline{b_i} \cdots b_n$ in $S_{LUT}$. Otherwise, if $R$ is not among the rows of $S_{LUT}$, $S$ is not surjective, therefore not bijective, which contradicts our initial choice of $S$.}
\item{\textbf{One-to-one Maping:} If $b_1b_2 \cdots b_i \cdots b_n$ is a row from $S_{LUT}$, flipping the bit $b_i$ will result in \textbf{only one} row $R = b_1b_2 \cdots \overline{b_i} \cdots b_n$ in $S_{LUT}$. Otherwise, if some other row $R^{'}$ of $S_{LUT}$ exists, s.t. $R \equiv R^{'}$, $S$ is not injective, therefore not bijective, which contradicts our initial choice of $S$.}
\item{\textbf{Search space:} The total number of distinct bit sequences of the form $b_1b_2 \cdots b_{i-1}b_{i+1} \cdots b_n$ is $2^{n-1}$.}
\end{enumerate}
Let's denote as a bandit $B_i$ the bandit, which corresponds to the $i$-th coordinate of $S$. Each bandit consists of $2^{n-1}$ distinct arms, s.t. each arm of $B_i$ corresponds to a distinct value of $b_1b_2 \cdots b_{i-1}b_{i+1} \cdots b_n$. Activating an arm of $B_i$ will result of interchanging two rows of $S_{LUT}$, which differ only in bit position $i$.
For example, let's consider an S-box X(4,4), with $X_{DLUT} = $ [15, 14, 9, 2, 11, 3, 12, 4, 1, 13, 7, 8, 6, 10, 5, 0]. $X$ is a bijective S-box with dimension $4$. Therefore, we can transform $X$ as an $8$-armed $4$-bandit problem. In Figure \ref{fig:bandits}, a visual interpretation of the bandits transformation of $X$ is shown. Each row corresponds to a distinct bandit, while each pair of cells inside a given row, sharing the same color, corresponds to an arm of the given bandit. The x-axis represents the indexes of elements of $X_{DLUT}$ (starting from 1).
As an illustration, if we activate the white arm of bandit 1, we interchange the elements of $X_{DLUT}$ with indexes 14 and 4, i.e. 10 and 2. Their respective binary representations (with zero-fill of 4) are \textbf{1010} and \textbf{0010} (they differ only in bit position 1).
The profit (if any) of activating a bandit $B_i$'s arm is measured by the same function $E$ presented in Algorithm \ref{algo}.
\begin{figure*}
\centering
\includegraphics[width=0.7\textwidth]{DIMIT3.png}
\caption{An example of 8-armed 4-bandit problem transformation of the S-box $X$}
\label{fig:bandits}
\end{figure*}
The transformation of the (n,n) bijective S-box ACNV optimization problem to the $2^{n-1}$-armed $n$-bandit problem allows us to focus on the optimization of the nonlinearity of single coordinates. Furthermore, by design, activating an arm of a given bandit doesn't affect the states of other bandits. Having this in mind, Algorithm \ref{algoBandit} is proposed.
\begin{algorithm}
\caption{}\label{algoBandit}
\begin{algorithmic}[1]
\State $s\gets R(n)$ \Comment{the function R(n) generates pseudo-random bijective S-box $S(n,n)$}
\State $\Omega \gets MODEL(s)$ \Comment{We transform the S-box $s$ to a $2^{n-1}$-armed $n$-bandit problem}
\Repeat
\State $bandit \gets random(1,n,\Lambda)$ \Comment{We choose a random bandit from $\left[1,n \right]$, based on some profit-maximizing strategy $\Lambda$}
\State $arm \gets random(1,2^{n-1})$ \Comment{We choose a random arm from $\left[1,2^{n-1} \right]$}
\State $oldBandit \gets \Call{E}{bandit}$
\State $\Call{Activate}{bandit, arm}$
\If{$\Call{E}{bandit} < \Call{E}{oldBandit}$}
\State $\Omega \gets MODEL(s)$ \Comment{We update the model}
\Else{}
\State $\Call{Activate}{bandit, arm}$ \Comment{We resume the original state of the bandit}
\EndIf
\Until{STOP condition is reached} \Comment{reaching $n{2^{n-1}}$ consequent unsuccessful attempts}
\end{algorithmic}
\end{algorithm}
\section{Results Part II}
Our implementation of Algorithm \ref{algoBandit} is based on a simple strategy $\Lambda$ - we always choose a bandit, which posses the lowest nonlinearity. In case there are several bandits sharing the lowest value of nonlinearity, we choose one of them at random.
We launched Algorithm \ref{algoBandit} as a stand-alone optimization routine, starting from pseudo-randomly generated S-boxes, and in almost all of the instances we reached S-boxes with an average coordinate nonlinearity value of 112. However, when we initiated Algorithm \ref{algoBandit} with S-boxes, which have been already optimized by Algorithm \ref{algo}, we have reached an average coordinate nonlinearity value of 114.5. An example of such S-box is given in Figure \ref{fig:Sc_best}. The corresponding nonlinearity by coordinates is given in Table \ref{tab:114.5}.
\begin{figure}[]
\centering
\begin{tikzpicture}[scale=0.7, every node/.style={anchor=base,text depth=.4ex,text height=1ex,text width=2ex, scale=0.7}]
\matrix (A) [matrix of nodes, nodes={draw}, font=\ttfamily, row 1/.style={nodes={fill=gray!50}}, column 1/.style={nodes={fill=gray!50}}]
{ & 00 & 01 & 02 & 03 & 04 & 05 & 06 & 07 & 08 & 09 & 0a & 0b & 0c & 0d & 0e & 0f \\
00 & a9 & 7b & bb & c9 & 0a & 55 & d1 & c1 & a3 & 1a & 24 & 26 & bf & 72 & f6 & 0d \\
10 & 4a & 73 & e2 & f1 & 3a & d3 & 35 & b2 & 64 & 93 & f5 & d7 & ff & dc & cb & 4e \\
20 & de & 7a & a2 & 98 & d9 & 87 & b3 & a5 & 28 & ba & a0 & 45 & 56 & 67 & 61 & 0c \\
30 & a7 & 33 & 53 & 2d & e7 & 58 & 7e & b6 & 37 & 71 & 1e & 10 & d0 & e0 & b7 & 49 \\
40 & 96 & 91 & 6e & b0 & f9 & 5b & fb & 13 & 8a & db & ad & a1 & 8c & 39 & 22 & ee \\
50 & 89 & 4f & 50 & da & 07 & 75 & 65 & bd & 9f & 18 & cd & 17 & 41 & be & 2f & 40 \\
60 & ca & 05 & ae & 32 & 94 & f7 & a8 & b1 & aa & f8 & e9 & e4 & 82 & 54 & 01 & 69 \\
70 & 27 & 81 & 5c & 84 & 7f & b4 & 29 & d2 & fc & 0e & a4 & 36 & 90 & 2e & 15 & 00 \\
80 & 4c & 51 & 25 & 11 & 16 & f3 & 3d & 8d & 9c & 6c & 95 & ef & 76 & cc & 8b & dd \\
90 & 2b & f4 & ce & 43 & 62 & d4 & 74 & fe & 92 & c2 & 7c & 80 & 2a & 21 & 68 & bc \\
a0 & c0 & 23 & af & e3 & 78 & 6f & e1 & eb & 03 & 38 & 09 & 42 & d6 & ed & ec & 02 \\
b0 & 1d & fa & 5e & b9 & c8 & c7 & 46 & 14 & e6 & 99 & 9d & 04 & c4 & d8 & 3f & 9b \\
c0 & e5 & 4d & 31 & 63 & 79 & 3c & d5 & f0 & 47 & 57 & 4b & c6 & f2 & 2c & 70 & b5 \\
d0 & cf & 9e & 0b & 3e & 1f & 5a & a6 & 6a & 6b & 12 & 1b & 77 & 5f & 48 & ac & 3b \\
e0 & 44 & 34 & 5d & ea & 20 & 85 & 8f & 30 & 9a & ab & 1c & c3 & 59 & 8e & fd & 08 \\
f0 & b8 & e8 & 06 & 6d & 66 & 7d & df & 60 & 52 & 83 & 88 & 19 & 0f & 97 & c5 & 86 \\
};
\end{tikzpicture}
\caption{An optimized, by applying the composition of Algorithms \ref{algo} and \ref{algoBandit}, (8,8) S-box}
\label{fig:Sc_best}
\end{figure}
\begin{table}
\centering
\caption{Nonlinearities of the S-box coordinates given in Figure \ref{fig:Sc_best}}
\label{tab:114.5}
\scalebox{0.9}{
\begin{tabular}{rllllllll}
& \multicolumn{8}{c}{} \\
Method & $f_1$ & $f_2$ & $f_3$ & $f_4$ & $f_5$ & $f_6$ & $f_7$ & $f_8$ \\
\noalign{\smallskip}\hline\noalign{\smallskip}
this work & 116 & 114 & 116 & 114 & 114 & 114 & 114 & 114 \\
\noalign{\smallskip}\hline
\end{tabular}}
\end{table}
In Table \ref{tab:summaryResults}, an extended S-box comparison between the state-of-the-art methods is given. The entries are sorted, in increasing order, by ACNV (the last column).
\begin{table}
\centering
\caption{A comparison of S-boxes, yielded by various methods to be found in the literature, with those S-boxes, reached by the algorithms presented in this work}
\label{tab:summaryResults}
\rowcolors{2}{gray!25}{white}
\begin{tabular}{lllll}
& \multicolumn{3}{c}{} \\
Method & Min NL & Max NL & ACNV \\
\noalign{\smallskip}\hline\noalign{\smallskip}
\cite{khan2015novel}\cite{khan2016construction} & 84 & 106 & 100.0 \\
\cite{jamal2016watermarking} & 98 & 108 & 102.3 \\
\cite{khan2018novel} & 96 & 106 & 102.5 \\
\cite{chen2007extended} & 100 & 106 & 103.0 \\
\cite{khan2012novel} & 96 & 106 & 103.0 \\
\cite{khan2013efficient} & 98 & 108 & 103.0 \\
\cite{jakimoski2001chaos} & 98 & 108 & 103.2 \\
\cite{ozkaynak2010method} & 100 & 106 & 103.2 \\
\cite{tang2005novel} & 99 & 106 & 103.3 \\
\cite{asim2008efficient} & 96 & 108 & 103.5 \\
\cite{tang2005method} & 101 & 108 & 103.8 \\
\cite{ozkaynak2013designing} & 101 & 106 & 103.8 \\
\cite{chen2008novel} & 102 & 106 & 104.0 \\
\cite{khan2013efficient2} & 98 & 108 & 104.0 \\
\cite{khan2014construction} & 100 & 106 & 104.0 \\
\cite{liu2014chaos} & 102 & 106 & 104.0 \\
\cite{khan2016new} & 98 & 108 & 104.0 \\
\cite{liu2018novel} & 102 & 108 & 104.5 \\
\cite{hussain2013group}\cite{ozkaynak2017new} & 100 & 108 & 104.7 \\
\cite{hussain2012novel}\cite{ozkaynak2019analysis} & 102 & 108 & 104.7 \\
\cite{khan2015efficient} & 100 & 108 & 104.75 \\
\cite{hussain2012construction} & 100 & 107 & 104.8 \\
\cite{ozkaynak2017biometric} & 104 & 106 & 105.0 \\
\cite{hussain2013novel} & 102 & 108 & 105.2 \\
\cite{belazi2017efficient} & 102 & 108 & 105.3 \\
\cite{hussain2013projective} & 100 & 110 & 105.5 \\
\cite{khan2014novel} & 98 & 110 & 105.5 \\
\cite{belazi2017simple} & 102 & 110 & 105.5 \\
\cite{liu2015designing} & 104 & 108 & 105.7 \\
\cite{ul2017designing} & 102 & 108 & 106.0 \\
\cite{ccavucsouglu2018novel}\cite{wang2018chaotic}\cite{wang2019s}a & 104 & 110 & 106.0 \\
\cite{wang2019s}c & 106 & 108 & 106.0 \\
\cite{ccavucsouglu2017novel} & 104 & 110 & 106.2 \\
\cite{farah2017novel} & 104 & 110 & 106.5 \\
\cite{lambic2018s} & 106 & 108 & 106.5 \\
\cite{ozkaynak2019construction}\cite{lambic2017novel} & 106 & 108 & 106.7 \\
\cite{ye2018chaotic} & 104 & 108 & 106.7 \\
\cite{ahmad2015novel} & 106 & 110 & 107.0 \\
\cite{wang2019s}b & 104 & 108 & 107.0 \\
\cite{ahmed2019novel} & 106 & 108 & 107.5 \\
\cite{yi2019novel} & 106 & 110 & 107.75 \\
\cite{wang2012novel} & 108 & 108 & 108.0 \\
\cite{zhang2014chaotic} & 104 & 110 & 108.0 \\
\cite{al2018new} & 106 & 110 & 108.5 \\
\cite{lambic2014novel} & 108 & 112 & 109.0 \\
\cite{hussain2013efficient}\cite{hussain2013efficient2}\cite{belazi2017chaos} & 112 & 112 & 112.0 \\
Alg.2 (this work) & 112 & 112 & 112.0 \\
Alg.1 (this work)& 114 & 114 & 114.0 \\
Alg.1 $\bigcup$ Alg.2 (this work) & 114 & 116 & 114.5 \\
\noalign{\smallskip}\hline
\end{tabular}
\end{table}
\section{Conclusion and future work}
\label{sec:6}
CF-based S-box construction is a relatively new and interesting technique, which interconnects the tools provided by various academic disciplines with the problem of finding secure cryptographic primitives.
In this paper, we analyzed the actual linear cryptanalysis resistance of CF-based S-boxes, which differs from the average nonlinearity value announced by a great number of papers. Integrating such S-boxes in a cryptosystem should be done with a considerable caution. For example, if we interchange the Rijndael S-box in AES \cite{AES} with some CF-based S-box with higher ACNV, but lower overall nonlinearity, the resulting modified block cipher will be significantly weaker in terms of resistance to linear cryptanalysis. Furthermore, we show that exploiting chaos structures, in the context of nonlinearity optimization problem, is arguable. Thus, the benefits of using chaos structures in the design of S-boxes is unclear and yet to be determined. However, as stated in \cite{accikkapi2019side}, the chaos-based designs may be an alternative to application attacks, such as side-channel analysis.
Nevertheless, from designer perspective, if the overall nonlinearity value of an S-box $S$ is negligible compared to the average nonlinearity value of all coordinates of $S$, two novel S-box constructions are suggested.
While Algorithm \ref{algo} yields better results than Algorithm \ref{algoBandit}, the latest could be used as an Algorithm \ref{algo} extension, to further improve the parameters of the resulting S-box. The methods presented in this paper significantly outperform all other state-of-the-art methods for designing S-boxes with high ACNV.
The linkage of the $n$-armed bandit problem to the problem of finding such S-boxes, opens an interesting area of future research - the investigation of how other state-of-the-art methods, such as the concept of fuzzy graphs \cite{rosenfeld1975fuzzy}\cite{hao2016mining}, the stochastic optimization techniques \cite{ermoliev1988numerical}\cite{thathachar2011networks}\cite{narasimhan2016stochastic}, or the exploration-exploitation algorithms \cite{alba2005exploration}\cite{macready1998bandit}\cite{li2015data}, could be exploited to further maximize the ACNV of a given S-box.
An interesting open question to be answered is to what extend the ACNV value of an (8,8) bijective S-box could be optimized? As summarized in \cite{picek2016maximal}, the maximal nonlinearity value achieved in balanced boolean functions with 8 variables is 116. Therefore, if an ACNV for an (8,8) bijective S-box greater than 116.0 is ever found, at least one of its eight components will posses nonlinearity value 118, which will finally give an answer to the long-standing problem of the maximum possible nonlinearity value of an eight variable balanced boolean functions. Furthermore, as shown in \cite{sarkar2000nonlinearity}, the upper bound for eight variable balanced boolean functions is less than 120. Thus, the maximum theoretical possible ACNV of (8,8) bijective S-boxes is less or equal to 118.0, but most probably, considering the academic skepticism that eight variable balanced boolean functions with nonlinearity value 118 really exist, less or equal to 116.0.
\bibliographystyle{IEEEtran}
| {'timestamp': '2020-06-19T02:09:21', 'yymm': '2006', 'arxiv_id': '2006.10289', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10289'} | arxiv |
\section{Introduction}
Advances in large scale data processing and computation enables the application of sophisticated learning algorithms to robotic design in complex and dynamic environments. In many applications a fundamental challenge lies not only in learning about the interaction between the ego agent and the environment, but also interactions between multiple agents. Due to the high dimensionality and typically noisy nature of the data required for such learning tasks, a standard approach is to utilize strong modeling assumptions on the interactions. For example, the interaction between a robotic agent and the environment can be represented by instantaneous physical variables such as positions, velocities, a time series of which are then endowed with a stationary distribution for mathematical convenience and interpretability (e.g., via a Markov process framework). While such approach is useful in highly controlled environments, the strong modeling assumption are usually violated in domains where the interactions among agents and with the environment are highly dynamic~\cite{foerster2017multi-agent}. Such domains require the development of more robust and data-driven representation learning approaches.
As a concrete example which serves as a primary motivation for this work, take the interaction between two intelligent vehicles that approach each other in a typical intersection. What the two vehicles proceed to do next depend on what they can learn of their encounter in real-time. The two cars may come toward the intersection in varying speeds at perhaps slightly different time points. They may or may not signal their intention. For example, one plans to go straight while the other plans to take a turn cutting through the other's path. Not only do the two agents have to learn their temporally varying interaction, they have to do so quickly and accurately while continually negotiating the traffic. In this type of applications where the interaction is highly dynamic, a promising approach to robust interaction learning is by decomposing the interaction in terms of simpler elements~\cite{1549935, Wang-Zhao-2017}. For traffic applications, such interaction elements are called traffic \emph{primitives}. These primitives can be learned, labeled, and effectively utilized for subsequent tasks such as vehicle trajectory prediction~\cite{zhu2019_nplstm_trajectory}, traffic data generation \cite{ding2018multi_vae_generation, zhang2019multi_gp_generation}, or anomaly detection \cite{ zhang2019learning_primitve_itsc}.
Stripping away the language of vehicle-to-vehicle (V2V) interactions, the temporal dynamic interaction between two agents comprises of a pair of well-aligned trajectories defined on a suitable space that satisfy constraints presented by the environment and agents' behaviors. Thus, the goal of robust representation learning of a pairwise interaction between the two dynamic agents boils down to the learning of pairs of functions or curves which describe the aligned car physical movements and/or driving behaviors. Such a mathematical viewpoint can be generalized to interactions among three or more vehicles. In this paper we will focus on the learning of interactions in two-agent dynamic scenarios. Although our work is motivated by the learning of multi-agent traffic interaction's primitives, we believe that the techniques developed here can be utilized to other settings of multi-agent temporal dynamic interaction learning.
Within the context of real-world traffic learning, both rule-based methods \cite{frazzoli2005maneuver_primitive}, supervised learning \cite{pervez2017learning_primitive_supervised}, and unsupervised learning \cite{Wang-Zhao-2017} have been applied to identify the interaction primitives. Due to the heterogeneity and complexity of traffic scenarios, unsupervised learning is a powerful tool to identify latent structures in unlabeled traffic scenario time series data; the goal is to organize the data into homogeneous groups/ clusters \cite{Bender-et-al-2015, Hamada-et-al-2016, Taniguchi-et-al-2015, Wang-Xi-Zhao-2017, liao2005clustering_survey}. Within automatically learned clusters, interpretable and typical driving behaviors can be obtained and analyzed, e.g., left/right turns along with multiple attributes including speed, acceleration, yaw rate and side-slip angle using Dynamic Time Wrapping (DTW) as a similarity measure \cite{Yao_2019_meta_learning_traffic}. Statistical model-based approaches that can learn complex driving behaviors while allowing for encoding domain-knowledge are also available. For instance, primitive segments extracted from time series traffic data can be obtained without specifying the number of categories via Bayesian nonparametric methods based on Dirichlet processes. They include hierarchical Dirichlet Process Hidden Markov Model (HDP-HMM) \cite{Taniguchi-et-al-2016, Wang-Xi-Zhao-2017}. Dirichlet process mixtures of Gaussian processes were also successfully employed to identify complex multi-vehicle velocity fields \cite{guo2019modeling_dpgp, joseph2011bayesian_dpgp}.
Given the plethora of methods and the need for learning complex interaction patterns in dynamic domains, it is natural to ask which method one should use.
For unsupervised learning, this question is particularly challenging because one typically works with unlabelled data and without immediately available objective functions for the quality of learned clusters of interactions, especially ones which are mathematically represented as a collection of two or more curves taking values in a suitable space, as discussed above. In addition, while the problem of devising techniques which are free of any tuning parameters is an important one, parameter-free algorithms tend to be not robust. A typical unsupervised learning method still requires some prior knowledge or pre-defined parameters (tuning knobs). As a result, clustering results may still be sensitive to these choices. Thus, even when a method is settled on, it is still an important issue how to handle the various tuning knobs and to assess their sensitivity, or stability with respect to changes in the tuning parameters.
Identifying suitable clustering criteria and analyzing learning stability/sensitivity have received much attention in data mining and statistical learning literatures.
For clustering criteria, there are broadly two categories: internal and external criteria \cite{XuWunschClustering2009}. Internal criteria relies on a similarity or dissimilarity measure that may be applied to the data samples. Such measures evaluate how alike the members of the same cluster are, how different the members of different clusters are, or some combination of thereof \cite{RokachMaimonClusteringMethods2005,XuTianComprehensiveSurveyClustering2015}.
On the other hand, there is a priori structure how the data should be partitioned, external criteria allow one to compare the clustering results against this structure \cite{RokachMaimonClusteringMethods2005}. Examples include Rand index, mutual information and model-based likelihood-type objectives \cite{XuTianComprehensiveSurveyClustering2015}.
Meanwhile, there is a rich literature on sensitivity analysis that focuses on the impacts of changes in model/method specification on the learning outcomes, see, e.g. textbooks \cite{ChatterjeeHadiSensitivityAnalysisLinear1988, SaltelliEtAlSensitivityAnalysisPractice2004, SaltelliEtAlGlobalSensitivityAnalysis2008}. If we focus on Bayesian methods or model-based methods, the key issue is on the effect of the prior/ model specification.
While there are a number of variations, most sensitivity analysis techniques involve model fitting with varying prior/ model specifications, and assessing the impacts on posterior distributions or estimates of parameters of interest. A model is said to be robust if the estimates are relatively insensitive to such varying specifications \cite{GustafsonLocalRobustnessBayesian2000,SivaganesanGlobalLocalRobustness2000}. Alternatively, instead of varying the model parameters one may consider perturbing data: a geometric framework was developed to conduct sensitivity analysis with respect to the perturbation of the data, the prior and the sampling distribution for a class of statistical models. Within this framework, various geometric quantities were studied to characterize the intrinsic structure and effect of the perturbation \cite{ZhuEtAlBayesianInfluenceAnalysis2011}.
\comment{
Briefly, there are three broad categories: informal sensitivity analysis, global sensitivity analysis, and local sensitivity analysis \cite{GustafsonLocalRobustnessBayesian2000}. In an informal sensitivity analysis, one might fit the model with a few different priors and compare the results. A global sensitivity approach formalizes this by considering a class of priors and then examining the range of results \cite{SivaganesanGlobalLocalRobustness2000}.
If the class of priors is reasonably sized and the resultant range of posterior learning is small, then the model is said to be robust, i.e., insensitive to the prior \cite{SivaganesanGlobalLocalRobustness2000}. Alternatively, one may consider the rate of change in the posterior learning results based on a local change in prior, where the rate of change is measured via a suitable notion of derivative of the posterior distribution, an approach known as local sensitivity analysis \cite{GustafsonLocalRobustnessBayesian2000}.
This type of analysis has been applied to hierarchical models \cite{RoosEtAlSensitivityAnalysisBayesian2015}. The variational Bayes technique was also employed to approximate the change in the posterior distribution on these types of models \cite{GiordanoEtAlCovariancesRobustnessVariational2018}. Finally, a geometric framework was developed to conduct sensitivity analysis with respect to the perturbation of the data, the prior and the sampling distribution for a class of statistical models. Within this framework, various geometric quantities were studied to characterize the intrinsic structure and effect of the perturbation \cite{ZhuEtAlBayesianInfluenceAnalysis2011}.}
To assess the quality of unsupervised learning methods for temporal dynamic interactions, at a high level one may consider the aforementioned methods and frameworks. Moreover, it is necessary to develop a set of suitable metrics for interaction comparison and for assessing the stability of an unsupervised learning method with respect to its tuning parameters.
Motivated by the representation of dynamic vehicle-to-vehicle interactions that arise in the traffic learning domain, one has to effectively deal with pairs of aligned functions, i.e., trajectories taking values in a suitable space, which is typically non-Euclidean and has high or infinite dimensions. Such metrics must account for the geometric constraints in the physical world as well as the uncertainty associated with the learned patterns.
To this end, we introduce a model-free metric on pairs of functions based on a Procrustes-type distance, and an optimal transport based Wasserstein distance metric for comparing between distributions of such pairs of functions. The former metric is critical because it preserves translation and rotation invariance, key properties required for capturing the essence of the temporal dynamic between two autonomous or semi-autonomous agents (e.g., vehicles or robots). The latter metric is also appropriate because the result of a clustering algorithm can be mathematically represented as the solution of an optimal transport problem~\cite{Graf-Luschgy-00,ho2017multilevel}.
In addition to some connection to optimal transport based clustering, it is worth noting how
our technical contributions are also inspired by several other prior lines of work.
In particular, Procrustes-type metrics have been employed in generalized Procrustes analysis which solves the problem of reorienting points to a fixed configuration~\cite{Gower-75-procrustes}. Similar metrics have also been successfully used in literature to study such problems of shape preservation~\cite{Srivastava-Shape-16} as well for alignment of manifolds~\cite{procrustes_manifold,continuous-procrustes-13}.
In our work, we use it to solve the clustering problem by comparing pairs of curves, each of which may be viewed as manifolds on $\mathbb{R}^2$.
Finally, we note that the introduced distance metrics can serve as an objective for assessing the stability of an interaction primitive learning algorithm. They are also used for comparing the outcomes produced by different algorithms. Furthermore, they may also be adopted as an objective function to obtain clusters of interactions, and the representative interactions. These concepts and techniques will be introduced in this paper, along with mathematical properties, while their usefulness will be demonstrated in the analysis of vehicle-to-vehicle interactions that arise in the Safety Pilot database \cite{bezzina2014safety}, the world's largest database for connected vehicles.
The paper is organized as follows. In Section~\ref{Section:distance}, we describe a distance metric for pairs of trajectories and explicate its useful mathematical properties. Building on this, Section~\ref{Section: Distribution_primitives} studies distributions of trajectory pairs, which lead to methods for obtaining and assessing clusters of interactions. Finally, Section~\ref{Section: Results} illustrates our methods on the clustering analysis of vehicle-to-vehicle interactions data.
\section{A distance metric on temporal interactions}
\label{Section:distance}
Because a temporal interaction between two agents is composed of trajectories, we need to first formally define a trajectory. Let $f:\mathbb{R}\rightarrow \mathbb{R}^2$ denote a trajectory of an object (e.g., vehicles, robots). In particular, $f(t)$ represents the location of the object at time-point $t$.
It suffices for our purpose to restrict to $t\geq 0$.
We can consider all possible trajectories in a similar manner. Define the set of all possible trajectories as $\ensuremath{\mathbb{F}}=\{f: [0,\infty) \rightarrow \mathbb{R}^2: f \text{ is continuous}\}$. The set of all possible trajectories up to time-point $t$ starting from time-point $s$ is denoted by $\ensuremath{\mathcal{F}}_{[s,t)}=\{f:[s,t)\rightarrow \mathbb{R}^{2}| f\in \ensuremath{\mathbb{F}}\}$. Similarly for $ (t_1,\dots,t_k) \in \mathbb{R}_+^{k}$ we will use $\ensuremath{\mathcal{F}}_{t_1,\ldots,t_k} :=\{ (f (t_1),\ldots,f (t_k)): f \in \ensuremath{\mathbb{F}}\}$. Also, we define $\ensuremath{\mathcal{F}}:= \cup_{s,t \in \mathbb{R}^+}\ensuremath{\mathcal{F}}_{[s,t)}$.
Next, operations can be defined on these trajectories. For any $c\in \mathbb{R}^2$, and $f \in \ensuremath{\mathbb{F}}$ we define $f+c\in \ensuremath{\mathbb{F}}$ as $ (f+c) (x)=f (x) + c$ for all $x \in [0,\infty)$. Similarly, for any orthogonal matrix $O \in \mathbb{R}^{2 \times 2}$, define the function $O\odot f \in \ensuremath{\mathbb{F}}$ as $ (O\odot f) (x)=O \cdot f(x)$ for all $x \in [0, \infty)$, where $O \cdot f (x)$ is the usual matrix product between matrix $O$ and vector $f (x)$ which have matching dimensions.
With these definitions in place, we now define an interaction and operations on these interactions. An interaction
is an ordered pair $ (f_1, f_2)$ such that $f_1, f_2 \in \ensuremath{\mathbb{F}}$. We also define operations on interactions as well. Let $SO (n)$ be the group of $n \times n$ orthogonal matrices with determinant $+1$. For a pair $f_1,f_2 \in \ensuremath{\mathbb{F}}$, we define $\ensuremath{\mathcal{O}}_{ (f_1, f_2)}=\{ (O \odot f_1, O \odot f_2) : O \in SO (2)\}$. Similarly, define $\ensuremath{\mathcal{C}}_{ (f_1,f_2)}=\{ (f_1+c,f_2+c) : c \in \mathbb{R}^{2}\}$.
\subsection{Rotation and translation-invariant metrics on curves}
\label{ssection:rotation}
To evaluate the stability and overall quality of clustering, we want a distance metric, $d:\ensuremath{\mathbb{F}}^2 \times \ensuremath{\mathbb{F}}^{2} \rightarrow \mathbb{R}_{+}$, where ($\ensuremath{\mathbb{F}}^{2} =\ensuremath{\mathbb{F}} \times \ensuremath{\mathbb{F}}$), that has the following properties:
\begin{itemize}
\item[ (a)] Distance between two interactions is invariant with respect to the re-ordering of corresponding trajectories, i.e., for $f_{11},f_{12},f_{21},f_{22} \in \ensuremath{\mathbb{F}}$, the following holds:
\begin{eqnarray}
d ( (f_{11},f_{12}), (f_{21},f_{22}))= d ( (f_{12},f_{11}), (f_{21},f_{22})). \nonumber
\end{eqnarray}
\item[ (b)] Distance between a pair of interactions is invariant of starting points of the trajectories composing the interactions, given the knowledge of the relative distance of the starting points of trajectories comprising each interaction. Specifically, if $ (f'_1,f'_2) \in \ensuremath{\mathcal{C}}_{ (f_1,f_2)} \cup \ensuremath{\mathcal{O}}_{ (f_1,f_2)}$, then,
\begin{eqnarray}
d ( (f'_1,f'_2), (f_1,f_2))=0. \nonumber
\end{eqnarray}
\end{itemize}
Condition (a) enables the removal of order in a pair of curves in an interaction, while condition (b) in essence characterizes \textbf{rotational} and \textbf{translational invariance} of interactions. We will henceforth use $ (\ensuremath{\mathcal{O}},\ensuremath{\mathcal{C}})_{ (f_1,f_2)}$ to denote the set $\{ (O \odot f_1 + c, O \odot f_2+ c) : O \in SO (2), c\in \mathbb{R}^2\}$. As shown in Lemma~\ref{lemma:invariance}, condition (b) implies that $d ( (f_{11},f_{12}), (f_{21},f_{22}))=d ( (O \odot f_{11} +c, O \odot f_{12} +c), (f_{21},f_{22}))$ for all $c \in \mathbb{R}^2$, $O \in SO (2)$.
This appears to be a reasonable requirement since the exact location and orientation of interactions should not affect the classification of different interactions into clusters characterized by "primitives". Note that throughout this paper we only consider non-reflective rotational transforms, i.e., transforms involving orthogonal matrices, O, such that $\textrm{det}(O)=+1$.
Let $\rho$ be a distance metric for $\ensuremath{\mathbb{F}}^2$. We will then construct a metric $d$ satisfying (a) and (b) from $\rho$. Definition \ref{def:rotation_translation_invariant_metric} shows how we can define $d$ in terms of $\rho$.
\begin{definition}
\label{def:rotation_translation_invariant_metric}
Define Procrustes distance
\begin{eqnarray}
\label{eq:rotation_translation_invariance}
& & d ( (f_{11},f_{12}), (f_{21},f_{22})) \\
&:=&\inf_{ (f'_1,f'_2) \in (\ensuremath{\mathcal{O}},\ensuremath{\mathcal{C}})_{ (f_{21},f_{22})}} \biggr \{ \min \biggr \{ \rho ( (f_{11},f_{12}), (f'_1,f'_2)), \rho ( (f_{12},f_{11}), (f'_1,f'_2)) \biggr \} \biggr \}.\nonumber
\end{eqnarray}
\end{definition}
From the definition of metric $d$ above, it is clear that $ (f_{21},f_{22}) \in (\ensuremath{\mathcal{O}},\ensuremath{\mathcal{C}})_{ (f_{11},f_{12})} \cup (\ensuremath{\mathcal{O}},\ensuremath{\mathcal{C}})_{ (f_{12},f_{11})} \iff d ( (f_{11},f_{12}), (f_{21},f_{22}))=0$. With that knowledge, we can define an equivalence relation, $\sim$, as
\begin{eqnarray}
\label{eq:metric_quotient_space}
(f_{11},f_{12}) \sim (f_{21},f_{22}) \iff d ( (f_{11},f_{12}), (f_{21},f_{22}))=0.
\end{eqnarray}
Although $d$ is not a proper metric on $\ensuremath{\mathbb{F}}^2$, as Proposition \ref{proposition:proper_metric} shows, $d$ does define a metric on the quotient space relative to the equivalence relation.
\begin{proposition}
\label{proposition:proper_metric}
Let $\rho$ be a distance metric on $\ensuremath{\mathbb{F}}^2$ such that for all $f_{11},f_{12},f_{21},f_{22} \in \ensuremath{\mathbb{F}}$,
\begin{enumerate}
\item[(i)] $\rho$ satisfies, for some function $h$,
\begin{eqnarray}
\rho ( (f_{11},f_{12}), (f_{21},f_{22}))= h( (f_{11},f_{12})-(f_{21},f_{22})). \nonumber
\end{eqnarray}
\item[(ii)] $\rho $ is an inner-product norm.
\end{enumerate}
Then $d$ given by Eq. \eqref{eq:rotation_translation_invariance} is a distance metric on the quotient space $\ensuremath{\mathbb{F}}^2/ \sim$.
\end{proposition}
Proposition \ref{proposition:proper_metric} also provides a method to build a metric satisfying conditions (a) and (b) above. One way to do so is from a probability measure perspective.
In fact, let $\mu$ be a probability measure on $[0,\infty)$. We consider the set of trajectories with integrable Euclidean norm on $[0,\infty)$, i.e., we restrict attention to the following set of trajectories:
\begin{eqnarray}
\ensuremath{\mathbb{F}}_2 (\mu)= \biggr \{f: [0,\infty) \rightarrow \mathbb{R}^2 \biggr | f \text{ is continuous, } \int_0^{\infty} \|f (x)\|_2^2\mu (\mathrm{d}x) < \infty, \biggr \}\nonumber
\end{eqnarray}
where $\|\cdot\|_2$ is the Euclidean norm in $\mathbb{R}^2$.
For our purposes, we use $\rho$ as the usual Euclidean metric on $\ensuremath{\mathbb{F}}_2^2 (\mu) :=\ensuremath{\mathbb{F}}_2 (\mu) \times \ensuremath{\mathbb{F}}_2 (\mu)$.
Namely, for $(f_{11},f_{12}),(f_{21},f_{22}) \in \ensuremath{\mathbb{F}}_2^2 (\mu)$, we use
\begin{equation}
\label{eq:l_2 metric}
\rho ( (f_{11},f_{12}) , (f_{21},f_{22}))^2
:= \|f_{11}-f_{21}\|_2^2
+ \|f_{12}-f_{22}\|_2^2,
\end{equation}
where $\|f_{1i}-f_{2i}\|_2^2=\int_0^{\infty}\|f_{1i}(x) -f_{2i}(x)\|_2^2 \mu (\mathrm{d}x), i=1,2 $. Here and henceforth we assume that the trajectories $f_{11},f_{12},f_{21},f_{22}$ all span across the same length of time.
Note that this choice of metric satisfies the criteria in Proposition~\ref{proposition:proper_metric}. Also, equivalently, to define similar rotation and translation invariant metrics on $\ensuremath{\mathcal{F}}_{[s,t)}$, for any $s<t\neq \infty$, we can simply choose any probability measure $\mu$ with support on $[s,t)$.
Proposition~\ref{proposition:computation} below provides a simple method to explicitly compute the metric $d$ between interactions, when $\rho$ is given by~\eqref{eq:l_2 metric}.
We will need the following notation:
\begin{enumerate}
\item[ (A1)] For $(f_{11},f_{12}),(f_{21},f_{22}) \in \ensuremath{\mathbb{F}}_2^2 (\mu)$, let $UDV^T$ be the singular value decomposition for the matrix given by
$$\sum_{i=1}^2 \int_0^\infty
\left (f_{2i} (x)-
\bar{f_{2\cdot}}(x)
\right)
\left(f_{1i} (x)-
\bar{f_{1\cdot}}(x)
\right)^T \mu (\mathrm{d}x),$$
\end{enumerate}
\noindent where $\bar{f_{2\cdot}}(x) = \int_0^\infty (f_{21} (x) + f_{22} (x))/2 \ \mu (\mathrm{d}x)$ and \\$\bar{f_{1\cdot}}(x) = \int_0^\infty (f_{11} (x) + f_{12} (x))/2 \ \mu (\mathrm{d}x)$.
Each of the summands in (A1) form a $2 \times 2$ dimensional matrix. Here, $\bar{f_1}(x)$ denotes the elementwise integration of the $2 \times 1 $
vector $(f_{11} (x) + f_{12} (x))/2$. Moreover, the outer-integral in each of the summands in (A1) is an elementwise integral of the $2 \times 2$ matrix integrand formed by matrix multiplication of the $ 2 \times 1$ vector $\left (f_{21} (x)-\bar{f_{2\cdot}}(x)\right)$ and the $1 \times 2$ vector $\left(f_{11} (x)-\bar{f_{1\cdot}}(x)\right)^T$.
\begin{proposition}
\label{proposition:computation}
Assume $f_{11},f_{12},f_{21},f_{22} \in \ensuremath{\mathbb{F}}_2 (\mu)$. Let $UDV^T$ be the singular value decomposition as in (A1). Then,
\begin{eqnarray}
\label{eq:computation}
\inf_{ (f'_1,f'_2) \in (\ensuremath{\mathcal{O}},\ensuremath{\mathcal{C}})_{(f_{21},f_{22})}} (\rho ( (f_{11},f_{12}), (f'_1,f'_2)))^2 = - 2 \operatorname{trace}\left (D
\begin{bmatrix}
1 & 0 \\
0 & \operatorname{det} (V^TU)
\end{bmatrix}\right) \nonumber \\ + \sum_{i=1}^2\int_0^\infty \biggr\|f_{2i} (x) -
\bar{f_{2\cdot}}(x)
\biggr\|_2^2 \nonumber + \biggr\|f_{1i} (x)-
\bar{f_{1\cdot}}(x)
\biggr\|_2^2\mu (\mathrm{d}x).
\end{eqnarray}
The optimal $\ensuremath{\mathcal{O}},\ensuremath{\mathcal{C}}$ that define the infimum are given by :
\begin{align}
\begin{split}
\tilde{\ensuremath{\mathcal{O}}} &= V^T \begin{bmatrix}
1 & 0 \\
0 & \operatorname{det} (V^TU)
\end{bmatrix}U,
\\
\tilde{\ensuremath{\mathcal{C}}} &=
\bar{f_{1\cdot}}(x)
-\tilde{\ensuremath{\mathcal{O}}} \cdot\left (
\bar{f_{2\cdot}}(x)
\right).
\end{split}
\end{align}
\end{proposition}
The proof of the proposition is discussed in Section~\ref{proof:proposition::computation}.
The problem discussed in Propostion~\ref{proposition:computation} is a version of the well-known \textbf{least root mean square deviation} problem. It was first solved by the Kabsch algorithm~\cite{Kabsch-76,Kabsch-78}. A more computationally efficient method to compute the optimal $\ensuremath{\mathcal{O}}, \ensuremath{\mathcal{C}}$ was later obtained using the theory of quarternions~\cite{Quarternion-86,Quarternion-04}.
\section{Quantifying distributions of primitives}
\label{Section: Distribution_primitives}
The metric defined above can be used to obtain clusters of interactions, in addition to evaluating the overall quality and stability of a particular clustering method. Our starting point is to note that the problem of clustering or summarizing interactions can be formalized as finding a discrete distribution on the space of interactions.
More specifically, one needs to obtain a discrete probability distribution on interactions, where each supporting atom represents a typical interaction (namely, an interaction \emph{primitive}) and the mass associated with each atom represents the proportion of a cluster.
From this perspective, an objective that naturally arises is to minimize a distance from the empirical distribution of interactions to a discrete probability measures with a fixed number, say $k$, of supporting atoms, which represent the primitives.
An useful tool for defining distance metrics on the space of distributions
arises from the theory of optimal transport \cite{Villani-03}.
Optimal transport distances enable comparisons of distributions in arbitrary structured and metric spaces by accounting for the underlying metric structure.
They have been increasingly adopted to address clustering in a number of contexts~\cite{Pollard-82-kmeans,Graf-Luschgy-00,ho2017multilevel}.
For instance, it is well-known that the problem of determining an optimal finite discrete probability measure minimizing the second-order Wasserstein distance $W_2$ to the empirical distribution of the data is directly connected to the k-means clustering problem (discussed in Section III in details). Inspired by this connection, we will seek to summarize the distribution of interactions appropriately. To this end, we will define Wasserstein distances for distributions of interactions as follows, by accounting for the metric structure developed in the previous section.
Let $d$ be a distance metric on $\ensuremath{\Fbb_2^2(\mu)/\sim}$, where $\sim$ is the equivalence relation defined in Eq.~\eqref{eq:metric_quotient_space}.
Fix $ [(f_{11},f_{12})] \in \ensuremath{\Fbb_2^2(\mu)/\sim}$. Here, $[(f_{11},f_{12})]$ denotes the equivalence class corresponding to interaction $(f_{11},f_{12})$ relative to the equivalence relation $\sim$ and $ \ensuremath{\Fbb_2^2(\mu)/\sim}$ denotes the collection of all such classes of interactions. Let $P (\ensuremath{\Fbb_2^2(\mu)/\sim})$ denote all probability measures on $\ensuremath{\Fbb_2^2(\mu)/\sim}$. For a fixed order $r\geq 1$, define the following subset of $P(\ensuremath{\Fbb_2^2(\mu)/\sim})$ subject to a moment-type condition using the metric $d$:
\begin{eqnarray}
& &\ensuremath{\mathcal{P}}_r (\ensuremath{\Fbb_2^2(\mu)/\sim}) := \biggr\{ G \in P (\ensuremath{\Fbb_2^2(\mu)/\sim}) | \nonumber \\ & & \int d^r ([ (f_{21},f_{22})],[ (f_{11},f_{12})]) \mathrm{d}G ([ (f_{21},f_{22})]) < \infty \biggr\}. \nonumber
\end{eqnarray}
This class of probability measures can be shown to be independent of the choice of $[ (f_{11},f_{12})]$ and therefore the collection of order-$r$ integrable probability measures on the quotient space $\ensuremath{\Fbb_2^2(\mu)/\sim}$ is independent of the choice of the base class $[ (f_{11},f_{12})]$. We arrive at the following distance metric to compare between probability measures on the quotient space $\ensuremath{\Fbb_2^2(\mu)/\sim}$. This is an instantiation of Wasserstein distances that arise in the theory of optimal transport in metric spaces~\cite{Villani-03}.
\begin{definition}[\textbf{Wasserstein distances}]
Let $F,G \in \ensuremath{\mathcal{P}}_r (\ensuremath{\Fbb_2^2(\mu)/\sim})$. The Wasserstein distance of order $r$ between $F$ and $G$ is defined as:
\begin{eqnarray}
W_r (F,G) := \biggr( \underset{\pi \in \Pi (F,G)}{\inf} \int d^r ([ (f_{11},f_{12})],[ (f_{21},f_{22})])
\mathrm{d}\pi ([ (f_{11},f_{12})],[ (f_{21},f_{22})])\biggr)^{1/r} \nonumber,
\end{eqnarray}
where $\Pi (F,G)$ is the collection of all joint distributions on $\ensuremath{\Fbb_2^2(\mu)/\sim} \times \ensuremath{\Fbb_2^2(\mu)/\sim}$ with marginals $F$ and $G$.
\end{definition}
\subsection{Wasserstein barycenter and k-means clustering}
\label{ssection:k-means}
In this section, we present the Wasserstein barycenter problem and highlight its connection to the k-means formulation.
\paragraph{Wasserstein barycenter problem} Fixing the order $r=2$, let $P_1,P_2,\ldots,P_N \\ \in \ensuremath{\mathcal{P}}_2 (\ensuremath{\Fbb_2^2(\mu)/\sim})$ be probability measures on $\ensuremath{\Fbb_2^2(\mu)/\sim}$. Their second-order Wasserstein barycenter is a probability measure $\bar{P}_{N,\lambda} $ such that
\begin{eqnarray}
\bar{P}_{N,\lambda}=\underset{P \in P_2 (\ensuremath{\Fbb_2^2(\mu)/\sim}) }{\text{argmin}} \sum_{i=1}^N \lambda_i W_2^2 (P,P_i). \nonumber
\end{eqnarray}
The Wasserstein barycenter problem was first studied by~\cite{Agueh-Carlier-11}.
When $P_i$ are themselves finite discrete probability measures on arbitrary metric spaces, efficient algorithms are available for obtaining locally optimal solutions to the above~\cite{Cuturi-Barycenter-14}.
\paragraph{k-means clustering problem} The k-means clustering problem, when adapted to obtaining clusters in a non-Euclidean space of interactions, can be viewed as solving for the set $S$ of $k$ elements $[ (g_{11},g_{12})], \ldots, [ (g_{k1},g_{k2})] \in \ensuremath{\Fbb_2^2(\mu)/\sim}$ such that, given samples $ (f_{11},f_{12}),\ldots, (f_{n1},f_{n2}) \in \ensuremath{\mathcal{F}}^2 (\mu) $
\begin{eqnarray}
\label{eq:k_means}
S= \underset{T: |T| \leq k}{\text{argmin}} \sum_{i=1}^n \inf_{[ (f'_1,f'_2)] \in T }d^2 ([ (f_{i1},f_{i2})],[ (f'_1,f'_2)]).
\end{eqnarray}
It can be shown that this is equivalent to finding a discrete measure $P$ which solves the following for the choice $r=2$:
\begin{eqnarray}
\label{eq:wasserstein-k_means}
\inf _{P \in \ensuremath{\mathcal{O}}_k (\ensuremath{\Fbb_2^2(\mu)/\sim})} W_r (P,P_n),
\end{eqnarray}
where $P_n$ is the empirical measure on $\ensuremath{\Fbb_2^2(\mu)/\sim}$, i.e., $P_n$ places mass $1/n$ on equivalence class sample $[(f_{i1},f_{i2})]$ for all $i =1,\ldots, n$, and $\ensuremath{\mathcal{O}}_k(\ensuremath{\Fbb_2^2(\mu)/\sim})$ is the set of all measures in $\ensuremath{\Fbb_2^2(\mu)/\sim}$ with at most $k$ support points. (It is interesting to note that Eq.~\eqref{eq:wasserstein-k_means} is a special case of the Wasserstein barycenter problem for $N=1$ and $r=2$.)
At the high level our approach is simple: we seek to summarize the empirical data distribution of interactions using a k-means-like approach, but there are several challenges due to the complex metric structure exhibited by the non-Euclidean space of interactions. Finding the exact solution even in the simplest cases is an NP-hard problem. The most common method to approximate the solution is the use of iterative steps similar to Lloyd's algorithm~\cite{Lloyd-algo} for solving the Euclidean k-means problem. However, the computation of cluster centroids at each iteration of Lloyd's algorithm when applied to the non-Euclidean metric $d$ is non-trivial. Moreover, the computation of pairwise distances between equivalence classes of interactions is non-trivial. In the next subsection we present some approximate solutions to Eq.~\eqref{eq:k_means}.
\subsection{Approximations for non-Euclidean $k$-means clustering}
\label{ssection:approximation}
The primary objective for this section is to obtain a robust representation for the distribution over interaction primitives. Although the empirical distribution of interactions provides an estimate of the distribution over primitives, it suffers from lack of robustness guarantees. A robust $k$-approximation for the empirical distribution is formalized by Eq.~\eqref{eq:wasserstein-k_means}. For order $r=2$ this is equivalent to solving the k-means problem given by Eq.~\eqref{eq:k_means} for the interaction scenarios. The computational problem for computing exact centroids of k-means clusters is cumbersome and generally not solvable for arbitrary distance metrics $d$. To overcome such challenges we propose three separate methods to obtain approximate solutions to Eq.~\eqref{eq:k_means}. The first approach is a standard application of multi-dimensional scaling technique. The second and third approaches are based on other geometric ideas to be described in the sequel.
\subsubsection{Multidimensional Scaling}
\label{sssection:mds}
Multi-dimensional scaling (MDS) provides a way to obtain a lower dimensional representation of high-dimensional and/or non-Euclidean space elements while approximately preserving some distance measure among data points. Given a distance (a.k.a. dissimilarity) matrix
$D= (d_{ij})_{1\leq i,j\leq n}$, which collects all pairwise distance among the $n$ data points using a notion of distance such as metric $d$ described earlier, MDS finds points $x_1,\ldots,x_n \in \mathbb{R}^m$, for some small dimension $m$, such that
\begin{eqnarray}
\label{eq:MDS}
\{x_1,\ldots, x_n\} = \underset{y_1,\ldots,y_n \in \mathbb{R}^m}{\text{argmin}} \sum_{i,j=1}^n (\|y_i-y_j\|-d_{ij})^2
\end{eqnarray}
In order to apply the k-means clustering technique to our MDS representation, the following implicit assumption is required:
\begin{itemize}
\item[ (C1)] Each of the cluster centroids for the k-means problem corresponds to an interaction in the data sample.
\end{itemize}
Given (C1), Eq.~\eqref{eq:k_means} can be reformulated as follows.
\paragraph{Approximate k-means} Given interaction samples $ (f_{11},f_{12}),\ldots, (f_{n1},f_{n2}) \in \ensuremath{\mathcal{F}}^2(\mu)$, find a set $S \subset \{1,\ldots,n\}$ such that,
\begin{eqnarray}
\label{eq:k_means_approx}
S= \underset{T: |T| \leq k}{\text{argmin}} \sum_{i=1}^n \min_{j \in T }d^2 ([ (f_{i1},f_{i2})],[ (f_{j1},f_{j2})]).
\end{eqnarray}
The approximate k-means problem in Eq. ~\eqref{eq:k_means_approx} differs from the k-means problem ~\eqref{eq:k_means} in that instead of finding primitives that are the global minimizer (and hence correspond to the cluster means), we look for the primitive that is closest to all other interactions in its cluster. The advantage of this approach is that we do not need explicitly the inverse map that goes from the MDS representation back to the interaction space. We summarize this approach as Algorithm~\ref{algo: primitive clustering} in the following.
\begin{algorithm}[ht]
\caption{Clustering interactions}
\label{algo: primitive clustering}
\algsetup{linenosize=\small}
\scriptsize
Input: interaction sample $\{(f_{i1},f_{i2})\}_{i=1}^{n}$\\
Output: $k$ interaction primitives
\begin{algorithmic}[1]
\STATE Obtain $x_1,\ldots,x_n$ as solution of MDS Eq.~\eqref{eq:MDS} with $d_{ij}=d ([ (f_{i1},f_{i2})],[ (f_{j1},f_{j2})])$.
\STATE Perform k-means on $x_1,\ldots,x_n$ to obtain the centroids.
\STATE Approximate the centroids with points $x_i \in \mathbb{R}^m$ which are closest in $\|\cdot\|$ distance to the centroids, $\Gamma_1, \Gamma_2, \ldots, \Gamma_k$.
\STATE Return as primitives the $k$ interaction sample corresponding to these approximate centroids, $\{(g_{j1},g_{j2})\}_{j=1}^{k}$.
\end{algorithmic}
\end{algorithm}
\subsubsection{Geometric Approximations}
\label{sssection:geometric_approx}
A major computational challenge to solving Eq.~\eqref{eq:k_means_approx} lies in the SVD decomposition of the Procrustes distances (Eq.~\eqref{eq:rotation_translation_invariance}) relative to each pair of interactions. There require $O(n^2)$ such decomposition. To avoid this, we instead consider a geometric approximation of the Procrustes distance, inspired by work from the field of morphometrics \cite{stats_shape_analysis}.
Consider two interactions $(f_{i1},f_{i2})$ and $(f_{j1},f_{j2})$. Then, by an application of triangle inequality,
\begin{eqnarray}
\label{eq:geo_approx_1}
& & \inf_{ (f'_1,f'_2) \in (\ensuremath{\mathcal{O}},\ensuremath{\mathcal{C}})_{ (f_{j1},f_{j2})}}\rho ( (f_{i1},f_{i2}), (f'_1,f'_2)) \\
&=&\inf_{O_1 \in SO(2), c_1 \in \mathbb{R}^2}\rho ( (f_{i1},f_{i2}), O_1\odot(f_{j1},f_{j2})+ c_1) \nonumber \\
& \leq & \inf_{O_1 \in SO(2), c_1 \in \mathbb{R}^2}\rho ( (f_{11},f_{12}), O_1\odot(f_{j1},f_{j2})+ c_1) \nonumber \\& + &\inf_{O_2 \in SO(2), c_2 \in \mathbb{R}^2}\rho ( (f_{11},f_{12}), O_2\odot(f_{i1},f_{i2})+ c_2).\nonumber
\end{eqnarray}
Eq.~\eqref{eq:geo_approx_1} shows that knowledge of optimal rotational matrices and translation vectors for computing the distances $d ([ (f_{i1},f_{i2})],[ (f_{11},f_{12})])$ and \\ $d ([ (f_{j1},f_{j2})],[ (f_{11},f_{12})])$ can provide an upper bound for computing the distance between the $i^{th}$ and $j^{th}$ pair of interactions. Therefore, we can provide a reasonable upper bound for all the $n^2$ pairwise distances by simply performing only $O(n)$ SVD decompositions. This approach, which we call the $\textit{first geometric approximation}$, is summarized in Algorithm~\ref{algo:first_geom_approx}.
\begin{algorithm}[!ht]
\caption{First Geometric Approximation}
\label{algo:first_geom_approx}
\algsetup{linenosize=\small}
\scriptsize
Input: $\{(f_{i1},f_{i2})\}_{i=1}^{n}$\\
Output: $k$ centroids
\begin{algorithmic}[1]
\FOR{$i = 1, 2, \dots, n$}
\STATE Center and reorient $(f_{i1},f_{i2})$ to $(f_{11},f_{12})$ using Algorithm \ref{algo: primitive reorienting}.
\ENDFOR
\STATE Perform k-means on the centered and oriented $\{(f_{i1},f_{i2})\}_{i=1}^{n}$ to obtain the centroids, $\{(\Gamma_{j1}, \Gamma_{j2})\}_{j = 1}^k$.
\STATE Return the centroids, $\{(\Gamma_{j1}, \Gamma_{j2})\}_{j = 1}^k$.
\end{algorithmic}
\end{algorithm}
\begin{algorithm}[!ht]
\caption{Second Geometric Approximation}
\label{algo:second_geom_approx}
\algsetup{linenosize=\small}
\scriptsize
Input: $\{(f_{i1}, f_{i2})\}_{i=1}^{n}$\\
Output: $k$ centroids
\begin{algorithmic}[1]
\STATE Randomly assign interaction samples $\{(f_{i1},f_{i2})\}_{i=1}^{n}$ to $k$ clusters. Let $z_i$ indicate the cluster assignment.
\WHILE{k-means convergence criterion has not been met}
\FOR{$k' = 1, 2, \dots, k$}
\STATE Center and orient all interaction samples $(f_{i1},f_{i2})$ to $(f_{i_{k'}1},f_{i_{k'}2})$ using Algorithm \ref{algo: primitive reorienting} if $(f_{i_{k'}1},f_{i_{k'}2})$ is the first interaction sample such that $z_i = k'$ for $i = 1, 2, \dots n$. Denote these oriented and centered samples as $(f'_{i1},f'_{i2})(t)$.
\STATE Compute the centroid for cluster $j$, $(\Gamma_{j1},\Gamma_{j2})$, such that for $t = 1, 2, \dots, t_m$,
\[
(\Gamma_{j1},\Gamma_{j2})(t) = \frac{1}{\countV{z_i = k}} \sum_{i:z_i = k} (f'_{i1},f'_{i2})(t)
\]
\ENDFOR
\FOR{$i = 1, 2, \dots, N$}
\FOR{$j = 1, 2, \dots, k$}
\STATE Center and orient $(f_{i1},f_{i2})$ to $(\Gamma_{j1}, \Gamma_{j2})$.
\STATE Compute the $L_2$ distance between the centered and oriented $(f_{i1},f_{i2})$ and $(\Gamma_{j1}, \Gamma_{j2})$.
\ENDFOR
\STATE Set $z_i = j$ if the smallest computed distance is from the centroid of cluster $j$.
\ENDFOR
\ENDWHILE
\STATE Return the centroids, $\{(\Gamma_{j1}, \Gamma_{j2})\}_{j = 1}^k$.
\end{algorithmic}
\end{algorithm}
However, this gain in computation efficiency is also accompanied by a loss of statistical efficiency. To mitigate this tension between computational and statistical efficiency we propose a $\textit{second geometric approximation}$ which performs the approximation of Algorithm~\ref{algo:first_geom_approx} in batch form, where the batches comprise of the respective clusters. This procedure is described in Algorithm \ref{algo:second_geom_approx}.
\section{Experimental Results}
\label{Section: Results}
In this section we provide a demonstration of our methods for unsupervised learning of vehicle interactions. In particular, we will evaluate the quality and stability of clustered primitives extracted from vehicle-to-vehicle interactions based on real-world experiments conducted in Ann Arbor, Michigan. In the literature for this application domain, a real-time interaction between two vehicles is also alternatively referred to as an encounter. In practice, the interactions between vehicles are represented by multi-dimensional time series of varying duration, which need to be further segmented into shorter time duration via suitable data processing techniques.
\begin{figure*}[!tp]
\centering
\begin{subfigure}{.19\textwidth}
\centering
\includegraphics[width = 1\textwidth]{mds_cluster_no_reflection_5.pdf}
\caption{Multidim. Scaling (cf. Section~\ref{sssection:mds})}
\end{subfigure}
\begin{subfigure}{.19\textwidth}
\centering
\includegraphics[width = 1\textwidth]{first_approx_no_reflection_cluster_5.pdf}
\caption{First geometric approx. (cf. Section~\ref{sssection:geometric_approx})}
\end{subfigure}
\begin{subfigure}{.19\textwidth}
\centering
\includegraphics[width = 1\textwidth]{second_approx_no_reflection_cluster_5.pdf}
\caption{Second geometric approx. (cf. Section~\ref{sssection:geometric_approx})}
\end{subfigure}
\begin{subfigure}{.19\textwidth}
\centering
\includegraphics[width = 1\textwidth]{poly_cluster_5.pdf}
\caption{Polynomial coefficients (cf. Section~\ref{ssection:clustering_quality})}
\end{subfigure}
\begin{subfigure}{.19\textwidth}
\centering
\includegraphics[width = 1\textwidth]{dtw_cluster_5.pdf}
\caption{DTW cost matrix (cf. \cite{Wang-Zhao-2017})}
\end{subfigure}\\
\caption{Silhouette plots for 5 clusters obtained under various approaches:
}
\label{fig:two_step_silhouette_plots}
\centering
\resizebox{1\textwidth}{!}{%
\begin{tabular}{@{\extracolsep{5pt}} cccccc}
\\[-1.8ex]\hline
\hline \\[-1.8ex]
& \multirow{3}{*}{\shortstack[c]{\textbf{Total within}\\\textbf{Square Distance}}} & \multirow{3}{*}{\shortstack[c]{\textbf{Cluster 1}\\\textbf{Average within}\\\textbf{Square Distance}}} & \multirow{3}{*}{\shortstack[c]{\textbf{Cluster 5}\\\textbf{Average within}\\\textbf{Square Distance}}} & \multirow{3}{*}{\shortstack[c]{\textbf{Cluster 1}\\\textbf{Average between}\\\textbf{Square Distance}}} & \multirow{3}{*}{\shortstack[c]{\textbf{Cluster 5}\\\textbf{Average between}\\\textbf{Square Distance}}}\\
& & & & &\\
& & & & &\\
\hline \\[-1.8ex]
& & & & &\\
\textbf{MDS} & 10.68 & 1.74e-03 (1.53e-05) & 1.23e-02 (4.60e-04) & 1.55e-02 (4.57e-04) & 1.17e-01 (5.13e-03)\\
& & & & &\\
\textbf{First Geometric Approx.} & 13.32 & 9.50e-04 (2.96e-05) & 6.33e-03 (3.92e-04) & 5.01e-02 (4.97e-03)) & 1.12e-02 (2.92e-04)\\
& & & & &\\
\textbf{Second Geometric Approx.} & 274.27 & 3.97e-03 (1.42e-04) & 8.01e-02 (1.38e-03) & 1.86e-02 (8.43e-04) & 1.84e-02 (1.51e-03)\\
& & & & &\\
\textbf{Spline Coefficients} & 222.56 & 5.02e-02 (3.91e-03) & 9.40e-02 (1.05e-02) & 5.95e-02 (4.27e-03) & 2.05e-01 (2.33e-02)\\
& & & & &\\
\textbf{DTW Matrices} & 201.12 & 3.12e-02 (4.51e-03) & 9.00e-03 (3.41e-04) & 5.01e-02 (6.30e-03) & 9.38e-03 (3.79e-04)\\
& & & & &\\
\hline \\[-1.8ex]
\end{tabular}
}
\captionof{table}{A table of the quantities from Eq. \eqref{eq:k_means_approx}, Eq. \eqref{eq:within_cluster_quality_stat_approx}, and Eq. \eqref{eq:between_cluster_quality_stat_approx}) for each method's cluster with the most interaction (Cluster 1) and cluster with the fewest (Cluster 5). Variance of these distances are included in parentheses. Note that the Procrustes distances were normalized so that the maximum distance between any interaction is 1.}
\label{table:two_step_cluster_quality_stats_approx}
\end{figure*}
\subsection{Vehicle-to-vehicle (V2V) interaction data processing}
\label{Section:data}
We work with a real-world V2V interaction data set which is extracted from the naturalistic driving database generated by experiments conducted as part of the University of Michigan Safety Pilot Model Development (SPMD) program. In these experiments, dedicated short range communications (DSRC) technology was utilized for the communication between two vehicles. Approximately 3,500 equipped vehicles have collected data for more than 3 years. Latitude and longitude data of each vehicle was recorded by the by-wire speed sensor. The on-board sensor records data in 10Hz.
To investigate basic V2V interaction behaviors, a subset of 1400 driving scenarios was further filtered out from the SPMD's database.
Each scenario consists of a time series of GPS locations and speeds of a pair of vehicles, which are mutually less than 100 metres apart.
For our purposes, it is natural to posit that each scenario is inclusive of multiple shorter encounters through different time duration. Pre-processing of the data was therefore aimed at segmenting each scenario into more basic driving segments. These segments constitute basic building blocks from which we can meaningfully learn interaction primitives using a variety of clustering algorithms.
The issue of segmentation is akin to identifying change points on functional curves embedded in a higher dimensional space.
We consider two different segmentation schemes for V2V interaction data processing.
The first segmentation scheme is detailed in Appendix \ref{Section: Spline}. It will be called a $\textit{two-step spline}$ approach, which goes as follows. Given an encounter, we fit it with cubic splines in two main steps. Here, the change points act as the knots. The first step involves identifying a large number of probable change points via a binary search approach to add change points if adding change points reduced the squared error between the fitted values and the observed data. The next step involves a single forward pass to remove excess change points from consideration in order to minimize the squared error with a penalty for the number of change points. We then segment each interaction at the knots. This segmentation technique created a set of 5622 basic V2V interactions to work with.
The second segmentation scheme is considerably more complex, as it is derived from a nonparametric Bayesian model for time series data, the sticky Hierarchical Dirichlet Process Hidden Markov Model (HDP-HMM)~\cite{Fox-etal-09}. This model extends the basic HMM by allowing the number of hidden Markov states to be unbounded, while encouraging the Markov process to be "sticky", that is, the state tends to be constant for a period of time (e.g., a car tends to go straight after a long period of time).
For model selection, as we will elaborate later, one of the hyperparameters of sticky HDP-HMM is varied. Consequently, the number of basic V2V interactions varied from 8779 to 8829 with an average of 8799 interactions.
\begin{figure*}[!t]
\centering
\begin{minipage}{\textwidth}
\begin{subfigure}{.33\textwidth}
\centering
\includegraphics[width = 1\textwidth]{mds_cluster_no_reflection_typical_encounters_3_ind_scale_no_legend_5_cluster_1.pdf}
\caption{Cluster 1}
\end{subfigure}
\begin{subfigure}{.33\textwidth}
\centering
\includegraphics[width = 1\textwidth]{mds_cluster_no_reflection_typical_encounters_3_ind_scale_no_legend_5_cluster_2.pdf}
\caption{Cluster 2}
\end{subfigure}
\begin{subfigure}{.33\textwidth}
\centering
\includegraphics[width = 1\textwidth]{mds_cluster_no_reflection_typical_encounters_3_ind_scale_no_legend_5_cluster_3.pdf}
\caption{Cluster 3}
\end{subfigure}
\end{minipage}
\begin{minipage}{\textwidth}
\begin{subfigure}{.33\textwidth}
\centering
\includegraphics[width = 1\textwidth]{mds_cluster_no_reflection_typical_encounters_3_ind_scale_no_legend_5_cluster_4.pdf}
\caption{Cluster 4}
\end{subfigure}
\begin{subfigure}{.33\textwidth}
\centering
\includegraphics[width = 1\textwidth]{mds_cluster_no_reflection_typical_encounters_3_ind_scale_no_legend_5_cluster_5.pdf}
\caption{Cluster 5}
\end{subfigure}
\begin{subfigure}{.33\textwidth}
\centering
\includegraphics[width = 1\textwidth]{mds_cluster_no_reflection_typical_encounters_3_5.pdf}
\caption{All clusters}
\end{subfigure}
\end{minipage}
\caption{Plot of the three most typical interactions organized from the cluster with the most interaction to the cluster with the fewest for clustering using Multidimensional scaling (cf. Section \ref{ssection:approximation}). The interactions are centered and oriented using Algortihm \ref{algo: primitive reorienting} to $(t, 2t - 1, -t, 1 - 2t)$ for $t = 0, 0.01, \dots, 1$. The solid shapes and shapes with a black interior indicate the starting location of each interaction. The dot with the black interior indicates the second trajectory. Midpoints are indicated by dots filled in with a grey interior. Different shapes indicate different V2V interactions. Note that the individual cluster interactions plots are placed on their own scales.}
\label{fig:two_step_typical_encounter_plot_approx_mds}
\end{figure*}
\subsection{Cluster analysis of V2V interactions}
\label{ssection:clustering_quality}
\begin{figure*}[!t]
\centering
\begin{subfigure}{.22\textwidth}
\centering
\includegraphics[width = 1\textwidth]{first_approx_no_reflection_no_legend_cluster_mean_dist_5.pdf}
\caption{In-cluster distances from mean interactions}
\end{subfigure}
\begin{subfigure}{.22\textwidth}
\centering
\includegraphics[width = 1\textwidth]{first_approx_no_reflection_no_legend_cluster_approx_dist_5.pdf}
\caption{In-cluster distances from typical interactions}
\end{subfigure}
\begin{subfigure}{.22\textwidth}
\centering
\includegraphics[width = 1\textwidth]{first_approx_no_reflection_no_legend_all_mean_dist_5.pdf}
\caption{All distances from mean interactions}
\end{subfigure}
\begin{subfigure}{.22\textwidth}
\centering
\includegraphics[width = 1\textwidth]{first_approx_no_reflection_all_approx_dist_5.pdf}
\caption{All distances from typical interactions}
\end{subfigure}\\
\label{fig:first_geometric_approx_dist_freq_plots}
\centering
\begin{subfigure}{.22\textwidth}
\centering
\includegraphics[width = 1\textwidth]{second_approx_no_reflection_no_legend_cluster_mean_dist_5.pdf}
\caption{In-cluster distances from the mean interactions}
\end{subfigure}
\begin{subfigure}{.22\textwidth}
\centering
\includegraphics[width = 1\textwidth]{second_approx_no_reflection_no_legend_cluster_approx_dist_5.pdf}
\caption{In-cluster distances from the typical interactions}
\end{subfigure}
\begin{subfigure}{.22\textwidth}
\centering
\includegraphics[width = 1\textwidth]{second_approx_no_reflection_no_legend_all_mean_dist_5.pdf}
\caption{All distances from mean interactions}
\end{subfigure}
\begin{subfigure}{.22\textwidth}
\centering
\includegraphics[width = 1\textwidth]{second_approx_no_reflection_all_approx_dist_5.pdf}
\caption{All distances from the typical interactions}
\end{subfigure}\\
\label{fig:second_geometric_approx_dist_freq_plots}
\centering
\begin{subfigure}{.22\textwidth}
\centering
\includegraphics[width = 1\textwidth]{poly_cluster_no_legend_cluster_mean_dist_5.pdf}
\caption{In-cluster from mean interactions}
\end{subfigure}
\begin{subfigure}{.22\textwidth}
\centering
\includegraphics[width = 1\textwidth]{poly_cluster_no_legend_cluster_approx_dist_5.pdf}
\caption{In-cluster distances from typical interactions}
\end{subfigure}
\begin{subfigure}{.22\textwidth}
\centering
\includegraphics[width = 1\textwidth]{poly_cluster_no_legend_all_mean_dist_5.pdf}
\caption{All distances from mean interactions}
\end{subfigure}
\begin{subfigure}{.22\textwidth}
\centering
\includegraphics[width = 1\textwidth]{poly_cluster_all_approx_dist_5.pdf}
\caption{All distances from typical interactions}
\end{subfigure}\\
\caption{Line plots showing the distribution (frequency) of interaction distance to either the cluster mean or the typical interaction. Clusters are obtained by the first geometric method in row 1, the second geometric method in row 2, and the cubic spline coefficients based method in row 3 (cf. Section~\ref{ssection:clustering_quality}). The clusters are numbered according to the number of interactions so that Cluster 1 has the most and Cluster 5 has the fewest. Note that the range for the y-axis are much larger on the left plots compared to the right plots.}
\label{fig:cluster_dist_freq_plots}
\end{figure*}
We evaluate the clustering of primitives qualitatively and quantitatively. For the former, silhouette plots are useful -- the silhouette, $s(i)$, for interaction $i$ is defined as following:
\[
s(i) = \frac{b(i) - a(i)}{\max(a(i), b(i))}.
\]
Here, $a(i)$ is the average Procrustes distance between interaction $i$ and all other interactions in the same cluster as interaction $i$, while $b(i)$ is the average Procrustes distance from interaction $i$ to those in another cluster. The cluster used for $b(i)$ is the one that minimizes this average distance. By definition, the silhouette ranges from -1 to 1. It will be close to 1 if $b(i)$ is significantly larger than $a(i)$ and -1 if $a(i)$ is significantly larger than $b(i)$. Thus, the quality of the clustering for interaction $i$ decreases as $s(i)$ decreases. Plotting the silhouettes for all interactions provides a qualitative way to determine how the clustering is performing because if most silhouettes are close to 1, the clustering is performing well.
forming because if most silhouettes are close to 1, the clustering is performing well.
For a more quantitative way to examine the clustering, we look at the quantity in Eq. \eqref{eq:k_means} and Eq. \eqref{eq:k_means_approx}. Naturally, the method that reduces that quantity the most should be selected. We can also break down that quantity further by the contribution of each cluster. Specifically, suppose $z_i$ indicates the cluster membership. If $(\Gamma_{j1}, \Gamma_{j2})$ is the cluster's mean, then we report the following:
\begin{align}
\frac{1}{\countV{z_i = k}} \sum_{i:z_i = k} d^2([ (f_{i1},f_{i2})],[(\Gamma_{j1}, \Gamma_{j2})]).
\label{eq:within_cluster_quality_stat}
\end{align}
Alternatively, if interaction $j$ minimizes $d^2 ([ (f_{i1},f_{i2})],[ (g_{j1},g_{j2})])$ for all $z_i, z_j = k$, the approximate version is the following:
\begin{align}
\frac{1}{\countV{z_i = k}} \sum_{i:z_i = k} d^2([ (f_{i1},f_{i2})],[(g_{j1},g_{j2})]).
\label{eq:within_cluster_quality_stat_approx}
\end{align}
To compare clusters with different number of interactions, we choose to divide it by the size of the cluster. Finally, like the silhouette, it might also be helpful to compare this against the average square Procrustes distance of one cluster's mean V2V interaction and the interactions of all other clusters. In other words, we report the following if the cluster's mean interactions are recoverable:
\begin{align}
\frac{1}{\countV{z_i \neq k}} \sum_{i:z_i \neq k} d^2([ (f_{i1},f_{i2})],[(\Gamma_{j1}, \Gamma_{j2})]).
\label{eq:between_cluster_quality_stat}
\end{align}
Again, we can report the approximate version instead:
\begin{align}
\frac{1}{\countV{z_i \neq k}} \sum_{i:z_i \neq k} d^2([ (f_{i1},f_{i2})],[(g_{j1},g_{j2})]).
\label{eq:between_cluster_quality_stat_approx}
\end{align}
Note that the silhouette is more stringent because for the silhouette, we average only the distance from interactions of the nearest cluster for an observation.
We then made these silhouette plots and calculated the quantity for five different methods. First, we wanted to evaluate how well the three clustering approaches, namely the Multidimensional Scaling approximation and the first and second geometric approximations of the Procrustes distance, introduced in Section~\ref{Section: Distribution_primitives}, performed. Next, because we segmented encounters using splines, we wanted to examine the quality of k-means clustering based on the coefficients of the cubic splines fitted to these interactions. In other words, suppose for interaction $i$, we fit the cubic spline $c^1_{i10} + c^1_{i11}t + c^1_{i12}t^2 + c^1_{i13}t^3$ to $(g_{i1})_1$. We do the same for $(g_{i2})_2$, $(g_{i2})_1$, and $(g_{i2})_2$. Then, we perform k-means on the vectors, $\{\{c^1_{i1\ell}\}_{\ell = 0}^3, \{c^2_{i1\ell}\}_{\ell = 0}^3, \{c^1_{i2\ell}\}_{\ell = 0}^3, \{c^2_{i2\ell}\}_{\ell = 0}^3\}_{i = 1}^n$. We call this approach $\textit{spline coefficient clustering}$. Finally, dynamic time warping (DTW) is a standard approach to match curves -- in Wang et. al \cite{Wang-Zhao-2017}, k-means clustering is performed on the DTW matrices that match one trajectory to another for each V2V interaction. This is another approach we wish to evaluate.
We focus on reporting for the case $k = 5$ for the moment, while the analysis can be replicated on other choices of $k$. The results for encounters segmented by the two step approach can be seen in Figure \ref{fig:two_step_silhouette_plots} and Table \ref{table:two_step_cluster_quality_stats_approx}.
Accordingly, the MDS approach outlined in Algorithm \ref{algo: primitive clustering} appears to perform the best whereas the spline coefficients and DTW matrices perform the worst. The total within square distance from Eq. \eqref{eq:k_means_approx} for the MDS approach in Table \ref{table:two_step_cluster_quality_stats_approx} is smallest and the silhouette plots in Figure \ref{fig:two_step_silhouette_plots} look reasonable. Indeed, even though the first geometric approximation's average within square distance for the clusters with most and fewest interactions is smaller and the average between square distance is comparable or larger, the silhouette plot shows us that the MDS approach does significantly better with the cluster with the second and third largest cluster. The silhouette values are much higher for that cluster than the first geometric approximation.
For interpretability, one may be interested in visualizing typical interactions from each clusters. Take the MDS method. There are various interesting observations in Fig. \ref{fig:two_step_typical_encounter_plot_approx_mds}. For instance, the two clusters with most interactions are interactions in which the vehicles do not move far from each other. On the other hand, the other clusters have interactions in which the opposite is true. Further, while only the cluster with the fewest interactions have vehicles going in the same direction, there are variation in how the vehicles are moving in opposite directions. Figure \ref{fig:two_step_typical_encounter_plot_approx} in the Appendix shows the three most typical encounters for all clustering methods.
One can look more deeply into the distribution of interactions in each cluster, which is revealed by Figure \ref{fig:cluster_dist_freq_plots}. The left two plots show the proportion of interactions in each cluster a certain distance away from the mean or typical interaction for each cluster. On the other hand, the right two plots show the proportion of interactions from the entire data set a certain distance away for each cluster's mean or typical interaction. The first geometric approximation plot is ideal. While the other methods have a cluster that peaks higher near zero, the left two plots show higher peaks near zero across all clusters, indicating that most interactions in the cluster are close to the typical or mean interaction. On the other hand, the right two plots show a peak near zero and then plateau for a bit before decreasing to zero. This supports what we see in the silhouette plot. The plateau demonstrates that the clusters are well separated because interactions outside the cluster are further away. Because of the left two plots, the peak near zero likely comes from the interactions assigned to that cluster. It is likely that the plots for the MDS will look similar to the first geometric approximation plots. For the second geometric approximation, the interaction plots for the mean interaction are ideal. However, outside of the largest cluster, the typical interaction to cluster interaction plots peak at values not near zero or plateau for ranges of distances.
Meanwhile, the plots for polynomial coefficient exhibit peculiar peaks or plateaus in the left plots. These peaks are slightly dampened when using the typical interaction in place of the mean interaction.
\subsection{Stability Evaluation}
\label{ssection:clustering_stability}
\begin{figure*}[!tbp]
\centering
\begin{subfigure}{.22\textwidth}
\centering
\includegraphics[width = 1\textwidth]{mds_no_reflection_all_stability_plots_stability_stat.pdf}
\caption{All $k$ and $\beta$ between 2 and 20}
\end{subfigure}
\begin{subfigure}{.22\textwidth}
\centering
\includegraphics[width = 1\textwidth]{mds_no_reflection_all_stability_plots_stability_stat_k_gt_10.pdf}
\caption{All $\beta$ between $10$ and $20$ and $k$ between $10$ and $20$}
\end{subfigure}
\centering
\begin{subfigure}{.22\textwidth}
\centering
\includegraphics[width = 1\textwidth]{mds_no_reflection_stability_change_no_reflection_plot.pdf}
\caption{All $\beta$ between 2 and 20 and $k$ between 10 and 20}
\end{subfigure}
\begin{subfigure}{.22\textwidth}
\centering
\includegraphics[width = 1\textwidth]{mds_no_reflection_stability_change_no_reflection_plot_k_gt_10.pdf}
\caption{All $\beta$ between $2$ and $20$ and $k$ between $10$ and $20$}
\end{subfigure}
\caption{The left two plots show heatmaps of the statistic introduced in Eq. \eqref{eq:equivalent_kmeans problem} for encounters segmented by the two-step spline approach (cf. Appendix \ref{Section: Spline}) and then clustered via MDS (cf. Section \ref{ssection:approximation}). The right two show changes in this statistic.}
\label{fig:eq_kmeans_heat_map_no_reflection}
\centering
\begin{subfigure}{.3\textwidth}
\centering
\includegraphics[width = .75\textwidth]{mds_no_reflection_all_stability_plots_stability_stat_k_gt_10_comparison.pdf}
\caption{MDS clustering (cf. Section \ref{ssection:approximation}) applied to two-step spline segmented encounters (cf. Appendix \ref{Section: Spline}).}
\end{subfigure}
\begin{subfigure}{.3\textwidth}
\centering
\includegraphics[width = .75\textwidth]{bnp_no_reflection_all_stability_plots_stability_stat_k_gt_10_comparison.pdf}
\caption{DTW matrix clustering applied to encounters segmented by BNP (cf. \cite{Wang-Zhao-2017}).\\}
\end{subfigure}
\begin{subfigure}{.3\textwidth}
\centering
\includegraphics[width = .75\textwidth]{comparison_bnp_no_reflection_all_stability_plots_stability_stat_k_gt_10_comparison.pdf}
\caption{Two step spline segmented encounters clustered using primitives extracted from BNP segmented encounters clustered using DTW matrices (cf. \ref{ssection:clustering_stability}).}
\end{subfigure}
\caption{Heatmaps of the statistic given by Eq. \eqref{eq:equivalent_kmeans problem} for non-reflective Procrustes distance for $k \geq 10$ across different methods.}
\label{fig:k_gt_10_stability_comparison}
\end{figure*}
We had to develop a statistic for stability based on our distance metric. Consider the k-means problem in a Euclidean space. Let $x_1,\dots,x_n \in \mathbb{R}^d$ be points in an Euclidean space belonging to clusters $\{1,\dots,K\}$. The cost function relative to the k-means problem is given by
\begin{eqnarray}
\min_{\{\Gamma_1,\dots,\Gamma_k, z_1,\dots,z_n\}}\frac{1}{n}\sum_{j=1}^k \sum_{i:z_i=j} \| x_i - \Gamma_j\|^2.\nonumber
\end{eqnarray}
The above cost function can also be written as:
\begin{eqnarray}
\label{eq:kmeans problem}
\min_{\{z_1,\dots,z_n\}}\frac{1}{2n}\sum_{k=1}^K \sum_{i,j:z_i,z_j=k} \| x_i-x_j\|^2.
\end{eqnarray}
Eq.~\eqref{eq:kmeans problem} provides a way to partition the dataset $\{x_1,\dots,x_n\}$ so as to optimize the within cluster distance. We then use a measure equivalent to~\eqref{eq:kmeans problem} to evaluate the stability of algorithms. Namely, if we use the same notation as before, then the stability of the algorithm is measured by computing
\begin{eqnarray}
\label{eq:equivalent_kmeans problem}
\frac{1}{2n}\sum_{k=1}^K \sum_{i,j:z_i,z_j=k} d^2((f_{i1}, f_{i2}),(f_{j1}, f_{j2}))),
\end{eqnarray}
for varying values of tuning parameters, where $d((f_{i1}, f_{i2}),(f_{j1}, f_{j2})))$ is the metric introduced in Eq.~\eqref{eq:metric_quotient_space}.
We then calculated this statistic for the MDS approach outlined in Section \ref{ssection:approximation}. Applying k-means to the MDS projection of the (non-reflective) Procrustes distance requires the specification of the following parameters: dimension of the projection, $\beta$, and the number of clusters, $k$. The results for $\beta \in [2, 20]$ and $k \in [2, 20]$ can be seen in Figure \ref{fig:eq_kmeans_heat_map_no_reflection}. From the heatmap, the MDS approach is particularly stable for $k \geq 15$ and $\beta > 5$. This is further supported by examining the change in the statistic introduced in Eq. \eqref{eq:equivalent_kmeans problem}. This makes sense because increasing the dimension for the MDS representation provides a better representation of the pairwise distance. On the other hand, increasing $k$ also leads to greater stability.
However, the scales in the figure suggests that most of the instability occurs when $k \leq 10$.
As before, we proceed to compare among methods and data sets. First,
following Wang and Zhou \cite{Wang-Zhao-2017}, we examined the stability of the DTW approach for the encounters segmented by sticky HMM-HDP. While there are more parameters to consider, we empirically investigated the results with $\alpha$ and $c$ fixed to 2 and 100 respectively and allowed $\gamma$ and $k$ to vary between $[2, 19]$ and $[2, 20]$. Because changing $\gamma$ gives us new primitives, we had to interpolate and recalculate the Procrustes distance for each set of primitives. Second, we wanted to inspect the stability of "transferring" primitives. In other words, let $\{(g'_{j1}, g'_{j2})\}_{j = 1}^k$ be the primitives derived from applying BNP to segment encounters and using the DTW matrices to cluster them and $\{(f_{i1}, f_{i2})\}_{i = 1}^{n}$ be the interactions extracted from the encounters using our two-step approach outlined in Appendix \ref{Section: Spline}. We assign interaction $i$ to cluster $j$ if
\[
j = \textrm{argmin}_{j' = 1:k} d((f_{i1}, f_{i2}), (g'_{j1}, g'_{j2})).
\]
Here, $d((f_{i1}, f_{i2}), (g'_{j1}, g'_{j2}))$ is the distance introduced in Eq. \eqref{eq:rotation_translation_invariance}.
The results can be seen in Figure \ref{fig:k_gt_10_stability_comparison}. For DTW, the results are similar to the results before with respect to $k$ and may even be better. On the other hand, as seen in the scales in Figure \ref{fig:k_gt_10_stability_comparison}, we see that there is greater instability in both the range and the pattern when we "transfer" primitives. Further, unlike before, this instability persists even as $k$ increases. This could be due to the more extreme values in the BNP primitive data set. As a result, there might be primitives that do not exist in the data set segmented by the two step spline approach. This could mean that as we increase $k$, we might not be adding centroids used to cluster the data. In addition, the ones that do exist might be influenced by these more extreme values. This might be why the values are unstable for lower values of $k$.
\section{Conclusion}
We developed a distance metric for the space of trajectory pairs that is invariant under translation and rotation. By using it to measure the distance between distributions, we could also use this metric for clustering and for evaluating a variety of unsupervised techniques for interaction learning. The distance metric and geometric approximation methods that we introduced help to address the challenges for robust learning of non-Euclidean quantities that represent temporally dynamic interactions. These techniques were demonstrated by the unsupervised learning of vehicle-to-vehicle interactions. An interesting direction for our work is to extend the metric based representation and geometric algorithms to the multiple-vehicle interaction setting, and general multi-agent settings. The challenge is the find a right metric or a family of metrics which are both meaningful and computationally tractable for a number of learning tasks of interests.
\section*{Acknowledgements}
Toyota Research Institute (TRI) provided funds to assist the authors with their research but this article solely reflects the opinions and conclusions of its authors and not TRI or any other Toyota entity. Dr. Nguyen is also partially supported by grants NSF CAREER DMS-1351362 and NSF CNS-1409303.
| {'timestamp': '2020-06-19T02:07:42', 'yymm': '2006', 'arxiv_id': '2006.10241', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10241'} | arxiv |
\section{Acknowledgements}
\label{Acknowledgements}
This work had been in part supported by the National Science
Foundation under Grant Number IIS-1409823.
\section*{Broader Impact}
The contributions of this paper expand the accuracy and applicability of few shot learning into domains where there is a limited amount of labeled data available. The practical impact of these results is that (a) users who cannot afford extensive data collection and labeling campaigns can develop competitive classifiers and (b) better performance can be obtained in classification applications where the amount of labeled data is naturally low.
There are many ways these advances can be put to a positive societal use. For instance, the approach can be used to classify medical images for rare illnesses, or illnesses where insufficient training data is available. Interestingly, COVID-19 at the time of the submission of this paper falls into this category in the United States. As part of our ongoing work to apply our research to practical applications, we found that as of June 2020, the COVIDx dataset~\cite{wang2020covid} is currently the largest accessible repository of COVID imaging in the US. This dataset contains 76 radiography images from 53 COVID-19 patient cases. Despite the prevalence of the illness, classifying these by severity maps them exactly into the few shot learning scenarios considered in this paper.
Naturally, any AI image classification technology can be put to negative use, for instance by repressive regimes improving their surveillance systems.
\section{Conclusion}
\vspace{-2mm}
We described LASIUM, an unsupervised meta-learning algorithm for few-shot classification. The algorithm is based on interpolation in the latent space of a generative model to create synthetic meta-tasks. In contrast to other approaches, LASIUM requires minimal domain specific knowledge. We found that LASIUM outperforms state-of-the-art unsupervised algorithms on the Omniglot and CelebA identity recognition benchmarks and competes very closely with CACTUs on the CelebA attributes learning benchmark.
\section{Experiments}
We tested the proposed algorithms on three few-shot learning benchmarks: (a) the $5$-way Omniglot~\cite{lake2011one}, a benchmark for few-shot handwritten character recognition, (b) the $5$-way CelebA few-shot identity recognition, and (c) the CelebA attributes dataset~\cite{liu2015faceattributes} proposed as a few-shot learning benchmark by~\cite{finn2017model} that comprises binary classification ($2$-way) tasks in which each task is defined by selecting 3 different attributes and 3 boolean values corresponding to each attribute. Every image in a certain task-specific class has the same attributes with each other while does not share any of these attributes with images in the other class. Last but not least we evaluate our results on (d) the mini-ImageNet~\cite{ravi2016optimization} few-shot learning benchmark.
We partition each dataset into meta-training, meta-validation, and meta-testing splits between classes.
To evaluate our method, we use the classes in the test set to generate 1000 tasks as described in section~\ref{section32}. We set $K^{(val)}$ to be 15.
We average the accuracy on all tasks and report a $95\%$ confidence interval. To ensure that comparisons are fair, we use the same random seed in the whole task generation process. For the Omniglot dataset, we report the results for $K^{(tr)} \in \{1, 5\}$, and $K^{(val)} = 15$. For CelebA identity recognition, we report our results for $K^{(tr)} \in \{1, 5, 15\}$ and $K^{(val)} = 15$. For CelebA attributes, we follow the $K^{(tr)} = 5$ and $K^{(val)} = 5$ tasks as proposed by~\cite{hsu2018unsupervised}.
\subsection{Baselines}
As baseline algorithms for our approach we follow the practice of recent papers in the unsupervised meta-learning literature. The simplest baseline is to train the same network architecture from scratch with $N \times K^{(tr)}$ images. More advanced baselines can be obtained by learning an unsupervised embedding on $\mathcal{U}$ and use it for downstream task training. We used the ACAI~\cite{berthelot*2018understanding}, BiGAN~\cite{donahue2016adversarial, dumoulin2016adversarially}, and DeepCluster~\cite{caron2018deep} as representative of the unsupervised learning literature. On top of these embeddings, we report accuracy for $K_{nn}$-nearest neighbors, linear classifier, multi layer perceptron (MLP) with dropout, and cluster matching.
The direct competition for our approach are the current state-of-the-art algorithms in unsupervised meta-learning. We compare our results with CACTUs-MAML~\cite{hsu2018unsupervised}, CACTUs-ProtoNets~\cite{hsu2018unsupervised} and UMTRA~\cite{khodadadeh2019unsupervised}. Finally, it is useful to compare our approach with algorithms that require supervised data. We include results for supervised standard transfer learning from VGG19 pre-trained on ImageNet~\cite{simonyan2014very} and two supervised meta-learning algorithms, MAML~\cite{hsu2018unsupervised}, and ProtoNets~\cite{hsu2018unsupervised}.
\subsection{Neural network architectures}
Since excessive tuning of hyperparameters can lead to the overestimation of the performance of a model~\cite{Goodfellow-realistic}, we keep the hyperparameters of the unsupervised meta-learning as constant as possible (including the MAML, and ProtoNets model architectures) in all experiments. Our model architecture consists of four stacked convolutional blocks. Each block comprises 64 filters that carry out $3 \times 3$ convolutions, followed by batch normalization, a ReLU non-linearity, and $2 \times 2$ max-pooling. For the MAML experiments, classification is performed by a fully connected layer, whereas for the ProtoNets model we compute distances based on the feature vectors produced by the last convolution module without any dense layers. The input size to our model is $84 \times 84 \times 3$ for CelebA and $28 \times 28 \times 1$ for Omniglot.
For Omniglot, our VAE model is constructed symmetrically. The encoder is composed of four convolutional blocks, with batch normalization and ReLU activation following each of them. A dense layer is connected to the end such that given an input image of shape $28 \times 28$, the encoder produces a latent vector of length $20$. On the other side, the decoder starts from a dense layer whose output has length $7 \times 7 \times 64 = 3136$. It is then fed into four modules each of which consists of a transposed convolutional layer, batch normalization and the ReLU non-linearity. We use $3 \times 3$ kernels, $64$ channels and a stride of $2$ for all the convolutional and transposed convolutional layers. Hence, the generated image has the size of $28 \times 28$ that is identical to the input images. This VAE model is trained for 1000 epochs with a learning rate of 0.001.
Our GAN generator gets an input of size $l$ which is the dimensionality of the latent space and feeds it into a dense layer of size $7 \times 7 \times 128$. After applying a Leaky ReLU with $\alpha = 0.2$, we reshape the output of dense layer to 128 channels of shape $7 \times 7$. Then we feed it into two upsampling blocks, where each block has a transposed convolution with 128 channels, $4 \times 4$ kernels and $2 \times 2$ strides. Finally, we feed the outcome of the upsampling blocks into a convolution layer with 1 channel and a $7 \times 7$ kernel with sigmoid activaiton. The discriminator takes a $28 \times 28 \times 1$ input and feeds it into three $3 \times 3$ convolution layers with 64, 128 and 128 channels and $2 \times 2$ strides. We apply leaky ReLU activation after each convolution layer with $\alpha=0.2$. Finally we apply a global $2$D max pooling layer and feed it into a dense layer with 1 neuron to classify the output as real or fake.
We use the same loss function for training as described in~\cite{mode-gan-Qi2019}.
For the CelebA GAN experiments, we use the pre-trained network architecture described in~\cite{karras2017progressive}. For VAE, we use the same architecture as we described for Omniglot VAE with one more convolution block and more channels to handle the larger input size of $84 \times 84 \times 3$. The exact architecture is described in section~\ref{ablation_studies}.
\subsection{Results on Omniglot}
Table~\ref{tab:omniglot} shows the results on the Omniglot dataset. We find that the LASIUM-RO-GAN-MAML configuration outperforms all the unsupervised approaches, including the meta-learning based ones like CACTUs~\cite{hsu2018unsupervised} and UMTRA~\cite{khodadadeh2019unsupervised}. Beyond the increase in performance, we must note that the competing approaches use more domain specific knowledge (in case of UMTRA augmentations, in case of CACTUs, learned clustering). We also find that on this benchmark, LASIUM outperforms transfer learning using the much larger VGG-19 network.
As expected even the best LASIUM result is worse than the supervised meta-learning models. However, we need to consider that the unsupervised meta-learning approaches use several orders of magnitude less labels. For instance, the 95.29\% accuracy of LASIUM-RO-GAN-MAML was obtained with only 25 labels, while the supervised approaches used 25,000.
\begin{table}[]
\caption{Accuracy results on the Omniglot dataset averaged over 1000, $5$-way, $K^{(tr)}$-shot downstream tasks with $K^{(val)} = 15$ for each task. $\pm$ indicates the 95\% confidence interval. The top three unsupervised results are reported in {\bf bold}.}
\label{tab:omniglot}
\centering
{\footnotesize
\begin{tabular}{lllll}
\toprule
Algorithm & Feature Extractor & $K^{(tr)}$ = 1 & $K^{(tr)}$ = 5 \\
\midrule
Training from scratch & $N/A$ & $51.64 \pm 0.65$ & $71.44 \pm 0.53$ \\
K-nearest neighbors & ACAI & $57.46 \pm 1.35$ & $81.16 \pm 0.57$ \\
Linear Classifier & ACAI & $61.08 \pm 1.32$ & $81.82 \pm 0.58$ \\
MLP with dropout & ACAI & $51.95 \pm 0.82$ & $77.20 \pm 0.65$ \\
Cluster matching & ACAI & $54.94 \pm 0.85$ & $71.09 \pm 0.77$ \\
K-nearest neighbors & BiGAN & $49.55 \pm 1.27$ & $68.06 \pm 0.71$ \\
Linear Classifier & BiGAN & $48.28 \pm 1.25$ & $68.72 \pm 0.66$ \\
MLP with dropout & BiGAN & $40.54 \pm 0.79$ & $62.56 \pm 0.79$ \\
Cluster matching & BiGAN & $43.96 \pm 0.80$ & $58.62 \pm 0.78$ \\
\midrule
CACTUs-MAML & BiGAN & $58.18 \pm 0.81$ & $78.66 \pm 0.65$ \\
CACTUs-MAML & ACAI & $68.84 \pm 0.80$ & $87.78 \pm 0.50$ \\
UMTRA-MAML & $N/A$ & $\bf{81.91 \pm 0.58}$ & $\bf{94.58 \pm 0.25}$ \\
LASIUM-RO-GAN-MAML & $N/A$ & $\bf{83.26 \pm 0.55}$ & $\bf{95.29 \pm 0.22}$ \\
LASIUM-N-VAE-MAML& $N/A$ & $76.11 \pm 0.64$ & $\bf{94.42 \pm 0.26}$ \\
\midrule
CACTUs-ProtoNets & BiGAN & $54.74 \pm 0.82$ & $71.69 \pm 0.73$ \\
CACTUs-ProtoNets & ACAI & $68.12 \pm 0.84$ & $83.58 \pm 0.61$ \\
LASIUM-RO-GAN-ProtoNets & $N/A$ & $\bf{80.15 \pm 0.64}$ & $91.10 \pm 0.35$ \\
LASIUM-OC-VAE-ProtoNets & $N/A$ & $73.22 \pm 0.73$ & $85.05 \pm 0.46$\\
\midrule
Transfer Learning (VGG-19) & $N/A$ & $54.49 \pm 0.90$ & $89.57 \pm 0.44$\\
Supervised MAML & $N/A$ & $94.46 \pm 0.35$ & $98.83 \pm 0.12$\\
Supervised ProtoNets & $N/A$ & $98.35 \pm 0.22$ & $99.58 \pm 0.09$\\
\bottomrule
\end{tabular}
}
\end{table}
\subsection{Results on CelebA}
Table~\ref{tab:gan_celeba} shows our results on the CelebA identity recognition tasks where the objective is to recognize $N$ different people given $K^{(tr)}$ images for each. We find that on this benchmark as well, the LASIUM-RO-GAN-MAML configuration performs better than other unsupervised meta-learning models as well as transfer learning with VGG-19 - it only falls slightly behind LASIUM-RO-GAN-ProtoNets on the one-shot case. As we have discussed in the case of Omniglot results, the performance remains lower then the supervised meta-learning approaches which use several orders of magnitude more labeled data.
Finally, Table~\ref{tab:celeba-annotation} shows our results for CelebA attributes benchmark introduced in~\cite{hsu2018unsupervised}. A peculiarity of this dataset is that the way in which classes are defined based on the attributes, the classes are unbalanced in the dataset, making the job of synthetic task selection more difficult. We find that LASIUM-N-GAN-MAML obtains the second best on this test with a performance of $\bf{74.79 \pm 1.01}$, within the confidence interval of the winner, CACTUs MAML with BiGAN $\bf{74.98 \pm 1.02}$. In this benchmark, transfer learning with the VGG-19 network performed better than all unsupervised meta-learning approaches, possibly due to existing representations of the discriminating attributes in that much more complex network.
\begin{table}[]
\caption{Accuracy results of unsupervised learning on CelebA for different unsupervised methods. The results are averaged over 1000, $5$-way, $K^{(tr)}$-shot downstream tasks with $K^{(val)} = 15$ for each task. $\pm$ indicates the 95\% confidence interval. The top three unsupervised results are reported in {\bf bold}.}
\label{tab:gan_celeba}
\centering
{\footnotesize
\begin{tabular}{llll}
\toprule
Algorithm & $K^{(tr)}$ = 1 & $K^{(tr)}$ = 5 & $K^{(tr)}$ = 15 \\
\midrule
Training from scratch & $34.69 \pm 0.50$ & $56.50 \pm 0.55$ & $70.56 \pm 0.49$\\
CACTUs
& $41.42 \pm 0.64$ & $\bf{62.71 \pm 0.57}$ & $\bf{74.18 \pm 0.68}$ \\
UMTRA & $39.30 \pm 0.59$ & $60.44 \pm 0.56$ & $\bf{72.41 \pm 0.48}$ \\
LASIUM-RO-GAN-MAML & $\bf{43.88 \pm 0.57}$ & $\bf{66.98 \pm 0.53}$ & $\bf{78.13 \pm 0.44}$ \\
LASIUM-RO-VAE-MAML & $41.25 \pm 0.57$ & $58.22 \pm 0.54$ & $71.05 \pm 0.49$ \\
LASIUM-RO-GAN-ProtoNets & $\bf{44.39 \pm 0.61}$ & $60.83 \pm 0.58$ & $66.66 \pm 0.53$ \\
LASIUM-RO-VAE-ProtoNets & $\bf{43.22 \pm 0.58}$ & $\bf{61.12 \pm 0.54}$ & $68.51 \pm 0.51$ \\
\midrule
Transfer Learning (VGG-19) & $33.28 \pm 0.57$ & $58.74 \pm 0.62$ & $74.04 \pm 0.49$ \\
Supervised MAML & $85.46 \pm 0.55$ & $94.98 \pm 0.25$ & $96.18 \pm 0.19$ \\
Supervised ProtoNets & $84.17 \pm 0.61$ & $90.84 \pm 0.38$ & $90.85 \pm 0.36$\\
\bottomrule
\end{tabular}
}
\end{table}
\begin{table}[]
\caption{Results on CelebA attributes benchmark $2$-way, $5$-shot tasks with $K^{(val)} = 5$. The results are averaged over 1000 downstream tasks and $\pm$ indicates 95\% confidence interval. The top three unsupervised results are reported in {\bf bold}.}
\label{tab:celeba-annotation}
\centering
{\footnotesize
\begin{tabular}{lll}
\toprule
Algorithm & Feature Extractor & Accuracy \\
\midrule
Training from scratch & N/A & $63.19 \pm 1.06$\\
K-nearest neighbors & BiGAN & $56.15 \pm 0.89$\\
Linear Classifier & BiGAN & $58.44 \pm 0.90$ \\
MLP with dropout & BiGAN & $56.26 \pm 0.94$ \\
Cluster matching & BiGAN & $56.20 \pm 1.00$\\
K-nearest neighbors & DeepCluster & $61.47 \pm 0.99$\\
Linear Classifier & DeepCluster & $59.57 \pm 0.98$\\
MLP with dropout & DeepCluster & $60.65 \pm 0.9$\\
Cluster matching & DeepCluster & $51.51 \pm 0.89$\\
\midrule
CACTUs MAML & BiGAN & $\bf{74.98 \pm 1.02}$ \\
CACTUs MAML & DeepCluster & $\bf{73.79 \pm 1.01}$ \\
LASIUM-N-GAN-MAML & N/A & $\bf{74.79 \pm 1.01}$ \\
\midrule
CACTUs ProtoNets & BiGAN & $65.58 \pm 1.04$ \\
CACTUs ProtoNets & DeepCluster & $74.15 \pm 1.02$ \\
LASIUM-N-GAN-ProtoNets & N/A & $73.41 \pm 1.10$ \\
\midrule
Transfer Learning (VGG-19) & N/A & $79.76 \pm 1.03$ \\
Supervised MAML & N/A & $87.10 \pm 0.85$\\
Supervised ProtoNets & N/A & $ 85.13 \pm 0.92$\\
\bottomrule
\end{tabular}
}
\end{table}
\section{Introduction}
Meta-learning algorithms for neural networks~\cite{mishra2017simple, finn2017model, snell2017prototypical} prepare networks to quickly adapt to unseen tasks. This is done in a meta-training phase that typically involves a large number of supervised learning tasks. Very recently, several approaches had been proposed that perform the meta-training by generating synthetic training tasks from an {\em unsupervised} dataset. This requires us to generate samples with specific pairwise information: {\em in-class} pairs of samples that are with high likelihood in the same class, and {\em out-of-class} pairs that are with high likelihood {\em not} in the same class. For instance, UMTRA~\cite{khodadadeh2019unsupervised} and AAL~\cite{AAL2019} achieve this through random selection from a domain with many classes for out-of-class pairs and by augmentation for in-class pairs. CACTUs~\cite{hsu2018unsupervised} creates synthetic labels through unsupervised clustering of the domain. Unfortunately, these algorithms depend on domain specific expertise for the appropriate clustering and augmentation techniques.
In this paper, we rely on recent advances in the field of generative models, such as the variants of generative adversarial networks (GANs) and variational autoencoders (VAEs), to generate the in-class and out-of-class pairs of meta-training data. The fundamental idea of our approach is that in-class pairs are close while out-of-class pairs are far away in the latent space representation of the generative model.
Thus, we can generate in-class pairs by interpolating between two out-of-class samples in the latent space and choosing interpolation ratios that put the new sample close to one of the objects. From this latent sample, the generative model creates the new in-class object. Our approach requires minimal domain-specific tweaking, and the necessary tweaks are human-comprehensible. For instance, we need to choose thresholds for latent space distance that ensure that classes are in different domains, as well as interpolation ratio thresholds that ensure that the sample is in the same class as the nearest edge. Another advantage of the approach is that we can take advantage of off-the-shelf, pre-trained generative models.
The main contributions of this paper can be summarized as follows:
\begin{itemize}
\item We describe an algorithm, LAtent Space Interpolation Unsupervised Meta-learning (LASIUM), that creates training data for a downstream meta-learning algorithm starting from an unlabeled dataset by taking advantage of interpolation in the latent space of a generative model.
\item We show that on the most widely used few-shot learning datasets, LASIUM outperforms or performs competitively with other unsupervised meta-learning algorithms, significantly outperforms transfer learning in all cases, and in a number of cases approaches the performance of supervised meta-learning algorithms.
\end{itemize}
\section{Method}
\newcommand{\mathcal{T}}{\mathcal{T}}
\newcommand{\mathcal{D}_{\mathcal{T}}^{(tr)}}{\mathcal{D}_{\mathcal{T}}^{(tr)}}
\newcommand{\mathcal{D}_{\mathcal{T}}^{(val)}}{\mathcal{D}_{\mathcal{T}}^{(val)}}
\subsection{Preliminaries}
We define an $N$-way, $K^{(tr)}$-shot supervised classification task, $\mathcal{T}$, as a set $\mathcal{D}_{\mathcal{T}}^{(tr)}$ composed of $i \in \{1, \ldots, N \times K^{(tr)}\}$ data points $(x_i, y_i)$ such that there are exactly $K^{(tr)}$ samples for each categorical label $y_i \in \{1, \ldots, N\}$.
During meta-learning, an additional set ,$\mathcal{D}_{\mathcal{T}}^{(val)}$, is attached to each task that contains another $N \times K^{(val)}$ data points separate from the ones in $\mathcal{D}_{\mathcal{T}}^{(tr)}$. We have exactly $K^{(val)}$ samples for each class in $\mathcal{D}_{\mathcal{T}}^{(val)}$ as well.
It is straightforward to package $N$-way, $K^{(tr)}$-shot tasks with $\mathcal{D}_{\mathcal{T}}^{(tr)}$ and $\mathcal{D}_{\mathcal{T}}^{(val)}$ from a labeled dataset.
However, in unsupervised meta-learning setting, a key challenge is how to automatically construct tasks from the unlabeled dataset $\mathcal{U} = \{\ldots x_i \ldots\}$.
\subsection{Generating meta-tasks using generative models}\label{section32}
We have seen that in order to generate the training data for the meta-learning phase, we need to generate $N$-way training tasks with $K^{(tr)}$ training and $K^{(val)}$ validation samples. The label associated with the classes in these tasks is not relevant, as it will be discarded after the meta-learning phase. Our objective is simply to generate samples of the type $x_{i,j}$ with $i \in \{1 \ldots N\}$ and $j \in \{1 \ldots K^{(tr)} + K^{(val)}\}$ with the following properties: (a) all the samples $x_{i,j}$ are different (b) any two samples with the same $i$ index are in-class samples and (c) any two samples with different $i$ index are out-of-class samples. In the absence of human provided labels, the class structure of the domain is defined only implicitly by the sample selection procedure. Previous approaches to unsupervised meta-learning chose samples directly from the training data $x_{i,j} \in \mathcal{U}$, or created new samples through augmentation. For instance, we can define the class structure of the domain by assuming that certain types of augmentations keep the samples in-class with the original sample. One challenge of such approaches is that the choice of the augmentation is domain dependent, and the augmentation itself can be a complex mathematical operation.
In this paper we approach the sample selection problem differently. Instead of sampling $x_{i,j}$ from $\mathcal{U}$, we use the unsupervised dataset to train a generative model $p(x)$. Generative models represent the full probability distribution of a model, and allow us to sample new instances from the distribution. For many models, this sampling process can be computationally expensive iterative process. Many successful neural network based generative models use the {\em reparametrization trick} for the training and sampling which concentrate the random component of the model in a latent representation $z$. By choosing the latent representation $z$ from a simple (uniform or normal) distribution, we can obtain a sample from the complex distribution $p(x)$ by passing $z$ through a deterministic generator $\mathcal{G}(z) \rightarrow x$. Two of the most popular generative models, variational autoencoders (VAEs) and generative adversarial networks (GANs) follow this model.
The idea of the LASIUM algorithm is that given a generator component $\mathcal{G}(.)$, {\em nearby} latent space values $z_1$ and $z_2$ map to {\em in-class} samples $x_1$ and $x_2$. Conversely, $z_1$ and $z_2$ values that are {\em far away} from each other, map to {\em out of class} samples. Naturally, we still need to define what we mean by ``near'' and ``far'' in the latent space and how to choose the corresponding $z$ values. However, this is a significantly simpler task than, for instance, defining the set of complex augmentations that might retain class membership.
\begin{figure}[ht]
\centering
\includegraphics[width=0.8\columnwidth, height=0.35\columnwidth]{figures/GAN-method-illustration.pdf}
\caption{$3$-way, $K^{(tr)}$-shot task generation with $K^{(val)}$ images for validation by a pre-trained GAN generator $\mathcal{G}$. \textbf{a)} Sample $3$ random vectors. \textbf{b)} Generate new vectors by one of the proposed in-class sampling strategies. \textbf{c)} Generate images from all of the latent vectors and put them into train and validation set to construct a task.
The images in this figure have been generated by our algorithm.
The colored edge of each image indicates that it was generated from its corresponding latent vector.
}
\label{fig:method-gan}
\end{figure}[ht]
\begin{figure}
\centering
\includegraphics[width=0.98\columnwidth, height=0.3\columnwidth]{figures/VAE-Method-Illusteration.pdf}
\caption{$3$-way, $K^{(tr)}$-shot task generation by VAE on Omniglot dataset with $K^{(val)}$ images for validation set of each task. \textbf{a)} Sample $3$ images from dataset. \textbf{b)} Encode the images into latent space and check if they are distanced. \textbf{c)} Use proposed in-class sampling techniques to generate new latent vectors. \textbf{d)} Generate images from the latent vectors and put them alongside with sampled images from step \textbf{a} into train and validation set to construct a task.}
\label{fig:method-vae}
\end{figure}
\noindent{\bf Training a generative model}
Our method for generating meta-tasks is agnostic to the choice of training algorithm for the generative model and can use either a VAE or a GAN with minimal adjustments. In our VAE experiments, we used a network trained with the standard VAE training algorithm~\cite{kingma2013auto}. For the experiments with GANs we used two different methods mode seeking GANs (MSGAN)~\cite{mode-gan-Qi2019} and progressive growing of GANs (proGAN)~\cite{karras2017progressive}.
Algorithm~\ref{alg:LASIUM} describes the steps of our method. We will delve into each step in the following parts of this section.
\begin{algorithm}[t]
\label{alg:LASIUM}
\caption{LASIUM for unsupervised meta-learning task generation}
\SetKwInOut{Require}{require}
\Require{Unlabeled dataset $\mathcal{U}=\{\ldots x_i \ldots\}$, Pre-trained generator $\mathcal{G}$, Policy $\mathcal{P}$}
\Require{$K^{(tr)}$, $K^{(val)}$: number of samples for train and validation during meta-learning}
\Require{$N$: class-count, $N_{MB}$: meta-batch size}
$B = \{\}$ \tcp*[l]{meta-batch of tasks}
\For {i in $1, \ldots, N_{MB}$} {
Sample $N$ class-vectors in latent space of $\mathcal{G}$ and add them to task-vectors
\For {$\omega$ in $1, \ldots, K^{(tr)} + K ^{(val)}- 1$} {
generate new-vectors = $\mathcal{P}$(class-vectors, $\omega$)
and
add them to task-vectors
}
Generate $N \times (K^{(tr)} + K^{(val)})$ images by feeding task-vectors to generator $\mathcal{G}$
Construct task $\mathcal{T}_i$ by putting the first $N \times K^{(tr)}$ images in task train set and the last $N \times K^{(val)}$ images in task validation set
$B \leftarrow B \cup \mathcal{T}_i$
}
\Return B
\end{algorithm}
\noindent{\bf Sampling out of class instances from the latent space representation:} Our sampling techniques differ slightly whether we are using a GAN or VAE. For GAN, we use rejection sampling to find $N$ latent space vectors that are at a pairwise distance of at least threshold $\epsilon$ - see Figure~\ref{fig:method-gan}(a). When using a VAE, we also have an encoder network that allows us to map from the domain to the latent space. Taking advantage of this, we can additionally sample data points from our unlabeled dataset $\mathcal{U}$ and embed them into a latent space. If the latent space representation of these $N$ images are too close to each other, we re-sample, otherwise we can use the $N$ images and their representations and continue the following steps exactly the same as GANs - see Figure~\ref{fig:method-vae}(a) and (b). We will refer to the vectors selected here as {\em anchor vectors}.
\noindent{ \bf Generating in-class latent space vectors}
\label{generating_class_candidates}
Next, having $N$ sampled anchor vectors $\{z_{1}, \ldots, z_{N}\}$ from the latent space representation, we aim to generate $N$ new vectors $\{z'_{1}, \ldots, z'_{N}\}$ from the latent space representation such that the generated image $\mathcal{G}(z_{i})$ belongs to the same class as the one of $\mathcal{G}(z'_{i})$ for $i \in {1, \ldots, N}$. This process needs to be repeated $\mathcal{P}$ for $K^{(tr)} + K^{(val)} - 1$ times.
The sampling strategy takes as input the sampled vectors
and a number $\mathcal{\omega} \in \{1 \ldots K^{(tr)} + K^{(val)} - 1\}$
and returns $N$ new vectors such that $z_{i}$ and $z'_{i}$ are an in-class pair for $i \in \{1 \ldots N\}$. This ensures that no two $z'_{i}$ belong to the same class and creates $N$ groups of $(K^{(tr)} + K^{(val)})$ vectors in our latent space. We feed these vectors to our generator to get $N$ groups of $(K^{(tr)} + K^{(val)})$ images. From each group we pick the first $K^{(tr)}$ for $\mathcal{D}_{\mathcal{T}}^{(tr)}$ and the last $K^{(val)}$ for $\mathcal{D}_{\mathcal{T}}^{(val)}$.
What remains is to define the strategy to sample the individual in-class vectors. We propose three different sampling strategies, all of which can be seen as variations of the idea of latent space interpolation sampling. This motivates the name of the algorithm LAtent Space Interpolation Unsupervised Meta-learning (LASIUM).
\begin{figure}[ht]
\centering
\includegraphics[width=0.85\columnwidth,height=0.55\columnwidth]{figures/all_procedures.pdf}
\caption{Latent space representation visualization of proposed strategies for generating in-class candidates.
\textbf{Left}: LASIUM-N, adding random noise to the sample vector.
\textbf{Middle}: LASIUM-RO, interpolate with random out-of-class samples.
\textbf{Right}: LASIUM-OC, interpolate with other classes' samples.
}
\label{fig:gcn}
\vspace{-4mm}
\end{figure}
{\bf{LASIUM-N} (adding Noise)}:
This technique generates in-class samples by adding Gaussian noise to the anchor vector $z'_{i} = z_{i} + \epsilon$ where $\epsilon \sim \mathcal{N}(0, \sigma^2)$ (see Figure~\ref{fig:gcn}-Left). In the context of LASIUM, we can see this as an interpolation between the anchor vector and a noise vector, with the interpolation factor determined by $\sigma$. For the impact of different choices of $\sigma$ see the ablation study in section~\ref{ablation_studies}.
{\bf{LASIUM-RO} (with Random Out-of-class samples)} To generate a new in-class sample to anchor vector $z_i$ we first find a random out-of-class sample $v_i$, and choose an interpolated version closer to the anchor: $z'_{i} = z_{i} + \alpha \times (v_{i} - z_{i})$ (see Figure~\ref{fig:gcn}-Middle). Here, $\alpha$ is a hyperparameter, which can be tuned to define the size of the class. As we are in a comparatively high-dimensional latent space (in our case, 512 dimensions), we need relatively large values of $\alpha$, such as $\alpha = 0.4$ to define classes of reasonable size. This model effectively allows us to define complex augmentations (such as a person seen without glasses, or in a changed lighting) with only one scalar hyperparameter to tune. By interpolating towards another sample we ensure that we are staying on the manifold that defines the dataset (in the case of Figure~\ref{fig:gcn}, this being human faces).
{\bf{LASIUM-OC} (with Other Classes' samples)} This technique is similar to LASIUM-RO, but instead of using a randomly generated out-of-class vector, we are interpolating towards vectors already chosen from the other classes in the same task (see Figure~\ref{fig:gcn}-Right). This limits the selection of the samples to be confined to the convex hull defined by the initial anchor points. The intuition behind this approach is that choosing the samples this way focuses the attention of the meta-learner towards the hard to distinguish samples that are {\em between} the classes in the few shot learning class (eg. they share certain attributes).
\subsubsection{Task definition}
\section{Related Work}
Meta-learning or ``learning to learn'' in the field of neural networks is an umbrella term that covers a variety of techniques that involve training a neural network over the course of a meta-training phase, such that when presented with the target task, the network is able to learn it much more efficiently than an unprepared network would. Such techniques had been proposed since the 1980s~\cite{schmidhuber1987evolutionary, bengio1990learning, naik1992meta, Sebastian1998}. In recent years, meta-learning has gained a resurgence, through approaches that either ``learn to optimize'' ~\cite{finn2017model,sachin2016,Mishra2017, reptile2018, rusu2018,rajeswaran2019meta} or learn embedding functions in a non-parametric setting~\cite{snell2017prototypical, matchingnet2016, Ren2018, Liu}. Hybrids between these two approaches had also been proposed~\cite{triantafillou2019meta,wang2019hybrid}.
Most approaches use labeled data during the meta-learning phase. While in some domains there is an abundance of labeled datasets, in many domains such labeled data is difficult to acquire. Unsupervised meta-learning approaches aim to learn from an unsupervised dataset from a domain similar from that of the target task. Typically these approaches generate synthetic few-shot learning tasks for the meta-learning phase through a variety of techniques. CACTUs~\cite{hsu2018unsupervised} uses a progressive clustering method. UMTRA~\cite{khodadadeh2019unsupervised} utilizes the statistical diversity properties and domain-specific augmentations to generate synthetic training and validation data. AAL~\cite{AAL2019} uses augmentation of the unlabeled training set to generate the validation data. The accuracy of these approaches was shown to be comparable with but lower than supervised meta-learning approaches, but with the advantage of requiring orders of magnitude less labeled training data. A common weakness of these approaches is that the techniques used to generate the synthetic tasks (clustering, augmentation, random sampling) are highly domain dependent.
Our proposed approach, LASIUM, takes advantage of generative models trained on the specific domain to create the in-class and out-of-class pairs of meta-training data. The most successful neural-network based generative models in recent years are variational autoencoders (VAE)~\cite{kingma2013auto} and generative adversarial networks (GANs)~\cite{goodfellow2014generative}. The implementation variants of the LASIUM algorithm described in this paper rely on the original VAE model and on two specific variations of the GAN concept, respectively. MSGAN (aka Miss-GAN)~\cite{mode-gan-Qi2019} aims to solve the missing mode problem of conditional GANs through a regularization term that maximizes the distance between the generated images with respect to the distance between their corresponding input latent codes. Progressive GANs~\cite{karras2017progressive} are growing both the generator and discriminator progressively, and approach resembling the layer-wise training of autoencoders.
\subsection{Results on mini-ImageNet}
In this section, we evaluate our algorithm on mini-ImageNet benchmark.
Its complexity is high due to the use of ImageNet images. In total, there are 100 classes with 600 samples of $84 \times 84$ color images per class. These 100 classes are divided into 64, 16, and 20 classes respectively for sampling tasks for meta-training, meta-validation, and meta-test.
A big difference between mini-ImageNet and CelebA is that we have to classify a group of concepts instead of just the identity of a subject. This makes interpreting the latent space a bit trickier. For example, it is not rational to interpolate between a bird and a piano. However, the assumption that nearby latent vectors belong to nearby instances is still valid. Thereby, we could be confident by not getting too far from the current latent vector, we generate something which belongs to the same class (identity).
For mini-ImageNet we use a pre-trained network BigBiGAN\footnote{https://tfhub.dev/deepmind/bigbigan-resnet50/1}. Our experiments show that our method is very effective and can outperform state-of-the-art algorithms. See Table~\ref{tab:mini-imagenet} for the results on mini-ImageNet benchmark.
Figure~\ref{fig:miniImageNet} demonstrates tasks constructed for mini-ImageNet by LASIUM-N with $\sigma^2 = 1.0$.
\begin{figure}[ht]
\centering
\includegraphics[width=0.7\columnwidth,height=0.4\columnwidth]{figures/mini_ImageNet.pdf}
\caption{Train and validation tasks for mini-ImageNet constructed by LASIUM-N with $\sigma^2 = 1.0$}
\label{fig:miniImageNet}
\end{figure}
\begin{table}[]
\caption{Results on mini-ImageNet benchmark for $5$-way, $K^{(tr)}$-shot tasks with $K^{(val)} = 15$. The results are averaged over 1000 downstream tasks and $\pm$ indicates 95\% confidence interval. The top three unsupervised results are reported in {\bf bold}.}
\label{tab:mini-imagenet}
\centering
{\footnotesize
\begin{tabular}{p{2.7cm}p{1.5cm}p{1.8cm}p{1.8cm}p{1.8cm}p{1.8cm}}
\toprule
Algorithm & Embedding & $K^{(tr)}$ = 1 & $K^{(tr)}$ = 5 & $K^{(tr)}$ = 20 & $K^{(tr)}$ = 50 \\
\midrule
Training from scratch & N/A & $27.59 \pm 0.59$ & $38.48 \pm 0.66$ & $51.53 \pm 0.72$ & $59.63 \pm 0.74$\\
K-nearest neighbors & BiGAN & $25.56 \pm 1.08$ & $31.10 \pm 0.63$ & $37.31 \pm 0.40$ & $43.60 \pm 0.37$\\
Linear Classifier & BiGAN & $27.08 \pm 1.24$ & $33.91 \pm 0.64$ & $44.00 \pm 0.45$ & $50.41 \pm 0.37$ \\
MLP with dropout & BiGAN & $22.91 \pm 0.54$ & $29.06 \pm 0.63$ & $40.06 \pm 0.72$ & $48.36 \pm 0.71$ \\
Cluster matching & BiGAN & $24.63 \pm 0.56$ & $29.49 \pm 0.58$ & $33.89 \pm 0.63$ & $36.13 \pm 0.64$\\
K-nearest neighbors & DeepCluster & $28.90 \pm 1.25$ & $42.25 \pm 0.67$ & $56.44 \pm 0.43$ & $63.90 \pm 0.38$\\
Linear Classifier & DeepCluster & $ 29.44 \pm 1.22$ & $39.79 \pm 0.64$ & $56.19 \pm 0.43$ & $ 65.28 \pm 0.34$\\
MLP with dropout & DeepCluster & $29.03 \pm 0.61$ & $39.67 \pm 0.69$ & $52.71 \pm 0.62$ & $60.95 \pm 0.63$\\
Cluster matching & DeepCluster & $22.20 \pm 0.50$ & $23.50 \pm 0.52$ & $24.97 \pm 0.54$ & $26.87 \pm 0.55$\\
\midrule
CACTUs MAML & BiGAN & $36.24 \pm 0.74$ & $51.28 \pm 0.68$ & $61.33 \pm 0.67$ & $66.91 \pm 0.68$ \\
CACTUs MAML & DeepCluster & ${39.90 \pm 0.74}$ & $\bf{53.97 \pm 0.70}$ & $\bf{63.84 \pm 0.70}$ & $\bf{69.64 \pm 0.63}$ \\
UMTRA MAML & N/A & $\bf{39.93}$ & $50.73$ & $61.11$ & $\bf67.15$ \\
LASIUM-N-GAN-MAML & N/A & $\bf{40.19 \pm 0.58}$ & $\bf{54.56 \pm 0.55}$ & $\bf{65.17 \pm 0.49}$ & $\bf{69.13 \pm 0.49}$ \\
\midrule
CACTUs ProtoNets & BiGAN & $36.62 \pm 0.70$ & $50.16 \pm 0.73$ & $59.56 \pm 0.68$ & $63.27 \pm 0.67$ \\
CACTUs ProtoNets & DeepCluster & $39.18 \pm 0.71$ & $\bf53.36 \pm 0.70$ & $\bf61.54 \pm 0.68$ & $63.55 \pm 0.64$ \\
LASIUM-N-GAN-ProtoNets & N/A & $\bf40.05 \pm 0.60$ & $52.53 \pm 0.51$ & $59.45 \pm 0.48$ & $61.43 \pm 0.45$ \\
\midrule
Supervised MAML & N/A & $46.81 \pm 0.77$ & $62.13 \pm 0.72$ & $71.03 \pm 0.69$ & $75.54 \pm 0.62$\\
Supervised ProtoNets & N/A & $46.56 \pm 0.76$ & $62.29 \pm 0.71$ & $70.05 \pm 0.65$ & $72.04 \pm 0.60$\\
\bottomrule
\end{tabular}
}
\end{table}
\subsection{Hyperparameters and ablation studies}
\label{ablation_studies}
In this section, we report the hyperparameters of LASIUM-MAML in Table~\ref{tab:hyperparams_maml} and LASIUM-ProtoNets in Table~\ref{tab:hyperparams_protonets} for Omniglot, CelebA, CelebA attributes and mini-ImageNet datasets.
We also report the ablation studies on different strategies for task construction in Table~\ref{tab:ablation1}. We run all the algorithm for just 1000 iterations and compared between them. We also apply a small shift to Omniglot images.
\begin{table}[!h]
\caption{LASIUM-MAML hyperparameters summary}
\label{tab:hyperparams_maml}
\centering
{\footnotesize
\begin{tabular}{lllll}
\toprule
Hyperparameter & Omniglot & CelebA & CelebA attributes & mini-ImageNet \\
\midrule
Number of classes & $5$ & $5$ & $2$ & $5$ \\
Input size & $28 \times 28 \times 1$ & $84 \times 84 \times 3$ & $84 \times 84 \times 3$ & $84 \times 84 \times 3$\\
Inner learning rate & 0.4 & 0.05 & 0.05 & 0.05\\
Meta learning rate & 0.001 & 0.001 & 0.001 & 0.001\\
Meta-batch size & 4 & 4 & 4 & 4\\
$K^{(tr)}$ meta-learning & 1 & 1 & 5 & 1\\
$K^{(val)}$ meta-learning & 5 & 5& 5 & 5\\
$K^{(val)}$ evaluation & 15 & 15 & 5 & 15\\
Meta-adaptation steps & 5 & 5 & 5 & 5\\
Evaluation adaptation steps & 50 & 50 & 50 & 50\\
\end{tabular}
}
\end{table}
\begin{table}[!h]
\caption{LASIUM-ProtoNets hyperparameters summary}
\label{tab:hyperparams_protonets}
\centering
{\footnotesize
\begin{tabular}{lllll}
\toprule
Hyperparameter & Omniglot & CelebA & CelebA attributes & mini-ImageNet \\
\midrule
Number of classes & $5$ & $5$ & $2$ & $5$ \\
Input size & $28 \times 28 \times 1$ & $84 \times 84 \times 3$ & $84 \times 84 \times 3$ & $84 \times 84 \times 3$\\
Meta learning rate & 0.001 & 0.001 & 0.001 & 0.001\\
Meta-batch size & 4 & 4 & 4 & 4\\
$K^{(tr)}$ meta-learning & 1 & 1 & 5 & 1\\
$K^{(val)}$ meta-learning & 5 & 5& 5 & 5\\
$K^{(val)}$ evaluation & 15 & 15 & 5 & 15\\
\end{tabular}
}
\end{table}
\begin{table}[]
\caption{Accuracy of different proposed strategies on Omniglot. For the sake of comparison, we stop meta-learning after 1000 iterations. Results are reported on 1000 tasks with a $95\%$ confidence interval.}
\label{tab:ablation1}
\centering
{\footnotesize
\begin{tabular}{p{2.3cm}p{1.9cm}p{1.8cm}p{1.75cm}p{1.75cm}p{1.75cm}}
\toprule
Sampling Strategy & Hyperparameters & GAN-MAML & VAE-MAML & GAN-Proto & VAE-Proto \\
\midrule
LASIUM-N & $\sigma^2$=0.5 & $\bf77.16 \pm 0.65$ & $70.41 \pm 0.71$ & $62.16 \pm 0.79$ & $61.57 \pm 0.80$ \\
LASIUM-N & $\sigma^2$=1.0 & $71.10 \pm 0.70$ & $68.26 \pm 0.71$ & $60.95 \pm 0.78$ & $62.17 \pm 0.80$ \\
LASIUM-N & $\sigma^2$=2.0 & $63.18 \pm 0.71$ & $65.18 \pm 0.71$ & $59.81 \pm 0.78$ & $\bf64.88 \pm 0.78$ \\
\midrule
LASIUM-RO & $\alpha$=0.2 & $\bf77.62 \pm 0.64$ & $\bf75.02 \pm 0.66$ & $\bf62.24 \pm 0.79$ & $62.17 \pm 0.80$\\
LASIUM-RO & $\alpha$=0.4 & $\bf75.79 \pm 0.65$ & $\bf71.31 \pm 0.70$ & $\bf64.19 \pm 0.76$ & $\bf62.20 \pm 0.80$\\
\midrule
LASIUM-OC & $\alpha$=0.2 & $74.70 \pm 0.68$ & $\bf74.98 \pm 0.67$ & $61.79 \pm 0.79$ & $62.16 \pm 0.78$ \\
LASIUM-OC & $\alpha$=0.4 & $73.40 \pm 0.68$ & $68.79 \pm 0.73$ & $\bf64.59 \pm 0.76$ & $\bf63.08 \pm 0.79$\\
\bottomrule
\end{tabular}
}
\end{table}
| {'timestamp': '2020-06-19T02:07:36', 'yymm': '2006', 'arxiv_id': '2006.10236', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10236'} | arxiv |
\section{Conclusion}
\label{section_conclusion}
In this paper, we studied the {\sc $\cal F$-Contraction} problem, where $\cal F$ is a subfamily of chordal graphs, in the realm of parameterized approximation. We showed that \textsc{Clique Contraction} admits
a {\sf PSAKS}. On the other hand, \textsc{Split Contraction} admits a factor $(2+\epsilon)$-\textsf{FPT}-approximation algorithm, for any $\epsilon > 0$. In fact, we showed that for any $\epsilon > 0$, \textsc{Split Contraction} admits an $(2 + \epsilon)$-approximate kernel with $\ensuremath{{\mathcal O}}(k^{f(\epsilon)})$ vertices. We complemented this result by showing that, assuming {\sf Gap-ETH}, no \textsf{FPT}\ time algorithm can approximate {\sc Split Contraction} within a
factor of $\left(\frac{5}{4}-\delta \right)$, for any fixed constant $\delta>0$. Finally, we showed that, assuming \textsf{FPT} $\neq$ {\sf W[1]}, {\sc Chordal Contraction} does not admit any $F(k)$-\textsf{FPT}-approximation algorithm.
Our results add to this growing list of collection of \textsf{FPT}-approximable and \textsf{FPT}-in-approximable problems.
We find it extremely interesting that three closely related problems have different behavior with respect to \textsf{FPT}-approximation. Our paper also shows that further classification of problems using lossy kernels are of interest and could shed new light on even well-studied problems.
The paper naturally leads to the following question: can the gap between upper and lower bounds for \textsc{Split Contraction} brought closer? We conjecture that \textsc{Split Contraction} does admit $\frac{5}{4}$-\textsf{FPT}-approximation algorithm.
\section{Introduction}
\label{sec:intro}
Graph modification problems have been extensively studied since the inception of Parameterized Complexity in the early `90s. The input of a typical graph modification problem consists of a graph $G$ and a positive integer $k$, and the objective is to edit $k$ vertices (or edges) so that the resulting graph belongs to some particular family, $\cal F$, of graphs. These problems are not only mathematically and structurally challenging, but have also led to the discovery of several important techniques in the field of Parameterized Complexity. It would be completely appropriate to say that solutions to these problems played a central role in the growth of the field. In fact, just in the last few years, parameterized algorithms have been developed for several graph editing problems~\cite{caoM14,cao15ICALP,cao2015,cao16SODA,ProperInterval14,IntervalSODA16,fomin2013,
fomin2014,thresholdESA,drangeSTACS14,drangeESA15,splitGraphs}.
The focus of all of these papers and the vast majority of papers on parameterized graph editing problems
has so far been limited to edit operations that delete vertices, delete edges or add edges.
In recent years, a different edit operation has begun to attract significant scientific attention. This operation, which is arguably the most natural edit operation apart from deletions/insertions of vertices/edges, is the one that contracts an edge. Here, given an edge $uv$
that exists in the input graph, we remove the edge from the graph and merge its two endpoints. Edge contraction is a fundamental operation in the theory of graph minors. For some particular family of graphs, $\cal F$, we say that a graph $G$ belongs to ${\cal F}+kv$, ${\cal F}+ke$ or ${\cal F}-ke$ if some graph in ${\cal F}$ can be obtained by deleting at most $k$ vertices from $G$, deleting at most $k$ edges from $G$ or adding at most $k$ edges to $G$, respectively. Using this terminology, we say that a graph $G$ belongs to ${\cal F}|ke$ if some graph in ${\cal F}$ can be obtained by contracting at most $k$ edges in $G$. In this paper, we study the following problem.
\smallskip
\defparproblem{\textsc{$\mathcal{F}$-Contraction}}{A graph $G$ and an integer $k$}{$k$}
{Does $G$ belong to $\mathcal{F}|ke$?}
\smallskip
\noindent
For several families of graphs $\cal F$, early papers by Watanabe et al.~\cite{contractEarly2,contractEarly3}, and Asano and Hirata~\cite{contractEarly1} showed that \textsc{ ${\cal F}$-Edge Contraction} is \textsf{NP}\xspace-complete.
In the framework of Parameterized Complexity, these problems exhibit properties that are quite different from those problems where we only delete or add vertices and edges. Indeed, a well-known result by Cai \cite{cai1996} states that in case $\cal F$ is a hereditary family of graphs with a finite set of forbidden induced subgraphs, then the graph modification problems, ${\cal F}+kv$, ${\cal F}+ke$ or ${\cal F}-ke$, defined by $\cal F$ admits a simple \textsf{FPT}\ algorithm (an algorithm with running time $f(k)n^{\mathcal{O}(1)}$). However, for {\sc ${\cal F}$-Contraction}, the result by Cai \cite{cai1996} does not hold. In particular, Lokshtanov et al.~\cite{elimNew} and Cai and Guo~\cite{CliqueContractUpp} independently showed that if $\cal F$ is either the family of $P_\ell$-free graphs for some $\ell\geq 5$ or the family of $C_\ell$-free graphs for some $\ell\geq 4$, then {\sc ${\cal F}$-Contraction} is \textsf{W[2]-Hard}\ ({\sf W[i]}-{\sf hardness}, for $i\geq 1$, is an analogue to \textsf{NP}\xspace-{\sf hardness} in Parameterized Complexity, and is used to rule out \textsf{FPT}-algorithm for the problem) when parameterized by $k$ (the number of edges to be contracted). These results immediately imply that {\sc Chordal Contraction} is \textsf{W[2]-Hard}\ when parameterized by $k$.
The parameterized hardness result for {\sc Chordal Contraction} led to finding subfamilies of chordal graphs, where the problem could be shown to be \textsf{FPT}. Two subfamilies that have been considered in the literature are families of
{\em split graphs} and {\em cliques}. Cai and Guo~\cite{CliqueContractUpp} showed that {\sc Clique Contraction} is
\textsf{FPT}, however, it does not admit a polynomial kernel. Later, Cai and Guo \cite{SplitContractErr} also claimed to design an algorithm that solves {\sc Split Contraction} in time $2^{\mathcal{O}(k^2)}\cdot n^{\mathcal{O}(1)}$, which proves that the problem is \textsf{FPT}. However, Agrawal et al.~\cite{DBLP:conf/stacs/AgrawalLSZ17} found an error with the proof and showed that {\sc Split Contraction} is \textsf{W[1]-Hard}.
\begin{tcolorbox}[colback=red!5!white,colframe=red!75!black]
Inspired by the intractable results that {\sc Chordal Contraction}, {\sc Split Contraction} and {\sc Clique Contraction} are \textsf{W[2]-Hard}, \textsf{W[1]-Hard}, and does not admit polynomial kernel, respectively, we study them from the viewpoint of parameterized approximation.
\end{tcolorbox}
\vspace{-0.35cm}
\paragraph{Our Results and Methods.} We start by defining a few basic definitions in parameterized approximation. To formally define these, we need a notion of parameterized optimization problems.
We defer formal definitions to Section~\ref{sec:prelim} and give intuitive definitions here.
We say that an algorithm is an $h(k)$-\textsf{FPT}-approximation algorithm for the {\sc $\cal F$-Contraction} problem, if it runs in \textsf{FPT}\ time, and on any input $(G, k)$ if there exists $X \subseteq E(G)$ such that $G/X \in \cal F$ and $|X| \leq k$, it outputs an edge set $Y$ of size at most $h(k)\cdot k$ and $G/Y \in \cal F$. Let $\alpha \geq 1$ be a real number. We now give an informal definition of $\alpha$-approximate kernels. The kernelization algorithm takes an instance $I$ with parameter $k$, runs in polynomial time, and produces a new instance $I'$ with parameter $k'$. Both $k'$ and the size of $I'$ should be bounded in terms of just the parameter $k$. That is, there exists a function $g(k)$ such that $|I'| \leq g(k)$ and $k' \leq g(k)$. This function $g(k)$ is called the {\em size} of the kernel. For minimization problems, we also require the following from $\alpha$-approximate kernels: For every $c \geq 1$, a $c$-approximate solution $S'$ to $I'$ can be transformed in polynomial time into a $(c \cdot \alpha)$-approximate solution $S$ to $I$. However, if the quality of $S'$ is ``worse than'' $k'$, or $(c \cdot \alpha) \cdot OPT(I) > k$, the algorithm that transforms $S'$ into $S$ is allowed to fail. Here, $OPT(I)$ is the value of the optimum solution of the instance $I$.
Our first result is about {\sc Clique Contraction}. It is known to be \textsf{FPT}. However, unless $\textsf{NP}\xspace \subseteq \textsf{coNP/poly}$, it does not admit a polynomial kernel~\cite{CliqueContractUpp}. We show that it admits a {\sf PSAKS}. That is, it admits a $(1 + \epsilon)$-approximate polynomial kernel with $\ensuremath{{\mathcal O}}(k^{f(\epsilon) })$ vertices for every $\epsilon >0$. In particular, we obtain the following result.
\begin{theorem}\label{thm:clique-lossy} For any $\epsilon > 0$, \textsc{Clique Contraction} parameterized by the size of solution $k$, admits a time efficient $(1 + \epsilon)$-approximate polynomial kernel with $\ensuremath{{\mathcal O}}(k^{d+1})$ vertices, where $d = \lceil \frac{1 }{\epsilon} \rceil$.
\end{theorem}
\vspace{-0.65cm}
\paragraph{Overview of the proof of Theorem~\ref{thm:clique-lossy}.}
Let us fix an input $(G,k)$ and a constant $\epsilon > 0$.
Given a graph $G$, contracting edges of $G$ to get into a graph class $\cal F$
is same as partitioning the vertex set $V(G)$ into connected sets, $W_1, W_2, \ldots ,W_\ell$, and then contracting each connected set to a vertex. These connected sets are called {\em witness sets}. A witness set $W_i$ is called {\em non-trivial}, if $|W_i|\geq 2$, and {\em trivial} otherwise.
Observe that if a graph $G$ can be transformed into a clique by contracting edges in $F$, then $G$ can also be converted into a clique by deleting all the endpoints of edges in $F$.
This observation implies that if $G$ is \emph{$k$-contractible} to a clique, then there exists an induced clique of size at least $|V(G)| - 2k$. Let $I$ be a set of vertices in $G$, which induces this large clique and let $C = V(G) \setminus I$. Observe that $C$ forms a vertex cover in the graph $\overline{G}$ (graph with vertex set $V(G)$ and those edges that are not present in $E(G)$). Using a factor $2$-approximation algorithm, we find a vertex cover $X$ of $\overline{G}$. Let $Y=V(\overline{G})-X$ be an independent set in $\overline{G}$.
If $|X|>4k$, we immediately say No. Now, suppose that we have some solution and let
$W_1, W_2, \ldots ,W_{\ell}$ be those witness sets that are either non-trivial or contained in $X$. Now, let us say that a set $W_i$ is {\em nice} if it has at least one vertex outside $X$, and {\em small} if it contains less than
$\mathcal{O}(1/\epsilon)$ vertices. A set that is not {\em small} is {\em large}. {Observe that there exists a
$(1+\epsilon)$-approximate solution where {\em the only sets} that are not nice are small.} Also, observe that
all nice sets are adjacent.
Now, we classify all subsets of $X$ of size at most $\mathcal{O}(1/\epsilon)$ as {\em possible} and {\em impossible} small witness sets. Notice that if a set $A \subseteq X$ has more than $2k$ non-neighbors, then it can not possibly be a witness set, as one of these non-neighbors will be a trivial witness set. Now for every set, $A \subseteq X$ of size at most $\mathcal{O}(1/\epsilon)$ mark all of its non-neighbors, but if there are more than $2k$, then mark $2k+1$ of them. Now, look at an unmarked vertex in $Y$, the only reason it could still be relevant if it is part of some $W_i$. So its job is $(a)$ connecting the vertices in $W_i$, or $(b)$ potentially being the vertex in $Y$ that is
making some $W_i$ nice, or $(c)$ it is a neighbor to {\em all} the small (not nice) subsets of $X$ in the solution.
Now notice that any vertex in $Y$ that is unmarked does jobs $(b)$ and $(c)$ equally well. So we only need to care about connectivity. Look at some nice and small set $W_i$; we only need to preserve the neighborhoods of the vertices of
$Y$ into $W_i$.
For every subset of size $\mathcal{O}(1/\epsilon)$, we keep one vertex in $Y$ that has that set in its neighborhood. Notice that we do not care that different $W_i$'s use different marked vertices for connectivity because merging two $W_i$'s is more profitable for us. Finally, we delete all unmarked vertices and obtain an $(1+\epsilon)$-approximate kernel of size roughly $k^{\mathcal{O}(1/\epsilon)}$.
We argue that this kernelization algorithm is time efficient i.e. the running time is polynomial in the size of an input and the constant in the exponent is independent of $\epsilon$.
This completes the overview of the proof for Theorem~\ref{thm:clique-lossy}.
Next, we move to {\sc Split Contraction}.
{\sc Split Contraction} is known to be \textsf{W[1]-Hard}~\cite{DBLP:conf/stacs/AgrawalLSZ17}. We ask ourselves whether {\sc Split Contraction} is {\em completely \textsf{FPT}-inapproximable} or admits an $\alpha$-\textsf{FPT}-approximation algorithm, for some fixed constant $\alpha>0$.
We obtain two results towards our goal.
\begin{theorem}\label{thm:split-lossy}
For every $\epsilon > 0$, \textsc{Split Contraction} admits a factor $(2+\epsilon)$-\textsf{FPT}-approximation algorithm. In fact, for any $\epsilon > 0$, \textsc{Split Contraction} admits a $(2 + \epsilon)$-approximate kernel with $\ensuremath{{\mathcal O}}(k^{f(\epsilon)})$ vertices.
\end{theorem}
Given, Theorem~\ref{thm:split-lossy}, it is natural to ask whether \textsc{Split Contraction} admits a factor $(1+\epsilon)$-\textsf{FPT}-approximation algorithm, for every $\epsilon > 0$. We show that this is not true and obtain the following hardness result.
\begin{theorem} \label{thm:split-no-lossy}
Assuming {\sf Gap-ETH}, no \textsf{FPT}\ time algorithm can approximate {\sc Split Contraction} within a
factor of $\left(\frac{5}{4}-\delta \right)$, for any fixed constant $\delta>0$.
\end{theorem}
\vspace{-0.65cm}
\paragraph{Overview of the proofs of Theorems~\ref{thm:split-lossy} and~\ref{thm:split-no-lossy}.}
Our proof for Theorem~\ref{thm:split-lossy} uses ideas for $(1+\epsilon)$-approximate kernel for {\sc Clique Contraction} (Theorem~\ref{thm:clique-lossy}) and thus we omit its overview.
Towards the proof of Theorem~\ref{thm:split-no-lossy}, we give a gap preserving reduction from a variant of the {\sc Densest-$k$-Subgraph} problem (given a graph $G$ and an integer $k$, find a subset $S \subseteq V(G)$ of $k$ vertices that induces maximum number of edges).
Chalermsook et al.~\cite{DBLP:conf/focs/ChalermsookCKLM17} showed that, assuming {\sf Gap-ETH}\footnote{We refer the readers to~\cite{DBLP:conf/focs/ChalermsookCKLM17} for the definition of \textsf{Gap-ETH} and related terms.}, for any $g=o(1)$, there is no \textsf{FPT}-time algorithm that, given an integer $k$ and any graph $G$ on $n$ vertices that contains at least one $k$-clique,
always output $S\subseteq V(G)$, of size $k$, such that ${\sf Den}(S)\geq k^{-g(k)}$. Here, ${\sf Den}(S)=|E(G[S])|/{|S|\choose 2}$. We need a strengthening of this result that says that assuming {\sf Gap-ETH}, for any $g=o(1)$ and for any constant $\alpha >1$, there is no \textsf{FPT}-time algorithm that, given an integer $k$ and any graph $G$ on $n$ vertices that contains at least one $k$-clique, always outputs $S\subseteq V(G)$, of size $\alpha k$, such that ${\sf Den}(S)\geq k^{-g(k)}$. Starting from this result, we give a gap-preserving reduction to {\sc Split Contraction} that takes \textsf{FPT}\ time and obtain Theorem~\ref{thm:split-no-lossy}. Given an instance $(G,k)$ of {\sc Densest-$k$-Subgraph}, we first use color coding to partition the edges into $t = \binom{k}{2}$ color classes such that every color class contains exactly one edge of a ``densest subgraph'' (or a clique). For each color class we make one {\em edge selection gadget}. Each edge selection gadget corresponding to the color class $j$ consists of an independent set $\texttt{ES}_j$ that contains a vertex corresponding to each edge in the color class$j,$ and a \emph{cap vertex} $g_j$ that is adjacent to every vertex in $\texttt{ES}_j$.
Next, we add a sufficiently large clique $Z$ of size $\rho \cdot |V(G)|$, where for every vertex $v\in V(G)$, we have $\rho$ vertices. Every vertex in an edge selection gadget is adjacent to every vertex of $Z$, except those corresponding to the endpoints of the edge the vertex represents. Finally, we add a clique $\texttt{SV}$ of size $t$ that has one vertex $s_j$ for each edge selection gadget. Make the vertex $s_j$ adjacent to every vertex in $\texttt{ES}_j$. We also add sufficient guards on vertices everywhere, so that ``unwanted'' contractions do not happen. The idea of the reduction is to contract edges in a way that the vertices in
$\texttt{SV}$, $Z$, and $g_j$, $j\in \{1,\ldots,t\}$, become a giant clique and other vertices become part of an independent set, resulting in a split graph. Towards this we first use $2t$ contractions so that $g_j$, $s_j$, and a vertex $a_j \in \texttt{ES}_j$ are contracted into one.
One way to ensure that they form a clique along with $Z$ is to contract each of them to a vertex in $Z$.
However, this will again require $t$ edge contractions.
We set our budget in a way that this is not possible. Thus, what we need is to destroy the non-neighbors of $a_j$. One way to do this again will be to match the vertices obtained after the first round of $2t$ contractions in a way that there are no non-adjacencies left. However, this will also cost $t/2$, and our budget does not allow this. The other option (which we take) is to take the union of all non-neighbors of $a_j$, say $N$, and contract each of them to one of the vertex in $Z\setminus N$. Observe that to minimize the contractions to get rid of non-neighbors of $a_j$, we would like to minimize $|N|$. This will happen when $N$ spans a large number of edges. Thus, it precisely captures the {\sc Densest-$k$-Subgraph} problem. The budget is chosen in a way that we get the desired gap-preserving reduction, which enables us to prove Theorem~\ref{thm:split-no-lossy}.
Our final result concerns {\sc Chordal Contraction}. Lokshtanov et al.~\cite{elimNew} showed that {\sc Chordal Contraction} is \textsf{W[2]-Hard}. We observe that the existing {\sf W[2]-hardness} reduction can be adapted to show the following theorem.
\begin{theorem} \label{thm:chordal-no-lossy}
Assuming \textsf{FPT} $\neq$ {\sf W[1]}, no \textsf{FPT}\ time algorithm can approximate {\sc Chordal Contraction} within a factor of $F(k)$. Here, $F(k)$ is a function depending on $k$ alone.
\end{theorem}
\vspace{-0.65cm}
\paragraph{Overview of the proof of Theorem~\ref{thm:chordal-no-lossy}.}
Towards proving Theorem~\ref{thm:chordal-no-lossy}, we give a $1$-approximate polynomial parameter transformation (1-appt)
from {\sc Set Cover} (given a universe $U$, a family of subsets $\cal S$, and an integer $k$,
we shall decide the existence of a subfamily of size $k$ that contains all the elements of $U$) to {\sc Chordal Contraction}. That is, given any solution of size at most
$\ell$ for {\sc Chordal Contraction}, we can transform this into a solution for {\sc Set Cover} of size at most $\ell$. Karthik et al.~\cite{DBLP:conf/stoc/SLM18} showed that assuming \textsf{FPT} $\neq$ {\sf W[1]}, no \textsf{FPT}\ time algorithm can approximate {\sc Set Cover} within a factor of $F(k)$. Pipelining this result with our reduction we get Theorem~\ref{thm:chordal-no-lossy}.
\vspace{-0.35cm}
\paragraph{Related Work.}
To the best of our knowledge, Heggernes et al.~\cite{treePathContract} was the first to explicitly study {\sc ${\cal F}$-Contraction} from the viewpoint of Parameterized Complexity. They showed that in case $\cal F$ is the family of trees, {\sc ${\cal F}$-Contraction} is \textsf{FPT}\ but does not admit a polynomial kernel, while in case $\cal F$ is the family of paths, the corresponding problem admits a faster algorithm and an $\mathcal{O}(k)$-vertex kernel. Golovach et al.~\cite{planarContract} proved that if $\cal F$ is the family of planar graphs, then {\sc ${\cal F}$-Contraction} is again \textsf{FPT}. Moreover, Cai and Guo~\cite{CliqueContractUpp} showed that in case $\cal F$ is the family of cliques, {\sc ${\cal F}$-Contraction} is solvable in time $2^{\mathcal{O}(k\log k)}\cdot n^{\mathcal{O}(1)}$, while in case $\cal F$ is the family of chordal graphs, the problem is \textsf{W[2]-Hard}.
Heggernes et al.~\cite{bipartiteContract} developed an \textsf{FPT}\ algorithm for the case where $\cal F$ is the family of bipartite graphs. Later, a faster algorithm was proposed by Guillemot and Marx~\cite{bipartiteContract2}.
Pioneering work of Lokshtanov et al.~\cite{lossy} on the approximate kernel is being followed by a series of papers generalizing/improving results mentioned in this work and establishing lossy kernels for various other problems.
Lossy kernels for some variations of \textsc{Connected Vertex Cover}~\cite{eiben2017lossy,krithika2018revisiting}, {\sc Connected Feedback Vertex Set}~\cite{DBLP:conf/esa/Ramanujan19}, \textsc{Steiner Tree}~\cite{dvorak2018parameterized} and \textsc{Dominating Set}~\cite{eiben2018lossy, siebertz2017lossy} have been established (also see~\cite{manurangsi2018note, van20181+}).
Krithika et al.~\cite{lossy-fst} were first to study graph contraction problems from the lenses of lossy kernelization. They proved that for any $\alpha > 1$, \textsc{Tree Contraction} admits an $\alpha$-lossy kernel with $\mathcal{O}(k^d)$ vertices, where $d = \lceil \alpha/(\alpha - 1) \rceil$. Agarwal et al.~\cite{agarwal2017parameterized} proved similar result for \textsc{$\mathcal{F}$-Contraction} problems where graph class $\mathcal{F}$ is defined in parametric way from set of trees. Eiben et al.~\cite{eiben2017lossy} obtained similar result for {\sc Connected $\cal H$-Hitting Set} problem.
\vspace{-0.35cm}
\paragraph{Guide to the paper.} We start by giving the notations and preliminaries that we use throughout the paper in Section~\ref{sec:prelim}. This section is best used as a reference, rather than being read linearly.
In Section~\ref{sec:lossy_clique} we give the $(1+\epsilon)$--approximate polynomial kernel for \textsc{Clique Contraction}. Section~\ref{sec:lossy_split} gives the $(2+\epsilon)$--approximate polynomial kernel for \textsc{Split Contraction}. The ideas here are similar to those used in Section~\ref{sec:lossy_clique}, and thus an eager reader could skip further.
In Section~\ref{hardness_splt}, we show that assuming {\sf Gap-ETH}, no \textsf{FPT}\ time algorithm can approximate {\sc Split Contraction} within a
factor of $\left(\frac{5}{4}-\delta \right)$, for any fixed constant $\delta>0$. Section~\ref{hardness_chordal} shows that,
assuming \textsf{FPT} $\neq$ {\sf W[1]}, no \textsf{FPT}\ time algorithm can approximate {\sc Chordal Contraction} within a factor of $F(k)$. This is an adaptation of the existing {\sf W[2]-hardness} reduction and may be skipped. Thus, our main technical results appear in Sections~\ref{sec:lossy_clique} and \ref{hardness_splt}. We conclude the paper with some interesting open problems in Section~\ref{section_conclusion}.
\section{Lossy Kernel for \textsc{Clique Contraction}}
\label{sec:lossy_clique}
In this section, we present a lossy kernel for \textsc{Clique Contraction}. We first define a natural optimization version of the problem.
$$\textsc{ClC}(G, k, F) = \left\{ \begin{array}{rl} \min\{|F|, k + 1\} &\mbox{\text{ if } $G/F$ \text{ is a clique }} \\ \infty &\mbox{ otherwise} \end{array} \right.$$
If the number of vertices in the input graph is at most $k+3$, then we can return the same instance as a kernel for the given problem. Further, we assume that the input graph is connected; otherwise, it can not be edited into a clique by edge contraction only.
Thus, we only consider {\em connected graphs with at least $k + 3$ vertices}. By the definition of optimization problem, for any set of edges $F$, if $G/F$ is a clique, then the maximum value of $\textsc{ClC}(G, k, F)$ is $k + 1$. Hence, any spanning tree of $G$ is a solution of cost $k + 1$. We call it a \emph{trivial solution} for the given instance. Consider an instance $(P_4, 1)$, where $P_4$ is a path on four vertices. One needs to contract at least two edges to convert $P_4$ into a clique. We call $(P_{4}, 1)$ a \emph{trivial \textsc{No}-instance} for this problem. Finally, we assume that we are given an $\epsilon>0$.
We start with a reduction rule, which says that if the minimum number of vertices that need to be deleted from an input graph to obtain a clique is large, then we can return a trivial instance as a lossy kernel.
\begin{reduction rule}
\label{rr:large-cvd}
For a given instance $(G, k)$, apply the algorithm mentioned in Observation~\ref{obs:factor-2-approx} to find a set $X$ such that $G - X$ is a clique. If the size of $X$ is greater than $4k$, then return $(P_4, 1)$.
\end{reduction rule}
\begin{lemma} \label{lemma:rr-large-cvd-safe}
Reduction Rule~\ref{rr:large-cvd} is a $1$-reduction rule.
\end{lemma}
\begin{proof} Let $(G, k)$ be an instance of \textsc{Clique Contraction} such that the Reduction Rule~\ref{rr:large-cvd} returns $(P_4, 1)$ when applied on it. The solution lifting algorithm returns a spanning tree $F$ of $G$. Note that for a set of edges $F'$, if $P_4/F'$ is a clique then $F'$ contains at least two edges. This implies $\textsc{ClC}(P_4, 1, F') = 2$ and $\textsc{OPT}(P_4, 1) = 2$.
Since a factor $2$-approximation algorithm returned a set of size strictly more than $4k$, for any set $X'$ of size at most $2k$, $G - X'$ is not a clique. But by Observation~\ref{obs:vertex-solution}, if $G$ is $k$-contractible to a clique then $G$ can be edited into a clique by deleting at most $2k$ vertices. Hence, for any set of edges $F^*$ if $G/F^*$ is a clique, then the size of $F^*$ is at least $k + 1$. This implies that $\textsc{OPT}(G, k) = k + 1$, and for a spanning tree $F$ of $G$, $\textsc{ClC}(G, k, F) = k + 1$.
Combining these values, we get $\frac{\textsc{ClC}(G, k, F)}{\textsc{OPT}(G, k)} = \frac{k + 1}{k + 1} = \frac{2}{2} = \frac{\textsc{ClC}(P_4, 1, F')}{\textsc{OPT}(P_4, 1)}$. This implies that if $F'$ is factor $c$-approximate solution for $(P_4, 1)$, then $F$ is factor $c$-approximate solution for $(G,k)$. This concludes the proof.
\end{proof}
We now consider an instance $(G, k)$ for which Reduction Rule~\ref{rr:large-cvd} does not return a trivial instance. This implies that for a given graph $G$, in polynomial time, one can find a partition $(X, Y)$ of $V(G)$ such that $G - X = G[Y]$ is a clique and $|X|$ is at most $4k$. For $\epsilon > 0$, find a smallest integer $d$, such that $\frac{d + 1}{d} \le 1 + \epsilon$. In other words, fix $d = \lceil \frac{1}{\epsilon} \rceil$.
We note that if the number of vertices in the graph is at most $\ensuremath{{\mathcal O}}(k^{d + 1})$, then the algorithm returns this graph as a lossy kernel of the desired size. Hence, without loss of generality, we assume that the number of vertices in the graph is larger than $\ensuremath{{\mathcal O}}(k^{d + 1})$.
Given an instance $(G, k)$, a partition $(X, Y)$ of $V(G)$ with $G[Y]$ being a clique, and an integer $d$, consider the following two marking schemes.
\begin{marking-scheme}
\label{marking:nbrs}
For a subset $A$ of $X$, let $M_1(A)$ be the set of vertices in $Y$ whose neighborhood contains $A$. For every subset $A$ of $X$ which is of size at most $d$, mark a vertex in $M_1(A)$.
\end{marking-scheme}
\noindent Formally, $M_1(A) = \{y \in Y | A \subseteq N(y)\}$. If $M_1(A)$ is an empty set, then the marking scheme does not mark any vertex. If it is non-empty, then the marking scheme arbitrarily chooses a vertex and marks it.
\begin{marking-scheme}
\label{marking:non-nbrs}
For a subset $A$ of $X$, let $M_2(A)$ be the set of vertices in $Y$ whose neighborhood does not intersect $A$. For every subset $A$ of $X$ which is of size at most $d$, mark $2k + 1$ vertices in $M_2(A)$.
\end{marking-scheme}
\noindent Formally, $M_2(A) = \{ y \in Y | N(y) \cap A = \emptyset \}$. If the number of vertices in $M_2(A)$ is at most $2k + 1$, then the marking scheme marks all vertices in $M_2(A)$. If it is larger than $2k + 1$, then it arbitrarily chooses $2k + 1$ vertices and marks them.
\begin{reduction rule}
\label{rr:delete-marked} For a given instance $(G, k)$, partition $(X, Y)$ of $V(G)$ with $G[Y]$ being a clique, and an integer $d$, apply the Marking Schemes~\ref{marking:nbrs} and \ref{marking:non-nbrs}. Let $G'$ be the graph obtained from $G$ by deleting all the unmarked vertices in $Y$. Return the instance $(G', k)$.
\end{reduction rule}
Above reduction rule can be applied in time $|X|^{d} \cdot |V(G)|^{\ensuremath{{\mathcal O}}(1)} = \mathcal{O}(k^{\mathcal{O}(d)}|V(G)|^{\ensuremath{{\mathcal O}}(1)})$ as $|X|$ is at most $4k$.
Note that $G'$ is an induced subgraph of $G$. We first show that since $G$ is a connected graph, $G'$ is also connected.
In the following lemma, we prove a stronger statement.
\begin{lemma} \label{lemma:connected-clique}
Consider instance $(G, k)$ of \textsc{Clique Contraction}.
Let $Y'$ be the set of vertices marked by Marking Scheme~\ref{marking:nbrs} or \ref{marking:non-nbrs} for some positive integer $d$.
For any subset $Y''$ of $Y \setminus Y'$, let $G''$ be the graph obtained from $G$ by deleting $Y''$.
Then, $G''$ is connected.
\end{lemma}
\begin{proof}
Recall that, by our assumption, $G$ is connected and $Y$ is a clique in $G$.
Hence, for every vertex in $X$, there exists a path from it to some vertex in $Y$.
By the construction of $G''$, $(X, Y\setminus Y'')$ forms a partition of $V(G'')$ and $Y \setminus Y''$ is a clique in $G''$.
To prove that $G''$ is connected, it is sufficient to prove that for every vertex in $X$, there exists a path from it to a vertex in $Y \setminus Y''$ in $G$.
Fix an arbitrary vertex, say $x$, in $X$.
Consider a path $P$ from $x$ to $y$ in $G$, where $y$ is some vertex in $Y$.
Without loss of generality, we can assume that $y$ is the only vertex in $V(P) \cap Y$.
We argue that there exists another path, say $P_1$, from $x$ to a vertex in $Y \setminus Y''$.
If $y$ is in $Y \setminus Y''$ then $P_1 = P$ is a desired path.
Consider the case when $y$ is in $Y''$.
Let $x_0$ be the vertex in $V(P)$ which is adjacent with $y$.
Note that $x_0$ may be same as $x$.
As Marking Scheme~\ref{marking:nbrs} considers all subsets of size at most $d$, it considered singleton set $\{x_0\}$.
As $x_0$ is adjacent with $y$, we have $\{x_0\} \subseteq N(y)$.
Since $y$ is in $Y''$, and hence unmarked, there exists a vertex, say $y_1$, in $Y$ which has been marked by Marking Scheme~\ref{marking:nbrs}.
Consider a path $P_1$ obtained from $P$ by deleting vertex $y$ (and hence edge $x_0y$) and adding vertex $y_1$ with edge $x_0y_1$.
This is a desired path from $x$ to a vertex in $Y \setminus Y''$.
As $x$ is an arbitrary vertex in $X$, this statement is true for any vertex in $X$ and
hence $G''$ is connected.
\end{proof}
\begin{figure}[t]
\centering
\includegraphics[scale=0.60]{./images/solution-lifting.pdf}
\caption{Straight lines (e.g within $W(t)$) represent edges in original solution $F$. Dashed lines (e.g. across $W(t)$ and $W(t')$) represents extra edges added to solution $F$. Please refer to the proof of Lemma~\ref{lemma:solution-lifting}. \label{fig:solution-lifting}}
\end{figure}
Thus, because of Lemma~\ref{lemma:connected-clique}, from now onwards, we assume that $G'$ is connected.
In fact, in our one of the proof, we will iteratively remove vertices from $Y\setminus Y'$, and Lemma~\ref{lemma:connected-clique} ensures that the graph at each step remains connected. In the following lemma, we argue that given a solution for $(G', k)$, we can construct a solution of almost the same size for $(G, k)$.
\begin{lemma} \label{lemma:solution-lifting} Let $(G', k)$ be the instance returned by Reduction Rule~\ref{rr:delete-marked} when applied on an instance $(G, k)$. If there exists a set of edges of size at most $k$, say $F'$, such that $G'/F'$ is a clique, then there exists a set of edges $F$ such that $G/F$ is a clique and cardinality of $F$ is at most $(1 + \epsilon) \cdot |F'|$.
\end{lemma}
\begin{proof} If no vertex in $Y$ is deleted, then $G'$ and $G$ are identical graphs, and the statement is true. We assume that at least one vertex in $Y$ is deleted. Let $Y'$ be the set of vertices in $Y$, which are marked. Note that the sets $X, Y'$ forms a partition of $V(G')$ such that $Y'$ is a clique and a proper subset of $Y$. Let $\mathcal{W}'$ be a $G'/F'$-witness structure of $G'$. We construct a clique witness structure $\mathcal{W}$ of $G$ from $\mathcal{W}'$ by adding singleton witness sets $\{y\}$ for every vertex $y$ in $Y \setminus Y'$. Since $G[Y \setminus Y']$ is a clique in $G$, any two newly added witness sets are adjacent to each other. Moreover, any witness set in $\mathcal{W}'$, which intersects $Y'$ is also adjacent to the newly added witness sets. We now consider witness sets in $\mathcal{W}'$, which do not intersect $Y'$.
Let $\mathcal{W}^\star$ be a collection of witness sets $W(t)$ in $\mathcal{W}'$ such that $W(t)$ is contained in $X$ and there exists a vertex $y$ in $Y \setminus Y'$ whose neighborhood does not intersect with $W(t)$. See Figure~\ref{fig:solution-lifting}. We argue that every witness set in $\mathcal{W}^\star$ has at least $d + 1$ vertices. For the sake of contradiction, assume that there exists a witness set $W(t)$ in $\mathcal{W}^\star$ which contains at most $d$ vertices. Since Marking Scheme~\ref{marking:non-nbrs} iterated over all the subsets of $X$ of size at most $d$, it also considered $W(t)$ while marking. Note that the vertex $y$ belongs to the set $M_2(W(t))$. Since $y$ is unmarked, there are $2k + 1$ vertices in $M_2(W(t))$ which have been marked. All these marked vertices are in $G'$. Since the cardinality of $F'$ is at most $k$, the number of vertices in $V(F')$ is at most $2k$. Hence, at least one marked vertex in $M_2(W(t))$ is a singleton witness set in $\mathcal{W}'$. However, there is no edge between this singleton witness set and $W(t)$. This non-existence of an edge contradicts the fact that any two witness sets in $\mathcal{W}'$ are adjacent to each other in $G'$. Hence, our assumption is wrong, and $W(t)$ has at least $d + 1$ vertices.
Next, we show that there exists a witness set in $\mathcal{W}'$ that intersects $Y'$. This is ensured by the fact that $G'$ is connected, and we are in the case where at least one vertex in $Y$ is deleted. The last assertion implies that $Y'$ is non-empty, and hence there must be a witness set in $\mathcal{W}'$ that intersects $Y'$.
Let $W(t')$ be a witness set in $\mathcal{W}'$ that intersects $Y'$.
Note that $W(t')$ is adjacent to every vertex in $Y\setminus Y'$. Let $W(t)$ be a witness set in $\mathcal{W}^\star$. Since $W(t')$ and $W(t)$ are two witness sets in the $G'/F'$-witness structure, there exists an edge with one endpoint in $W(t')$ and another in $W(t)$. Therefore, the set $W(t') \cup W(t)$ is adjacent to every other witness set in $\mathcal{W}$.
We now describe how to obtain $F$ from $F'$. We initialize $F = F'$. For every witness set $W(t)$ in $\mathcal{W}^\star$ add an edge between $W(t)$ and $W(t')$ to the set $F'$. Equivalently, we construct a new witness set by taking the union of $W(t')$ and all witness sets $W(t)$ in $\mathcal{W}^\star$. This witness set is adjacent to every vertex in $Y \setminus Y'$, and hence $G/F$ is a clique. We now argue the size bound on $F$. Note that we have added one extra edge for every witness set $W(t)$ in $\mathcal{W}^\star$. We also know that every such witness set has at least $d + 1$ vertices. Hence, we have added one extra edge for at least $d$ edges in the solution $F'$. Moreover, since witness sets in $\mathcal{W}^\star$ are vertex disjoint, no edge in $F$ can be part of two witness sets. This implies that the number of edges in $F'$ is at most $(\nicefrac{d + 1}{d})|F| \le (1 + \epsilon) \cdot |F|$.
\end{proof}
In the following lemma, we argue that the value of the optimum solution for the reduced instance can be upper bounded by the value of an optimum solution for the original instance.
\begin{lemma}\label{lemma:reduction-rule} Let $(G', k)$ be the instance returned by Reduction Rule~\ref{rr:delete-marked} when applied on an instance $(G, k)$. If $\textsc{OPT}(G, k) \le k$, then $\textsc{OPT}(G', k) \le \textsc{OPT}(G, k)$.
\end{lemma}
\begin{proof} Let $F$ be a set of at most $k$ edges in $G$ such that $\textsc{OPT}(G, k) = \textsc{ClC}(G, k, F)$ and $\mathcal{W}$ be a $G/F$-witness structure of $G$. Since we are working with a minimization problem, to prove this lemma it is sufficient to find a solution for $G'$ which is of size $|F|$.
Recall that $(X, Y)$ is a partition of $V(G)$ such that $G - X = G[Y]$ is a clique.
Let $Y'$ be the set of vertices that were marked by either of the marking schemes. In other words, $(X, Y')$ is a partition of $G'$ such that $G' - X = G'[Y]$ is a clique.
We proceed as follows. At each step, we construct graph $G^\star$ from $G$ by deleting one or more vertices of $Y \setminus Y'$. Simultaneously, we also construct a set of edges $F^\star$ from $F$ by either replacing the existing edges by new ones or by simply adding extra edges to $F$. At any intermediate state, we ensure that $G^\star/F^\star$ is a clique, and the number of edges in $F^\star$ is at most $|F|$. Let $F^{\circ} = F$ be an optimum solution for the input instance $(G, k)$. {\em For notational convenience, we rename $G^\star$ to $G$ and $F^\star$ to $F$ at regular intervals but do not change $F^{\circ}$. }
To obtain $G^\star$ and $F^\star$, we delete witness sets which are subsets of $Y \setminus Y'$ (Condition~~\ref{cond:witness-subset-YY}) and modify the ones which intersect with $Y \setminus Y'$. Every witness set of latter type intersects with $Y'$ or $X$ or both. We partition these non-trivial witness sets in $\mathcal{W}$ into two groups depending on whether the intersection with $X$ is empty (Condition~\ref{cond:witness-does-not-intersectsX}) or not (Condition~\ref{cond:witness-intersectsX}). We first modify the witness sets that satisfy the least indexed condition. If there does not exist a witness set which satisfies either of these three conditions, then $Y \setminus Y'$ is an empty set, and the lemma is vacuously true.
\begin{condition1}\label{cond:witness-subset-YY}
There exists a witness set $W(t)$ in $\mathcal{W}$ which is a subset of $Y \setminus Y'$.
\end{condition1}
Construct $G^\star$ from $G$ by deleting the witness sets $W(t)$ in $\mathcal{W}$. Let $F^\star$ be obtained from $F$ by deleting those edges whose both the endpoints are in $W(t)$. Since the class of cliques is closed under vertex deletion, $G^\star/F^\star$ is a clique, and as we only deleted edges from $F$, we have $|F^*|\leq |F|$. We repeat this process until there exists a witness set that satisfies Condition~\ref{cond:witness-subset-YY}.
\smallskip
\begin{tcolorbox}[colback=red!5!white,colframe=red!75!black]
\centerline {At this stage we rename $G^\star$ to $G$ and $F^\star$ to $F$.}
\end{tcolorbox}
\begin{condition1}\label{cond:witness-does-not-intersectsX}
There exists a witness set $W(t)$ in $\mathcal{W}$ which contains vertices from $Y \setminus Y'$ but does not intersect $X$.
\end{condition1}
Since $W(t)$ is not contained in $Y\setminus Y'$ and $W(t)\cap X$ is empty it must intersect with $Y'$. See Figure~\ref{fig:reduction-rule}. Let $y_4$ and $y_5$ be vertices in $W(t) \cap Y'$ and $W(t) \cap (Y \setminus Y')$, respectively. Let $W(t_1)$, different from $W(t)$, be a witness set which intersects $Y'$. Since $Y'$ is large and non-empty, such a witness set exists.
Let $y_6$ be a vertex in the set $W(t_1) \cap Y'$. Consider the witness sets $W(t), W(t_1)$ and vertex $y_5$ in $W(t)$ in graph $G$. Lemma~\ref{lemma:connected-clique} implies that these witness sets satisfy the premise of Observation~\ref{obs:merging-witness-sets}. This implies $\mathcal{W}^\star$ is a clique witness structure of $G - \{y_5\}$, where $\mathcal{W}^\star$ is obtained from $\mathcal{W}$ by removing $W(t), W(t_1)$ and adding $(W(t) \cup W(t_1)) \setminus \{y_5\}$. This corresponds to replacing an edge in $F$ which was incident to $y_5$ with the one across $W(t)$ and $W(t_1)$. For example, in Figure~\ref{fig:reduction-rule}, we replace edge $y_4y_5$ in the set $F$ with an edge $y_4y_6$ to obtain a solution for $G - \{y_5\}$. An edge in $F$ has been replaced with another edge and one vertex in $Y \setminus Y'$ is deleted. The size of $F^\star$ is same as that of $F$ and $G^\star/F^\star$ is a clique. We repeat this process until there exist a witness set which satisfies Condition~\ref{cond:witness-does-not-intersectsX}.
\begin{tcolorbox}[colback=red!5!white,colframe=red!75!black]
\centerline {At this stage we rename $G^\star$ to $G$ and $F^\star$ to $F$.}
\end{tcolorbox}
\begin{figure}[t]
\centering
\includegraphics[scale=0.60]{./images/reduction-rule-clique-simple.pdf}
\caption{Straight lines (e.g. $y_4y_5$) represent edges in original solution $F$. Dotted lines (e.g. $y_4y_6)$ represents edges which are replaced for some edges in $F$.
Please refer to the proof of Lemma~\ref{lemma:reduction-rule}. \label{fig:reduction-rule}}
\end{figure}
\begin{condition1}\label{cond:witness-intersectsX} There exists a witness set $W(t)$ in $\mathcal{W}$ which contains vertices from $Y \setminus Y'$ and intersects $X$.
\end{condition1}
Let $y$ be a vertex in $W(t) \cap (Y \setminus Y')$, $X_t$ be the set of vertices in $W(t) \cap X$ which are adjacent to $y$ via edges in $F$, and $Q_t$ be the set of vertices in $W(t)\cap Y$ which are adjacent to $y$ via edges in $F$.
We find a \emph{substitute} for $y$ in $Y'$.
If the set $X_t$ is empty then the vertex $y$ is adjacent only with the vertices of $Y$, in this case the edges incident to $y$ can be replaced as mentioned in the Condition~\ref{cond:witness-does-not-intersectsX}.
Assume that $X_t$ is non-empty.
For every vertex $x$ in $X_t$ the set $\{x\}$ is considered by Marking Scheme ~\ref{marking:nbrs}.
Since $y$ is adjacent to every vertex $x$ in $X_t$, the set $M_1(\{x\})$ is non-empty.
As $y$ is in $Y\setminus Y'$, and hence unmarked, for every $x$ in $X_t$, there is a vertex in $M_1(\{x\})$, say $y_x$, different from $y$ which has been marked.
We construct $F^\star$ from $F$ by the following operation: For every vertex $x$ in $X_t$, replace the edge $xy$ in $F$ by $xy_x$.
Fix a vertex $x_o$ in $X_t$, and for every vertex $u$ in $Q_t$, replace the edge $uy$ in $F$ with $uy_{x_o}$.
Since we are replacing a set of edges in $F$ with another set of edges of same size we have $|F^\star|\leq |F|$.
(For example, in Figure~\ref{fig:reduction-rule}, $X_t = W_1$ and $Q_t = \{y_7\}$.
Edges $yx_1, yy_7$ are replaced by $x_1y_1, y_1y_7$ resp.)
We argue that if $G^\star$ is obtained from $G$ by removing $y$, then $G^\star/F^\star$ is a clique.
We argue that contracting edges in $F^{\star}$ partitions $W(t)$ into $|X_t| + |Q_t|$ many parts and merges each part with some witness set in $\mathcal{W} \setminus \{W(t)\}$.
Recall that $F$ contains a spanning tree of graph $G[W(t)]$.
Let $T$ be a spanning tree of $G[W(t)]$ such that $E(T) \subseteq F$ and $T$ contains all edges in $F$ that are incident on $y$.
It is easy to see that such a spanning tree exists.
Let $y$ be the root of tree $T$.
For every $z$ in $X_t \cup Q_t$, let $W'(z)$ be the set of vertices in the subtree of $T$ rooted at $z$.
As $V(T) = W(t)$, set $\{W'(z) |\ z \in X_t \cup Q_t \}$ is a partition of $W(t) \setminus \{y\}$.
For every $x$ in $X_t$, let $W(y_x)$ be the witness set in $\mathcal{W}$ containing the vertex $y_x$.
For every $x$ in $X_t \setminus \{x_o\}$, let $W^\star(y_x)$ be the set $ W(y_x) \cup W'(x)$.
Let $W^\star(y_{x_o})$ be the set $W(y_{x_o}) \cup W'(x_o) \cup \bigcup_{y'} W'(y')$ for all $y'$ in $Q_t$.
We obtain $\mathcal{W}^\star$ from $\mathcal{W}$ by removing $W(t)$ and $W(y_x)$ for every $x$ in $X_t$, and adding the sets $W^\star(y_x)$ for every $x$ in $X_t$.
Since $W^\star(y_x)$ contains the set $W(y_x)$ which was adjacent to every witness set in $\mathcal{W}$, $W^\star(y_x)$ will be adjacent with every witness set in $\mathcal{W}^\star$.
We repeat this process until there exists a witness set that satisfies this condition.
Any vertex in $Y \setminus Y'$ must be a part of some witness set in $\mathcal{W}$, and any witness set in $\mathcal{W}$ satisfies at least one of the above conditions. If there are no witness sets that satisfy these conditions, then $Y \setminus Y'$ is empty.
This implies $G^\star = G'$ and there exists a solution $F^\star$ of size at most $ |F^{\circ}|$. This concludes the proof of the lemma.
\end{proof}
We are now in a position to prove the following lemma.
\begin{lemma} \label{lemma:rr-delete-marked-safe}
Reduction Rule~\ref{rr:delete-marked}, along with a solution lifting algorithm, is an $(1 + \epsilon)$-reduction rule.
\end{lemma}
\begin{proof} Let $(G', k)$ be the instance returned by Reduction Rule~\ref{rr:delete-marked} when applied on an instance $(G, k)$. We present a solution lifting algorithm as follows. For a solution $F'$ for $(G, k)$ if $\textsc{ClC}(G', k, F') = k + 1$, then the solution lifting algorithm returns a spanning tree $F$ of $G$ (a trivial solution) as solution for $(G, k)$. In this case, $\textsc{ClC}(G, k, F) = \textsc{ClC}(G', k, F')$. If $\textsc{ClC}(G', k, F') \le k$, then size of $F'$ is at most $k$ and $G'/F'$ is a clique. Solution lifting algorithm uses Lemma~\ref{lemma:solution-lifting} to construct a solution $F$ for $(G, k)$ such that cardinality of $F$ is at most $(1 + \epsilon) \cdot |F'|$. In this case, $\textsc{ClC}(G, k, F) \le (1 + \epsilon) \cdot \textsc{ClC}(G', k, F')$. Hence, there exists a solution lifting algorithm which given a solution $F'$ for $(G', k')$ returns a solution $F$ for $(G, k)$ such that $\textsc{ClC}(G, k, F) \le (1 + \epsilon) \cdot \textsc{ClC}(G', k, F')$.
If $\textsc{OPT}(G, k) \le k$, then by Lemma~\ref{lemma:reduction-rule}, $\textsc{OPT}(G', k) \le \textsc{OPT}(G, k)$. If $\textsc{OPT}(G, k) = k + 1$ then $\textsc{OPT}(G', k) \le k + 1 = \textsc{OPT}(G, k)$. Hence in either case, $\textsc{OPT}(G', k) \le \textsc{OPT}(G, k)$.
Combining the two inequalities, we get $\frac{\textsc{ClC}(G, k, F)}{ \textsc{OPT}(G, k)} \le \frac{(1 + \epsilon) \cdot \textsc{ClC}(G', k, F')}{\textsc{OPT}(G', k)}$. This implies that if $F'$ is a factor $c$-approximate solution for $(G', k)$ then $F$ is a factor $(c \cdot (1 + \epsilon))$-approximate solution for $(G,k)$. This concludes the proof.
\end{proof}
We are now in a position to present the main result of this section.
\begin{reptheorem}{thm:clique-lossy}
For any $\epsilon > 0$, \textsc{Clique Contraction} parameterized by the size of solution $k$, admits a time efficient $(1 + \epsilon)$-approximate polynomial kernel with $\ensuremath{{\mathcal O}}(k^{d + 1})$ vertices, where $d = \lceil\frac{1 }{\epsilon}\rceil$.
\end{reptheorem}
\begin{proof} For a given instance $(G, k)$ with $|V(G)|\geq k+3$, a kernelization algorithm applies the Reduction Rule~\ref{rr:large-cvd}. If it returns a trivial instance, then the statement is vacuously true. If it does not return a trivial instance, then the algorithm partitions $V(G)$ into two sets $(X, Y)$ such that $G - X = G[Y]$ is a clique and size of $X$ is at most $4k$. Then the algorithm applies the Reduction Rule~\ref{rr:delete-marked} on the instance $(G, k)$ with the partition $(X, Y)$ and the integer $d = \lceil \frac{1 }{\epsilon} \rceil$. The algorithm returns the reduced instance as $(1 + \epsilon)$-lossy kernel for $(G, k)$.
The correctness of the algorithm follows from Lemma~\ref{lemma:rr-large-cvd-safe} and Lemma~\ref{lemma:rr-delete-marked-safe} combined with the fact that Reduction Rule~\ref{rr:delete-marked} is applied at most once. By Observation~\ref{obs:factor-2-approx}, Reduction Rule~\ref{rr:large-cvd} can be applied in polynomial time. The size of the instance returned by Reduction Rule~\ref{rr:delete-marked} is at most $\ensuremath{{\mathcal O}}((4k)^d \cdot (2k + 1) + 4k) = \ensuremath{{\mathcal O}}(k^{d+1})$. Reduction Rule~\ref{rr:delete-marked} can be applied in time $n^{\ensuremath{{\mathcal O}}(1)}$ if the number of vertices in $(G, k)$ is more than $\ensuremath{{\mathcal O}}(k^{d+1})$.
\end{proof}
\section{Lossy Kernel for Split Contraction}
\label{sec:lossy_split}
In this section, we present a lossy kernel for \textsc{Split Contraction}. We start by defining a
natural optimization version of the problem.
$$\textsc{SpC}(G, k, F) = \left\{ \begin{array}{rl}
\min\{|F|, k + 1\} & \mbox{\text{ if } $G/F$ \text{ is a split graph}} \\
\infty & \mbox{ otherwise.} \end{array} \right.$$
We assume that the input graph is {\em connected and justify this assumption at the end}. If the number of vertices in the input graph is at most $k+3$, then we return the same instance as a kernel for the given problem. Thus we only consider inputs that have at least $k + 3$ vertices. By the definition of optimization problem, for any set of edges $F$ if $G/F$ is a split graph then the maximum value of $\textsc{SpC}(G, k, F)$ is $k + 1$. Hence, any spanning tree of $G$ is a solution of cost $k + 1$. We call it a \emph{trivial solution} for the given instance. Consider an instance $(C_5, 1)$ where $C_5$ is a cycle on five vertices. One needs to contract at least two edges to convert $C_5$ into a split graph. We say $(C_{5}, 1)$ a \emph{trivial no instance} for \textsc{Split Contraction}.
We start with a reduction rule, which says that if the minimum number of vertices that need to be deleted from an input graph to obtain a split graph is large, then we can return a trivial instance as a lossy kernel.
\begin{reduction rule}
\label{rr:large-splitvd}
Given an instance $(G, k)$, apply the algorithm mentioned in Observation~\ref{obsn:approx-svd-solution} to find a set $S$ such that $G-S$ is a split graph. If $|S|>10k$ then return $(C_5,1)$.
\end{reduction rule}
\begin{lemma} \label{lemma:rr-large-splitvd-safe}
Reduction Rule~\ref{rr:large-splitvd} is a $1$-reduction rule.
\end{lemma}
\begin{proof} Let $(G,k)$ be an instance such that Reduction Rule \ref{rr:large-splitvd} returns $(C_5,1)$ when applied on it. Solution lifting algorithm returns a spanning tree $F$ of $G$.
For a set of edges $F'$, if $C_5/F'$ is a split graph then $F'$ contains at least two edges. This implies $\textsc{OPT}(C_5,1)=2$.
Since a factor $5$-approximate algorithm returns a set of size strictly more than $10k$, for any $S'$ of size at most $2k$, $G-S'$ is not a split graph. But by Observation \ref{obsn-splitvd-solution} if $G$ is $k$-contractible to a split graph then $G$ can be converted into a split graph by deleting at most $2k$ vertices. Hence, for any set of edges $F^\star$, if $G/F^\star$ is a split graph, then the size of $F^\star$ is at least $k+1$. This implies that $\textsc{OPT}(G,k)=k+1$.
Combining these values, we get $\frac{\textsc{SpC}(G, k, F)}{\textsc{OPT}(G, k)} = \frac{k + 1}{k + 1} = \frac{2}{2} = \frac{\textsc{SpC}(C_5, 1, F')}{\textsc{OPT}(C_5, 1)}$. This implies that if $F'$ is a factor $c$-approximate solution for $(C_5, 1)$, then $F$ is a factor $c$-approximate solution for $(G,k)$. This concludes the proof.
\end{proof}
We consider an instance $(G, k)$ for which Reduction Rule~\ref{rr:large-splitvd} does not return a trivial instance.
This implies that for a given graph $G$, in polynomial time, one can find a partition $(S, X, Y)$ of $V(G)$ such that $|S|$ is at most $10k$ and $G - S$ is a split graph with $(X, Y)$ as its split partition.
Recall that, our objective is to present a $(2 + \epsilon)$-approximate polynomial kernel for given $\epsilon > 0$.
Fix $\alpha = (2 + \epsilon)/2$.
Find a smallest integer $d$ such that $\frac{d + 1}{d} \le \alpha$. In other words, fix $d = \lceil \frac{1 }{\alpha -1 } \rceil$.
If the number of vertices in the graph is at most $\ensuremath{{\mathcal O}}(k^{d^2 + d + 1})$, then the algorithm returns the original graph as a lossy kernel of the desired size. Hence, without loss of generality, we assume that the number of vertices is larger than $\ensuremath{{\mathcal O}}(k^{d^2 + d + 1})$.
Given an instance $(G,k)$, a partition $(S, X, Y)$ of $V(G)$, and an integer $d$, we marks some vertices in $Y$ using the following two marking schemes.
\begin{marking-scheme}\label{mrk-nbrs-in-I} For a subset $A$ of $S$, let $M_{NY}(A)$ be the set of neighbors of $A$ in $Y$. For every subset $A$ of $S$ whose size is at most $d$, mark $k+2$ vertices in $M_{NY}(A).$
\end{marking-scheme}
Formally, $M_{NY}(A)=\{y\in Y| y \in N(A)\}$. If the number of vertices in $M_{NY}(A)$ is at most $k+2$, then the marking scheme marks all vertices in $M_{NY}$, else it arbitrarily chooses $k+2$ vertices and marks them.
\begin{marking-scheme}\label{mrk-cmn-nbrs-in-I} For a subset $A$ of $S$, let $M_{CY}(A)$ be the set of vertices in $Y$ whose neighborhood contains $A$. For every subset $A$ of $S$ whose size is at most $d$, mark a vertex in $M_{CY}(A)$. Marking scheme prefers a vertex with highest degree.
\end{marking-scheme}
Formally, $M_{CY}(A)=\{y \in Y | A \subseteq N(y)\}$. If $M_{CY}(A)$ is empty, then marking scheme does not mark any vertex, otherwise it picks a vertex with the highest degree.
Let $Y'$ be the set of vertices of $Y$ that have been marked by the Marking Schemes \ref{mrk-nbrs-in-I} or \ref{mrk-cmn-nbrs-in-I}. Using set $S$ and marked vertices in $Y$, Marking Schemes~\ref{mrk-cmn-nbr-in-C}~and~\ref{mrk-nonnbrs-in-C} marks some vertices in $X$. We remark that these two schemes are
similar to Marking Schemes~\ref{marking:nbrs}~and~\ref{marking:non-nbrs}
\begin{marking-scheme}\label{mrk-cmn-nbr-in-C} For a subset $A$ of $S\cup Y'$, let $M_{CX}(A)$ be the set of vertices in $X$ whose neighborhood contains $A$. For every subset $A$ of $S \cup Y'$ whose size is at most $d$, mark two vertices in $M_{CX}(A)$.
\end{marking-scheme}
Formally, $M_{CX}(A)=\{ x\in X |\ A\subseteq N(x) \}$. If $M_{CX}(A)$ is empty, then the marking scheme does not mark any vertex, and if it has only one vertex, then the marking scheme marks that vertex. If it has at least two vertices, then the marking scheme arbitrarily chooses two vertices and marks them.
\begin{marking-scheme}\label{mrk-nonnbrs-in-C} For a subset $A$ of $S \cup Y'$, let $M_{NX}(A)$ be the set of vertices in $X$ whose neighborhood does not intersect $A$. For every subset $A$ of $S\cup Y'$ whose size is at most $d$, mark $2k+2$ vertices in $M_{NX}(A)$.
\end{marking-scheme}
Formally, $M_{NX}(A)=\{x\in X |\ N(x)\cap A = \emptyset \}$. If the number of vertices in $M_{NX}(A)$ is at most $2k+2$, then the marking scheme marks all vertices in $M_{NX}(A)$. If the number is greater than $2k+2$, then the marking scheme arbitrarily chooses $2k+2$ vertices and marks them.
\begin{reduction rule} \label{rr:splitcontraction-reduction} For a given instance $(G, k)$, a partition $(S, X, Y)$ of $V(G)$, and an integer $d$,
apply Marking Schemes~\ref{mrk-nbrs-in-I}~to~\ref{mrk-nonnbrs-in-C}. Let $G'$ be the graph obtained from $G$ by deleting unmarked vertices of $X$ and $Y$. Return the instance $(G',k)$.
\end{reduction rule}
The number of vertices in $Y$ marked by Marking Schemes~\ref{mrk-nbrs-in-I}~and~\ref{mrk-cmn-nbrs-in-I} is at most $\ensuremath{{\mathcal O}}(|S|^{d + 1})$. This implies that the total number of vertices marked by these four marking schemes is at most $\ensuremath{{\mathcal O}}(|S|^{d^2 + d + 1})$. Above reduction rule can be applied in time $|S|^{d^2 + d + 1} \cdot |V(G)|^{\ensuremath{{\mathcal O}}(1)} = |V(G)|^{\ensuremath{{\mathcal O}}(1)}$ as $|S|$ is at most $10k$ and number of vertices in $G$ is at least $\ensuremath{{\mathcal O}}(k^{d^2 + d+ 1})$.
Note that $G'$ is an induced subgraph of $G$, and hence $G' - S$ is a split graph with $(X', Y')$ as its split partition.
We first prove the following lemma which is similar to Lemma~\ref{lemma:connected-clique}.
\begin{lemma} \label{lemma:connected-split}
Consider instance $(G, k)$ of \textsc{Split Contraction}.
Let $Y'$ be the set of vertices marked by Marking Schemes~\ref{mrk-nbrs-in-I}~to~\ref{mrk-nonnbrs-in-C} for some positive integer $d$.
For any subset $Z''$ of $(X \setminus X') \cup (Y \setminus Y')$, let $G''$ be the graph obtained from $G$ by deleting $Z''$.
Then, $G''$ is connected.
\end{lemma}
\begin{proof}
Recall that, by our assumption, $G$ is connected and $X$ is a clique in $G$.
Hence, for every vertex in $S \cup Y$, there exists a path from it to some vertex in $X$.
By the construction of $G''$, $(S, X \setminus Z'', Y \setminus Z'')$ forms a partition of $V(G'')$ and $X \setminus Z''$ is a clique in $G''$.
To prove that $G''$ is connected, it is sufficient to prove that for every vertex in $S \cup (Y \setminus Z'')$, there exists a path from it to a vertex in $X \setminus Z''$ in $G$.
We first prove that every vertex in $Y \setminus Z''$ has a path from it to a vertex in $X \setminus Z''$.
Fix an arbitrary vertex, say $y$, in $Y \setminus Z''$.
Consider a path $P$ from $y$ to $x$ in $G$, where $x$ is some vertex in $X$.
Without loss of generality, we can assume that $x$ is the only vertex in $V(P) \cap X$.
We argue that there exists a path, say $P_1$, from $y$ to a vertex in $X \setminus Z''$.
If $x$ is in $X \setminus Z''$ then $P_1 = P$ is a desired path.
Consider the case when $x$ is in $Z''$.
Let $w$ be the vertex in $V(P)$ which is adjacent with $x$.
Note that $w$ is either in $S$ or in $Y$.
It may be the same as $y$.
As Marking Scheme~\ref{mrk-cmn-nbr-in-C} considered all subsets of size at most $d$ in $S \cup (Y \setminus Z'')$, it considered the singleton set $\{w\}$.
As $w$ is adjacent with $x$, we have $\{w\} \subseteq N(x)$.
Since $x$ is in $Z''$, and hence unmarked, there exists a vertex, say $x_1$, in $X$ which has been marked by Marking Scheme~\ref{mrk-cmn-nbr-in-C}.
Consider the path $P_1$ obtained from $P$ by deleting vertex $x$ (and hence edge $wx$) and adding vertex $x_1$ with edge $wx_1$.
This is a desired path from $y$ to a vertex in $X \setminus Z''$.
As $y$ is an arbitrary vertex in $Y \setminus Z''$, this statement is true for any vertex in $Y \setminus Z''$ and
hence $G''$ is connected.
Now, it is sufficient to argue that for every vertex in $S$, there exists a path from it to a vertex in $(X \cup Y) \setminus Z''$.
Fix an arbitrary vertex, say $s$, in $S$.
Consider a path $P$ from $s$ to $u$ in $G$, where $u$ is some vertex in $X \cup Y $.
As $G$ is connected, such a path exists.
Without loss of generality, we can assume that $u$ is the only vertex in $V(P) \cap (X \cup Y)$.
We argue that there exists a path, say $P_1$, from $s$ to a vertex in $(X \cup Y) \setminus Z''$.
If $u$ is in $(X \cup Y) \setminus Z''$ then $P_1 = P$ is a desired path.
Consider the case when $u$ is in $Z''$.
Let $s_0$ be the vertex in $V(P)$ which is adjacent with $u$.
Note that $s_0$ is in $S$ and it may be the same as $s$.
As Marking Scheme~\ref{mrk-nbrs-in-I} and \ref{mrk-cmn-nbr-in-C} considered all subsets of size at most $d$ in $S$, it considered the singleton set $\{s_0\}$.
As $s_0$ is adjacent with $u$, we have $\{s_0\} \subseteq N(u)$.
Since $u$ is in $Z''$, and hence unmarked, there exists a vertex, say $u_1$, in $(X \cup Y) \setminus Z''$ which has been marked by Marking Scheme~\ref{mrk-nbrs-in-I} or \ref{mrk-cmn-nbr-in-C}.
Consider a path $P_1$ obtained from $P$ by deleting vertex $u$ (and hence edge $s_0u$) and adding the vertex $u_1$ with edge $s_0u_1$.
This is a desired path from $s$ to a vertex in $(X \cup Y) \setminus Z''$.
As $s$ is an arbitrary vertex in $S$, this statement is true for any vertex in $S$.
Hence, there exists a path from every vertex in $S \cup (Y \setminus Z'')$ to a vertex in $X \setminus Z''$ in $G''$.
As $X \setminus Z''$ is a clique in $G''$, we can conclude that $G''$ is connected.
\end{proof}
As in case of \textsc{Clique Contraction}, we will iteratively remove vertices from $(X \setminus X') \cup (Y\setminus Y')$, and Lemma~\ref{lemma:connected-split} ensures that the graph at each step remains connected.
To avoid corner cases, we need to ensure that whenever $X \setminus X'$ is non-empty, there is at least one witness set, which contains a vertex in $X'$. We ensure that by marking a few additional vertices in $X$.
\begin{remark1}\label{remark-extra-coloring} Mark any $2k + 2$ vertices in $X$.
\end{remark1}
Note that we can not infer anything about the adjacency of these vertices with vertices in $S \cup Y$. We use these vertices only to add certain edges, which are entirely contained in $X$.
In Lemma~\ref{lem-numerator-SC}, we argue that given a solution for $(G', k)$, we can construct a solution of almost the same size for $(G, k)$.
\begin{figure}[t]
\centering \includegraphics[scale=0.60]{./images/solution-lifting-split.pdf}
\caption{Left hand side figure shows partition $(S, X, Y)$ of $G$ where as right hand side figure shows witness sets in $G$ and $G'$. We need to modify witness sets in $\mathcal{W}_{I}$ which are adjancent with each other (e.g. $\{y_1\}$ and $\{x_2\}$) and witness sets in $\mathcal{W}_C$ which are not adjancent with each other (e.g. $W(t)$ and $\{x_1\}$). Please refer to Lemma~\ref{lem-numerator-SC}. \label{fig:solution-lifting-split}}
\end{figure}
\begin{lemma} \label{lem-numerator-SC} Let $(G',k)$ be the instance returned by Reduction Rule \ref{rr:splitcontraction-reduction} when applied on the instance $(G,k)$. If there exists a set of edges of size at most $k$, say $F'$, such that $G'/F'$ is a split graph then there exists a set of edges $F$ such that $G/F$ is a split graph and cardinality of $F$ is at most $\alpha \cdot |F'|+1$.
\end{lemma}
\begin{proof}
If no vertex in $X \cup Y$ has been deleted, then $G'$ and $G$ are identical graphs, and the statement is true.
We assume that at least one vertex from $X \cup Y$ has been deleted.
Recall that $X', Y'$ is the set of vertices in $X, Y$, respectively, that have been marked.
It is easy to see that $(S, X', Y')$ is a partition of $V(G')$ such that $G' - S$ is a split graph with $(X', Y')$ as one of its split partition.
Let $\mathcal{W}'$ be a $G'/F'$-witness structure of $G'$.
By Lemma~\ref{lemma:connected-split}, $G'$ is connected and without loss of generality we assume that edges $F'$ satisfies the three properties mentioned in Observation~\ref{obs:bags_in_clique}.
Let $(C', I')$ be the split partition of $G'/F'$ mentioned in the third property in Observation~\ref{obs:bags_in_clique}.
Let $\mathcal{W}_{C'}$ (resp. $\mathcal{W}_{I'}$) be the collection of witness sets in $\mathcal{W}'$ which correspond to vertices in $C'$ (resp. $I'$). We intentionally name a subset of $\mathcal{W}'$ with $\mathcal{W}_{C'}$ (instead of $\mathcal{W}'_{C'}$) as it simplifies notations in remaining proof. Note that any two witness sets in $\mathcal{W}_{C'} $ are adjacent with each other in $G'$ and no two witness sets in $\mathcal{W}_{I'}$ are adjacent with each other in $G'$.
By Observation~\ref{obs:bags_in_clique}, all non-trivial witness sets in $\mathcal{W}'$ are contained in $\mathcal{W}_{C'}$.
We start constructing witness structure $\mathcal{W}$ and set a of edges $F$ of $G$ from $\mathcal{W}'$ and $F'$ as follows. For every vertex $u$ in $(X\setminus X') \cup (Y\setminus Y')$, add singleton witness sets $\{u\}$ to $\mathcal{W}'$. Initialize $F$ to $F'$. Let $\mathcal{W}_{C \setminus C'}$ be the set of newly added singleton witness sets that correspond to the vertices in $X \setminus X'$ and let $\mathcal{W}_{I \setminus I'}$ be the set of newly added singleton witness sets that correspond to the vertices in $Y \setminus Y'$.
In the remaining proof, we argue that we can carefully add some edges in $F'$ such that following two conditions are satisfied. $(i)$ Any two witness sets in $\mathcal{W}_{C'} \cup \mathcal{W}_{C \setminus C'}$ are adjacent with each other in $G$
$(ii)$ No two witness sets in $\mathcal{W}_{I'} \cup \mathcal{W}_{I \setminus I'}$ are adjacent with each other in $G$.
To ensure condition $(i)$, we might have to add one extra edge for $d$ edges present in $F'$. {\bf This addition of edges introduces the multiplicative factor of $\alpha$ in the upper bound for the size of $F$ in terms of $F'$. To ensure condition $(ii)$, we might have to contract an edge outside $F'$. This brings an additive factor of one. }
Let $\mathcal{W}^*$ be the collection of witness sets in $\mathcal{W}_{C'}$ which violates Condition~$(i)$. In other words, $\mathcal{W}^*$ is the collection of witness set $W(t)$ in $\mathcal{W}_{C'}$ such that there exists a (singleton) witness set $\{x\}$ in $\mathcal{W}_{C \setminus C'}$ which is not adjacent with $W(t)$. See Figure~\ref{fig:solution-lifting-split}. (For example, here witness set $\{x_1\}$ is not adjacent with $W(t)$.) We argue that every witness set in $\mathcal{W}^*$ has at least $d + 1$ vertices. For the sake of contradiction, assume that there exists a witness set $W(t)$ in $\mathcal{W}^*$ which contains at most $d$ vertices. Let $\{x_1\}$ be a singleton set in $\mathcal{W}_{C \setminus C'}$ which is not adjacent with $W(t)$. Since $G[X]$ induces a clique in $G$, witness set $W(t)$ is contained in $S \cup Y'$.
Since Marking Scheme~\ref{mrk-nonnbrs-in-C} iterated over all sets of size at most $d$, it also considered $W(t)$ while marking. Note that $x_1$ is contained in $M_{NX}(W(t))$, a set of non-neighbors of $W(t)$ in $X$. As $x_1$ is unmarked, there are $2k + 2$ vertices in $M_{NX}(W(t))$ that have been marked. All these marked vertices are in $G'$. Since the cardinality of $F'$ is at most $k$, the number of vertices in $V(F')$ is at most $2k$. This implies that at least two marked vertices in $M_{NX}(W(t))$ remain as singleton witness set. Since these two witness sets are adjacent to each other, at least one of these sets in contained in $\mathcal{W}_{C'}$. This contradicts the fact that any two witness sets in $\mathcal{W}_{C'}$ are adjacent to each other. Hence our assumption is wrong and $W(t)$ has at least $d+1$ vertices.
Fix a witness set, say $W(t')$, in $\mathcal{W}_{C'}$ which intersects with $X'$. By Remark~\ref{remark-extra-coloring}, $X'$ is non-empty and such set exists. We note that $W(t')$ is adjacent with every (singleton) witness set in $\mathcal{W}_{C \setminus C'}$. For every witness set $W(t)$ in $\mathcal{W}^*$, we add an edge between $W(t)$ and $W(t')$ to the set $F'$.
Equivalently, we construct a new witness set by taking the union of $W(t')$ and all the witness sets $W(t)$ in $\mathcal{W}^*$.
We now argue the size bound of $F$. Note that we have added one extra edge for every witness set $W(t)$ in $\mathcal{W}^*$. As every witness set of $\mathcal{W}^*$ has at least $d+1$ vertices, we have added one extra edge for at least $d$ edges in the solution $F$. Moreover, since witness sets in $\mathcal{W}^*$ are vertex disjoint, no edge in $F'$ can be part of two witness sets. This implies that the number of edges in $F$ is at most $\frac{d+1}{d}|F'| \leq \alpha \cdot |F'|$.
We now consider Condition~$(ii)$. Let $\mathcal{W}^*$ be the collection of witness sets in $\mathcal{W}_{I'}$ which violates Condition~$(ii)$. In other words, $\mathcal{W}^*$ is the collection of witness set $W(t)$ in $\mathcal{W}_{I'}$ such that there exists a (singleton) witness set $\{y\}$ in $\mathcal{W}_{I \setminus I'}$ which is adjacent with $W(t)$.
Since $Y$ is an independent set in $G$, any witness set $W(t)$ in $\mathcal{W}^*$ intersects with either $X'$ or $S$. We consider two cases depending on whether $W(t)$ intersects $X'$ or not. We argue that in the first case, we can add an extra edge to $F'$ and avoid all such cases, while the second case can not occur.
Consider a witness set $W(t)$ in $I'$ which intersects with $X'$. Let $a$ be the vertex in $I'$ and $W_a = W(t)$ be the witness set corresponding to it. By Remark~\ref{remark-extra-coloring}, there exists vertex $b$ in $G'/F'$ which is adjacent to $a$.
Let $W_b$ be the witness set in $\mathcal{W}'$ corresponding to $b$.
Remove $W_b, W_a$ from $\mathcal{W}'$ and add $W_a \cup W_b$ as a witness set to $\mathcal{W}'$ (or more specifically to $\mathcal{W}_{C'}$). Since $X'$ is a clique, at most one vertex from $X'$ can be part of witness set in $\mathcal{W}_{I'}$. Hence there is at most one such vertex in $I'$. Since edge across $W_a, W_b$ is not in $F'$, this operation adds one extra edge in $F'$. (For example, edge $x_2x_3$ in Figure~\ref{fig:solution-lifting-split}). Hence, in order to make sure that no witness set violates Condition $(i)$ and $(ii)$, we have added edges to $F'$ to obtain $F$ such that the size is at most $\alpha |F'| + 1$.
Now, consider the second case.
Assume that there exists a witness $W(t)$ in $\mathcal{W}^*$ which does not intersect with $X'$.
This implies that $W(t)$ is contained in $S$.
Let ${y_1}$ be a singleton witness set in $\mathcal{W}_{I \setminus I'}$ which is adjacent with $W(t)$.
By Observation~\ref{obs:bags_in_clique}, we know that $W(t)$ is a singleton witness set and is contained in $S$. Hence set $A = W(t)$ has been considered by Marking Scheme~\ref{mrk-nbrs-in-I}.
Note that $y_1$ is contained in $M_{NY}(A)$, a set of neighbors of $A$ in $I$.
Since $y_1$ is unmarked, there are $k + 2$ vertices in $M_{NY}(A)$ that have been marked.
All these marked vertices are in $G'$.
Since $Y'$ is an independent set in $G'$, at most $k$ vertices in $Y'$ can be incident on solution edges.
Only these vertices can be part of $\mathcal{W}_{C'}$.
There can be at most one vertex which is a singleton witness set in $\mathcal{W}_{C'}$.
Hence there exists at least one singleton witness set in $\mathcal{W}_{I'}$ which is adjacent with $W(t)$.
This contradicts the fact that no two witness sets in $\mathcal{W}_{I'}$ are adjacent to each other.
Hence our assumption is wrong, and no such witness structure exists in $\mathcal{W}^*$.
This concludes the proof of the lemma.
\end{proof}
In the following lemma, we argue that the value of the optimum solution for reduced instance can be upper bounded by the value of the optimum solution for the original instance.
\begin{lemma} \label{lem-denominator-SC} Let $(G',k)$ be the instance returned by Reduction Rule \ref{rr:splitcontraction-reduction} when applied on an instance $(G,k)$. If $\textsc{OPT}(G,k) \leq k$ then $\textsc{OPT}(G',k) \leq 2\cdot \textsc{OPT}(G,k)$.
\end{lemma}
\begin{proof}
Let $F$ be a set of at most $k$ edges in $G$ such that $\textsc{OPT}(G,k)=\textsc{SpC}(G,k,F)$. Since we are working with a minimization problem, to prove the lemma, it is sufficient to find a solution for $G'$, which is of size at most $2 \cdot |F|$. Recall that $(S,X,Y)$ is a partition of $V(G)$ such that $G-S$ is a split graph with $(X, Y)$ as split partition where $X$ is a clique, and $Y$ is an independent set.
The set of vertices that have been marked in $Y$ is denoted by $Y'$, and the set of vertices that have been marked in $X$ is denoted by $X'$.
By our assumption, the input graph $G$ is connected. Without loss of generality, we can assume that $F$ satisfies three properties mentioned in Observation~\ref{obs:bags_in_clique}.
Let $(C, I)$ be the split partition of $G/F$ mentioned in the third property in Observation~\ref{obs:bags_in_clique}.
Let $\mathcal{W}$ be a $G/F$-witness structure of $G$. Let $\mathcal{W}_{C}$ (resp. $\mathcal{W}_{I}$) be the collection of witness sets in $\mathcal{W}$ which correspond to vertices in $C$ (resp. $I$).
Note that any two witness sets in $\mathcal{W}_{C} $ are adjacent with each other in $G$, and no two witness sets in $\mathcal{W}_{I}$ are adjacent with each other in $G$.
By Observation~\ref{obs:bags_in_clique}, all non-trivial witness sets in $\mathcal{W}$ are contained in $\mathcal{W}_{C}$.
At each step, we construct the graph $G^*$ from $G$ by deleting one or more vertices in $(X\setminus X')\cup (Y\setminus Y')$.
By Lemma~\ref{lemma:connected-split}, $G^*$ is connected.
{\bf We also construct a set of edges $F^*$ from $F$ by replacing existing edges and/or adding extra edges to $F$.}
In terms of witness sets, we delete witness sets that are subsets of $(X\setminus X')\cup (Y\setminus Y')$ and modify the ones that intersect $(X\setminus X')\cup (Y\setminus Y')$.
After the modification, we represent the witness sets corresponding to vertices in the clique as $\mathcal{W}^*_{C}$ and the independent set as $\mathcal{W}^*_{I}$.
At any point, we ensure that any two witness sets in
$\mathcal{W}^*_{C}$ are adjacent to each other, and any two witness sets in $\mathcal{W}^*_{I}$ are not adjacent to each other.
This implies that at any intermediate state, $G^*/F^*$ is a split graph.
We modify $F$ to obtain $F^*$ such that the number of edges in $F^*$ is at most $2 \cdot |F^{\circ}|$, where $F^{\circ}=F$ be an optimum solution for the original instance $(G, k)$.
For notational convenience, we rename $G^*$ to $G$ and $F^*$ to $F$ at regular intervals but do not change $F^{\circ}$.
Since the class of split graphs is closed under vertex deletion, we can delete all witness sets, which are entirely contained in $(X\setminus X')\cup (Y\setminus Y')$. Suppose that there exists a witness set $W(t)$ in $\mathcal{W}$ which is a subset of $(X\setminus X')\cup (Y\setminus Y')$, construct $G^*$ from $G$ by deleting witness set $W(t)$ in $\mathcal{W}$. Delete the edges corresponding to spanning tree of $G[W(t)]$ from $F$ to obtain $F^*$.
We repeat this process until there exists a witness set that satisfies this condition. After exhaustively applying this process, we have $|F^*|\leq |F|$.
\smallskip
\begin{tcolorbox}[colback=red!5!white,colframe=red!75!black]
\centerline {At this stage we rename $G^\star$ to $G$ and $F^\star$ to $F$.}
\end{tcolorbox}
Note that at this stage, there is no witness set in $\mathcal{W}_{I}$ which contains vertex in $(X\setminus X')\cup (Y\setminus Y')$. Hence, we do not need to modify witness sets in $\mathcal{W}_{I}$. In all the conditions mentioned below, the modification is done on non-trivial witness sets in $\mathcal{W}_{C}$ only. These modifications do not affect the independent property of witness sets in $\mathcal{W}_{I}$. So, to prove that the modified witness structure obtained corresponds to a split graph, it is enough to show that the witness sets in $\mathcal{W}^*_C$ are connected, and any two of them are adjacent to each other.
We partition all non-trivial witness sets in $\mathcal{W}_C$ with respect to their intersection with sets $S, X, Y$. For a non-trivial witness set $W(t)$, we denote its intersection with $S, X, Y$, respectively, using an ordered tuple $(i; j; k)$ where integers $i, j, k$ take $0$ or $1$. If $W(t)$ intersects with $Z$ in $\{S, X, Y\}$, then we assign the corresponding integer to $1$ and $0$ otherwise. Since $(S, X, Y)$ is a partition of $V(G)$, witness sets in $\mathcal{W}_C$ can be partitioned into seven parts (excluding the trivial $(0; 0; 0)$ case). Note that since $Y$ is an independent set in $G$, no non-trivial witness set can contain only vertices in $Y$. This implies that there is no non-trivial witness set in partition of $\mathcal{W}_C$ corresponding to $(0; 0; 1)$. Consider a witness set that is entirely contained in $S$. Since we do not delete any vertex in $S$ while creating $G^*$ from $G$, this witness set remains unchanged throughout the process. Hence we do not consider witness sets in partition corresponding to $(1; 0; 0)$.
This implies we only need to modify witness sets in five partitions of $\mathcal{W}_C$. Each of these partitions can be further divided into subparts based on whether witness set intersects with $X \setminus X'$ or $Y \setminus Y'$ or both or none. We note that any witness set which does not intersect with $(X \setminus X') \cup (Y \setminus Y')$ is not affected; hence we only need to consider first three cases.
We modify a witness set that satisfies the least indexed condition. If there does not exist any witness set which satisfies either of these conditions, then $(X\setminus X')\cup (Y\setminus Y')$ is an empty set, and the lemma is vacuously true. Hence in every case, we assume that witness set intersects $(X\setminus X')\cup (Y\setminus Y')$, and it is not entirely contained inside it.
\iffalse
\begin{table}[t]
\begin{center}
\begin{tabular}{|c|c|c|c|c|}
\hline
$(S; X; Y)$ & $(X \setminus X'; Y \setminus Y')$ & Addressed in \\
\hline
\multirow{2}{*}{$(0; 1; 0)$} & $(*; 1)$ & Not valid \\
& $(1; 0)$ & Condition~\ref{cond:part_010} \\
\hline
\multirow{2}{*}{$(1; 1; 0)$} & $(*; 1)$ & Not valid \\
& $(1; 0)$ & Condition~\ref{cond:part_110} \\
\hline
\multirow{2}{*}{$(1; 0; 1)$} & $(1; *)$ & Not valid \\
& $(0; 1)$ & Condition~\ref{cond:part_101} \\
\hline
\multirow{2}{*}{$(0; 1; 1)$} & $(*; 1)$ & Condition~\ref{cond:part_011} \\
& $(1; 0)$ & Condition~\ref{cond:part_011} \\
\hline
\multirow{2}{*}{$(1; 1; 1)$} & $(*; 1)$ & Condition~\ref{cond:part_111}$(b)$ \\
& $(1; 0)$ & Condition~\ref{cond:part_111}$(a)$ \\
\hline
\end{tabular}
\end{center}
\caption{Overview of cases considered in Lemma~\ref{lem-denominator-SC}. A case is "Not Valid" if value corresponding to $X$ (resp. $Y$) is $0$ but value correponding to $X \setminus X'$ (resp. $Y \setminus Y'$) is $1$. Symbol $(*)$ denotes that value at this place is irrelevant for the condition. \label{table:cases-overview}}
\end{table}
\fi
\begin{condition}[ Partition $(0; 1; 0)$] \label{cond:part_010}
There exists a witness set, say $W(t)$, which intersects with $X$ but does not intersect with $S$ or $Y$.
\end{condition}
\vspace{0.1cm}
Since $W(t)$ is contained in set $X$, it intersects with $X \setminus X'$ but is not contained in it.
Hence both the sets $W(t) \cap X'$ and $W(t)\cap (X \setminus X')$ are non empty. Let $x_1$ be a vertex in $W(t) \cap (X\setminus X')$.
Fix a witness set, say $W(t^\#)$, in $\mathcal{W}_{C}$ which is different from $W(t)$ and intersects with $X'$. By Remark~\ref{remark-extra-coloring}, $X'$ is of size at least $2k + 2$ and hence such a set exists. Let $\mathcal{W}_C^*$ be the witness set obtained from $\mathcal{W}_C$ by removing $W(t), W(t^\#)$ and adding $(W(t) \setminus \{x_1\}) \cup W(t^\#)$. Note that in $\mathcal{W}_C, W(t), W(t^\#)$ and $x_1$ satisfy the premise of Observation~\ref{obs:merging-witness-sets}. This implies that any two witness sets in $\mathcal{W}^*_C$ are adjacent with each other.
Let $F^*$ be the set of edges obtained from $F$ by removing an edge incident on $x_1$ and adding an edge across $W(t)$ and $W(t^\#)$.
Hence, if $G^*$ is obtained from $G$ by deleting $x_1$ then $G^*/F^*$ is a split graph. Since we are deleting at least one edge from $F$ and adding only one edge, we have $|F^*| \leq |F|$.
\begin{figure}[t]
\centering
\includegraphics[scale=0.60]{./images/split-opt-cond-23.pdf}
\caption{Straight lines (e.g. $xx'$) represent edges in original solution $F$. Dotted lines (e.g. $x_1x'$) represents an edges replaced in $F$. Dashed lines (e.g. $x_1x_2$) represents extra edges added to $F$. Please refer to Conditions~\ref{cond:part_110} and \ref{cond:part_101} in Lemma~\ref{lem-denominator-SC}. Vertex $z_2$ can be in $X$ or $S$. \label{fig:condition-2-3}}
\end{figure}
\smallskip
\begin{tcolorbox}[colback=red!5!white,colframe=red!75!black]
\centerline {At this stage we rename $G^\star$ to $G$ and $F^\star$ to $F$.}
\end{tcolorbox}
\begin{condition}[ Partition $(1; 1; 0)$] \label{cond:part_110} There exists a witness set, say $W(t)$, which intersects with $S$ and $X$ but does not intersect with $Y$.
\end{condition}
\vspace{0.1cm}
Since $W(t)$ does not intersect with $Y$, it intersects with $X \setminus X'$.
Let $x$ be a vertex in $W(t)\cap (X\setminus X')$; $S_t$ be the set of vertices in $W(t) \cap S$ which are adjacent with $x$ via edges in $F$ and $Q_t$ be the set of vertices in $W(t)\cap X$ which are adjacent with $x$ via edges of $F$.
We find a \emph{substitute} for $x$ in $X'$.
(This condition is same as that of Condition~\ref{cond:witness-intersectsX} in the proof of Lemma~\ref{lemma:reduction-rule}.)
Note that if $S_t$ is empty then $Q_t$ must be non-empty and we replace the edges incident on $x$ similar to that of in Condition \ref{cond:part_010}.
Every vertex in $S_t$ is considered by Marking Scheme~\ref{mrk-cmn-nbr-in-C}.
For every $s$ in $S_t$, vertex $x$ is contained in $M_{CX}(\{s\})$, the set of vertices in $X$ whose neighborhood contains $\{s\}$.
Since $x$ is in $X \setminus X'$, and hence unmarked, there are two vertices in $M_{CX}(\{s\})$, say $x^1_s, x^2_s$, different from $x$ which have been marked for each $s$ in $S_t$.
Since $X$ is a clique in $G$, at most one of these two vertices are part of witness set contained in $\mathcal{W}_{I}$.
Without loss of generality, assume that for every vertex $s$ in $S_t$, vertex $x^1_s$ is contained in witness set contained in $\mathcal{W}_C$.
We construct $F^*$ from $F$ by following operation: Arbitrarily fix a vertex $s_0$ in $S_t$.
Remove the edge $s_ox$ in $F$ and add the edge $s_ox^1_{s_o}$ and for every vertex $s$ in $S_t\setminus \{s_o\}$, remove the edge $sx$ in $F$ and add two edges $sx^1_s, x^1_sx^1_{s_o}$.
For every vertex $x'$ in $Q_t$ replace the edge $x'x$ by $x'x^1_{s_0}$.
(For example, in Figure~\ref{fig:condition-2-3}, let $W(t) = \{x, x', s_1, s_2, s_3\}$ and $x$ is in $X \setminus X'$.
This implies that $S_t = \{s_1, s_2, s_3\}$ and $Q_t = \{x'\}$.
Let $s_1$ be the vertex which is fixed arbitrarily.
In this process, edge $xs_3$ is deleted and two edges $x_3s_3, x_3x_1$ are added to $F$.)
We argue that contracting edges in $F^*$ merges $W(t)\setminus \{x\}$ into the witness set in $\mathcal{W}^*_C$ that contains $x_s^1$.
Define $W := (W(t) \setminus \{x\}) \cup (\bigcup_{s \in S_t}W(x^1_s))$ where $W(x^1_s)$ is the witness set in $\mathcal{W}$ containing the vertex $x^1_s$.
Let $\mathcal{W}_C^*$ be the witness structure obtained from $\mathcal{W}_C$ by removing every witness set which intersects $W$ and adding $W$.
Since $W$ contains $W(x^1_{s_0})$, it is adjacent with every other witness set in $\mathcal{W}_C$ and hence in $\mathcal{W}^*_C$.
This implies that any two witness sets in $\mathcal{W}^*_C$ are adjacent to each other.
Hence, if $G^*$ is obtained from $G$ by deleting $x$, then $G^*/F^*$ is a split graph.
Since we are adding at most two edges only for deleted edges in $F$, we have $|F^*| \leq 2 \cdot |F|$.
\smallskip
\begin{tcolorbox}[colback=red!5!white,colframe=red!75!black]
\centerline {At this stage we rename $G^\star$ to $G$ and $F^\star$ to $F$.}
\end{tcolorbox}
\begin{condition}[ Partition $(1; 0; 1)$] \label{cond:part_101} There exists a witness set, say $W(t)$, which intersects with $S$ and $Y$ but does not intersect with $X$.
\end{condition}
\vspace{0.1cm}
Since $W(t)$ does not intersect with $X$, it intersects with $Y \setminus Y'$. Let $y$ be a vertex in $W(t)\cap (Y\setminus Y')$; $S_t$ be the set of vertices in $W(t) \cap S$ which are adjacent with $y$ via edges in $F$. After removing all the edges incident on $y$ we add some edges to ensure connectivity of vertices in $S_t$ and some other to ensure adjacency among witness sets in $\mathcal{W}_C$. Arbitrarily fix a vertex $s_0$ in $S_t$.
If $S_t \setminus \{s_0\}$ is an empty set then no edge needs to be included to ensure connectivity. For every vertex $s$ in $S_t \setminus \{s_0\}$, set $\{s_0, s\}$ is considered by Marking Scheme~\ref{mrk-cmn-nbrs-in-I}. (For any $\alpha > 1$, $d$ is at least two.)
For every $s$ in $S_t \setminus \{s_0\}$, vertex $y$ is contained in $M_{CY}(\{s_0, s\})$, the set of common neighbors of $\{s_0, s\}$ in $Y$. Since $y$ is in $Y \setminus Y'$, and hence unmarked, there is a vertex in $M_{CY}(\{s_0, s\})$ different from $y$ which has been marked for each set $\{s_0, s\}$. For every vertex $s$ in $S_t \setminus \{s_0\}$, let $y_s$ be the marked vertex which is adjacent with $s_0$ and $s$. We construct $F^*$ from $F$ by following operation: Remove the edge $s_oy$ and for every vertex $s$ in $S_t \setminus \{s_o\}$, remove the edge $sy$ in $F$ and add two edges $sy_s, s_oy_s$.
(For example, in Figure~\ref{fig:condition-2-3}, let $W(t) = \{y, s_4, s_5, s_6\}$ and $y$ is in $Y \setminus Y'$. This implies that $S_t = \{s_4, s_5, s_6\}$. Let $s_4$ be the vertex which is fixed arbitrarily. In this process, edges $s_4y, s_5y$ are deleted and two edge $s_5y_2, s_4y_2$ are added to $F$.) Now we include additional edges to ensure adjacency among witness sets in $\mathcal{W}_C$.
Towards this we first prove that there always exists a witness set $W(t^\#)$ different from $W(t)$, in $\mathcal{W}_{C}$ that is adjacent with either $W(t)\setminus \{y\}$ or with $y_s$ for some $s$ in $S_t\setminus \{s_o\}$. Suppose that there is no set $W(t^\#)$ that is adjacent with $W(t)\setminus \{y\}$ this implies that every witness set in $\mathcal{W}$ is adjacent with only vertex $y$ in $W(t)$. As the size of $X'$ is at least $2k + 2$ and $y$ is adjacent with every witness set in $\mathcal{W} \setminus \{W(t)\}$ and every vertex in $S_t$, $y$ is adjacent with at least $k + 2$ vertices.
For a vertex $s'$ in $S_t\setminus \{s_o\}$, let $y_{s'}$ be the vertex marked by Marking Scheme~\ref{mrk-cmn-nbrs-in-I} while considering set $\{s_o,s'\}$. Note that Marking Scheme~\ref{mrk-cmn-nbrs-in-I} preferred $y_{s'}$ over $y$. This implies that $y_{s'}$ is adjacent with at least $k + 2$ vertices. Hence, $y_{s'}$ has at least one neighbor outside $W(t)$. Note that $y_{s'}$ is not in the clique because $W(t)\setminus \{y\}$ did not have a neighbor in $\mathcal{W}_{C}$, this implies that the neighbor of $y_{s'}$ is in $\mathcal{W}_{C}$. Since there always exists another witness set $W(t^\#)$ that is adjacent with $(W(t)\setminus \{y\}) \cup \{y_{s} |\ \text{for every}\; s\; \text{in}\; S_t\setminus \{s_o\}\}$, we add the edge across $W(t), W(t^\#)$ in $F$.
Let $W$ be the superset of $W(t)\setminus \{y\}$ which contains witness sets of all the newly added vertices to $W(t)$. Formally, $W=(W(t)\setminus \{y\})\cup(\bigcup_{s\in S_t\setminus \{s_o\}}W(y_s))$ where $W(y_s)$ is the witness set containing $y_s$. Note that every vertex in $S_t$ is connected with each other (as we have added edges $y_ss, y_ss_0$ for every $s$ in $S_t \setminus \{s_o\}$) and $W$ is adjacent with $W(t^\#)$.
Let $\mathcal{W}_C^*$ be the witness structure obtained from $\mathcal{W}_C$ by removing every witness set which intersects with $W, W(t^\#)$ and adding $W \cup W(t^\#)$.
Since $W \cup W(t^\#)$ contains $W(t^\#)$, which is adjacent with every other witness set in $\mathcal{W}_C$ and hence in $\mathcal{W}^*_C$. This implies that any two witness sets in $\mathcal{W}^*_C$ are adjacent with each other. Hence, if $G^*$ is obtained from $G$ by deleting $y$ then $G^*/F^*$ is a split graph. Since we are adding two edges of the form $y_ss, y_ss_0$ for every edge of the form $sy$ in $F$, where $s \in S_t \setminus \{s_o\}$ and one edge across $W(t), W(t^\#)$ instead of $ys_o$ we have $|F^*| \leq 2 \cdot |F|$.
\smallskip
\begin{tcolorbox}[colback=red!5!white,colframe=red!75!black]
\centerline {At this stage we rename $G^\star$ to $G$ and $F^\star$ to $F$.}
\end{tcolorbox}
\begin{condition}[ Partition $(0; 1; 1)$] \label{cond:part_011} There exists a witness set, say $W(t)$, which intersects with $X$ and $Y$ but does not intersect with $S$.
\end{condition}
\vspace{0.1cm}
We construct $F^*$ from $F$ in two steps, where the first step deletes the vertices of $Y\setminus Y'$, and the second step deletes the vertices of $X\setminus X'$.
Suppose that there exists a vertex $y$ in $W(t)\cap (Y\setminus Y')$.
Fix a witness set, say $W(t^\#)$, in $\mathcal{W}_{C}$ which is different from $W(t)$ and intersects $X'$.
By Remark~\ref{remark-extra-coloring}, $X'$ is of size at least $2k + 2$ and hence such set exists.
Let $\mathcal{W}_C^*$ be the witness set obtained from $\mathcal{W}_C$ by removing $W(t), W(t^\#)$ and adding $W(t^\#) \cup (W(t) \setminus \{y\})$.
Note that in $\mathcal{W}_C$, witness sets $W(t), W(t^\#)$ and $y$ satisfy the premise of Observation~\ref{obs:merging-witness-sets}. This implies that any two witness sets in $\mathcal{W}^*_C$ are adjacent with each other.
Hence, if $G^*$ is obtained from $G$ by deleting $y$ then $G^*/F^*$ is a split graph. Since we are deleting at least one edge from $F$ and adding only one edge, we have $|F^*| \leq |F|$.
We repeat this process as long as there exists a witness set that satisfy Condition~\ref{cond:part_011} and intersects $Y \setminus Y'$.
Consider a witness set $W(t)$ which satisfies Condition~\ref{cond:part_011} and does not intersect with $Y \setminus Y'$. This implies $W(t)$ intersects with $X \setminus X'$ and every vertex in $W(t) \cap Y$ is contained in $Y'$.
Consider a vertex $x$ in $W(t) \cap (X \setminus X')$. If $F$ does not contain any edges across $\{x\}$ and $ Y'$ then in $\mathcal{W}_C$, witness sets $W(t), W(t^\#)$ and $x$ satisfy the premise of Observation~\ref{obs:merging-witness-sets}.
We obtain the modified graph as mentioned in previous case.
Suppose that there exist edges in $F$ across $\{x\}$ and $ Y'$.
Let $Y_t$ be the set of neighbors of $x$ in $Y'$ via edges in $F$.
For every $y$ in $Y_t$, the set $\{y\}$ is considered by Marking Scheme~\ref{mrk-cmn-nbr-in-C}.
Note that $x$ is contained in the set $M_{CX}(\{y\})$, the set of vertices in $X$ whose neighborhood contains $\{y\}$.
Since $x$ is in $X \setminus X'$, and hence unmarked, there are two vertices in $M_{CX}(\{y\})$, say $x^1_y, x^2_y$, different from $x$ which have been marked for each $y$ in $Y_t$.
Since $X$ is a clique in $G$, at most one of these two vertices are part of witness set contained in $\mathcal{W}_{I}$.
Without loss of generality, assume that for every vertex $y$ in $Y_t$, vertex $x^1_y$ is contained in the witness set in $\mathcal{W}_C$.
We construct $F^*$ from $F$ by following operation (This step is similar modification as we did in Condition~\ref{cond:part_110}): Arbitrarily fix a vertex $y_0$ in $Y_t$. For every vertex $y$ in $Y_t$, remove the edge $yx$ in $F$ and add two edges $yx^1_y, x^1_yx^1_{y_0}$.
Let $W = (W(t) \setminus \{x\}) \cup (\bigcup_{y \in Y_t}W(x^1_y))$ where $W(x^1_y)$ is the witness set in $\mathcal{W}$ containing $x^1_y$.
We obtain the witness structure $\mathcal{W}^*_C$ from $\mathcal{W}_C$ by removing every witness set that intersects $W$ and adding $W$.
Since $W$ contains $W(x^1_{y_0})$, it is adjacent with every other witness set in $\mathcal{W}_C$ and hence in $\mathcal{W}^*_C$. This implies that any two witness sets in $\mathcal{W}^*_C$ are adjacent to each other. Hence, if $G^*$ is obtained from $G$ by deleting $x,$ then $G^*/F^*$ is a split graph. Since we are adding at most two edges $yx^1_y,x^1_yx^1_{y_o} $ for one deleted edge of the form $yx$ in $F$, we have $|F^*| \leq 2 \cdot |F|$.
\smallskip
\begin{tcolorbox}[colback=red!5!white,colframe=red!75!black]
\centerline {At this stage we rename $G^\star$ to $G$ and $F^\star$ to $F$.}
\end{tcolorbox}
\begin{condition}[ Partition $(1; 1; 1)$] \label{cond:part_111} There exists a witness set, say $W(t)$, which intersects with $S, X$ and $Y$.
\end{condition}
\vspace{0.1cm}
We further divide this condition based on whether the intersection of $W(t)$ with $(Y\setminus Y')$ is empty (Condition~\ref{cond:part_111}$(a)$) or not (Condition~\ref{cond:part_111}$(b)$)
\noindent\emph{Condition~\ref{cond:part_111}(a):} Consider that $W(t)\cap (Y\setminus Y')$ is empty. Then there is at least one vertex in $W(t)\cap (X\setminus X')$. In this case, construction of $G^*$ and $F^*$ is similar to that of Condition~\ref{cond:part_110}. Instead of considering a subset of $S$ in Condition~\ref{cond:part_110}, we consider a subset of $S \cup Y'$.
Let $x$ be a vertex in $W(t)\cap (X\setminus X')$; $Z_t$ be the set of vertices in $W(t) \cap (S \cup Y')$ which are adjacent with $x$ via edges in $F$ and $Q_t$ be the set of vertices in $W(t) \cap X'$ which are adjacent with $x$ via edges of $F$.
Note that every vertex in $Z_t$ is considered by the Marking Scheme~\ref{mrk-cmn-nbr-in-C}. For every vertex $z$ in $Z_t$, vertex $x$ is contained in $M_{CX}(\{z\})$, the set of vertices in $X$ whose neighborhood contains $\{z\}$. Since $x$ is in $X \setminus X'$, and hence unmarked, there are two vertices in $M_{CX}(\{z\})$, say $x^1_z, x^2_z$, different from $x$ which have been marked for each $z$ in $Z_t$. Since $X$ is a clique in $G$, at most one of these two vertices are part of witness set contained in $\mathcal{W}_{I}$. Without loss of generality, assume that for every vertex $z$ in $Z_t$, vertex $x^1_z$ is contained in witness set of $\mathcal{W}_C$. We construct $F^*$ from $F$ by following operation: Arbitrarily fix a vertex $z_0$ in $Z_t$. remove the edge $z_0x$ and for every vertex $z$ in $Z_t\setminus \{z_0\}$, remove the edge $zx$ in $F$ and add two edges $zx^1_z, x^1_zx^1_{z_0}$. For every vertex $x'$ in $Q_t$ replace the edge $x'x$ by $x'x^1_{z_0}$.
Let $W$ be the superset of $W(t) \setminus \{x\}$ which contains witness set containing all newly added vertices in $W(t)$. Formally, $W = (W(t) \setminus \{x\}) \cup (\bigcup_{z \in Z_t}W(x^1_z))$ where $W(x^1_z)$ is the witness set in $\mathcal{W}$ containing $x^1_z$.
Let $\mathcal{W}^*_C$ be the witness structure obtained from $\mathcal{W}_C$ by removing every witness set which intersects $W$ and adding $W$.
Since $W$ contains $W(x^1_{z_0})$, it is adjacent with every other witness set in $\mathcal{W}_C$ and hence in $\mathcal{W}^*_C$. This implies that any two witness sets in $\mathcal{W}^*_C$ are adjacent to each other.
Hence, if $G^*$ is obtained from $G$ by deleting $x$, then $G^*/F^*$ is a split graph. Since we are adding at most two edges only for deleted edges in $F$, we have $|F^*| \leq 2 \cdot |F|$.
\smallskip
\begin{tcolorbox}[colback=red!5!white,colframe=red!75!black]
\centerline {At this stage we rename $G^\star$ to $G$ and $F^\star$ to $F$.}
\end{tcolorbox}
\noindent\emph{Condition~\ref{cond:part_111}$(b)$:} Consider that $W(t)\cap (Y\setminus Y')$ is non-empty. In this case, construction of $G^*$ and $F^*$ is similar to that of Condition~\ref{cond:part_101}.
Let $y$ be a vertex in $W(t)\cap(Y\setminus Y')$ and $S_t$ be the set of vertices in $W(t)\cap S$ which are adjacent with $y$ via edges in $F$ and $Q_t$ be the set of vertices in $W(t)\cap X$ which are adjacent with $y$ via edges in $F$.
Arbitrarily fix a vertex $s_0$ in $S_t$.
We add some edges to ensure connectivity of vertices in $S_t$ and some other to ensure adjacency among witness sets in $\mathcal{W}_C$.
If $S_t \setminus \{s_o\}$ is an empty set then no edge needs to be included to ensure connectivity. For every vertex $s$ in $S_t \setminus \{s_o\}$, the set $\{s_o, s\}$ is considered by Marking Scheme~\ref{mrk-cmn-nbrs-in-I}. (For any $\alpha > 1$, $d$ is at least two.)
For every $s$ in $S_t \setminus \{s_o\}$, vertex $y$ is contained in $M_{CY}(\{s_o, s\})$, the set of common neighbors of $\{s_o, s\}$ in $Y$.
Since $y$ is in $Y \setminus Y'$, and hence unmarked, there is a vertex in $M_{CY}(\{s_o, s\})$ different from $y$ which has been marked for each set $\{s_o, s\}$.
For every vertex $s$ in $S_t \setminus \{s_o\}$, let $y_s$ be the marked vertex which is adjacent with $s_o$ and $s$.
We construct $F^*$ from $F$ by following operation: Remove the edge $s_oy$ and for every vertex $s$ in $S_t \setminus \{s_o\}$, remove edge $sy$ in $F$ and add two edges $sy_s, s_oy_s$.
Since $W(t)$ also intersects $X$, there exists another witness set $W(t^\#)$, in $\mathcal{W}_{C}$ such there is an edge across $W(t^\#)$ and $W(t) \setminus \{y\}$.
Let $uv$ be that edge. Include $uv$ in the solution.
Let $W$ be the superset of $W(t) \setminus \{y\}$ which contains the witness sets of all the newly added vertices in $W(t)$. Formally, $W = (W(t) \setminus \{y\}) \cup (\bigcup_{s \in S_t}W(y_s))$ where $W(y_s)$ is the witness set containing $y_s$. Note that every vertex in $S_t$ is connected with each other (as we have added edges $y_ss, y_ss_o$ for every $s$ in $S_t \setminus \{s_o\}$) and $W$ is adjacent with $W(t^\#)$. Let $\mathcal{W}^*_C$ be the witness structure obtained from $\mathcal{W}_C$ by removing every witness set which intersects with $W,W(t^\#)$ and adding $W \cup W(t^\#)$. Since $W \cup W(t^\#)$ contains $ W(t^\#)$, which is adjacent with every other witness set in $\mathcal{W}_C$ and hence in $\mathcal{W}'_C$. This implies that any two witness sets in $\mathcal{W}^*_C$ are adjacent with each other. Hence, if $G^*$ is obtained from $G$ by deleting $y$ then $G^*/F^*$ is a split graph. Since we are adding at most two edges of the form $y_ss, y_ss_o$ for every edge of the form $sy$ in $F$ where $y \in S_t \setminus \{s_o\}$ and at most two edges for edge $ys_o$, we have $|F^*| \leq 2 \cdot |F|$.
\smallskip
We now argue that even after repeating the process, the size of $|F^*|$ is bounded. In every condition, an edge $uv$ is replaced only if one of the endpoints belongs to $(X\setminus X')\cup (Y\setminus Y')$. Every time edges were replaced by those edges that belong to $G'$. So once any of the conditions mentioned above consider an edge in $F$, it will never be considered by any other condition. This implies that the number of edges in $F^*$ is always upper bounded by $2 \cdot |F^{\circ}|$ where $F^{\circ}$ is a solution for original instance $(G, k)$. If there exists no witness set {\bf that satisfies any condition}, then $G' = G^*$ and solution $F^*$ is the solution with desired properties. This concludes the proof of the lemma.
\end{proof}
Lemma~\ref{lem-numerator-SC}~and~\ref{lem-denominator-SC} are not sufficient to prove a time-efficient $(2 + \epsilon)$-approximate polynomial kernel. This is primarily because of the additive factor in Lemma~\ref{lem-numerator-SC}. We present the following lemma, which describes a solution lifting algorithm whose running time is dependent on $\epsilon$.
\begin{lemma}\label{lemma:solution-lifting-split} For a fixed $\alpha^{\prime}, \alpha$ satisfying $\alpha^{\prime} > \alpha > 1$, there exists a solution lifting algorithm which satisfies following properties.
\begin{enumerate}
\item Given a reduced instance $(G', k)$ obtained by applying Reduction Rule~\ref{rr:splitcontraction-reduction} on instance $(G, k)$, partition $(S, X, Y)$ of $V(G)$ and an integer $d = \lceil \frac{1}{\alpha - 1}\rceil$ together with a solution $F'$ for $(G', k)$, it returns a solution $F$ for $(G, k)$ such that $\frac{\textsc{SpC}(G,k,F)}{\textsc{OPT}(G,k)} \leq 2 \cdot \alpha^{\prime} \cdot \frac{\textsc{SpC}(G',k,F')}{\textsc{OPT}(G',k)}$.
\item The algorithm runs in time $\mathcal{O}(m^{{\alpha} \cdot c + 2})$ where $m$ is the number of edges in $G$ and $c = \frac{1}{\alpha' - \alpha}$.
\end{enumerate}
\end{lemma}
\begin{proof} We present a solution lifting algorithm which considers three cases depending on cardinality of $F'$. Before mentioning the algorithm, we recall Lemma~\ref{lem-denominator-SC} which states that if $\textsc{OPT}(G,k) \leq k$ then $\textsc{OPT}(G',k) \leq 2 \cdot \textsc{OPT}(G,k)$. If $\textsc{OPT}(G, k) = k + 1$ then $\textsc{OPT}(G', k) \le k + 1 = \textsc{OPT}(G, k)$. Hence in either case, $\textsc{OPT}(G', k) \le 2 \cdot \textsc{OPT}(G, k)$.
If cardinality of $F'$ is greater than or equal to $k + 1$ then solution lifting algorithm returns a spanning tree $F$ of $G$ (a trivial solution) as solution for $(G, k)$. In this case, $\textsc{SpC}(G, k, F) = k + 1 = \textsc{SpC}(G', k, F')$. Since $\textsc{OPT}(G', k) \le 2 \cdot \textsc{OPT}(G, k)$, in this case we get
$\frac{\textsc{SpC}(G,k,F)}{\textsc{OPT}(G,k)} \leq 2 \cdot \frac{\textsc{SpC}(G',k,F')}{\textsc{OPT}(G',k)}$.
If cardinality of $F'$ is at most $k$ but greater than or equal to $c$ then the algorithm uses Lemma~\ref{lem-numerator-SC} to compute a solution $F$ for $(G, k)$ such that cardinality of $F$ is at most $\alpha \cdot |F'| + 1$. Since $\textsc{OPT}(G', k) \le 2 \cdot \textsc{OPT}(G, k)$, this implies:
$$\frac{|F|}{\textsc{OPT}(G,k)} \leq \frac{ 2 \cdot (\alpha \cdot |F'| + 1)}{\textsc{OPT}(G',k)} \le 2 \cdot \Big(\alpha + \frac{1}{|F'|}\Big) \cdot \frac{ |F'|}{\textsc{OPT}(G',k)} \le 2 \cdot \alpha^{\prime} \cdot \frac{ |F'|}{\textsc{OPT}(G',k)}$$
Last inequality follows from the fact that $|F'| \ge c$ and $1/c = \alpha' - \alpha$. Hence in this case, $\frac{\textsc{SpC}(G,k,F)}{\textsc{OPT}(G,k)} \leq 2 \cdot \alpha^{\prime} \cdot \frac{\textsc{SpC}(G',k,F')}{\textsc{OPT}(G',k)}$.
Consider the remaining case when $|F'| < c$. By definition, $F'$ is a valid solution for $(G', k)$. By Lemma~\ref{lem-numerator-SC}, there exists a solution $F$ for $(G, k)$ such that $|F| \le \alpha |F'|+1 < \alpha \cdot c+1$. Since we are working with minimization problem, this implies $\textsc{OPT}(G,k) \le \alpha \cdot c$. In this case, solution lifting algorithm computes an optimum solution for $(G, k)$ by brute force, i.e. checking all set of edges in $G$ of size at most $\alpha \cdot c$, and returns it. In this case, we have, $\frac{\textsc{SpC}(G,k,F)}{\textsc{OPT}(G,k)} = 1$.
Hence, the solution lifting algorithm returns a solution with the desired property. The running time of the algorithm follows from its description, and the fact that solution satisfying Lemma~\ref{lem-numerator-SC} can be obtained in polynomial time.
\end{proof}
We note that solution lifting algorithm mentioned in Lemma~\ref{lemma:solution-lifting-split} allows us to choose a value of $\alpha$ between $1$ and $\alpha'$. This choice of $\alpha$ is a trade-off between the running time of the algorithm (as $c$ is inversely proportional to $\alpha' - \alpha$) and the size of lossy kernel (as $d$ is inversely proportional to $\alpha - 1$). We now present the main result of this section.
\begin{reptheorem}{thm:split-lossy} For any $\epsilon > 0$, \textsc{Split Contraction} parameterized by the size of solution $k$, admits $(2 + \epsilon)$-approximate polynomial kernelization algorithm which runs in $\mathcal{O}(m^{\alpha \cdot c + 2})$ time and return an instance with $\ensuremath{{\mathcal O}}(k^{d^2+d+1})$ vertices. Here, $m$ is number of edges in $G$ and constants $\alpha, c,$ and $d$ depend only on $\epsilon$.
\end{reptheorem}
\begin{proof} Any split graph can have at most one component which contains an edge. Hence, if graph $G$ in given instance $(G, k)$ is not connected, then all but one connected component needs to be contracted to an isolated vertex.
If there are more than one connected components with at least $k + 1$ vertices, then we return a trivial instance. Otherwise, we apply reduction rules to the unique connected component in $G$, which has more than $k + 1$ vertices. Hence, we can assume that the input graph is connected.
For a given instance $(G,k)$, a kernelization algorithm applies Reduction Rule~\ref{rr:large-splitvd}. If it returns a trivial instance then the statement is vacuously true. If it does not return a trivial instance then the algorithm partitions $V(G)$ in three sets $(S,X,Y)$ such that $|S|\leq 10k$ and $G - S$ is a split graph with $(X, Y)$ as its split partition. For given $\epsilon$, fix $\alpha' = 1 + \epsilon/2$. The algorithm fixes $\alpha$ which is strictly more than $1$ and strictly less than $\alpha'$. The algorithm then applies Reduction Rule \ref{rr:splitcontraction-reduction} on $(G,k)$ with partition $(S, X, Y)$ and $\alpha$. The algorithm returns the reduced instance as an $(2 \cdot \alpha')$-lossy kernel for $(G,k)$.
The correctness of the algorithms follows from Lemma~\ref{lem-denominator-SC}~and~\ref{lemma:solution-lifting-split} combined with the fact that Reduction Rule~\ref{rr:splitcontraction-reduction} is applied at most once.
By Observation~\ref{obsn:approx-svd-solution}, Reduction Rule~\ref{rr:large-splitvd} can be applied in polynomial time. The size of the instance returned by Reduction Rule~\ref{rr:splitcontraction-reduction} is at most $\ensuremath{{\mathcal O}}(k^{d^2 + d + 1})$. Reduction Rule~\ref{rr:splitcontraction-reduction} can be applied in time $n^{\ensuremath{{\mathcal O}}(1)}$ if number of the vertices in $G$ is more than $\ensuremath{{\mathcal O}}(k^{d^2 + d + 1})$.
\end{proof}
\section{(No) {\textsf{FPT}}\xspace Approximation Algorithm for Chordal Contraction}
\label{hardness_chordal}
In this section, we show that unlike \textsc{Clique Contraction} or \textsc{Split Contraction}, one can not obtain a lossy kernel of any size for \textsc{Chordal Contraction}.
It is known that for every $\alpha \ge 1$ and parameterized optimization problem $\Pi$, $\Pi$ admits a fixed parameter tractable $\alpha$-approximation algorithm if and only if $\Pi$ has an $\alpha$-approximate kernel \cite[Proposition~$2.11$]{lossy}.
We prove that \textsc{Chordal Contraction}\ parameterized by the solution size $k$, cannot be approximated within a factor of $F(k)$ in \textsf{FPT}\ time.
Towards this we give a reduction from {\sc Set Cover} and use a known result that no \textsf{FPT}\ time algorithm can approximate {\sc Set Cover} within a factor of $F(k)$, where $F(k)$ is the function of $k$ alone~\cite{DBLP:conf/stoc/SLM18}.
The parameterized optimization version of \textsc{Chordal Contraction}\ is defined as follows.
$$\textsc{ChC}(G,k,F)=\begin{cases}
\min\left\{|F|,k+1\right\}\;\; &\text{if}\; G/F\; \text{is a chordal graph}\\
\infty \; \; &\text{otherwise}.
\end{cases}$$
Lokshtanov et al.~\cite{elimNew} proved that \textsc{Chordal Contraction}, parameterized by solution size $k$, does not admit a (classical) kernel of any size under widely believed assumption. They proved this by presenting a \emph{parameter preserving} reduction from \textsc{Hitting Set} problem to \textsc{Chordal Contraction}. In the following lemma, we argue that such \emph{parameter preserving} reduction can also be obtained in case of the optimization version of problems. Our reduction is the same as the reduction given by Lokshtanov et al.~\cite{elimNew}. We need some more arguments to show that there exists a \texttt{$1$-appt} from \textsc{Set Cover$/k$} to \textsc{Chordal Contraction} when parameterized by solution size. For the sake of completeness, we give the full reduction.
\begin{lemma}\label{lemma:1-appt-chordal} There exists an $1$-approximate polynomial parameter transformation (\texttt{$1$-appt}) from \textsc{Set Cover$/k$} to \textsc{Chordal Contraction} parameterized by solution size.
\end{lemma}
\begin{proof} To prove this lemma, we present a reduction algorithm, $R_{\mathcal{A}}$, which given an instance $((U, \mathcal{S}), k)$ of \textsc{Set Cover$/k$} outputs an instance $(G, k')$ of \textsc{Chordal Contraction}. We also present a solution lifting algorithm that takes as input an instance $((U, \mathcal{S}), k)$ of \textsc{Set Cover$/k$}; an output instance $(G, k') = R_{\mathcal{A}}((U, \mathcal{S}), k)$ of \textsc{Chordal Contraction}; and a solution $F$ to the instance $(G, k')$; and outputs a solution $\mathcal{F}$ to $((U, \mathcal{S}), k)$ such that \textsc{SC$/k((U, \mathcal{S}), k, \mathcal{F})$} = \textsc{ChC}$(G, k, F)$.
Without loss of generality, we assume that every element of the universe $U$ is contained in some set $S_i$ in $\mathcal{S}$ as otherwise $((U, \mathcal{S}), k)$ is a trivial instance. We first present a reduction algorithm.
\smallskip
\noindent \textbf{Reduction Algorithm :}
Given an instance $((U,\mathcal{S}), k)$ of the \textsc{Set Cover} problem with $U = \{u_1, \cdots , u_n \}$ and $\mathcal{S} = \{S_1, \cdots, S_m\}$, the algorithm constructs graph $G$ as follows: It creates a vertex $s_j$ for each set $S_j$ in $\mathcal{S}$ and three vertices $a_{i}, b_{i}$ and $c_{i}$ for each element $u_i$ in the universe $U$. It also adds a special vertex $g$ to $G$. It adds following edges in $G$.
\begin{itemize}
\item an edge between any two different vertices corresponding to sets; (In other words, the algorithm converts set $\{s_{1}, s_2, \cdots, s_m\}$ into a clique by adding all edges $s_js_{j^{\prime}}$ for $1 \le j, j^{\prime} \le m$ and $j \neq j^{\prime}$.)
\item edge $gs_j$ for every $j$ in $\{1, 2, \cdots, m\}$ and edges $ga_i, gb_i$ for every $i$ in $\{1, 2, \cdots, n\}$;
\item edges $a_ic_i$ and $b_ic_i$ for every $i$ in $\{1, 2, \cdots, n\}$;
\item for an element $x_{i}$ and a set $S_j$, if $x_i$ is in $S_j$ then it adds edge $c_is_{j}$;
\end{itemize}
The algorithm returns $(G, k)$ as an instance of \textsc{Chordal Contraction}.
See Figure \ref{fig:redc4} for an illustration.
It is easy to verify that graph $G$ does not contain any induced cycle of length five or more.
We have created cycles of length four for each element in the universe which intersects with each other only in $g$.
Informally speaking, all these cycles can be killed by introducing the edge $gc_j$ for every cycle.
To introduce all these chords with at most $k$ contractions, we need to carefully select at most $k$ sets (and contracts edges of the form $gs_i$) which \emph{covers} all the elements.
We argue that introducing chords of the form $gs_j$ also kills other cycles of length four in the graph.
\begin{figure}[t]
\centering
\includegraphics[scale=0.75]{./images/chordal.pdf}
\caption{Reduction from an instance $((U, \mathcal{S}), k)$ of \textsc{Set Cover} to an instance $(G, k)$ of \textsc{Chordal Contraction}. Here $U = \{u_1, u_2, u_3\}; \mathcal{S} = \{S_1, S_2, S_3\}$ where $S_1 = \{u_1, u_2\}, S_2 = \{u_1, u_2, u_3\}$, and $S_3 = \{u_2, u_3\}$. Straight lines (eg. $a_1g$) are part of gadget construction whereas dashed lines (eg. $c_1s_1$) are added because of containment relationship between elements and sets. Please refer to the Reduction Algorithm in the proof of Lemma~\ref{lemma:1-appt-chordal}. \label{fig:redc4}}
\end{figure}
\smallskip
\noindent \textbf{Solution Lifting Algorithm:} Let $F^{\circ}$ be the given solution for $(G, k)$. If $|F^{\circ}| \ge k + 1$ then the algorithm returns $\mathcal{F} = \mathcal{S}$ as a solution. Otherwise, the algorithm first constructs another solution for $(G, k)$ with the following two operations. $(a)$ If $F^{\circ}$ contains an edge of the form $ga_i, gb_i, a_ic_i$ or $b_ic_i$, then replace it by $gs_j$, where $S_j$ is any set containing $u_i$. $(b)$ If $F^{\circ}$ contains an edge of the form $s_jc_i$, then replace it by $gs_j$. Let $F$ be the solution obtained from $F^{\circ}$ by exhaustively applying these two operations. Consider a $G/F$-witness structure of $G$ and let $W(g)$ be the witness set containing $g$. Define $\mathcal{F}$ as a collection of sets in $\mathcal{S}$ whose corresponding vertices are contained in $W(g)$. The algorithm returns $\mathcal{F}$ as a solution for $((U, \mathcal{S}), k)$.
We justify the two modification operations defined in solution lifting algorithm.
It is easy to see that $|F| \le |F^{\circ}|$.
We slightly abuse notations and rename new vertex added while contracting edge $gs_j$ as $g$.
The only cycle affected by contracting edges of the form $ga_i, gb_i, a_ic_i$ or $b_ic_i$ is $\{g, a_i, c_i, b_i\}$.
By contracting an edge of the form $gs_j$ where $S_j$ is any set containing $u_i$, we introduce another chord $gc_i$ which \emph{destroys} the cycle.
Similarly, if $F^{\circ}$ contains an edge of the form $s_jc_i$, then the only four-cycles of $G$ that gets a chord in $G/\{s_jc_i\}$ are: $\{g, a_i, c_i, b_i\}$, $\{s_j, g, a_i, c_i\}$, and $\{s_j, g, b_i, c_i\}$.
All of these cycles get a chord when the edge $gs_j$ is contracted instead.
This implies that if $G/F^{\circ}$ is a chordal graph then so is $G/F$.
We now prove that the cycles present in the graph $G$ are of a very specific type. This claim is similar to Proposition~$1$ in \cite{elimNew}. Note that because of Claim~$1$, to convert $G$ into a chordal graph it is sufficient to introduce chords $gc_i$ for every $i$ in $\{1, 2, \cdots, n\}$.
\vspace{0.2cm}
\noindent \emph{Claim 1.} Graph $G$ does not contain any induced cycle of length five or more. The only induced cycles of length four in the graph $G$ are of one of the three forms: $(i)$ $\{g, a_{i}, c_{i}, s_{j}\}$ for some element $u_i$ and set $S_j$ containing it; $(ii)$ $\{g, b_{i},c_{i},s_{j}\}$ for some element $u_i$ and set $S_j$ containing it; $(iii)$ $\{g, a_{i}, c_{i}, b_{i}\}$ for some element $u_i$.\\
\noindent \emph{Proof:} We define subsets $T, A, B, C$ of $V(G)$ as collections of vertices $s_j$'s, $a_i$'s, $b_i$'s and $c_i$'s respectively. Formally, $T = \{s_1, s_2, \cdots , s_m\}$; $A = \{a_1, a_2, \cdots, a_n\}$; $B = \{b_1, b_2, \cdots, b_n\}$ and $C = \{c_1, c_2, \cdots, c_n\}$. Note that $G[T]$ is a clique whereas $A, B, C$ are independent sets in $G$.
Since $G[T \cup \{g\}]$ is a clique, any induced cycle of length at least four contains at most two vertices of $T \cup \{g\}$.
As $G \setminus (T \cup \{g\})$ is a collection of induced paths on three vertices, and hence acyclic, the largest induced cycle possible in $G$ is of length five. We note that every induced paths is of the form $\{a_i, c_i, b_i\}$ and only other vertex adjacent to $a_i, b_i$ is $g$. Hence, such path can not be part of an induced $C_5$.
This implies that $G$ does not contain an induced cycle of length five or more.
Assume that there exists an induced $C_4$ with two vertices, say $s_j, s_{j^{\prime}}$, in $T$. By construction, the only vertices which are adjacent with $s_j, s_{j^{\prime}}$ are in the set $C \cup \{g\}$. Since $g$ is adjacent with both these vertices, it can not be part of induced $C_4$ that contains $s_j, s_{j^{\prime}}$. This implies that the remaining two vertices in $C_4$ are from $C$. As $s_j, s_{j^{\prime}}$ are adjacent to each other, the remaining two vertices in $C_4$ must be adjacent to each other. This contradicts the fact that $C$ is an independent set in $G$. Hence our assumption is wrong and no such induced $C_4$ exists.
Consider an induced $C_4$ which contains exactly one vertex, say $s_j$, in $T$. Assume that this induced $C_4$ does not contain $g$. By construction, only neighbors of $s_j$ outside $T$ are in $C$. Let $c_i, c_j$ are two vertices contained in this induced $C_4$. Since the only common neighbor of $c_i, c_j$ outside $T$ is $g$, our assumption that this $C_4$ does not contain $g$ is wrong. This implies every such induced $C_4$ contains $g$. Since the only other neighbor of $s_j$ is in $C$, one of the remaining vertex in this cycle is from set $C$.
Let that vertex be $c_i$.
Since $a_i$ or $b_i$ are the only common neighbors of $g$ and $c_i$, the only possible cycles are of the form $(i)$ or $(ii)$ mentioned in the claim.
As there is no edge between following pair of vertices- $(g, c_i)$, $(s_j, a_i)$ and $(s_j, b_i)$, this cycle is indeed an induced $C_4$.
Consider an induced $C_4$ which does not intersect with $T$. Since $G \setminus (T \cup \{g\})$ is acyclic, every cycle of this type contains $g$. In this cycle, neighbors of $g$ are from sets $A$ and $B$. By construction, vertices $a_{i}$ and $b_{i^{\prime}}$ have a common neighbor only if $i = i^{\prime}$. This implies the only possible induced $C_4$ which does not intersect with $T$ is of the form $(iii)$.
As we have considered all cases exhaustively, this proves the claim. \hfill $\diamond$
\vspace{0.2cm}
We now prove that any solution of \textsc{Set Cover/$k$} naturally leads to a solution for \textsc{Chordal Contraction}. For any subset $\mathcal{F}$ of $\mathcal{S}$, let $F_{\mathcal{F}}$ be the set of edges in $G$ which are incident on $g$ and $s_i$ for some $s_i$ in $\mathcal{F}$.
\vspace{0.2cm}
\noindent\emph{Claim 2:} If $\mathcal{F}$ is a set cover of instance the $((U,\mathcal{S}), k)$, then $G/F_{\mathcal{F}}$ is a chordal graph.\\
\noindent\emph{Proof :} Let $H$ be the graph obtained from $G$ by contracting all edges in $F_{\mathcal{F}}$. Since $\mathcal{F}$ covers all the elements of $U$, contracting all the edges in $F_{\mathcal{F}}$ introduces edge $gc_i$ for every $i$ in $\{1, 2, \cdots,n\}$ in graph $H$. By Claim~$1$, all the induced cycles in $G$ are of the form $\{g, a_{i}, c_{i}, s_{j}\}$ or $\{g, b_{i},c_{i},s_{j}\}$ or $\{g, a_{i}, c_{i}, b_{i}\}$ for some element $u_i$. Hence, there is no induced cycle of length four or more in $H$; thus it is a chordal graph. \hfill $\diamond$
\vspace{0.2cm}
Let $F$ be the given solution for $(G, k)$ such that $G/F$ is a chordal graph and $|F|$ is at most $k$.
Let $\mathcal{F}$ be the solution for \textsc{Set Cover/$k$} instance returned by the solution lifting algorithm. Recall that the modification operation $(a)$ or $(b)$ mentioned in the solution lifting algorithm does not change the size of $F$.
\vspace{0.2cm}
\noindent\emph{Claim 3:} $\mathcal{F}$ is a set cover of size at most $|F|$ for $(U, \mathcal{S})$.\\
\noindent \emph{Proof:} Consider the four-cycle given by $\{g, a_i, c_i, b_i\}$ in graph $G$. Since $G/F$ is a chordal graph, there exists an edge $gc_i$ in $E(G/F)$. This implies there is an edge $gs_j$ in $F$ for some set $S_j$ which contains $u_i$. Hence there is a set $S_j$ in $\mathcal{F}$ which contains element $u_i$. Since this is true for any element in $U$, $\mathcal{F}$ is a set cover for $(U, \mathcal{S})$. As $|W(g)|$ is at most $|F| + 1$ and it contains vertex $g$, upper bound on $\mathcal{F}$ follows. \hfill $\diamond$
\vspace{0.2cm}
We are now in the position to conclude the proof. Claim~$2$ implies that $\textsc{OPT}_{\textsc{ChC}(G, k)} \le \textsc{OPT}_{\textsc{SC$/k$}}((U, \mathcal{S}), k)$. Moreover, if $|F| \ge k + 1$, then solution lifting algorithm returns $\mathcal{F} = \mathcal{S}$. In this case, \textsc{ChC}$(G, k, F) = k + 1 = $ \textsc{SC$/k((U, \mathcal{S}), k, \mathcal{S})$}. If $|F| \le k$ and $G/F$ is a chordal graph then by Claim~$3$, \textsc{SC$/k((U, \mathcal{S}), k, \mathcal{F})$} $\le$ \textsc{ChC}$(G, k, F)$. This implies that there exists a \texttt{$1$-appt} from \textsc{Set Cover$/k$} to \textsc{Chordal Contraction} when parameterized by solution size.
\end{proof}
Karthik et al.~\cite[see conclusion]{DBLP:conf/stoc/SLM18} showed that assuming \textsf{FPT} $\neq$ {\sf W[1]}, no \textsf{FPT}\ time algorithm can approximate {\sc Set Cover} within a factor of $F(k)$. Pipelining this result with
Lemma~\ref{lemma:1-appt-chordal}, we get the following result.
\begin{reptheorem}{thm:chordal-no-lossy} Assuming \textsf{FPT} $\neq$ {\sf W[1]}, no \textsf{FPT}\ time algorithm can approximate {\sc Chordal Contraction} within a
factor of $F(k)$. Here, $F(k)$ is a function depending on $k$ alone.
\end{reptheorem}
\section{Preliminaries}
\label{sec:prelim}
In this section, we give notations and definitions that we use throughout the paper. Unless specified, we will be using all general graph terminologies from the book of Diestel~\cite{diestel-book}.
\subsection{Graph Theoretic Definitions and Notations}
For an undirected graph $G$, sets $V(G)$ and $E(G)$ denote the set of vertices and edges, respectively. Two vertices $u, v$ in $V(G)$ are said to be \emph{adjacent} if there is an edge $uv$ in $E(G)$. The neighborhood of a vertex $v$, denoted by $N_G(v)$, is the set of vertices adjacent to $v$ in $G$. For subset $S$ of vertices, we define $N(S) =\bigcup_{v \in S} N(v)) \setminus S$.
The subscript in the notation for the neighborhood is omitted if the graph under consideration is clear. For a set of edges $F$, set $V(F)$ denotes the endpoints of edges in $F$. For a subset $S$ of $V(G)$, we denote the graph obtained by deleting $S$ from $G$ by $G - S$ and the subgraph of $G$ induced on set $S$ by $G[S]$. For two subsets $S_1, S_2$ of $V(G)$, we say $S_1, S_2$ {\em are adjacent if there exists an edge} with one endpoint in $S_1$ and other in $S_2$.
An edge $e$ in $G$ is a \emph{chord} of a cycle $C$ (resp. path $P$) if (i) both the endpoints of $e$ are in $C$ (resp. in $P$), and (ii) edge $e$ is not in $C$ (resp. not in $P$). An \emph{induced cycle} (resp. \emph{path}) is a cycle (resp. path) which has no chord. We denote induced cycle and path on $\ell$ vertices by $C_{\ell}$ and $P_{\ell}$, respectively.
A \emph{complete graph} $G$ is an undirected graph in which for every pair of vertices $u,v\in V(G)$, there is an edge $uv$ in $E(G)$. As an immediate consequence of definition we get the following.
\begin{lemma}
\label{lem:complete-characterization}
A connected graph $G$ is complete if and only if $G$ does not contain an induced $P_3$.
\end{lemma}
A \emph{clique} is a subset of vertices in the graph that induces a complete graph. A set $I \subseteq V(G)$ of pairwise non-adjacent vertices is called an {\em independent set}.
A graph $G$ is a \emph{split graph} if $V(G)$ can be partitioned into a clique and an independent set. For split graph $G$, partition $(X, Y)$ is \emph{split partition} if $X$ is a clique and $Y$ is an independent set. In this article, whenever we mention a split partition, we first mention the clique followed by the independent set. We will also use the following well-known characterization of split graphs. Let, $2K_2$ be a graph induced on four vertices, which contains exactly two edges and no isolated vertices.
\begin{lemma}[\cite{golumbic2004algorithmic}]
\label{lem:split-characterization}
A graph $G$ is a split graph if and only if it does not contain $C_4, C_5$ or $2K_2$ as an induced subgraph.
\end{lemma}
A graph \(G\) is \emph{chordal} if every induced cycle in \(G\) is a triangle; equivalently, if every cycle of length at least four has a chord.
A vertex subset $S \subseteq V(G)$ is said to \emph{cover} an edge $uv \in E(G)$ if $S \cap \{u,v\} \neq \emptyset$. A vertex subset $S \subseteq V(G)$ is called a \emph{vertex cover} in $G$ if it covers all the edges in $G$.
We start with the following observation, which is useful to find a large induced clique in the input graph.
The \emph{complement} of $G$, denoted by $\bar{G}$, is a graph whose vertex set is $V(G)$ and edge set is precisely those edges which are not present in $E(G)$.
Note that given a graph $G$, if $S$ is a set of vertices such that $G-S$ is a clique, then $S$ is a vertex cover in the complement graphs of $G$, denoted by $\bar{G}$, as $\bar{G}-S$ is edgeless. Using the well-known factor $2$-approximation algorithm for {\sc Vertex Cover}~\cite{bar1981linear}, we have following.
\begin{observation}[\cite{bar1981linear}]
\label{obs:factor-2-approx}
There is a factor $2$-approximation algorithm to compute a set of vertices whose deletion results in a complete graph.
\end{observation}
\begin{comment}
\begin{proof} For a given graph $G$, let $S_0$ be a subset of vertices in $V(G)$ of smallest cardinality such that $G - S_0$ is a complete graph. If $G$ is not a connected graph, then there is exactly one connected component of $G$ whose entire vertex set is not in $S_0$. We know that a connected graph is complete if and only if it does not contain induced $P_3$. Hence for every three vertices $v_1, v_2, v_3$ which induces a $P_3$, solution $S_0$ contains $v_1$ or $v_3$. Consider an approximation algorithm which repeatedly finds three vertices, say $v_1, v_2, v_3$, in $V(G)$ which induces a $P_3$, includes $v_1, v_3$ in solution and delete $v_1, v_3$ from input graph. If the graph is not connected, $S$ includes vertices of all connected components except one of the connected components with the largest number of vertices. Let $S$ be a solution returned by this algorithm. It is easy to observe that $|S|$ is at most $2|S_0|$, and this algorithm terminates in polynomial time.
\end{proof}
\end{comment}
Using, Lemma~\ref{lem:split-characterization} one can obtain a simple factor $5$-approximation algorithm for deleting vertices to get a split graph.
\begin{observation}\label{obsn:approx-svd-solution} There is a factor $5$-approximation algorithm to compute a set of vertices whose deletion results in a split graph.
\end{observation}
Recently, for every $\epsilon >0$, a factor $(2+\epsilon)$-approximation algorithm for deleting vertices to get a split graph has been obtained~\cite{LokshtanovMPPS20}. However, for our purposes Observation~\ref{obsn:approx-svd-solution} will suffice.
\subsection{Graph Contraction}
The {\em contraction} of edge $e = uv$ in $G$ deletes vertices $u$ and $v$ from $G$, and adds a new vertex, which is made adjacent to vertices that were adjacent to either $u$ or $v$. Any parallel edges added in the process are deleted so that the graph remains simple. The resulting graph is denoted by $G/e$. Formally, for a given graph $G$ and edge $e = uv$, we define $G/e$ in the following way: $V(G/e) = (V(G) \cup \{w\}) \backslash \{u, v\}$ and $E(G/e) = \{xy \mid x,y \in V(G) \setminus \{u, v\}, xy \in E(G)\} \cup \{wx |\ x \in N_G(u) \cup N_G(v)\}$.
For a subset of edges $F$ in $G$, graph $G/ F$ denotes the graph obtained from $G$ by repeatedly contracting edges in $F$ until no such edge remains.
We say that a graph $G$ is \emph{contractible} to a graph $H$ if there exists an onto function $\psi: V(G) \rightarrow V(H)$ such that the following properties hold.
\begin{itemize}
\setlength{\itemsep}{-2pt}
\item For any vertex $h$ in $V(H)$, graph $G[W(h)]$ is connected, where set $W(h) := \{v \in V(G) \mid \psi(v)= h\}$.
\item For any two vertices $h, h'$ in $V(H)$, edge $hh'$ is present in $H$ if and only if there exists an edge in $G$ with one endpoint in $W(h)$ and another in $W(h')$.
\end{itemize}
For a vertex $h$ in $H$, set $W(h)$ is called a \emph{witness set} associated with $h$. We define $H$-\emph{witness structure} of $G$, denoted by $\mathcal{W}$, as collection of all witness sets. Formally, $\mathcal{W}=\{W(h) \mid h \in V(H)\}$. Witness structure $\mathcal{W}$ is a partition of vertices in $G$, where each witness forms a connected set in $G$. Recall that if a \emph{witness set} contains more than one vertex, then we call it \emph{non-trivial} witness set, otherwise a \emph{trivial} witness set.
If graph $G$ has a $H$-witness structure, then graph $H$ can be obtained from $G$ by a series of edge contractions. For a fixed $H$-witness structure, let $F$ be the union of spanning trees of all witness sets. By convention, the spanning tree of a singleton set is an empty set. Thus, to obtain $H$ from $G$, it is {\em sufficient} to contract edges in $F$. If such witness structure exists, then we say that graph $G$ is contractible to $H$. We say that graph $G$ is \emph{$k$-contractible} to $H$ if cardinality of $F$ is at most $k$. In other words, $H$ can be obtained from $G$ by at most $k$ edge contractions. Following observation is an immediate consequence of definitions.
\begin{observation}
\label{obs:witness-structure-property} If graph $G$ is $k$-contractible to graph $H$, then the following statements are true.
\begin{itemize}
\setlength{\itemsep}{-2pt}
\item For any witness set $W$ in a $H$-witness structure of $G$, the cardinality of $W$ is at most $k+1$.
\item For a fixed $H$-witness structure, the number of vertices in $G$, which are contained in non-trivial witness sets is at most $2k$.
\end{itemize}
\end{observation}
In the following two observations, we state that if a graph can be transformed into a clique or a split graph by contracting few edges, then it can also be converted into a clique or split graph by deleting few vertices.
\begin{observation}
\label{obs:vertex-solution}
If a graph $G$ is $k$-contractible to a clique, then $G$ can be converted into a clique by deleting at most $2k$ vertices.
\end{observation}
\begin{proof} Let $F$ be a set of edges of size at most $k$ such that $G/F$ is a clique. Let $\mathcal{W}$ be a $G/F$-witness structure of $G$. Let $X$ be a set of all vertices which are contained in the non-trivial witness sets in $\mathcal{W}$.
By Observation~\ref{obs:witness-structure-property}, size of $X$ is at most $2k$.
Any two vertices in $V(G) \setminus X$ are adjacent to each other as these vertices form singleton sets, which are adjacent in $G/F$. Hence, $G$ can be converted into a clique by deleting vertices in $X$.
\end{proof}
\begin{observation}\label{obsn-splitvd-solution} If a graph $G$ is $k$-contractible to a split graph then $G$ can be converted into a split graph by deleting at most $2k$ vertices.
\end{observation}
\begin{proof}
For graph $G$, let $F$ be the set of edges such that $G/F$ is a split graph and $|F| \leq k$. Let $V(F)$ be the collection of all endpoints of edges in $F$. Since cardinality of $F$ is at most $k$, $|V(F)|$ is at most $2k$. We argue that $G - V(F)$ is a split graph. For the sake of contradiction, assume that $G - V(F)$ is not a split graph. We know that a graph is split if and only if it does not contain induced $C_4, C_5$ or $2K_2$. This implies that there exists a set of vertices $V'$ in $V(G) \setminus V(F)$ such that $G[V']$ is either $C_4, C_5$ or $2K_2$. Since no edge in $F$ is incident on any vertices in $V'$, $G/F[V']$ is isomorphic to $G[V']$. Hence, there exists a $C_4, C_5$ or $2K_2$ in $G/F$ contradicting the fact that $G/F$ is a split graph. Hence, our assumption is wrong and $G - V(F)$ is a split graph. \end{proof}
Consider a connected graph $G$ which is $k$-contractible to the clique $K_{\ell}$. Let $\mathcal{W}$ be a $K_{\ell}$-witness structure of $G$. The following observation gives a sufficient condition for obtaining a witness structure of
an induced subgraph of $G$ from $\mathcal{W}$.
\begin{observation} \label{obs:merging-witness-sets} Let $\mathcal{W}$ be a clique witness structure of $G$. If there exists two different witness sets $W(t_1), W(t_2)$ in $\mathcal{W}$ and a vertex $v$ in $W(t_1)$ such that the set $W(t) = (W(t_1) \cup W(t_2)) \setminus \{v\}$ is a connected set in $G - \{v\}$, then $\mathcal{W}'$ is a clique witness structure of $G - \{v\}$, where $\mathcal{W}'$ is obtained from $\mathcal{W}$ by removing $W(t_1), W(t_2)$ and adding $W(t)$.
\end{observation}
\begin{proof} Let $G' = G - \{v\}$. Note that $\mathcal{W}'$ is a partition of vertices in $G'$. Any set in $\mathcal{W}' \setminus \{W(t)\}$ is a witness set in $\mathcal{W}$ and does not contain $v$. Hence, these sets are connected in $G'$. Since $G'[W(t)]$ is also connected, all the witness sets in $\mathcal{W}'$ are connected in $G'$.
Consider any two witness sets $W(t'), W(t'')$ in $\mathcal{W}'$. If none of these two is equal to $W(t)$ then both of these sets are present in $\mathcal{W}$. Since none of these witness sets contains vertex $v$, they are adjacent to each other in $G'$. Now, consider a case when one of them, say $W(t'')$, is equal to $W(t)$. As witness sets $W(t')$ and $W(t_2)$ are present in $\mathcal{W}$, there exists an edge with one endpoint in $W(t')$ and another in $W(t_2)$. The same edge is present in graph $G'$ as it is not incident on $v$. Since $W(t_2)$ is subset of $W(t)$, sets $W(t')$ and $W(t)$ are adjacent in $G'$. Hence any two witness sets in $\mathcal{W}'$ are adjacent to each other. This implies that $\mathcal{W}'$ is a clique witness structure of graph $G - \{v\}$.
\end{proof}
In the case of \textsc{Split Contraction}, the following observation guarantees the existence of witness structure with a particular property.
\begin{observation}\label{obs:bags_in_clique} For a connected graph $G$, let $F$ be a set of edges such that $G/F$ is a split graph. Then, there exists a set of edges $F'$ which satisfy the following properties: $(i)$ $G/F'$ is a split graph. $(ii)$ The number of edges in $F'$ is at most $|F|$. $(iii)$ There exists a split partition of $G/F'$ such that all vertices in $G/F'$ which correspond to a non-trivial witness set in $G/F'$-witness structure of $G$ are in clique side.
\end{observation}
\begin{proof}
Let $(C,\;I)$ be a split partition of vertices of $G/F$ such that $C$ is a clique and $I$ is an independent set. If all the vertices corresponding to non-trivial witness sets are in $C$, then the observation is true. Consider a vertex $a$ in $I$ which corresponds to a non-trivial witness set $W_a$. Since $G$ is connected, $G/F$ is a connected split graph. This implies that there exists a vertex, say $b$, in $C$ which is adjacent to $a$ in $G/F$. We denote witness set corresponding to $b$ by $W_b$. We construct a new witness structure by shifting all but one vertices in $W_a$ to $W_b$. Since $ab$ is an edge in $G/F$, there exists an edge in $G$ with one endpoint in $W_a$ and another in $W_b$. Let that edge be $u_au_b$ with vertices $u_a$ and $u_b$ contained in sets $W_a$ and $W_b$, respectively. Consider a spanning tree $T$ of graph $G[W_a]$ which is rooted at $u_a$. We can replace edges in $F$ whose both endpoints are in $V(W_a)$ with $E(T)$ to obtain another set of edges $F^*$ such that $G/F^*$ is a split graph. Formally, $F^* = (F \cup E(T)) \setminus (E(G[W_a]) \cap F)$. Note that the number of edges in $F^*$ and $F$ are same. Let $v_1$ be a leaf vertex in $T$ and $v_2$ be its unique neighbor. Consider $F' = (F^* \cup \{u_au_b\}) \setminus \{v_1v_2\}$. Since edge $v_1v_2$ is in $F^*$ and $u_au_b$ is not in $F^*$, $|F'| = |F^*|$. We now argue that $G/F'$ is also a split graph.
Let $\mathcal{W}^{\prime}$ be the $G/F'$-witness structure of $G$. Note that $\mathcal{W}^{\prime}$ can be obtained from $G/F^*$-witness structure $\mathcal{W}^*$ of $G$ by replacing $W_a$ by $\{v_1\}$ and $W_b$ by $W_b \cup (W_a \setminus \{v_1\})$. Since all other witness set remains unchanged any witness set which was adjacent to $W_b$ is also adjacent to $W_b \cup (W_a \setminus \{v_1\})$. Similarly, any witness set which was not adjacent to $W_a$ is not adjacent to $\{v_2\}$. In other words, this operation of shifting edges did not remove any vertex from the neighborhood of $b$ (which is in $C)$ nor it added any vertex in the neighborhood of $a$ (which is in $I$). Hence, $G/F'$ is also a split graph with $(C, I)$ as one of its split partition. Note that there exists a split partition of $G/F'$ such that the number of vertices in the independent side corresponding to non-trivial witness set is one less than the number of vertices in $I$ which corresponds to non-trivial witness sets. Hence, by repeating this process at most $|V(G)|$ times, we get a set of edges that satisfy three properties mentioned in the observation.
\end{proof}
\subsection{Parameterized Complexity and Lossy Kernelization}
An important notion in parameterized complexity is \emph{kernelization}, which captures the efficiency of data reduction techniques. A parameterized problem $\rm \Pi$ admits a kernel of size $g(k)$ (or $g(k)$-kernel) if there is a polynomial time algorithm (called {\em kernelization algorithm}) which takes as input $(I,k)$, and returns an instance $(I',k')$ of $\Pi$ such that: $(i)$ $(I, k)$ is a \textsf{Yes}\xspace-instance if and only if $(I', k')$ is a \textsf{Yes}\xspace-instance; and $(ii)$ $|I'| + k' \leq g(k)$, where $g(\cdot)$ is a computable function whose value depends only on $k$. Depending on whether the function $g(\cdot)$ is \emph{linear, polynomial} or \emph{exponential}, the problem is said to admit a \emph{linear, polynomial} or \emph{exponential kernel}, respectively. We refer to the corresponding chapters in the books~\cite{fomin2019kernelization,saurabh-book,DF-new,flumgrohe,niedermeier2006} for a detailed introduction to the field of kernelization.
In lossy kernelization, we work with the optimization analog of parameterized problem. Along with an instance and a parameter, an optimization analog of the problem also has a string called \emph{solution}. We start with the definition of a {\em parameterized optimization problem}. It is the parameterized analog of an optimization
problem used in the theory of approximation algorithms.
\begin{definition}[Parameterized Optimization Problem] A parameterized optimization problem is a computable function $\Pi : \Sigma^* \times \mathbb{N} \times \Sigma^* \mapsto \mathbb{R} \cup \{\pm \infty\}$. The instances of $\Pi$ are pairs $(I,k) \in \Sigma^* \times \mathbb{N}$ and a solution to $(I,k)$ which is simply a string $S \in \Sigma^*$ such that $|S| \leq |I|+k$.
\end{definition}
The {\em value} of a solution $S$ is $\Pi(I,k,S)$. In this paper, all optimization problems are minimization problems. Therefore, we present the rest of the section only with respect to parameterized \emph{minimization} problem.
The {\em optimum value} of $(I,k)$ is defined as:
$$\textsc{OPT}_{\Pi}(I, k)= \min_{S \in \Sigma^*,\, |S| \leq |I|+k} \Pi(I,k,S),$$
and an {\em optimum solution} for $(I,k)$ is a solution $S$ such that $\Pi(I,k,S)=\textsc{OPT}_{\Pi}(I, k)$. For a constant $c > 1$, $S$ is \emph{$c$-factor approximate} solution for $(I,k)$ if $\frac{\Pi(I, k, S)}{OPT_{\Pi}(I, k)} \le c$.
We omit the subscript $\Pi$ in the notation for optimum value if the problem under consideration is clear from the context.
For some parameterized optimization problems we are unable to obtain \textsf{FPT}\ algorithms, and we are also unable to find satisfactory polynomial time approximation algorithms. In this case one might aim for \textsf{FPT}\-approximation algorithms, algorithms that run in time $f(k)n^c$ and provide good approximate solutions to the instance.
\begin{definition}\label{def:fptAppx}
Let $\alpha \geq 1$ be constant. A fixed parameter tractable $\alpha$-approximation algorithm for a parameterized optimization problem $\Pi$ is an algorithm that takes as input an instance $(I,k)$, runs in time $f(k)|I|^{\mathcal{O}(1)}$, and outputs a solution $S$ such that $\Pi(I,k,S) \leq \alpha \cdot \mbox{{\sc OPT}}(I,k)$ if $\Pi$ is a minimization problem, and $\alpha \cdot \Pi(I,k,S) \geq \mbox{{\sc OPT}}(I,k)$ if $\Pi$ is a maximization problem.
\end{definition}
Note that Definition~\ref{def:fptAppx} only defines constant factor FPT-approximation algorithms. The definition can in a natural way be extended to approximation algorithms whose approximation ratio depends on the parameter $k$, on the instance $I$, or on both. Next, we define an {\em $\alpha$-approximate polynomial-time preprocessing algorithm} for a parameterized minimization problem $\Pi$ as follows.
\begin{definition}[$\alpha$-Approximate Polynomial-time Preprocessing Algorithm] \label{def:lossy-kernel}
Let $\alpha \ge 1$ be a real number and $\Pi$ be a parameterized minimization problem. An $\alpha$-approximate polynomial-time preprocessing algorithm is defined as a pair of polynomial-time algorithms, called the {\em reduction algorithm} and the {\em solution lifting algorithm}, that satisfy the following properties.
\begin{itemize}
\setlength{\itemsep}{-2pt}
\item Given an instance $(I,k)$ of $\Pi$, the reduction algorithm computes an instance $(I',k')$ of $\Pi$.
\item Given instances $(I,k)$ and $(I',k')$ of $\Pi$, and a solution $S'$ to $(I',k')$, the solution lifting algorithm computes a solution $S$ to $(I,k)$ such that $\frac{\Pi(I,k,S)}{\textsc{OPT}(I,k)} \leq \alpha \cdot \frac{\Pi(I',k',S')}{\textsc{OPT}(I',k')}$.
\end{itemize}
\end{definition}
We sometimes refer $\alpha$-approximate polynomial-time preprocessing algorithm kernel as \emph{$\alpha$-lossy rule} or \emph{$\alpha$-reduction rule}.
\section{Lower Bound on Inapproximability of {\textsc{Split Contraction}}\xspace}
\label{hardness_splt}
In this section, we show that for any $\delta>0$, {\textsc{Split Contraction}}\xspace parameterized by the solution size does not admit a factor $(5/4-\delta)$-{\textsf{FPT}}\xspace approximation algorithm, assuming \textsf{Gap-ETH}. Towards this, we give a polynomial time reduction from {\textsc{Multicolored Densest-$k$-Subgraph with Perfect Completeness}}\xspace, which is $k^{o(1)}$-factor {\textsf{FPT}}\xspace inapproximable (Corollary~\ref{lem:Gap-ETH result densest-color}). In the \textsc{Densest-$k$-Subgraph}\xspace\ problem, input is a graph $G$ and an integer $k$; and the goal is to find a subset $S$ of $V(G)$ of size $k$ such that $\textsf{Den}(S)\geq k^{-g(k)}$. Recall that we defined $\textsf{Den}(S)= |E(G[S])|/\binom{|S|}{2}$. \textsc{Densest-$k$-Subgraph with Perfect Completeness}\xspace is a special case of \textsc{Densest-$k$-Subgraph}\xspace\ problem, in which the input graph $G$ contains a $k$-clique, and it is known to be $k^{o(1)}$-factor {\textsf{FPT}}\xspace inapproximable~\cite{DBLP:journals/corr/abs-1708-04218}.
Now, we define a colorful version of \textsc{Densest-$k$-Subgraph with Perfect Completeness}\xspace. We call a set of edges \emph{colorful}, if all the edges in the set are colored with pairwise distinct colors. We say that a clique is \emph{colorful-clique}, if the set of edges in this clique is colorful.
In the {\textsc{Multicolored Densest-$k$-Subgraph with Perfect Completeness}}\xspace, an input graph $G$ is given with an edge coloring $\phi : E(G) \rightarrow [\binom{k}{2}]$, and $G$ is promised to have a colorful-$k$-clique. The goal is to find a subset $S$ of $V(G)$ of size $k$ such that the set $E(G[S])$ is colorful and $\textsf{Den}(S)\geq k^{-g(k)}$.
We start with the following known inapproximability result for \textsc{Densest-$k$-Subgraph with Perfect Completeness}\xspace.
\begin{proposition}[Lemma $5.21$ in \cite{DBLP:journals/corr/abs-1708-04218}] \label{Gap-ETH result densest} Assuming {\rm \textsf{Gap-ETH}}, for every function $g=o(1)$ and every function $f$, there is no $f(k)\cdot n^{\ensuremath{{\mathcal O}}(1)}$-time algorithm such that, given an integer $k$ and a graph $G$ with $n$ vertices containing a $k$-clique, always outputs a set $S$ of $k$ vertices such that $\textsf{Den}(S)\geq k^{-g(k)}$.
\end{proposition}
For notational convenience, let $t=\binom{k}{2}$. The size of $(|E(G)|, t)$-perfect hash family is bounded by $e^tt^{\ensuremath{{\mathcal O}}(\log t)} \cdot n^{\ensuremath{{\mathcal O}}(1)}$ \cite{naor1995splitters}. Using $(|E(G)|, t)$-perfect hash family and Proposition~\ref{Gap-ETH result densest}, we obtain the following result for {\textsc{Multicolored Densest-$k$-Subgraph with Perfect Completeness}}\xspace.
\begin{corollary}\label{lem:Gap-ETH result densest-color}
Assuming {\rm \textsf{Gap-ETH}}, for every function $g=o(1)$ and every function $f$, there is no $f(k)\cdot n^{\ensuremath{{\mathcal O}}(1)}$-time algorithm such that, given an integer $k$ and an edge colored graph $G$ with $n$ vertices containing a colorful-$k$-clique, always outputs a set $S$ of $k$ vertices such that $E(G[S])$ is colorful and $\textsf{Den}(S)\geq k^{-g(k)}$.
\end{corollary}
\begin{comment}
Recall that we defined $\textsf{Den}(S)= |E(G[S])|/\binom{|S|}{2}$.
\end{comment}
For a given subset $S$ of vertices, we say that $S$ \emph{spans} an edge, if both of its endpoints are in $S$.
Due to Corollary~\ref{lem:Gap-ETH result densest-color}, we obtain following result.
\begin{corollary}\label{cor:Gap-ETH result densest}
Assuming {\rm \textsf{Gap-ETH}}, for every $0<\epsilon <1 $, and for every function $f$, there is no $f(k)\cdot n^{\ensuremath{{\mathcal O}}(1)}$-time algorithm such that, given an integer $k$ and an edge colored graph $G$ with $n$ vertices containing a colorful-$k$-clique, always outputs a set $S$ of $k$ vertices which span at least $\epsilon \binom{k}{2}$ colorful edges.
\end{corollary}
In the following lemma, we strengthen the above result.
\begin{lemma}\label{lemma:original-problem}
Assuming {\rm \textsf{Gap-ETH}}, for every $0<\epsilon <1 $, $\alpha>1$ and every function $f$, there is no $f(k)\cdot n^{\ensuremath{{\mathcal O}}(1)}$-time algorithm such that, given an integer $k$ and an edge colored graph $G$ with $n$ vertices containing a colorful-$k$-clique, always outputs a set $S$ of at most $\alpha k$ vertices that spans at least $\epsilon \binom{k}{2}$ colorful edges.
\end{lemma}
\begin{proof}
Assume that there is a $f(k) \cdot n^{\ensuremath{{\mathcal O}}(1)}$-time algorithm, $\mathcal{A}$, that takes the input $(G, k)$ such that $G$ has a colorful-$k$-clique, and outputs a set $S$ of at most $\alpha k$ vertices, that spans at least $\epsilon \binom{k}{2}$ colorful edges. Partition the set $S$ into $\lceil 2\alpha \rceil$ sets $S_1,S_2,\cdots, S_{\lceil 2\alpha \rceil}$ each of size at most $\nicefrac{k}{2}$. As the set $S$ spans at least $\epsilon \binom{k}{2}$ colorful edges, there exists a pair of sets, say $S_i, S_j$, in this partition, such that $S_i\cup S_j$ spans at least $\epsilon'\binom{k}{2}$ colorful edges, where $\epsilon' = \nicefrac{\epsilon}{\binom{\lceil 2\alpha \rceil}{2}}$. Moreover, the size of $S_i\cup S_j$ is at most $k$. This implies that there exists an algorithm, that outputs a set of vertices of size at most $k$ that spans $\epsilon' \binom{k}{2}$ colorful edges, in time $f(k) \cdot n^{\ensuremath{{\mathcal O}}(1)}$.
Hence, the existence of such algorithm contradicts Corollary~\ref{cor:Gap-ETH result densest}.
\end{proof}
\begin{comment}
A set of edges is \emph{colorful} if all edges in the set are colored with pairwise different colors. Such set is also called as \emph{colorful edges}. For notational convenience, we fix \framebox{$t=\binom{k}{2}$} for remaining section. As the size of $(|E(G)|, t)$-perfect hash family is bounded by $e^tt^{\ensuremath{{\mathcal O}}(\log t)} \cdot n^{\ensuremath{{\mathcal O}}(1)}$ \cite{naor1995splitters}, we obtain following result for colorful version of the problem. We say that a clique is \emph{colorful-clique} if the set of edges in this clique is a set of colorful edges. Using $(|E(G)|, t)$-perfect hash family and Lemma~\ref{lemma:original-problem}, we obtain following result.
\begin{corollary}\label{cor:col-original-problem} Assuming \textsf{Gap-ETH}, for every $0<\epsilon <1 $, $\alpha>1$ and every function $f$, there is no $f(k)\cdot n^{\ensuremath{{\mathcal O}}(1)}$-time algorithm such that, given integer $k$ and an edge colored graph $G$ with $n$ vertices containing a colorful $k$-clique, always outputs a set $S$ of at most $\alpha k$ vertices that span at least $\epsilon \binom{k}{2}$ colorful edges.
\end{corollary}
In \textsc{Densest-$k$-Subgraph}\xspace\ problem, the input is a graph $G$ and integers $k, t$. The goal is to find a subset $S$ of $V(G)$ of $k$ vertices, which induce at least $t$ edges. Lemma~\ref{lemma:original-problem} states the in-approximability result for \textsc{Densest-$k$-Subgraph}\xspace\ problem. We note that the result holds for the special case when it is known that graph $G$ contains a $k$-clique. In the literature, this problem is known as \textsc{Densest-$k$-Subgraph with Perfect Completeness}\xspace.
We define a colorful version of \textsc{Densest-$k$-Subgraph}\xspace.
In this version, an input graph is given with an edge coloring $\phi : E(G) \rightarrow [t]$. The goal is to find subset $S$ of $V(G)$ of $k$ vertices which span at least $t$ colorful edges. In {\textsc{Multicolored Densest-$k$-Subgraph with Perfect Completeness}}\xspace\ it known that there exists a $k$-clique which spans $t$ colorful edges.
\end{comment}
Now, we are ready to give our reduction.
We argue that if {\textsc{Split Contraction}}\xspace parameterized by the solution size admits a factor $(\nicefrac{5}{4}-\delta)$-{\textsf{FPT}}\xspace approximation algorithm for some $\delta$, then it contradicts Lemma~\ref{lemma:original-problem},
and hence \textsf{Gap-ETH}. Towards this, we present a reduction in which given an instance $(G,k)$ of {\textsc{Multicolored Densest-$k$-Subgraph with Perfect Completeness}}\xspace, and a constant $\delta$, constructs an instance $(G',k')$ of {\textsc{Split Contraction}}\xspace.
\begin{comment}
Note that $k$-clique in $G$ which spans $t$ colorful edges is not provided explicitly and hence reduction algorithm can not use it.
For notational simplicity, we present the reduction from {\textsc{Multicolored Densest-$k$-Subgraph}}\xspace\ to {\textsc{Split Contraction}}\xspace and prove the relation between the approximate solution for these two problems. We use the existence of such $k$-clique to argue the correctness of Theorem~\ref{thm:split-hardness}.
\end{comment}
\vspace{0.3cm}
\noindent \textbf{Reduction Algorithm:} Given an instance $(G,k)$ of {\textsc{Multicolored Densest-$k$-Subgraph with Perfect Completeness}}\xspace,
and a constant $\delta > 0$, the algorithm constructs a graph $G'$ as follows. Recall that $t=\binom{k}{2}$.
\begin{itemize}
\setlength{\itemsep}{-2pt}
\item Fix $\rho=\lceil \nicefrac{\delta t}{k}\rceil$, $k' = 2t + \rho k$, and $k^{\circ}=\lceil \nicefrac{5}{2}\cdot k'\rceil+2$.
\item For every vertex $u$ in $V(G)$, add $\rho$ copies of it to $V(G')$ and convert them into a clique. Formally, define $X_u := \{u_1,\cdots, u_{\rho}\}$ for every vertex $u$ in $V(G)$. Let $Z=\cup_{u \in V(G)} X_u$. We add $k^\circ +2$
extra vertices in $Z$.
For every pair of vertices $z_1, z_2 \in Z$, add an edge $z_1z_2$ to $E(G')$. That is, the vertices in $Z'$ form a clique.
\item For every vertex $z$ in $Z$, we add $k^{\circ}$ pendant vertices $y_1, \cdots, y_{k^{\circ}}$ to $V(G')$.
We
denote the set of these vertices as $\mathtt{Guard}_V$. We also add edges $zy_1,\cdots,zy_{k^{\circ}}$ to $E(G')$.
\item For a given coloring function $\phi : E(G) \rightarrow [t]$, let $E_i$ denote the set of edges, which are assigned color $i$. For every $i \in [t]$, we create a set of vertices ${\mathtt{ES}}\xspace_i$ as follows. We add a vertex $w_e$ corresponding to every edge $e$ in $E_i$. Formally, ${\mathtt{ES}}\xspace_i=\{w_e\mid e\in E_i\}$. For every $i \in [t]$, we add ${\mathtt{ES}}\xspace_i$ to $V(G')$.
We call these sets {\em edge selector sets}. Let $e=uv$ be an edge in $G$, we add all the edges between $w_e$ and the vertices in $Z\setminus(X_u\cup X_v)$ to $E(G')$.
Let ${\mathtt{ES}}\xspace=\cup_{i\in[t]}\mathtt{ES}_i$.
\item
For every ${\mathtt{ES}}\xspace_i$, we add a vertex $g_i$ to $V(G')$. We call this vertex {\em cap vertex}\xspace, corresponding to ${\mathtt{ES}}\xspace_i$. We also add all the edges between $g_i$ and the vertices in ${\mathtt{ES}}\xspace_i$. We denote the set of cap vertices by $\mathtt{Cap}$.
\item For every cap vertex $g_i$ in $V(G')$, we add $k^{\circ}$ pendant vertices $y_i^1,\cdots,y_i^{k^{\circ}}$ to $V(G')$. We
denote the set of these vertices as $\mathtt{Guard}_E$. We also add edges $g_iy_i^1,\cdots,g_iy_i^{k^{\circ}}$ to $E(G')$.
\item We add a set of $t$ {\em special vertices}\xspace, ${\mathtt{SV}}\xspace=\{s_1,\cdots,s_t\}$ to $V(G')$. We add all the edges between $s_i$ and the vertices in ${\mathtt{ES}}\xspace_i$, where $i\in [t]$. We add edges between every pair of vertices in ${\mathtt{SV}}\xspace$, that is, for all $s_i,s_j \in {\mathtt{SV}}\xspace$, we add an edge $s_is_j$ to $E(G')$. That is, the vertices in ${\mathtt{SV}}\xspace$ form a clique.
We call $s_i$ as {\em special vertex}\xspace corresponding to ${\mathtt{ES}}\xspace_i$.
\item For every special vertex $x$ in ${\mathtt{SV}}\xspace$, we add $k^{\circ}$ pendant vertices $x_1,\cdots,x_{k^{\circ}}$ to $V(G')$. We
denote the set of these vertices as $\mathtt{Guard}_S$. We also add edges $xx_1,\cdots,xx_{k^{\circ}}$ to $E(G')$.
\end{itemize}
This completes the construction. Reduction algorithm returns $(G', k')$ as an instance of {\textsc{Split Contraction}}\xspace. See Figure~\ref{fig:split-hardness} for an illustration.
\begin{figure}[t]
\centering
\includegraphics[scale=0.75]{./images/split-hardness.pdf}
\caption{Sets with rectangular boundary represent cliques whereas sets with elliptical boundary represent independent sets. A vertex $w_{uv}$, corresponding to an edge $uv$, is adjacent to all vertices in $Z$ except the ones in $X_u \cup X_v$. Dashed lines shows non-adjacency between the vertex and sets. Please refer to reduction from {\textsc{Multicolored Densest-$k$-Subgraph with Perfect Completeness}}\xspace to {\textsc{Split Contraction}}\xspace for details. \label{fig:split-hardness}}
\end{figure}
Note that without loss of generality, we can assume that for a given instance $(G, k)$ of {\textsc{Multicolored Densest-$k$-Subgraph with Perfect Completeness}}\xspace, graph $G$ contains at least $k + 1$ vertices, and $k$ is not a constant.
\begin{lemma}\label{lem:fwd}
Let $(G', k')$ be the instance of {\textsc{Split Contraction}}\xspace returned by the reduction algorithm mentioned above when the input is $(G, k)$ and $\delta>0$. Then, there exists a set of edges $F'$ in $G'$ of size most $k'$, such that $G'/F'$ is a split graph.
\end{lemma}
\begin{comment}
\begin{lemma}\label{lem:fwd}
Let $(G', k')$ be the instance of {\textsc{Split Contraction}}\xspace returned by the reduction algorithm mentioned above when input is $(G, k, t)$ and $\delta$. If $G$ contains a colorful $k$-clique then there exists a set of edges $F'$ in $G'$ such that $G'/F'$ is a split graph and size of $F'$ is at most $k'$.
\end{lemma}
\end{comment}
\begin{proof}
Let $S = \{u^1,\cdots,u^k\}$ be a set of vertices that induces a colorful-$k$-clique in $(G,k)$.
Let $E_S = \{e_1,\cdots, e_t\}$ be the set of edges in $G[S]$. Since $E_S$ is a set of colorful edges, let $e_i\in E_i$, where $i$ in $[t]$.
Let ${W}=\{w_{e_i}\in V(G')\mid e_i\in E_S\}$, we construct a solution $F'$ to $(G',k')$ as follows. For every $w_{e_i}\in {W}$, add the edges $w_{e_i}g_i, w_{e_i}s_i \in E(G')$ to $F'$, where $g_i$ is the {cap vertex}\xspace corresponding to ${\mathtt{ES}}\xspace_i$, and $s_i$ is the {special vertex}\xspace corresponding to ${\mathtt{ES}}\xspace_i$.
Note that we have added $2t$ edges to $F'$.
As the number of vertices in $V(G)$ is at least $k + 1$, there exists a vertex, say $u_0$, in $V(G) \setminus S$.
Consider a vertex $z_0$ in $X_{u_0}$ in graph $G'$.
For every vertex $u$ in $S$, we add the edges $\{u_1z_0,\cdots,u_\rho z_0\}$ to $F'$.
Thus, for every $u\in S$, we have added $\rho$ edges to $F'$. Hence, $|F'|= 2t+\rho k= k'$.
We now show that $G'/F'$ is a split graph. Let $\mathtt{New}$ be the set of new vertices that are introduced in $G'\slash F'$ by contracting edges in $F'$. Let $C=(Z\setminus (\cup_{u\in S}X_u\cup \{z_0\}))\cup \mathtt{New}$. Let $I = \mathtt{Guard}_V \cup\ \mathtt{Guard}_E \cup\ \mathtt{Guard}_S \cup\ ({\mathtt{ES}}\xspace\setminus {W})$. We claim that $(C,I)$ is a split partition of $G'\slash F'$. By the construction of $G'$, $V(G')=Z\cup\ {\mathtt{ES}}\xspace \cup\ \mathtt{Cap} \cup\ {\mathtt{SV}}\xspace \cup\ \mathtt{Guard}_V\cup\ \mathtt{Guard}_E \cup\ \mathtt{Guard}_S$. Since $\{z_0\}\cup (\cup_{u\in S}X_u) \cup W \cup\ \mathtt{Cap} \cup\ {\mathtt{SV}}\xspace \subseteq V(F')$, we know that $(C,I)$ is a partition of $G'\slash F'$.
As $I$ is an independent set in $G'$ and no edges incident to $I$ are contracted, this set is also an independent set in $G'/F'$.
We now argue that $C$ is a clique in $G'$.
Since every pair of vertices in $Z$ is adjacent to each other in $G'/F'$, if the vertices $u, v$ are in $Z\setminus \mathtt{New}$, then they are adjacent to each other in $G'/F'$.
Consider a vertex $u$ in $\mathtt{New}$; we have the following two cases.
\noindent {\color{blue}\textsl{Case (A): Vertex $u$ is obtained by contracting $w_{e_i}g_i$ and $w_{e_i}s_i$ for some edge $e_i (= xy)$ in $E_i$}}.
By the construction of $G'$, the vertex $w_{e_i}$ is adjacent to all the vertices in $Z\setminus (X_x\cup X_y)$ of the graph $G'$. Hence, $u$ is adjacent to all the vertices, which are in $Z \setminus (X_x \cup X_y)$, thus, $u$ is adjacent to all the vertices in $Z\setminus (\cup_{u\in S}X_u\cup \{z_0\})$. We now show that $u$ is also adjacent to all the vertices in $\mathtt{New}$. Let $v \in \mathtt{New}$, and suppose that $v$ is a vertex obtained by contracting $w_{e_j}g_j$ and $w_{e_j}s_j$, where $e_j\in E_S$. Since $s_i,s_j$ are in ${\mathtt{SV}}\xspace$, $s_is_j\in E(G')$, $u,v$ are adjacent to each other in $G'\slash F'$. Now, suppose that $v$ is obtained by contracting $x_iz_0$, where $x\in S$ and $i\in [\rho]$. Since $u_0 \notin S$, $z_0$ is adjacent to $w_{e_i}$, $uv$ is an edge in $E(G'\slash F')$.
\noindent{\color{blue}\textsl{Case (B): Vertex $u$ is obtained by contracting the edge $x_iz_0$, where $x\in S$}}. Since $z_0\in Z$, $u$ is adjacent to all the vertices in $Z\setminus (\cup_{u\in S}X_u\cup \{z_0\})$. Now, consider another vertex $v\in \mathtt{New}$. Note that as $u,v$ are two different vertices in $V(G'\slash F')$, $v$ can not be obtained by contracting $y_iz_0$ for any $y\in S$. Thus, $v$ is obtained by contracting $w_{e_j}g_j$ and $w_{e_j}s_j$, where $e_j\in E_S$. Then, as argued above $uv$ is an edge in $E(G'\slash F')$ (we only need to interchang $u$ and $v$ in the previous argument). Hence, any two vertices in $C$ are adjacent.
This implies that $(C, I)$ is a split partition of $G'/F'$, and hence $G'/F'$ is a split graph. Since the number of edges in $F'$ is at most $k'$, this proves the lemma.
\end{proof}
\begin{comment}
\todo{I think we don't need Claim 5.3. Because, our good case is that witness set contains exactly one cap vertex, no vertex of Z, and exactly one vertex of ES. Witness set of size 2 which contains a cap vertex qualifies this.}
\begin{claim}\label{claim:edge-selector-big} For every cap vertex $g_i$, there exists $u^i_e$ in such that $g_iu^i_e$ is in $F'$ and there exists an edge other than $g_iu^i_e$ in $F'$ which is incident to $u^i_e$.
\end{claim}
\begin{proof}
\end{proof}
\begin{figure}[t]
\centering
\includegraphics[scale=0.05]{./images/edge-selector-big.jpg}
\caption{See Lemma~\ref{lemma:edge-selector-big}, Condition $(b)$ \label{fig:edge-selector-big}}
\end{figure}
\begin{lemma}\label{lemma:edge-selector-big} For every cap vertex $g_i$, there exists $u^i_e$ in such that $g_iu^i_e$ is in $F'$ and there exists an edge other than $g_iu^i_e$ in $F'$ which is incident to $u^i_e$.
\end{lemma}
\begin{proof}
By Lemma~\ref{lemma:cap-vertex-solution-edge}, for every cap vertex $g_i$, there exists at least one vertex $u_e$ in ${\mathtt{ES}}\xspace_i$ such that $g_iu_e$ is in $F'$. For the sake of contradiction, assume that there exists $i$ such that for any $g_iu_e$ is in $F'$, it is the only edge in $F'$, which is incident to $u_e$. In other words, $W(\psi(g_i))$ is contained in neighborhood of $g_i$. Hence, for $j \neq i$, $W(\psi(g_i))$ does not intersect with $W(\psi(g_j))$. By Lemma~\ref{lemma:cap-vertex-solution-edge}, both $\psi(g_i)$ and $\psi(g_j)$ are in $\tilde{C}$.
This implies for every $j \neq i$ in $[t]$, there exists a vertex in $W(\psi(g_j))$ which is adjacent to $W(\psi(g_i))$. Only vertices which are adjacent to $W(\psi(g_i))$, apart from $s_i$ and pendant neighbors of $g_i$, are in $Z$. Hence, there are at least $t - 2$ cap vertices $g_j$ such that $W(\psi(g_j))$ intersects $Z$. For any cap vertex $g_j$, one of following two conditions hold. $(a)$ There exists $u_j$ in ${\mathtt{ES}}\xspace_j$ such that edges $g_ju_j, u_jz$ are in $F'$. $(b)$ There exists $g_{j'}$ such that $\psi(g_{j'}) = \psi(g_j)$; $g_{j'}$ satisfy Condition~$(a)$; and there exists $u_j$ in ${\mathtt{ES}}\xspace_j$ such that vertices $g_j, u_j, s_j, s_{j'}, u_{j'}$ are in $V(F')$, where $u_{j'}$ is a vertex in ${\mathtt{ES}}\xspace_{j'}$ such that $g_{j'}u_{j'}$ is in $F'$. See Figure~\ref{fig:edge-selector-big}.
Without loss of generality, we can assume that $F'$ contains edges $g_ju_j, u_js_j, s_js_{j'}, s_{j'}u_{j'}$.
We partition $t - 2$ cap vertices into $Cap_1$ and $Cap_2 $ depending on whether they satisfy condition $(a)$ or $(b)$. If a cap vertex satisfy both conditions then we include it in $Cap_1$.
Fix a function $\lambda$ as specified after Claim~\ref{claim:special-vertex-t-edges}. The existence of such a function is guaranteed by Claim~\ref{claim:special-vertex-t-edges}.
We modify this function, without changing its property, for certain vertices in ${\mathtt{SV}}\xspace$.
Consider a cap vertex $g_i$ in $Cap_1$.
Let $u_j$ in ${\mathtt{ES}}\xspace_j$ such that edges $g_ju_j, u_jz$ are in $F'$.
The edge $u_jz$ is not incident to cap or special vertices, and hence it is in \texttt{extra edges}\ for any function $\lambda$. Since ${\mathtt{ES}}\xspace_j$s are disjoints different $j$s in $[t]$, for every cap vertex in $Cap_1$, there is an edge in $\texttt{extra edges}$. Consider a cap vertex $g_{j}$ in $Cap_2$. We know that edges $u_js_j, s_js_{j'}, s_{j'}u_{j'}$ are present in $F'$. We modify $\lambda$ to define $\lambda(s_j) = u_js_j$ and $\lambda(s_{j'}) = u_{j'}s_{j'}$ if it was not the case. Note that these edges are only incident to $s_j, s_{j'}$, and hence were not in the range of $\lambda$. An edge $s_js_{j'}$ is in $\texttt{extra edges}$ as both of its endpoints are assigned a value by $\lambda$. This implies that for every cap vertex in $Cap_2$, there exists an edge which is in $\texttt{extra edges}$. Hence, there are at least $t - 2$ $\texttt{extra edges}$ with respect to $\lambda$.
This leads to a contradiction as there are at most $(\nicefrac{1}{2} - \gamma) \cdot t < t - 2$ \texttt{extra edges}\ with respect to any such function. We assume that $(\nicefrac{1}{2} - \gamma) \cdot t < t - 2$ as otherwise $t$ is bounded by some small constant which results in trivial instances. Hence, our assumption is wrong which concludes the proof of the lemma.
\end{proof}
\end{comment}
In the following lemma, we argue that given an approximate solution for an instance of {\textsc{Split Contraction}}\xspace, one can obtain a set of $\alpha k$ vertices, $\alpha > 1$, that spans at least $\epsilon t$ colorful edges, where $0<\epsilon < 1$.
\begin{lemma}\label{lem:rev}
Let $(G', k')$ be an instance of {\textsc{Split Contraction}}\xspace returned by the reduction algorithm mentioned above when the input is $(G, k)$ and $\delta >0$. If there exists a set of edges $F'$ in $G'$ such that $G'/F'$ is a split graph and size of $F'$ is at most $(\nicefrac{5}{4} - \delta)k'$, then there exists a set of at most $\nicefrac{1}{\delta}\cdot k$ vertices in $G$ that spans at least $\nicefrac{3\delta}{2} \cdot t$ colorful edges.
\end{lemma}
We establish some properties of the instance of {\textsc{Split Contraction}}\xspace\ that is returned by the reduction algorithm and its solution before presenting proof of Lemma~\ref{lem:rev}.
In Claims~\ref{claim:clique-side-ver} to \ref{claim:disjoint-from-Z}, we use the following notation:
The reduction algorithm returns $(G', k')$, when input is $(G, k)$, and $\delta$. Let $F'$ be a set of edges in $G'$ such that $G'/F'$ is a split graph and size of $F'$ is at most $(\nicefrac{5}{4} - \delta) \cdot k'$. Let $\mathcal{W}$ be the $G'/F'$-witness structure of $G'$.
Let $\psi : V(G') \rightarrow V(G'/F')$ be the onto function corresponding to contracting all the edges in $F'$.
For a vertex $\tilde{w}$ in $V(G'/F')$, $W(\tilde{w})$ denotes the witness set which is contracted to obtain the vertex $\tilde{w}$.
Hence, for a vertex $u$ in $V(G')$, if $u \in W(\tilde{w})$ then $\psi(u) = \tilde{w}$.
We fix a split partition $(\tilde{C}, \tilde{I})$ of $V(G'/F')$.
Note that $|F'|+2 \leq 2|F'| \le 2 (\nicefrac{5}{4} - \delta)k' \le \nicefrac{5}{2}k' \le k^{\circ}$. Hence, there are at least
$|F'| + 2$ many pendant vertices adjacent to every cap vertices, special vertices, and every vertex in $Z$ of $G'$. Moreover, since the size of $Z$ is at least $k^{\circ}+2$, there exists at least one vertex in $Z$ which is not in $V(F')$. Let $z^{\star}$ be one such vertex in $V(G')$ which is in $Z \setminus V(F')$. Note that $W(\psi(z^{\star}))= \{z^{\star}\}$.
We refer readers to Section~\ref{sec:intro} for an overview of the proof.
Consider a cap vertex $g_i$ and the witness set $W(\psi(g_i))$.
A cap vertex $g_i$ is said to be \emph{spoiled}, if $W(\psi(g_i))$ either $(a)$ contains another cap vertex;
$(b)$ intersects with $Z$; or
$(c)$ has more than one vertex from ${\mathtt{ES}}\xspace$.
We bound the number of cap vertices that can be spoiled because of $(a), (b)$ or $(c)$ in Claims~\ref{claim:multi-cap}, \ref{claim:intersect-with-Z}, and \ref{claim:disjoint-from-Z}, respectively.
We first present few results, which are used in the proof of these claims.
\begin{claim}\label{claim:clique-side-ver} If $u \in V(G')$ is either a cap vertex or a special vertex or in $Z$, then $\psi(u)$ is in $\tilde{C}$.
\end{claim}
\begin{proof} Any such vertex $u$ is adjacent to $|F'| + 2$ many pendant vertices. This implies that there are at least two pendant vertices, say $u_1, u_2$, which are not in $V(F')$, which in turn implies that $W(\psi(u_1))$ and $W(\psi(u_2))$ are singleton sets in $\mathcal{W}$. Since $u_1, u_2$ are not adjacent to each other in $G'$ and $W(\psi(u_1)), W(\psi(u_2))$ are singleton witness sets, $\psi(u_1)$, $\psi(u_2)$ are not adjacent to each other in $G'/F'$. Hence, at most one of them can be in $\tilde{C}$. Without loss of generality, let $\psi(u_1)$ is in $\tilde{I}$. Since $u$ is adjacent to $u_1$ in $G'$, and $u$ is not contained in $\psi(u_1)$, $\psi(u)$ is adjacent to $\psi(u_1)$. This implies $\psi(u)$ is in $\tilde{C}$.
\end{proof}
\begin{claim}\label{claim:cap-vertex-solution-edge} For every cap vertex $g_i$ there exists a vertex $u_e$ in ${\mathtt{ES}}\xspace_i$ such that $g_iu_e$ is in $F$.
\end{claim}
\begin{proof} Recall that $\psi(z^{\star})$ is a vertex in $\tilde{C}$ and $W(\psi(z^{\star}))$ is a singleton witness set.
Assume that for a cap vertex $g_i$, there is no vertex $u_e$ in ${\mathtt{ES}}\xspace_i$ such that edge $g_iu_e$ is in $F$. This implies that $\psi(g_i) \cap {\mathtt{ES}}\xspace_i$ is an empty set. Since neighbors of $g_i$ outside ${\mathtt{ES}}\xspace_i$ (i.e. pendant neighbors of $g_i$) are not adjacent to $z^{\star}$ in $G'$, there is no edge with one endpoint in $W(\psi(g_i))$ and another one in $W(\phi(z^{\star}))$.
But by Claim~\ref{claim:clique-side-ver}, both $\psi(z^{\star})$ and $\psi(g_i)$ are in $\tilde{C}$. This contradicts the fact that $\tilde{C}$ is a clique. Hence, our assumption is wrong, which concludes the proof of the claim.
\end{proof}
\begin{claim}\label{claim:special-vertex-solution-edge} For every special vertex $s_i$ there exists a vertex $u_e$ in ${\mathtt{ES}}\xspace$ such that $u_e$ is in $W(\psi(s_i))$.
\end{claim}
\begin{proof} For the sake of contradiction, assume that there exists a witness set, say $W(\psi(s_i))$ such that $W(\psi(s_i)) \cap {\mathtt{ES}}\xspace =\emptyset$.
Recall that $\psi(z^{\star})$ is a vertex in $\tilde{C}$ and $W(\psi(z^{\star}))$ is a singleton witness set. Since $W(\psi(s_i))$ does not contain any vertex of ${\mathtt{ES}}\xspace$, $W(\psi(s_i)) \subseteq \mathtt{SV}\cup \mathtt{Guard}_S$. Hence,
there is no edge with one endpoint in $W(\psi(s_i))$ and another one in $W(\psi(z^{\star}))$.
By Claim~\ref{claim:clique-side-ver} both $\psi(s_i)$ and $\psi(z^{\star})$ are in $\tilde{C}$. This contradicts the fact that $\tilde{C}$ is a clique. Hence, our assumption is wrong, which concludes the proof of the claim.
\end{proof}
\begin{claim}\label{claim:special-vertex-t-edges} There are at least $2t$ edges in $F'$, which are incident to either cap vertices, or special vertices. Moreover, every vertex can be assigned to an edge in $F'$, which is unique to it.
\end{claim}
\begin{proof} By Claim~\ref{claim:cap-vertex-solution-edge}, there are at least $t$ edges incident to cap vertices. Since a cap vertex is neither adjacent to other cap vertex nor to a special vertex, a cap vertex can be uniquely mapped to the edge incident to it.
Consider a special vertex $s_i$. Define $S = W(\psi(s_i)) \cap {\mathtt{SV}}\xspace$.
By Claim~\ref{claim:special-vertex-solution-edge}, $W(\psi(s_i))$ contains a vertex, say $u_e$, which is in $\mathtt{ES}$. Hence, there is an additional edge, which is incident to $S$.
Without loss of generality, we can assume that $F'$ contains a spanning tree of $G'[S \cup \{u_e\}]$. This implies that there is at least $|S|$ many edges incident to $S$. To assign each vertex to a unique edge, we root this spanning tree at $u_e$. For every vertex in $S$, assign it to the edge connecting that vertex to its parent in this rooted tree.
Since witness structure $\mathcal{W}$, partitions ${\mathtt{SV}}\xspace$, there are at least $|{\mathtt{SV}}\xspace| = t$ edges in $F'$ which has at least one endpoint in ${\mathtt{SV}}\xspace$. Note that none of these edges is incident to cap vertices. This concludes the proof.
\end{proof}
Claim~\ref{claim:special-vertex-t-edges} allows us to define an \emph{one-to-one} function $\lambda$ from the set of cap vertices and special vertices to the edges in $F'$ such that $\lambda(v)$ is an edge incident to $v$. We call such functions as \emph{accounting function}s.
We use such a function in the following arguments to bound certain kinds of witness sets.
For an accounting function $\lambda$, the set of edges in $F'$ which do not belong to the range of $\lambda$ are called \texttt{extra edges}.
We fix a function $\lambda$ and modify it in Claim~\ref{claim:multi-cap}~and~\ref{claim:disjoint-from-Z} at certain vertices of special vertices to obtain another accounting function. We use the number of edges in \texttt{extra edges}\ with respect to this function to argue that the number of spoiled cap vertices is not very large.
Let $\gamma = \nicefrac{3\delta}{4}$.
Note that, for any accounting function $\lambda$, the number of edges in \texttt{extra edges}\ is at most $|F'|- 2t \le (\nicefrac{5}{4} - \delta)k' -2t \le (\nicefrac{5}{4} - \delta) \cdot (2t + \rho k)-2t \le (\nicefrac{1}{2})t - (\nicefrac{3\delta}{4})t = (\nicefrac{1}{2} - \gamma) \cdot t$. If an edge is not incident to cap or special vertex then such an edge is always in \texttt{extra edges}\ for any accounting function.
\begin{claim} \label{claim:multi-cap}
Let $\mathtt{\mathtt{Cap}_1}$ be a subset of $\mathtt{Cap}$ such that every vertex in $\mathtt{Cap}_1$ is in a witness set in $\cal W$ that contains at least two cap vertices. Then, $F'$ contains at least $\nicefrac{1}{2}\cdot |\mathtt{Cap}_1|$ edges in {\rm $\texttt{extra edges}$} for an accounting function $\lambda$.
\end{claim}
\begin{proof}
Let $\mathcal{W}_1$ be the collection of witness sets in $\mathcal{W}$ which contains at least two cap vertices. Clearly, $|{\cal W}_1|\leq \nicefrac{1}{2}\cdot |\mathtt{Cap}_1|$. Consider a witness set $W(p)$ in $\mathcal{W}_1$, we argue that there are at least $|W(p)\cap \mathtt{Cap}_1|-1$ many edges in ${\rm \texttt{extra edges}}$ incident to the vertices of $W(p)$ for an accounting function $\lambda$.
Consider the accounting function $\lambda$ which is constructed/modified before considering $W(p)$. We modify this accounting function
for some vertices in ${\mathtt{SV}}\xspace$ to obtain another accounting function. Let $T$ be a spanning tree of $G'[W(p)]$ such that $E(T)\subseteq F'$. We arbitrarily fix a cap vertex $g_o$ in $W(p)$ and the root of $T$ at $g_o$.
Consider a cap vertex $g_i$ and let $g_j$ be the first cap vertex on the unique path from $g_i$ to $g_o$ in $T$(Note that $g_j$ can be equal to $g_o$).
Let $P_{g_ig_j}$ be the unique path between $g_i$ and $g_j$ in the tree $T$.
By the construction of $G'$,
there exists a vertex $u^i_e$ in ${\mathtt{ES}}\xspace_i$ such that $g_iu^i_e$ is an edge in $E(P_{g_ig_j})$. We modify $\lambda$ in a way that there exists an edge incident to $u^i_e$ which is in \texttt{extra edges}. Since $u^i_e$ is not in the domain of accounting function, this edge in \texttt{extra edges}\ is unique to $g_i$.
Hence, for every cap vertex in $W(p) \cap \mathtt{Cap}_1$ except for $g_o$, there is an edge in \texttt{extra edges}\ with respect to an accounting function $\lambda$.
Consider the path $P_{g_ig_j}$ between $g_i$ and $g_j$ in the spanning tree $T$. Clearly, there exists a vertex $u_e^i \in {\mathtt{ES}}\xspace_i$ and a vertex $w\in Z \cup \{s_i\}$ such that $g_iu_e^i, u_e^iw \in E(P_{g_ig_j})$, otherwise there cannot be a path between $g_i$ and $g_j$.
If $w\in Z$, then $u_e^iw$ is in $\texttt{extra edges}$ for $\lambda$. Suppose that $w= s_i$. Then, in the path $P_{g_ig_j}$, either $s_i$ is adjacent to $u_{e'}^i \in {\mathtt{ES}}\xspace_i$ or a special vertex $s_q \in {\mathtt{SV}}\xspace$, then $s_iu_{e'}^i \in E(P_{g_ig_j})$. Note that either $s_iu_e^i$ or $s_iu_{e'}^i $ is in \texttt{extra edges}\ for $\lambda$.
Now, suppose that $s_is_q \in E(P_{g_ig_j})$.
If $\lambda(s_i)=s_is_q$, then $s_iu_e^i$ is in $\texttt{extra edges}$ for $\lambda$. Suppose that $\lambda(s_i)=s_iu_e^i$. Now, we modify $\lambda$ to obtain $\lambda(s_i)=s_is_q$.
We denote the successor and predecessor of a vertex $s$ in the path $P_{g_ig_j}$ by $\mathtt{succ}[s]$ and $\mathtt{pred}[s]$, respectively. Let $s_\ell$ be the first special vertex in the path $P_{g_ig_j}$ such that either $\lambda(s_\ell)=s_\ell \mathtt{succ}[{s_\ell}]$ or $\mathtt{succ}[{s_\ell}] \in {\mathtt{ES}}\xspace_\ell$.
Let $\mathtt{\widetilde{SV}}$ be the set of the vertices in the subpath of $P_{g_ig_j}$ from $s_i$ to $s_\ell$. For every special vertex $s$ in $\mathtt{\widetilde{SV}}$, we set $\lambda(s)=s\mathtt{succ}[s]$.
Note that $\lambda$ is still a \emph{one-to-one} function as earlier either $s_\ell \mathtt{pred}[s_\ell]$ (when $\lambda(s_\ell)=s_\ell \mathtt{succ}[{s_\ell}]$) or $s_\ell\mathtt{succ}[{s_\ell}]$ (when $\lambda(s_\ell)=s_\ell \mathtt{pred}[{s_\ell}]$, and $\mathtt{succ}[{s_\ell}] \in {\mathtt{ES}}\xspace_\ell$) was not in the range of $\lambda$.
Now, since $\lambda(s_i)=s_is_q$, $s_iu_e^i$ is in $\texttt{extra edges}$ for the modified $\lambda$.
This implies that for any cap vertex $g_i\neq g_0$ there is an edge incident to $u_e^i$ which is in $\texttt{extra edges}$ for an accounting function $\lambda$.
Hence, $F'$ has at least $|W(p)\cap \mathtt{Cap}_1|-1$ edges in $\texttt{extra edges}$.
By the above discussion, for every witness set $W(p) \in {\cal W}_1$, $F'$ has at least $|W(p)\cap \mathtt{Cap}_1|-1$ edges in $\texttt{extra edges}$ for the function $\lambda$. Since $\mathcal{W}$ partitions vertices in $\mathtt{Cap}$, we can infer that $F'$ has at least $|\mathtt{Cap}_1|-|{\cal W}_1|$ edges in $\texttt{extra edges}$ for the function $\lambda$.
\end{proof}
\begin{claim}\label{claim:intersect-with-Z}
Let $\mathtt{Cap}_2$ be a subset of $\mathtt{Cap}$ such that every vertex in $\mathtt{Cap}_2$ is in a witness set in $\cal W$ that intersects with $Z$ and contains exactly one cap vertex. Then, $F'$ contains at least $|\mathtt{Cap}_2|$ edges in {\rm $\texttt{extra edges}$} for any function $\lambda$.
\end{claim}
\begin{proof}
Let $\mathcal{W}_2$ be the collection of witness sets in $\mathcal{W}$ that intersects with $Z$ and contains exactly one cap vertex. Consider a witness set $W(p)$ in $\mathcal{W}_2$ and let $z$ be a vertex in $W(p) \cap Z$.
Hence, $F'$ contains at least one edge incident to $z$. For any function $\lambda$, an edge incident to a vertex of $Z$ is in $\texttt{extra edges}$ as the vertices of $Z$ are neither adjacent to cap vertices nor special vertices. This implies that $F'$ contains an edge in $\texttt{extra edges}$ that is incident to a vertex of $W(p)$.
Since $\mathcal{W}$ partitions vertices in $\mathtt{Cap}_2$, and every witness set in $\mathcal{W}_2$ contains exactly one cap vertex, $F'$ has at least $|\mathtt{Cap}_2|$ edges in $\texttt{extra edges}$ for the function $\lambda$.
\end{proof}
\begin{claim}\label{claim:disjoint-from-Z}
Let $\mathtt{Cap}_3$ be a subset of $\mathtt{Cap}$ such that every vertex in $\mathtt{Cap}_3$ is in a witness set in $\cal W$ that is disjoint from $Z$; contains exactly one cap vertex; and
at least two vertices of $\mathtt{ES}$. Then, $F'$ contains at least $|\mathtt{Cap}_3|$ edges in {\rm $\texttt{extra edges}$} for a function $\lambda$.
\end{claim}
\begin{proof}
Let $\mathcal{W}_3$ be a collection of witness sets in $\mathcal{W}$ that are disjoint from $Z$; contains exactly one cap vertex; and at least two vertices of $\mathtt{ES}$.
Consider a witness set $W(p)$ in $\mathcal{W}_3$. We argue that $F'$ has at least one edge in {\rm $\texttt{extra edges}$} that is incident to a vertex of $W(p)$ for a function $\lambda$.
Let $T$ be a spanning tree of $G'[W(p)]$ such that $E(T)\subseteq F'$.
Consider the accounting function $\lambda$ which is constructed/modified before considering $W(p)$. Let $g_i$ be the cap vertex contained in $W(p)$.
By Claim~\ref{claim:cap-vertex-solution-edge}, there exists $u_e^i \in {\mathtt{ES}}\xspace_i$ such that $g_iu_e^i \in F'$.
We consider two cases depending on whether another vertex in ${\mathtt{ES}}\xspace \cap W(p)$ is in ${\mathtt{ES}}\xspace_i$ or not.
Suppose that there exists a vertex $u_{e'}^i \in {\mathtt{ES}}\xspace_i \cap W(p)$ such that $u_{e'}^i\neq u_{e}^i$ and
if $g_iu_{e'}^i \in E(T)$, then either $g_iu_{e}^i$ or $g_iu_{e'}^i$ is in $\texttt{extra edges}$ for $\lambda$. Suppose that $g_iu_{e'}^i \notin E(T)$ and consider a path from $g_i$ to $u_{e'}^i$, say $P_{g_iu_{e'}^i}$, in the spanning tree $T$. Since $W(p)$ does not intersect with $Z$, $E(P_{g_iu_{e'}^i}) = \{g_iu_e^i, u_e^is_i, s_iu_{e'}^i\}$, either $s_iu_e^i$ or $s_iu_{e'}^i$ is in $\texttt{extra edges}$ for $\lambda$. Now, suppose that $u_e^i$ is the only vertex in $ {\mathtt{ES}}\xspace_i \cap W(p)$. Since $W(p)$ contains at least two vertices of $\mathtt{ES}$, there exists a vertex $u_{e'}^j \in {\mathtt{ES}}\xspace_j \cap W(p)$, where $j\in [t], j\neq i$. Consider a path $P_{g_iu_{e'}^j}$ from $g_i$ to $u_{e'}^j$, since $W(p)$ is disjoint from $Z$, $u_{e}^is_i,u_{e'}^js_j \in E(P_{g_iu_{e'}^j})$ (otherwise there can not be a path from $g_i$ to $u_{e'}^j$), and the path from $s_i$ to $s_j$ in $T$ contains only special vertices. Let $S$ be the set of vertices in the path from $s_i$ to $s_j$ in $T$. We modify $\lambda$ to define $\lambda(s)=s\mathtt{succ}[s]$, for all $s \in S$. Note that $\lambda$ is still a {\em one-to-one} function, and $s_iu_{e}^i$ is in $\texttt{extra edges}$. Hence, for every witness set in $\mathtt{Cap}_3$, we have an edge in $\texttt{extra edges}$ for some function $\lambda$.
\end{proof}
\begin{proof}(of Lemma~\ref{lem:rev})
Let $\mathtt{Cap}_1, \mathtt{Cap}_2,$ and $\mathtt{Cap}_3$ be the subset of $\mathtt{Cap}$ as defined in Claim~\ref{claim:multi-cap}, \ref{claim:intersect-with-Z} and \ref{claim:disjoint-from-Z}. Note that sets $\mathtt{Cap}_1, \mathtt{Cap}_2, \mathtt{Cap}_3$ are pairwise disjoint. Let $\mathtt{Cap}_4$ be the collection of cap vertices in $\mathtt{Cap} \setminus (\mathtt{Cap}_1 \cup \mathtt{Cap}_2 \cup \mathtt{Cap}_3)$.
We first argue that $|\mathtt{Cap}_4| \geq 2\gamma t$. Since there are $t$ many cap vertices, $|\mathtt{Cap}_1| + |\mathtt{Cap}_2| + |\mathtt{Cap}_3| + |\mathtt{Cap}_4| = t$.
Recall the accounting function $\lambda$, which was fixed before Claim~\ref{claim:multi-cap}. We modify this function in Claim~\ref{claim:multi-cap} and \ref{claim:disjoint-from-Z} at some special vertices to obtain another accounting function. Note that the modifications to $\lambda$ in Claim~\ref{claim:multi-cap} are at special vertices, which are contained in witness sets that contains at least two cap vertices. The modifications to $\lambda$ in Claim \ref{claim:disjoint-from-Z} are at special vertices, which are contained in witness sets that contains exactly one cap vertex. Since witness sets partition special vertices, one modification does not affect another. Since Claim~\ref{claim:intersect-with-Z} holds true for any accounting function, we know that for the function $\lambda$, there are at least $ \nicefrac{1}{2} \cdot |\mathtt{Cap}_1| + |\mathtt{Cap}_2| + |\mathtt{Cap}_3|$ many edges in \texttt{extra edges}. Since there are at most $(\nicefrac{1}{2} - \gamma)t$ many edges in \texttt{extra edges}\ for any accounting function, $|\mathtt{Cap}| - |\mathtt{Cap}_4| = |\mathtt{Cap}_1| + |\mathtt{Cap}_2| + |\mathtt{Cap}_3| \le (1 - 2\gamma)t$. Hence, $|\mathtt{Cap}_4| \ge 2\gamma t$. This implies that there are at least $2\gamma t$ many cap vertices, which are contained in a witness set, that does not contain any other cap vertex, no vertex of $Z$, and precisely one vertex of $\mathtt{ES}$.
Let $\mathcal{W}^\star$ be the subset of witness sets that contain at least one cap vertex. Let $\mathcal{W}_1, \mathcal{W}_2,$ and $\mathcal{W}_3$ be the subset of $\mathcal{W}^\star$ as defined in the proofs of Claim~\ref{claim:multi-cap}, \ref{claim:intersect-with-Z} and \ref{claim:disjoint-from-Z}.
Let $\mathcal{W}_4$ be the collection of remaining witness sets in $\mathcal{W}^\star \setminus (\mathcal{W}_1 \cup \mathcal{W}_2 \cup \mathcal{W}_3)$.
Note that any witness set in $\mathcal{W}_4$ contains exactly one cap vertex, no vertex of $Z$, and exactly one vertex of $\mathtt{ES}$.
Hence, $|\mathcal{W}_4| = |\mathtt{Cap}_4| \geq 2\gamma t$.
Let $W(p)$ be a witness set in $\mathcal{W}_4$ and $u_e$ be a vertex in $W(p) \cap {\mathtt{ES}}\xspace$. We argue that all the non-neighbors of $u_e$ in $Z$ are in $V(F')$. For the contradiction, suppose that there exists a non-neighbor of $u_e$, say $w$, in $Z$ that does not belong to $V(F')$. Note that $W(p)$ contains a cap vertex. By Claim~\ref{claim:clique-side-ver}, $\psi(w)$ and $p$ are in $\tilde{C}$.
Since $W(p)$ neither contains a vertex of $Z$ nor any other vertex of $\mathtt{ES}$, $p$ and $\psi(w)$ are not adjacent to each other, a contradiction to the fact that $\tilde{C}$ is a clique. Hence, our assumption is wrong and all the non-neighbors of $u_e$ in $Z$ are in $V(F')$. Recall that for every vertex $v$ in $G$, the reduction algorithm has added $\rho$ many copies of $v$ in $G'$, and the set of these vertices is
denoted by $X_{v}$. If the vertex $u_e$ in graph $G'$ corresponds to the edge $e = v_1v_2$ then all vertices in $X_{v_1} \cup X_{v_2}$ are contained in $V(F')$.
Let $Y$ be the subset of $\mathtt{ES}$ such that every vertex in $Y$ is in a witness set in $\mathcal{W}_4$. Since each witness set in $\mathcal{W}_4$ contains exactly one vertex of $Y$, $|Y| \geq 2\gamma t$.
Let $Y_{E}$ be the set of edges in $G$, which corresponds to vertices in $Y$.
Let $\bar{N}_{Z}(Y)$ be the set of non-neighbors of $Y$ in $Z$. We know that $\bar{N}_Z(Y)\subseteq V(F')$.
Since size of $F'$ is at most $|F'|\leq (\nicefrac{5}{2})t-\gamma t$ and $2t$ edges are incident to $\mathtt{Cap} \cup {\mathtt{SV}}\xspace$ (Claim~\ref{claim:special-vertex-t-edges}) there are at most $\nicefrac{t}{2}-\gamma t$ edges incident to the vertices of $Z$. Since every edge can be incident to at most two vertices of $\bar{N}_Z(Y)$, $|\bar{N}_Z(Y)|\leq t-2\gamma t$.
Let $S$ be the set of vertices, which are endpoint of some edge in $Y_E$ in $G$.
Since we have added $\rho$ copies for each vertex in $S$, we have $\rho |S| = |\bar{N}_Z(Y)| \le t-2\gamma t$.
This implies there are at most $(1 - 2\gamma)\nicefrac{t}{\rho} \le \nicefrac{k}{\delta}$ (as $\rho = \lceil \nicefrac{\delta t}{k} \rceil$) vertices which span at least $2\gamma t$ many edges in $G$.
Since a witness set in $\mathcal{W}_4$ contains exactly one cap vertex and exactly one vertex of $\mathtt{ES}$, due to Claim~\ref{claim:cap-vertex-solution-edge}, any two edges in $Y_E$ corresponds to two vertices in $G'$, which are in different edge selector sets, that corresponds to different color class in edge coloring $\phi$ in $G$. Hence, the set of edges $Y_E$ is colorful. This completes the proof of the lemma.
\end{proof}
We are now in a position to prove the main theorem of this section.
\begin{reptheorem}{thm:split-no-lossy} Assuming {\sf Gap-ETH}, no \textsf{FPT}\ time algorithm can approximate {\sc Split Contraction} within a
factor of $\left(\nicefrac{5}{4}-\delta \right)$, for any fixed constant $\delta>0$.
\end{reptheorem}
\begin{proof}
For the sake of contradiction, assume that for a given fixed $\delta > 0$, there exists an \textsf{FPT}\ time algorithm, say $\mathcal{A}_{\delta}$, which can approximate {\sc Split Contraction} within a factor of $(\nicefrac{5}{4} - \delta)$.
Consider an instance $(G, k)$ of {\textsc{Multicolored Densest-$k$-Subgraph with Perfect Completeness}}\xspace. We run the reduction algorithm mentioned in this section to obtain an instance $(G', k')$ of \textsc{Split Contraction}, where $k' = 2t + \lceil \nicefrac{\delta t}{k}\rceil, k' \in \ensuremath{{\mathcal O}}(k^2)$. Let $\texttt{opt}(G')$ be the number of minimum edges that needs to be contracted in $G'$ to convert it into a split graph.
By Lemma~\ref{lem:fwd}, there exists a set of edges $F'$ in $G'$ such that $G'/F'$ is a split graph and the size of $F'$ is at most $k'$. This implies that $\texttt{opt}(G') \le k'$. Let $\tilde{F}$ be the set of edges returned by algorithm $\mathcal{A}_{\delta}$ when the input is $(G', k')$. Since $\mathcal{A}_{\delta}$ returns an approximate solution within factor $(\nicefrac{5}{4} - \delta)$, we know that $|\tilde{F}| \le (\nicefrac{5}{4} - \delta) \cdot \texttt{opt}(G') \le (\nicefrac{5}{4} - \delta)\cdot k'$. By Lemma~\ref{lem:rev}, there exists a set of at most $\nicefrac{k}{\delta}$ vertices in $G$ that spans at least $(\nicefrac{3\delta}{2})t$ edges in $G$. Note that the proof of Lemma~\ref{lem:rev} can easily be converted into a polynomial time algorithm to obtain these set of vertices and edges in $G$ given $F'$. Since $\mathcal{A}_{\delta}$ is an \textsf{FPT}\ time approximation algorithm, it runs in time $f(k')\cdot |V(G')|^{\ensuremath{{\mathcal O}}(1)} = f(k) \cdot |V(G)|^{\ensuremath{{\mathcal O}}(1)}$ time.
We can conclude that there is a $f(k)\cdot |V(G)|^{\ensuremath{{\mathcal O}}(1)}$-time algorithm such that, given an integer $k$ and an edge colored graph $G$ containing a colorful-$k$-clique, always outputs a vertex set of size at most $\nicefrac{k}{\delta}$ vertices that span at least $2\gamma t$ colorful edges. Fix positive constants $\epsilon, \alpha$ such that $0 < \epsilon < 1$; $1 <\alpha$ and $3 \le 4 \alpha \epsilon$. For $\delta = \nicefrac{1}{\alpha}$, the above conclusion contradicts Lemma~\ref{lemma:original-problem}. Hence, our assumption is wrong, which implies the correctness of the theorem.
\end{proof} | {'timestamp': '2020-06-19T02:11:33', 'yymm': '2006', 'arxiv_id': '2006.10364', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10364'} | arxiv |
\section{Further experiment details and results}\label{app:experiments}
\subsection{Relative impact of performance optimizations}\label{app:rel-impact}
We performed an experiment to analyze how much improvement was due to the different performance optimization steps. We ran Falkon on the HIGGS dataset several times with the same hyperparameters ($m=\num{1e5}$ and \num{10} epochs), but with different \textit{features} enabled. Each feature roughly corresponds to one of the performance optimizations discussed in Section~\ref{sec:methods}.
Our baseline model is very similar to the original Falkon implementation~\cite{rudi2017falkon}, where the preconditioner ran on the CPU, float64 precision was being used, but matrix-vector multiplications for the CG algorithm were GPU accelerated.
As a first optimization we used float32 precision for all computations, with care taken to avoid errors in the Cholesky decomposition as discussed in Section~\ref{sec:methods}. This immediately resulted in a $2\times$ speedup for the CPU part, and $3\times$ for the GPU part.
Switching to a GPU preconditioner (using the algorithms described in Appendix~\ref{app:ooc}) gave a huge boost to the preconditioner running time which went from more than \SI{20}{\minute} to just under \SI{3}{\minute}.
Adding a second GPU produced a perfect $2\times$ speedup for the CG iterations, and a more modest $1.5\times$ speedup for the preconditioner which \begin{enumerate*}[label=\alph*)]\item involves operations which are not perfectly parallelizable and \item incurs in some fixed startup costs\end{enumerate*}.
Finally, since the HIGGS dataset has only 9 features (thus the data matrix is thin), we can use KeOps~\cite{keops} with great benefits to the speed of matrix-vector multiplications.
Overall our implementation provides a nearly $20\times$ improvement over the baseline, which makes learning on several huge datasets doable in a matter of minutes.
\subsection{Multi-GPU scalability}\label{app:multi-gpu-exp}
In this section we look into the scalability of our implementation across multiple GPUs. Scalability results for the full Falkon algorithm on the TAXI dataset are shown in Figure~\ref{fig:4gpu}. This result depends on scaling both the preconditioner and the conjugate gradient iterations.
The preconditioner itself is computed with three main operations: two Cholesky decompositions and one triangular matrix multiplication (this is called the LAUUM operation in LAPACK terms), see Figure~\ref{fig:preconditioner} for more details.
Each CG iteration instead consists of two multiplications between the kernel matrix and an arbitrary vector.
First we look at the scalability of the preconditioner operations with multiple GPUs. Then we examine our out-of-core matrix-vector product implementation and compare it to KeOps for different settings of $n$ and $d$.
\begin{figure}[!ht]
\centering
\includegraphics[width=0.5\linewidth]{img/4gpus.png}
\caption{Multi-GPU scalability of Falkon on the TAXI dataset (settings are the same as per Table~\ref{tbl:hparams}). Falkon scales remarkably well, with even 4 GPUs.}
\label{fig:4gpu}
\end{figure}
\paragraph{Preconditioner scalability.}
\begin{figure}
\centering
\subcaptionbox{Parallel LAUUM.\label{fig:par-lauum}}{%
\includegraphics[width=0.49\linewidth]{img/parallel_lauum.pdf}%
}\hfill
\subcaptionbox{Parallel Cholesky decomposition.\label{fig:par-potrf}}{%
\includegraphics[width=0.49\linewidth]{img/parallel_potrf.pdf}%
}%
\caption{Running time of two preconditioner operations with one and two GPUs. The relative speed-up with 2 GPUs is shown in the black dashed line. The LAUUM operation (triangular matrix multiplication) was run out-of-place, which is theoretically easier to parallelize, while the Cholesky decomposition was run in-place.}\label{fig:par-precond}
\end{figure}
Figure~\ref{fig:par-precond} shows the results from running both triangular matrix multiplication and the Cholesky decomposition with one and two GPUs. At low matrix sizes the speedup with two GPUs is negligible, especially for the Cholesky decomposition. In such cases it is best to use a single GPU (especially since for $n=40000$ the whole matrix fits in GPU memory, so an in-place decomposition can be used).
With higher matrix sizes, having more than one GPU starts bringing real benefits, with a peak speedup around $1.8\times$ for preconditioners of size \num{140000}.
The factors blocking such speedup from reaching a perfect $2\times$ are different for the two operations.
Since the LAUUM operation was run out-of-place (see Appendix~\ref{app:ooc} for more details), it does not need any synchronization -- and should therefore be able to scale well across multiple GPUs. The main blocking factor is the operation at Line~\ref{line:lauum} of Algorithm~\ref{alg:oocLauum} which is executed on the CPU (since an equivalent implementation does not exist in cuSOLVER), thus both GPU threads must share the same CPU resources. We left porting the LAUUM operation to the GPU as future work, but it has the potential to speed up the LAUUM operation considerably.
For the Cholesky decomposition the limiting factors are the data-dependencies intrinsic to the algorithm which cannot be easily solved.
\paragraph{Comparing different MVM implementations.}
We compare our specialized routine for the kernel-vector multiplication $k(X^{(1)}, X^{(2)}) \bm{v}$ implemented in Python, leveraging PyTorch for GPU computations, against the native CUDA implementation from KeOps~\cite{keops}. Using a similar notation for the dimensions as in the main text we have $X^{(1)} \in \real{n\times d}, X^{(2)} \in \real{m \times d}, \bm{v} \in \real{m \times 1}$ and $k(\cdot, \cdot)$ is a kernel function.
Two distinct scenarios arise in different settings: increasing the number of data points $n$ produces linear scaling for both implementations, with KeOps being approximately 10 times faster than our implementation (see Figure~\ref{subfig:mvm_impl_n}).
Increasing the data dimensionality $d$ our implementation scales linearly, but KeOps scales polynomially, so as it is obvious from Figure~\ref{subfig:mvm_impl_d} KeOps can not be used when the data is high-dimensional. A caveat of this plot is that KeOps is continuously evolving, and is likely to improve performance with large $d$ in the future.
In our final algorithm we set a threshold on the data dimensionality and switch implementation based on this.
Finally note that this operation scales almost perfectly with multiple GPUs.
\begin{figure}
\centering
\begin{subfigure}{.5\textwidth}
\centering
\includegraphics[width=0.9\textwidth]{img/mmv_varying_n.pdf}
\caption{}
\label{subfig:mvm_impl_n}%
\end{subfigure}%
\begin{subfigure}{.5\textwidth}
\centering
\includegraphics[width=0.9\textwidth]{img/mmv_varying_d.pdf}
\caption{}
\label{subfig:mvm_impl_d}%
\end{subfigure}%
\caption{
Scaling of matrix-vector implementations where the matrix is the Gaussian kernel. In~\protect\subref{subfig:mvm_impl_n} we have set $m=\num{20000}$, $d=10$ and $n$ is variable;
in~\protect\subref{subfig:mvm_impl_d} we set $m=n=\num{20000}$ and we vary $d$. All experiments are run on 1 and 2 GPUs on single precision random data.
}
\label{fig:mvm_impl}
\end{figure}
\subsection{Additional information on the datasets}\label{app:datasets}
We used several datasets which we believe represent a broad set of scenarios for kernel learning, in terms of data size, data type, and learning task. We normally used a standard random split with 80\% training, 20\% testing data unless predefined splits existed (as noted below). Preprocessing mostly consisted in basic data cleaning and data standardization to zero mean and unit standard deviation; we comment in more detail below on specific preprocessing steps applied to the individual datasets.
\paragraph{HIGGS} has dimensions $n = 1.1 \times 10^7, d = 28$ and a binary target. It was preprocessed to 0 mean and unit variance. Results are reported on a 80-20 split with $1$ minus the AUC metric in Table~\ref{tbl:results1} and with the binary classification error in Table~\ref{tbl:results2}. It is available for download at \url{https://archive.ics.uci.edu/ml/datasets/HIGGS}.
\paragraph{TIMIT} has dimensions $n = 1.2 \times 10^6, d = 440$ and a multiclass target with $144$ classes. TIMIT comes from audio data, and our dataset uses the \SI{10}{\milli\second} resampling rate as in~\cite{eigenpro17,eigenpro2}. It was preprocessed to 0 mean and unit standard deviation. The error metric is classification error on a subset of classes (as used in~\cite{eigenpro17}), and is calculated over a standardized subset of $\num{57242}$ samples. It is available for download at \url{https://catalog.ldc.upenn.edu/LDC93S1}.
\paragraph{YELP} has dimensions $n = 1.5 \times 10^6, d = 6.52 \times 10^7$ and a continuous target.
This dataset consists of text reviews, labeled with their star rating. We used the same data as~\cite{Yelp16} (Yelp round 9 dataset), processed by extracting all 3-grams and encoding each review by a count vector which tells us which 3-grams are present. Such encoding produces a large number of sparse features which is reflected in the huge dimensionality of this dataset. Since the data is sparse we did not normalize it. The error metric is RMSE, calculated on random 20\% of the samples. The dataset can be provided on request.
\paragraph{TAXI} has dimensions $n = 1.1 \times 10^9, d = 9$ with a continuous target. Data are normalized to have zero-mean and unit standard deviation; reported error is RMSE on a 20\% random sub-sample. The data can be downloaded by following instructions at \url{https://github.com/toddwschneider/nyc-taxi-data}. Consistently with other users of this dataset~\cite{distributedGP} we took the data from January 2009 to December 2015, excluding outliers (taxi trips more than 5 hours long) and trips where the pickup or drop off location is outside of NYC.
\paragraph{AIRLINE} has dimensions $n = \num{5.93e6}, d=8$ and a continuous target. Data are normalized to zero-mean and unit standard deviation, and the error is the MSE over normalized targets calculated on random test-sets of size \SI{33}{\percent} of the full data (consistently with the literature~\cite{vffgp_hensman17,hensman13}).
The same dataset is also used for binary classification by thresholding the target at 0, which results in the \textbf{AIRLINE-CLS} dataset.
For this latter variation we used \num{100000} random points for testing, reporting classification error in Table~\ref{tbl:results1} and $1$ minus the AUC in Table~\ref{tbl:results2} to facilitate comparisons with the literature.
The data can be downloaded from \url{https://www.transtats.bts.gov/Fields.asp?Table_ID=236} and \url{http://stat-computing.org/dataexpo/2009/supplemental-data.html}.
\paragraph{MSD} has dimensions $n = \num{5.1e5}, d = 90$ with continuous target. Data are normalized to zero-mean and unit standard deviation, and we report the relative error over a standard test-set of size \num{51630}. The dataset can be downloaded from \url{https://archive.ics.uci.edu/ml/datasets/YearPredictionMSD}.
\paragraph{SUSY} has dimensions $n= \num{5e6}, d=18$ with binary target. Data are normalized to zero-mean and unit standard deviation. We report the classification error on 20\% of the data. Data is available from the UCI repositories \url{https://archive.ics.uci.edu/ml/datasets/SUSY}.
\subsection{Additional information on the experimental settings}\label{app:hyperparams}
\begin{enumerate}
\item EigenPro2.
Its only hyperparameters -- other than the kernel parameters -- are the ones governing the preconditioner's complexity making EigenPro easy to tune.
It is however limited to datasets which fit entirely in GPU memory, so can not easily scale to larger datasets; to alleviate this problem, consistently with the original paper, some experiments were run on sub-sampled datasets.
Furthermore, on some experiments we found it necessary to manually tune the learning rate (we divided the automatically inferred learning rate by a fixed integer, denoted by $\eta\div$ in Table~\ref{tbl:hparams}).
\item GPFlow (v2.1.3).
We used the SVGP model with Gaussian likelihood for regression, Bernoulli for binary classification and Softmax for multi-class problems.
We used Adam for optimization and tuned the learning rate, the number of inducing points, and the constraints on the variational distribution covariance (i.e. diagonal or full covariance matrix).
We found that using a full covariance matrix was rarely beneficial and increased training times slightly, so all final experiments used a diagonal covariance matrix. The number of parameters was $m\times d + m\times2 + 3$ which includes the inducing points, the variational parameters, two parameters for the Gaussian kernel (lengthscale and variance) and the variance of the likelihood. For multi-class problems separate variational parameters were trained for each class.
Since we wished to use single-precision floating point numbers in order to make GPU training more efficient, we found that natural gradient optimization was unstable. It remains to be seen whether the tradeoff between double-precision data and natural gradient optimization could further improve results. We further tested the benefits of using whitening of the inducing points, and found that it decreased per-epoch running times by about $2\times$, while at the same time slowing down convergence by around the same amount. In practice this meant that the difference in global running time was not strongly affected by whitening, and we ended up using it only for the HIGGS data.
\item GPyTorch (v.1.2.0). We used the SVGP model with Gaussian and Bernoulli likelihoods.
We were unable to run GPyTorch's SVGP model on the TIMIT dataset due to problems in dealing with multiple outputs. We used the natural gradient optimizer to learn the variational parameters, and Adam to learn the other hyperparameters. The learning rate of the two optimizers was kept equal and tuned for best performance. We further optimized the number of inducing points, and variational distribution constraints. In practice we found that we had to use the natural gradient variational distribution for regression problem, and the lower-triangular parametrization for classification problems (which are non-conjugate). We additionally tested whether whitening the inducing points was beneficial: in practice we found that using the unwhitened strategy was around $3\times$ faster and did not hamper convergence, so we selected it for all experiments.
While GPyTorch is theoretically able to run on multi-GPU systems, we noticed that this feature was not available for the SVGP model thus we always used a single GPU; furthermore, while a KeOps integration into GPyTorch is available, we found that for the SVGP model it would increase the running time, so we did not use it.
The trained parameters were the same as for GPFlow plus another scalar for the GP mean.
\item Falkon. We tuned the kernel length-scale, number of inducing points and regularization amount. We used a coarse to fine approach to tune the length-scale which gives good results with a limited number of validation runs.
\item Logistic Falkon. Here we tuned the kernel length-scale, number of inducing points and regularization path. We found that the algorithm is not very sensitive to the exact regularization path: it is sufficient to set the final $\lambda$, and many different paths which lead to such value will work in the same way.
\end{enumerate}
\begin{table}
\caption{Summary of the most important hyperparameter settings for all algorithm-dataset combinations. We denote by $\eta$ the learning rate, by \textit{subsample} the amount of training-set subsampling that was performed (i.e. training was done on a smaller dataset), and by Newton steps the number of separate runs of the main Falkon algorithm for Logistic Falkon (see Appendix~\ref{app:logistic}).}
\label{tbl:hparams}
\centering
\resizebox{0.97\linewidth}{!}{
\begin{tabular}{llllllllll}
\toprule
& & AIRLINE & AIRLINE-CLS & MSD & SUSY & TIMIT & YELP & HIGGS & TAXI \\
\midrule
& n & \num{5.93e6} & \num{5.93e6} & \num{5.1e5} &\num{5e6} &\num{1.2e6} &\num{1.6e6} &\num{11e7} &\num{1.15e9} \\
& d &\num{8} & \num{8} & \num{90} &\num{18} &\num{440} &\num{6.5e7} &\num{28} &\num{9} \\
& labels & reg & 2-cls & reg & 2-cls & 144-cls & reg & 2-cls & reg \\
\midrule
\multirow[t]{4}{*}{Falkon}
& m & \num{1e5} & \num{1e5} & \num{5e4} & \num{3e4} & \num{1e5} & \num{5e4} & \num{1.2e5} & \num{1e5} \\
& $\sigma$ & \num{0.9} & \num{0.9} & \num{7} & 3 & \num{14.5} & \num{20} & \num{3.8} & \num{1} \\
& $\lambda$ & \num{1e-8} & \num{1e-8} & \num{2e-6} & \num{1e-6} & \num{5e-9} & \num{1e-6} & \num{3e-8} & \num{2e-7} \\
& epochs & 20 & 10 & 10 & 5 & 5 & 10 & 10 & 7 \\
\multirow[t]{4}{*}{LogFalkon}
& m & -- & \num{1e5} & -- & \num{2e4} & -- & -- & \num{1e5} & -- \\
& $\sigma$ & -- & \num{0.9} & -- & 3 & -- & -- & \num{5} & -- \\
& $\lambda$ & -- & \num{1e-9} & -- & \num{1e-8} & -- & -- & \num{1e-9} & -- \\
& Newt. steps & -- & 9 & -- & 6 & -- & -- & 9 & -- \\
\multirow[t]{3}{*}{GPyTorch}
& m & 2000 & 2000 & 3000 & 2000 & -- & -- & 2000 & 1000 \\
& $\eta$ & \num{5e-3} & \num{2e-3} & \num{2e-3} & \num{1e-3} & -- & -- & \num{2e-2} & \num{2e-3} \\
& epochs & 20 & 20 & 20 & 20 & -- & -- & 15 & 5 \\
\multirow[t]{3}{*}{GPflow}
& m & 2000 & 2000 & 3000 & 2000 & 2000 & -- & 2000 & 1000 \\
& $\eta$ & \num{5e-3} & \num{5e-3} & \num{2e-3} & \num{3e-3} & \num{1e-2} & -- & \num{2e-2} & \num{3e-3} \\
& epochs & 25 & 20 & 45 & 10 & 15 & -- & 60 & 10 \\
& whiten & no & no & no & no & no & -- & yes & no \\
\multirow[t]{3}{*}{EigenPro}
& $\eta\div$ & 10 & 12 & 20 & 1 & 1 & -- & -- & -- \\
& subsample & \num{1e6} & \num{1e6} & -- & \num{6e5} & -- & -- & -- & -- \\
& epochs & 9 & 10 & 9 & 1 & 4 & -- & -- & -- \\
\bottomrule
\end{tabular}
}
\end{table}
\subsection{Additional benchmarks}
In Table~\ref{tbl:results-1gpu} we show the performance of the Falkon algorithm on all considered datasets for 1 and 2 GPUs side by side. It is clear that larger datasets scale better with more GPUs since the startup cost (mostly taken up by CUDA initialization) and the lower scaling ratio of the preconditioner are amortized.
{
\renewcommand{\arraystretch}{1.2}
\begin{table}
\centering
\caption{Benchmark timings using a single GPU. The relative slowdown with respect to Falkon on 2 GPUs is also provided for comparison with Table~\ref{tbl:results1}. }
\label{tbl:results-1gpu}
\begin{tabular}{llll}
\toprule
& 1 GPU & 2 GPUs & Relative change \\
\midrule
TAXI & \SI{7215 \pm 4}{\second} & \SI{3628 \pm 2}{\second} & $1.99\times$ \\
HIGGS & \SI{715 \pm 6}{\second} & \SI{443 \pm 2}{\second} & $1.61\times$ \\
YELP & \SI{1981 \pm 6}{\second} & \SI{1008 \pm 2}{\second} & $1.97\times$ \\
TIMIT & \SI{416 \pm 4}{\second} & \SI{288 \pm 3}{\second} & $1.44\times$ \\
AIRLINE & \SI{334 \pm 2}{\second} & \SI{245 \pm 5}{\second} & $1.36\times$ \\
MSD & \SI{81(0)}{\second} & \SI{62 \pm 1}{\second} & $1.31\times$ \\
AIRLINE-CLS & \SI{391 \pm 5}{\second} & \SI{269 \pm 3}{\second} & $1.45\times$ \\
SUSY & \SI{29 \pm 1}{\second} & \SI{22(0)}{\second} & $1.32\times$ \\
\bottomrule%
\end{tabular}
\end{table}
}
In Table~\ref{tbl:results-svm} we compare the running times of Falkon and ThunderSVM~\cite{wenthundersvm18} on three popular image datasets. ThunderSVM was chosen among several SVM implementations as it runs entirely on the GPU, and can thus solve the hinge-loss problem quickly for problems of moderate size. Smaller datasets than the ones used for previous experiments were considered, since ThunderSVM solves the full SVM problem and thus suffers from cubic time scaling. The results obtained show that Falkon can work efficiently even on smaller datasets, resulting between 2 and 10 times faster than ThunderSVM (depending on problem size), with comparable accuracy.
To further shave off some time, we implemented a version of Falkon which runs entirely inside the GPU: we call this \textbf{InCoreFalkon}, and it can only be used on smaller datasets which fit inside the GPU, leaving some space to spare which is used for the preconditioner and the other computations. Table~\ref{tbl:results-svm} shows that InCoreFalkon gives a further speed-up of -- on average -- $2\times$ compared to the standard implementation.
\begin{table}
\renewcommand{\arraystretch}{1.2}
\centering
\caption{Comparing the running times of Falkon, the in-core version of Falkon and ThunderSVM on three image datasets. Hyperparameters (especially the number of inducing points $m$) were tuned so that the two algorithms obtained approximately the same accuracy.}
\label{tbl:results-svm}
\begin{tabular}{lp{9em}p{9em}p{9em}}
\toprule
& MNIST \newline $n=6\cdot 10^4, d=780$ & CIFAR10\newline $n=6\cdot 10^4, d=1024$ & SVHN\newline $n=7\cdot 10^4, d=1024$ \\
\midrule
Falkon & \SI{10.9}{\second} & \SI{13.7}{\second} & \SI{17.2}{\second} \\
InCoreFalkon & \SI{6.5}{\second} & \SI{7.9}{\second} & \SI{6.7}{\second} \\
ThunderSVM & \SI{19.6}{\second} & \SI{82.9}{\second} & \SI{166.4}{\second} \\
\bottomrule
\end{tabular}
\end{table}
\subsection{Performance comparisons in a literature review}\label{app:more-exp}
{
\renewcommand{\arraystretch}{1.5}
\begin{table}
\caption{Survey of results on the datasets we considered, as reported in the literature. We report the result of our implementation (Falkon) next to other implementations, along with the time taken and the hardware used (where available).}
\label{tbl:results2}
\centering
\resizebox{1\linewidth}{!}{
\begin{tabular}{lll|lp{9em}p{11em}}
\toprule
Dataset & \multicolumn{2}{c}{Falkon} & \multicolumn{3}{c}{Other methods} \\
\cmidrule(r){2-3} \cmidrule(r){4-6}
& error & time & error & time & reference \\
\midrule
\multirowcell{2}{TAXI \\ (metric: RMSE)} &
\multirow[t]{1}{*}{$\num{311.7 \pm 0.1}$} & \multirow[t]{1}{*}{$\SI{3628 \pm 2}{\second}$} &
\num{309.7} & \SI{6000}{\second} \newline \num{28000} vCPUs (AWS) & ADVGP~\cite{distributedGP} \\
\cmidrule(r){2-6}
\multirowcell{2}{HIGGS \\ (metric: c-err)} &
\multirow[t]{1}{*}{\SI{25.78 \pm 0.03}{\percent}} & \multirow[t]{1}{*}{$\SI{443 \pm 2}{\second}$} &
\SI{32.87}{\percent} & $\SI{1392}{\second}$ \newline on 14 node cluster & liquidSVM~\cite{liquisvm17} \\
\cmidrule(r){2-6}
\multirowcell{4}{YELP \\ (metric: RMSE)} &
\multirow[t]{1}{*}{\num{0.810 \pm 0.001}} & \multirow[t]{1}{*}{\SI{1008 \pm 2}{\second}} &
\num{0.861} & $\approx \SI{3500}{\second}$ & Nystr{\"o}m~\cite{Yelp16} \\
& & & \num{0.854} & $\approx \SI{30000}{\second}$ \newline on 128 machines (AWS) & Full linear kernel~\cite{Yelp16} \\
\cmidrule(r){2-6}
\multirowcell{4}{AIRLINE \\ (metric: MSE)} &
\multirow[t]{1}{*}{$\num{0.758 \pm 0.005}$} & \multirow[t]{1}{*}{$\SI{245 \pm 5}{\second}$} &
$\num{0.827\pm0.004}$ & $\SI{265\pm 6}{\second}$ \newline on a laptop & VFF-GP~\cite{vffgp_hensman17} \\
& & & $\num{0.791 \pm 0.005}$ & $\SI{18360 \pm 360}{\second}$ \newline on a cluster & SVIGP~\cite{vffgp_hensman17} \\
\cmidrule(r){2-6}
\multirowcell{4}{MSD \\ (metric: rel. err.)} &
\multirow[t]{2}{*}{\num{4.48e-3}} & \multirow[t]{2}{*}{$\SI{62 \pm 1}{\second}$} &
$\approx \num{4.55e-3}$ & \SI{210}{\second} \newline on IBM POWER8 & Hierarchical~\cite{hierachical17} \\
& & & \num{4.58e-3} & \SI{289}{\second} \newline on 8 r3.8xlarge (AWS) & Faster KRR~\cite{fasterkrr17} \\
\cmidrule(r){2-6}
\multirowcell{5}{\shortstack[l]{AIRLINE-CLS \\ (metric: AUC)}} &
\multirow[t]{5}{*}{\num{0.739 \pm 0.002}} & \multirow[t]{5}{*}{\bfseries \SI{186 \pm 1}{\second}} &
$\num{0.781\pm0.001}$ & $\SI{14328}{\second}$ & Varitional Deep GP~\cite{wilson_deep16}\\
& & & $\num{0.694}$ & $\SI{5200}{\second}$ & TT-GP~\cite{tensor_train18} \\
& & & $\num{0.788}$ & $\SI{1375}{\second}$ & Deep TT-GP~\cite{tensor_train18} \\
& & & \num{0.665} & $\SI{80000}{\second}$ & cVGP\cite{classif_vgps15} \\
& & & \num{0.785} & $\approx \SI{5000}{\second}$ & RF Deep GPs~\cite{cutajar17} \\
\cmidrule(r){2-6}
\multirowcell{2}{SUSY \\ (metric: c-err)} &
\multirow[t]{2}{*}{\SI{19.67 \pm 0.02}{\percent}} & \multirow[t]{2}{*}{\bfseries \SI{22(0)}{\second}} &
$\approx 20\%$ & $\approx \SI{2000}{\second}$ \newline on IBM POWER8 & Hierarchical~\cite{hierachical17} \\
& & & $19.8\%$ & \SI{58}{\second} \newline on 1 Titan Xp & EigenPro 2.0~\cite{eigenpro2} \\
\end{tabular}
}
\end{table}
}
We scanned the literature for results which used kernel methods on the datasets considered in this paper, which reported both accuracy and running times. This allowed us to confirm that the results reported in our benchmarks (see Table~\ref{tbl:results1}) were in-line with what had been previously reported. The outcome is shown in Table~\ref{tbl:results2}.
We do not report results where running time is not mentioned. Some of the numbers in Table~\ref{tbl:results2} have higher accuracy than Falkon: this comes from the use of deep GPs which -- through a vast number of parameters -- can learn better data representations.
Such models are intrinsically different in spirit from kernel methods, and we do not aim to compare with them specifically; they are reported in Table~\ref{tbl:results2} for the sake of completeness.
\section{Logistic Falkon Algorithm}\label{app:logistic}
\input{applogistic.tex}
\section{Out-Of-Core Algorithms}\label{app:ooc}
In this section we describe more in detail the out-of-GPU core algorithms for \begin{enumerate*}[label=\arabic*)]\item Cholesky decomposition of a positive definite matrix and \item multiplication of a triangular matrix by its transpose\end{enumerate*}.
Both algorithms use a similar technique of dividing the input matrix in smaller tiles such that operations can be performed in-core on the individual tiles.
Then the main challenges of such algorithms consist in choosing when to bring which tiles in-core, and how to do so in parallel, handling data-dependencies between different tiles.
We handle parallelism between multiple GPUs using a static work-allocation scheme where the input matrix is divided into block rows or columns (made up of several tiles), and each GPU is assigned one or more such rows (or columns) block-cyclically, to ensure that the workload is approximately balanced.
Ensuring a balanced workload is tricky since the input matrices are triangular, and for example a row at the top of a lower-triangular matrix will have many more tiles than a row towards the bottom of said matrix.
Smaller tile-sizes (so thinner block rows/columns) make each processor's workload more even, but -- in case the input matrix is not big enough -- they reduce overall GPU utilization.
\paragraph{Triangular matrix multiplication.}
\begin{algorithm}
\caption{Out-of-core LAUUM operation on an upper-triangular matrix. The algorithm's inputs are matrix $U$, a synchronization object \texttt{barrier}, an array of arrays describing which row indices are assigned to which processor $\texttt{blockAllocs}$, and the number of tiles per side $N$. The function described below should be called for every available GPU with a different $\texttt{procId}$ value.}
\label{alg:oocLauum}
\begin{algorithmic}[1]
\Function{OocLauum}{$U \in \real{n\times n}, \mathtt{barrier}, \mathtt{blockAllocs}, \mathtt{procId}, N$}
\For{$i = 1, \dots, N$}
\State $C\in \real{t\times t \cdot (N-i)} \gets \mathtt{ToGPU(procId,\ } \Big[U_{i, i}, \dots, U_{i, N} \Big]\mathtt{)}$
\State \texttt{barrier.wait()}
\For{$j \in \mathtt{blockAllocs[procId]}$}
\If{$i = j$}
\State $C_1 \gets C_1 C_1^\top$ \Comment{via \texttt{LAUUM}} \label{line:lauum}
\If{$i \ne N$}
\State $C_1 \gets C_1 + C_{1:(N-i+1)} C_{1:(N-i+1)}^\top$ \Comment{via \texttt{SYRK}}
\EndIf
\ElsIf{$j > i$}
\State $D \in \real{t\times t\cdot (N-j)} \gets \mathtt{ToGPU(procId,\ } \Big[ U_{j,j}, \dots, U_{j, N} \Big]\mathtt{)}$
\State $C_{(j-i)} \gets C_{(j-i)}D_1^{\top}$ \Comment{via \texttt{TRMM}}
\If{$j \ne N$}
\State $C_{(j-i)} \gets C_{(j-i+1):(N-i+1)}D_{2:(N-j+1)}^\top$ \Comment{via \texttt{GEMM}}
\EndIf
\EndIf
\State $U_{i,j} \gets \mathtt{FromGPU(procId,\ } C_{(j-i)}\mathtt{)}$ \label{line:write-back}
\EndFor
\EndFor
\Return $U$
\EndFunction
\end{algorithmic}
\end{algorithm}
We begin by describing OOC triangular matrix multiplication, an operation which is known as LAUUM within the LAPACK library. Given an input upper triangular matrix $U\in\real{n\times n}$, we want to calculate the upper triangle of $UU^\top$ and store it in the upper part of $U$ (thus making this an in-place operation).
We divide $U$ in $N\times N$ tiles of size $t$ (uneven tile sizes are possible, and indeed necessary to support all input sizes, but omitted from the description for clarity), and we index all matrices by their tiles: $U_{2,2}$ is the square tile at the second block-row and second block-column of $U$.
The in-place LAUUM operation can be compactly described as $U_{i,j} = \sum_{k=j}^{N-1} U_{i,k}U_{j,k}^\top$ for $j \ge i$: to update a tile of $U$ we need to multiply two block-rows of the original matrix. However, we can exploit the triangular structure of some of the above matrix multiplications to improve performance: for example, when $i = j$ it is possible to split the update into two parts $U_{i,i} = U_{i,i}U_{i,i}^\top + \sum_{k=i}^N U_{i,k}U_{i,k}^\top$ where the first part consists of an in-core LAUUM operation and the second of a symmetric matrix multiplication (BLAS routine SYRK) which can be up to twice as fast as the general matrix multiplication routine.
Similarly, for $i < j$, $U_{i,j} = U_{i,j}U_{j,j}^\top + \sum_{k=j + 1}^N U_{i,k}U_{j,k}^\top$ where the first part can use the TRMM routine from the BLAS library and the second must use the generic GEMM routine.
To avoid overwriting parts of $U$ which are still needed for the updates -- especially in a multi-GPU setting -- the rows of $U$ are to be updated one at a time, from top to bottom. To ensure synchronization between multiple GPUs we use a thread barrier so that all GPUs start updating a given row after having loaded its original, non-updated version in GPU memory.
GPU memory requirements for Algorithm~\ref{alg:oocLauum} are two block-columns (i.e. $2Nt^2$ numbers).
As discussed above, rows are assigned to GPUs in a 1D block-cyclic way. Such allocations are recorded in the \texttt{blockAllocs} variable.
An adaptation of Algorithm~\ref{alg:oocLauum} is possible when in-place operation is not needed: it is sufficient to remove the synchronization barrier, and change line~\ref{line:write-back} to write the output to a different matrix.
\paragraph{Cholesky decomposition.}
\begin{algorithm}
\caption{Out-of-core, in-place Cholesky decomposition of symmetric positive definite matrix $A$. The lower triangle of $A$ will be overwritten by $L$ such that $L^\top L = A$. The function \texttt{OocPotrf} should be called for each available GPU with different values of the \texttt{procId} variable to parallelize the decomposition across GPUs. The inputs are the same as for Algorithm~\ref{alg:oocLauum} but for work-table $T\in\mathbb{Z}^{N\times N}$ whose values are atomically updated by the different GPU processes to ensure synchronization.}
\label{alg:oocPotrf}
\begin{minipage}[t]{0.62\linewidth}{
\begin{algorithmic}[1]
\Function{OocPotrf}{$A\mathtt{, blockAllocs, procId,\ }T\mathtt{,\ }N$}
\For{$i = 1, \dots, N$}
\If{$i \in \mathtt{blockAllocs[procId]}$}
\State $B \gets \mathtt{Load(}A\mathtt{,\ }T\mathtt{,\ }i\mathtt{,\ }j\mathtt{,\ }i\mathtt{)}$
\State $B \gets \mathtt{POTRF(}B\mathtt{)}$
\State $A_{i,i} \gets \mathtt{Write(}B\mathtt{,\ }T\mathtt{,\ }i\mathtt{,\ }i\mathtt{)}$
\EndIf
\For{$j \in \mathtt{blockAllocs[procId]}$}
\If{$j \le i$}
\State $\mathtt{continue}$
\EndIf
\State $B \gets \mathtt{Load(}A\mathtt{,\ }T\mathtt{,\ }i\mathtt{,\ }i\mathtt{,\ }i+1\mathtt{)}$
\State $C \gets \mathtt{Load(}A\mathtt{,\ }T\mathtt{,\ }j\mathtt{,\ }i\mathtt{,\ }i\mathtt{)}$
\State $C \gets C(B^{-1})^\top$ \Comment{via \texttt{TRSM}}
\State $A_{j, i} \gets \mathtt{Write(}C\mathtt{,\ }T\mathtt{,\ }j\mathtt{,\ }i\mathtt{)}$
\EndFor
\For{$j \in \mathtt{blockAllocs[procId]}$}
\If{$j \le i + 1$}
\State $\mathtt{continue}$
\EndIf
\State $C \gets \mathtt{Load(}A\mathtt{,\ }T\mathtt{,\ }j\mathtt{,\ }i\mathtt{,\ }i+1\mathtt{)}$
\For{$y = i, \dots j$}
\State $E \gets \mathtt{Load(}A\mathtt{,\ }T\mathtt{,\ }j\mathtt{,\ }y\mathtt{,\ }i\mathtt{)}$
\If{$y = j$}
\State $E \gets E - CC^\top$ \Comment{via \texttt{SYRK}}
\Else
\State $D \gets \mathtt{Load(}A\mathtt{,\ }T\mathtt{,\ }y\mathtt{,\ }i\mathtt{,\ }i+1\mathtt{)}$
\State $E \gets E - DC^\top$ \Comment{via \texttt{GEMM}}
\EndIf
\State $A_{j, y} \gets \mathtt{Write(}E\mathtt{,\ }T\mathtt{,\ }j\mathtt{,\ }y\mathtt{)}$
\EndFor
\EndFor
\EndFor
\EndFunction
\end{algorithmic}%
}\end{minipage}%
%
\adjustbox{valign=t}{
\begin{minipage}[t]{0.37\linewidth}{
\begin{algorithmic}[1]
\setcounter{ALG@line}{34}
\Function{Load}{$A, T, i, j, \mathtt{exp}$}
\While{$T_{i,j} < \mathtt{exp}$}
\State \texttt{wait}
\EndWhile
\State \Return $\mathtt{ToGPU(}A_{i,j}\mathtt{)}$
\EndFunction
\item[]
\Function{Write}{$G, T, i, j$}
\State $T_{i,j} \gets T_{i,j} + 1$
\State \Return $\mathtt{FromGPU(}G\mathtt{)}$
\EndFunction
\end{algorithmic}%
\vfill%
}\end{minipage}}%
\end{algorithm}
We want to decompose positive definite matrix $A$ into lower triangular matrix $L$ such that $L^\top L = A$. But $A$ does not fit entirely in GPU memory, and potentially more than one GPU is available.
As before it is convenient to subdivide $A$ into smaller tiles such that the tiles fit in GPU memory.
\begin{equation*}
\begin{pmatrix}
A_{1,1} & & \\
A_{2,1} & A_{2,2} & \\
\vdots & \ddots & \\
A_{n,1} & \dots & A_{n,n}
\end{pmatrix}
=
\begin{pmatrix}
L_{1,1} & & \\
L_{2,1} & L_{2,2} & \\
\vdots & \ddots & \\
L_{n,1} & \dots & L_{n,n}
\end{pmatrix}
\begin{pmatrix}
L_{1,1}^T & L_{2,1}^T & \dots & L_{n,1}^T \\
& L_{2,2}^T & \dots & L_{n,2}^T \\
& & \ddots& \vdots \\
& & & L_{n,n}^T
\end{pmatrix}
\end{equation*}
Then the in-place decomposition may proceed column-wise across matrix $A$, where each column update requires three steps.
The first step is to use the in-core \texttt{POTRF} function from cuSOLVER~\cite{cusolver} on a single tile. Then, a triangular solution step is used to update the remaining rows of the first column (taking the first column as an example $A_{j,1} = L_{j,1}L_{1,1}^\top, 1 < j < N$, so clearly $L_{j,1} = A_{j,1}(L_{1,1}^{-1})^\top$). This can be done by using the \texttt{TRSM} operation from any GPU BLAS implementation.
Finally, the \textit{trailing} submatrix must be updated with those terms which can be computed from the current column, so that after this last step such column is not needed anymore. This step consists of running $A_{ij} = A_{ij} - L_{i,1}L_{j,1}^\top$ where if $c$ is the current column $i > c,\quad c < j \le i$ (refer to Figure~\ref{fig:potrf} for a more intuitive picture).
Running this algorithm in parallel requires dealing with several data dependencies in-between tiles, and in general it will not be possible to achieve perfect parallelism due to the inherently serial step of performing the Cholesky decomposition of the first tile in a column.
We avoid coarse synchronization mechanisms such as the thread barrier which was used for the LAUUM OOC implementation, since we found they could introduce very high waiting times (barriers would be needed after each of the three steps of the algorithm to ensure proper synchronization).
Our solution, which somewhat follows~\cite{ltaief10magma}, uses an integer table $T$ with one entry per tile, which is shared between all GPU threads. The entries of $T$ represent the current state of each tile: basically how many times the tile has been updated.
Since we use a static row-cyclic work allocation like for the triangular matrix multiplication, each thread knows the expected state of a tile for each step (e.g. to perform the first step on tile $A_{c,c}$ the tile must have been updated exactly $c$ times). So it can wait until such state has been reached, then read the tile into GPU memory, perform the update, write back the tile to main RAM, and increment the corresponding entry in $T$. Such a scheme is implemented in Algorithm~\ref{alg:oocPotrf} with the help of the \texttt{Load} and \texttt{Write} sub-routines.
Further optimizations are possible by being careful about which tiles are swapped in and out of GPU memory and at what times, overlapping computation with memory transfers when possible.
Such optimizations generally require to increase the total memory allocated on the GPU, thus decreasing the maximum possible tile-size.
\section{Introduction}
\input{introduction}
\section{Background}\label{sec:background}
\input{background}
\section{Reformulating kernel solvers for multi-core/multi-GPU architectures}\label{sec:methods}
\input{methods}
\section{Large-scale experiments}\label{sec:exp}\label{sec:large-exp}
\input{experiments}
\section{Conclusions}
\input{conclusion}
\section*{Acknowledgments}
This material is based upon work supported by the Center for Brains, Minds and Machines (CBMM), funded by NSF STC award CCF-1231216, and the Italian Institute of Technology. We gratefully acknowledge the support of NVIDIA Corporation for the donation of the Titan Xp GPUs and the Tesla k40 GPU used for this research.
Part of this work has been carried out at the Machine Learning Genoa (MaLGa) center, Università di Genova (IT)
L. R. acknowledges the financial support of the European Research Council (grant SLING 819789), the AFOSR projects FA9550-17-1-0390 and BAA-AFRL-AFOSR-2016-0007 (European Office of Aerospace Research and Development), and the EU H2020-MSCA-RISE project NoMADS - DLV-777826.
This work was funded in part by the French government under management of Agence Nationale de la Recherche as part of the ``Investissements d’avenir'' program, reference ANR-19-P3IA-0001 (PRAIRIE 3IA Institute).
\bibliographystyle{plainnat}
\subsection{Overcoming RAM memory bottleneck}\label{sec:RAM-memory}
Kernel solvers that use the Nystr{\"o}m method need the matrices $K_{mm}$ and $K_{nm}$. Since $K_{nm}$ is used only in matrix-vector products, we can avoid constructing it explicitly (as we shall see in the following paragraphs) which leaves us to deal with the $K_{mm}$ matrix. When $m$ is large, it is crucial to carefully manage the memory needed for this task:
in our implementation we only ever allocate one $m\times m$ matrix, and overwrite it in different steps to calculate the preconditioner.
Indeed, choosing an appropriate form of the preconditioner, the matrix $K_{mm}$ itself is not needed in the conjugate gradient iteration.
Figure~\ref{fig:mem-buffers} shows the total memory usage, which consists of the preconditioner occupying approximately $90\%$ of the memory (see last paragraph of Sect.~\ref{sec:RAM-memory}), the weight vector $\bm{\beta}$ and two buffers holding (part of) the $m$ inducing points and a data batch needed to compute $K_{nm}$.\\
\noindent{\bf In-place computation and storage of the preconditioner.}
The preconditioner $\tilde{P}$ of Eq.~\eqref{eq:flk_preconditioner} is used to solve a linear system of the form $\tilde{P}^\top H \tilde{P}\bm{\beta} = \tilde{P}^\top K_{mn}\bm{y}$ with $H = K_{mn}K_{nm} + \lambda n K_{mm}$ and $\bm{\beta} = \tilde{P}^{-1}\bm{\alpha}$.
$\tilde{P}$ can be decomposed into two triangular matrices obtained via Cholesky decomposition of $K_{mm}$,
\begin{equation}\label{eq:flk-prec-chol}
\tilde{P} = \tfrac{1}{\sqrt{n}}T^{-1}A^{-1},\qquad T = \ensuremath{\mathrm{chol}}(K_{mm}), \qquad A = \ensuremath{\mathrm{chol}}(\tfrac{1}{m} TT^\top + \lambda \ensuremath{\bm{I}}_m).
\end{equation}
All operations are performed in-place allocating a single $m\times m$ matrix as shown in Figure~\ref{fig:preconditioner} and as described next:
\begin{enumerate*}[label=(\alph*)]
\item a matrix of dimension $m\times m$ is allocated in memory;
\item the $K_{mm}$ kernel is computed in blocks on the GPU and copied to the matrix;
\item {\em in-place} Cholesky decomposition of the upper triangle of $K_{mm}$ is performed on the GPU (if the kernel does not fit GPU memory an out-of-core algorithm is used, see later sections);
\item the product $TT^\top$ is computed in blocks via GPU and stored in the lower part;
\item out-of-core in-place Cholesky decomposition is performed on the lower triangle to get $A^\top$.
\end{enumerate*}
Additional care is needed to take into account the matrix diagonal, not described here for brevity.\\
\noindent{\bf Elimination of the storage of $K_{mm}$.} Considering more carefully the matrix $\tilde{P} (K_{nm}^\top K_{nm} + \lambda n K_{mm}) \tilde{P}$ with $\tilde{P}$ as in Eq.~\eqref{eq:flk-prec-chol}, we observe that the occurrences of $K_{mm}$ cancel out. Indeed $(T^{-1})^{\top}K_{mm}T^{-1} = \ensuremath{\bm{I}}$ since $K_{mm}=T^\top T$ by Eq.~\ref{eq:flk-prec-chol}. Then, the following characterization allows to overwrite $K_{mm}$ when calculating the preconditioner.
\begin{align}
\tilde{P}^\top H\tilde{P}\beta &=~~~ (A^{-1})^{\top} (T^{-1})^{\top} (K_{nm}^\top K_{nm} + \lambda n K_{mm})T^{-1}A^{-1}\bm{\beta} \label{eq:cg-iter-non-opt}\\
& =~~~ (A^{-1})^{\top} [ (T^{-1})^{\top} K_{nm}^\top K_{nm} T^{-1}+ \lambda n I ]A^{-1}\bm{\beta}. \label{eq:cg-iter}
\end{align}\\
\noindent{\bf Blockwise $K_{nm}$-vector product on GPU.}
The conjugate gradient algorithm will repeatedly execute Eq.~\eqref{eq:cg-iter} for different $\bm{\beta}$. The most expensive operations are the matrix-vector products $K_{nm}^\top (K_{nm} \bm{v})$ for an arbitrary vector $\bm{v} \in \real{m\times 1}$ which -- if computed explicitly -- would require $n \times m$ memory.
However, it is possible to split the input data $X \in \real{n\times d}$ in $B$ batches of $q$ rows each $\{X_{b,:} \in \real{q \times d}\}_{b=1}^B$, so that matrix-vector products can be accumulated between batches using the formula $\sum_{b=1}^B k(X_{b,:}, X_m)^\top (k(X_{b,:}, X_m) \bm{v})$.
The matrix blocks to be held in memory are summarized in Figure~\ref{fig:mem-buffers} for a total size of $m \times (m + d + 1) + q\times d$ where $q$ can be small under memory pressure, or large for greater performance.
It is important to note that $k(X_{b,:}, X_m)$ is never stored in main memory, as all operations on it are done on the GPU.
\begin{figure}
\centering
\resizebox{!}{3.5cm}{\input{img/tikz_preconditioner}}
\caption{Evolution of the preconditioner matrix in memory.}
\label{fig:preconditioner}
\end{figure}
\subsection{Fitting in GPU memory and dealing with multiple GPUs}
While the main RAM might be a bottleneck, GPUs have an even smaller amount of memory, and another level of splitting is needed to exploit their speed. For example, a typical architecture has 256GB of RAM and 4 GPUs with 16GB ram each; a preconditioner with $m=2 \times 10^5$ occupies \SI{150}{\giga\byte} and $K_{nm}$ with $n=10^7$ would need \SI{2000}{\giga\byte} of memory if stored.
So we need to deal with both efficient computation of $K_{nm}$-vector product in chunks that fit a GPU, and with the computation of the preconditioner that usually does not fit in GPU memory. Operations based on a large storage layer (main RAM) and a small but fast layer (GPU) are called out-of-core (OOC) operations.
However, common machine learning libraries such as Tensorflow~\cite{tensorflow} or PyTorch~\cite{pytorch} do not implement OOC versions of the required matrix operations, leaving potentially complex implementations to the users.
Hence, in our library, we provide these implementations in easily reusable form.
It is important to note that splitting our workload to fit in GPU also provides an easy path to parallelization in a multi-GPU system: new chunks of computation are assigned to the first free GPU, effectively redistributing the workload between multiple accelerators when available. \\
\noindent{\bf Optimized block decomposition for out-of-core $K_{nm}$-vector multiplication.}
As seen in the previous section, matrix-vector products can be split along the dimension $n$, resulting in independent chunks of work that need to be summed up at the end. The OOC product between a kernel matrix and a vector proceeds by: \begin{enumerate*}[label=(\alph*)] \item transferring a block of data onto the device, \item computing the kernel on device and multiplying it by the vector, \item copying the result back to the host.\end{enumerate*} This sequence of operations minimizes expensive data-transfers between host and device since the kernel matrix is never moved.
In particular, the computation is also split along dimensions $m$ and $d$, to maximize the ratio between computational complexity and transfer time: i.e., maximizing $\frac{qrs}{qs + ds}$ subject to $qs + ds \leq G$, where $q$, $r$ and $s$ are the batch dimensions along $n$, $m$ and $d$ respectively, and $G$ is the available GPU memory.\\%
\begin{figure}[t]
\centering
\resizebox{!}{3.5cm}{
\input{img/tikz_cholesky}
}
\caption{Three phases of the block Cholesky decomposition for updating the first column. Arrows indicate inter-GPU memory transfers between accelerators G-1 and G-2.}
\label{fig:potrf}
\end{figure}%
\noindent{\bf Out-of-core multi-GPU Cholesky decomposition.}
Other operations, such as Cholesky decomposition and triangular matrix multiplication (lines \ref{line:chol1},~\ref{line:lauum_bg},~\ref{line:chol2} of Algorithm~\ref{alg:falkon}), can also benefit from GPU execution.
Here we describe, at a high level, our algorithm for multi-GPU OOC Cholesky decomposition inspired by~\cite{ltaief10magma, wu18parallel}. We leave further details to Appendix~\ref{app:ooc}.
Consider a symmetric matrix $A$, split into $B\times B$ tiles $A_{ij} \in \real{t\times t}, i \in [B], j \in [B]$, assumed of equal size for brevity. We want a factorization $A = L L^\top$, where $L$ is lower triangular, with the formula $A_{i,j} = \sum_{k=1}^j L_{i,k}L_{j,k}^\top$.
The algorithm runs in-place, updating one column of $A$ at a time. Each column update proceeds in three steps, illustrated in Figure~\ref{fig:potrf}. Clearly $A_{1,1} = L_{1,1}L_{1,1}^\top $ so we compute $L_{1,1}$ by a Cholesky decomposition on tile $A_{1,1}$ which is small and can be done entirely on the GPU (e.g. with cuSOLVER~\cite{cusolver}).
Then we consider the other tiles of the first block column of $L$ for which $A_{j,1} = L_{j,1}L_{1,1}^\top $ with $j > 1$. Since we know $L_{1,1}$ from the first step, we obtain $L_{j,1} = A_{j,1}L_{1,1}^{-\top} $ for all $j > 1$ by solving a triangular system (on the GPU).
Finally the first block column of $L$ is used to update the trailing submatrix of $A$. Note that $A_{i,j} = \sum_{k=1}^j L_{i,k}L_{j,k}^\top = L_{i,1}L_{j,1}^\top + \sum_{k=2}^jL_{i,k}L_{j,k}^\top $ for $2 \le j \le i$, so we can update the trailing submatrix as $A_{i,j} = A_{i,j} - L_{i,1}L_{j,1}^\top $.
We implemented a parallel version of the above algorithm which distributes block-rows between the available processors in a 1D block-cyclic way (e.g.~Figure~\ref{fig:potrf} (left): rows 1 and 3 are assigned to GPU-1, rows 2 and 4 are assigned to GPU-2).
For each column update, one processor executes the first step and transfers the result to the others (the arrows in Figure~\ref{fig:potrf}), which can then execute step 2 in parallel. To update the trailing matrix, further data transfer between devices may be necessary.
The tile-size is chosen as a function of GPU memory: each device needs to hold one block column plus a single block at any given time. An analysis of the scalability of our implementation is in Appendix~\ref{app:ooc}.
\subsection{Optimizing data transfers and other improvements.}
The speed of computations on GPUs is such that data transfers to and from the devices become significant bottlenecks. We have described earlier how, for matrix-vector products, the computed blocks of $K_{nm}$ never leave the device.
Further, optimization is possible by parallelizing computations and
data transfers. Indeed, modern GPUs have an independent and parallel control on the following activities: loading from RAM, saving to RAM, performing computations.
By running three parallel threads for the same GPU and assuming equal duration of each piece of work, we can run $t$ GPU computations in $t+2$ time units instead of $3t$ time units for a serial implementation (see Figure~\ref{fig:super-scalar}, where $t=3$). This guarantees near optimal usage of the GPU and in practice corresponds to a considerable speed up of matrix-vector products.\\
\noindent{\bf Leveraging the trade-off numerical precision / computational power.}
GPUs are designed to achieve peak performance with low precision floating point numbers, so much that going from 64 to 32-bit floats can correspond (depending on the exact architecture) to $\approx10\times$ throughput improvement.
However, changing precision can lead to unexpected problems. For example, computing the Gaussian kernel is commonly done by expanding the norm $\norm{\bm{x}-\bm{x}'}^2 = \bm{x}^{\top}\bm{x} - 2\bm{x}^{\top}\bm{x}' + \bm{x}'^{\top}\bm{x}'$, but in high dimensions $\norm{\bm{x}}, \norm{\bm{x}'}$ can be very large and the cross-term very negative, so their sum has fewer significant digits.
Loss of precision can lead to non positive-definite kernels causing Cholesky decomposition to fail.
To avoid this, we compute $K_{mm}$ in blocks, converting each block to 64-bit precision for the sum, and then back to 32-bits.\\
\noindent{\bf Dealing with thin submatrices.}
As a result of our block division strategies, it may happen that blocks become thin (i.e. one dimension is small). In this case, matrix operations, e.g.~using cuBLAS~\cite{cublas}, cannot leverage the full computational power. In turn this can reduce performance, breaking the inherent computational symmetry among GPUs which is crucial for the effectiveness of a parallel system like the one proposed in this paper. To guarantee good performance for this case, instead of using standard GPU operations, we perform matrix-vector products using KeOps~\cite{keops}: a specialized library to compute kernel matrices very efficiently when one dimension is small, see Table~\ref{tbl:perf-imp}.\\
\noindent{\bf Dealing with sparse datasets.}
On the other side of the spectrum, sparse datasets with high dimensionality are common in some areas of machine learning. While the kernel computed on such datasets will be dense, and thus can be handled normally, it is inefficient and in some cases impossible (e.g.~with $d\sim10^6$ as is the case for the YELP dataset we used) to convert the inputs to a dense representation.
We therefore wrapped specialized sparse linear algebra routines to perform sparse matrix multiplication~\cite{cusparse}, and adapted other operations such as the row-wise norm to sparse matrices.
Thus our library handles sparse matrices with no special configuration, both on the GPU and -- if a GPU is not available -- on the CPU. | {'timestamp': '2020-11-30T02:17:16', 'yymm': '2006', 'arxiv_id': '2006.10350', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10350'} | arxiv |
\section{Introduction}\label{sec:intro}
With the wide use of mobile applications such as TikTok, Pandora radio and Instagram feeds, interactive recommender systems (IRS) have received much attention in recent years \cite{zhao2013interactive,wang2017factorization}.
Unlike that in traditional recommender systems \cite{he2017neural,wang2006unifying, koren2009matrix}, where the recommendation is treated as a one-step prediction task, the recommendation in IRS is formulated as a multi-step decision-making process. In each step, the system delivers an item to the user and may receive feedback from her, which subsequently derives the next recommendation decision in a sequential manner. The recommendation-feedback interaction is repeated until the end of this visit session of the user. The goal of the IRS is to explore users' new interests, as well as to exploit the learned preferences, to provide accurate predictions, so as to optimize the outcome of the entire recommendation sequence \cite{zhao2013interactive,zhao2018recommendations}.
One way to implement IRS and balance the exploration and exploitation is multi-armed bandit (MAB) methods~\cite{li2010contextual,zeng2016online,wang2017factorization}. In MAB-based models, the user preference is often modeled by a linear function that is continuously learned through the interactions with proper exploration-exploitation tradeoff.
However, these MAB-based models pre-assume that the underlying user preference remains unchanged during the recommendation process, i.e., they do not model the dynamic transitions of user preferences \cite{zhao2013interactive}.
The key advantage for modern IRS is to learn about the possible dynamic transitions of the user's preference and optimize the long-term utility.
Recently, some researchers have incorporated deep reinforcement learning (DRL) models into interactive recommender system \cite{zheng2018drn,zhao2018recommendations,hu2018reinforcement,chen2019large, zhao2018deep}, due to the great potential of DRL in decision making and long-term planning in dynamic environment~\cite{silver2016mastering}. \citet{mahmood2007learning} first proposed to used model-based techniques in RL where dynamic programming algorithms such as policy iteration are utilized. Some recent works use model-free frameworks to tackle IRS tasks, e.g., deep Q-network (DQN)~\cite{zhao2018recommendations} and deep deterministic policy gradient (DDPG)~\cite{hu2018reinforcement}.
Nevertheless, employing DRL in real-world interactive recommender system is still challenging.
A common method for training recommendation models is to make use of offline logged data directly, but it will suffer from the estimation bias problem~\cite{chen2019top} under the real-time interaction setting. In contrast, the ideal setting of learning the optimal recommendation policy is to train the agent online. However, due to the item-state search space for each recommendation step and the trial-and-error nature of RL algorithms,
DRL methods normally face sample efficiency problem \cite{zou2019reinforcement}, i.e., learning such a policy requires a huge amount of data through interacting with real users before achieving the best policy, which may degrade user experience and damage system profit \cite{zhang2016collectivepolicy}. Therefore, it is quite crucial to improve the sample efficiency of existing DRL models with only a limited amount of interaction data.
Fortunately, there is rich prior knowledge from other external sources that may contribute to dealing with the above problems, such as textual reviews, visual images or item attributes~\cite{cheng2016wide}.
Among these, knowledge graph (KG), a well-known structured knowledge base,
represents various relations as the attributes of items and links items if they have common attributes, which has shown great effectiveness for representing the correlation between items \cite{wang2018ripplenet}. The association between the items provided by KG is very suitable for the recommendation scenarios. For example, a user likes the movie $\textit{Inception}$, and the information behind it may be that her favorite director is $\textit{Nolan}$. With such links among actions (items) on the graph, one user-item interaction record could reveal the user's preference on multiple connected items. In addition, the information contained in the semantic space of the entire knowledge graph will also be helpful in extracting user interest during the recommendation process. Since there have been many successful works applying open-sourced KGs (such as DBpedia, NELL, and Microsoft Satori)
to \textit{traditional} recommendation systems~\cite{yu2014personalized,zhang2016collaborative,wang2018ripplenet}, we believe that it is reasonably promising to leverage KG to DRL-based methods in IRS scenarios.
In this paper, we make the first attempt to leverage KG for reinforcement learning in interactive recommender systems, trying to address the aforementioned limitations of the existing DRL methods.
We propose \textit{KGQR (Knowledge Graph enhanced Q-learning framework for interactive Recommendation)}, a novel architecture that extends DQN. Specifically, we integrate graph learning and sequential decision making as a whole to facilitate knowledge in KG and pattern mining in IRS. On one hand, to alleviate data sparsity, the user feedback is modeled to propagate via structure information of KG, so that the user's preference can be transited among correlated items (in the KG). In this way, one interactive record can affect multiple connected items, thus the sample efficiency is improved. On the other hand, by aggregating the semantic correlations among items in KG, the item embedding and the user's preference are effectively represented, which leads to more accurate Q-value approximation and hence better recommendation performance. In addition, we also conduct a methodology to deal with action selection in such large space. Rather than enumerating the whole item set, each step the candidate set for recommendation is dynamically generated from the local graph of KG, by considering the neighborhood of the items in user's high-scored interacted items. The method of candidate selection forces the deep Q-network to fit on the samples that KG considers more useful through the structure of item correlations, hence it can make better use of limited learning samples for RL-algorithm.
To the best of our knowledge, this is the first work to introduce KG into RL-based methods to interactive recommender systems. The contributions of our work can be summarized as follows.
\begin{itemize}[leftmargin = 10pt]
\item We propose a novel end-to-end deep reinforcement learning based framework KGQR for interactive recommendation to addresses the sparsity issue. By leveraging prior knowledge in KG in both candidate selection and the learning of user preference from sparse user feedback, KGQR can improve sample efficiency of RL-based IRS models.
\item The dynamic user preference can be represented more precisely by considering the semantic correlations of items in KG, with graph neural networks.
\item Extensive experiments have been conducted on two real-world datasets, demonstrating that KGQR is able to achieve better performance than state-of-the-arts with much fewer user-item interactions, which indicates high sample efficiency.
\end{itemize}
\section{Related Work}
\label{sec:related}
\noindent\textbf{Traditional KG Enhanced Recommendation}.
Traditional KG enhanced recommendation models can be classified into three categories: path-based methods, embedding-based methods and hybrid methods.
In \emph{path-based} methods~\cite{yu2014personalized,shi2015semantic,zhao2017meta}, KG is often treated as a heterogeneous information network (HIN), in which specific meta-paths/meta-graphs are manually designed to represent different patterns of connections.
The performance of these methods is heavily dependent on the hand-crafted meta-paths, which are hard to design.
In \emph{embedding-based} methods, the entity embedding extracted from KG via Knowledge Graph Embedding (KGE) algorithms (like TransE~\cite{bordes2013translating}, TransD~\cite{ji2015knowledge}, TransR~\cite{lin2015learning}), is utilized to better represent items in recommendation. \citet{zhang2016collaborative} propose Collaborative Knowledge Base Embedding (CKE), to jointly learn the latent representations in collaborative filtering as well as items' semantic representations from the knowledge base, including KG, texts, and images. MKR~\cite{wang2019multi} associates the embedding learning on KG with the recommendation task by cross \& compress units.
KSR~\cite{huang2018improving} extends the GRU-based sequential recommender by integrating it with a knowledge-enhanced Key-Value Memory Network.
In \emph{hybrid} methods, researchers combine the above two categories to learn the user/item embeddings by exploiting high-order information in KG. Ripplenet~\cite{wang2018ripplenet} is a memory-network-like model that propagates users' potential preferences along with links in the KG.
Inspired by the development of graph neural network ~\cite{kipf2016semi,hamilton2017inductive,velivckovic2017graph}, KGAT ~\cite{wang2019kgat} applies graph attention network~\cite{velivckovic2017graph} framework in a collaborative knowledge graph to learn the user, item and entity embeddings in an end-to-end manner.
However, most of these methods are one-step prediction tasks and can not model the iterative interactions with users. Besides, they all greedily optimize an immediate user's feedback and
don't take the user's long-term utility into consideration.
\vspace{5pt}\noindent\textbf{Reinforcement Learning in IRS}.
RL-based recommendation methods model the interactive recommendation process as a Markov Decision Process (MDP), which can be divided into model-based and model-free methods. As one of the \emph{model-based} techniques, Mahmood and Ricci \cite{mahmood2007learning} utilize policy iteration to search for the optimal recommendation policy where an action is defined to be an item and a state is represented as $n$-gram of items.
Policy iteration needs to go through the whole state space in each iteration, with exponential complexity to the number of items. Therefore, it is unable to handle large state and action space.
Recently, most works on RL-based recommendation prefer \emph{model-free} techniques, including policy gradient (PG)-based, DQN-based and DDPG-based methods. PG-based methods, as well as DQN-based, treat recommending an item as an action. PG-based methods~\cite{chen2019large} learn a stochastic policy as a distribution over the whole item space and sample an item according to such distribution.
DQN-based methods ~\cite{zhao2018recommendations,zheng2018drn,zou2019reinforcement} learn Q-value for each item and select the item with the maximum Q-value.
Zheng et al.~\cite{zheng2018drn} combine DQN and Dueling Bandit Gradient Decent (DBGD) \cite{grotov2016online} to conduct online news recommendation. Zou et al.~\cite{zou2019reinforcement} integrate both the intent engagement (such as click and order) and long-term engagement (such as dwell time and revisit) when modeling versatile user behaviors. In DDPG-based works, an action is often defined as a continuous ranking vector.
Dulac et al.~\cite{dulac2015deep} represent the discrete actions in a continuous vector space, pick a proto-action in a continuous hidden space according to the policy and then choose the valid item via a nearest neighbor method. In \cite{hu2018reinforcement, zhao2018deep}, the policies compute the ranking score of an item by calculating the pre-defined function value (such as an inner product) of the generated action vector and the item embedding.
Nevertheless, all existing RL-based recommendation models suffer from low sample efficiency issue and need to pre-train user/item embeddings from history, which means that they cannot handle recommendation on cold-start problem well. A significant difference between our approach and the existing models is that we first propose a framework that combines the semantic and structural information of KG with the IRS to break such limitations.
\begin{figure}[t]
\begin{centering}
\includegraphics[width=\columnwidth]{source/KG_overall.pdf}
\vspace{-10pt}
\caption{The overall KGQR framework. The left part illustrates the interaction process between the user and the IRS. The right part illustrates how the IRS recommends an item to the user according to past interaction history.}
\label{fig:overall}
\end{centering}
\vspace{-10pt}
\end{figure}
\section{Problem Formulation}
\label{sec:problem}
In feed streaming recommendation scenario, the interactive nature between the recommender system and the user is a multi-step interaction process that lasts for a period of time. At each timestep $t$, according to the observations on past interactions,
the recommendation agent delivers an item $i_t\in\mathcal I$ to the user, and receives feedback (e.g., click, purchase or skip) from her. This process continues until the user leaves the recommender system. Under such circumstances, the interactive recommendation process can be formulated as a Markov Decision Process (MDP). The ultimate goal of the recommender system is to learn a recommendation policy $\pi:\mathcal S \to \mathcal I$, which maximizes the cumulative utility over the whole interactive recommendation process as
\begin{equation}
\pi^* = \arg\max_{\pi\in\Pi}\mathbb{E}\Big[\sum_{t=0}^{T} r(s_t,i_t)\Big] .
\end{equation}
Here $s_{t}\in \mathcal{S}$ is a representation abstracted from user's positively interacted items $ o_t = \{i_1,i_2,...i_n\}$ that denotes user's preference at timestep $t$; $r(s_t,i_t)$ is the user's immediate feedback to the recommended item $i_t$ at the state $s_t$ according to some internal function $\mathcal{R} : \mathcal{S} \times \mathcal{I} \to \mathbb{R}$, abbreviated as $r_t$.
\begin{table}[t]
\centering
\caption{Notations and descriptions.}
\vspace{-10pt}
\resizebox{\columnwidth}{!}{
\setlength{\tabcolsep}{3pt}
\begin{tabular}{c|l}
\hline
Notations & Descriptions \\
\hline
$\mathcal U, \mathcal I$ & Set of users and items in IRS.\\
$\mathcal G = (\mathcal E, \mathcal R)$ & Knowledge graph. \\
$\mathcal E, \mathcal R $ & Set of entities and relations in $\mathcal G$. \\
$ o_t = \{i_1,i_2,...i_n\}$ & Recorded user's positively interacted at timestep $t$. \\
$\mathbf{s}_t $ & Dense representation of user's preference at timestep $t$. \\
$ r_t $ & The user's reward at timestep $t$. \\
$T$ & Episode length. \\
$\mathbf{e}_{h},h\in \mathcal{E} $ & Dense representation of an entity.\\
$\mathcal I_t(\mathcal G)$ & Candidate action space at timestep $t$.\\
$\theta_S$ & Parameters of state representation network.\\
$\theta_Q,\theta_Q'$ & Parameters of online Q-network /target Q-network.\\
$\mathcal D$ & Replay Buffer.\\
\hline
\end{tabular}
}
\label{table:notation}
\end{table}
To achieve this goal, traditional recommendation methods usually adopt a greedy strategy and only optimize one-step reward, i.e., at each timestep $t$, they optimize the immediate reward $r_t$. Different from them,
DRL algorithms take the long-term impact into consideration and explicitly model the long-run performance. They will optimize $\sum_{j=0}^{T-t} \gamma^{j} r_{t+j}$ at timestep $t$, instead. And $\gamma \in (0, 1] $ is the discount factor to control the degressively accumulated long-term rewards.
In general, we can use Q-value to evaluate the value of an action (i.e., recommending an item) taken at a given state, defined as
\begin{equation}
Q^{\pi}(s_{t},i_{t}) = \mathbb{E}\Big[\sum_{j=0}^{T-t} \gamma^{j} r_{t+j}\Big]=\mathbb{E}\Big[r_{t}+\sum_{j=1}^{T-t}\gamma^{j}r_{t+j} \Big],
\end{equation}
which is a weighted sum of the expected reward of all future steps starting from the current state and following the policy $\pi$ to take actions. Then following the optimal Bellman equation~\cite{bellman1952theory}, the optimal $Q^*$, having the maximum expected reward achievable is:
\begin{equation}
Q^{*}(s_{t},i_{t}) = \mathbb{E}_{s_{t+1}}[r_{t}+\gamma \max_{i_{t+1}}Q^{*}(s_{t+1},i_{t+1})|s_{t},i_{t}].
\label{eq:bellman}
\end{equation}
Since the state and action spaces are usually enormous, we normally estimate the Q-value of each state-action ($s_t,i_t$) pair via a $\theta_Q$-parameterized deep neural network, i.e., $Q^*_{\theta_Q}(s_{t},i_{t}) \approx Q^*(s_t,i_t)$.
As mentioned in Section~\ref{sec:intro}, learning this Q-function from scratch requires numerous interactions with real users due to the low data efficiency problem that is common in the RL algorithm. However, unlike basic RL algorithms, in RS scenarios, KG can provide complementary and distinguishable information for each item by their latent knowledge-level connection in the graph. Thus, with the prior knowledge of the environment and actions, the Q-function can be learned more efficiently,
\begin{equation}
Q^*_{\theta_Q}(s_{t},i_{t};\mathcal G) = Q^*_{\theta_Q}\Big(s_t(\mathcal G),i_t(\mathcal G)\Big).
\end{equation}
Here $\mathcal { G } $ is the knowledge graph comprised of subject-property-object triples facts, e.g., triple ($\textit{Nolan}, \textit{DirectorOf}, \textit{Inception}$), which denotes $\textit{Nolan}$ is the director of $\textit{Inception}$. And it is ofen present as ($\textit{head},\textit{relation}, \textit{tail}$), $\textit{head} \in \mathcal{E}$, $ \textit{relation} \in \mathcal{R}$ , $\textit{tail} \in \mathcal{E}$ and $\mathcal{E}$, $\mathcal{R}$ denote the set of entities and relationships in $\mathcal{G}$, respectively. Usually, an item $i \in \mathcal I$ can be linked to an entity $e \in \mathcal E$ in the knowledge graph, e.g., the movie $\textit{Godfather}$ from MovieLens dataset has a corresponding entity entry in DBpedia. We will introduce how we design the knowledge enhanced DRL framework for IRS in the following sections and the key notations used in this paper are summarized in Table \ref{table:notation}.
\section{KGQR Methodology}
\label{sec:model}
The overview of our proposed framework is shown in Figure~\ref{fig:overall}. Generally, our KGQR model contains four main components: graph convolution module, state representation module, candidate selection module and Q-learning network module. In the interactive recommendation process, at each timestep $t$, the IRS sequentially recommends items $i_t$ to users, and correspondingly updates its subsequent recommendation strategy based on user's feedback $r_t$. At the specific time during one recommendation session, according to the interaction history $o_t$ combined with the knowledge graph $\mathcal G$, the IRS models the user's preference $s_t$ via graph convolution module and state representation module. The details of these two representation learning modules will be discussed in Section~\ref{sec:state}.
Then the IRS calculates the highest-scored item in the candidate set through Q-network and recommends it to the user. We will introduce the candidate selection module and deep Q-network module in Section~\ref{sec:CS} and Section~\ref{sec:DDQN}, respectively.
\subsection{KG Enhanced State Representation}\label{sec:state}
In IRS scenario, it is impossible to get user's state $s_t$ directly, and what we can directly observe is the recorded user-system interaction history $o_t$. As state is one of the key part in MDP, the design of state representation module is critical to study the optimal recommendation strategy.
\subsubsection{Graph convolutional embedding layer}
Generally, the state representation in IRS is abstracted from the user's clicked\footnote{Without loss of generality, we take ``click'' behavior as user positive feedback as the running example.} items, since the positive items represent the key information about what the user prefers~\cite{zhao2018recommendations}. Given the user's history, we first convert the clicked item set $\{i_t\}$ into embedding vectors $\mathbf{i}_t\in \mathbb{R}^{d}$, where $d$ is the dimension of the embeddings.
Since we have already linked items with entities in KG, we can take advantage of the semantic and correlation information among items in KG for better item embedding $\mathbf{i}_t(\mathcal G)$.
In order to distill structural and semantic knowledge in the graph into a low-dimensional dense node representation, different approaches of graph embedding methods can be applied. In addition to harvesting the semantic information, we incline to explicitly link these items so that one data can affect more items. Thus, a graph convolutional network (GCN) ~\cite{kipf2016semi} is used in our work to recursively propagate embeddings along the connectivity of items and learn the embeddings of all entities $\{\mathbf{e}_{h}\in \mathbb{R}^{d}\}_{h\in \mathcal{E}}$ on the graph $\mathcal G$.
The computation of the node's representation in a single graph convolutional embedding layer is a two-step procedure: aggregation and integration. These two procedures can naturally be extended to multiple hops, and we use the notation $k$ to identify $k$-th hop.
In each layer, first, we aggregate the representations of the neighboring nodes of a given node $h$:
\begin{equation}
\mathbf{e}_{N(h)}^{k-1} = \frac{1}{|N(h)|} \sum_{t \in N(h)} \mathbf{e}_{t}^{k-1},
\label{eq:GCN1}
\end{equation}
where $N(h)=N(\textit{head})=\{\textit{tail} ~|~ (\textit{head},\textit{relation}, \textit{tail} ) \in \mathcal { G }\}$ is the set of neighboring nodes of $h$. Notice that, here we consider the classic \emph{Average} aggregator for example, other aggregator like concat aggregator ~\cite{hamilton2017inductive}, neighbor aggregator or attention mechanism (GAT)~\cite{velivckovic2017graph} can also be implemented.
Second, we integrate the neighborhood representation with $h$'s representation as
\begin{equation}
\mathbf{e}_h^{k} = \sigma (\mathbf{W}_{k} \mathbf{e}_{N(h)}^{k-1} +\mathbf{B}_{k} \mathbf{e}_{h}^{k-1}),
\label{eq:GCN2}
\end{equation}
where $\mathbf{W}_{k}$ and $\mathbf{B}_{k}$ are trainable parameters for $k$-hop neighborhood aggregator and $\sigma$ is the activation function implemented as $\text{ReLU}(x) = \max(0, x)$.
In Equation~\ref{eq:GCN2}, we assume the neighborhood representation and the target entity representation are integrated via a multi-layer perceptron. After $k$-hop graph convolutional embedding layer, each clicked item is then converted into $\mathbf{i}_t(\mathcal G)= \mathbf{e}_{i_t}^k$.
\subsubsection{Behavior aggregation layer}
Since the interactive recommendation is a sequential decision-making process, at each step, the model requires the current observation of the user as input, and provides a recommended item $i_t$ as output. It is natural to use auto-regressive models such as recurrent neural networks (RNN) to represent the state based on the observation-action sequence ~\cite{hausknecht2015deep,narasimhan2015language}.
Thus, we use an RNN with a gated recurrent unit (GRU) as the network cell~\cite{cho2014learning} to aggregate user's historical behaviors and distill user's state $\mathbf{s}_t(\mathcal G)$.
The update function of a GRU cell is defined as
\begin{equation}
\begin{aligned}
\mathbf{z}_{t} &=\sigma_{g}\left(\mathbf{W}_{z} \mathbf{i}_{t}+\mathbf{U}_{z} \mathbf{h}_{t-1}+\mathbf{b}_{z}\right), \\
\mathbf{r}_{t} &=\sigma_{g}\left(\mathbf{W}_{r} \mathbf{i}_{t}+\mathbf{U}_{r} \mathbf{h}_{t-1}+\mathbf{b}_{r}\right), \\
\hat{\mathbf{h}}_t &= \sigma_{h}\left(\mathbf{W}_{h} \mathbf{i}_{t}+\mathbf{U}_{h}\left(\mathbf{r}_{t} \circ \mathbf{h}_{t-1}\right)+\mathbf{b}_{h}\right),\\
\mathbf{h}_{t} &=\left(1-\mathbf{z}_{t}\right) \circ \mathbf{h}_{t-1}+\mathbf{z}_{t} \circ \hat{\mathbf{h}}_t,
\end{aligned}
\label{eq:gru}
\end{equation}
where $\mathbf{i}_t$ denotes the input vector, $\mathbf{z}_t$ and $\mathbf{r}_t$ denote the update gate and reset gate vector respectively, $\circ$ is the elementwise product operator.
The update function of hidden state $\mathbf{h}_t$ is a linear interpolation of previous hidden state $\mathbf{h}_{t-1}$ and a new candidate hidden state $\hat{\mathbf{h}}_t$. The hidden state $\mathbf{h}_t$ is the representation of current user state, which is then fed into the Q-network, i.e.,
\begin{equation}
\mathbf{s}_t(\mathcal G) = \mathbf{h}_t.
\label{eq:s_t}
\end{equation}
For simplicity, the set of the whole network parameters for computing $\mathbf{s}_t(\mathcal G)$, including parameters of graph convolutional layer and parameters of GRU cell, is denoted as $\theta_S$.
In Figure~\ref{fig:architecture}(a), we illustrate the knowledge enhanced state representation module elaborated above. The upper part is the recurrent neural network that takes clicked item's embedding at each timestep as the input vector, and outputs the hidden state of the current step as the state representation. The item embeddings, which are the input to GRU, are learned by performing graph convolutional network in KG, as shown in the bottom part.
\begin{figure}[t]
\centering
\includegraphics[width=\columnwidth]{source/architecture.pdf}
\vspace{-10pt}
\caption{The neural architecture of KGQR. (a) The knowledge-enhanced state representation module maintains user's preferences with a recurrent neural network and a graph neural network; (b) The candidate selection module dynamically reduces large action space according to user's positive feedback; (c) The Q-value network predicts the Q-value with a value network and an advantage network. }
\label{fig:architecture}
\vspace{-10pt}
\end{figure}
\subsection{Neighbor-based Candidate Selection}
\label{sec:CS}
Generally, the clicked items have some inherent semantic characteristics, e.g., similar genre movies \cite{wang2018ripplenet}. Since users are usually not likely to be interested in all items, we can focus on selecting the potential candidates for restricted retrieval based on this semantic information in KG. Specifically, we utilize KG to filter some irrelevant items (i.e., actions) and dynamically obtain the potential candidates. The restricted retrieval will focus the data samples on the area that is more useful, as suggested in the structure of item correlation. Thus, these potential candidates would not only reduce the large searching space, but also improve the sample efficiency of policy learning.
More specifically, we perform a sampling strategy based on the $k$-hop neighborhood in KG.
In each timestep $t$, the user's historical interacted items serve as the seed set $\mathcal { E } _ { t } ^ {0} = \{i_{1},i_{2},...i_{n}\} $.
The $k$-hop neighborhood set starting from the seed entities is denoted as
\begin{equation}
\begin{aligned}
\mathcal { E } _ { t } ^ { k } = \left\{ \textit{tail} ~|~ (\textit{head},\textit{relation}, \textit{tail} ) \in \mathcal { G } \text { and } \textit{head} \in \mathcal { E } _ { t } ^ {l - 1 } \right\} ,\\ \quad l = 1,2 , \ldots ,k .
\end{aligned}
\label{eq:CS1}
\end{equation}
Then, the candidate action set for the current user state is defined as
\begin{equation}
\mathcal{I}_{t}(\mathcal G) =\Big\{ \textit{item} | \textit{item} \in \bigcup_{l=1}^{k}\mathcal { E } _ { t } ^ { l }\ \text{and}\ \textit{item} \in \mathcal{I} \Big\},
\label{eq:CS2}
\end{equation}
with a user-defined cardinality.
The shallow part in "candidate selection" in Figure~\ref{fig:architecture}(b) denotes the selected actions with the information from KG. Then all candidate items get their embedding through the graph convolutional layers.
\subsection{Learning Deep Q-Network} \label{sec:DDQN}
After modeling the user's state $\mathbf{s}_t(\mathcal G)$ and obtaining candidate sets $\mathcal{I}_{t}(\mathcal G)$, we need to design Q-network to combine this information and improve the recommendation policy for the interactive recommendation process. Here we implement a deep Q-network (DQN) with dueling-Q \cite{wang2015dueling} and double-Q \cite{van2016deep} techniques to model the expected long-term user satisfaction from the current user state as well as to learn the optimal strategy.
\subsubsection{Deep Q-network.} We adopt dueling technique to reduce the approximation variance and stabilize training ~\cite{wang2015dueling}. That is, using two networks to compute the value function $V(i_{t}(\mathcal G))$ and advantage functions $A(s_{t}(\mathcal G),i_{t}(\mathcal G))$ respectively, and it is shown in Figure~\ref{fig:architecture}. Then the Q-value can be computed as,
\begin{equation}
Q(s_t(\mathcal G),i_t(\mathcal G);\theta_V,\theta_A)= V(i_{t}(\mathcal G);\theta_V)+A(s_{t}(\mathcal G),i_{t}(\mathcal G);\theta_A).
\label{eq:qnet}
\end{equation}
Here the approximation of value function and advantage function are accomplished by multi-layer perceptrons. $\theta_V$ and $\theta_A$ is the parameter of value function and advantage function respectively and we denote $\theta_Q = \{\theta_V,\theta_A\}$.
\subsubsection{Model training.} With the proposed framework, we can train the parameters of the model through trial-and-error process. During the interactive recommendation process, at timestep $t$, the recommender agent gets the user's state $\mathbf{s}_t$ from the observations $o_t$ about her, and recommendeds an item $i_t$ via an $\epsilon$-greedy policy (i.e., with probability $1-\epsilon$ choosing the item in the candidate with the max Q-value, with probability $\epsilon$ choosing a random item). Then the agent receives the reward $r_t$ from the user's feedback and stores the experience $(o_t, i_t, r_t, o_{t+1})$ in the replay buffer $\mathcal D$. From $\mathcal D$, we sample mini-batch of experiences, and minimize the mean-square loss function to improve the Q-network, defined as
\begin{equation}
L(\theta_Q) = \mathbb{E}_{(o_t,i_t,r_t,o_{t+1})\sim\mathcal D}[(y_t-Q(\mathbf{s}_t,\mathbf{i}_t;\theta_Q))^{2}].
\label{eq:loss}
\end{equation}
Here $y_t$ is the target value based on the optimal $Q^*$. According to Equation (\ref{eq:bellman}), $y_t$ is defined as
\begin{equation}
y_t=r_t+\gamma \max\limits_{{i}_{t+1}\in\mathcal I_{t+1}(\mathcal G)}Q(s_{t+1},i_{t+1};\theta_Q).
\end{equation}
To alleviate the overestimation problem in original DQN, we also utilize a target network $Q'$ along with the online network $Q$ (i.e., the double DQN architecture~\cite{van2016deep}). The online network back-propagates and updates its weights at each training step. The target network is a duplicate of the online network and updates its parameters with training delay. The target value of the online network update is then changed to
\begin{equation}
y_t=r_t+\gamma Q'\Big(s_{t+1},\mathop{\arg\max}\limits_{i_{t+1}\in\mathcal I_{t+1}(\mathcal G)} Q(s_{t+1},i_{t+1};\theta_Q);\theta_Q'\Big),
\label{eq:target}
\end{equation}
where $\theta_Q'$ denotes the parameter of the target network, and $\theta_Q'$ updates according to soft assign as
\begin{equation}
\theta_Q' = \tau\theta_Q+(1-\tau)\theta_Q',
\label{eq:Q'}
\end{equation}
where the interpolation parameter $\tau$ is also called update frequency.
To summarize, the training procedure of our KGQR is presented in Algorithm~\ref{alg:trainingKGQR}.
Note that this paper mainly focuses on the way of incorporating KG into DRL methods for IRS. Thus we study the most typical DQN model as a running example. Our method can be seamlessly incorporated into other DRL models such as policy gradient (PG) \cite{chen2019large}, DDPG \cite{hu2018reinforcement} etc.
\begin{algorithm}[t]
\small
\caption{Training KGQR}
\label{alg:trainingKGQR}
\KwIn{ $\mathcal{D}$; $\tau$; $\epsilon$;}
\KwOut{ $\theta_S$; $\theta_Q$; $\{\mathbf{e}_h\}_{h\in \mathcal{E}} $; }
Initialize all parameters: $\theta_S$, $\theta_Q$, $\{\mathbf{e}_h\}_{h\in \mathcal{E}}$, $\theta_Q' \leftarrow \theta_Q$\;
\Repeat{coverged}{
\For{$u \in \mathcal U$}{
Initialize the clicked history $\mathbf{x} \leftarrow \{\}$\;
\For{$t \in \{ 0, 1, \ldots , T\}$}{
for $ \mathbf{x} =o_t = \{i_{1},i_{2},\ldots,i_{n}\} $, get $\{ \mathbf{i}_{1}, \ldots, \mathbf{i}_{n}\}$ via Eq.(\ref{eq:GCN1}), Eq.(\ref{eq:GCN2})\;
Get $\mathbf{s}_t$ via Eq.(\ref{eq:gru}), Eq.(\ref{eq:s_t})\;
Recommend $i_t$ by $\epsilon$-greedy w.r.t Q-value in Eq.(\ref{eq:qnet})\;
Receive reward $r_t$\;
\If{$r_t>0$}{Append $i_t$ to $\mathbf{x}$\;}
Set $o_{t+1} \leftarrow \mathbf{x}$\;
Get $\mathcal{I}_{t+1}(\mathcal G)$ via Eq.(\ref{eq:CS1}), Eq.(\ref{eq:CS2})\;
Store $(o_t, i_t, r_t, o_{t+1}, \mathcal{I}_{t+1}(\mathcal G))$ to buffer $\mathcal{D}$\;
}
Sample mini-batch of tuples $(o_t, i_t, r_t, o_{t+1}, \mathcal{I}_{t+1}(\mathcal G)) \sim \mbox{Unif}(\mathcal{D})$\;
Get $\mathbf{s}_t,\mathbf{s}_{t+1}$ from $o_{t}, o_{t+1}$ via Eq.(\ref{eq:GCN1}), Eq.(\ref{eq:GCN2}) and Eq.(\ref{eq:gru})\;
Construct target values $y_t$ via Eq. (\ref{eq:target})\;
Update $\theta_S$, $\theta_Q$, $\{\mathbf{e}_h\}_{h\in \mathcal{E}} $ via SGD w.r.t the loss function Eq.(\ref{eq:loss})\;
Update $\theta_Q'$ via Eq. (\ref{eq:Q'}) \;
}
}
\end{algorithm}
\section{Experiment}
\label{sec:exp}
We conduct experiments on two real-world datasets to evaluate our proposed KGQR framework.
We aim to study the following research questions (RQs):
\begin{itemize}[leftmargin = 10pt]
\item \textbf{RQ1:} How does KGQR perform as compared with state-of-the-art interactive recommendation methods?
\item \textbf{RQ2:} Does KGQR improve sample efficiency?
\item \textbf{RQ3:} How do different components (i.e., KG-enhanced state representation, GCN-based task-specific representation learning, neighbor-based candidate selection) affect the performance of KGQR?
\end{itemize}
\subsection{Experimental Settings}
\subsubsection{Datasets}
We adopt two real-world benchmark datasets for evaluation and describe them as below.
\begin{savenotes}
\begin{description}[leftmargin = 10pt]
\item[Book-Crossing\footnote{http://www2.informatik.uni-freiburg.de/$\sim$\text{cziegler/BX/}}] is a book rating dataset from Book-Crossing community. The ratings are ranging from 0 to 10. This dataset is linked with Microsoft Satori and the sub-KG is released by \cite{wang2018ripplenet}.
\item[Movielens-20M\footnote{https://grouplens.org/datasets/movielens/}] is a benchmark dataset, which consists of 20 million ratings from users to movies in MovieLens website. The ratings are ranging from 1 to 5. It is also linked with Microsoft Satori and the sub-KG is released by \cite{wang2019knowledge}.
\end{description}
\end{savenotes}
For Book-Crossing dataset, we follow the processing of \cite{wang2018ripplenet} to convert original ratings into two categories, 1 for high ratings, 0 for others. For MovieLens-20M dataset, we keep the users with at least 200 interactions. The statistics information of these two datasets is presented in Table~\ref{tab:dataset}.
We choose these two typical datasets since our work focuses on incorporating KG into RL-based models for IRS. The experiments on more datasets with rich domain information such as news or images will be left as future work.
\begin{table}[]
\centering
\caption{Statistics of the datasets.}
\vspace{-10pt}
\small
\begin{tabular}{cl|r|r}
\hline
& &Book-crossing & Movielens-20M \\
\hline
\hline
\multirow{3}{*}{\begin{tabular}[c]{@{}c@{}}User-Item\\ Interaction\end{tabular}} & \#User &17,860 & 16,525\\
&\#Linked Items &14,910&16,426\\
&\#Interactions &139,746&6,711,013 \\
\hline
\hline
\multirow{3}{*}{\begin{tabular}[c]{@{}c@{}}Knowledge\\ Graph\end{tabular}} & \#Entities &77,903 &101,769 \\
&\#Relation Types &25&32\\
&\#Triples &151,500& 489,758\\
\hline
\end{tabular}
\label{tab:dataset}
\end{table}
\subsubsection{Simulator}
Due to the interactive nature of our problem, online experiments where the recommender system interacts with users and learns the policy according to the users' feedback directly would be ideal. However, as mentioned in Section~\ref{sec:intro}, the trial-and-error strategy for training policy in an online fashion would degrade the user's experience, as well as the system profit. Thus, the community has formed a protocol \cite{hu2018reinforcement,chen2019large,zhao2018deep,dulac2015deep,wang2017factorization} to build up an environment simulator based on offline datasets for evaluation.
Following the experiment protocol in \cite{chen2019large}, our mimic environment simulator takes into account the instinctive feedback as well as the sequence nature of user behavior. We perform matrix factorization to train the 20-dimensional embeddings of the users and items. Then we normalize the ratings of each dataset into the range [-1,1], and use them as users' instinctive feedback. Then we combine a sequential reward with the instinctive reward. For instance, if the recommender system recommends an item $i_{j}$ to a user $u_{i}$ at timestep $t$, the final reward function comes as
\begin{equation}\label{eq:sim-reward}
R(s_{t},i_{t}) = r_{ij} + \eta(c_{p}-c_{n}),
\end{equation}
where $r_{ij}$ is the predicted rating given by the simulator, $c_{p}$ and $c_{n}$ means the consecutive positive and negative counts representing the sequential pattern, and $\eta$ is a trade-off between instinctive feedback and sequential nature. In our experiment, $\eta$ is chosen from \{0.0, 0.1, 0.2\}, following the empirical experience in~\cite{chen2019large}.
For each dataset, we randomly divide the users into two parts: 80\% of the users are used for training the parameters of our model, and the other 20\% are used for testing the model performance.
Due to train/test dataset splitting style, the users in our test set never exist in the training set.
That is to say, the experiment is a cold-start scenario, which means there is no user click history at the beginning.
To handle cold-start problem, the recommender system collects the most popular items among the training users, and recommends a popular item to a test user at step $t_0$.
Then, according to the user's feedback, the recommender system recommends items to the user interactively. Besides, we remove the recommended items from the candidate set to avoid repeated recommendation in one episode.
The episode length $T=32$ for all the two datasets in our experiment.
\subsubsection{Evaluation Metrics}
Three evaluation metrics are used.\\
\noindent\textbf{Average Reward}. As an IRS aims to maximize the reward of the whole episode, a straightforward evaluation measure is the average reward over each interaction of test users.
\begin{equation}
Reward = \frac{1}{\#users \times T}\sum_{users}\sum_{t=1}^{T}\gamma ^{t}R(s_{t},i_{t})
\end{equation}
We also check for the precision and recall during $T$ timesteps of the interactions, which are widely used metrics in traditional recommendation tasks.\\
\noindent\textbf{Average Cumulative Precision@$T$}.
\begin{equation}
Precision@T = \frac{1}{\#users\times T}\sum_{users}\sum_{t=1}^{T}\theta_{hit}
\end{equation}
\noindent\textbf{Average Cumulative Recall@$T$}.
\begin{equation}
Recall@T = \frac{1}{\#users}\sum_{users}\sum_{t=1}^{T}\frac{\theta_{hit}}{\#preferences}
\end{equation}
We define $\theta_{hit}=1$ if the instinctive feedback of the recommended item given by the simulator is higher than the predefined threshold, which is 0.5 in Book-Crossing and 3.5 in Movielens-20M. And we define $\#preferences$ is the total number of the positive instinctive feedback among all items, i.e., number of items with $r_{ij}>\textit{boundary}$ based on the simulator.
\noindent\textbf{Significance test}. The Wilocoxon signed-rank test has been performed to evaluate whether the difference between KGQR and the other baselines is significant.
\subsubsection{Baselines}
We compare KGQR with 7 representative baseline methods in the IRS scenario, where GreedySVD and GRU4Rec are traditional recommendation methods, LinearUCB and HLinearUCB are based on multi-armed bandits, DDPG$^\text{KNN}$, DDPGR, DQNR are DRL-based methods.
\begin{description}[topsep = 3pt,leftmargin =10pt]
\item [GreedySVD] is a well-known collaborative filtering methods via singular value decomposition \cite{koren2008factorization}. In interactive scenarios, we train the model after each interaction with users and recommend an item with the predicted highest rating to one user.
\item [GRU4Rec] is a representative RNN-based sequential recommendation algorithm~\cite{hidasi2015session} to predict what the user will click at the next timestep based on the browsing histories.
\item[LinearUCB] is a multi-armed bandit algorithm~\cite{li2010contextual} which selects items according to the estimated upper confidence bound (UCB) of the potential reward based on contextual information about the users and items.
\item[HLinearUCB] is a contextual bandit algorithm combined with extra hidden features~\cite{wang2017factorization}.
\item[DDPG$^\text{KNN}$] is a DDPG-based method~\cite{dulac2015deep} which represents the discrete actions into a continuous vector space. The actor selects a proto-action in the continuous space and then chooses the item with the max Q-value from the candidate items selected via $K$-nearest-neighbor (KNN) according to the proto-action. In this approach, a larger $K$ value boosts the performance but also brings computational cost, indicating the existence of a trade-off between performance and efficiency. In our experiment, the $K$ value is set to \{1, 0.1$N$, $N$\}, where $N$ is the total number of items.
\item[DDPGR] is a DDPG-based method~\cite{zhao2018deep} where the actor learns a ranking vector. The vector is utilized to compute the ranking score of each item, by performing product operation between this vector and item embedding. Then the item with the highest ranking score is recommended to the user.
\item[DQNR] is a DQN-based method~\cite{zheng2018drn} where the recommender system learns a Q function to estimate the Q-value of all the actions at a given state. The method then recommends the item with highest Q-value at the current state.
\end{description}
Note that, traditional knowledge enhanced recommendation methods like CKE~\cite{zhang2016collaborative}, RippleNet~\cite{wang2018ripplenet}, KGAT~\cite{wang2019kgat} and etc. are not suitable for the online interactive recommendation as tested in this paper. Because our recommendation process is an online sequential recommendation in the case of cold-start setting, this means there is no data about the test user at the beginning. We model user preferences in real-time through the user interaction process and provide recommendations under the current situation. These traditional models could not handle this cold-start problem; thus, we do not compare our proposed model with them.
\subsubsection{Parameter Settings}
In KGQR, we set the maximal hop number $k=2$ for both datasets. We have tried larger hops, and find that the model with larger hops brings exponential growth of computational cost with only limited performance improvement.
The dimension of item embedding is fixed to 50 for all the models. For baseline methods, the item embedding is pre-trained by matrix factorization with the training set. For KGQR, we pre-train the embedding of KG by TransE~\cite{bordes2013translating}, and then embedding will be updated while learning the deep Q-network. Besides, other parameters are randomly initialized with uniform distribution. The policy network in all the RL-based methods takes two fully-connected layers with activation function as ReLU. The hyper-parameters of all models are chosen by grid search, including learning rate, $L_{2}$ norm regularization, discount factor $\gamma$ and etc. All the trainable parameters are optimized by \emph{Adam} optimizer ~\cite{kingma2014adam} in an end-to-end manner. We use PyTorch \cite{paszke2019pytorch} to implement the pipelines and train networks with an NVIDIA GTX 1080Ti GPU.
We repeat the experiments 5 times by changing the random seed for KGQR and all the baselines.
\begin{table*}[]
\centering
\caption{Overall Performance Comparison.}
\vspace{-10pt}
\resizebox{\textwidth}{!}{
\begin{tabular}{c|c|c|c|c|c|c|c|c|c|c}
\hline
\multirow{2}{*}{Dataset} & \multirow{2}{*}{Method} & \multicolumn{3}{c|}{$\eta=0$} & \multicolumn{3}{c|}{$\eta=0.1$} & \multicolumn{3}{c}{$\eta=0.2$} \\ \cline{3-11}
& & Reward & Precision@32 & Recall@32 & Reward & Precision@32 & Recall@32 & Reward & Precision@32 & Recall@32 \\ \hline \hline
\multirow{8}{*}{Book-Crossing}& Greedy SVD & -0.0890 & 0.3947 & 0.0031 & -0.1637 & 0.4052 & 0.0032 & -0.2268 & 0.4133 & 0.0033 \\
& GRU4Rec & 0.5162 & 0.8611 &0.0070 & 1.3427 & 0.8595 & 0.0070 &2.1797 & 0.8625 & 0.0070 \\ \cline{2-11}
& LinearUCB & -0.0885 & 0.3956 & 0.0032 & -0.1640 & 0.4049 & 0.0032 & -0.2268 & 0.4133 & 0.0033 \\
& HLinearUCB& -0.1346 & 0.3819 & 0.0031 & -0.3566 & 0.3841 & 0.0031 & -0.6064 & 0.3713 & 0.0031 \\ \cline{2-11}
& DDPGR & 0.5521 & 0.9115 & 0.0074 & 1.1412 & 0.8800 & 0.0072 & 2.2057 & 0.9270 & 0.0076 \\
& DDPG$^\text{KNN}$(K=1) & 0.3159 & 0.7302 & 0.0059 & 0.7312 & 0.7990 & 0.0065 & 0.8409 & 0.7472 & 0.0061 \\
& DDPG$^\text{KNN}$(K=0.1N) & 0.7312 & 0.9907 & 0.0080 & 2.0750 & 0.9813 & 0.0080 & 3.3288 & 0.9758 & 0.0079 \\
& DDPG$^\text{KNN}$(K=N) & 0.7639 & 0.9927 & 0.0081 & 2.2729 & 0.9942 & 0.0081 & 3.7179 & 0.9915 & 0.0081 \\
& DQNR & 0.7634 & 0.9936 & 0.0081 & 2.2262 & 0.9907 & 0.0080 & 3.6118 & 0.9881 & 0.0080 \\ \cline{2-11}
& KGQR &\textbf {0.8307*} & \textbf{0.9945*} & \textbf{0.0081} & \textbf{2.3451*}& \textbf{0.9971*} &\textbf{0.0081} & \textbf{3.7661*}& \textbf{0.9966*} &\textbf{0.0081*} \\ \hline\hline
\multirow{8}{*}{MovieLens-20M} & Greedy SVD &0.4320 &0.6569 & 0.0049& 0.6915 &0.6199 & 0.0048 &0.9042 & 0.5932 & 0.0046\\
& GRU4Rec & 0.7822 & 0.8382 & 0.0074 & 1.5267 & 0.8253 & 0.0072 & 2.3500 & 0.8316 & 0.0073 \\ \cline{2-11}
& LinearUCB & 0.2307 &0.3790 &0.0029 &0.6147 & 0.5821 & 0.0046 & 0.8017 &0.5614 &0.0044 \\
& HLinearUCB & 0.0995 & 0.3852 & 0.0029 & 0.0172 &0.3841 & 0.0028& 0.2265 & 0.3774 & 0.0027 \\ \cline{2-11}
& DDPGR &0.2979 &0.4917 &0.0034 &1.4952 & 0.7626 & 0.0055 &2.3003 & 0.6977 &0.0045 \\
& DDPG$^\text{KNN}$(K=1) &0.5755 & 0.7293& 0.0059& 1.0854 & 0.7165 &0.0058 & 1.6912 & 0.7371 & 0.0061 \\
& DDPG$^\text{KNN}$(K=0.1N) & 0.6694 & 0.8167 &0.0070 & 1.1578 & 0.8165 & 0.0069 &2.2212 & 0.8215 & 0.0068 \\
& DDPG$^\text{KNN}$(K=N) & 0.8071 & 0.9606& 0.0082 &2.1544 & 0.9446 & 0.0081 & 3.6071 & 0.9533 & 0.0082 \\
& DQNR &0.8863 & 0.9680 &0.0086 &2.3025 & 0.9667 & 0.0081 &3.4036 & 0.9089 & 0.0071 \\ \cline{2-11}
& KGQR & \textbf{0.9213*} &\textbf{0.9726*} & \textbf{0.0086*} & \textbf{2.4242*}& \textbf{0.9722*} & \textbf{0.0083*}&\textbf{3.7695*} & \textbf{0.9713*}&\textbf{0.0084*} \\ \hline
\end{tabular}
}
\footnotesize \flushleft{* indicates statistically significant improvements (measured by Wilocoxon signed-rank test at $p<0.05$) over all baselines.}
\label{results}
\end{table*}
\subsection{Overall Performance (RQ1)}
Table~\ref{results} reports the performance comparison results. We have the following observations:
(i) KGQR consistently obtains the best performance across all environment settings on both datasets. For instance, compared to RL-based recommendation methods like DQN-based (i.e., DQNR) and DDPG-based (e.g., DDPG$^\text{KNN}$, DDPGR), KGQR improves over the strongest baselines in terms of Reward by 3.2\% and 5.3\% in Book-Crossing and MovieLens-20M, respectively. For traditional evaluation metrics, KGQR improves Precision@32 by 0.5\% and 1.9\% in the two datasets, respectively. This demonstrates that the leverage of prior knowledge in KG significantly improves the recommendation performance.
(ii) In most conditions, non-RL methods including conventional methods and MAB-based methods, perform worse than the RL-based methods. Two reasons stand for the significant performance gap. On the one hand, except GRU4Rec, the capacity of other non-RL methods are limited in modeling user preference without considering sequential information. On the other hand, they all focus on the immediate item reward and do not take the present value of the overall performance of the whole sequence into the current decision, which makes them perform even worse in environments that give future rewards more (e.g., $\eta=0.1$, $\eta=0.2$).
(iii) Among the RL-based baselines, we can observe that DQNR and DDPG$^\text{KNN}$ ($K=N$) achieves much better performance than the other DDPG based methods.
When $K=N$ ($N$ is the total number of items), DDPG$^\text{KNN}$ can be seen as a greedy policy that always picks the item with max Q-value.
We also notice that the training process of DDPG based methods is not stable, e.g., their training curves sometimes experience a sudden drop. This may be accounted for that the continuous proto-action picked by the actor is inconsistent with the final action that the critic is learned with.
Such inconsistency between actor and critic may result in inferior performance.
\begin{figure}[t]
\centering
\includegraphics[width=0.5\textwidth]{source/interaction.pdf}
\vspace{-10pt}
\caption{Learning curves of KGQR and DRL-based baseline models. }
\label{fig:sample efficiency}
\vspace{-10pt}
\end{figure}
\begin{table}[]
\centering
\caption{Sample Efficiency Comparison: number of interactions to achieve reward 0.5,1.0,1.5,2.0 for each dataset.}
\vspace{-10pt}
\resizebox{0.50\textwidth}{!}{
\begin{tabular}{c|cccc|cccc}
\hline
\multirow{2}{*}{Model} & \multicolumn{4}{c|}{Book-Crossing} &\multicolumn{4}{c}{Movielens-20M} \\ \cline{2-9}
&0.5& 1.0 & 1.5&2.0 & 0.5& 1.0&1.5&2.0 \\
\hline
\hline
DDPGR &0.46M &2.49M &- & -&2.28M &2.62M &3.82M &- \\
DDPG$^\text{KNN}$ &0.20M &0.49M & 1.46M& 2.44M&0.04M &0.07M&1.76M&2.42M\\
DQNR&0.20M &1.06M & 3.09M&4.83M &0.06M &0.08M&2.47M&4.27M\\
KGQR &0.06M &0.17M &0.24M &0.40M & 0.04M&0.06M&0.16M&0.33M\\
\hline
\end{tabular}
}
\label{tab:sample efficiency}
\end{table}
\subsection{Sample Efficiency (RQ2)}
One motivation of exploiting KG is to improve sample efficiency in RL-based recommendation, i.e., to reduce the amount of interaction data needed to achieve the same performance. In Figure~\ref{fig:sample efficiency} and Table~\ref{tab:sample efficiency}, we analyze the number of interactions needed for each DRL-based model to achieve the same performance with the environment of $\eta=0.1$ in Eq.(\ref{eq:sim-reward}). As can be observed, our proposed KGQR can achieve the same performance as the other RL-based methods using the least number of interactions. More specifically, to achieve a test reward of 2.0, KGQR only needs 17.3\% and 13.6\% of interactions compared to the second efficient baseline (i.e., DDPG$^\text{KNN}$) in the two datasets. This result empirically validates that sample efficiency is improved by utilizing the semantic and correlation information of items in KG. The detailed analysis of different components that contributes to improve sample efficiency is proposed in Section~\ref{sec:sample}.
\begin{table}[]
\centering
\caption{Comparison of Different KGQR Variants.}
\vspace{-10pt}
\begin{tabular}{c|c|c|c|c}\hline
& KGQR\footnotesize-KG\normalsize & KGQR\footnotesize-GCN-CS\normalsize & KGQR\footnotesize-CS\normalsize & KGQR \\\hline\hline
KGemb* & $\times$ & $\checkmark$ &$\checkmark$ & $\checkmark$\\
GCNprop* & $\times$ & $\times$ & $\checkmark$ & $\checkmark$\\
CS* & $\times$ & $\times$ & $\times$ & $\checkmark$\\
\hline
\end{tabular}
\label{tab:KGQR-variants}
\footnotesize \flushleft{* KGemb denotes KG enhanced item representation; GCNprop denotes GCN propagation in state representation; CS denotes the neighbor-based candidate selection.}
\end{table}
\begin{table}[]
\centering
\caption{Ablation Study of KGQR.}
\vspace{-10pt}
\resizebox{0.48\textwidth}{!}{
\begin{tabular}{c|cc|cc}
\hline
\multirow{2}{*}{Model} & \multicolumn{2}{c|}{Book-Crossing} &\multicolumn{2}{c}{Movielens-20M} \\ \cline{2-5}
& Reward & Precision@32 & Reward & Precision@32 \\
\hline
\hline
KGQR\footnotesize-KG\normalsize &2.2262 & 0.9907&2.3025 & 0.9667 \\
KGQR\footnotesize-GCN-CS\normalsize &2.2181&0.9819& 2.2402 & 0.9621\\
KGQR\footnotesize-CS\normalsize& 2.2836 &0.9939 & 2.3689&0.9698\\
\textbf{KGQR} & \textbf{2.3451} & \textbf{0.9971} & \textbf{2.4242} & \textbf{0.9722} \\
\hline
\end{tabular}}
\label{tab:ablation study}
\end{table}
\subsection{Analysis (RQ3)}
In this section, we further analyze the effectiveness of different components in the proposed framework. In KGQR, there are three components utilizing KG that may affect the performance of KGQR: KG enhanced item representation, GCN propagation in state representation (Section~\ref{sec:state}) and neighbor-based candidate selection (Section~\ref{sec:CS}). To study the effectiveness of each such component, we evaluate the performance of four different KGQR variants, namely KGQR\footnotesize-KG\normalsize~(i.e.,DQNR), KGQR\footnotesize-CS\normalsize, KGQR\footnotesize-GCN-CS\normalsize~and KGQR. The relationship between KGQR variants and different components is presented in Table~\ref{tab:KGQR-variants}. In the ablation study, we consider the environment of $\eta=0.1$ in Eq.(\ref{eq:sim-reward}), and Table~\ref{tab:ablation study} shows the performance of these four variants.
\begin{figure}[t]
\centering
\begin{subfigure}[b]{0.45\columnwidth}
\includegraphics[width=\textwidth]{source/book.pdf}
\caption{Book-Crossing}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.45\columnwidth}
\includegraphics[width=\textwidth]{source/movie.pdf}
\caption{MovieLens-20M}
\end{subfigure}
\vspace{-10pt}
\caption{Influence of Candidate Size. }
\label{fig:candidate selection}
\end{figure}
\subsubsection{Recommendation performance}
\noindent \textbf{Effect of KG enhanced item representation.}
In KGQR\footnotesize-KG\normalsize, the item embeddings are pretrained by MF model from the historical interaction data, while in KGQR\footnotesize-GCN-CS\normalsize, they are retrieved from KG, pretrained with TransE. Therefore, the marginal difference between KGQR\footnotesize-KG\normalsize~and KGQR\footnotesize-GCN-CS\normalsize~performance indicates that the information in KG has almost equal contribution with the historical interaction data, which suggests the superiority of applying KG for cold-start scenario (i.e., no historical interaction data exists).
\noindent \textbf{Effect of GCN propagation in state representation.} Comparing the performance of KGQR\footnotesize-GCN-CS\normalsize~with KGQR\footnotesize-CS\normalsize~in Table~\ref{tab:ablation study}, the improvement in KGQR\footnotesize-GCN-CS\normalsize~ indicates that the signal from RL-based recommendation guides the update of KG embedding so that the items in KG can be represented more suitably for the current specific recommendation task.
\noindent \textbf{Effect of neighbor-based candidate selection.} The comparison between the performance of KGQR\footnotesize-CS\normalsize~and KGQR validates the effectiveness of neighbor-based candidate selection, for candidate selection module can leverage the local structure of interacted items in KG to filter irrelevant items and such restricted retrieval improves the final recommendation performance.
To study the influence of candidate size, we vary the candidate size in the range of \{1000, 2000, 3000, 5000, 10000\} and present the recommendation performance in Figure~\ref{fig:candidate selection}. We observe that recommendation performance first grows as candidate size increases, since a small size of candidate limits possible choices of the recommendation algorithm. However, further increasing of candidate size degrades the performance, since the neighbor-based candidate selection filters some irrelevant items in advance. Such irrelevant items have very limited chance to be recommended and to collect feedback which makes them not be able to learn well by the recommendation algorithm and eventually gains a negative effect to the performance.
\subsubsection{Sample efficiency}
\label{sec:sample}
\noindent \textbf{Effect of KG-enhanced state representation.} Comparing the number of interactions of KGQR\footnotesize-KG\normalsize~ with that of KGQR w.r.t same test average reward in Figure~\ref{fig:sample efficiency}, we notice that in both two environments the utilizing of KG and task-specific representation learning improves the sample efficiency. This observation demonstrates our motivation that the propagation of user preference through the correlated items via GCN is helpful in dealing with sample efficiency issues.
\noindent \textbf{Effect of neighbor-based candidate selection.} Besides the performance improvements, the candidate selection significantly improves the sample efficiency, as shown in Figure~\ref{fig:sample efficiency} (comparing the purple line and red line).
\section{Conclusion}
\label{sec:conclude}
In this work, we proposed a knowledge graph enhanced Q-learning framework (KGQR) for the interactive recommendation. To the best of our knowledge, it is the first work leveraging KG in RL-based interactive recommender systems, which to a large extent addresses the sample complexity issue and significantly improves the performance.
Moreover, we directly narrow down the action space by utilizing the structure information of knowledge graphs to effectively address the large action space issue.
The model propagates user preference among the correlated items in the graph, to deal with the extremely sparse user feedback problem in IRS.
All these designs improve sample efficiency, which is a common issue in previous works.
The comprehensive experiments with a carefully-designed simulation environment based on two real-world datasets demonstrate that our model can lead to significantly better performance with higher sample efficiency compared to state-of-the-arts.
For future work, we plan to investigate KGQR on news and image recommendation tasks with other DRL frameworks such as PG and DDPG. We are also scheduling the process of deploying KGQR onto an online commercial recommender system. Further, we are interested in inducing a more complex sequential model to represent the dynamics of user preferences, e.g., taking user's propensity to different relations that the click history shows into consideration.
\section*{Acknowledgement}
The corresponding author Weinan Zhang thanks the support of "New Generation of AI 2030" Major Project 2018AAA0100900 and NSFC (61702327, 61772333, 61632017, 81771937). The work is also sponsored by Huawei Innovation Research Program.
\bibliographystyle{ACM-Reference-Format}
| {'timestamp': '2020-06-19T02:12:44', 'yymm': '2006', 'arxiv_id': '2006.10389', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10389'} | arxiv |
\section{Introduction}
In recent years, {\it Graph Representation Learning} (GRL) has emerged as a promising tool to utilize the rich information that lies in complex network structures. The effectiveness of these methods has led to them finding applications in molecular physics \cite{pmlrSanchez2018}, biology \cite{battaglia2018relational}, e-commerce \cite{wang2018billion}, online platforms \cite{grbovic2018real} and finance \cite{bruss2019DeepTrax, bruss2019Scale}.
Viewed under a unified prism, GRL methods are trained to embed closer together the nodes that appear in the same {\it context} as one another \cite{Khosla2019Comparative}. However, the manner in which they define this context varies significantly affecting both scalability and performance. Its purest form would be the full adjacency matrix, while other more computationally efficient approximations include defining a sample of the context either through random walks or subsampling of neighborhoods \cite{marsden2013eigenvalues}. Amongst deep learning approaches in this field, Graph Convolutional Networks (GCNs) have gained in popularity due to their smaller number of trainable parameters, their ability to handle arbitrary network geometries and produce relational information in an inductive way. Variations of GCNs have also been employed in a unified training setting to extract information from the graph topology while optimizing for a set of node labels.
Traditional graph mining techniques, the predecessors of GRL, were evaluated on their ability to express properties of the original graph, e.g. community structure, degree distribution, centralities and role preservation to name a few \cite{Faloutsos2006Sample, henderson2012rolx}. Similarly, the effectiveness of GRL methods should be tested with regard to these complex graph characteristics \cite{Dalmia2018WWW}. It is stated in \cite{dehmamy2019} that representing a wide range of graph statistics is a non trivial task for GCNs. Even though some of the theoretical limitations of GCNs have been explored in recent studies, a rigorous data-driven comparison of approaches in this regard has not been conducted yet.
Recent concerns in the GRL community regarding the lack of reliable benchmarks to evaluate these methods have been raised leading to the creation of the Open Graph Benchmark initiative \footnote{https://ogb.stanford.edu/}.
In the state of the art, each new approach focuses on slightly improving accuracy in either node classification or link prediction tasks often based on small datasets with non complex characteristics. Moreover, assumptions about the data remain unaddressed with some examples including the density and transitivity of the original graph, the use of the strongest connected components in the training process or the effects of uniform sampling on the degree distribution. However, selecting one of the state of the art methods for a real-world application scenario could depend heavily on these assumptions.
In this work, we utilize a rigorous data driven framework to discover the limitations and possible obstacles in the application of popular GRL approaches. We provide both theoretical and experimental evidence on the relationship between characteristics of the graph, the considered methods and their hyperparameters. Our objective is to shed light on the context GRL methods extract from a graph and the properties that are preserved in the latent space without focusing on optimizing the inference process as happens when representation learning is conditioned upon a specific set of labels.
Unified training of representation learning with node classification tasks is out of scope in this analysis since the objective in those tasks would be the inference of the particular label instead of the accuracy of the representation. Moreover, unified training is not always a valid option in real-world scenarios with high class imbalance, but enhancement in performance can still be observed by incorporating the appropriate topological information that best fits the properties of the dataset at hand.
Our contributions:
\begin{itemize}
\item We select a wide range of state of the art GRL methods to be tested in an unsupervised embedding generation setting. We utilize open source datasets commonly used in literature with the addition of synthetically generated ones with data properties similar to what is often exhibited by real world graphs.
\item We provide theoretical proofs of the relationship of GRL methods to graph properties, including degree, community memberships and triangle counts.
\item Going beyond this theoretical background, we design an evaluation framework that challenges unsupervised GRL approaches in their ability to encapsulate information about properties of the original graph and connect them to the applicability of each method dependent on structural complexities that need to be preserved in the embedding space.
\item We then investigate these principles in practice and conduct an extensive sensitivity analysis on the interaction between method selection, hyperparameters and data characteristics for any practitioner interested in deploying GRL methods. We connect the applicability of the methods to the type of graph, its density and connectivity patterns and suggest that there is no "one-to-fit-all" approaches in GRL.
\end{itemize}
\section{Related Work}
Graph representation learning seeks to define a function that can map a geometric graph structure to a low-dimensional, most commonly, euclidean space. This function is usually parameterized to learn or approximate some correspondence of the geometric distance between nodes to distance in the desired continuous space. Early efforts focused on factorization approaches such as Singular Value Decomposition or computing the eigenvectors of the graph Laplacian \cite{belkin2003laplacian} \cite{tenenbaum2000global} \cite{roweis2000nonlinear}. These efforts built on an even longer history of spectral graph theory which had been studying the relationships between the eigenvalues of a graph Laplacian and its connectedness \cite{marsden2013eigenvalues}. One of the big challenges to these methods is applicability on very large graphs.
Subsequent GRL efforts found scalable approaches for large natural graphs by applying effective word embedding techniques from NLP to graphs. Sequences of nodes are generated via random, or biased, walks on the graph which are then fed into shallow single layer skip-gram models \cite{perozzi2014deepwalk}, \cite{grover2016node2vec}. The random walks can be viewed as a type of sampling from a distribution of pairwise proximities between all nodes. The skip-gram model implicitly learns to map nodes in those samples to Euclidean space preserving neighborhood structure. Most recently, efforts to connect graph learning to broader efforts in deep learning have sought to reformulate state-of-the-art neural networks to apply to graph structures. These efforts have primarily focused on connecting graph learning to supervised and semi-supervised architectures by applying various mechanisms of neighborhood aggregation to incorporate relational information in the predictive task \cite{kipf2016semi}, \cite{velivckovic2017graph}, \cite{scarselli2008graph}, \cite{bruna2013spectral}, \cite{hamilton2017inductive}. It has become common to view many of these neighborhood aggregation algorithms as a type of message passing algorithm that transmits neighborhood information over the edges of the network\cite{Gilmer2017}\cite{GarciaDuran2017}.
While GCNs have seen significant empirical success, researchers have started to identify some of their limitations. For instance, among the known limitations of GRL algorithms is the challenge of modeling structures with hierarchies and power-law distributions, such as language as well as natural graphs. Research suggests that embedding natural graphs in hyberbolic space as opposed to Euclidean space allows for the model to effectively capture latent hierarchical structures \cite{Nickel2017}. Another recent approach applying graph coarsening via cluster assignment layers also seeks to overcome this challenge in GNN architectures\cite{Murphy2019}. Furthermore, a comparative study of a number of GRL approaches, found that certain graph properties such as clustering coefficient have a big determination on which algorithm performs better \cite{khosla2019}.
Until recently, efforts have lagged to establish a theoretical foundation for understanding GNN expressiveness, power and limitations. Primary attention in these efforts has been focused on understanding the expressiveness power of graph convolutional approaches. \cite{Maron2019}, \cite{Morris2018}, and \cite{Xu2018} define expressiveness in terms of a model's ability to test for isomorphic graphs. A common benchmark approach for testing graph isomorphism is the Weisfeler-Leman (WL) test. They prove theoretically that common GCN models are bounded in terms of their ability to distinguish graph structures by the 1-WL test. The WL test can be extended to higher-orders with increasing expressiveness. This research suggests that by modifying existing GCN architectures they can achieve up to K-WL expressiveness. The main limitation described in this research relates to the class of permutation invariant functions required to aggregate information over sets of neighboring nodes \cite{zaheer2017deepset} \cite{Xu2018}. Other recent efforts expanding beyond graph isomorphism tests follow two paths. \cite{verma2019stability} studied the relationship between the eigenvalues of a graph convolution filter and the stability of the model. Finally, \cite{dehmamy2019} seek to quantify a representation learning algorithms expressiveness in its ability to learn graph moments. While this work was largely confined to small random graphs, it is an important precursor to the work described here.
\section{Theoretical Framework}
\subsection{Properties of Shallow and Deep Embedding Approaches}
In this section, we will explore what different GRL approaches are learning about the input graph and attempt to identify their strengths and limitations.
When it comes to the objective function, both shallow and deep embedding methods in the unsupervised setting attempt to minimize a proximity-based reconstruction error of the form:
\begin{equation}
J = - \sum_{i,j} A_{i,j} \cdot f(\phi_i, \phi_j)
\end{equation}
where $i$ and $j$ represent two nodes and $A_{i,j}$ the corresponding entry in the adjacency matrix, while $\phi$ represents the parameters to be learnt and $f$ is the proximity function.
\subsubsection{Shallow Embedding Approaches}
Popular shallow embedding approaches extract the context around a node using co-occurence pairs in truncated random walks. At each step, the transition probability from vertex $i$ to vertex $j$ is $P_{ij} = \frac{A_{ij}}{D_{ii}}$
or in matrix notation $P = D^{-1} \cdot A$ where $D$ is the diagonal degree matrix and $A$ is the adjacency matrix.
Truncated random walks express similarity between nodes $i$ and $j$ proportional
to the sum of probabilities, denoted as $P^{t}_{ij}$, that node $j$ is reachable from a walk of length $t$ initiated from node $i$ and vice versa.
\begin{lemma} Transition probabilities $P^{t}_{ij}$ and $P^{t}_{ji}$ through a random walk
of length t have a ratio that only depends on the degrees that are noted as $D_{ii}$ and $D_{jj}$ in the diagonal degree matrix:
\begin{equation}
D_{ii} \cdot P^{t}_{ij} = D_{jj} \cdot P^{t}_{ji}
\end{equation}
\end{lemma}
\begin{lemma} When the length t of a random walk starting at node i tends towards infinity, the transition probability $P^{t}_{ij}$ only depends on the normalized degree of destination node j.
\begin{equation}
\lim_{t \to \infty} P^{t}_{ij} = \frac{D_{jj}}{\sum_{k=1}^{N} D_{kk}}
\end{equation}
\end{lemma}
where $N$ is the total number of nodes in the graph.
The above hold true for the case of unbiased random walks, an example of which is DeepWalk. Node2vec, however, manipulates random walks based on the two hyperparameters $p$ and $q$ that control the probability of going backwards and the probability of favoring locality respectively. The values of these hyperparameters alter the transition probability to achieve a more balanced exploration of the neighborhood. The second order transition probability of getting from node $i$ to $j$ with the preceding node in the walk being $k$ is defined as:
\begin{equation}
P_{i,k,j} = \begin{cases}
\frac{1}{p} & if \ s_{kj}=0 \\
1 & if \ s_{kj} = 1 \\
\frac{1}{q} & if s_{kj} = 2
\end{cases}
\end{equation}
where $s$ stands for shortest path length.
Proofs for the above lemmas can be found in Appendix \ref{sec-appendix}.
\subsubsection{Deep Embedding Approaches}
In GRL the set of feature vectors in a node's neighborhood can be expressed as a multiset, i.e. a set with multiple entries of an element. Subsequently, aggregating neighbor features is essentially an aggregation function over multisets. The discriminative power of a node representation lies in the ability to map different multisets into different representations.
The message passing framework on which most GCN approaches in literature are based implements the aforementioned principles for equivariant transformations. Instead of external node features, these methods can also operate on identity features directly derived from the adjacency matrix. The $l_{th}$ layer in a GCN is defined as:
\begin{equation}
h_{N(u)}^{(l)}) = AGGREGATE(h_{v}^{(l-1)}, \forall v \in N(u))
\label{eq_agg}
\end{equation}
\begin{equation}
h_u^{(l)} = \sigma (W \cdot COMBINE(h_u^{(l-1)}, h_{N(u)}^{(l)}))
\label{eq_comb}
\end{equation}
where $u$ is the current node, $h_u^{l}$ is the feature vector of node $u$ at the $l_{th}$ layer, $N(u)$ is $v's$ neighborhood, $\sigma$ and $W$ are a non-linearity and weight matrix respectively.
Common choices for the aggregate functions are element-wise mean and max pooling as introduced in the GraphSAGE framework \cite{hamilton2017inductive}, while the combine function is often a form of concatenation with a set of linear weights followed by a non-linearity. The two functionalities can also be integrated, as happens in the GCN framework \cite{kipf2016semi}. Inherently during the aggregation step certain information about the neighborhood properties is smoothed out, since both mean and max aggregations are not strictly injective. The aforementioned aggregate functions over multisets showcase the following properties:
\begin{lemma}
Given a set $X_1$ and $X_2$ is a multiset containing fixed number of copies of the elements in $X_1$ and a function $f$ that operates on multisets, then there exists a function $h(X) = mean_{x \in X} f(x)$ such that $X_1 = set(X_2)$ and $h(X_1) = h(X_2)$.
\end{lemma}
\begin{lemma}
Given two multisets $X_1$ and $X_2$ that share the same underlying set $X_1 = X_2$ and a function $f$ that operates on multisets, then there exists a function $h(X) = max_{x \in X} f(x)$ such that $h(X_1) = h(X_2)$.
\end{lemma}
As a direct result of Lemma 3.1, if the sets of neighborhood features contain different number of copies of the same distinct elements, i.e. neighbors that share the same feature values, then the mean aggregator will fail to distinguish between them. This aggregator captures distributions rather than the exact topological structure.
Max aggregations on the other hand simplify the multiset into its core making them robust to outliers and noise.
However, multiple nodes with the same feature are treated as a single occurence (see Lemma 3.2) therefore distributions of features inside the neighborhood set deviates from the original graph topology.
Finally, in order for these methods to scale, neighbors are often down-sampled using random sampling which fails to retain the original degree distribution. Variations on these aggregations include operating on fixed sized neighborhoods to preserve the computational footprint of the method or applying learnt weighting (e.g. with attention mechanism) in the case of mean aggregations.
\subsection{Connection to Graph Properties}
\label{sec-graphProps}
GRL approaches differ in the process used to collect and combine the context around a node and this affects how these processes capture the complexities in the structure of a graph.
Broadly used metrics to describe these structures include communities, variations of degree, transitivity related metrics, such as clustering coefficient and distance based metrics such as closeness centrality.
{\it Community structure:} Under the homophily hypothesis embedding approaches should bring closer together highly interconnected nodes that belong to the same community.
Based on the Markovian properties of random walks, if two nodes $i$ and $j$ are in the same community, then for every intermediate node $k$ in a random walk we have transition probabilities $P_{i,k} \approx P_{j,k}$ meaning they view the rest of the network in a similar way and this is encoded in the transition probabilities. This property has been used in \cite{Pons2005Walks} to prove the correlation between random walks and community structure.
Going one step further, by tweaking the transition probabilities one can alter the extent to which community structure is represented in the resulting samples as occurs in biased random walks (e.g. Node2Vec with small $q$ parameter). It needs to be noted that sampling based GCNs that are no more than 2 layers deep observe a smoothed out version of the position of the node inside a community broader than the 2-hop neighborhood. Only when there are rich node features can the distribution of the neighborhood features provide a strong signal for community structure.
{\it Degree and Neighborhood Degree:}
As expressed in Lemma 3.3 transition probabilities are dependent on the ratio of degrees between source node and all other nodes. Therefore degree distribution is implicitly expressed in the topology sampled from a random walk, however walk length would have to approach infinity to have a direct dependence on the degree of the source (see Lemma 3.4). In biased random walks when the sampling is skewed towards locality (in-out parameter $q >1$), the variance in representing the distribution of 1-hop neighbors is reduced leading to a more accurate approximation of the source node's degree. Finally, GCN variations that operate directly on the normalized adjacency matrix should observe a more accurate degree distribution only when the sampling neighborhood size is comparable to the average degree of all the nodes in the graph.
{\it Clustering coefficient and triangles: }
Clustering coefficient is highly dependent on reciprocity and closed triads in a graph. The count of triangles that a node participates in is an unnormalized expression of the strategic positioning of a node. For Node2Vec, if the probability of a triangle between nodes $i$, $j$ and $k$ is low then the effect of parameter $p$ is limited and biased random walks collapse into uniform ones. Similarly, in a sparse graph with clearly defined components that are disconnected with one another, parameter $q$ becomes less relevant. GCNs that operate with pooling architectures at depths higher than $l=3$ have been proven to preserve clustering coefficient \cite{hamilton2017inductive}. It is crucial though that this proof assumes that all nodes have a distinct feature representation and the network can map them to unique vectors which is not guaranteed since the aggregation functions are not injective.
{\it Closeness Centrality:} Calculated as the reciprocal of the sum of length of all shortest paths between a node and all others, this metric is closely related with the concept of walks on a graph.
With appropriate values in parameters $p$ and $q$ Node2Vec is expected to capture the structural equivalence of nodes, hence their relative proximity to the rest of the network. A node that assumes the role of a ‘broadcaster’ in the network will be heavily represented in any form of truncated random walk generated topology. On the other hand, GCNs may find it challenging to represent high level graph structure information that cannot be easily captured by local features. In Section \ref{sec-res} we will explore the ability of GCNs to preserve such global roles of nodes.
\section{Experimental Design}
\label{sec-Exps}
\subsection{Workflow}
\label{sec-wrkfl}
Driven from the observations on the theoretical properties of GRL approaches with respect to the topology of the original graph, our goal is to design an experimental workflow to address the following research questions:
\begin{itemize}
\item To what extent is the performance of GRL methods influenced by the structural properties of the original graph?
\item How is the combination of input graph, embedding method and hyperparameter selection affecting performance in downstream tasks?
\item How well are graph topological properties represented in the latent representations of GRL methods and how is this related to the hyperparameter selection?
\item Finally, do deep GRL methods always outperform shallow ones with regards to all tasks?
\end{itemize}
The workflow we follow to address these questions is depicted in Figure \ref{fig-workflow}. We start with a set of structural properties that are often encountered in real world graphs and utilize both real and synthetic datasets to explore the full spectrum of these properties (Section \ref{sec-data}). We select a set of representative GRL methods and a subset of their hyperparameters that affect the data distribution the models are trained on that are described in Section \ref{sec-unsup}. For the evaluation process (Section \ref{sec-eval}) in the unsupervised case we introduce a set of learning tasks related to graph properties. Finally, we link the results back to the properties of the underlying graph and the modeling choices (Section \ref{sec-res}).
\begin{figure}[h]
\centering
\scalebox{0.65}{
\includegraphics[width=\linewidth]{Experimental_Design_Pic_unsupOnly.png}}
\caption{Diagram of the experimental workflow.}
\label{fig-workflow}
\end{figure}
\subsection{Datasets}
\label{sec-data}
Despite the abundance of GRL approaches being introduced, most of them are still evaluated on small graphs representing a limited set of application domains (e.g. bibliographic references) that often exhibit repetitive motifs and similar values in graph statistics, such as density or transitivity. Oftentimes the underlying graph generation process of real world graphs (e.g. scale free or small-world) is associated with these graph properties. In our experiments we use a set of open source datasets widely adopted for testing in GRL literature along with a set of synthetic graphs to simulate these cases in a controlled environment and identify graph motifs that pose challenges to GRL methods. The open source datasets used are comprised of Cora and Citeseer \cite{sen2008collective}, which represent citation networks, Pubmed \cite{namata2012query} which focuses on medical publications and Reddit representing the social network built around an online blogging platform (in the version released in \cite{hamilton2017inductive}).
Many real world networks exhibit scale-free properties linked to a hierarchical topology with a small subset of nodes exhibiting a high number of connections, while the majority of the network is less connected \cite{Adcock2013TreeLikeSI}. This case is represented in our experiments with the Barabasi-Albert (BA) model with preferential attachment \cite{albert2002statistical}. In addition, many of them exhibit a small average shortest path length indicating high connectivity but also a clustering coefficient significantly higher than expected by random chance, which adheres to the Holme-Kim (HK) graph generation process \cite{holme2002growing}. Finally, the case of purely random generated graphs with a binomial edge distribution is expressed by Erd\H{o}s-R\`enyi model \cite{newman2003random}. In practive, networks have been observed to be sparser than the purely random ones which means the average degree is smaller compared to the number of nodes $N$. In ER graphs this is achieved by setting the edge probability to a small value but maintaining $N \cdot p > 1$. This leads to an approximate Poisson degree distribution and the resulting graph is expected to have at least one large connected component. Examples of the degree distribution and community structure that arise from the different generators are shown in Figure \ref{fig-syntheticPlots}.
For our experiments we generated three different variations of BA graphs with number of edges to attach $m=2,5,9$, four ER variations with probability $p=0.002,0.004,0.008,0.016$ and finally HK graphs with two parameters: number of edges to attach ($m$) and probability of creating a triangle ($p$). The values used for HK graphs are the full set of combinations with $m=3,4,5$ and $p=0.005,0.02,0.09$. All the generated graphs contain $5000$ nodes. As can be seen in Figure \ref{fig-syntheticStats} with the addition of the synthetic graphs we are able to explore a broader range of density, transitivity and clustering coefficient values.
\begin{figure}[]
\centering
\scalebox{.88}{
\includegraphics[width=\textwidth]{deg_comms_synthetic4.png}
}
\caption{Examples of synthetic graphs generated with the three described random graph generators: degree distributions on the first row and community structure on the second.}
\label{fig-syntheticPlots}
\end{figure}
\begin{figure}[!htbp]
\centering
\scalebox{.55}{
\includegraphics[width=\linewidth]{dataset_propertiesWithDots2.png}}
\caption{Transitivity, average clustering coefficient and density values for datasets used in the experiments}
\label{fig-syntheticStats}
\end{figure}
\subsection{Embedding Methods}
\label{sec-unsup}
In the case of GRL methods trained in an unsupervised manner, the main learning objective is to reflect effectively the topology of the input graph either through aggregation of identity rows or through the distribution of external node features. For the experimental section we have selected popular approaches from both shallow and deep embedding methods described in Table \ref{tab-unsupMeth}. In order to explore the relationship between graph properties and GRL methods, we add one more axis of evaluation namely the {\it hyperparameters} of each method. Out of the wide range of hyperparameters we have selected the subset related to either the data distribution that gets fit into the model or the dimensionality of the resulting latent space. Hyperparameters that relate to the optimization process (such as choice of optimizer and learning rate) are out of scope for our analysis and we opt for using the default values proposed in the original implementation of each method (refer to Appendix \ref{sec-appendix}).
\begin{table}[h]
\centering
\scalebox{0.8}{
\begin{tabular}{cl}
\hline
Embedding Method & \multicolumn{1}{c}{Hyperparameters} \\ \hline
\multicolumn{2}{c}{Shallow methods} \\ \hline
\multirow{3}{*}{DeepWalk \cite{perozzi2014deepwalk}} & \textit{negative sampling exponent (ns)} \\ \cline{2-2}
& \textit{sampling frequency (s\_freq)} \\ \cline{2-2}
& \textit{embedding dimension (d)} \\ \hline
\multirow{3}{*}{Node2Vec \cite{grover2016node2vec}} & \textit{return parameter (p)} \\ \cline{2-2}
& \textit{in-out parameter (q)} \\ \cline{2-2}
& \textit{embedding dimension (d)} \\ \hline
\multicolumn{2}{c}{GCN variations} \\ \hline
\multirow{4}{*}{GraphSAGE \cite{hamilton2017inductive}} & \textit{maximum degree (max\_d)} \\ \cline{2-2}
& \textit{neighborhood sample size 1 (s1)} \\ \cline{2-2}
& \textit{neighborhood sample size 2 (s2)} \\ \cline{2-2}
& \textit{embedding dimension (d)} \\ \hline
\multirow{2}{*}{GCN \cite{kipf2016semi}} & \textit{maximum degree (max\_d)} \\ \cline{2-2}
& \textit{embedding dimension (d)} \\ \hline
\multirow{2}{*}{Graph Attention Network (GAT) \cite{velivckovic2017graph}} & \textit{number of heads (n\_a)} \\ \cline{2-2}
& \textit{embedding dimension (d)} \\ \hline
\end{tabular}
}
\caption{Description of embedding methods and their hyperparameters used in the experimental process}
\label{tab-unsupMeth}
\end{table}
\subsection{Evaluation}
\label{sec-eval}
To address the research questions posed in Section \ref{sec-wrkfl} about the relationship between the properties of the original graph and the performance of the embedding methods, we expand the evaluation criteria beyond link reconstruction. We define predictive models for the node-level topological graph properties discussed in Section \ref{sec-graphProps}.
The goal of this evaluation is to explore which topological properties are preserved in the latent space by each GRL method and what part of this connection can be traced back to the type of generation process that the graph adheres to. The aforementioned node level properties can characterize roles inside a network that are crucial for downstream learning tasks. More specifically, a post hoc supervised predictor is fit to predict each of these properties using the embedding vector of each node as input. For the degree and average neighborhood degree predictor we log-transform the target variable and for community memberships the class assignment is based on Louvain community detection \cite{blondel2008fast}. We use Random Forest predictors for this task with the number of estimators ranging from 100 to 500 and the depth of each tree from 8 to 12. A split of 90/10 for train and test set is employed and the best performing results are reported for each predictor in Section \ref{sec-res}. However, the hyperparameters for the Random Forest models remain the same for a given dataset across results derived from different methods to avoid biasing the evaluation of a method due to more efficient hyperparameter tuning. Regarding model selection we opted for a non linear model since the association between the latent space and the target metrics is unlikely to follow linear correlation. Opting for Random Forest models allows for minimal hyperparameter tuning on the downstream model to avoid biasing the subsequent sensitivity analysis. With six GRL methods and on average ten hyperparameter per method and over 20 datasets, the total scale of our sensitivity analysis is over 1000 GRL models trained in total. Accounting for the models trained for the prediction of graph properties as part of the evaluation we reach a total of 8000 models constituting this the largest sensitivity analysis in the field of graph representation learning.
\section{Results}
\label{sec-res}
The most popular evaluation task used for GRL methods that are not trained to optimize node class assignment is {\it link prediction} which is depicted in Figure \ref{fig-LPbar}. Shallow methods seem to outperform deep GRL approaches across almost all graphs. Only GAT appears to be on par with the shallow embedding methods, which implies that applying attention weights over a node's neighborhood can significantly improve the reconstructive power of the produced embeddings. DeepWalk and Node2Vec are also able to adapt better to scale-free graphs and heavily clustered graphs ({\it BA} and {\it HK}). In highly dense random graphs ({\it ER}) all GRL seem to be performing poorly, which is to be explained since in the random edge creation process there is wider variety of connectivity patterns to learn. For the Reddit dataset, the largest of the contemplated graphs, GCN variations appear to suffer significantly in performance which can be explained by the sampling of neighborhoods that needs to occur for these methods to effectively scale.
\begin{figure}[h]
\begin{center}
\begin{adjustbox}{minipage=\textwidth,scale=0.75}
\begin{subfigure}{\textwidth}
\includegraphics[width=\textwidth]{synthetic_datasetToMethodBarChartSynthLPFinal.png}
\caption{Synthetic datasets}
\end{subfigure}
\begin{subfigure}{\textwidth}
\includegraphics[width=\textwidth]{synthetic_datasetToMethodBarChartOpenLPFinal.png}
\caption{Open Source Datasets}
\end{subfigure}
\end{adjustbox}
\end{center}
\caption{Link prediction AUC scores for different datasets and GRL methods}
\label{fig-LPbar}
\end{figure}
\begin{figure}
\centering
\scalebox{0.95}{
\includegraphics[width=\textwidth,width=\textwidth]{barplot_subsetGPs_avgPerf_synthTrainALL.png}
}
\caption{Performance of different GRL methods for six graph properties prediction tasks for synthetic graphs.}
\label{fig-indGPSynth}
\end{figure}
Figures \ref{fig-indGPSynth} and \ref{fig-indGPOpen} demonstrate performance across all graph properties prediction tasks for different GRL methods corresponding to the best performing hyperparameter combination. Performance is expressed in terms of $Micro-F1$ and $R^2$ scores for classification and regression tasks respectively. We identify a trend of GCN variations managing to preserve individual node degree and average neighborhood degree as opposed to shallow embedding methods that show a higher success rate in capturing community structure and closeness centrality. In the case of synthetic graphs in particular where there is no rich feature set to accompany the nodes, transition probabilities used in shallow methods encode nodes belonging in the same community more effectively as explained in Section \ref{sec-graphProps}. Derived from Lemma 3.3, however, finite random walks capture ratios of degree with an advantage to biased walks with increased locality sampling. This is evident by the good performance of Node2Vec in predicting degree and the overall better performance of GCNs in degree related tasks as they have a more complete view of 1- and 2-hop neighborhoods. Node2Vec appears to be performing well in high reciprocity graphs (e.g. BA) in tasks related to capturing closed triads. As explained is Section \ref{sec-graphProps}, random walks efficiently capture 'broadcaster' node behavior and only addition of attention weights improves the discriminative power of GCNs in this matter. Performance is significantly higher across tasks for the simpler open source graphs which adheres to our original observation that existing benchmarks are not providing enough variation. In particular for graphs with hierarchical properties like {\it BA} and {\it HK} where there exist supernodes that cause community overlap (refer to Figure \ref{fig-syntheticPlots}) the difference in performance between embedding methods is even higher for the community identification task.
Next, we explore the effect of individual hyperparameters on the performance in different evaluation tasks. In Figure \ref{fig-synth_avgHyp} examples of hyperparameter values are plotted against performance in a subset of tasks averaged over all instances of a given graph generator. Interestingly, BA graphs appear to be more affected from hyperparameter values and different graph generators respond differently to a given hyperparameter setting which indicates that sensitivity analysis of GRL methods needs to include multiple types of graphs. More specifically, it appears that the maximum degree value selected to subset each node's neighborhood in GraphSAGE with mean aggregator is related with increased performance as the degree value is set higher for HK graphs. The other two graph types plateau or even drop in performance when the value is increased above 150. This can be attributed to the thicker tail in degree distribution for HK graphs (see Figure \ref{fig-syntheticPlots}) with more nodes displaying high degree values. An interesting observation is the effect of parameter $q$ for BA graphs, with higher $q$ value increasing performance for clustering coefficient and average neighborhood degree, while it drops for closeness centrality prediction. This showcases the difference between local and global structure, since parameter $q$ regulates the exploration of immediate neighbors and the ones at a higher depth. Finally, link prediction in BA graphs achieves best performance for smaller number of dimensions but all other tasks require collectively higher dimensionality. This evidence suggests that there is not necessarily a single value in hyperparameter selection that achieves optimal performance for all evaluation tasks.
\begin{figure}
\centering
\scalebox{0.95}{
\includegraphics[width=\textwidth]{AllGPs_datasetToMethodBarOpen_subplots.png}
}
\caption{Performance of different GRL methods for six graph properties prediction tasks for open source graphs.}
\label{fig-indGPOpen}
\end{figure}
\begin{figure}[!ht]
\begin{subfigure}{\linewidth}
\centering
\includegraphics[width=\linewidth]{Barabasi-Albert_avg_perf_hyperparams3NoTitleAllRes.png}
\caption{Barabasi-Albert graphs}
\label{fig-ba_avgHyp}
\end{subfigure}
\begin{subfigure}{\linewidth}
\centering
\includegraphics[width=\linewidth]{Erdos-Renyi_avg_perf_hyperparams3NoTitleAllRes.png}
\caption{Erd\H{o}s-R\`enyi graphs}
\label{fig-er_avgHyp}
\end{subfigure}
\begin{subfigure}{\linewidth}
\centering
\includegraphics[width=\linewidth]{Holme-Kim_avg_perf_hyperparams3NoTitleAllRes.png}
\caption{Holme-Kim graphs}
\label{fig-pl_avgHyp}
\end{subfigure}
\caption{Performance across individual evaluation tasks for the three categories of synthetic graphs and different hyperparameters to method combinations.}
\label{fig-synth_avgHyp}
\end{figure}
\begin{figure}[!ht]
\centering
\scalebox{0.92}{
\includegraphics[width=\linewidth]{graphPropertiesToGP_perf_subplotsSynth.png}
}
\caption{Relationship of performance of individual evaluation tasks to increasing values of transitivity, density and average clustering coefficient.}
\label{fig-grProps}
\end{figure}
Finally, we attempt to quantify the relationship between the features of the input graph to the performance in each of the evaluation tasks, as depicted in Figure \ref{fig-grProps}. It needs to be noted that this relationship is not always smooth, since the different values on graph features could also correspond to a different graph generation process. We opted for this abstraction to correlate a single graph property to an evaluation task irrespective of other particularities of the graph. In this comparison, GraphSAGE maxpool appears to be outperforming all other approaches for lower value of transitivity, while it faces a steep drop in performance in higher transitivity cases. As the density increases, the "commute time" to get from one node to another increases and higher order walks would be needed to accurately reflect the strategic placement of a node, i.e. closeness centrality, which causes performance of shallow methods to drop.
Finally, high average clustering coefficient (e.g. in the case of HK graphs) indicates that across the network a node's neighbors are also neighbors of each other therefore an aggregation of neighbor's features serves as a good representation for a node in the latent space.
{\bf Practitioner's guidelines.} Our evaluation process provided evidence that there is not a "one-to-fit-all" approach in the application of GRL. Different types of graphs respond differently to a hyperparameter setting which indicates that a sensitivity analysis of a GRL method needs to be specialized to the type of input graph. Suggested default values are often derived from graphs with different properties and thus cannot be easily transferred to a new application. It appears that GRL approaches do not adapt equally well to the particularities of the input graph which can be problematic in a real world application scenario. Dependent on the downstream learning task, whether that means identifying strategic nodes or the ones that bridge together different communities, the selection of GRL method may vary. As with other graph mining tasks, capturing both local and global structure is challenging and we provide evidence that popular GRL approaches often manage to preserve one of the two. Random walk based methods appear to capture global roles, e.g. community memberships, efficiently and adapt to heavily clustered graphs with power law degree distributions whereas GCNs capture local properties, such as degree, and the application of attention weights on them provides a significant boost. Our evidence suggests that graphs with Poisson degree distribution (ER) respond better to shallow embedding approaches. BA graphs are well combined with both shallow approaches and attention GCNs. GraphSAGE with max pooling appears well suited for graphs with hierarchical structure but high local clustering, i.e. HK graphs.
Our analysis indicates that the choice of embedding algorithm on each own is not the key decision point in the application of GRL. Instead, the identification of the characteristics of the input graph and the definition of the properties that need to be preserved for downstream learning tasks are the decisive factors that determine the applicability of GRL in a real world scenario. Following such an evaluation process improves interpretability in the application of GRL and provides verification for the choice of method and hyperparameter setting based on application needs and properties of the input graph.
\section{Conclusions}
In the present work we propose an extensive data-intensive evaluation approach of GRL methods with respect to the characteristics of the input graph, the hyperparameters of each method and the properties that are of importance for downstream learning applications hence need to be preserved in the latent space. We provide evidence on test cases that challenge each family of methods and distill applicability guidelines for practitioners in the process to select the appropriate GRL method for their purposes.
| {'timestamp': '2020-06-19T02:07:56', 'yymm': '2006', 'arxiv_id': '2006.10252', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10252'} | arxiv |
\section{APPENDIX}\label{sec:appendix}
\subsection{PRELIMINARIES}\label{subsec:prelim}
\begin{definition}\label{def:martingale}
(Martingale) A sequence of random variables $\{Z_i\}_{i=0}^n$ is a martingale with respect to the sequence $\{X_i\}_{i=0}^n$, if for all $n\geq 0$, the following conditions hold:
\begin{itemize}
\item $Z_n$ is a function of $\{X_i\}_{i=0}^n$
\item $\mathbb{E}[\vert Z_n \vert] < \infty$
\item $\mathbb{E}[Z_n \vert X_0...X_{n-1}] = Z_{n-1}$.
\end{itemize}
\end{definition}
\begin{definition}
(Filtration) Given a stochastic process, $\{X_t\}$ and a Borel space, $\mathcal{B}:= (T,\Sigma)$, then the sequence of nested $\sigma-$algebras, $\mathcal{F}_0 \subseteq \mathcal{F}_1 \subseteq \mathcal{F}_2... \subseteq \mathcal{F}_t \, \mathcal{F}_i \in \Sigma$ which may contain contain some information about $\{X_t\}$ is called a filtration. The stochastic process $\{X_t\}$ is said to be adapted to the filtration $\{\mathcal{F}_t\}$, if $X_t$ is $\mathcal{F}_t-$measurable for all $t$.
\end{definition}
\begin{remark}
A martingale can be equivalently defined over a filtration sequence: $Z_n$ is $\\ \mathcal{F}_n-$measurable for all $n \geq 0$ and $\mathbb{E}[Z_n \vert \mathcal{F}_{n-1} ] = Z_{n-1}$ in the definition~\ref{def:martingale}.
\end{remark}
\begin{definition}
(Stopping Time~\citep{mitzenmacher2005probability}) A nonnegative, integer-valued random variable $T$ is stopping time for the martingale sequence $\{Z_i\}_{i=0}^n$ if the event $T = n$ depends only on the value of the random variables, $Z_0,Z_1...Z_n$.
\end{definition}
The following lemma is Freedman's version of Bernstein inequality for martingales. Given bounded increments in the martingale sequence and with a known bound on the total conditional variation, the lemma provides a strong bounds on the value of each element in the sequence.
\begin{lemma}\label{freedman}
\textbf{Generalized Bernstein inequality for Martingales} (Theorem 1.6 in~\cite{freedman1975tail}, Theorem 10 in~\cite{pike2018bandits}) Let $\{Y_k\}_{k=0}^{\infty}$ be a real valued martingale with respect to the filtration, $\{\mathcal{F}_k\}_{k=0}^{\infty}$ with increments $\{Z_k\}_{k=1}^{\infty}$, implying $\mathbb{E}[Z_k \vert \mathcal{F}_{k-1}] = 0$ and $Z_k = Y_k - Y_{k-1}$ for $k=1,2,\hdots$. Given the martingale difference sequence is uniformly upper bounded as, $Z_k \leq b$ for $k=1,2,...$. Define the predictable variation process $W_k = \sum_{j=1}^k \mathbb{E}[Z_j^2 \vert \mathcal{F}_{j-1}]$ for $k=1,2,...$. Then for all $\alpha \geq 0$, $\sigma^2 \geq 0$, the following probability is bounded:
\begin{equation}\label{eq:concentration}
\mathbb{P}\left( \exists k \; :\; Y_k \geq \alpha \; \textrm{ and } W_k \leq \sigma^2 \right) \leq \exp\left(-\frac{\alpha^2/2}{\sigma^2+b\alpha/3}\right).
\end{equation}
\end{lemma}
The way to interpret Lemma~\ref{freedman} is that $\alpha$ denotes a deterministic boundary that the random walk, $Y_k$ is unlikely to cross. Following lemma relates this idea to the more applicable concept of the stopping times.
\begin{lemma}\label{equivalence}
\textbf{Equivalence Principle} (Proposition 1 in~\cite{zhao2016adaptive}) For any $\delta > 0$, $\mathbb{P}( S_J \geq f(J) ) \leq \delta$ for any stopping time $J$ if and only if, $\mathbb{P}( \{\exists n,\,S_n\geq f(n)\}) \leq \delta$, where $S_J$ is a random walk.
\end{lemma}
Using the above lemma in the setting of Lemma~\ref{freedman}, we are guaranteed that $Y_J$ also follows the same concentration as given by Equation~\ref{eq:concentration}. The following lemma combines the intuition of Doob's Optional Stopping theorem with the Azuma-Hoeffding's Inequality and also bounds the growth rate of certain martingale sequences.
\begin{lemma}\label{doob}
(Lemma A.1 in~\cite{szita2011agnostic}, Lemma 11 in~\cite{pike2018bandits}) Fix the positive integers $m$, $n$ and let $a,c \in \mathbb{R}$. Let $\mathcal{F}= \{\mathcal{F}_t\}_{t=0}^{\infty}$ be a filtration, $(\rho_t)_{t=1,2,3...n}$ be $\{0,1\}$-valued and $\mathcal{F}_{t-1}$-measurable random variables, and $(Z_t)_{t=1,2,3...n}$ be $\mathcal{F}_t$-measurable $\mathbb{R}$-valued random variables satisfying $\mathbb{E}[Z_t\vert\mathcal{F}_{t-1}]=0$, $Z_t\in[a,a+c]$ and $\sum_{s=1}^n\rho_s \leq m$ with probability one. Then for any $\eta >0$:
\begin{equation*}
\mathbb{P} \left( \sum_{t=1}^n \rho_t Z_t \geq \eta \right) \leq \exp\left(-\frac{2\eta^2}{c^2m} \right ).
\end{equation*}
\end{lemma}
\subsection{ADDITIONAL PROOFS}\label{subsec:missing_proofs}
\begin{customlemma}{1}\label{stocnm_app}
There exists a positive $n_m$ for which the estimate $\overline{X}_{m,j}$ calculated by Algorithm~\ref{alg:expectation_known} for an active arm $j$ ( $j\in \mathcal{K}_m$ ) and phase $m$, satisfies the following inequality with probability at least $1-\frac{2}{T^2}$:
\begin{equation*}
\overline{X}_{m,j} - \mu_j \leq \tilde{\Delta}_m/2.
\end{equation*}
\end{customlemma}
\begin{proof}
Using the above notation, it follows that for each arm $j$:
\begin{gather}
\sum_{i=1}^m\sum_{t=S_{i,j}}^{U_{i,j}} ( X_t - \mu_j ) \leq \sum_{i=1}^m\sum_{t=S_{i,j}}^{U_{i,j}} ( R_{t,J_t} - \mu_j )\nonumber \\- \sum_{i=1}^m\sum_{t=S_{i,j}}^{U_{i,j}} R_{t,J_t}\mathbb{I}\{ T_j(J_t,N) \leq D_{t,J_t}\}.\label{eq:stoc1_app}
\end{gather}
Since only one arm is played at a time, $T_t(J_t,N) \leq t-S_{i,j}$ and $J_t=j$ within a phase. Therefore:
\begin{gather*}
\sum_{i=1}^m\sum_{t=S_{i,j}}^{U_{i,j}} ( X_t - \mu_j ) \leq \sum_{i=1}^m\sum_{t=S_{i,j}}^{U_{i,j}} ( R_{t,j} - \mu_j )\nonumber \\- \sum_{i=1}^m\sum_{t=S_{i,j}}^{U_{i,j}} R_{t,j}\mathbb{I}\{ T_t(J_t,N) \leq D_{t,J_t}\}.
\end{gather*}
Define $A_{i,t} := R_{t,j}\mathbb{I}\{ t \leq S_{i,j} + D_{t,J_t}\}$ and $M_t := \sum_{i=0}^m A_{i,t}\mathbb{I}\{ S_{i,j}\leq t \leq U_{i,j} \}$ . We rewrite~(\ref{eq:stoc1}) in terms of $M_t$ as:
\begin{gather*}
\sum_{i=1}^m\sum_{t=S_{i,j}}^{U_{i,j}} ( X_t - \mu_j ) \leq \sum_{i=1}^m\sum_{t=S_{i,j}}^{U_{i,j}} ( R_{t,j} - \mu_j ) - \sum_{t=1}^{U_{m,j}} M_t,
\end{gather*}
therefore:
\begin{gather}
\sum_{i=1}^m\sum_{t=S_{i,j}}^{U_{i,j}} ( X_t - \mu_j ) \leq \sum_{i=1}^m\sum_{t=S_{i,j}}^{U_{i,j}} ( R_{t,j} - \mu_j )\nonumber\\ +\sum_{t=1}^{U_{m,j}} (\mathbb{E}[M_t\vert G_{t-1}] - N_t ) -
\sum_{t=1}^{U_{m,j}}\mathbb{E}[M_t\vert G_{t-1}].\label{eq:71_app}
\end{gather}
Due to the above construction we are able to succinctly separate loss in rewards due to the \textit{wear-in} effect. We bound each term individually in Equation~\ref{eq:71_app}. The first term is nothing but the deviations of the rewards from their true means and hence a reasonable upper bound is crucial for the $T$ dependence of the leading term in Corollary~\ref{coroll:expectation_known}. On the other hand the upper bounds on the second term decides the impact of the priming effect. From Lemmas~\ref{term1} and~\ref{term2} accompanied by a trivial non-negative upper bound for the last term in Equation~\ref{eq:71_app} above, we can write that with probability at least $1-\frac{2}{T^2}$ (from union bound):
\begin{gather*}
\sum_{i=1}^m\sum_{t=S_{i,j}}^{U_{i,j}} ( X_t - \mu_j ) \leq \sqrt{n_m \log(T)} + \frac{2}{3}\log(T) \\+ \sqrt{\frac{4\log^2(T)}{9}+4m\mathbb{E}[D]\log(T)}.
\end{gather*}
For each active arm $j \in \mathcal{K}_m$,
\begin{gather*}
\frac{1}{n_m}\sum_{t \in T_j(m)} ( X_t - \mu_j ) \leq \sqrt{\frac{\log(T)}{n_m}} \\+ \frac{2\log(T)}{n_m} + \frac{1}{n_m}\sqrt{4m\mathbb{E}[D]\log(T)} = w_m.
\end{gather*}
Algorithm~\ref{alg:expectation_known} requires $w_m \leq \tilde{\Delta}_m/2$ so that the arm elimination condition holds good. This helps to determine the appropriate $n_m$. Let $s1=\\ \sqrt{\frac{4\log^2(T)}{9}+4m\mathbb{E}[D]\log(T)}$, then, the smallest $n_m$ which satisfies the above is given by:
\begin{gather*}
n_m = \left\lceil\frac{1}{\tilde{\Delta}^2_m}\left( \sqrt{\log(T)}\qquad \qquad\qquad \qquad \qquad\qquad \right.\right. \\
\quad\quad\left.\left.+ \sqrt{\log(T) + \frac{4\tilde{\Delta}_m\log(T)}{3} + 2\tilde{\Delta}_m s1 } \right )^2\right\rceil.
\end{gather*}
Using $(a+b)^2 \leq 2(a^2+b^2)$ and $x=\lceil y \rceil \Rightarrow x \leq y+1$:
\begin{gather*}
n_m \leq \left\lceil\frac{1}{\tilde{\Delta}^2_m}\left( 4 \log(T) + \frac{8\tilde{\Delta}_m\log(T)}{3} + 4\tilde{\Delta}_ms1\right )\right\rceil.
\end{gather*}
We can now substitute $s1$ and use inequality $\sqrt{a^2+b^2}\leq (a+b)$ to get:
\begin{gather*}
n_m \leq \left\lceil\frac{4 \log(T)}{\tilde{\Delta}^2_m} + \frac{24\log(T)}{3\tilde{\Delta}_m} + \frac{8\sqrt{m\mathbb{E}[D]\log(T)}}{\tilde{\Delta}_m} \right\rceil.
\end{gather*}
Further, we can modify the \textit{ceiling} operator with a tight upper bound as below:
\begin{gather*}
n_m \leq 1+\frac{4 \log(T)}{\tilde{\Delta}^2_m} + \frac{16\log(T)}{3\tilde{\Delta}_m} + \frac{8\sqrt{m\mathbb{E}[D]\log(T)}}{\tilde{\Delta}_m}.
\end{gather*}
This completes the proof.
\end{proof}
\begin{customlemma}{2}\label{martingaleproof_app}
$Y_s = \sum_{t=1}^s \mathbb{E}[M_t\vert G_{t-1}] - M_t)$ for all $s\geq 1$ with $Y_0=0$ is a martingale with respect to the filtration $\{G_s\}^{\infty}_{s=0}$ with increments $C_s = Y_s-Y_{s-1} = \mathbb{E}[M_s\vert G_{s-1}] - M_s )$, satisfying $\mathbb{E}[C_s\vert G_{s-1}] = 0$, $C_s \leq 1$ for all $s\geq 1$.
\end{customlemma}
\begin{proof}
To show $\{Y_s\}_{s=0}^{\infty}$ is a martingale defined on filtration $\{\mathcal{G}_s\}_{s=0}^{\infty}$, we need to show $Y_s$ is $\{\mathcal{G}_s\}$-measurable for all $s\geq 1$ and $\mathbb{E}[Y_s\vert G_{s-1}] =Y_{s-1}$.
By the definition of $\sigma$-algebra $\{\mathcal{G}_s\}_{s=0}^{\infty}$, random variables $D_{t,J_t},R_{t,J_t}$ are all $\{\mathcal{G}_s\}$-measurable for $t\leq s$. Additionally for phases $i$ where time instance $t$ lie in phases after $i$, $\mathbb{I}\{ S_{i,j}\leq t \leq U_{i,j} \}=0$ ( measurable by $\mathcal{G}_0$ ). Hence $\{Y_s\}_{s=0}^{\infty}$ is measurable by $\{\mathcal{G}_s\}_{s=0}^{\infty}$. Now consider the conditional expectation:
\begin{gather*}
\mathbb{E}[Y_s\vert \mathcal{G}_{s-1}] = \mathbb{E}\left[\sum_{t=1}^s (\mathbb{E}[M_t\vert G_{t-1}] - M_t) \vert \mathcal{G}_{s-1} \right ]\\
= \mathbb{E}\left[\sum_{t=1}^{s-1} (\mathbb{E}[M_t\vert G_{t-1}] - M_t) \vert \mathcal{G}_{s-1} \right ] +\\ \mathbb{E}\left[ (\mathbb{E}[M_s\vert G_{s-1}] - M_s) \vert \mathcal{G}_{s-1} \right ]\\
= \mathbb{E}\left[\sum_{t=1}^{s-1} (\mathbb{E}[M_t\vert G_{t-1}] - M_t) \vert \mathcal{G}_{s-1} \right ] = Y_{s-1}.
\end{gather*}
Therefore $\{Y_s\}_{s=0}^{\infty}$ is a martingale with respect to the filtration $\{\mathcal{G}_s\}_{s=0}^{\infty}$. Clearly, the increment $C_s = Y_s - Y_{s-1} = (\mathbb{E}[M_s\vert G_{s-1}] - M_s)$ and $\mathbb{E}[C_s\vert G_{s-1}] = \mathbb{E}[(\mathbb{E}[M_s\vert G_{s-1}] - M_s)\vert G_{s-1} ] = 0$
Note that for any phase $i$, $A_{i,t} \leq 1$ as reward $R_{t,J_t}$ is bounded by $1$. Also, for any time $t$ $M_t \leq 1$ as $\mathbb{I}\{ S_{i,j}\leq t \leq U_{i,j} \}$ is $1$ for only a particular phase $i$ thus $C_s \leq 1$ for $s \geq 1$. This completes the proof.
\end{proof}
\begin{customlemma}{3}\label{term1_app} With probability at least $1 - \frac{1}{T^2}$,
\begin{gather*}
\sum_{i=1}^m\sum_{t=S_{i,j}}^{U_{m,j}}( R_{t,J_t} -\mu_j ) \leq \sqrt{n_m \log(T)}.
\end{gather*}
\end{customlemma}
\begin{proof}
We will invoke an instance of Lemma~\ref{doob} to prove the above. For arm $j$, take $n=T$, $\mathcal{F}_t$ as filtration with $\sigma$-algebra on $(X_1,....X_t,R_{1,j}...R_{t,j})_{t=1,2...T}$. Let $Z_t = R_{t,j}-\mu_j$ and $\rho_t = \mathbb{I}\{J_t=j,\;t\leq U_{m,j}\}$. Therefore $\sum_{t=1}^T\rho_t$ is nothing but number of times arm $j$ was pulled till phase $m$, which is equal to $\vert T_j(m) \vert$ by definition. Also, $\vert T_j(m) \vert \leq n_m$. Hence the summation can be alternatively written as: $\sum_{t\in T_j(m)} (R_{t,j} -\mu_j) = \sum_{t=1}^T \rho_t(R_{t,j}-\mu_j)$.
Additionally, for any $1\leq t \leq T$, $\rho_t = \mathbb{I}\{J_t=j,\;t\leq U_{m,j}\}$ is $\mathcal{F}_{t-1}$-measurable. Given all the observations $X_1,X_2....X_{t-1}$ till $(t-1)$, we know in which phase does $t$ belongs. This is because of the phased nature of Algorithm~\ref{alg:expectation_known}, thus, $\mathbb{I}\{t\leq U_{m,j}\}$ is determined. Similarly $J_t=j$ can also be determined, establishing that $\rho_t$ is $\mathcal{F}_{t-1}$-measurable. $Z_t$ is $\mathcal{F}_{t}$-measurable by definition. Taking $a=-\mu_j$ and $c=1$ in the application of Lemma~\ref{doob}, we get the stated result.
\end{proof}
\begin{customlemma}{4}\label{variation_app}
For any $t$, if $P_t= \mathbb{E}[M_t\vert G_{t-1}] - M_t$, then
\begin{gather*}
\sum_{t=1}^{U_{m,j}} \mathbb{E}[P_t^2\vert G_{t-1}] \leq m\mathbb{E}[D]
\end{gather*}
\end{customlemma}
\begin{proof}
Consider:
\begin{align*}
\sum_{t=1}^{U_{m,j}} \mathbb{E}[P_t^2\vert G_{t-1}] = \sum_{t=1}^{U_{m,j}} \mathbb{V}[M_t^2\vert G_{t-1}] \leq \sum_{t=1}^{U_{m,j}} \mathbb{E}[M_t^2\vert G_{t-1}]\\
= \sum_{t=1}^{U_{m,j}}\mathbb{E}\left[\left( \sum_{i=1}^m A_{i,t}\mathbb{I} \{ S_{i,j} \leq t \leq U_{i,j} \} \right)^2 \vert G_{t-1} \right].
\end{align*}
Notice that the product, $\mathbb{I} \{ S_{i,j} \leq t \leq U_{i,j} \} \mathbb{I} \{ S_{k,j} \leq t \leq U_{k,j} \} =0 $ for distinct phases $i,k \leq m$ as $t$ lies only in a specific phase. Therefore:
\begin{gather*}
\sum_{t=1}^{U_{m,j}} \mathbb{E}[P_t^2\vert G_{t-1}] \leq \sum_{t=1}^{U_{m,j}}\mathbb{E}\left[\sum_{i=1}^m A_{i,t}^2\mathbb{I} \{ S_{i,j} \leq t \leq U_{i,j} \} \vert G_{t-1} \right ]\\
= \sum_{i=1}^m\sum_{t=1}^{U_{m,j}}\mathbb{E}\left[\sum_{i=1}^m A_{i,t}^2\mathbb{I} \{ S_{i,j} \leq t \leq U_{i,j} \} \vert G_{t-1} \right ]\\
= \sum_{i=1}^m\sum_{t=S_{i,j}}^{U_{m,j}}\mathbb{E}\left[ A_{i,t}^2\mathbb{I} \{ S_{i,j} \leq t \leq U_{i,j} \} \vert G_{t-1} \right ].
\end{gather*}
As $S_{i,j}$ and $U_{i,j}$ are $G_{t-1}$-measurable and if $\mathbb{I} \{ S_{i,j} \leq t \leq U_{i,j} \}=1$, therefore:
\begin{gather*}
\leq \sum_{i=1}^m\sum_{t=S_{i,j}}^{U_{i,j}}\mathbb{E}[A_{i,t}^2\vert G_{t-1}]\\
= \sum_{i=1}^m\sum_{t=S_{i,j}}^{U_{i,j}}\mathbb{E}[R_{t,J_t}^2\mathbb{I}\{ t \leq S_{i,j} + D_{t,J_t} \} \vert G_{t-1}]\\
\leq \sum_{i=1}^m\sum_{t=S_{i,j}}^{U_{i,j}}\mathbb{E}[\mathbb{I}\{ t \leq S_{i,j} + D_{t,J_t} \} \vert G_{t-1}]\\
= \sum_{i=1}^m\sum_{s=0}^{\infty}\sum_{s'=s}^{\infty}\sum_{t=s}^{s'}\mathbb{E}[\mathbb{I}\{S_{i,j}=s,\;U_{i,j}=s',\; t \leq s + D_{t,J_t} \} \vert G_{t-1}]\\
= \sum_{i=1}^m\sum_{s=0}^{\infty}\sum_{s'=s}^{\infty}\sum_{t=s}^{s'}\mathbb{I}\{S_{i,j}=s,\;U_{i,j}=s'\}\sum_{t=s}^{s'}\mathbb{P}( t \leq s + D_{t,J_t} )\\
\leq \sum_{i=1}^m\sum_{s=0}^{\infty}\sum_{s'=s}^{\infty}\sum_{t=s}^{s'}\mathbb{I}\{S_{i,j}=s,\;U_{i,j}=s'\}\sum_{l=0}^{\infty}\mathbb{P}( l \leq D ),
\end{gather*}
\begin{equation*}
\leq \sum_{i=1}^m \mathbb{E}[D] = m\mathbb{E}[D].
\end{equation*}
This completes the proof.
\end{proof}
\begin{customlemma}{5}\label{term2_app}
With probability at least $1-\frac{1}{T^2}$,
\begin{gather*}
\sum_{t=1}^{U_{m,j}}(\mathbb{E}[M_t\vert G_{t-1}] - M_t ) < \frac{2}{3}\log(T)\\ + \sqrt{\frac{4\log^2(T)}{9}+4m\mathbb{E}[D]\log(T)}.
\end{gather*}
\end{customlemma}
\begin{proof}
$Y_s = \sum_{t=1}^s (\mathbb{E}[M_t\vert G_{t-1}] - M_t)$ for all $s\geq 1$ and $Y_0=0$ is a martingale with respect to the filtration $\{G_s\}^{\infty}_{s=0}$. Also, the increments $Z_s = Y_s-Y_{s-1} = \mathbb{E}[M_s\vert G_{s-1}] - M_s $ satisfy $\mathbb{E}[Z_s\vert G_{s-1}] = 0$ and $Z_s \leq 1$ for all $s\geq 1$. Additionally the Lemma~\ref{variation} implies $\sum_{t=1}^s\mathbb{E}[Z_t^2\vert G_{t-1}] \leq m\mathbb{E}[D]$. From Lemma~\ref{freedman}, there exists a $s$ for which $\sum_{t=1}^s (\mathbb{E}[M_t\vert G_{t-1}] - M_t)$ is bounded with high probability. Now, Lemma~\ref{equivalence} suggests that $Y_J$ concentrates well for all stopping times $J$ and hence, also for $J=U_{m,j}$.
\end{proof}
\noindent{\textbf{Proof of Theorem~\ref{thm:expectation_known}:}}
\begin{proof}
We create four mutually exclusive and exhaustive cases. We then bound the expected regret conditioned on the events of these cases. For each sub-optimal arm $i$, let $m_i := \min \{ m \vert \tilde{\Delta}_m < \frac{\Delta_i}{2}\}$, is the first phase where $\tilde{\Delta}_m < \frac{\Delta_i}{2}$. We also define $\mathcal{K}_1 = \{ i\in \mathcal{K} \vert \Delta_i > \lambda \}$. The four cases are as follows:\\
\textbf{Case (a):} \textit{Arm $i$ is not deleted in phase $m_i$ with the optimal arm $*$ in the set $\mathcal{K}_{m_i}$}.\\
The phase $m_i$ is characterized by : $w_{m_i} \leq \frac{\Delta_{m_i}}{2} \leq \frac{\Delta_i}{4}$. Let $E:=\mathbb{I}\{\overline{\mu}_i \leq \mu_i + w_{m_i}\}$ and $R:=\mathbb{I}\{\overline{\mu}_* \geq \mu_* - w_{m_i}\}$.
If the events $E$ and $R$ hold then the phase-end elimination condition of the Algorithm~\ref{alg:expectation_known} is satisfied, as:
\begin{equation*}
\overline{\mu}_i + w_{m_i} \leq \mu_i + 2w_{m_i} < \mu_i + \Delta_i - 2w_{m_i} \leq \overline{\mu}_* - w_{m_i}.
\end{equation*}
From Lemma~\ref{stocnm}, $\mathbb{P}(E) > 1-\frac{1}{T^2}$ and $\mathbb{P}(R) > 1-\frac{1}{T^2}$ follows. In this case we are interested in regret conditional on $\{E^{\complement} \cup \R^{\complement}\}$, which via an union bound argument can be shown as:
\begin{equation*}
R_T \leq \sum_{i\in \mathcal{K}_1} \frac{4}{T^2} T\Delta_i \leq \sum_{i\in \mathcal{K}_1} \frac{4\Delta_i}{T}.
\end{equation*}
\textbf{Case (b)}\textit{ Arm $i$ is eliminated at the phase $m_i$ with the optimal arm $* \in \mathcal{K}_{m_i}$.}\\
By lemma~\ref{stocnm}, in case the sub-optimal arm $i$ is eliminated in the phase $m_i$ then the maximum number of times it is played is given by Equation~\ref{eq:stocnmval}. Additionally, we make use of $\Delta_i/4 \leq \tilde{\Delta}_m\leq \Delta_i/2$ and $m_i \leq \log_2\left(\frac{4}{\Delta_i}\right) < 2\log\left(\frac{4}{\Delta_i}\right)$. Therefore:
\begin{gather*}
n_{m_i} \leq 1 + \frac{64 \log(T)}{\Delta_i^2} + \frac{64\log(T)}{3\Delta_i} + \frac{32\sqrt{\log\left(\frac{4}{\Delta_i}\right)\mathbb{E}[D]\log(T)}}{\tilde{\Delta}_i}.
\end{gather*}
Thus,
\begin{gather*}
R_T \leq \sum_{i\in\mathcal{K}'}\Delta_i\left( 1 + \frac{64 \log(T)}{\Delta_i^2} + \frac{64\log(T)}{3\Delta_i}\right. \\ \left.+\frac{32\sqrt{\log\left(\frac{4}{\Delta_i}\right)\mathbb{E}[D]\log(T)}}{\tilde{\Delta}_i}\right)\\
\leq \sum_{i\in\mathcal{K}'}\left( \Delta_i + \frac{64 \log(T)}{\Delta_i} + \frac{64\log(T)}{3} \right.\\
\left.+ 32\sqrt{\log\left(\frac{4}{\Delta_i}\right)\mathbb{E}[D]\log(T)} \right).
\end{gather*}
\textbf{Case (c)} \textit{Optimal arm $*$ deleted by some sub-optimal $i$ in the set $\mathcal{K}_2$}.\\
Now, we consider the case when the last of all the optimal arms (in case there more than one), denoted $*$, is eliminated by some sub optimal arm $i$ in $\mathcal{K}_2 = \{ i\in \mathcal{K} \vert \Delta_i >0 \}$ in some round $m_*$ (overloading the definition of $m_i$, $m_*$ is any round where $*$ is eliminated). As elimination of the optimal arm can be induced by larger number of arms (the set $\mathcal{K}''$) at the end of a phase as compared to during a phase, we only need to analyze the events at the end of a phase to upper bound regret. This is similar in spirit to the events in \textbf{Case (d)}, as $E$ and $R$ cannot hold together with the elimination condition of the Algorithm~\ref{alg:expectation_known}. Hence the probability of this happening is again upper bounded by $\frac{4}{T^2}$ by a similar argument.
The optimal arm $*$ belonged to $K_{m_s}$ corresponding to all sub-optimal arms $s$ with $m_s < m_*$. Therefore arm $i$, which causes elimination of the optimal arm $*$, should satisfy $m_i \geq m_*$. Therefore the regret is upper bounded by:
\begin{gather*}
R_T \leq \overset{\max_{j\in\mathcal{K}_1}m_j}{\underset{m_*=0}{\sum}} \underset{i\in \mathcal{K}_2:m_i \leq m_*}{\sum} \frac{4}{T^2}.T \underset{j\in \mathcal{K}_2:m_j\geq m_*}{\max}\Delta_j,
\end{gather*}
\begin{equation*}
\leq \overset{\max_{j\in\mathcal{K}_1}m_j}{\underset{m_*=0}{\sum}} \underset{i\in \mathcal{K}_2:m_i \leq m_*}{\sum} \frac{4}{T}4\tilde{\Delta}_{m_*},
\end{equation*}
\begin{equation*}
\leq \underset{i\in \mathcal{K}_2}{\sum} \underset{m_*\geq 0}{\sum} \frac{16}{T} 2^{-m_*} \leq \underset{i\in \mathcal{K}_2}{\sum} \frac{32}{T}.
\end{equation*}
\textbf{Case (d)} \textit{Arm $i\,\in\,\mathcal{K}_2$ and $\notin \,\mathcal{K}_1$}.\\
Here, we account for the difference in the sets $\mathcal{K}_2$ and $\mathcal{K}_1$. The following gives an upper bound on the regret conditioned on this case:
\begin{equation*}
R_T \leq \underset{i \in \mathcal{K}_2: \Delta_i < \lambda}{\max} \Delta_i T .
\end{equation*}
As all the four cases are mutually exclusive and exhaustive, we thus, get the desired regret upper bound.
\end{proof}
\begin{customlemma}{6}\label{stocnm_wi_wo_app}
There exists a positive $n_m$ for which the estimate $\overline{X}_{m,(i,j)}$ calculated by Algorithm~\ref{alg:expectation_known2} for an active pair $(i,j)$ ( $(i,j)\,\in \mathcal{K}^2_m$ ) and phase $m$, satisfies the following inequality with probability at least $1-\frac{2}{T^2}$ :
\begin{gather*}
\overline{X}_{m,(i,j)} - \mu_(i,j) \leq \tilde{\Delta}_m/2,
\end{gather*}
where $\mu_{i,j} = \frac{1}{2}(\mu_i+\mu_j)$.
\end{customlemma}
\begin{proof}
The phases are defined with respect to the compound arms and the reward $R_{t,J_t}$ is due to arm played by Algorithm~\ref{alg:expectation_known2} at time $t$. Define a filtration $\{\mathcal{G}_t\}_{t=0}^{\infty}$, with $\mathcal{G}_t$ a $\sigma$-algebra over $(X_{1}....X_t$,$J_1....J_t$,$D_{1,J_1}....D_{t,J_t}$,$Z_{1,J_1}....Z_{t,J_t}$, $R_{1,J_1}...R_{t,J_t})$. Most notations introduced for the proof of Lemma~\ref{stocnm_app} carry through unaltered here. For each compound arm $(i,j)$:
\begin{gather}
\sum_{k=1}^m\sum_{t=S_{k,(i,j)}}^{U_{k,(i,j)}} ( X_t - \mu_{(i,j)} ) \leq \sum_{k=1}^m\sum_{t=S_{k,(i,j)}}^{U_{k,(i,j)}} ( R_{t,J_t} - \mu_{(i,j)} )\nonumber \\ -\sum_{k=1}^m\sum_{t=S_{k,(i,j)}}^{U_{k,(i,j)}} R_{t,J_t}\mathbb{I}\{ \min(t-S_{k,(i,j)},T_t(J_t,N)) \leq D_{t,J_t}\}\nonumber \\
-\sum_{k=1}^m\sum_{t=S_{k,(i,j)}}^{U_{k,(i,j)}} R_{t,J_t}\mathbb{I}\{ \min(t-S_{k,(i,j)},T_t(J_t,N)) \geq Z_{t,J_t}\}\nonumber \\
\leq \sum_{k=1}^m\sum_{t=S_{k,(i,j)}}^{U_{k,(i,j)}} ( R_{t,J_t} - \mu_{(i,j)} ) -\sum_{k=1}^m\sum_{t=S_{k,(i,j)}}^{U_{k,(i,j)}} R_{t,J_t}\mathbb{I}\{ T_t(J_t,N) \leq D_{t,J_t}\}\nonumber \\
-\sum_{k=1}^m\sum_{t=S_{k,(i,j)}}^{U_{k,(i,j)}} R_{t,J_t}\mathbb{I}\{ \min(t-S_{k,(i,j)},T_t(J_t,N)) \geq Z_{t,J_t}\}\label{eq:stoc_wiwo_app},
\end{gather}
where the second term is due to the loss in rewards due to wear-in and third term accounts for the same due to wear-out. Using a non-negative upper bound for the third term, we can loosen the upper bound and write:
\begin{gather}
\sum_{k=1}^m\sum_{t=S_{k,(i,j)}}^{U_{k,(i,j)}} ( X_t - \mu_{(i,j)} )
\leq \sum_{k=1}^m\sum_{t=S_{k,(i,j)}}^{U_{k,(i,j)}} ( R_{t,J_t} - \mu_{(i,j)} )\nonumber \\ -\sum_{k=1}^m\sum_{t=S_{k,(i,j)}}^{U_{k,(i,j)}} R_{t,J_t}\mathbb{I}\{ T_t(J_t,N) \leq D_{t,J_t}\}\label{eq:stoc1_wiwo_app}.
\end{gather}
By ignoring the wear-out term, we loosen the upper bound however it is intuitive to see that the loss of rewards due to wear-out effect is limited. During a phase, since the algorithm plays 2 arms uniformly, it is likely that each of the two arms get played equal number of times and neither of them gets worn out in any contagious $N$ rounds. Similarly in any phase, number of such $N$ sized contagious periods where the arms play unequal number of times would be limited. Define $B_{k,t} := R_{t,J_t}\mathbb{I}\{ T_t(J_t,N) \leq D_{t,J_t}\}$ and $N_t := \sum_{k=0}^m B_{k,t}\mathbb{I}\{ S_{k,(i,j)}\leq t \leq U_{k,(i,j)} \}$. We rewrite Equation~\ref{eq:stoc1_wiwo_app} in terms of $N_t$ as:
\begin{gather*}
\sum_{k=1}^m\sum_{t=S_{k,(i,j)}}^{U_{k,(i,j)}} ( X_t - \mu_{(i,j)} ) \leq \sum_{k=1}^m\sum_{t=S_{k,(i,j)}}^{U_{k,(i,j)}} ( R_{t,J_t} - \mu_{(i,j)} ) - \sum_{t=1}^{U_{m,j}} N_t,
\end{gather*}
therefore:
\begin{gather}
\sum_{i=1}^m \sum_{t=S_{i,j}}^{U_{i,j}} ( X_t - \mu_{(i,j)} ) \leq \sum_{i=1}^m\sum_{t=S_{i,j}}^{U_{i,j}} ( R_{t,J_t} - \mu_{(i,j)} )\nonumber\\ +\sum_{t=1}^{U_{m,j}} (\mathbb{E}[N_t\vert G_{t-1}] - N_t ) -
\sum_{t=1}^{U_{m,j}}\mathbb{E}[N_t\vert G_{t-1}].\label{eq:71_wiwo_app}
\end{gather}
We bound each term individually in Equation~\ref{eq:71_wiwo_app}. The first term is nothing but the deviations of the rewards from their true means and hence a reasonable upper bound is crucial for the $T$ dependence of the leading term in Corollary~\ref{coroll:wi_wo}. On the other hand the upper bounds on the second term decides the impact of the priming effect. We again use Lemma~\ref{term1} to bound the growth of the first term in Equation~\ref{eq:71_wiwo_app}. This also works out since in the definition of compound arm $(i,j)$ the arms $i,j$ are played randomly with equal probability. Hence $R_{t,J_t} -\mu_{(i,j)}$ is still zero mean. Further we use Lemma~\ref{term2_wi_wo} accompanied by a trivial non-negative upper bound for the last two terms. Finally, we can write that with probability at least $1-\frac{2}{T^2}$ (from union bound):
\begin{flalign*}
\sum_{k=1}^m\sum_{t=S_{k,(i,j)}}^{U_{k,(i,j)}} ( X_t - \mu_{(i,j)} ) \leq \sqrt{n_m \log(T)} + \frac{2}{3}\log(T) \\+ \sqrt{\frac{4\log^2(T)}{9}+4mN\mathbb{E}[D]\log(T)}.
\end{flalign*}
For each active arm $(i,j) \in \mathcal{K}^2_m$,
\begin{flalign*}
\frac{1}{n_m}\sum_{t \in T_{(i,j)}(m)} ( X_t - \mu_{(i,j)} ) \leq \sqrt{\frac{\log(T)}{n_m}} \\+ \frac{2\log(T)}{n_m} + \frac{1}{n_m}\sqrt{4Nm\mathbb{E}[D]\log(T)} = w_m.
\end{flalign*}
Algorithm~\ref{alg:expectation_known} requires $w_m \leq \tilde{\Delta}_m/2$ so that the arm elimination condition holds good. This helps to determine the appropriate $n_m$. Let $s1=\\ \sqrt{\frac{4\log^2(T)}{9}+4Nm\mathbb{E}[D]\log(T)}$, then, the smallest $n_m$ which satisfies the above is given by:
\begin{flalign*}
n_m = \left\lceil\frac{1}{\tilde{\Delta}^2_m}\left( \sqrt{\log(T)}\qquad \qquad\qquad \qquad \qquad\qquad \right.\right. \\
\quad\quad\left.\left.+ \sqrt{\log(T) + \frac{4\tilde{\Delta}_m\log(T)}{3} + 2\tilde{\Delta}_m s1 } \right )^2\right\rceil.
\end{flalign*}
Using $(a+b)^2 \leq 2(a^2+b^2)$ and $x=\lceil y \rceil \Rightarrow x \leq y+1$:
\begin{equation*}
n_m \leq \left\lceil\frac{1}{\tilde{\Delta}^2_m}\left( 4 \log(T) + \frac{8\tilde{\Delta}_m\log(T)}{3} + 4\tilde{\Delta}_ms1\right )\right\rceil.
\end{equation*}
We can now substitute $s1$ and use inequality $\sqrt{a^2+b^2}\leq (a+b)$ to get:
\begin{equation*}
n_m \leq \left\lceil\frac{4 \log(T)}{\tilde{\Delta}^2_m} + \frac{24\log(T)}{3\tilde{\Delta}_m} + \frac{8\sqrt{Nm\mathbb{E}[D]\log(T)}}{\tilde{\Delta}_m} \right\rceil.
\end{equation*}
Further, we can modify the \textit{ceiling} operator with a tight upper bound as below:
\begin{equation*}
n_m \leq 1+\frac{4 \log(T)}{\tilde{\Delta}^2_m} + \frac{16\log(T)}{3\tilde{\Delta}_m} + \frac{8\sqrt{Nm\mathbb{E}[D]\log(T)}}{\tilde{\Delta}_m}.
\end{equation*}
This completes the proof.
\end{proof}
\begin{customlemma}{7}\label{martingaleproof_wi_wo}
$H_s := \sum_{t=1}^s \mathbb{E}[N_t\vert G_{t-1}] - N_t)$ for all $s\geq 1$ with $H_0=0$ is a martingale with respect to the filtration $\{G_s\}^{\infty}_{s=0}$ with increments $V_s = H_s-H_{s-1} = \mathbb{E}[N_s\vert G_{s-1}] - N_s $ satisfying $\mathbb{E}[V_s\vert G_{s-1}] = 0$ and $V_s \leq 1$ for all $s\geq 1$.
\end{customlemma}
The proof is identical to that of Lemma~\ref{martingaleproof_app}.\\
\begin{customlemma}{8}\label{term2_wi_wo}
With probability at least $1-\frac{1}{T^2}$,
\begin{gather*}
\sum_{t=1}^{U_{m,j}}(\mathbb{E}[N_t\vert G_{t-1}] - N_t ) < \frac{2}{3}\log(T)\\ + \sqrt{\frac{4\log^2(T)}{9}+4mN\mathbb{E}[D]\log(T)}.
\end{gather*}
\end{customlemma}
The proof is identical to that of Lemma~\ref{term2} when we use the appropriate bounds on the variation process as given by Lemma~\ref{lemma:variation_wiwo} in this section.\\
\begin{customlemma}{9}\label{lemma:variation_wiwo}
For any $t$, if $P_t= \mathbb{E}[N_t\vert G_{t-1}] - N_t$ then
\begin{gather*}
\sum_{t=1}^{U_{m,(i,j)}} \mathbb{E}[P_t^2\vert G_{t-1}] \leq Nm\mathbb{E}[D]
\end{gather*}
\end{customlemma}
\begin{proof}
Consider:
\begin{gather*}
\sum_{t=1}^{U_{m,(i,j)}} \mathbb{E}[P_t^2\vert G_{t-1}] = \sum_{t=1}^{U_{m,(i,j)}} \mathbb{V}[N_t^2\vert G_{t-1}] \leq \sum_{t=1}^{U_{m,(i,j)}} \mathbb{E}[N_t^2\vert G_{t-1}]\\
= \sum_{t=1}^{U_{m,(i,j)}}\mathbb{E}\left[\left( \sum_{k=1}^m B_{k,t}\mathbb{I} \{ S_{k,(i,j)} \leq t \leq U_{k,(i,j)} \} \right)^2 \vert G_{t-1} \right].
\end{gather*}
Notice that the product, $\mathbb{I} \{ S_{k,(i,j)} \leq t \leq U_{k,(i,j)} \} \mathbb{I} \{ S_{l,(i,j)} \leq t \leq U_{l,(i,j)} \} =0 $ for distinct phases $k,l \leq m$ as $t$ lies only in a specific phase. Therefore:
\begin{gather*}
\sum_{t=1}^{U_{m,(i,j)}} \mathbb{E}[P_t^2\vert G_{t-1}] \leq \sum_{t=1}^{U_{m,(i,j)}}\mathbb{E}\left[\sum_{k=1}^m B_{k,t}^2\mathbb{I} \{ S_{k,(i,j)} \leq t \leq U_{k,(i,j)} \} \vert G_{t-1} \right ],
\end{gather*}
\begin{equation*}
= \sum_{t=1}^{U_{m,(i,j)}}\mathbb{E}\left[\sum_{k=1}^m B_{k,t}^2\mathbb{I} \{ S_{k,(i,j)} \leq t \leq U_{k,(i,j)} \} \vert G_{t-1} \right ],
\end{equation*}
\begin{equation*}
= \sum_{k=1}^m\sum_{t=S_{k,(i,j)}}^{U_{m,(i,j)}}\mathbb{E}\left[ B_{k,t}^2\mathbb{I} \{ S_{k,(i,j)} \leq t \leq U_{k,(i,j)} \} \vert G_{t-1} \right ].
\end{equation*}
As $S_{k,(i,j)}$ and $U_{k,(i,j)}$ are $G_{t-1}$-measurable and if $\mathbb{I} \{ S_{k,(i,j)} \leq t \leq U_{k,(i,j)} \}=1$, therefore:
\begin{gather*}
\leq \sum_{k=1}^m\sum_{t=S_{k,(i,j)}}^{U_{k,(i,j)}}\mathbb{E}[B_{k,t}^2\vert G_{t-1}]\\
= \sum_{k=1}^m\sum_{t=S_{k,(i,j)}}^{U_{k,(i,j)}}\mathbb{E}[R_{t,J_t}^2\mathbb{I}\{ T_t(J_t,N) \leq D_{t,J_t} \} \vert G_{t-1}]\\
\leq \sum_{k=1}^m\sum_{t=S_{k,(i,j)}}^{U_{k,(i,j)}}\mathbb{E}[\mathbb{I}\{ T_t(J_t,N) \leq D_{t,J_t} \} \vert G_{t-1}]\\
= \sum_{k=1}^m\sum_{s=0}^{\infty}\sum_{s'=s}^{\infty}\sum_{t=s}^{s'}\mathbb{E}[\mathbb{I}\{S_{k,(i,j)}=s,\;U_{k,(i,j)}=s',\; T_t(J_t,N) \leq D_{t,J_t} \} \vert G_{t-1}]\\
= \sum_{k=1}^m\sum_{s=0}^{\infty}\sum_{s'=s}^{\infty}\sum_{t=s}^{s'}\mathbb{I}\{S_{k,(i,j)}=s,\;U_{k,(i,j)}=s'\}\sum_{t=s}^{s'}\mathbb{P}( T_t(J_t,N) \leq D_{t,J_t} ).
\end{gather*}
$T_t(J_t,N)$ is a random variable which takes upto $N$. Hence an union bound gives:
\begin{equation*}
\leq \sum_{i=1}^m\sum_{s=0}^{\infty}\sum_{s'=s}^{\infty}\sum_{t=s}^{s'}\mathbb{I}\{S_{i,j}=s,\;U_{i,j}=s'\}N\sum_{l=0}^{\infty}\mathbb{P}( l \leq D ),
\end{equation*}
\begin{equation*}
\leq \sum_{i=1}^m \mathbb{E}[D] = Nm\mathbb{E}[D].
\end{equation*}
This completes the proof.
\end{proof}
\textbf{Proof of Theorem~\ref{thm:wi_wo}:}\\
Proceeding as in the proof of Theorem~\ref{thm:expectation_known}, we create four mutually exclusive and exhaustive cases with the difference from the former proof being: in this setting the arm set is $\mathcal{K}^2$ (set of all possible pairs of arms) which is of size $|^{\mathcal{K}}C_2|$. To be able to reuse the proof for the Theorem~\ref{thm:expectation_known}, we rely on the idea of compound arms. We must replace notion of $\Delta_i$ corresponding to the arm $i$ by the analogous notions of the regret gap, $\Delta_{(i,j)}$ for the arms $(i,j)$. Similarly the sets, $\mathcal{K}_1$ and $\mathcal{K}_2$ would need to be appropriately redefined and would contain $\mathrm{O}(K^2)$ elements. Specifically, if $\mathcal{K}^2$ be the set of all compound arms (all pair-wise combinations from $\mathcal{K}$) then: $\mathcal{K}^2_1 = \{ (i,j)\in \mathcal{K}^2 \vert \Delta_{(i,j)} > \lambda \}$, $\mathcal{K}^2_2 = \{ (i,j)\in \mathcal{K}^2 \vert \Delta_{(i,j)} >0 \}$, and $\Delta_{(i,j)} = \frac{1}{2}(\mu_{(1)}^* + \mu_{(2)}^* - \mu_{i} - \mu_{j})$.
\subsection{ASSUMPTIONS ON THE SUPPORT OF THE DISTRIBUTIONS: $\xi^D$ and $\xi^Z$}\label{subsec:alpha_beta_assumption}
Recall from Section~\ref{sec:problem_definition} that the wear-in and the wear-out effects manifest through distributions $\xi^D$ and $\xi^Z$ supported on $\{0,...,a\}$ and $\{b,...,N\}$ respectively. Following assumptions intuitively follow:
\begin{itemize}
\item $a < N$: This implies that the actions utilize the whole of relevant history duration of $N$ just to get worn-in. Otherwise, there would be problem instances when no reward is accrued at all.
\item $b < N$: We do not allow problem instances when wear-out is weak/non-existent. As $b \geq N$ implies that there would be problem instances in which, even if the arm was played through all the $N$ past rounds, the arm does not get worn out.
\item $a < b$ : Thus, we disallow instances where the arms get worn-out before it could be worn-in.
\end{itemize}
To analyse combined impact of the wear-in and the wear-out effects, in Section~\ref{sec:wiwo}, we made an additional assumption that $a < \nicefrac{N}{2}$. This might seem to be a strong assumption but it is practical. To see why this assumption is required consider a contradictory case: let $a > \nicefrac{N}{2}$, then we there can be instance of the distribution $\xi_j^D$ ( say $D_{t,j}$ are constant equal to $\nicefrac{N}{2}+1$) for which only meaningful arm playing strategy is to play a single for all instance in a window $N$. This is because the number of rounds required to wear-in is more than half of the history window size and hence in a window size of $N$ only one arm could be worn-in. As $b <N$ ( that is wear-out is significant in the observation window) then arm has to switch for the next window of size $N$. Thus, any algorithm in this regime must play an arm continuously for $N$ rounds wherein only $N-D-(N-Z)$ rounds accrue rewards and the algorithm must switch arms after every $N$ instances.
\subsection{OPTIMAL BENCHMARKS}\label{subsec:optimal benchmark}
\begin{lemma}\label{lemma:wi_benchmark}
Under only wear-in effect (i.e., $Z_{t,j} > N\,\forall t$ and arms $j$), the optimal constant benchmark policy ($\pi$) in the Eq (\ref{eq:regret_general}) is the one which plays the arm with the highest reward for all rounds $T$.
\end{lemma}
\begin{proof}
There is loss of rewards due to wear-in for each arm any policy may chose to play. Hence there is no gain in playing multiple arms if none of them can beat the optimal arm. Therefore, the optimal constant policy in expectation is to play the best arm for all rounds in $T$.
\end{proof}
The above benchmark policy is sub-optimal for the setting of the Section~\ref{sec:wiwo}. Since playing the same arm continuously would make it \emph{worn-out} quickly leading to no reward being accrued. In Section~\ref{sec:wiwo}, we introduced a benchmark policy based on the notion of the \emph{compound arms}. In the following lemma we propose another benchmark policy for this setting and prove it is optimal.
\begin{lemma}\label{lemma:wiwo_benchmark}
Under both wear-in and wear-out effects with $0<a< \nicefrac{N}{2}<b < N$, the benchmark policy of playing top two arms, $i^*=\max_{j\,\in\,\mathcal{K}}\mu_j$ and $i^{**}=\max_{j\,\in\,\mathcal{K},\,j\neq i^*}\mu_j$ alternatively is optimal. Alternatively, playing any other arm or playing in any other order cannot improve have better expected cumulative reward.
\end{lemma}
\begin{proof}
Since, just playing one arm continuously is sub-optimal, thus any non-trivial strategy would involve playing more than 1 arm. Also, as $a<\nicefrac{N}{2}$, then atmost 2 arms can be \emph{worn-in}, therefore any strategy involving more than 2 arms would lead to additional loss of rewards due to wearing-in. Finally since $b> \nicefrac{N}{2}$, therefore if the arms are being played alternatively then under no realizations of the priming effect distributions $\xi^Z$ and $\xi^D$ would the arms get \emph{worn-out}. Hence the optimal policy should play with exactly two arms.
\end{proof}
\subsection{EXPERIMENTS}\label{sec:experiments}
We run four experiments. In the first two experiments we compared our proposed algorithms \textsc{WI-UCB}{} and \textsc{WI/WO-UCB}{} with other baseline algorithms namely \textit{AAE}~\cite{even2006action}, \textit{MOSS}~\cite{audibert2009minimax} and \textit{UCB}~\cite{auer2002finite}. In the third, we investigate the arm switching behavior of \textsc{UCB1}{}, showing how it can be suboptimal for certain input instances. In the fourth, we show how \textsc{WI-UCB}{} performs as a function of the wear-in effect. In all these experiments, the cumulative regret curves plotted were averaged over 30 Monte Carlo runs. The bandit instances were generated randomly, unless otherwise noted.
We use a set up of $K=20$ arms and the reward distributions to be Bernoulli with randomly chosen means. $T=5000$. In the first experiment we consider only the wear-in setting with $N=10$ and $\xi^D\,\sim$ Uniform[0,N]. Figure~\ref{fig:8} shows that the standard stochastic multi armed bandit algorithms incur linear regret, whereas, \textsc{WI-UCB}{} has a sub-linear regret. In the second experiment we consider both wear-in and wear-out effects with $N=10$, $\xi^D\,\sim$ Uniform[0,3] and $\xi^Z\,\sim$ Uniform[6,10]. Under this general priming setting with both the wear-in and the wear-out effects, only \textsc{WI/WO-UCB}{} has sub-linear regret (see Figure~\ref{fig:15}).
\begin{figure}
\centering
\includegraphics[width=.9\columnwidth]{wi_all_algo2.png}
\caption{Performance (cumulative regret) of \textsc{WI-UCB}{} compared to other algorithms.}
\label{fig:8}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=.9\columnwidth]{wiwo_all_algo2.png}
\caption{Performance (cumulative regret) of \textsc{WI/WO-UCB}{} compared to other algorithms.}
\label{fig:15}
\end{figure}
We use a simple setup of $K = 30$ arms and set the reward distributions to be the Bernoulli with randomly chosen biases. The horizon length $T = 5000$. We then run \textsc{UCB1} under three different configurations. In the first, the bandit instance is run as is and there is an unique optimal arm. In the second, the number of optimal arms is increased to $3$, and in the third the number of optimal arms is increased to $7$. Figure~\ref{fig:7} shows the unnormalized counts of \emph{same arm plays} in the past $15$ plays. This was computed by checking how many times the current arm was also played in the past $15$ rounds. As expected, as the number of optimal arms increases, the counts of same arm plays decreases rapidly. This indicates that \textsc{UCB1}{} and other related algorithms may perform poorly in settings with priming.
\begin{figure}
\centering
\includegraphics[width=.9\columnwidth]{history_count_plotv2.png}
\caption{Plot of unnormalized counts (y-axis) versus number of same arm plays in the past $15$ rounds by \textsc{UCB1}{} for three different settings.}
\label{fig:7}
\end{figure}
Now, we show the performance of \textsc{WI-UCB}{} (Algorithm ~\ref{alg:expectation_known}) for varying levels of wear-in effect. The number of arms in this experiment is fixed at $10$. Wear-in effect is stochastic and is simulated using the absolute value normal distribution with means = $\{2,6,10,14\}$ and the standard deviation being proportional to the arm indices. The history window, $N = 20$ and the time horizon is $10000$. From Figure~\ref{fig:4}, we can observe that as the cumulative regret increases as $\mathbb{E}[D]$ is increased.
\begin{figure}
\centering
\includegraphics[width=.9\columnwidth]{memory_plotsv2}
\caption{Performance (cumulative regret) of \textsc{WI-UCB}{} as the wear-in parameter is varied.}
\label{fig:4}
\end{figure}
\section{CONCLUSION}\label{sec:conclusion}
We considered the problem of showing recommendations and ads when the user behavior is influenced by priming effect: wear-in, where the user responds positively when shown the same recommendation multiple times in the recent past, and wear-out, where the user response dampens when the same recommendation is shown too frequently in the recent past. Modeling this in a bandit framework, we develop a new algorithm and show how its performance in terms of regret can be bounded.
An open problem is to develop a theory for general temporal dependencies of current rewards on past actions and rewards. Any departure from the functional form as described in the Section~\ref{sec:problem_definition} may need additional analytical tools beyond what was presented here. One possible way is to model the temporal dependency structures via Markov decision processes. Regret analysis may not be straightforward in such settings or may produce loose bounds.
Further, the current regret bounds contain additive terms for priming, and it might be possible to achieve a better dependence on the priming effect parameters while having a worse dependence on other parameters. In this regard, characterizing the benchmarks thoroughly and finding tight lower bounds under the current model is a potential starting point. Extensions to adversarial behavior models, inclusion of contexts, handling non-stationarity, and most importantly, developing regret minimizing algorithms when multiple user behavioral effects including priming occur simultaneously, are some additional future research directions.
\section{INTRODUCTION}\label{sec:introduction}
In advertising applications and recommendation systems, there has been a large body of work that models consumer behavior~\citep{hawkins2009consumer,solomon2014consumer}. One such effect that is relatively well studied is the priming/repetition effect. Under the priming effect, an advertiser's payoff (for instance, click through rate) depends on how frequently they have presented the same ad to the same audience in the recent past. If the advertiser presents a specific ad sporadically, then the click through rate is much lower, even if this ad is the best among a collection of ads. Priming can be broken down into two sub-effiects; \emph{wear-in} and \emph{wear-out}~\citep{pechmann1988advertising}. Wear-in effect leads to a user not responding to an ad if it has not been shown enough number of times in the recent past. Whereas, the wear-out effect leads to a user not responding (or becoming insensitive) to an ad if it has been shown too many times in the recent past. Different ads may need different levels of repetition to obtain payoffs, and all the relevant parameters that model the priming effect may not be known a priori to the advertiser~\citep{ma2016user}.
This phenomenon also translates to recommendations, such as for products and movies, where repeated display of item(s) can cause positive reinforcement to build over time, culminating in a conversion. It can also lead to fatigue and therefore no conversion. Since these conversion events depend on the past recommendations, they interfere with learning the true underlying (mean) payoffs and demands of different recommendations.
Motivated by the above discussion, we define a new class of problems, which we call \emph{bandit learning under priming effect}, to address the agent's need for repetitions. The amount by which the agent (say an ad platform or a recommendation system) needs to replay an arm depends on the degree of priming effect (see Section~\ref{sec:problem_definition} for a formal treatment). In essence, the platform's current rewards are functions of its previous actions. A diagram illustrating this is shown in Figure~\ref{fig:1}. Our model and solution is one among a growing literature~\cite{kveton2015cascading,den2017dynamic,shah2018bandit,wang2019thompson} that focuses on combining empirically validated behavioral models with sequential decision making
\begin{figure}
\centering
\includegraphics[width=.5\textwidth]{Impaired_Learning.png}
\caption{Bandit learning under priming effect.}
\end{figure}\label{fig:1}
While our setting can be addressed using Markov Decision Processes/reinforcement learning (RL) techniques, we choose to use the framework of multi-armed bandits (MAB) for their simplicity, analytical tractability and relatively tighter regret guarantees. The MAB problem, which is a special case of the RL problem, captures exploration-exploitation trade-off in certain sequential decision making settings.
In a stochastic MAB set-up, reward distributions are associated with each arm of the set of arms $\mathcal{K}$. When the algorithm plays an arm, it immediately receives a reward with which it can learn, and also suffers a regret, which is the difference between the obtained reward versus the reward that it could have obtained, had it played the best arm in hindsight.
In the presence of priming effect, popular MAB algorithms such as \textsc{UCB1}~\citep{auer2002finite}, \textsc{SE}~\citep{even2006action}, \textsc{MOSS}{}~\citep{audibert2009minimax} or Thompson Sampling~\citep{chapelle2011empirical} can be ineffective because they cannot directly control the number of times an arm is played in any given time window. For problem instances with non-unique optimal arms, the aforementioned algorithms may in fact switch between these very frequently (see Appendix~\ref{sec:experiments}), potentially causing linear regret. Even when the mean rewards are not close, initial exploration will yield no rewards due to wear-in effects, hampering learning and hence, subsequent exploitation. To address these issues, we develop \textsc{WI-UCB} and \textsc{WI/WO-UCB}{}, which expand on the phase-based algorithmic template~\citep{auer2010ucb} to learn in the presence of priming effect.
The consequence of priming effect considered here is closely related to the recent works in corruption~\citep{lykouris2018stochastic} and delay~\citep{pike2018bandits} in the reward accrual process. Unlike these settings, priming effect is \textit{endogenous}, and correlates past actions with the current reward. As an unifying view, in all three works one can assume that there is a intermediate function that allows an MAB algorithm to accrue some transformation of the current and past rewards instead of just the current reward. In our case, we accrue rewards that are modulated by the stochastic sequence of actions that our algorithm took previously, which makes learning more challenging as rewards are now policy dependent.
For instance, \cite{lykouris2018stochastic} consider settings with arbitrary exogenous corruptions of rewards, and propose a randomized algorithm that achieves smooth degradation as the corruption level increases. Unlike their setting, priming effect is \textit{endogenous}, and correlates past actions with the current reward.
While the amount of corruption due to priming in our setting would be O($N K\log T$) ($N$ is a instance dependent parameter in our setting, $K$ is the number of arms, and $T$ is the horizon length) if our algorithm is used, we cannot reuse their analytical techniques because of endogeneity.
Impact of delayed rewards on learning has been well-studied recently ~\citep{joulani2013online,perchet2016batched,cesa2018nonstochastic}. In particular, ~\cite{joulani2013online} provide a recipe to use any regular MAB algorithm in this setting and show that delay causes an additive regret penalty. In~\citep{cesa2018nonstochastic} for adversarial bandits and in~\citep{pike2018bandits} for stochastic bandits, the authors provide regret guarantees for a much weaker setting where rewards can get mixed up and may partially accrue over time. That is, components of rewards due to multiple previous actions may appear collectively at some future point. In contrast to the delay effect, which is affecting the future accrual of rewards, the priming/repetition effect can be viewed as being caused by the trajectory of past actions. As a result, we obtain very different regret bounds.
There has been recent parallel work on rotting bandits~\citep{levine2017rotting,seznec2019rotting}, which can be thought of as capturing the wear-out effect via a sequence of reward random variables with decreasing means. While it does not capture the wear-in effect, the dependence of the reward means on the number of times the ad/arm is played is accounted from the start of the horizon rather than an immediate preceding window, which is critical in our applications. In a closely related subsequent work~\citep{pike2019recovering}, the authors make the mean reward of each arm an unknown function of the time since its last play. While this is an interesting structure, it does not again capture repetition effects (wear-in and wear-out) studied here, and the work relies on a very different modeling setup (using Gaussian processes) to obtain regret bounds.
Some prior works have studied bandit settings under rich temporal user behavior models. For instance, \cite{shah2018bandit} study a temporal behavioral effect rooted in microeconomic theory, namely self-reinforcement. In addition to delays and corruptions influencing rewards, works such as ~\citep{xu2018reinforcement} and~\citep{gamarnik2018delay} also consider the impact of reward accrual in the presence of limited memory, which affects learning and regret. Finally, bandits with switching costs~\cite{banks1994switching,dekel2014bandits} consider penalties for switching arms too often. As we will discuss soon, our algorithms are also candidate solutions to this problem setting by virtue of switching arms rarely. This is because priming effect imposes a hard constraint on switching arms too frequently and too infrequently, which is approximately equivalent to having large switching costs.
\noindent\textbf{Our Results and Techniques:} Owing to the nature of the priming effect, algorithms necessarily have to ensure that the arms still under consideration are played frequently, perhaps in batches. Phase based algorithms form a natural algorithmic template for such a mechanism. This family of algorithms date back to ~\citep{agrawal1988asymptotically}, who considered arm switching costs. Our algorithms, \textsc{WI-UCB}{} and \textsc{WI/WO-UCB}, follow this design pattern, wherein the focus is to eliminate arms between stages (for instance, in \textsc{WI-UCB}{} each arm is played consecutively for multiple rounds between stages). In particular, both \textsc{WI-UCB}{} (wear-in effect setting) and \textsc{WI/WO-UCB}{} (wear-in and wear-out effect setting) are based on algorithms such as \textsc{UCB-Revisited}{}~\citep{auer2010ucb} and \textsc{UCB2}{}~\citep{auer2002finite}, and work under the setting when just the expected priming effect parameters are known. We also introduce a key new idea of \emph{compound-arms} in \textsc{WI/WO-UCB}, which lets us retain the algorithmic structure described above as well as the corresponding analytical machinery to obtain regret bounds.
In our analysis, we design martingales on the sequence of the cumulative sums of the accrued reward deviations from their means. Following the techniques of~\citep{pike2018bandits} and~\citep{auer2010ucb}, we use foundational tools, such as the Bernstein inequality for martingales and the Azuma-Hoeffding inequality based Doob's optimal stopping theorem (see Sections~\ref{sec:wear_in} and \ref{sec:wiwo}), to bound the priming effect under a judicious choice of phase lengths, and guarantee fast convergence of the reward estimates with high probability. Our analysis deviates from these previous works in the following ways: (a) our reward random variables are functions of the past history and \textit{policy} dependent, (b) the use of a phase-based strategy is only possible due to the notion of compound-arms (novel to this work and different from the dueling bandit literature~\citep{yue2012k}), and (c) their regret analysis is not directly applicable to our setting.
The key technical challenge in our setting is due to the opposing wear-in and wear-out effects: while wear-in requires frequent repetition to learn, wear-out hampers learning if arms are played too frequently. Assume that an algorithm can accrue a reward for pulling arm $j$ at time $t$ if it has been tried at least $D_{t,j}$ and at most $Z_{t,j}$ times in the past $N$ rounds, where $D_{t,j}$ and $Z_{t,j}$ are unobserved random variables with means $\mathbb{E}[D_j]$ and $\mathbb{E}[Z_j]$, and $N$ is a known instance-specific fixed positive integer. Then, the regret upper bounds of our algorithms, shown in Table~\ref{tab:introresults}, depend \emph{sublinearly} and \emph{additively} on the priming effect parameters (for simplicity assume $\mathbb{E}[D_j] = \mathbb{E}[D]$ for all $j$). To our knowledge, this is the first work that takes into account both wear-in and wear-out effects for advertising and recommendation systems in an online learning scenario.
\begin{table}
\centering
\resizebox{\columnwidth}{!}{
\begin{tabular}{ |c||c|}
\hline
Algorithm & Bound \\
\hline
Lower bound~\citep{lai1985asymptotically} & $\mathrm{O}(\sqrt{KT})$\\
\textsc{UCB1}~\citep{auer2002finite} & $\mathrm{O}(\sqrt{KT\log T })$ \\
\textsc{MOSS}~\citep{audibert2009minimax} & $\mathrm{O}(\sqrt{KT})$\\
\textsc{WI-UCB}{ }[\textit{this work}, no priming] & $\mathrm{O}(\sqrt{KT\log T })$ \\
\textsc{WI-UCB}{ }[\textit{this work}, wear-in only] & $ \mathrm{O}\left(\sqrt{KT\log T} + K\sqrt{\log^2 T \mathbb{E}[D]}\right)$\\
\textsc{WI/WO-UCB}{ }[\textit{this work}, wear-in \& wear-out] & $\mathrm{O}\left(K\sqrt{T\log T} + K^2\sqrt{\log^2 T N\mathbb{E}[D]}\right)$\\
\hline
\end{tabular}\label{tab:results}
}
\caption{Results summary.}
\label{tab:introresults}
\end{table}
\section{PROBLEM DEFINITION}\label{sec:problem_definition}
There are $K > 1$ arms in the set $\mathcal{K}$ available to the platform (agent/learner), each corresponding to an ad/recommendation. An arm is played by the platform in each of the $T>1$ rounds of interaction with the user (environment).
\noindent{\textbf{Priming Effect:}} Each arm $j \in \mathcal{K}$ is associated with a reward distribution $\xi_j$, which has support in $[0,1]$. The mean reward for arm $j$ is $\mu_j$. $\mu^*$ is the maximum of all $\mu_j$ and corresponds to the arm $j^*$. Let $N\,\in\,\mathbb{N}$ denote the number of historical rounds, and let $\xi_j^D$ and $\xi_j^Z$ for each $j \in \mathcal{K}$, with supports in $\{0,...,a\}$ and $\{b,...,N\}$ respectively, parameterize the priming effect (wear-in and wear-out). In particular, the distributions $\xi_j^D$ and $\xi_j^Z$ (where $0\leq a<b\leq N$ are fixed non-negative integers) are associated with the wear-in and wear-out effects respectively, and characterize the stochastic user who is unknown to the platform a priori. At each round $t$ of interaction between the platform and the stochastic user, the following happens:
\begin{itemize}
\item The platform selects an arm (e.g., shows an ad) denoted by $J_t$ (say, $J_t=j$).
\item The user/environment generates a sample $R_{t,j}\,\sim\,\xi_j$, as well as samples from the wear-in and wear-out distributions: $D_{t,j}\,\sim\,\xi_j^D$ and $Z_{t,j}\,\sim\,\xi_j^Z$.
\item The user returns the following derived sample reward $X_{t,j}$ via a click/purchase given by:
\begin{equation}\label{eq:feedback_general}
X_{t,j} = R_{t,j} \mathbb{I}\left[ Z_{t,j} \geq f_{t,j}(N) \geq D_{t,j} \right],
\end{equation}
which is the only quantity observed by the platform. Here $\mathbb{I}[\,]$ is the indicator function, and $f_{t,j}(N)$ is a \emph{history function} that encapsulates contribution of prior user interactions, i.e., events and outcomes of rounds $\{t-N,...t-1\}$ that capture the priming effect.
\end{itemize}
We assume that the value of $f_{t,j}(N)$ only depends on the number of times arm $j$ was played by the platform in the past $N$ rounds and is independent of the other choices made, and is non-decreasing in $N$. We also assume that each play of arm $j$ in the relevant history contributes equally to the value of $f_{t,j}(N)$. With these assumptions, we focus our analysis on the following reward accrual model:
\begin{equation}\label{eq:feedback}
\resizebox{.9\columnwidth}{!}
{
$X_{t,j} = R_{t,j} \mathbb{I}\left[ Z_{t,j} \geq\left(\sum_{k= \max(t-N,0)} ^t \mathbb{I}[ J_k = j]\right) \geq D_{t,j} \right].$
}
\end{equation}
\noindent\textit{Justifying the reward model:} The reward model, as a product of $R_{t,j}$ and an indicator function of the history of arms played along with the wear-in/wear-out effects, is quite practical while being amenable to analysis, and can be viewed as a stepping stone for more realistic models in the future. In fact, when $\xi_j$ are Bernoulli, as is the case with clicks and checkouts in applications such as e-commerce, there is very little loss in expressivity when using an indicator function as a multiplier versus any other continuous unimodal function of the history. One could imagine applications where a more sensitive function of history\footnote{It is possible to extend our analysis to case when different intervals of the past $N$ rounds have a weighted contribution in the definition of $f_{t,j}(N)$.} (for example, $X_{t,j}$ gradually increases due to wear-in and then decreases due to wear-out) could be relevant, where such an indicator function (even as an approximation) may be oversimplified. In these cases, a different algorithmic approach and analysis will be needed, potentially relying on RL techniques (we are already capturing the impact of past actions on the current reward without relying on RL methodology here). Further note that the priming effect in Equation \ref{eq:feedback_general} entails the necessity of having non-overlapping support for the distributions $\{\xi_j^D\}$ and $\{\xi_j^D\}$ (i.e., $a<b$). If not, there will be problem instances where no rewards would be accrued for any policy.
\noindent\textit{The stochastic nature of user behavior:} We are in a (non-contextual) stochastic bandit setting. As noted earlier, every time an arm $j$ is presented, the user generates the three random variables (and using N and $f_{t,j}(N)$) responds by giving back a transformed reward $X_{t,j}$. In doing so, they are agnostic to the strategy of the platform. Making the priming effect stochastic in each round captures a natural time-varying behavior of users on such advertising/recommendation platforms. It is important to distinguish between our setup and a setting where $D_{t,j}$ and $Z_{t,j}$ do not depend on time. The latter is a restricted stochastic setting where the priming effect is static across time ($R_{t,j}$ is the only randomness in the environment) and can result in potentially simpler learning strategies (such as playing each arm for $O(\mathbb{E}[D_j])$ rounds, and then estimating $\mu_i$s), although it is unclear if there will be any improvements in terms of the regret guarantees over ours.
\noindent\textit{Knowledge of $\mathbb{E}[D_j]$:} We assume that the platform knows the first moment $\mathbb{E}[D_j]$, as well as $N$ and $T$. This may seem limiting at first, but we argue that it is fairly benign: the platform needs no additional distributional knowledge to be able to achieve sub-linear regret matching the performance of stochastic MABs (modulo additive factors, see Section~\ref{sec:wear_in}). Further knowing (just) this first moment is readily possible for a platform using observational data or from previous interactions with its users.
For simplicity of exposition, we assume that $\xi^D_j = \xi^D$ and $\xi^Z_j = \xi^Z$ (and thus work with $\mathbb{E}[D]$ and $\mathbb{E}[Z]$ moving forward).
\begin{figure}
\centering
\includegraphics[width=.45\textwidth]{model_description2.png}
\caption{Model Illustration: At any round (x axis), if the cumulative number of times a chosen arm was played is in the white region, then a reward is obtained by the platform. If it is lower (wear-in, blue region) or higher (wear-out, green region), the platform does not get the reward. Each pair of blue and green bars is for the arm that was pulled in that time step.}
\end{figure}\label{fig:model}
\noindent{\textbf{Goal:}} We want to design an online algorithm for the platform that plays a sequence of arms $\{J_t\}$ such that the expected (pseudo-)regret $R_T$ of the algorithm when compared to a benchmark policy is sublinear in the time horizon $T$:
\begin{equation}\label{eq:regret_general}
\begin{split}
R_T &= \mathbb{E}\left[\sum_{t=1}^T X_{t,\pi_t} \right] - \mathbb{E}\left[ \sum_{t=1}^{T} X_{t,J_t}\right],
\end{split}
\end{equation}
where $\pi = (\pi_1,...,\pi_T)$ lies in the class of benchmark policies $\Pi_B$, and each $\pi_t$ is a function that maps the history of arms played in the past and their rewards to arm choice in round $t$. Note that the rewards for the benchmark are censored according to that policy and not the policy the learner is playing.
In the standard bandit setting, it is standard to assume that $\pi$ is a set of constant functions (i.e., $\pi_1=...=\pi_T$) that are determined by the mean rewards $\mu_j$ for $j\,\in\,\mathcal{K}$. Similarly, in our setting, we consider benchmark policies that are designed to take into account the priming effect. Intuitively, the benchmark policy of playing the best arm in hindsight may not be suitable anymore, especially when both wear-in and wear-out effects are present (Section \ref{sec:wiwo}). We defer further discussion on the choice of the benchmark policy to Sections~\ref{sec:wear_in} and~\ref{sec:wiwo}.
\begin{comment}
Concerning Problem definition
\begin{itemize}
\item Introduce equation 1 with a general function and generalize it to an indicator based function
\item Talk about steps which take place and every round t. Emphasize on the fact that only expected is required. $\zeta^D$ and $\zeta^Z$ could be any stationary distribution with finite mean. In general, they are different for each arm.
\item Improve figure 2 so that there are no white lines.
\item talk about regret considered is wrt to optimal policy and the optimal policy is model dependent.
\item talk about importance of phased based strategy why important : AAE, UCB2 and UCB-R, of which UCB-R is the most malleable controls the order of arm in which they are played, give example (essentially the last 2 paragraphs of section old 3).
\item emphasize that the goal is to minimize regret and that does not require learning E[D]. Rather given E[D] what is the value of phase length which gives sublinear regret. One way is to find that phase length for which nice things about phased based strategies could be proved.
\end{itemize}
We also assume that the learner has the knowledge of $N$ and the time horizon $T$ beforehand.
fixed random variables:
if the RVs realize at the beginning of time, then we might as well assume they are fixed constants.
Z_t,j can also be independent of time. i.e, fixed unknowns or realize once per arm. In these cases, the problem becomes simpler and one could focus on estimating three parameters per each arm. simple strategy: try each arm for E[D] times as a burn-in state is insufficient when these are random variables that realize every time period. Further, the simple strategy gives a regret that linearly depends on E[D] whereas we have a better dependence (sqrt{E[D]}).
[motivate why the start and end points have to be stochastic from a practical point of view].
These random variables being dependent on time captures the \emph{stochastic behavior} of the same user well. For instance, in one round,the user is happy to click if D and Z are benign etc.
[incorrect] D and Z are dependent on the sensitivities of an user arriving on the platform (the learner whois trying to minimize the regret) towards a particular action/advertisement (arm). Just likerewards are random, in general, D and Z are best modeled as random variables. This isbecause some users might have short wear-in period, while others might have larger, andsimilarly for wear-out. Randomness bakes in this variation. They are sampled at each time indexby the environment/user. Also, at any time t if the sample of D > sample of Z, then no reward willbe observed. In general, D and Z can be arm (index j) dependent. However, for simplicity ofexposition we drop this dependence. Our results still hold for this case, as the same analysisextends to each arm and we would have n_{m,j} instead of n_m in the algorithm.
user model
single sochastic user setting. Every time an arm is presented, The user generates the three RVs (and also using N and the previous ads seen) responds to the arm by giving back an X_t. They do not need to to know the strategy of the platform.
oversimplification
the priming effect model is \emph{oversimplified} but captures the stochastic behavior of a single user
the effects are gradual and non-discrete
buys us tractability
In future work, general priming effect models in full RL setting would be highly compelling.
we are already captuing past actions impact on present reward without full RL, but this specific to the priming effect model.
known E[D]
No distributional information is being leveraged or learned here. Multimodality of the dists is not considered. We are not learning the acceptable region,
Even if D and Z are multi-modal, the analysis holds as it is geared towards finding appropriatephase length n_m based only on the first moments, which gives good regret guarantees. We donot “learn the acceptable region”. Making additional assumptions on D and Z’s distributions maygive way to a different algorithm and bounds.
the objective is not to learn E[D] for the rest of the paper. If E[D] is unknown, then curruption models may be relevant
no reward outside the acceptable region
Could have a base rate of rewards outside this region.
platform model
the platform does not observe D or Z, it simply observes X. We sidestep inferring whether X was in the interval or not
\end{comment}
\section{WEAR-IN EFFECT}\label{sec:wear_in}
We start with those instances where wear-out effect is non-existent, i.e., $Z_{t,j} = N$ for all $t$ and $j \in \mathcal{K}$. This simplifies the treatment, while allowing for the same analytical tools to be extended to the general setting in Section~\ref{sec:wiwo}.
Methods such as UCB1~\citep{auer2002finite}, MOSS~\citep{audibert2009minimax} or Thompson Sampling~\citep{chapelle2011empirical} will not succeed in our problem setting for any reasonable values of $\mathbb{E}[D]$ (and $\mathbb{E}[Z]$). For instance, the UCB1 algorithm, which is based on the optimism principle, adaptively decreases its optimism over mean rewards such that arms are easily distinguishable from each other. But while doing this, it does not allow for a direct control on how arms switch between rounds. Even when only wear-in effect is present, is impact is minimal only when $\mathbb{E}[D] << N$, which is quite limiting. To control the switching between arms, one could employ algorithms such as \textsc{SE}~\citep{even2006action},
\textsc{UCB-Revisited}~\citep{auer2010ucb} or \textsc{UCB2}~\citep{auer2002finite}, which either play arms in a predictable round robin fashion or play the same arm consecutively. And this is precisely what we attempt to do here.
Our proposed strategy, \textsc{WI-UCB}{} (Algorithm~\ref{alg:expectation_known}) plays arms in phases (indexed by $m$). These phases are distinct and non-overlapping. The algorithm maintains a set of active arms, and in every phase, each arm from the active set is played repeatedly and consecutively. The algorithm also maintains a confidence bound $\tilde{\Delta}_m$ on the estimates of mean rewards in each phase. At the end of each phase, arms are eliminated based on confidence gaps computed using this arm-agnostic bound. We refer to the number of rounds that each active arm is played in a given phase as the \emph{incremental phase length}. The total length of the phase is the sum of such individual incremental phase lengths. In particular, a sequence of (cumulative) phase lengths $\{n_m| m=0,1,2,...\}$ determine the number of rounds each active arm has been played by phase $m$ (thus, the incremental phase length is $n_m - n_{m-1}$). And we denote the set of active arms in phase $m$ using the set $\mathcal{K}_m$.
Intuitively, longer incremental phase lengths help in negating the wear-in effect, whereas shorter incremental phase lengths help in negating the wear-out effect. These opposing consequences necessitate a different algorithm design when both the priming effect are present (see Section~\ref{sec:wiwo}). In the current setting, switching the arms too often reduces the rewards accumulated due to the wear-in effect and impedes the algorithm from exploring as well as exploiting what it has learned so far. Thus, a careful design of phase length is necessary, which we discuss below. In Algorithm~\ref{alg:expectation_known}, we use $T_j(m)$ to refer to the collection of times when the $j^{th}$ arm is played up to phase $m$. Further, the estimated mean reward for arm $j$ at the end of phase $m$ is denoted by $\overline{X}_{m,j}$.
\begin{algorithm}[t]
\SetAlgoLined
\textbf{Input:} A set of arms $\mathcal{K}$, time horizon $T$, and phase length parameters $\{n_m| m=0,1,2,...\}$.\\
\textbf{Initialization:} Phase index $m=1$, $\mathcal{K}_m = \mathcal{K}$, $\tilde{\Delta}_{1}$ = 1, $T_j(0) = \phi\;\; \forall j \in \mathcal{K}$, where $\phi$ is the empty set, and time index $t= 1$.\\
\While{$t\leq T$ }{
\If{ $|\mathcal{K}_m|>1$}{
\emph{Play Arms:}\\
\For{ each active arm $j$ in $\mathcal{K}_m$}{
Set $T_j(m) = T_j(m-1)$.\\
Play $j$ for $n_m-n_{m-1}$ consecutive rounds and update $T_j(m)$.\\
\emph{Accrue rewards according to the environment model Equation (\ref{eq:feedback}).}\\
}
\emph{Eliminate Sub-optimal Arms:}\\
\For{each active arm $j$ in $\mathcal{K}_m$}{
$\quad \overline{X}_{m,j} = \frac{1}{|T_j(m)|}\sum_{s\in T_j(m)} X_{s,j}$.
}
Construct $\mathcal{K}_{m+1}$ by eliminating arms $j$ in $\mathcal{K}_m$ for which:\\
$\overline{X}_{m,j} + \tilde{\Delta}_m/2 < \max_{j' \in \mathcal{K}_m} \overline{X}_{m,j'} - \tilde{\Delta}_m/2$.\\
\emph{Update the Confidence Bound:}\\
Set $\tilde{\Delta}_{m+1} = \frac{\tilde{\Delta}_m}{2}$.\\
Increment phase index $m$ by $1$ and update $t$ based on $\{n_m\}$ values up to the current phase.
}
Play the single arm in $\mathcal{K}_m$ and update $t$.\\
}
\caption{\textsc{WI-UCB}}\label{alg:expectation_known}
\end{algorithm}
\noindent{\textbf{Benchmark Policy:}} To bound the regret defined in Equation~(\ref{eq:regret_general}) for this algorithm, we consider the benchmark policy $\pi$ to be one which plays the arm with the highest mean reward at all rounds. It can be shown that such a policy is optimal even with the wear-in effect (See Appendix \ref{subsec:optimal benchmark} for a proof).
There are two key aspects to bounding regret with respect to the aforementioned benchmark for Algorithm~\ref{alg:expectation_known}: (a) identifying an appropriate $n_m$ that depends on the wear-in effect parameter $\mathbb{E}[D]$, and (b) showing that this $n_m$ swiftly eliminates the sub-optimal arms. With these two steps addressed, we can get a regret guarantee such as below.
\begin{theorem}\label{thm:expectation_known} For any $\lambda >0$, the expected (pseudo-)regret of \textsc{WI-UCB}{} (Algorithm~\ref{alg:expectation_known}) is bounded as:
\begin{flalign}
R_T \leq & \underset{i\in\mathcal{K}_1}{\sum}\left(\Delta_i + \frac{64 \log(T)}{\Delta_i} + \frac{64\log(T)}{3}\right.&\nonumber\\
&\left.\quad\quad\quad+ 32\sqrt{\log\left(\frac{4}{\Delta_i}\right)\mathbb{E}[D]\log(T)} \right)&\nonumber\\
&\quad +\underset{i\in \mathcal{K}_1}{\sum} \frac{4\Delta_i}{T} + \underset{i\in \mathcal{K}_2}{\sum} \frac{32}{T} + \underset{\{i \in \mathcal{K}_2: \Delta_i < \lambda\}}{\max} \Delta_i T,&\nonumber
\end{flalign}
where $\mathcal{K}_1 = \{ i\in \mathcal{K} \vert \Delta_i > \lambda \}$, $\mathcal{K}_2 = \{ i\in \mathcal{K} \vert \Delta_i >0 \}$, and $\Delta_{i} = \mu^* - \mu_{i}$.
\end{theorem}
Given an appropriate choice for phase lengths $n_m$, the proof of the above theorem follows that in~\cite{auer2010ucb}, where a similar phased-based algorithm was suggested for the vanilla stochastic MAB. Following Theorem~\ref{thm:expectation_known}, we can also obtain a corresponding instance independent bound, as shown in the following corollary.
\begin{corollary}\label{coroll:expectation_known}
For all $T \geq K$, choosing $\lambda=\sqrt{\frac{K\log(T)}{T}}$ and using $\log(1/\tilde{\Delta}_m) \leq \log(T)$, the expected (pseudo-)regret of \textsc{WI-UCB}{} is $\mathrm{O}\left(\sqrt{KT\log T} + K\sqrt{\log^2 T \mathbb{E}[D]}\right)$.
\end{corollary}
A key point to note is that the \textit{wear-in} effect parameter $\mathbb{E}[D]$ appears as an additive penalty. The leading term, $\sqrt{KT\log T}$ is only a logarithmic factor away from the best known bounds for the vanilla stochastic MAB~\citep{audibert2009minimax}. Thus our regret upper bound behaves gracefully with the level of the wear-in priming effect.
To define suitable phase length parameters $\{n_m\}$, we design martingales on the sequences of bias adjusted rewards sequences and eventually bound the growth of such martingales under our model. Appendix~\ref{subsec:prelim} contains an overview of martingales, stopping times, and key concentration bounds required for the analysis. For a detailed discussion on martingale properties, one can refer~\cite{mitzenmacher2005probability}.
For any active arm $j$ and phase $m$, let $S_{m,j}$ denote the time in this phase when the algorithm starts playing this arm. Similarly let $U_{m,j}$ denote the time in this phase when the algorithm stops playing this arm. Also, let $T_t(j,N)$ be a random variable that denotes the number of times that the arm $j$ was played in the rounds $\{t-N,...t-1\}$. We define a filtration $\{\mathcal{G}_s\}_{s=0}^{\infty}$ by setting $\{\mathcal{G}_0\} = \{\Omega, \phi \}$ with $\Omega$ suitably defined, and letting $\{\mathcal{G}_t\}$ to be the $\sigma$-algebra over $(X_{1}....X_t,J_1....J_t,D_{1,J_1}....D_{t,J_t},R_{1,J_1}...R_{t,J_t})$. In Lemma~\ref{stocnm} below, we give a constructive proof for the choice of $n_m$ such that the estimated mean reward for an arm $j$ gets closer to its true mean at the end of phase, and we can use this property to eliminate sub-optimal arms quickly.
\begin{lemma}\label{stocnm}
There exists a positive $n_m$ for which the estimate $\overline{X}_{m,j}$ calculated by Algorithm~\ref{alg:expectation_known} for an active arm $j$ ($j\in \mathcal{K}_m$) and phase $m$, satisfies $\overline{X}_{m,j} - \mu_j \leq \tilde{\Delta}_m/2$ with probability at least $1-\frac{2}{T^2}$.
\end{lemma}
Below, we show how unlikely it is to grossly overestimate the mean value, assuming $j$ is a sub-optimal arm.
\noindent{\textbf{Outline of the proof:}} We build on the observation that the cumulative sums of bias adjusted rewards ($\overline{X}_{m,j} - \mu_j$) can be decomposed into a couple of martingale sequences (see the first two terms in Equation~\ref{eq:71}). As the algorithm progresses, we show via Lemmas~\ref{term1} and~\ref{term2} that the growth of both these martingales can be bounded with high probability in terms of the phase length $n_m$ and the wear-in effect parameter $\mathbb{E}[D]$. To start, it follows that for each arm $j$:
\begin{gather}
\sum_{i=1}^m\sum_{t=S_{i,j}}^{U_{i,j}} ( X_{t,j} - \mu_j ) \leq \sum_{i=1}^m\sum_{t=S_{i,j}}^{U_{i,j}} ( R_{t,J_t} - \mu_j )\nonumber \\- \sum_{i=1}^m\sum_{t=S_{i,j}}^{U_{i,j}} R_{t,J_t}\mathbb{I}\{ T_t(J_t,N) \leq D_{t,J_t}\}.\label{eq:stoc1}
\end{gather}
Since only one arm is played at a time, therefore, $J_t=j$ and $T_t(J_t,N) \leq t-S_{i,j}$ within a phase. Define $A_{i,t} := R_{t,J_t}\mathbb{I}\{ t \leq S_{i,j} + d_{t,J_t}\}$ and $M_t := \sum_{i=0}^m A_{i,t}\mathbb{I}\{ S_{i,j}\leq t \leq U_{i,j} \}$ . We can upper bound Equation \ref{eq:stoc1} and write it in terms of $M_t$ as:
\begin{gather}
\sum_{i=1}^m\sum_{t=S_{i,j}}^{U_{i,j}} ( X_t - \mu_j ) \leq \sum_{i=1}^m\sum_{t=S_{i,j}}^{U_{i,j}} ( R_{t,j} - \mu_j )\nonumber\\ +\sum_{t=1}^{U_{m,j}} (\mathbb{E}[M_t\vert G_{t-1}] - M_t ) -
\sum_{t=1}^{U_{m,j}}\mathbb{E}[M_t\vert G_{t-1}].\label{eq:71}
\end{gather}
Due to the above construction, we are able to succinctly separate the loss/modulation in rewards due to the \textit{wear-in} effect. Next, we bound each term in Equation \ref{eq:71} individually. The first term is the deviations of the un-modulated rewards from their true means, and a reasonable upper bound is desired to get the right dependence on $T$ in the Corollary~\ref{coroll:expectation_known}. Next, the second term captures the impact of the wear-in effect, and can be upper bounded using Lemmas~\ref{term1} and~\ref{term2}. Finally, by taking trivial non-negative upper bound on the last term in Equation~\ref{eq:71} above, and applying a simple union bound, we obtain the following expression for $n_m$ that guarantees the claim made in the statement of Lemma~\ref{stocnm} with probability at least $1-\frac{2}{T^2}$:
\begin{equation}
\label{eq:stocnmval}
\resizebox{.9\columnwidth}{!}
{
$n_m \leq 1+\frac{4 \log(T)}{\tilde{\Delta}^2_m} + \frac{16\log(T)}{3\tilde{\Delta}_m} + \frac{8\sqrt{m\mathbb{E}[D]\log(T)}}{\tilde{\Delta}_m}.$
}
\end{equation}
Below, we now discuss the supporting lemmas needed for Lemma~\ref{stocnm}. First, we start with the second term of Equation~\ref{eq:71}. The following lemma shows that $Y_s = \sum_{t=1}^s (\mathbb{E}[M_t\vert G_{t-1}] - M_t)$ forms a martingale. This fact is a prerequisite for Lemma~\ref{term2}.
\begin{lemma}\label{martingaleproof}
$Y_s := \sum_{t=1}^s (\mathbb{E}[M_t\vert G_{t-1}] - M_t)$ for all $s\geq 1$ with $Y_0=0$ is a martingale with respect to the filtration $\{G_s\}^{\infty}_{s=0}$ with increments $C_s = \mathbb{E}[M_s\vert G_{s-1}] - M_s $ satisfying $\mathbb{E}[C_s\vert G_{s-1}] = 0$ and $C_s \leq 1$ for all $s\geq 1$.
\end{lemma}
The next lemma is used to bound the sum of deviations of the received rewards from their mean values at the end of a phase (the first term in Equation~\ref{eq:71}). In effect, we show that the sum of accrued rewards will be close to their sum of means with high probability. This is a high probability guarantee that reasonably long sequences of rewards can give information about the mean reward parameters of the arms.
\begin{lemma}\label{term1}
With probability at least $1 - \frac{1}{T^2}$, $\sum_{i=1}^m\sum_{t=S_{i,j}}^{U_{m,j}}( R_{t,j} -\mu_j ) \leq \sqrt{n_m \log(T)}.$
\end{lemma}
\noindent{\textbf{Outline of the proof:}}
For an arm $j$ that was played at time $t$, the quantity $R_{t,J_t} -\mu_j$ can be either positive or negative. And we are interested in bounding the maximum cumulative positive growth. One can interpret this bound to be the maximum expected value of a finite $1$-dimensional random walk, where an agent is taking steps at $n_m$ randomly chosen time instances in the given horizon $T$. The cumulative displacements of the agent because of the random walk form a martingale with an appropriately defined filtration. We use a modified version of the Azuma-Hoeffding inequality (see Lemma~\ref{doob} in Appendix~\ref{subsec:prelim}) to upper bound this displacement with high probability.
Next, through the following lemma, we show that the wear-in effect martingale sequence (the second term in Equation~\ref{eq:71} does not have any \textit{sudden jumps} by upper bounding the corresponding quadratic variation process.
\begin{lemma}\label{variation}
For any $t$, let $P_t= \mathbb{E}[M_t\vert G_{t-1}] - M_t$. It follows that: $\sum_{t=1}^{U_{m,j}} \mathbb{E}[P_t^2\vert G_{t-1}] \leq m\mathbb{E}[D].$
\end{lemma}
\noindent{\textbf{Outline of the proof:}} From the definition of $P_t$, it is easy to see that $\sum_{t=1}^{U_{m,j}} \mathbb{E}[P_t^2\vert G_{t-1}] \leq \sum_{t=1}^{U_{m,j}} \mathbb{E}[M^2_t\vert G_{t-1}]$. Recall that $M_t$ denotes the sum of $m$ random variables of which only one is non-negative while others are zero, and this depends on the phase number the time index $t$ belongs to. Intuitively, this contributes the factor $m$ to bound claimed. In a phase $i$, for arm $j$, the reward is lost if $\mathbb{I}\{t < S_{i,j}+D_{t,j}\} = 1$. We are interested in sum of these indicator values when $t$ varies from $1$ to $T$. In expectation, each indicator is given by $\mathbb{P}(t < S_{i,j} + D_{t,j})$, the summation of which can be upper bounded by $\mathbb{E}[D]$.
Finally, we can now bound the second term in Equation~\ref{eq:71}, using the following lemma.
\begin{lemma}\label{term2}
With probability at least $1-\frac{1}{T^2}$, $\sum_{t=1}^{U_{m,j}}(\mathbb{E}[M_t\vert G_{t-1}] - M_t ) \leq \frac{2}{3}\log(T)+ \sqrt{\frac{4\log^2(T)}{9}+4m\mathbb{E}[D]\log(T)}.$
\end{lemma}
\noindent{\textbf{Outline of the proof:}}
It follows from Lemma~\ref{martingaleproof} that $Y_{U_{m,j}}= \sum_{t=1}^{U_{m,j}}(\mathbb{E}[M_t\vert G_{t-1}] - M_t )$ forms a martingale, and represents an upper bound on the missed rewards due the wear-in effect. Next, note that each reward is bounded. Further, we had claimed in Lemma~\ref{variation} that there are no sudden jumps in the growth of the corresponding martingale sequences. Using Lemma~\ref{freedman}(see Appendix~\ref{subsec:prelim} for the statement) implies that $Y_{U_{m,j}}$ is bounded as well, which can then be used to show that the above inequality is true with high probability. Detailed proofs of Lemmas~\ref{stocnm}-\ref{term2} and Theorem~\ref{thm:expectation_known} are provided in Appendix~\ref{subsec:missing_proofs}.
\section{WEAR-IN AND WEAR-OUT EFFECTS}\label{sec:wiwo
The general setting involving both wear-in and wear-out effects is significantly harder to tackle, primarily because of the opposing nature of these two. Qualitatively, wear-in effect necessitates continued exploitation (repetition of actions), while on the other hand, wear-out penalized continued exploitation. In \textsc{WI-UCB}{}, arms are consecutively repeated $n_m-n_{m-1}$ times (see Equation \ref{eq:stocnmval}) in each phase $m$. The amount of repetition quickly supersedes $N$, which leads to zero reward accrual due to the wear-out effect for a majority of the rounds (see Equation~\ref{eq:feedback}). Hence, an appropriate algorithm for the general priming situation should be able to track the number of plays of each arm like \textsc{WI-UCB}{}, potentially in a phased manner, but also also have sufficient \textit{local exploration} to discourage any detrimental wear-out effect.
Recall (from Section \ref{sec:problem_definition}) that the distributions $\xi_j^D$ and $\xi_j^Z$ have supports on $\{0,...,a\}$ and $\{b,...,N\}$, with $N \in \mathbb{N}$ and $0\leq a<b \leq N$ being unknown fixed constants. Clearly, $D_{t} = 0$ or $Z_{t} = N$ would imply there are no loss of rewards due to wear-in or wear-out respectively (dropping the dependence on arm $j$ here for clarity). Additionally, $D_t > \nicefrac{N}{2}$ would make the wear-in effect $\textit{too strong}$ as it necessitates the following: any algorithm will need to repeat the same arm for a majority portion of any contiguous $N$ rounds, and further the algorithm would fail to accrue rewards from other arms that are played in the remaining portion of this set of $N$ rounds. Hence, we assume $a \leq \nicefrac{N}{2} < b$ (refer to Appendix \ref{subsec:alpha_beta_assumption} for a more detailed discussion about this assumption).
The way we tackle both the wear-in and wear-out effects is through a \textit{key observation}: that playing a pair of arms (or more) with equal probability may provide sufficient \textit{local exploration} which could nullify wear-out effect, while ensuring that arms are repeated often enough for sufficient \textit{global exploitation} to also counter wear-in effect simultaneously. This is exactly what we do in the algorithm \textsc{WI/WO-UCB}{} (see Algorithm \ref{alg:expectation_known2}). Similar to the algorithm \textsc{WI-UCB}{} (of Section \ref{sec:wear_in}), \textsc{WI/WO-UCB}{} plays arms in phases. However, instead of repeating the same arm continuously for $n_m-n_{m-1}$ times, the algorithm plays a pair of arms with equal probability for a collective $n_m-n_{m-1}$ times in the $m$-th phase (for some new optimally chosen phase length parameters $\{n_m\}$). Intuitively it is similar to the following hypothetical setting: construct $^{|\mathcal{K}}|C_2$ pairs of arms from the original set $\mathcal{K}$, appropriately calculate the mean rewards for each pair and run an instance of \textsc{WI-UCB}{} with $^{|\mathcal{K}|}C_2$ arms. To be able to reuse the techniques and analysis from Section \ref{sec:wear_in}, we formalize the above idea of arm-pair or \textit{compound arm} next. Notation wise, let $(i,j)$ denote the compound arm constructed by playing the arms $i$ and $j$ with equal probability and $\mathcal{K}^2$ denote the set of all possible pairs composed of arms in $\mathcal{K}$. Clearly $\mu_{(i,j)}=\nicefrac{(\mu_i+\mu_j)}{2}$.
\begin{algorithm}[t]
\SetAlgoLined
\textbf{Input:} Compound arms composed of pairs from $\mathcal{K}$: $\mathcal{K}^2$, time horizon $T$, and phase length parameters $\{n_m| m=0,1,2,...\}$.\\
\textbf{Initialization:} Phase index $m=1$, $\mathcal{K}_m^2 =\mathcal{K}^2$, $\tilde{\Delta}_{1}$ = 1, $T_{(i,j)}(0) = \phi\;\; \forall (i,j) \in \mathcal{K}^2$, where $\phi$ is the empty set, and time index $t= 1$.\\
\While{$t\leq T$ }{
\If{$|\mathcal{K}_m^2|>1$}{
\emph{Play Compound Arms:}\\
\For{ each compound arm $(i,j)$ in $\mathcal{K}_m^2$}{
Set $T_{(i,j)}(m) = T_{(i,j)}(m-1)$.\\
Play either $i$ or $j$ with equal probability for $(n_m-n_{m-1})$ consecutive rounds and update $T_{(i,j)}(m)$.\\
\emph{Accrue rewards according to the environment model Equation \ref{eq:feedback}.}\\
}
\emph{Eliminate Sub-optimal Pairs:}\\
\For{each active pair $(i,j)$ in $\mathcal{K}_m^2$}{
\resizebox{.8\columnwidth}{!}
{
$\quad \overline{X}_{m,(i,j)} = \frac{1}{|T_{(i,j)}(m)|}\sum_{s\in T_{(i,j)}(m)} X_{s,(i,j)}$.
}
}
Construct $\mathcal{K}_{m+1}^2$ by eliminating all pairs $(i,j)$ in $\mathcal{K}_m^2$ for which:\\
\resizebox{.8\columnwidth}{!}
{
$\overline{X}_{m,(i,j)} + \tilde{\Delta}_m/2 < \max_{(i,j)' \in \mathcal{K}_m^2} \overline{X}_{m,(i,j)'} - \tilde{\Delta}_m/2.$
}\\
\emph{Update the Confidence Bound:}\\
Set $\tilde{\Delta}_{m+1} = \frac{\tilde{\Delta}_m}{2}$.\\
Increment phase index $m$ by $1$ and update $t$ based on $\{n_m\}$ values up to the current phase.
}
Play the single compound arm in $\mathcal{K}_m^2$ and update $t$.\\
}
\caption{\textsc{WI/WO-UCB}}\label{alg:expectation_known2}
\end{algorithm}
\noindent{\textbf{Benchmark Policy:}} Again, recall the definition of expected regret from Section \ref{sec:problem_definition} (Equation \ref{eq:regret_general}). Since any benchmark also endures the priming effect, the benchmark policy of Section \ref{sec:wear_in}, which plays the best arm consistently for all rounds is not optimal (in fact, it will have linear regret). So for the setting in this Section, we define $\pi$ to be the policy that knows the mean rewards of all arms and plays the top two arms (in terms of mean rewards, denoted by $\mu_{(1)}^* $ and $ \mu_{(2)}^*$) with equal probability in each round. The policy $\pi$ may not necessarily be optimal, however it provides a natural performance measure to contrast against for cases where a learning algorithm plays \textit{compound arms}. For a more detailed discussion on the above benchmark and the optimal benchmark, see Appendix \ref{subsec:optimal benchmark}.
As in the previous section, we assume the knowledge of the wear-in parameter $\mathbb{E}[D]$. The key design challenge is to calculate the $\{n_m\}$ sequence such that Algorithm \ref{alg:expectation_known2} quickly eliminates sub-optimal \textit{compound arms}, which we do in Lemma \ref{lemma:stocnm_wiwo}. Using this choice for \textsc{WI/WO-UCB}{}, we obtain an expected regret upper bound against the above benchmark as follows.
\begin{theorem}\label{thm:wi_wo} For any $\lambda >0$, the expected (pseudo-)regret of \textsc{WI/WO-UCB}{} is bounded as:
\begin{flalign}
R_T \leq & \underset{i\in\mathcal{K}^2_1}{\sum}\left(\Delta_i + \frac{64 \log(T)}{\Delta_i} + \frac{64\log(T)}{3}\right.&\nonumber\\
&\left.\quad\quad\quad\quad+ 32\sqrt{\log\left(\frac{4}{\Delta_i}\right)N\mathbb{E}[D]\log(T)} \right)&\nonumber\\
&\quad +\underset{i\in \mathcal{K}^2_1}{\sum} \frac{4\Delta_i}{T} + \underset{i\in \mathcal{K}^2_2}{\sum} \frac{32}{T} + \underset{\{i \in \mathcal{K}^2_2: \Delta_i < \lambda\}}{\max} \Delta_i T,&\nonumber
\end{flalign}
where $\mathcal{K}^2_1 = \{ (i,j)\in \mathcal{K}^2 \vert \Delta_{(i,j)} > \lambda \}$, $\mathcal{K}^2_2 = \{ (i,j)\in \mathcal{K}^2 \vert \Delta_{(i,j)} >0 \}$, and $\Delta_{(i,j)} = \frac{1}{2}(\mu_{(1)}^* + \mu_{(2)}^* - \mu_{i} - \mu_{j})$.
\end{theorem}
The proof of Theorem~\ref{thm:wi_wo} follows a similar proof strategy as that of Theorem~\ref{thm:expectation_known}, and has been provided in detail in Appendix \ref{subsec:missing_proofs}. It relies on an appropriate choice for $\{n_m\}$, as given by Equation~\ref{eq:stocnmval_wiwo} (see Appendix~\ref{subsec:missing_proofs}). As before, we can also get an instance independent bound as shown below.
\begin{corollary}\label{coroll:wi_wo}
For all $T \geq K^2$, choosing $\lambda=\sqrt{\frac{K^2\log(T)}{T}}$, using the inequality $\log(1/\tilde{\Delta}_m) \leq \log(T)$, and the observation that both $|\mathcal{K}^2_1|$ and $|\mathcal{K}^2_2| $ are $\mathrm{O}(K^2)$, gives the following upper bound on the expected (pseudo-)regret of \textsc{WI/WO-UCB}{} is $R_T \leq \mathrm{O}\left(K\sqrt{T\log T} + K^2\sqrt{\log^2 T N\mathbb{E}[D]}\right).$
\end{corollary}
When compared to Corollary~\ref{coroll:expectation_known}, we immediately notice the following. The first term has an additional factor of $\sqrt{K}$ and the second term has an additional factor of $K\sqrt{N}$. The increased dependence on $K$ can easily be attributed to the choice of using compound-arms by the algorithm. The dependence on $\sqrt{N}$ comes from the wear-out effect. Because $\mathbb{E}[D]$ can be $O(N)$ itself, overall, one can conclude that the priming effect (wear-in and wear-out) lead to an additive linear term in $N$ (which also parameterizes these effects).
The following lemma provides a recipe to calculate $n_m$ which is an input to Algorithm~\ref{alg:expectation_known2}.
\begin{lemma}\label{lemma:stocnm_wiwo}
There exists a positive $n_m$ for which the estimate $\overline{X}_{m,(i,j)}$ calculated by Algorithm~\ref{alg:expectation_known2} for an active pair $(i,j)$ ($(i,j)\in \mathcal{K}^2_m$) in phase $m$ satisfies the following inequality with probability at least $1-\frac{2}{T^2}$:
\begin{equation*}
\overline{X}_{m,(i,j)} - \mu_{(i,j)} \leq \tilde{\Delta}_m/2,
\end{equation*}
where $\mu_{(i,j)} = \frac{1}{2}(\mu_i + \mu_j)$.
\end{lemma}
\noindent{\textbf{Outline of the proof:}} The phases are defined with respect to the compound arms and the reward $R_{t,J_t}$ is due to arm played by Algorithm~\ref{alg:expectation_known2} at time $t$. We continue to build up on the same observation as used in the proof of Lemma~\ref{stocnm}: the cumulative sums of bias adjusted rewards ($\overline{X}_{m,(i,j)} - \mu_{(i,j)}$) can be decomposed into three sequences, where the additional third is due to the loss of rewards due to wear-out effect see Appendix \ref{subsec:missing_proofs} for details. The value of $n_m$ for which the lemma holds is given by:
\begin{equation}\label{eq:stocnmval_wiwo}
\resizebox{.85\columnwidth}{!}
{
$n_m \leq 1+\frac{4 \log(T)}{\tilde{\Delta}^2_m} + \frac{16\log(T)}{3\tilde{\Delta}_m} + \frac{8\sqrt{Nm\mathbb{E}[D]\log(T)}}{\tilde{\Delta}_m}.$
}
\end{equation} | {'timestamp': '2020-06-19T02:11:19', 'yymm': '2006', 'arxiv_id': '2006.10356', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10356'} | arxiv |
\section{Approximation algorithms for weighted hierarchical clustering}
\label{app:weighted_algo}
In this section we first prove that running constant-approximation algorithms on fairlets gives good solutions for value objective, and then give constant approximation algorithms for both revenue and value in weighted hierarchical clustering problem, as is mentioned in Corollary~\ref{cor:revenue} and~\ref{cor:main}. That is, a weighted version of average-linkage, for both weighted revenue and value objective, and weighted ($\epsilon/n$)-locally densest cut algorithm, which works for weighted value objective. Both proofs are easily adapted from previous proofs in~\cite{cohenaddad} and~\cite{moseleywang}.
\subsection{Running constant-approximation algorithms on fairlets}
In this section, we prove Theorem~\ref{thm:reduction}, which says if we run any $\beta$-approximation algorithm for the upper bound on weighted value on the fairlet decomposition, we get a fair tree with minimal loss in approximation ratio. For the remainder of this section, fix any hierarchical clustering algorithm $A$ that is guaranteed on any \emph{weighted} input $(V,d,m)$ to construct a hierarchical clustering with objective value at least $\beta m(V) d(V)$ for the value objective on a weighted input. Recall that we extended the value objective to a weighted variant in the Preliminaries Section and $m(V) = \sum_{u\in V} m_u$. Our aim is to show that we can combine $A$ with the fairlet decomposition $\mathcal{Y}$ introduced in the prior section to get a fair hierarchical clustering that is a $\beta(1-\epsilon)$-approximation for the value objective, if $\phi(\mathcal{Y}) \leq \epsilon d(V)$.
In the following definition, we transform the point set to a new set of points that are weighted. We will analyze $A$ on this new set of points. We then show how we can relate this to the objective value of the optimal tree on the original set of points.
\begin{definition}
Let $\mathcal{Y} = \{Y_1, Y_2, \ldots \}$ be the fairlet decomposition for $V$ that is produced by the local search algorithm. Define $V(\mathcal{Y})$ as follows:
\begin{itemize}
\item Each set $Y_i$ has a corresponding point $a_i$ in $V(\mathcal{Y})$.
\item The weight $m_i$ of $a_i$ is set to be $|Y_i|$.
\item For each partitions $Y_i, Y_j$, where $i \neq j$ and $Y_i,Y_j \in \mathcal{Y}$, $d(a_i,a_j)= d(Y_i,Y_j)$.
\end{itemize}
\end{definition}
We begin by observing the objective value that $A$ receives on the instance $V(\mathcal{Y})$ is large compared to the weights in the original instance.
\begin{theorem}\label{claim:rev}
On the instance $V(\mathcal{Y})$ the algorithm $A$ has a total weighted objective of $\beta(1-\epsilon) \cdot n d(V)$.
\end{theorem}
\begin{proof}
Notice that $m(V(\mathcal{Y})) = |V| = n$. Consider the total sum of all the distances in $V(\mathcal{Y})$. This is $\sum_{a_i,a_j \in V(\mathcal{Y})} d(a_i, a_j) = \sum_{Y_i,Y_j \in \mathcal{Y}} d(Y_i,Y_j) = d(V) - \phi(\mathcal{Y})$. The upper bound on the optimal solution is $(\sum_{Y_i \in \mathcal{Y}}m_i) (d(V) - \phi(\mathcal{Y})= n (d(V) - \phi(\mathcal{Y}))$. Since $\phi(\mathcal{Y}) \leq \epsilon d(V)$, this upper bound is at least $ (1-\epsilon)n d(V)$. Theorem \ref{thm:reduction} follows from the fact that the algorithm $A$ archives a weighted revenue at least a $\beta$ factor of the total weighted distances.
\end{proof}
\subsection{Weighted hierarchical clustering: Constant-factor approximation}
For weighted hierarchical clustering with positive integral weights, we define the weighted average-linkage algorithm for input $(V, d, m)$ and $(V, s, m)$. Define the \emph{average distance} to be $\mathit{Avg}(A,B) = \frac{d(A,B)}{m(A) m(B)}$ for dissimilarity-based input, and $\mathit{Avg}(A,B) = \frac{s(A,B)}{m(A) m(B)}$ for similarity-based input. In each iteration, weighted average-linkage seeks to merge the clusters which minimizes this value, if dissimilarity-based, and maximizes this value, if similarity-based.
\begin{lem} \label{lem:avlk_approx_weighted}
Weighted average-linkage is a $\frac{2}{3} (resp., \frac{1}{3})$ approximation for the upper bound on weighted value (resp., revenue) objective with positive, integral weights.
\end{lem}
\begin{proof}
We prove it for weighted value first. This is directly implied by the fact that average-linkage is $\frac{2}{3}$ approximation for unweighted value objective, as is proved in \cite{cohenaddad}. We have already seen in the last subsection that a unweighted input $V$ can be converted into weighted input $V(\mathcal{Y})$. Vice versa, we can construct a weighted input $(V, d, m)$ into unweighted input with same upper bound for value objective.
In weighted hierarchical clustering we treat each point $p$ with integral weights as $m(p)$ duplicates of points with distance $0$ among themselves, let's call this set $S(p)$. For two weighted points $(p, m(p))$ and $(q, m(q))$, if $i \in S(p), j \in S(q)$, let $d(i,j) = \frac{d(p,q)}{m(p) m(q)}$. This \emph{unweighted} instance, composed of many duplicates, has the same upper bound as the weighted instance. Notice that running average-linkage on the unweighted instance will always choose to put all the duplicates $S(p)$ together first for each $p$, and then do hierarchical clustering on top of the duplicates. Thus running average-linkage on the unweighted input gives a valid hierarchical clustering tree for weighted input. Since unweighted value upper bound equals weighted value upper bound, the approximation ratio is the same.
Now we prove it for weighted revenue. In \cite{moseleywang}, average-linkage being $\frac{1}{3}$ approximation for unweighted revenue is proved by the following. Given any clustering $\mathcal{C}$, if average-linkage chooses to merge $A$ and $B$ in $\mathcal{C}$, we define a local revenue for this merge:
$$\text{merge-rev}(A,B) = \sum_{C \in \mathcal{C} \setminus \{A,B\}} |C||A||B| \mathit{Avg}(A,B).$$
And correspondingly, a local cost:
\begin{align*}
\text{merge-cost}(A,B) = \sum_{C \in \mathcal{C} \setminus \{A,B\}} (|B||A||C| \mathit{Avg}(A,C)
+ |A||B||C| \mathit{Avg}(B,C)).
\end{align*}
Summing up the local revenue and cost over all merges gives the upper bound. \cite{moseleywang} used the property of average-linkage to prove that at every merge, $\text{merge-cost}(A,B) \leq 2\text{merge-rev}(A,B)$, which guarantees the total revenue, which is the summation of $\text{merge-rev}(A,B)$ over all merges, is at least $\frac{1}{3}$ of the upper bound. For the weighted case, we define
\begin{align*}
\text{merge-rev}(A,B)
= \sum_{C \in \mathcal{C} \setminus \{A,B\}} m(C)m(A)m(B) \mathit{Avg}(A,B).
\end{align*}
And
\begin{align*}
\text{merge-cost}(A,B)
\sum_{C \in \mathcal{C} \setminus \{A,B\}} (m(B)m(A)m(C) \mathit{Avg}(A,C)
+ m(A)m(B)m(C) \mathit{Avg}(B,C)).
\end{align*}
And the rest of the proof works in the same way as in \cite{moseleywang}, proving weighted average-linkage to be $\frac{1}{3}$ for weighted revenue.
\end{proof}
Next we define the weighted $(\epsilon/n)$-locally-densest cut algorithm. The original algorithm, introduced in \cite{cohenaddad}, defines a cut to be $\frac{d(A,B)}{|A||B|}$. It starts with the original set as one cluster, at every step, it seeks the partition of the current set that locally maximizes this value, and thus constructing a tree from top to bottom. For the weighted input $(V, d, m)$, we define the cut to be $\frac{d(A,B)}{m(A)m(B)}$, and let $n = m(V)$. For more description of the algorithm, see Algorithm 4 in Section 6.2 in \cite{cohenaddad}.
\begin{lem} \label{lem:densest_cut_approx_weighted}
Weighted $(\epsilon/n)$-locally-densest cut algorithm is a $\frac{2}{3}-\epsilon$ approximation for weighted value objective.
\end{lem}
\begin{proof}
Just as in the average-linkage proof, we convert each weighted point $p$ into a set $S$ of $m(p)$ duplicates of $p$. Notice that the converted unweighted hierarchical clustering input has the same upper bound as the weighted hierarchical clustering input, and the $\epsilon/n$-locally-densest cut algorithm moves all the duplicate sets $S$ around in the unweighted input, instead of single points as in the original algorithm in \cite{cohenaddad}.
Focus on a split of cluster $A \cup B$ into $(A,B)$. Let $S$ be a duplicate set. $\forall S \subseteq A$, where $S$ is a set of duplicates, we must have
$$(1+\frac{\epsilon}{n})\frac{d(A,B)}{|A||B|} \geq \frac{d(A \setminus S, B \cup S)}{(|A| - |S|)(|B| + |S|)}.$$
Pick up a point $q \in S$,
\begin{align*}
& \qquad (1+\frac{\epsilon}{n})d(A,B)|S|(|A|-1)(|B|+1)\\
& = (1+\frac{\epsilon}{n})d(A,B)(|A||B|+|A|-|B|-1)|S|\\
& = (1+\frac{\epsilon}{n})d(A,B)(|A||B|+|A||S|-|B||S|-|S|) + (1+\frac{\epsilon}{n})d(A,B)(|A||B|)(|S|-1)\\
& \geq (1+\frac{\epsilon}{n})d(A,B)(|A|-|S|)(|B|+|S|) + d(A,B)|A||B|(|S|-1)\\
& \geq |A||B|d(A \setminus S, B \cup S) + d(A,B)|A||B|(|S|-1)\\
& = |A||B| (d(A,B) + |S|d(q,A) - |S|d(q,B)) + |A||B|(|S|-1)d(A,B)\\
& = |A||B||S|(d(A,B) + d(q,A) - d(q,B)).
\end{align*}
Rearrange the terms and we get the following inequality holds for any point $q \in A$:
$$\left( 1+\frac{\epsilon}{n} \right)\frac{d(A,B)}{|A||B|} \geq \frac{d(A,B) + d(q,A) - d(q,B)}{(|A|-1)(|B|+1)}.$$
The rest of the proof goes exactly the same as the proof in~\cite[Theorem 6.5]{cohenaddad}.
\end{proof}
\section{Proof of Theorem~\ref{thm:fair_moseley_wang}} \label{sec:thmproofsec}
\begin{proof}
Let $\mathcal{A}$ be the $\beta$-approximation algorithm to (\ref{eq:maxrevenue}). For a given instance $G = (V, s)$, let $\mathcal{Y} = \{ Y_1, Y_2, \ldots \}$ be a fairlet decomposition of $V$; let $m_f = \max_{Y \in \mathcal{Y}} |Y|$. Recall that $n = |V|$.
We use $\mathcal{Y}$ to create a weighted instance $G_\mathcal{Y} = (\mathcal{Y}, s_\mathcal{Y}, m_\mathcal{Y})$.
For $Y, Y' \in \mathcal{Y}$, we define
$s(Y, Y') = \sum_{i \in Y, j \in Y'} s(i, j)$ and we define $m_\mathcal{Y}(Y) = |Y|$.
We run $\mathcal{A}$ on $G_\mathcal{Y}$ and let $T_{\mathcal{Y}}$ be the hierarchical clustering obtained by $\mathcal{A}$. To extend this to a tree $T$ on $V$, we simply place all the points in each fairlet as leaves under the corresponding vertex in $T_\mathcal{Y}$.
We argue that $\mathrm{rev}_G(T) \geq \beta\left(1-\frac{2m_f}{n}\right)(n-2)s(V)$.
Since $\mathcal{A}$ obtains a $\beta$-approximation to hierarchical clustering on $G_\mathcal{Y}$, we have $\mathrm{rev}_{G_\mathcal{Y}}\big(T_\mathcal{Y}) \geq \beta \cdot \sum_{Y, Y' \in \mathcal{Y}}s(Y, Y') (n- m(Y) - m(Y')). $
\iffalse
\marina{Actually, is this true? If $A$ is a $c$-apx, that just means $T(V(\mathcal{Y})) \geq c\cdot OPT(\mathcal{Y})$. We don't know that it's a $c$ factor of the upper bound (this often ends up being how we prove algorithms approximate revenue, but it's not simply assured by the fact that $A$ is a $c$-apx for rev). Am I correct? How do we handle this?}
\yuyan{I would say this is not really a problem... In the theorem statement (Theorem \ref{thm:fair_moseley_wang}) what we said is "any const-apx" algorithm for the \textbf{upper bound} on weighted input, the equation we have here is just the math formulation. In the original paper of \cite{moseleywang}, the apx-ratio for average-linkage is proved by directly comparing to the upper bound. Even if some algorithm's apx-ratio is proved by comparing to the OPT, it will still be an const-apx for the upper bound because average-linkage is already proved to be at least $\frac{1}{3}$ of the upper bound, and OPT is at least that, which implies any algorithm that is const-apx for OPT must also be const-apx for the upper bound, up to losing a constant in ratio.}
\marina{Maybe you're already aware of this, but I just wanted to point out that this theorem then can only prove an algorithm has an approximation factor of at most 1/3: In the complete graph with unweighted vertices, $OPT = (1/3 + \epsilon)n w(V)$ [from Dasgupta's paper]. Therefore, no algorithm can be shown to achieve better than $(1/3+\epsilon)n w(V)$, even if it achieves a better overall approximation for revenue. Thus, this theorem cannot prove any approximation better than 1/3. Of course, it's still better and more general than a theorem that directly proves average-linkage extends to the fairness setting, but it can't show anything \textit{better} than average-linkage.\\\\Unfortunately that also means my proof has the same limitation, because it also requires proving the algorithm achieves $\beta n w(V)$, so $\beta$ can be at best 1/3 by the same reasoning.}
\fi
Notice the fact that, for any pair of points $u,v$ in the same fairlet $Y \in \mathcal{Y}$, the revenue they get in the tree $T$ is $(n-m(Y))s(u,v)$. Then using $rev_G(T) = \sum_{Y \in \mathcal{Y}} (n-m(Y)) s(Y) + \mathrm{rev}(T_\mathcal{Y})$,
\begin{align*}
\mathrm{rev}_G(T) &\geq \sum_{Y \in \mathcal{Y}} \beta(n-m(Y))s(Y) + \beta \sum_{Y, Y' \in \mathcal{Y}} s(Y, Y')(n- m(Y) - m(Y')) \\
&\geq \beta(n - 2m_f)\left(\sum_{Y \in \mathcal{Y}}s(Y) + \sum_{Y, Y' \in \mathcal{Y}}s(Y, Y')\right)
\geq \beta\left(1-\frac{2m_f}{n}\right)(n-2)s(V).
\end{align*}
Thus the resulting tree $T$ is a $\beta\left(1-\frac{2m_f}{n}\right)$-approximation of the upper bound.
\end{proof}
\section{Proofs for $(\epsilon/n)$-locally-optimal local search algorithm}
\label{app:algo_is_correct}
In this section, we prove that Algorithm \ref{alg:eps_local_opt_decomp} gives a good fairlet decomposition for the fairlet decomposition objective \ref{obj:fairlet_obj}, and that it has polynomial run time.
\subsection{Proof for a simplified version of Lemma~\ref{lem:algo_is_correct}}
In Subsection~\ref{app:multi_color}, we will prove Lemma~\ref{lem:algo_is_correct}. For now, we will consider a simpler version of Lemma~\ref{lem:algo_is_correct} in the context of \cite{chierichetti}'s disparate impact problem, where we have red and blue points and strive to preserve their ratios in all clusters. Chierichetti et al.~\cite{chierichetti} provided a valid fairlet decomposition in this context, where each fairlet has at most $b$ blue points and $r$ red points. Before going deeper into the analysis, we state the following useful proposition.
\begin{prop}\label{prop:rat}
Let $r_t = |\mathit{red}(V)|$ be the total number of red points and $b_t=|\mathit{blue}(V)|$ the number of blue points. We have that, $\max \{\frac{r}{r_t}, \frac{b}{b_t}\}
\leq \frac{2(b+r)}{n}$.
\end{prop}
\begin{proof}
Recall that $\mathit{balance}(V) = \frac{b_t}{r_t} \geq \frac{b}{r}$, and wlog $b_t \leq r_t$. Since the fractions are positive and $\frac{b_t}{r_t} \geq \frac{b}{r}$ we know that $\frac{b_t}{b_t+ r_t} \geq \frac{b}{b+r}$. Since $b_t+r_t=n$ we conclude that $b_t \geq \frac{b}{b+r}n$. Similarly, we conclude that $\frac{r_t}{b_t+ r_t} \leq \frac{r}{b+r}$. Therefore $r_t \leq \frac{r}{b+r}n$.
Thus, $\frac{r}{r_t} \geq \frac{b+r}{n} \geq \frac{b}{b_t}$. However, since $b_t \leq r_t$ and $b_t + r_t = n$, $r_t \geq \frac{1}{2}n$, $\frac{r}{r_t} \leq \frac{2r}{n} \leq \frac{2(b+r)}{n}$.
\end{proof}
Using this, we can define and prove the following lemma, which is a simplified version of Lemma~\ref{lem:algo_is_correct}.
\begin{lem}
\label{lem:algo_is_correct_prop}
The fairlet decomposition $\mathcal{Y}$ computed by Algorithm \ref{alg:eps_local_opt_decomp} has an objective value for (\ref{obj:fairlet_obj}) of at most $(1+\epsilon)\frac{2(b+r)}{n}d(V)$.
\end{lem}
\begin{proof}
Let $Y:V \mapsto \mathcal{Y}$ denote a mapping from a point in $V$ to the fairlet it belongs to. Let $d_R(X)=\sum_{u \in \mathit{red}(X)}d(u,X)$, and $d_B(X)=\sum_{v \in \mathit{blue}(X)}d(v,X)$. Naturally, $d_R(X)+d_B(X)=2d(X)$ for any set $X$. For a fairlet $Y_i \in \mathcal{Y}$, let $r_i$ and $b_i$ denote the number of red and blue points in $Y_i$.
We first bound the total number of intra-fairlet pairs. Let $x_i=|Y_i|$, we know that $0 \leq x_i \leq b+r$ and $\sum_{i}x_i=n$. The number of intra-fairlet pairs is at most $\sum_{i}x_i^2 \leq \sum_{i} (b+r) x_i = (b+r)n$.
The {\bf While} loop can end in two cases: 1) if $\mathcal{Y}$ is $(\epsilon/n)$-locally-optimal; 2) if $\sum_{Y_k \in \mathcal{Y}} d(Y_k) \leq \Delta$. Case 2 immediately implies the lemma, thus we focus on case 1.
By definition of the algorithm, we know that for any pair $u \in Y(u)$ and $v \in Y(v)$ where $u,v$ have the same color and $Y(u) \neq Y(v)$ the swap does not increase objective value by a large amount. (The same trivially holds if the pair are in the same cluster.)
\begin{align*}
\sum_{Y_k} d(Y_k)
& \leq (1+ \frac{\epsilon}{n})(\sum_{Y_k} d(Y_k) - d(u,Y(u))-d(v,Y(v))
+ d(u,Y(v)) +d(v,Y(u)) -2d(u,v))\\
&\leq (1+ \frac{\epsilon}{n})(\sum_{Y_k} d(Y_k) - d(u,Y(u))-d(v,Y(v))
+ d(u,Y(v)) +d(v,Y(u)) ).
\end{align*}
After moving terms and some simplification, we get the following inequality:
\begin{equation} \label{neq:eps_local_swap1}
\begin{split}
& \quad d(u,Y(u))+d(v,Y(v)) \\
& \leq d(u,Y(v)) + d(v,Y(u)) + \quad \frac{\epsilon/n}{1+\epsilon/n}\sum_{Y_k \in \mathcal{Y}}d(Y_k)\\
& \leq d(u,Y(v)) + d(v,Y(u)) + \frac{\epsilon}{n}\sum_{Y_k \in \mathcal{Y}}d(Y_k).
\end{split}
\end{equation}
Then we sum up (\ref{neq:eps_local_swap1}), $d(u,Y(u))+d(v,Y(v)) \leq d(u,Y(v)) + d(v,Y(u)) + \frac{\epsilon}{n}\sum_{Y_k \in \mathcal{Y}}d(Y_k)
$, over every pair of points in $\mathit{red}(V)$ (even if they are in the same partition).
\begin{align*}
&r_t\sum_{Y_i}d_R(Y_i) \leq \Bigg(\sum_{Y_i}r_i d_R(Y_i) \Bigg)
+ \Bigg( \sum_{u \in \mathit{red}(V)} \sum_{Y_i \neq Y(u)}r_i d(u,Y_i)\Bigg) + r_t^2 \frac{\epsilon}{n}\sum_{Y_i}d(Y_i).
\end{align*}
Divide both sides by $r_t$ and use the fact that $r_i \leq r$ for all $Y_i$:
\begin{align}
\sum_{Y_i}d_R(Y_i) \leq \left(\sum_{Y_i}\frac{r}{r_t} d_R(Y_i) \right) + \left( \sum_{u \in \mathit{red}(V)} \sum_{Y_i \neq Y(u)}\frac{r}{r_t} d(u,Y_i)\right) + \frac{r_t\epsilon}{n} \sum_{Y_i}d(Y_i). \label{neq:red_swap_simplified_with_eps1}
\end{align}
For pairs of points in $\mathit{blue}(V)$ we sum (\ref{neq:eps_local_swap1}) to similarly obtain:
\begin{align}
\sum_{Y_i}d_B(Y_i) \leq \left(\sum_{Y_i}\frac{b}{b_t} d_B(Y_i) \right) + \left( \sum_{v \in \mathit{blue}(V)} \sum_{Y_i \neq Y(v)}\frac{b}{b_t} d(v,Y_i)\right) + \frac{b_t\epsilon}{n} \sum_{Y_i}d(Y_i). \label{neq:blue_swap_simplified_with_eps1}
\end{align}
Now we sum up \eqref{neq:red_swap_simplified_with_eps1} and \eqref{neq:blue_swap_simplified_with_eps1}. The LHS becomes:
$$\sum_{Y_i}(d_R(Y_i)+d_B(Y_i))=\sum_{Y_i}\sum_{u \in Y_i}d(u,Y_i)=2\sum_{Y_i}d(Y_i.)$$
For the RHS, the last term in \eqref{neq:red_swap_simplified_with_eps1} and \eqref{neq:blue_swap_simplified_with_eps1} is $\frac{\epsilon(b_t+r_t)}{n} \sum_{Y_i}d(Y_i)= \epsilon \sum_{Y_i}d(Y_i)$.
The other terms give:
\begin{align*}
&\quad \frac{r}{r_t}\sum_{Y_i} d_R(Y_i) + \frac{r}{r_t}\sum_{u \in \mathit{red}(V)}\sum_{Y_i \neq Y(u)}d(u,Y_i)
+ \frac{b}{b_t}\sum_{Y_i}d_B(Y_i) + \frac{b}{b_t}\sum_{v \in \mathit{blue}(V)} \sum_{Y_i \neq Y(v)}d(v,Y_i)\\
&\leq \max\{\frac{r}{r_t},\frac{b}{b_t}\} \Bigg\{\sum_{Y_i}\left( d_R(Y_i) + d_B(Y_i)\right)
+ \sum_{u \in V} \sum_{Y_i \neq Y(u)}d(u,Y_i) \Bigg\}\\
&= \max\{\frac{r}{r_t},\frac{b}{b_t}\} \Bigg\{ \sum_{Y_i}\sum_{u \in Y_i}d(u,Y_i)
+ \sum_{Y_i} \sum_{Y_j \neq Y_i} d(Y_i,Y_j) \Bigg\}\\
&=2 \max\{\frac{r}{r_t},\frac{b}{b_t}\}d(V)\\
&\leq \frac{4(b+r)}{n} d(V).
\end{align*}
The last inequality follows from Proposition~\ref{prop:rat}. All together, this proves that
\begin{align*}
2\sum_{Y_k}d(Y_k) \leq \frac{4(b+r)}{n} d(V) + \epsilon\sum_{Y_k} d(Y_k).
\end{align*}
Then, $\frac{\sum_{Y_k}d(Y_k)}{d(V)} \leq \frac{2(b+r)}{n}\cdot \frac{1}{1-\epsilon/2} \leq (1+\epsilon)\frac{2(b+r)}{n}$. The final step follows from the fact that $(1+\epsilon)(1-\epsilon/2)=1+\frac{\epsilon}{2}(1-\epsilon) \geq 1$. This proves the lemma.
\end{proof}
\subsection{Proof for the generalized Lemma \ref{lem:algo_is_correct}}
\label{app:multi_color}
Next, we prove Lemma~\ref{lem:algo_is_correct} for the more generalized definition of fairness, which is $\alpha$-capped fairness.
\begin{proofof}[Lemma~\ref{lem:algo_is_correct}]
The proof follows the same logic as in the two-color case: we first use the $(\epsilon/n)$-local optimality of the solution, and sum up the inequality over all pairs of points with the same color.
Let $Y:V \mapsto \mathcal{Y}$ denote a mapping from a point in $V$ to the fairlet it belongs to. Let $R_i(X)$ be the set of $R_i$ colored points in a set $X$. Let $d_{R_i}(X)=\sum_{u \in R_i(X)}d(u,X)$. Naturally, $\sum_{i}d_{R_i}(x)=2d(X)$ for any set $X$ since the weight for every pair of points is repeated twice.
The {\bf While} loop can end in two cases: 1) if $\mathcal{Y}$ is $(\epsilon/n)$-locally-optimal; 2) if $\sum_{Y_k \in \mathcal{Y}} d(Y_k) \leq \Delta$. Case 2 immediately implies the lemma, thus we focus on case 1.
By definition of the algorithm, we know that for any pair $u \in Y(u)$ and $v \in Y(v)$ where $u,v$ have the same color and $Y(u) \neq Y(v)$ the swap does not increase objective value by a large amount. (The same trivially holds if the pair are in the same cluster.) We get the following inequality as in the two color case:
\begin{equation}
d(u,Y(u))+d(v,Y(v))
\leq d(u,Y(v)) + d(v,Y(u)) + \frac{\epsilon}{n}\sum_{Y_k \in \mathcal{Y}}d(Y_k).
\end{equation}
For any color $R_i$, we sum it over every pair of points in $R_i(V)$ (even if they are in the same partition).
\begin{align*}
n_i\sum_{Y_k}d_{R_i}(Y_k) \leq \Bigg(\sum_{Y_k}r_{ik} d_{R_i}(Y_k) \Bigg)
+ \Bigg( \sum_{u \in R_i(V)} \sum_{Y_k \neq Y(u)}r_{ik} d(u,Y_k)\Bigg) + n_i^2 \frac{\epsilon}{n}\sum_{Y_k}d(Y_k).
\end{align*}
Divide both sides by $n_i$ and we get:
\begin{align}
\sum_{Y_k}d_{R_i}(Y_k) \leq \left(\sum_{Y_k}\frac{r_{ik}}{n_i} d_{R_i}(Y_k) \right) + \left( \sum_{u \in R_i(V)} \sum_{Y_k \neq Y(u)}\frac{r_{ik}}{n_i} d(u,Y_k)\right) + \frac{n_i\epsilon}{n} \sum_{Y_k}d(Y_k).
\end{align}
Now we sum up this inequality over all colors $R_i$. The LHS becomes:
$$\sum_{Y_k} \sum_{i}d_{R_i}(Y_k)=\sum_{Y_k}\sum_{u \in Y_k}d(u,Y_k)=2\sum_{Y_k}d(Y_k).$$
For the RHS, the last term sums up to $ \frac{\epsilon(\sum_{i}n_i)}{n} \sum_{Y_k}d(Y_k)= \epsilon \sum_{Y_k}d(Y_k)$. Using the fact that $\frac{r_{ik}}{n_i} \leq \max_{i,k}\frac{r_{ik}}{n_i}$, the other terms sum up to :
\begin{align*}
&\quad \sum_{i} \sum_{Y_k} \frac{r_{ik}}{n_i}d_{R_i}(Y_k) + \sum_{i} \sum_{u \in R_i(V)}\sum_{Y_k \neq Y(u)} \frac{r_{ik}}{n_i} d(u,Y_k) \\
&\leq \max_{i,k}\frac{r_{ik}}{n_i} \Bigg\{\sum_{Y_k}\sum_{i} d_{R_i}(Y_i) + \sum_{u \in V} \sum_{Y_k \neq Y(u)}d(u,Y_k) \Bigg\}\\
&= \max_{i,k}\frac{r_{ik}}{n_i} \Bigg\{ \sum_{Y_k}\sum_{u \in Y_k}d(u,Y_k) + \sum_{Y_k} \sum_{Y_j \neq Y_k} d(Y_j,Y_k) \Bigg\}\\
&=2 \max_{i,k}\frac{r_{ik}}{n_i} \cdot d(V).
\end{align*}
Therefore, putting LHS and RHS together, we get
\begin{align*}
2\sum_{Y_k}d(Y_k) \leq 2\max_{i,k}\frac{r_{ik}}{n_i} d(V) + \epsilon\sum_{Y_k} d(Y_k).
\end{align*}
Then, $\frac{\sum_{Y_k}d(Y_k)}{d(V)} \leq \max_{i,k}\frac{r_{ik}}{n_i} \cdot \frac{1}{1-\epsilon/2} \leq (1+\epsilon)\cdot \max_{i,k}\frac{r_{ik}}{n_i}$. The final step follows from the fact that $(1+\epsilon)(1-\epsilon/2)=1+\frac{\epsilon}{2}(1-\epsilon) \geq 1$.
\end{proofof}
In the two-color case, the ratio $\max_{i,k}\frac{r_{ik}}{n_i}$ becomes $\max \{\frac{r}{r_t}, \frac{b}{b_t}\}$, which can be further bounded by $\frac{2(b+r)}{n}$ (see Proposition~\ref{prop:rat}). If there exists a caplet decomposition such that $\max_{i,k}\frac{r_{ik}}{n_i} = o(1)$, Lemma \ref{lem:algo_is_correct} implies we can build a fair hierarchical clustering tree with $o(1)$ loss in approximation ratio for value objective.
Assuming for all color class $R_i$, $n_i \rightarrow +\infty$ as $n \rightarrow +\infty$, here we give a possible caplet decomposition for $\alpha = \frac{1}{t}(t <= c)$ with size $O(t)$ for positive integer $t$, thus guaranteeing $\max_{i,k}\frac{r_{ik}}{n_i} = o(1)$ for any $i$.
\begin{lem}\label{lem:fairletpartition}
For any set $P$ of size $p$ that satisfies fairness constraint with $\alpha = 1/t$, there exists a partition of $P$ into sets $(P_1, P_2, \ldots)$ where each $P_i$ satisfies the fairness constraint and $t \leq |P_i| < 2t$.
\end{lem}
\begin{proof}
Let $p = m \times t + r$ with $ 0 \leq r < t$, then the fairness constraints ensures that there are at most $m$ elements of each color. Consider partitioning obtained through the following process: consider an ordering of elements where points of the same color are in consecutive places, assign points to sets $P_1, P_2, \ldots, P_m$ in a round robin fashion. So each set $P_i$ gets at least $t$ elements and at most $t + r < 2t $ elements assigned to it. Since there are at most $m$ elements of each color, each set gets at most one point of any color and hence all sets satisfy the fairness constraint as $1 \leq \frac{1}{t} \cdot |P_i|$.
\end{proof}
\subsection{Proof for the running time of $(\epsilon/n)$-locally-optimal fairlet decomposition algorithm}
\begin{proofof}[Lemma \ref{lem:algo_is_fast1}]
Notice that finding the maximum pairwise distance takes $O(n^2)$ time. Thus, we focus on analyzing the time spent on the {\bf While} loop.
Let $t$ be the total number of swaps. We argue that $t=\tilde{O}(n/\epsilon)$. If $t=0$ the conclusion trivially holds. Otherwise, consider the decomposition $\mathcal{Y}_{t-1}$ before the last swap. Since the {\bf While} loop does not terminate here, $\sum_{Y_k \in \mathcal{Y}_{t-1}}d(Y_k)\geq \Delta = \frac{b+r}{n} d_{max}$. However, at the beginning, we have $\sum_{Y_k \in \mathcal{Y}}d(Y_k) \leq (b+r)n \cdot d_{max}=n^2\Delta \leq n^2 \sum_{Y_k \in \mathcal{Y}_{t-1}}d(Y_k)$. Therefore, it takes at most $\log_{1+\epsilon/n}(n^2)=\tilde{O}(n/\epsilon)$ iterations to finish the {\bf While} loop.
It remains to discuss the running time of each iteration. We argue that there is a way to finish each iteration in $O(n^2)$ time. Before the {\bf While} loop, keep a record of $d(u,Y_i)$ for each point $u$ and each fairlet $Y_i$. This takes $O(n^2)$ time. If we know $d(u,Y_i)$ and the objective value from the last iteration, in the current iteration, it takes $O(1)$ time to calculate the new objective value after each swap $(u,v)$, and there are at most $n^2$ such calculations, before the algorithm either finds a pair to swap, or determines that no such pair is left. After the swap, the update for all the $d(u,Y_i)$ data takes $O(n)$ time. In total, every iteration takes $O(n^2)$ time.
Therefore, Algorithm~\ref{alg:eps_local_opt_decomp} takes $\tilde{O}(n^3/\epsilon)$ time.
\end{proofof}
\section{Hardness of optimal fairlet decomposition}
\label{app:hardness}
Before proving Theorem~\ref{thm:np_hard_constant_approx}, we state that the PARTITION INTO TRIANGLES (PIT) problem is known to belong to the NP-complete class \cite{garey2002computers}, defined as follows. In the definition, we call a clique $k$-clique if it has $k$ nodes. A triangle is a $3$-clique.
\begin{definition}
\emph{PARTITION INTO TRIANGLES\\ (PIT).} Given graph $G=(V,E)$, where $V=3n$, determine if $V$ can be partitioned into $3$-element sets $S_1,S_2, \ldots,S_n$, such that each $S_i$ forms a triangle in $G$.
\end{definition}
The NP-hardness of PIT problem gives us a more general statement.
\begin{definition}
\emph{PARTITION INTO $k$-CLIQUES\\ (PIKC).}
For a fixed number $k$ treated as constant, given graph $G=(V,E)$, where $V=kn$, determine if $V$ can be partitioned into $k$-element sets $S_1,S_2,\ldots,S_n$, such that each $S_i$ forms a $k$-clique in $G$.
\end{definition}
\begin{lem} \label{lem:np_hard_pikc}
For a fixed constant $k \geq 3$, the PIKC problem is NP-hard.
\end{lem}
\begin{proof}
We reduce the PIKC problem from the PIT problem. For any graph $G=(V,E)$ given to the PIT problem where $|V|=3n$, construct another graph $G'=(V',E')$. Let $V'=V \cup C_1 \cup C_2 \cup \cdots \cup C_n$, where all the $C_i$'s are $(k-3)$-cliques, and there is no edge between any two cliques $C_i$ and $C_j$ where $i \neq j$. For any $C_i$, let all points in $C_i$ to be connected to all nodes in $V$.
Now let $G'$ be the input to PIKC problem. We prove that $G$ can be partitioned into triangles if and only if $G'$ can be partitioned into $k$-cliques. If $V$ has a triangle partition $V=\{S_1,\ldots,S_n\}$, then $V'=\{S_1 \cup C_1,\ldots,S_n \cup C_n\}$ is a $k$-clique partition. On the other hand, if $V'$ has a $k$-clique partition $V'=\{S_1',\ldots,S_n'\}$ then $C_1,\ldots,C_n$ must each belong to different $k$-cliques since they are not connected to each other. Without loss of generality we assume $C_i \subseteq S_i$, then $V=\{S_1'\setminus C_1,\ldots,S_n' \setminus C_n\}$ is a triangle partition.
\end{proof}
We are ready to prove the theorem.
\begin{proofof}[Theorem~\ref{thm:np_hard_constant_approx}]
We prove Theorem~\ref{thm:np_hard_constant_approx} by proving that for given $z \geq 4$, if there exists a $c$-approximation polynomial algorithm $\mathcal{A}$ for (\ref{obj:fairlet_obj}), it can be used to solve the PIKC problem where $k=z-1$ for any instance as well. This holds for any finite $c$.
Given any graph $G=(V,E)$ that is input to the PIKC problem, where $|V|=kn=(z-1)n$, let a set $V'$ with distances be constructed in the following way:
\begin{enumerate}
\item $V'=V \cup \{C_1,\ldots,C_n\}$, where each $C_i$ is a singleton.
\item Color the points in $V$ red, and color all the $C_i$'s blue.
\item For a $e=(u,v)$, let $d(u,v)=0$, if it satisfies one of the three conditions: 1) $e \in E$. 2) $u, v \in C_i$ for some $C_i$. 3) one of $u,v$ is in $V$, while the other belong to some $C_i$.
\item All other edges have distance $1$.
\end{enumerate}
Obviously the blue points make up a $\nicefrac{1}{z}$ fraction of the input so each fairlet should have exactly $1$ blue point and $z-1$ red points.
We claim that $G$ has a $k$-clique partition if and only if algorithm $\mathcal{A}$ gives a solution of $0$ for (\ref{obj:fairlet_obj}). The same argument as in the proof of Lemma~\ref{lem:np_hard_pikc} will show that $G$ has a $k$-clique partition if and only if the optimal solution to (\ref{obj:fairlet_obj}) is $0$. This is equal to algorithm $\mathcal{A}$ giving a solution of $0$ since otherwise the approximate is not bounded.
\end{proofof}
\input{cost_appendix}
\section{Additional experimental results for revenue}
We have conducted experiments on the four datasets for revenue as well. The
Table~\ref{emp:ratiorevenue} shows the ratio of fair tree built by using average-linkage on different fairlet decompositions. We run Algorithm \ref{alg:eps_local_opt_decomp} on the subsamples with Euclidean distances. Then we convert distances into similarity scores using transformation $s(i,j) = \frac{1}{1+d(i,j)}$. We test the performance of the initial random fairlet decomposition and final fairlet decomposition found by Algorithm~\ref{alg:eps_local_opt_decomp} for revenue objective using the converted similarity scores.
\begin{table*}[t!]
\centering
\caption{Impact of different fairlet decomposition on ratio over original average-linkage in percentage (mean $\pm$ std. dev).}
\label{emp:ratiorevenue}
\tiny
\begin{tabular}{r|llllllll}
\hline
Samples & 100 & 200 & 400 & 800 & 1600 \\
\hline
\textsc{CensusGender}\xspace, initial & $74.12 \pm 2.52$ & $76.16 \pm 3.42$ & $74.15 \pm 1.44$ & $70.17 \pm 1.01$ & $65.02 \pm 0.79$ \\
final & $92.32 \pm 2.70$ & $95.75 \pm 0.74$ & $95.68 \pm 0.96 $ & $96.61 \pm 0.60 $ & $ 97.45 \pm 0.19 $ \\
\hline
\textsc{CensusRace}\xspace, initial & $65.67 \pm 7.53$ & $65.31 \pm 3.74$ & $61.97 \pm 2.50$ & $59.59 \pm 1.89$ & $56.91 \pm 0.82$ \\
final & $85.38 \pm 1.68$ & $92.98 \pm 1.89$ & $94.99 \pm 0.52$ & $96.86 \pm 0.85$ & $97.24 \pm 0.63$ \\
\hline
\textsc{BankMarriage}\xspace, initial & $75.19 \pm 2.53$ & $73.58 \pm 1.05$ & $74.03 \pm 1.33$ & $73.68 \pm 0.59$ & $72.94 \pm 0.63$ \\
final & $ 93.88 \pm 2.16$ & $96.91 \pm 0.99$ & $96.82 \pm 0.36$ & $97.05 \pm 0.71$ & $97.81 \pm 0.49$ \\
\hline
\textsc{BankAge}\xspace, initial & $77.48 \pm 1.45$ & $78.28 \pm 1.75 $ & $76.40 \pm 1.65$ & $ 75.95 \pm 0.77 $ & $75.33 \pm 0.28$ \\
final & $91.26 \pm 2.66$ & $95.74 \pm 2.17 $ & $96.45 \pm 1.56$ & $ 97.31 \pm 1.94 $ & $97.84 \pm 0.92$ \\
\hline
\end{tabular}
\end{table*}
\section{Additional experimental results for multiple colors}\label{sec:multicolorexp}
We ran experiments with multiple colors and the results are analogous to those in the paper. We tested both Census and Bank datasets, with age as the protected feature. For both datasets we set 4 ranges of age to get 4 colors and used $\alpha=1/3$. We ran the fairlet decomposition in~\cite{ahmadian} and compare the fair hierarchical clustering's performance to that of average-linkage. The age ranges and the number of data points belonging to each color are reported in Table~\ref{table:datasets_multi_colors}. Colors are named $\{1,2,3,4\}$ descending with regard to the number of points of the color. The vanilla average-linkage has been found to be unfair: if we take the layer of clusters in the tree that is only one layer higher than the leaves, there is always one cluster with $\alpha > \frac{1}{3}$ for the definition of $\alpha$-capped fairness, showing the tree to be unfair.
\begin{table*}[ht]
\centering
\caption{Age ranges for all four colors for Census and Bank.} \label{table:datasets_multi_colors}
\tiny
\begin{tabular}{r|llll}
\hline
Dataset & Color 1 & Color 2 & Color 3 & Color 4 \\
\hline
\textsc{CensusMultiColor} & $(26, 38]:9796$ & $(38, 48]: 7131$ & $(48, +\infty): 6822$ & $(0, 26]: 6413$ \\
\textsc{BankMultiColor} & $(30, 38]:14845$ & $(38, 48]: 12148$ & $(48, +\infty): 11188$ & $(0, 30]: 7030$ \\
\hline
\end{tabular}
\end{table*}
As in the main body, in Table~\ref{emp:ratiockmm_multi_color}, we show for each dataset the $\mathrm{ratio}_\mathrm{value}$ both at the time of initialization (Initial) and after using the local search algorithm (Final), where $\mathrm{ratio}_\mathrm{value}$ is the ratio between the performance of the tree built on top of the fairlets and that of the tree directly built by average-linkage.
\begin{table*}[ht]\vspace{-0.2in}
\centering
\caption{Impact of Algorithm~\ref{alg:eps_local_opt_decomp} on $\mathrm{ratio}_{\mathrm{value}}$ in percentage (mean $\pm$ std. dev).}
\label{emp:ratiockmm_multi_color}
\tiny
\begin{tabular}{r|llllllll}
\hline
Samples & 200 & 400 & 800 & 1600 & 3200 & 6400 \\
\hline
\textsc{CensusMultiColor}, initial & $88.55 \pm 0.87$ & $88.74 \pm 0.46$ & $88.45 \pm 0.53$ & $88.68 \pm 0.22$ & $88.56 \pm 0.20$ & $88.46 \pm 0.30$\\
final & $99.01 \pm 0.09$ & $99.41 \pm 0.57$ & $99.87 \pm 0.28$ & $99.80 \pm 0.27$ & $100.00 \pm 0.14$ & $99.88 \pm 0.30$\\
\hline
\textsc{BankMultiColor}, initial & $90.98 \pm 1.17$ & $91.22 \pm 0.84$ & $91.87 \pm 0.32$ & $91.70 \pm 0.30$ & $91.70 \pm 0.18$ & $91.69 \pm 0.14$\\
final & $98.78 \pm 0.22$ & $99.34 \pm 0.32$ & $99.48 \pm 0.16$ & $99.71 \pm 0.16$ & $99.80 \pm 0.08$ & $99.84 \pm 0.05$ \\
\hline
\end{tabular}
\end{table*}
Table~\ref{emp:ratiorevenue_multi_color} shows the performance of trees built by average-linkage based on different fairlets, for Revenue objective. As in the main body, the similarity score between any two points $i,j$ is $s(i,j) = \frac{1}{1+d(i,j)}$. The entries in the table are mean and standard deviation of ratios between the fair tree performance and the vanilla average-linkage tree performance. This ratio was calculated both at time of initialization (Initial) when the fairlets were randomly found, and after Algorithm \ref{alg:eps_local_opt_decomp} terminated (Final).
\begin{table*}[ht]\vspace{-0.2in}
\centering
\caption{Impact of Algorithm~\ref{alg:eps_local_opt_decomp} on revenue, in percentage (mean $\pm$ std. dev).}
\label{emp:ratiorevenue_multi_color}
\tiny
\begin{tabular}{r|llllllll}
\hline
Samples & 200 & 400 & 800 & 1600 & 3200 \\
\hline
\textsc{CensusMultiColor}, initial & $75.76 \pm 2.86$ & $73.60 \pm 1.77$ & $69.77 \pm 0.56$ & $66.02 \pm 0.95$ & $61.94 \pm 0.61$\\
final & $92.68 \pm 0.97$ & $94.66 \pm 1.66$ & $96.40 \pm 0.61$ & $97.09 \pm 0.60$ & $97.43 \pm 0.77$\\
\hline
\textsc{BankMultiColor}, initial & $72.08 \pm 0.98$ & $70.96 \pm 0.69$ & $70.79 \pm 0.72$ & $70.77 \pm 0.49$ & $69.88 \pm 0.53$\\
final & $94.99 \pm 0.79$ & $95.87 \pm 2.07$ & $97.19 \pm 0.81$ & $97.93 \pm 0.59$ & $98.43 \pm 0.14$\\
\hline
\end{tabular}
\end{table*}
Table \ref{emp:runtime_multi_color} shows the run time of Algorithm \ref{alg:eps_local_opt_decomp} with multiple colors.
\begin{table*}[ht]
\centering
\caption{Average running time of Algorithm~\ref{alg:eps_local_opt_decomp} in seconds.}
\label{emp:runtime_multi_color}
\begin{tabular}{r|llllllll}
\hline
Samples & 200 & 400 & 800 & 1600 & 3200 & 6400 \\
\hline
\textsc{CensusMultiColor} & 0.43 & 1.76 & 7.34 & 35.22 & 152.71 & 803.59\\
\hline
\textsc{BankMultiColor} & 0.43 & 1.45 & 6.77 & 29.64 & 127.29 & 586.08 \\
\hline
\end{tabular}
\end{table*}
\iffalse
\begin{table}[h]
\centering
\begin{tabular}{l|ll}
& Census & Bank \\
\hline
Revenue, final (\%) & 96.11 & 99.53 \\
Revenue, random (\%) & 58.75 & 70.44 \\
\hline
Value, initial (\%) & 88.56 & 91.55 \\
Value, final (\%) & 99.99 &99.88 \\
\hline
Runtime(s) & 867 & 1803 \\
\hline
\end{tabular}
\caption{Results for multiple colors.}
\end{table}
\fi
\input{cost_algorithm}
\section*{Broader Impact}
\section{Conclusions}
\vspace{-.1cm}
In this paper we extended the notion of fairness to the classical problem of hierarchical clustering under three different objectives (revenue, value, and cost). Our results show that revenue and value are easy to optimize with fairness; while optimizing cost appears to be more challenging.
Our work raises several questions and research directions. Can the approximations be improved? Can we find better upper and lower bounds for fair cost? Are there other important fairness criteria?
\section{Optimizing cost with fairness}\label{sec:cost}
This section considers the cost objective of~\cite{dasgupta}. Even without our fairness constraint, the difficulty of approximating cost is clear in its approximation hardness and the fact that all known solutions require an LP or SDP solver. We obtain the result in Theorem~\ref{thm:cost}; extending this result to other fairness constraints, improving its bound, or even making the algorithm practical, are open questions.
\begin{theorem}\label{thm:cost}
Consider the two-color case. Given a $\beta$-approximation for cost and a $\gamma_t$-approximation for minimum weighted bisection
\footnote{
The minimum weighted bisection problem is to find a partition of nodes into two equal-sized subsets so that the sum of the weights of the edges crossing the partition is minimized.
}
on input of size $t$, then for parameters $t$ and $\ell$ such that $n\geq t\ell$ and $n> \ell + 108t^2/\ell^2$, there is a fair $O\left(\frac nt + t\ell +\frac{n\ell\gamma_t}{t}+ \frac{nt\gamma_t}{\ell^2}\right)\beta$-approximation for $\mathrm{cost}(T^*_{\mathrm{unfair}})$.
\end{theorem}
With proper parameterization, we achieve an $O\left(n^{5/ 6}\log^{5/4} n \right)$-approximation.
We defer our algorithm description, pseudocode, and proofs to the Supplementary Material. While our algorithm is not simple, it is an important (and non-obvious) step to show the existence of an approximation, which we hope will spur future work in this area.
\section{Pseudocode for the cost objective}\label{sec:costpseudo}
\begin{algorithm}[tb]
\caption{Fair hierarchical clustering for cost objective.}
\label{alg:cost}
\begin{algorithmic}
\STATE {\bfseries Input:} Graph $G $, edge weight $w:E\to\mathbb{R}$, color $c:V\to\{\text{red, blue}\}$, parameters $t$ and $\ell$
\STATE
\STATE \COMMENT{Step (A)}
\STATE $T \gets \textsc{UnfairHC}(G,w)$
\COMMENT{Blackbox unfair clustering that minimizes cost}
\STATE
\STATE \COMMENT{Step (B)}
\STATE Let $\mathcal{C} \gets \emptyset$
\STATE Do a \textsf{BFS} of $T$, placing visited cluster $C$ in $\mathcal{C}$ if $|C|\leq t$, and not proceeding to $C$'s children
\STATE
\STATE \COMMENT{Step (C)}
\STATE $\mathcal{C}_0, C' \gets \emptyset$
\FOR{$C$ {\bfseries in} $\mathcal{C}$}
\STATE $C' \leftarrow C' \cup C$
\IF{$|C'| \geq t$}
\STATE Add $C'$ to $\mathcal{C}_0$
\STATE Let $C' \gets \emptyset$
\ENDIF
\ENDFOR
\STATE If $|C'| > 0$, merge $C'$ into some cluster in $\mathcal{C}_0$
\STATE
\STATE \COMMENT{Step (D)}
\FOR{$C$ {\bfseries in} $\mathcal{C}_0$}
\STATE Let $exc(C) \gets$ majority color in $C$
\STATE Let $ex(C) \gets$ difference between majority and minority colors in $C$
\ENDFOR
\STATE
\STATE \COMMENT{Step (E}
\STATE $H_M \gets$ BuildClusteringGraph$(\mathcal{C}_0, ex, exc)$
\STATE
\STATE \COMMENT{Step (F)}
\STATE $\mathit{fV} \gets$ FixUnmatchedVertices$(\mathcal{C}_0, H_M, ex, exc)$
\STATE
\STATE \COMMENT{Step (G)}
\STATE $\mathcal{C}' \gets$ ConstructClustering$(\mathcal{C}_0, ex , exc, \mathit{fV})$
\RETURN $\mathcal{C}'$
\end{algorithmic}
\end{algorithm}
\begin{algorithm}[tb]
\caption{BuildClusteringGraph $(\mathcal{C}_0, ex, exc)$}
\label{alg:stepe}
\begin{algorithmic}
\STATE $H_M \gets (V_M=\mathcal{C}_0, E_M=\emptyset)$
\STATE Let $C_i \in V_M$ be any vertex
\STATE Let $\ell \gets n^{1/3}\sqrt{\log n}$
\WHILE{$\exists$ an unvisited $C_j\in V_M$ such that $exc(C_j)\neq exc(C_i)$}
\STATE Add $(C_i,C_j)$ to $E_M$
\STATE Swap labels $C_i$ and $C_j$ if $ex(C_j) > ex(C_i)$
\STATE Let $ex(C_i) \leftarrow ex(C_i) - ex(C_j)$
\IF{$ex(C_i) < \ell$ or $|\mathit{component}(C_i)| \geq \ell$}
\STATE Reassign starting point $C_i$ to an unvisited vertex in $V_M$
\ENDIF
\ENDWHILE
\RETURN $H_M$
\end{algorithmic}
\end{algorithm}
\begin{algorithm}[tb]
\caption{FixUnmatchedVertices$(\mathcal{C}_0, H_M, ex, exc)$}
\label{alg:stepf}
\begin{algorithmic}
\STATE Let $\ell \gets n^{1/3}\sqrt{\log n}$
\FOR{$C\in\mathcal{C}_0\setminus V_M$}
\STATE Let $\mathit{fV}(C,\text{red}), \mathit{fV}(C,\text{blue})
\gets m^2/\ell^2$
\ENDFOR
\FOR{$i$ {\bfseries from} $1$ {\bfseries to} $108t^2/\ell^3$}
\FOR{each $k$ component in $H_M$}
\FOR{$p$ {\bfseries in} a \textsf{BFS} of $k$}
\STATE Let $ch \gets$ some child of $p$
\STATE $\mathit{fV}(p, exc(p)) \gets \mathit{fV}(p, exc(p)) + \ell$
\STATE $ex(p) \gets ex(p) - \ell$
\STATE $\mathit{fV}(ch, exc(ch)) \gets \mathit{fV}(ch, exc(ch)) + \ell$
\STATE $ex(ch) \gets ex(ch) - \ell$
\IF{\# matches between $p$ and $ch$ $< \ell$}
\STATE Remove $(p,ch)$ from $E_M$
\COMMENT {This creates a new component}
\ENDIF
\ENDFOR
\ENDFOR
\ENDFOR
\RETURN $\mathit{fV}$
\end{algorithmic}
\end{algorithm}
\iffalse
\begin{algorithm}[tb]
\caption{Break Components}
\label{alg:stepff}
\begin{algorithmic}
\STATE Find some $c$ child of $p$
\IF{$exc(p) == \text{RED}$}
\STATE $freeRVerts(p) += \ell$
\STATE $freeBVerts(c) += \ell$
\ELSE
\STATE $freeRVerts(c) += \ell$
\STATE $freeBVerts(p) += \ell$
\ENDIF
\STATE $ex(p) -= \ell$
\STATE $ex(p) -= \ell$
\IF{Less than $\ell$ matches between $p$ and $c$ remain}
\STATE Remove $(p,c)$ from $E(H_M)$
\STATE For new component $K'$, set $root(K') = c$
\ENDIF
\end{algorithmic}
\end{algorithm}
\fi
\begin{algorithm}[tb]
\caption{ConstructClustering$(\mathcal{C}_0, ex , exc, \mathit{fV})$}
\label{alg:stepg}
\begin{algorithmic}
\STATE Let $\mathcal{C}', R \gets \emptyset$
\FOR{$C$ in $\mathcal{C}_0$}
\FOR{$c$ {\bfseries in} $\{\text{red, blue}\}$}
\STATE Let $f = \mathit{fV}(C, c)$
\STATE Let $C_f = \{v\in C:c(v)=c\}$
\STATE Create the transformed graph $L$ from $C_f$ \COMMENT{Described in the proof of Lemma~\ref{lem:weightloss}}
\STATE $C' \gets \textsc{MinWeightBisection}(L)$ \COMMENT{Blackbox, returns isolated $C_f$ vertices}
\STATE $C \gets C\setminus C'$
\STATE $R \gets R \cup C'$
\STATE $ex(C) \gets ex(C) - |C'|$
\ENDFOR
\ENDFOR
\FOR{$C\in \mathcal{C}_0$}
\STATE Let $S\subset R$ such that $|S| = ex(C)$ with no vertices of color $exc(C)$
\STATE $C = C\cup S$
\STATE $R \gets R \setminus S$
\STATE Add $C$ to $\mathcal{C}'$
\ENDFOR
\RETURN $\mathcal{C}'$
\end{algorithmic}
\end{algorithm}
\section{Pseudocode for the cost objective}
\begin{algorithm}[tb]
\caption{Fair Hierarchical Clustering for Cost}
\label{alg:cost}
\begin{algorithmic}
\STATE {\bfseries Input:} graph $G $, edge weight function $w:E\to\mathbb{R}$, color function $c:V\to\{\text{RED,BLUE}\}$, parameters $t$ and $\ell$
\STATE $T = \textsc{UnfairHC}(G,w)$
\COMMENT{Blackbox unfair clustering, Step (A)}
\STATE Run Algorithms 3-8 \COMMENT{Steps (B)-(G)}
\STATE Return $\mathcal{C}'$
\end{algorithmic}
\end{algorithm}
\begin{algorithm}[tb]
\caption{Get Maximal Clustering, Step (B)}
\label{alg:stepb}
\begin{algorithmic}
\STATE Let $\mathcal{C} = \emptyset$
\FOR{$C$ with $|C|\leq t$ in a \textsf{BFS} of $T$}
\STATE Put $C$ in $\mathcal{C}$
\STATE Do not proceed to $C$'s children
\ENDFOR
\STATE Return $\mathcal{C}$
\end{algorithmic}
\end{algorithm}
\begin{algorithm}[tb]
\caption{Combine Clusters, Step (C)}
\label{alg:stepc}
\begin{algorithmic}
\STATE $\mathcal{C}_0, nextC = \emptyset$
\FOR{$C$ {\bfseries in} $\mathcal{C}$}
\STATE $nextC \leftarrow nextC\cup C$
\IF{$|nextC| \geq t$}
\STATE Add $nextC$ to $\mathcal{C}_0$
\STATE $nextC = \emptyset$
\ENDIF
\ENDFOR
\STATE If applicable, merge the remaining $nextC$ into some element in $\mathcal{C}_0$
\STATE Return $\mathcal{C}_0$
\end{algorithmic}
\end{algorithm}
\begin{algorithm}[tb]
\caption{Find Excess, Step (D)}
\label{alg:stepd}
\begin{algorithmic}
\STATE Init excess function $ex:\mathcal{C}_0\to\mathbb{N}$
\STATE Init excess color function $exc:\mathcal{C}_0 \to\{\text{RED,BLUE}\}$
\FOR{$C$ {\bfseries in} $\mathcal{C}_0$}
\STATE Let $exc(C)$ be the majority color in $C$
\STATE Let $ex(C)$ be the difference between majority and minority colors in $C$
\ENDFOR
\STATE Return $ex, exc$
\end{algorithmic}
\end{algorithm}
\begin{algorithm}[tb]
\caption{Construct Clustering Graph, Step (E)}
\label{alg:stepe}
\begin{algorithmic}
\STATE Init clustering graph $H_M= (V_M=\mathcal{C}_0,E_M)$, let $K_H$ be its components throughout the algorithm
\STATE Let $C_i\in V_M$ be some starting point
\WHILE{$\exists$ an unvisited $C_j\in V_M$ such that $exc(C_j)\neq exc(C_i)$}
\STATE Add $(C_i,C_j)$ to $E_M$
\STATE Swap labels $C_i$ and $C_j$ if $ex(C_j) > ex(C_i)$
\STATE Set $ex(C_i) \leftarrow ex(C_i) - ex(C_j)$
\IF{$ex(C_i) < \ell$ or $|k_{C_i}| >= \ell$}
\STATE Reassign starting point $C_i$ to an unvisited vertex in $V_M$
\ENDIF
\ENDWHILE
\STATE Return $H_M, root$
\end{algorithmic}
\end{algorithm}
\begin{algorithm}[tb]
\caption{Fix Unmatched Vertices, Step (F)}
\label{alg:stepf}
\begin{algorithmic}
\STATE Init $freeVerts: \mathcal{C}_0\times\{\text{RED,BLUE}\}\to \mathbb{N}$
\STATE Let $nSteps = 108t^2/\ell^3$ \COMMENT{derived in Appendix}
\FOR{$C\in\mathcal{C}_0\setminus V_M$}
\STATE Set $freeVerts(C,\text{RED}), freeVerts(C,\text{BLUE}) = m^2/\ell^2$
\ENDFOR
\FOR{$i$ {\bfseries from} $1$ {\bfseries to} $nSteps$}
\FOR{Component $k$ {\bfseries in} $K_H$}
\FOR{$p$ {\bfseries in} a \textsf{BFS} of $k$}
\STATE Let $ch$ be some child of $p$
\STATE Add $\ell$ to $freeVerts(p, exc(p))$, remove $\ell$ from $ex(p)$
\STATE Add $\ell$ to $freeVerts(ch,exc(ch))$, remove $\ell$ from $ex(ch)$
\IF{Less than $\ell$ matches between $p$ and $ch$ remain}
\STATE Remove $(p,ch)$ from $E_M$, creating new component $k'\in K_H$
\ENDIF
\ENDFOR
\ENDFOR
\ENDFOR
\STATE Return $freeVerts$
\end{algorithmic}
\end{algorithm}
\iffalse
\begin{algorithm}[tb]
\caption{Break Components}
\label{alg:stepff}
\begin{algorithmic}
\STATE Find some $c$ child of $p$
\IF{$exc(p) == \text{RED}$}
\STATE $freeRVerts(p) += \ell$
\STATE $freeBVerts(c) += \ell$
\ELSE
\STATE $freeRVerts(c) += \ell$
\STATE $freeBVerts(p) += \ell$
\ENDIF
\STATE $ex(p) -= \ell$
\STATE $ex(p) -= \ell$
\IF{Less than $\ell$ matches between $p$ and $c$ remain}
\STATE Remove $(p,c)$ from $E(H_M)$
\STATE For new component $K'$, set $root(K') = c$
\ENDIF
\end{algorithmic}
\end{algorithm}
\fi
\begin{algorithm}[tb]
\caption{Construct Clustering, Step (G)}
\label{alg:stepg}
\begin{algorithmic}
\STATE Let $\mathcal{C}'=\emptyset$
\STATE Let $removedVerts = \emptyset$
\FOR{$C$ in $\mathcal{C}_0$}
\FOR{$color$ {\bfseries in} $\{\text{RED, BLUE}\}$}
\STATE Let $f = freeVerts(C, color)$
\STATE Let $C_f = \{v\in C:c(v)=color\}$
\STATE Create the transformed graph $L$ \COMMENT{Described in the proof of Lemma~\ref{lem:weightloss}}
\STATE $C' = \textsc{MinWeightBisection}(L)$ \COMMENT{Blackbox, returns isolated $C_f$ vertices}
\STATE $C = C\setminus C'$
\STATE $removedVerts = removedVerts \cup C'$
\STATE $ex(C) -= |C'|$
\ENDFOR
\ENDFOR
\FOR{$C\in \mathcal{C}_0$}
\STATE Let $S\subset removedVerts$ such that $|S| = ex(C)$ with no vertices of color $exc(C)$
\STATE $C = C\cup S$
\STATE $removedVerts = removedVerts \setminus S$
\STATE Add $C$ to $\mathcal{C}'$
\ENDFOR
\STATE Return $\mathcal{C}'$
\end{algorithmic}
\end{algorithm}
\section{Optimizing cost with fairness}\label{sec:cost_appendix}
In this section, we present our fair hierarchical clustering algorithm that approximates
Dasgupta's cost function and satisfies Theorem~\ref{thm:cost}. Most of the proofs can be found in Section~\ref{sec:cost_proofs}. We consider the problem of equal representation, where vertices are red or blue and $\alpha=1/2$. From now on, whenever we use the word ``fair'', we are referring to this fairness constraint. Our algorithm also uses parameters $t$ and $\ell$ such that $n\geq t\ell$ and $t>\ell+108t^2/\ell^2$ for $n=|V|$, and leverages a $\beta$-approximation for cost and $\gamma_t$-approximation for minimum weighted bisection. We will assume these are fixed and use them throughout the section.
We will ultimately show that we can find a fair solution that is a sublinear approximation for the unfair optimum $T^*_{\mathrm{unfair}}$, which is a lower bound of the fair optimum. Our main result is Theorem~\ref{thm:cost}, which is stated in the body of the paper.
The current best approximations described in Theorem~\ref{thm:cost} are $\gamma_t = O(\log^{3/2} n)$ by~\cite{feige} and $\beta = \sqrt{\log n}$ by both~\cite{dasgupta} and~\cite{charikar17}. If we set $t =
\sqrt{n} (\log^{3/4} n)$ and $\ell = n^{1/3} \sqrt{\log n}$, then we get Corollary~\ref{cor:cost_main}.
\begin{cor}\label{cor:cost_main}
Consider the equal representation problem with two colors. There is an $O\left(n^{5/ 6}\log^{5/4} n \right)$-approximate fair clustering under the cost objective.
\end{cor}
The algorithm will be centered around a single clustering, which we call $\mathcal{C}$, that is extracted from an unfair hierarchy. We will then adapt this to become a similar, fair clustering $\mathcal{C}'$. To formalize what $\mathcal{C}'$ must satisfy to be sufficiently ``similar'' to $\mathcal{C}$, we introduce the notion of a $\mathcal{C}$-good clustering. Note that this is not an intuitive set of properties, it is simply what $\mathcal{C}'$ must satisfy in order
\begin{definition}[Good clustering]
\label{def:good}
Fix a clustering $\mathcal{C}$ whose cluster sizes are at most $t$. A fair clustering $\mathcal{C}'$ is $\mathcal{C}$-\emph{good} if it satisfies
the following two properties:
\begin{enumerate}[topsep=0pt,itemsep=0pt,partopsep=0pt,parsep=0pt]
\item For any cluster $C\in \mathcal{C}$, there is a cluster $C'\in \mathcal{C}'$ such that all but (at most) an $O(\ell\gamma_t/t + t\gamma_t/\ell^2)$-fraction of the weight of edges in $C$ is also in $C'$.
\item Any $C'\in\mathcal{C}'$ is not too much bigger, so $|C'| \leq 6t\ell$.
\end{enumerate}
\end{definition}
The hierarchy will consist of a $\mathcal{C}$-good (for a specifically chosen $\mathcal{C}$) clustering $\mathcal{C}'$ as its only nontrivial layer.
\begin{lem}\label{lem:finalcluster}
Let $T$ be a $\beta$-approximation for cost and $\mathcal{C}$ be a maximal clustering in $T$ under the condition that all cluster sizes are at most $t$. Then, a fair two-tiered hierarchy $T'$ whose first level consists of a $\mathcal{C}$-good clustering achieves an $O\left(\frac{n}{t} + t\ell + \frac{n\ell\gamma_t}{t} + \frac{nt\gamma_t}{\ell^2}\right)\beta$-approximation for cost.
\end{lem}
\begin{proof}
Since $T$ is a $\beta$-approximation, we know that:
\[\mathrm{cost}(T) \leq \beta\mathrm{cost}(T^*_{\mathrm{unfair}})\]
We will then utilize a scheme to account for the cost contributed by each edge relative to their cost in $T$ in the hopes of extending it to $T^*_{\mathrm{unfair}}$. There are three different types of edges:
\begin{enumerate}[topsep=0pt,itemsep=0pt,partopsep=0pt,parsep=0pt]
\item An edge $e$ that is merged into a cluster of size $t$ or greater in $T$, thus contributing $t \cdot s(e)$ to the cost. At worst, this edge is merged in the top cluster in $T'$ to contribute $n \cdot s(e)$. Thus, the factor increase in the cost contributed by $e$ is $O(n/t)$. Then since the total contribution of all such edges in $T$ is at most $\mathrm{cost}(T)$, the total contribution of all such edges in $T'$ is at most $O(n/t) \cdot \mathrm{cost}(T)$.
\item An edge $e$ that started in some cluster $C\in\mathcal{C}$ that does not remain in the corresponding cluster $C'$. We are given that the total weight removed from any such $C$ is an $O(\ell\gamma_t/t + t\gamma_t/\ell^2)$-fraction of the weight contained in $C$. If we sum across the weight in all clusters in $\mathcal{C}$, that is at most $\mathrm{cost}(T)$. So the total amount of weight moved is at most $O(\ell\gamma_t/t + t\gamma_t/\ell^2) \cdot \mathrm{cost}(T)$. These edges contributed at least $2s(e)$ in $T$ as the smallest possible cluster size is two. In $T'$, these may have been merged at the top of the cluster, for a maximum cost contribution of $n \cdot s(e)$. Therefore, the total cost across all such edges is increased by at most a factor of $n/2$, which gives a total cost of at most $O(n\ell\gamma_t/t + nt\gamma_t/\ell^2) \cdot \mathrm{cost}(T)$.
\item An edge $e$ that starts in some cluster $C\in\mathcal{C}$ and remains in the corresponding $C'\in\mathcal{C}'$. Similarly, this must have contributed at least $2s(e)$ in $T$, but now we know that this edge is merged within $C'$ in $T'$, and that the size of $C'$ is $|C'| \leq 6t\ell$. Thus its contribution increases at most by a factor of $3t\ell$. By the same reasoning from the first edge type we discussed, all these edges total contribute at most a factor of $O(t\ell) \cdot \mathrm{cost}(T)$.
\end{enumerate}
We can then put a conservative bound by putting this all together.
\begin{align*}
\mathrm{cost}(T') \leq& O\left(\frac nt + t\ell +\frac{n\ell\gamma_t}{t} + \frac{nt\gamma_t}{\ell^2}\right)\mathrm{cost}(T).
\end{align*}
Finally, we know $T$ is a $\beta$-approximation for $T^*_{\mathrm{unfair}}$.
\begin{align*}
\mathrm{cost}(T') & \leq O\left(\frac nt + t\ell +\frac{n\ell \gamma_
t}{t}+ \frac{nt\gamma_t}{\ell^2}\right) \\
& \quad\qquad \cdot \beta \cdot \mathrm{cost}(T^*_{\mathrm{unfair}}).
\qedhere
\end{align*}
\end{proof}
With this proof, the only thing left to do is find a $\mathcal{C}$-good clustering $\mathcal{C}'$ (Definition~\ref{def:good}). Specifically, using the clustering $\mathcal{C}$ mentioned in Lemma~\ref{lem:finalcluster}, we would like to find a $\mathcal{C}$-good clustering $\mathcal{C}'$ using the following.
\begin{lem}\label{lem:buildcluster}
There is an algorithm that, given a clustering $\mathcal{C}$ with maximum cluster size $t$, creates a $\mathcal{C}$-good clustering.
\end{lem}
The proof is deferred to the Section~\ref{sec:cost_proofs}. With these two Lemmas, we can prove Theorem~\ref{thm:cost}.
\begin{proof}
Consider our graph $G$. We first obtain a $\beta$-approximation for unfair cost, which yields a hierarchy tree $T$. Let $\mathcal{C}$ be the maximal clustering in $T$ under the constraint that the cluster sizes must not exceed $t$. We then apply the algorithm from Lemma~\ref{lem:buildcluster} to get a $\mathcal{C}$-good clustering $\mathcal{C}'$. Construct $T'$ such that it has one layer that is $\mathcal{C}'$. Then we can apply the results from Lemma~\ref{lem:finalcluster} to get the desired approximation.
\end{proof}
From here, we will only provide a high-level description of the algorithm for Lemma~\ref{lem:buildcluster}. For precise details and proofs, see Section~\ref{sec:cost_proofs}. To start, we need to propose some terminology.
\begin{definition}[Red-blue matching]
A \textbf{red-blue matching} on a graph $G$ is a matching $M$ such that $M(u)=v$ implies $u$ and $v$ are different colors.
\end{definition}
Red-blue matchings are interesting because they help us ensure fairness.
For instance, suppose $M$ is a red-blue matching that is also perfect (i.e., touches all nodes). If the lowest level of a hierarchy consists of a clustering such that $v$ and $M(v)$ are in the same cluster for all $v$, then that level of the hierarchy is fair since there is a bijection between red and blue vertices within each cluster. When these clusters are merged up in the hierarchy, fairness is preserved.
Our algorithm will modify an unfair clustering to be fair by combining clusters and moving a small number of vertices. To do this, we will use the following notion.
\begin{definition}[Red-blue clustering graph]
Given a graph $G$ and a clustering $\mathcal{C}=\{C_1,\ldots,C_k\}$, we can construct a \textbf{red-blue clustering graph} $H_M = (V_M, E_M)$ that is associated with some red-blue matching $M$. Then $H_M$ is a graph where $V_M=\mathcal{C}$ and $(C_i,C_j)\in E_M$ if and only if there is a $v_i\in C_i$ and $M(v_i)=v_j\in C_j$.
\end{definition}
Basically, we create a graph of clusters, and there is an edge between two clusters if and only if there is at least one vertex in one cluster that is matched to some vertex in the other cluster. We now show that the red-blue clustering graph can be used to construct a fair clustering based on an unfair clustering.
\begin{prop}\label{prop:clusteringgraph}
Let $H_M$ be a red-blue clustering graph on a clustering $\mathcal{C}$ with a perfect red-blue matching $M$. Let $\mathcal{C}'$ be constructed by merging all the clusters in each component of $H_M$. Then $\mathcal{C}'$ is fair.
\end{prop}
\begin{proof}
Consider some $C\in \mathcal{C}'$. By construction, this must correspond to a connected component in $H_M$. By definition of $H_M$, for any vertex $v\in C$, $M(v)\in C$. That means $M$, restricted to $C$, defines a bijection between the red and blue nodes in $C$. Therefore, $C$ has an equal number of red and blue vertices and hence is fair.
\end{proof}
We will start by extracting a clustering $\mathcal{C}$ from an unfair hierarchy $T$ that approximates cost. Then, we will construct a red-blue clustering graph $H_M$ with a perfect red-blue matching $M$. Then we can use the components of $H_M$ to define our first version of the clustering $\mathcal{C}'$. However, this requires a non-trivial way of moving vertices between clusters in $\mathcal{C}$.
We now give an overview of our algorithm in Steps (A)--(G). For a full description, see our pseudocode in Section~\ref{sec:costpseudo}.
(A) \textbf{Get an unfair approximation $T$}. We start by running a $\beta$-approximation for cost in the unfair setting. This gives us a tree $T$ such that $\mathrm{cost}(T) \leq \beta \cdot \mathrm{cost} (T^*_{\mathrm{unfair}})$.
(B) \textbf{Extract a $t$-maximal clustering}. Given $T$, we find the maximal clustering $\mathcal{C}$ such that (i) every cluster in the clustering is of size at most $t$, and (ii) any cluster above these clusters in $T$ is of size more than $t$.
(C) \textbf{Combine clusters to be size $t$ to $3t$.} We will now slowly change $\mathcal{C}$ into $\mathcal{C'}$ during a number of steps. In the first step, we simply define $\mathcal{C}_0$ by merging small clusters $|C|\leq t$ until the merged size is between $t$ and $3t$. Thus clusters in $\mathcal{C}$ are contained within clusters in $\mathcal{C}_0$, and all clusters are between size $t$ and $3t$.
(D) \textbf{Find cluster excesses.} Next, we strive to make our clustering more fair. We do this by trying to find an underlying matching between red and blue vertices that agrees with $\mathcal{C}_0$ (matches are in the same cluster). If the matching were perfect, then the clusters in $\mathcal{C}_0$ would have equal red and blue representation. However, this is not guaranteed initially. We start by conceptually matching as many red and blue vertices within clusters as we can. Note we do not actually create this matching;
we just want to reserve the space for this matching to ensure fairness, but really some of these vertices may be moved later on. Then the remaining unmatched vertices in each cluster is either entirely red or entirely blue. We call this amount the \textit{excess} and the color the \textit{excess color}. We label each cluster with both of these.
(E) \textbf{Construct red-blue clustering graph}. Next, we would like to construct $H_M = (V_M, E_M)$, our red-blue clustering graph on $\mathcal{C}_0$. Let $V_M = \mathcal{C}_0$. In addition, for the within-cluster matchings mentioned in Step (D), let those matches be contained in $M$. With this start, we will do a matching process to simultaneously construct $E_M$ and the rest of $M$. Note the unmatched vertices are specifically the excess vertices in each cluster. We will match these with an iterative process given our parameter $\ell$:
\begin{enumerate}[topsep=0pt,itemsep=0pt,partopsep=0pt,parsep=0pt]
\item Select a vertex $C_i\in V_M$ with excess at least $\ell$ to start a new connected component in $H_M$. Without loss of generality, say its excess color is red.
\item Find a vertex $C_j\in V_M$ whose excess color is blue and whose excess is at least $\ell$. Add $(C_i,C_j)$ to $E_M$.
\item Say without loss of generality that the excess of $C_i$ is less than that of $C_j$. Then match all the excess in $C_i$ to vertices in the excess of $C_j$. Now $C_j$ has a smaller excess.
\item If $C_j$ has an excess less than $\ell$ or $C_j$ is the $\ell$th cluster in this component, end this component. Start over at (1) with a new cluster.
\item Otherwise, use $C_j$ as our reference and continue constructing this component at (2).
\item Complete when there are no more clusters with over $\ell$ excess that are not in a component (or all remaining such clusters have the same excess color).
\end{enumerate}
We would like to construct $\mathcal{C}'$ by merging all clusters in each component. This would be fair if $M$ were a perfect matching, however this is not true yet. In the next step, we handle this.
(F) \textbf{Fix unmatched vertices.} We now want to match excess vertices that are unmatched. We do this by bringing vertices from other clusters into the clusters that have unmatched excess, starting with all small unmatched excess. Note that some clusters were never used in Step (E) because they had small excess to start. This means they had many internal red-blue matches. Remove $t^2/\ell^2$ of these and put them into clusters in need. For other vertices, we will later describe a process where $t/\ell$ of the clusters can contribute $108t^2/\ell^2$ vertices to account for unmatched excess. Thus clusters lose at most $108t^2/\ell^2$ vertices, and we account for all unmatched vertices. Call the new clustering $\mathcal{C}_1$. Now $M$ is perfect and $H_M$ is unchanged.
(G) \textbf{Define $\mathcal{C}'$.} Finally, we create the clustering $\mathcal{C}'$ by merging the clusters in each component of $H_M$. Note that Proposition~\ref{prop:clusteringgraph} assures $C'$ is fair. In addition, we will show that cluster sizes in $\mathcal{C}_1$ are at most $6t$, so $\mathcal{C}'$ has the desired upper bound of $6t\ell$ on cluster size. Finally, we removed at most $\ell+ t^2/\ell^2$ vertices from each cluster. This is the desired $\mathcal{C}$-good clustering.
Further details and the proofs that the above sequence of steps achieve the desired approximation can be found in the next section. While the approximation factor obtained is not as strong as the ones for revenue or value objectives with fairness, we believe cost is a much harder objective with fairness constraints.
\subsection{Proof of Theorem ~\ref{thm:cost}}\label{sec:cost_proofs}
This algorithm contains a number of components. We will discuss the claims made by the description step by step. In Step (A), we simply utilize any $\beta$-approximation for the unfair approximation. Step (B) is also quite simple. At this point, all that is left is to show how to find $\mathcal{C}'$, ie, prove Lemma~\ref{lem:buildcluster} (introduced in Section~\ref{sec:cost}). This occurs in the steps following Step (B). In Step (C), we apply our first changes to the starting clustering from $T$. We now prove that the cluster sizes can be enforced to be between $t$ and $3t$.
\begin{lem}\label{lem:maximalcluster}
Given a clustering $\mathcal{C}$, we can construct a clustering $\mathcal{C}_0$, where each $C\in \mathcal{C}_0$ is a union of clusters in $\mathcal{C}$ and $t\leq |C|< 3t$.
\end{lem}
\begin{proof}
We iterate over all clusters in $\mathcal{C}$ whose size are less than $t$ and continually merge them until we create a cluster of size $\geq t$. Note that since the last two clusters we merged were of size $<t$, this cluster is of size $t\leq|C|< 2t$. We then stop this cluster and continue merging the rest of the clusters. At the end, if we are left with a single cluster of size $<t$, we simply merge this with any other cluster, which will then be of size $t \leq |C| < 3t$.
\end{proof}
Step (D) describes a rather simple process. All we have to do in each cluster is count the amount of each color in each cluster, find which is more, and also compute the difference. No claims are made here.
Step (E) defines a more careful process. We describe this process and its results here.
\begin{lem}\label{lem:hgraph}
There is an algorithm that, given a clustering $\mathcal{C}_0$ with $t\leq |C| \leq 3t$ for $C\in\mathcal{C}_0$, can construct a red-blue clustering graph $H_M = (V_M, E_M)$ on $\mathcal{C}_0$ with underlying matching $M$ such that:
\begin{enumerate}
\item $H_M$ is a forest, and its max component size is $\ell$.
\item For every $(C_i, C_j)\in E_M$, there are at least $\ell$ matches between $C_i$ and $C_j$ in $M$. In other words, $|M(C_i)\cap C_j| \geq \ell$.
\item For most $C_i\in V_M$, at most $\ell$ vertices in $C_i$ are unmatched in $M$. The only exceptions to this rule are (1) exactly one cluster in every $\ell$-sized component in $H_M$, and (2) at most $n/2$ additional clusters.
\end{enumerate}
\end{lem}
\begin{proof}
We use precisely the process from Step 5. Let $V_M = \mathcal{C}_0$. $H_M$ will look like a bipartite graph with some entirely isolated nodes. We then try to construct components of $H_M$ one-by-one such that (1) the max component size is $\ell$, and (2) edges represent at least $\ell$ matches in $M$.
\iffalse
This will go as follows:
\begin{enumerate}
\item Select a vertex $C_i\in V_M$ with excess at least $\ell$ to start a new connected component in $H_M$. Without loss of generality, say its excess color is red.
\item Find a vertex $C_j\in V_M$ whose excess color is blue and whose excess is at least $\ell$. Add $(C_i,C_j)$ to $E_M$.
\item Say without loss of generality that the excess of $C_i$ is less than that of $C_j$. Then match all the excess in $C_i$ to vertices in the excess of $C_j$. Now $C_j$ has a smaller excess.
\item If $C_j$ has an excess less than $\ell$ OR $C_j$ is the $\ell$th cluster in this component, end this component. Start over at (1) with a new cluster.
\item Otherwise, use $C_j$ as our reference and continue constructing this component at (2).
\item Complete when there are no more clusters with over $\ell$ excess that are not in a component.
\end{enumerate}
\fi
Let us show it satisfies the three conditions of the lemma. For condition 1, note that we will always halt component construction once it reaches size $\ell$. Thus no component can exceed size $\ell$. In addition, for every edge added to the graph, at least one of its endpoints now has small excess and will not be considered later in the program. Thus no cycles can be created, so it is a forest.
For condition 2, consider the construction of any edge $(C_i,C_j)\in E_M$. At this point, we only consider $C_i$ and $C_j$ to be clusters with different-color excess of at least $\ell$ each. In the next part of the algorithm, we match as much excess as we can between the two clusters. Therefore, there must be at least $\ell$ underlying matches.
Finally, condition 3 will be achieved by the completion condition. By the completion condition, there are no isolated vertices (besides possibly those leftover of the same excess color) that have over $\ell$ excess. Whenever we add a cluster to a component, either that cluster matches all of its excess, or the cluster it becomes adjacent to matches all of its excess. Therefore at any time, any component has at most one cluster with any excess at all. If the component is smaller than $\ell$ (and is not the final component), then that can only happen when in the final addition, both clusters end up with less than $\ell$ excess. Therefore, no cluster in this component can have less than $\ell$ excess. For an $\ell$-sized component, by the rule mentioned before, only one cluster can remain with $\ell$ excess. When the algorithm completes, we are left with a number of large-excess clusters with the same excess color, say red without loss of generality. Assume for contradiction there are more than $n/2$ such clusters, and so there is at least $n\ell/2$ . Since we started with half red and half blue vertices, the remaining excess in the rest of the clusters must match up with the large red excess. Thus the remaining at most $n/2$ clusters must have at least $n\ell/2$ blue excess, but this is only achievable if they have large excess left. This is a contradiction. Thus we satisfy condition 3.
\end{proof}
This concludes Step (E). In Step (F), we will transform the underlying clustering $\mathcal{C}_0$ such that we can achieve a perfect matching $M$. This will require removing a small number of vertices from some clusters in $\mathcal{C}_0$ and putting them in clusters that have unmatched vertices. This process will at most double cluster size.
\begin{lem}\label{lem:fixmatch}
There is an algorithm that, given a clustering $\mathcal{C}_0$ with $t\leq |C| \leq 3t$ for $C\in\mathcal{C}_0$, finds a clustering $\mathcal{C}_1$ and an underlying matching $M'$ such that:
\begin{enumerate}
\item There is a bijection between $\mathcal{C}_0$ and $\mathcal{C}_1$.
\item For any cluster $C_0\in\mathcal{C}_0$ and its corresponding $C_1\in\mathcal{C}_1$, $|C_0|-|C_1|\leq \ell + 108t^2/\ell^2$. This means that at most $\ell$ vertices are removed from $C_0$ in the construction of $C_1$.
\item For all $C_1\in \mathcal{C}_1$, $t-\ell-108t^2/\ell^2 \leq |C_1|\leq 6t$.
\item $M'$ is a perfect red-blue matching.
\item $H_M$ is a red-blue clustering graph of $\mathcal{C}_1$ with matching $M'$, perhaps with additional edges.
\end{enumerate}
\end{lem}
\begin{proof}
Use Lemma~\ref{lem:hgraph} to find the red-blue clustering graph $H_M$ and its corresponding graph $M$. Then we know that only one cluster in every $\ell$-sized component plus one other cluster can have a larger than $\ell$ excess. Since cluster sizes are at least $t$, $|V_M|\geq n/t$. This means that at most $n/(t\ell) + 1 = (n+t\ell)/(t\ell) \leq 2n/(t\ell)$ clusters need more than $\ell$ vertices. Since the excess is upper bounded by cluster size which is upper bounded by $3t$, this is at most $6n/\ell$ vertices in large excess that need matches.
We will start by removing all small excess vertices from clusters. This removes at most $\ell$ from any cluster. These vertices will then be placed in clusters with large excess of the right color. If we run out of large excess of the right color that needs matches, since the total amount of red and blue vertices is balanced, that means we can instead transfer the unmatched small excess red vertices to clusters with a small amount of unmatched blue vertices. In either case, this accounts for all the small unmatched excess. Now all we need to account for is at most $6n/\ell$ unmatched vertices in large excess clusters. At this point, note that the large excess should be balanced between red and blue. From now on, we will remove matches from within and between clusters to contribute to this excess. Since this always contributes the same amount of red and blue vertices by breaking matches, we do not have to worry about the balance of colors. We will describe how to distribute these contributions across a large number of clusters.
Consider vertices that correspond to clusters that (ignoring the matching $M$) started out with at most $\ell$ excess. So the non-excess portion, which is at least size $t-\ell$, is entirely matched with itself. We will simply remove $t^2/\ell^2$ of these matches to contribute.
Otherwise, we will consider vertices that started out with large excess. We must devise a clever way to break matches without breaking too many incident upon a single cluster. For every tree in $H_M$ (since $H_M$ is a forest by Lemma~\ref{lem:hgraph}), start at the root, and do a breadth-first search over all internal vertices. At any vertex we visit, break $\ell$ matches between it and its child (recall by by Lemma~\ref{lem:hgraph} that each edge in $H_M$ represents at least $\ell$ inter-cluster matches). Thus, each break contributes $2\ell$ vertices. We do this for every internal vertex. Since an edge represents at least $\ell$ matches and the max cluster size is at most $3t$, any vertex can have at most $3t/\ell$ children. Thus the fraction of vertices in $H_M$ that correspond to a contribution of $2\ell$ vertices is at least $\ell/(3t)$.
Clearly, the worst case is when all vertices in $H_M$ have large excess, as this means that fewer clusters are ensured to be able to contribute. By Lemma~\ref{lem:hgraph}, at least $n/2$ of these are a part of completed connected components (ie, of size $\ell$ or with each cluster having small remaining excess). So consider this case. Since $|V_M| \geq n/(3t)$, then this process yields $n\ell^2/(18t^2)$ vertices. To achieve $6n/\ell$ vertices, we must then run $108t^2/\ell^3$ iterations. If an edge no longer represents $\ell$ matches because of an earlier iteration, consider it a non-edge for the rest of the process. The only thing left to consider is if a cluster $C$ becomes isolated in $H_M$ during the process. We know $C$ began with at least $t$ vertices, and at most $\ell$ were removed by removing small excess. So as long as $t>\ell+108t^2/\ell^2$, we can remove the rest of the $108t^2/\ell^2$ vertices from the non-excess in $C$ (the rest must be non-excess) in the same way as vertices that were isolated in $H_M$ to start. Thus, we can account for the entire set of unmatched vertices without removing more than $108t^2/\ell^2$ vertices from any given cluster.
Now we consider the conditions. Condition 1 is obviously satisfied because we are just modifying clusters in $\mathcal{C}_0$, not removing them. The second condition is true because of our careful accounting scheme where we only remove $\ell+108t^2/\ell^2$ vertices per cluster. The same is true for the lower bound in condition 3. When we add them to new clusters, since we only add a vertex to match an unmatched vertex, we at most double cluster size. So the max cluster size is $6t$.
For the fourth condition, note that we explicitly executed this process until all unmatched vertices became matched, and any endpoint in a match we broke was used to create a new match. Thus the new matching, which we call $M'$, is perfect. It is still red-blue. Finally, note we did not create any matches between clusters. Therefore, no match in $M'$ can violate $H_M$. Thus condition 5 is met.
\end{proof}
Finally, we construct our final clustering in Step (G). However, to satisfy the qualities of Lemma \ref{lem:finalcluster}, we must first argue about the weight loss from each cluster.
\begin{lem}\label{lem:weightloss}
Consider any clustering $\mathcal{C}$ with cluster sizes between $t$ and $6t$. Say each cluster has a specified $r$ number of red vertices to remove and $b$ number of blue vertices to remove such that $r+b\leq x$ for some $x$, and $r$ (resp. $b$) is nonzero only if the number of red (resp. blue) vertices in the cluster is $O(n)$. Then we can remove the desired number of each color while removing at most an $O((x/t)\gamma_t)$ of the weight originally contained within the cluster.
\end{lem}
\begin{proof}
Consider some cluster $C$ with parameters $r$ and $b$. We will focus first on removing red vertices. Let $C_r$ be the red vertex set in $C$. We create a graph $K$ corresponding to this cluster as follows. Let $b_0$ be a vertex representing all blue vertices from $C$, $b_0'$ be the ``complement'' vertex to $b_0$, and $R$ be a set of vertices $r_i$ corresponding to all red vertices in $C$. We also add a set of $2r - |C_r| + 2X$ dummy vertices (where $X$ is just some large value that makes it so $2r - |C_r| + X > 0$). $2r - |C_r| + X$ of the dummy vertices will be connected to $b_0$ with infinite edge weight (denote these $\delta_i$), the other $X$ will be connected to $b_0'$ with infinite edge weight (denote these $\delta_i'$). This will ensure that $b_0$ and $b_0'$ are in the same partitions as their corresponding dummies. Let $s_G$ and $s_K$ be the similarity function in the original graph and new graph respectively.
\begin{align*}
s_K(b_0, \delta_i) =& \infty
\\mathrm{sim}_K(b_0', \delta_i') =& \infty
\end{align*}
The blue vertex $b_0$ is also connected to all $r_i$ with the following weight (where $C_b$ is the set of blue vertices in $C$):
\[s_K(b_0, r_i) = \sum_{b_j\in C_b} s_G(r_i, b_j) + \frac12\sum_{r_j\in R\setminus \{r_j\}} s_G(r_i, r_j)\]
This edge represents the cumulative edge weight between $r_i$ and all blue vertices. The additional summation term, which contains the edge weights between $r_i$ and all other red vertices, is necessary to ensure our bisection cut will also contain the edge weights between two of the removed red vertices.
Next, the edge weights between red vertices must contain the other portion of the corresponding edge weight in the original graph.
\[s_K(r_i, r_j) = \frac12 s_G(r_i, r_j)\]
Now, we note that there are a total of $2 - |C_r| + 2X + |C_r| = 2r + 2X$ vertices. So a bisection will partition the graph into vertex sets of size $r +X$. Obviously, in any approximation, $b_0$ must be grouped with all $\delta_i$ and $b_0'$ must be grouped with all $\delta_i'$. This means the $b_0$ partition must contain $|C_r|-r$ of the $R$ vertices, and the $b_0'$ partition must contain the other $r$. These $r$ vertices in the latter partition are the ones we select to move.
Consider any set $S$ of $r$ red vertices in $K$. Then it is a valid bisection. We now show that the edge weight in the cut for this bisection is exactly the edge weight lost by removing $S$ from $K$. We can do this algebraically. We start by breaking down the weight of the cut into the weight between the red vertices in $S$ and $b_0$, and also the red vertices in $S$ and the red vertices not in $S$.
\begin{align*}
s_K&(S, V(K)\setminus S) \\=& \sum_{r_i\in S} s_K(b_0, r_i) + \sum_{r_i\in S, r_j\in R\setminus S} s_K(r_i, r_j)
\\=&\sum_{r_i\in S} \left(\sum_{b_j\in B} s_G(r_i, b_j) + \frac12\sum_{r_j\in R\setminus \{r_j\}} s_G(r_i, r_j)\right)\\&+ \sum_{r_i\in S, r_j\in R\setminus S} \frac12 s_G(r_i, r_j)
\\=&\sum_{r_i\in S} \left(\sum_{b_j\in B} s_G(r_i, b_j) + \frac12\sum_{r_j\in R\setminus \{r_j\}} s_G(r_i, r_j) \right.\\&\left.\quad\quad\quad+ \frac12\sum_{r_j\in R\setminus S} s_G(r_i, r_j)\right)
\end{align*}
Notice that the two last summations have an overlap. They both contribute half the edge weight between $r_i$ and vertices in $R\setminus S$. Thus, these edges contribute their entire edge weight. All remaining vertices in $S\setminus \{r_i\}$ only contribute half their edge weight. We can then distribute the summation.
\begin{align*}
s_K&(S, V(K)\setminus S) \\=&\sum_{r_i\in S} \left(\sum_{b_j\in B} s_G(r_i, b_j) + \frac12\sum_{r_j\in S\setminus \{r_j\}} s_G(r_i, r_j)\right. \\&\left.\quad\quad\quad+ \sum_{r_j\in R\setminus S} s_G(r_i, r_j)\right)
\\=&\sum_{r_i\in S,b_j\in B} s_G(r_i, b_j) + \frac12\sum_{r_i\in S,r_j\in S\setminus \{r_j\}} s_G(r_i, r_j)
\\&+ \sum_{r_i\in S,r_j\in R\setminus S} s_G(r_i, r_j)
\end{align*}
In the middle summation, note that every edge $e=(u,v)$ is counted twice when $r_i=u$ and $r_j=v$, and when $r_i=v$ and $r_j=u$. We can then rewrite this as:
\begin{align*}
s_K(S, V(K)\setminus S) =&\sum_{r_i\in S,b_j\in B} s_G(r_i, b_j) \\&+ \sum_{r_i,r_j\in S} s_G(r_i, r_j) \\&+ \sum_{r_i\in S,r_j\in R\setminus S} s_G(r_i, r_j)
\end{align*}
When we remove $S$, we remove the connections between $S$ and blue vertices, the connections within $S$, and the connections between $S$ and red vertices not in $S$. This is precisely what this accounts for. Therefore, any bisection on $K$ directly corresponds to removing a vertex set $S$ of $r$ red vertices from $C$. If we have a $\gamma_t$-approximation for minimum weighted bisection, then, this yields a $\gamma_t$-approximation for the smallest loss we can achieve from removing $r$ red vertices.
Now we must compare the optimal way to remove $r$ vertices to the total weight in a cluster. Let $\rho = |C_r|$ be the number of red vertices in a cluster. Then the total number of possible cuts to isolate $r$ red vertices is $\binom{\rho}{r}$. Let $\mathcal{S}$ be the set of all possible cuts to isolate $r$ red vertices. Then if we sum over the weight of all possible cuts (where weight here is the weight between the $r$ removed vertices and all vertices, including each other), that will sum over each red-red edge and blue-red edge multiple times. A red-red edge is counted if either of its endpoints is in $S\in\mathcal{S}$, and this happens $2\binom{\rho}{r-1} - \binom{R-1}{r-2} \leq 2\binom{\rho}{r-1}$ of the time. A blue-red edge is counted if its red endpoint is in $S$, which happens $\binom{\rho}{r-1} \leq 2\binom{\rho}{r-1}$. And of course, since no blue-blue edge is covered, each is covered under $2\binom{\rho}{r-1}$ times. Therefore, if we sum over all these cuts, we get at most $2\binom{\rho}{r-1}$ times the weight of all edges in $C$.
\[\sum_{S\in\mathcal{S}} s(S) \leq 2\binom{\rho}{r-1} s(C)\]
Let $OPT$ be the minimum possible cut. Now since there are $\binom{\rho}{r}$ cuts, we know the lefthand side here is bounded above by $\binom{\rho}{r}s(OPT)$.
\[\binom{\rho}{r} s(OPT)\leq 2\binom{\rho}{r-1} s(C)\]
We can now simplify.
\[s(OPT)\leq \frac{2r}{\rho} s(C)\]
But note we are given $\rho = O(t)$. So if we have a $\gamma_t$ approximation for the minimum bisection problem, this means we can find a way to remove $r$ vertices such that the removed weight is at most $O(r/t)\gamma_t$. We can do this again to get a bound on the removal of the blue vertices. This yields a total weight removal of $O(x/t)\gamma_t$.
\end{proof}
Finally, we can prove Lemma~\ref{lem:buildcluster}, which satisfies the conditions of Lemma \ref{lem:finalcluster}.
\begin{proof}
Start by running Lemma~\ref{lem:maximalcluster} on $\mathcal{C}$ to yield $\mathcal{C}_0$. Then we can apply Lemma~\ref{lem:fixmatch} to yield $\mathcal{C}_1$ with red-blue clustering graph $H_M$ and underlying perfect red-blue matching $M'$. We create $\mathcal{C}'$ by merging components in $H_M$ into clusters. Since the max component size is $\ell$ and the max cluster size in $\mathcal{C}_1$ is $6t$, then the max cluster size in $\mathcal{C}'$ is $6t\ell$. This satisfies condition 2 of being $\mathcal{C}$-good. In addition, it is fair by Proposition~\ref{prop:clusteringgraph}.
Finally, we utilize the fact that we only moved at most $\ell + 108t^2\ell^2$ vertices from any cluster, and note that we only move vertices of a certain color if we have $O(n)$ of that color in that cluster. Then by Lemma~\ref{lem:weightloss}, we know we lost at most $O(\ell\gamma_t/t + t\gamma_t/\ell^2)$ fraction of the weight from any cluster. This satisfies the second condition and therefore $\mathcal{C}'$ is $\mathcal{C}$-good.
\end{proof}
\section{Experiments}
\label{sec:exp}
\vspace{-.2cm}
This section validates our algorithms from Sections~\ref{sec:rev} and~\ref{sec:val} empirically. We adopt the disparate impact fairness constraint~\cite{chierichetti}; thus each point is either blue or red. In particular, we would like to:
\begin{itemize}[nosep]
\item Show that running the standard average-linkage algorithm results in highly unfair solutions.
\item Demonstrate that demanding fairness in hierarchical clustering incurs only a small loss in the hierarchical clustering objective.
\item Show that our algorithms, including fairlet decomposition, are practical on real data.
\end{itemize}
In \refappendix{sec:multicolorexp} we consider multiple colors and the same trends as the two color case occur.
\begin{table*}[t!] \vspace{-0.15in}
\centering
\caption{ \vspace{-0.2in} Dataset description. Here $(b, r)$ denotes the balance of the dataset.} \label{table:datasets}
\small
\begin{tabular}{r|lllll}
\hline
Name & Sample size & \# features & Protected feature & Color (blue, red) & $(b,r)$ \\
\hline
\textsc{CensusGender}\xspace & 30162 & 6 & gender & (female, male) & $(1,3)$ \\
\textsc{CensusRace}\xspace & 30162 & 6 & race & (non-white, white) & $(1,7)$ \\
\textsc{BankMarriage}\xspace & 45211 & 7 & marital status & (not married, married) & $(1,2)$ \\
\textsc{BankAge}\xspace & 45211 & 7 & age & ($<40$, $\geq 40$) & $(2,3)$ \\
\hline
\end{tabular}
\end{table*}
\vspace{-0.1in}
\begin{table*}[t!]\vspace{-0.2in}
\centering
\caption{Impact of Algorithm~\ref{alg:eps_local_opt_decomp} on $\mathrm{ratio}_{\mathrm{value}}$ in percentage (mean $\pm$ std. dev).}
\label{emp:ratiockmm}
\tiny
\begin{tabular}{r|llllllll}
\hline
Samples & 400 & 800 & 1600 & 3200 & 6400 & 12800\\
\hline
\textsc{CensusGender}\xspace, initial & $88.17 \pm 0.76$ & $88.39 \pm 0.21$ & $88.27 \pm 0.40$ & $88.12 \pm 0.26$ & $88.00 \pm 0.10$ & $88.04 \pm 0.13$ \\
final & $99.01 \pm 0.60$ & $99.09 \pm 0.58$ & $99.55 \pm 0.26 $ & $99.64 \pm 0.13 $ & $ 99.20 \pm 0.38 $ & $99.44 \pm 0.23$ \\
\hline
\textsc{CensusRace}\xspace, initial & $84.49 \pm 0.66$ & $85.01 \pm 0.31$ & $85.00 \pm 0.42$ & $84.88 \pm 0.43$ & $84.84 \pm 0.16$ & $84.89 \pm 0.20 $ \\
final & $99.50 \pm 0.20$ & $99.89 \pm 0.32$ & $100.0 \pm 0.21$ & $99.98 \pm 0.21$ & $99.98 \pm 0.11$ & $99.93 \pm 0.31$ \\
\hline
\textsc{BankMarriage}\xspace, initial & $92.47 \pm 0.54$ & $92.58 \pm 0.30$ & $92.42 \pm 0.30$ & $92.53 \pm 0.14$ & $92.59 \pm 0.14$ & $92.75 \pm 0.04$\\
final & $ 99.18 \pm 0.22$ & $99.28 \pm 0.33$ & $99.59 \pm 0.14$ & $99.51 \pm 0.17$ & $99.46 \pm 0.10$ & $99.50 \pm 0.05$ \\
\hline
\textsc{BankAge}\xspace, initial & $93.70 \pm 0.56$ & $93.35 \pm 0.41$ & $92.95 \pm 0.25$ & $93.28 \pm 0.13$ & $93.36 \pm 0.12$ & $93.33 \pm 0.12$ \\
final & $99.40 \pm 0.28$ & $99.40 \pm 0.51 $ & $99.61 \pm 0.13$ & $ 99.64 \pm 0.07 $ & $99.65 \pm 0.08$ & $99.59 \pm 0.06$\\
\hline
\end{tabular}
\end{table*}
\noindent \textbf{Datasets.} We use two datasets from the UCI data repository.%
\footnote{\url{archive.ics.uci.edu/ml/index.php}, Census: \url{archive.ics.uci.edu/ml/datasets/census+income}, Bank: \url{archive.ics.uci.edu/ml/datasets/Bank+Marketing} }
In each dataset, we use features with numerical values and leave out samples with empty entries. For for value, we use the Euclidean distance as the dissimilarity measure. For revenue, we set the similarity to be $s(i,j) = \frac{1}{1+d(i,j)}$ where $d(i,j)$ is the Euclidean distance. We pick two different protected features for both datasets, resulting in four datasets in total (See Table \ref{table:datasets} for details).
\begin{itemize}[nosep]
\item \emph{Census} %
dataset: We choose \emph{gender} and \emph{race} to be the protected feature and call the resulting datasets \textsc{CensusGender}\xspace and \textsc{CensusRace}\xspace.
\item \emph{Bank} %
dataset: We choose \emph{marital status} and \emph{age} to be the protected features and call the resulting datasets \textsc{BankMarriage}\xspace and \textsc{BankAge}\xspace.
\end{itemize}
In this section, unless otherwise specified, we report results only for the value objective. Results for the revenue objective are qualitatively similar and are omitted here. We do not evaluate our algorithm
for the cost objective since it is currently only of theoretical interest.
We sub-sample points of two colors from the original data set proportionally, while approximately retaining the original color balance. The sample sizes used are
$100 \times 2^i, i = 0, \ldots, 8$. On each, we do $5$ experiments and report the average results. We set $\epsilon$ in Algorithm~\ref{alg:eps_local_opt_decomp} to $0.1$ in all of the experiments.
\noindent \textbf{Implementation.} The code is available in the Supplementary Material. In the experiments, we use Algorithm~\ref{alg:eps_local_opt_decomp} for the fairlet decomposition phase, where the fairlet decomposition is initialized by randomly assigning red and blue points to each fairlet. We apply the average-linkage algorithm to create a tree on the fairlets. We further use average-linkage to create subtrees inside of each fairlet.
The algorithm selects a \emph{random} pair of blue or red points in different fairlets to swap, and checks if the swap sufficiently improves the objective. We do not run the algorithm until all the pairs are checked, rather the algorithm stops if it has made a $2n$ failed attempts to swap a random pair. As we obseve empirically, this does not have material effect on the quality of the overall solution.
\iffalse
\begin{table*}[ht]
\centering
\caption{Impact of Algorithm~\ref{alg:eps_local_opt_decomp} on $ratio_{value}$ in Percentage, Mean $\pm$ Std. Dev}
\label{emp:ratiockmm}
\tiny
\begin{tabular}{lllllllll}
\hline
Samples & 100 & 200 & 400 & 800 & 1500 & 3200 & 6400 & 12800\\
\hline
Initial, CensusGender & 87.53 \% & 87.86\% & 88.17\% & 88.39\% & 88.27\% & 88.12\% & 88.00\% & 88.04\% \\
Final, CensusGender & 98.50 \% & 98.93 \% & 99.01 \% & 99.09 \% & 99.55 \% & 99.64 \% & 99.20 \% & 99.44\% \\
\hline
Initial, CensusRace & 83.90\% & 84.21\% & 84.49\% & 85.01\% & 85.00\% & 84.88\% & 84.84\% & 84.89\% \\
Final, CensusRace & 98.29 \% & 98.81 \% & 99.50 \% & 99.89 \% & 100.00 \% & 99.98 \% & 99.98 \% & 99.93 \% \\
\hline
Initial, BankMarriage & 91.26\% & 91.82\% & 92.47\% & 92.58\% & 92.42\% & 92.53\% & 92.59\% & 92.75\%\\
Final, BankMarriage & 97.78\% & 99.12\% & 99.18\% & 99.28\% & 99.59\% & 99.51\% & 99.46\% & 99.50\% \\
\hline
Initial, BankAge & 92.71\% & 93.01\% & 93.70\% & 93.35\% & 92.95\% & 93.28\% & 93.36\% & 93.33\%\\
Final, BankAge & 98.39\% & 98.93\% & 99.40\% & 99.40\% & 99.61\% & 99.64\% & 99.65\% & 99.59\%\\
\hline
\hline
\end{tabular}
\end{table*}
\fi
\begin{table*}[t!]\vspace{-0.2in}
\centering
\caption{Impact of Algorithm~\ref{alg:eps_local_opt_decomp} on $\mathrm{ratio}_{{\text{fairlets}}}$.}
\label{table:ratio_fairness}
\tiny
\begin{tabular}{r|llllllll}
\hline
Samples & 100 & 200 & 400 & 800 & 1600 & 3200 & 6400 & 12800\\
\hline
\textsc{CensusGender}\xspace, initial & 2.5e-2 & 1.2e-2 & 6.2e-3 & 3.0e-3 & 1.5e-3 & 7.5e-4 & 3.8e-4 & 1.9e-4 \\
final & 4.9e-3 & 1.4e-3 & 6.9e-4 & 2.5e-4 & 8.5e-5 & 3.6e-5 & 1.8e-5 & 8.0e-6
\\
\hline
\textsc{CensusRace}\xspace, initial & 6.6e-2 & 3.4e-2 & 1.7e-2 & 8.4e-3 & 4.2e-3 & 2.1e-3 & 1.1e-3 & 5.3e-4 \\
final & 2.5e-2 & 1.2e-2 & 6.2e-3 & 3.0e-3 & 1.5e-3 & 7.5e-4 & 3.8e-4 & 1.9e-5 \\
\hline
\textsc{BankMarriage}\xspace, initial & 1.7e-2 & 8.2e-3 & 4.0e-3 & 2.0e-3 & 1.0e-3 & 5.0e-4 & 2.5e-4 & 1.3e-4\\
final & 5.9e-3 & 2.1e-3 & 9.3e-4 & 4.1e-4 & 1.3e-4 & 7.1e-5 & 3.3e-5 & 1.4e-5 \\
\hline
\textsc{BankAge}\xspace, initial & 1.3e-2 & 7.4e-3 & 3.5e-3 & 1.9e-3 & 9.3e-4 & 4.7e-4 & 2.3e-4 & 1.2e-4\\
final & 5.0e-3 & 2.2e-3 & 7.0e-4 & 3.7e-4 & 1.3e-4 & 5.7e-5 & 3.0e-5 & 1.4e-5 \\
\hline
\end{tabular}
\end{table*}
\begin{figure*}[t!]
\centering
\begin{tabular}{ccc}
\includegraphics[width=.3\linewidth]{fairness_obj_every_100_swaps_3200pts.pdf}
&
\includegraphics[width=.3\linewidth]{cohen_addad_every_100_swaps_3200pts.pdf}
&
\includegraphics[width=.3\linewidth]{adult_runtime_b=1_r=3.pdf}
\\
(i) & (ii) & (iii) \\
\end{tabular}
\caption{
(i) $\mathrm{ratio}_{\text{fairlets}}$, every $100$ swaps.
(ii) $\mathrm{ratio}_{\mathrm{value}}$, every $100$ swaps.
(iii) \textsc{CensusGender}\xspace: running time vs sample size on a log-log scale.
}
\label{fig:combined}
\vspace{-0.15in}
\end{figure*}
\noindent \textbf{Metrics.}
We present results for value here, the results for revenue are qualitatively similar. In our experiments, we track the following quantities. Let $G$ be the given input instance and let $T$ be the output of our fair hierarchical clustering algorithm. We consider the following ratio $\mathrm{ratio}_\mathrm{value} = \frac{\mathrm{value}_G(T)}{ \mathrm{value}_G(T')}$, where $T'$ is the tree obtained by the standard average-linkage algorithm. We consider the fairlet objective function where $\mathcal{Y}$ is a fairlet decomposition. Let $\mathrm{ratio}_{{\text{fairlets}}} = \frac{\phi(\mathcal{Y})}{d(V)}$.
\noindent \textbf{Results.}
Average-linkage algorithm always constructs unfair trees. For each of the datasets, the algorithm results in monochromatic clusters at some level, strengthening the case for fair algorithms.
In Table~\ref{emp:ratiockmm}, we show for each dataset the $\mathrm{ratio}_\mathrm{value}$ both at the time of initialization (Initial) and after usint the local search algorithm (Final). We see the change in the ratio as the local search algorithm performs swaps. Fairness leads to almost no degradation in the objective value as the swaps increase.
Table~\ref{table:ratio_fairness} shows the
$\mathrm{ratio}_{{\text{fairlets}}}$ between the initial initialization and the final output fairlets. As we see, Algorithm~\ref{alg:eps_local_opt_decomp} significantly improves the fairness of the initial random fairlet decomposition.
\if 0
\begin{figure}[t!]
\centering
\centering
\includegraphics[width=.7\linewidth]{fairness_obj_every_100_swaps_3200pts.pdf}
\caption{$\mathrm{ratio}_{\text{fairlets}}$, every $100$ swaps.}
\label{fig:test1}
\vspace{-0.2in}
\end{figure}
\fi
\begin{table*}[t!] \vspace{-0.05in}
\centering
\small
\caption{Clustering on fairlets found by local search vs. upper bound, at size 1600 (mean $\pm$ std. dev).}
\label{emp:size_1600_upper_bound}
\tiny
\begin{tabular}{r|llllllll}
\hline
Dataset & \textsc{CensusGender}\xspace & \textsc{CensusRace}\xspace & \textsc{BankMarriage}\xspace & \textsc{BankAge}\xspace \\
\hline
Revenue vs. upper bound& $81.89 \pm 0.40$ & $81.75 \pm 0.83$ & $61.53 \pm 0.37$ & $61.66 \pm 0.66$ \\
Value vs. upper bound & $84.31 \pm 0.15$ & $84.52 \pm 0.22$ & $89.17 \pm 0.29 $ & $88.81 \pm 0.18 $ \\
\hline
\end{tabular}
\vspace{-0.1in}
\end{table*}
The more the locally-optimal algorithm improves the objective value of \eqref{obj:fairlet_obj}, the better the tree's performance based on the fairlets. Figures~\ref{fig:combined}(i) and \ref{fig:combined}(ii) show $\mathrm{ratio}_{\mathrm{value}}$ and $\mathrm{ratio}_{{\text{fairlets}}}$ for every $100$ swaps in the execution of Algorithm~\ref{alg:eps_local_opt_decomp} on a subsample of size $3200$ from Census data set. The plots show that as the fairlet objective value decreases, the value\ objective of the resulting fair tree increases. Such correlation are found on subsamples of all sizes.
Now we compare the objective value of the algorithm with the upper bound on the optimum. We report the results for both the revenue and value objectives, using fairlets obtained by local search, in Table~\ref{emp:size_1600_upper_bound}. On all datasets, we obtain ratios significantly better than the theoretical worst case guarantee.
\if 0
\begin{figure}[t!]
\centering
\includegraphics[width=.7\linewidth]{cohen_addad_every_100_swaps_3200pts.pdf}
\caption{$\mathrm{ratio}_{\mathrm{value}}$, every $100$ swaps.}
\label{fig:test2}
\vspace{-0.2in}
\end{figure}
\begin{figure}[t!]
\centering
\includegraphics[width=.7\linewidth]{adult_runtime_b=1_r=3.pdf}
\caption{\textsc{CensusGender}\xspace: running time vs sample size on a log-log scale.}
\label{fig:log_time_comparison}
\vspace{-0.1in}
\end{figure}
\fi
In Figure~\ref{fig:combined}(iii), we show the average running time on Census data for both the original average-linkage and the fair average-linkage algorithms. As the sample size grows, the running time scales almost as well as current implementations of average-linkage algorithm. Thus with a modest increase in time, we can obtain a fair hierarchical clustering under the value objective.
\section{Fairlet decomposition}
\begin{definition}[Fairlet~\cite{chierichetti}]
A \emph{fairlet} $Y$ is a fair set of points such that there is no partition of $Y$ into $Y_1$ and $Y_2$ with both $Y_1$ and $Y_2$ being fair.
\end{definition}
In the bounded representation fairness setting, a set of points is fair if at most an $\alpha$ fraction of the points have the same color. We call this an \emph{$\alpha$-capped fairlet}. For $\alpha=1/t$ with $t$ an integer, the fairlet size will always be at most $2t-1$. We will refer to the maximum size of a fairlet by $m_f$.
Recall that given a union-closed fairness constraint, if the bottom clustering in the tree is a layer of fairlets (which we call a \textit{fairlet decomposition} of the original dataset) the hierarchical clustering tree is also fair. This observation gives an immediate algorithm for finding fair hierarchical clustering trees in a two-phase manner. (i) Find a fairlet decomposition, i.e., partition the input set $V$ into clusters $Y_1, Y_2, \ldots$ that are all fairlets. (ii) Build a tree on top of all the fairlets. Our goal is to complete both phases in such a way that we optimize the given objective (i.e., revenue or value).
In Section~\ref{sec:rev}, we will see that to optimize for the revenue objective, all we need is a fairlet decomposition with bounded fairlet size. However, the fairlet decomposition required for the value objective is more nuanced. We describe this next.
\paragraph{Fairlet decomposition for the value objective}
For the value objective, we need the total distance between pairs of points inside each fairlet to be small. Formally, suppose $V$ is partitioned into fairlets $\mathcal{Y} = \{Y_1, Y_2, \ldots\}$ such that $Y_i$ is an $\alpha$-capped fairlet. The cost of this decomposition is defined as:
\begin{equation}
\label{obj:fairlet_obj}
\phi(\mathcal{Y}) = \sum_{Y \in \mathcal{Y}}\sum_{\{u,v\} \subseteq Y}d(u,v).
\end{equation}
Unfortunately, the problem of finding a fairlet decomposition to minimize $\phi(\cdot)$ does not admit any constant-factor approximation unless P = NP.
\begin{theorem} \label{thm:np_hard_constant_approx}
Let $z \geq 3$ be an integer. Then
there is no bounded approximation algorithm for finding $(\frac{z}{z+1})$-capped fairlets optimizing $\phi(\mathcal{Y})$, which runs in polynomial time, unless P = NP.
\end{theorem}
The proof proceeds by a reduction from the Triangle Partition problem, which asks if a graph $G = (V, E)$ on $3n$ vertices can be partitioned into three element sets, with each set forming a triangle in $G$.
Fortunately, for the purpose of optimizing the value objective, it is not necessary to find an approximate decomposition.
\section{Introduction}
Algorithms and machine learned models are increasingly used to assist in decision making on a wide range of issues, from mortgage approval to court sentencing recommendations~\cite{kleinberg2017human}. It is clearly undesirable, and in many cases illegal, for models to be biased to groups, for instance to discriminate on the basis of race or religion. Ensuring that there is no bias is not as easy as removing these protected categories from the data. Even without them being explicitly listed, the correlation between sensitive features and the rest of the training data may still cause the algorithm to be biased. This has led to an emergent literature on computing provably fair outcomes (see the book~\cite{hardtbook}).
The prominence of clustering in data analysis, combined with its use for data segmentation, feature engineering, and visualization makes it critical that efficient fair clustering methods are developed. There has been a flurry of recent results in the ML research community, proposing algorithms for fair {\em flat} clustering, i.e., partitioning a dataset into a set of disjoint clusters, as captured by \textsc{k-center}, \textsc{k-median}, \textsc{k-means}, correlation clustering objectives~\cite{ahmadian,ahmadian2020fair,backurs, bera2019fair,bercea2018cost, chen2019proportionally,chiplunkar2020fair,huang2019coresets,jones2020fair,kleindessner2, spectralfair}. However, the same issues affect {\em hierarchical clustering}, which is the problem we study.
The input to the hierarchical clustering problem is a set of data points, with pairwise similarity or dissimilarity scores. A hierarchical clustering is a tree, whose leaves correspond to the individual datapoints. Each internal node represents a cluster containing all the points in the leaves of its subtree. Naturally, the cluster at an internal node is the union of the clusters given by its children. Hierarchical clustering is widely used in data analysis~\cite{dubes1980clustering}, social networks~\cite{mann2008use,rajaraman2011mining}, image/text organization~\cite{karypis2000comparison}.
Hierarchical clustering is frequently used for flat clustering when the number of clusters is unknown ahead of time. A hierarchical clustering yields a set of clusterings at different granularities that are consistent with each other. Therefore, in all clustering problems where fairness is desired but the number of clusters is unknown, fair hierarchical clustering is useful. As concrete examples, consider a collection of news articles organized by a topic hierarchy, where we wish to ensure that no single source or view point is over-represented in a cluster; or a hierarchical division of a geographic area, where the sensitive attribute is gender or race, and we wish to ensure balance in every level of the hierarchy. There are many such problems that benefit from fair hierarchical clustering, motivating the study of the problem area.
\para{Our contributions} We initiate an algorithmic study of fair hierarchical clustering.
We build on Dasgupta's seminal formal treatment of hierarchical clustering~\cite{dasgupta} and prove our results for the revenue~\cite{moseleywang}, value~\cite{cohenaddad}, and cost~\cite{dasgupta} objectives in his framework.
To achieve fairness, we show how to extend the fairlets machinery, introduced by~\cite{chierichetti} and extended by~\cite{ahmadian}, to this problem. We then investigate the complexity of finding a good fairlet decomposition, giving both strong computational lower bounds and polynomial time approximation algorithms.
Finally, we conclude with an empirical evaluation of our approach. We show that ignoring protected attributes when performing hierarchical clustering can lead to unfair clusters. On the other hand, adopting the fairlet framework in conjunction with the approximation algorithms we propose yields {\em fair} clusters with a {\em negligible} objective degradation.
\para{Related work}
Hierarchical clustering has received increased attention over the past few years. Dasgupta~\cite{dasgupta} developed a cost function objective for data sets with similarity scores, where similar points are encouraged to be clustered together lower in the tree. Cohen-Addad et al.~\cite{cohenaddad} generalized these results into a class of optimization functions that possess other desirable properties and introduced their own value objective in the dissimilarity score context.
In addition to validating their objective on inputs with known ground truth, they gave a theoretical justification for the average-linkage algorithm, one of the most popular algorithms used in practice, as a constant-factor approximation for value.
Contemporaneously, Moseley and Wang \cite{moseleywang} designed a revenue objective function based on the work of Dasgupta for point sets with similarity scores and showed the average-linkage algorithm is a constant approximation for this objective as well. This work was further improved by Charikar \cite{charikar19} who gave a tighter analysis of average-linkage for Euclidean data for this objective and \cite{AhmadianBisect,YossiNogaHC} who improved the approximation ratio in the general case.
In parallel to the new developments in algorithms for hierarchical clustering, there has been tremendous development in the area of fair machine learning. We refer the reader to a recent textbook ~\cite{hardtbook} for a rich overview, and focus here on progress for fair clustering. Chierichetti et al.~\cite{chierichetti} first defined fairness for $k$-median and $k$-center clustering, and introduced the notion of {\em fairlets} to design efficient algorithms. Extensive research has focused on two topics: adapting the definition of fairness to broader contexts, and designing efficient algorithms for finding good fairlet decompositions. For the first topic, the fairness definition was extended to multiple values for the protected feature~\cite{ahmadian, bercea2018cost,rosner}. For the second topic, Backurs et al.~\cite{backurs} proposed a near-linear constant approximation algorithm for finding fairlets for $k$-median, Kleindessner et al.~\cite{kleindessner2} designed a linear time constant approximation algorithm for $k$-center, Bercea et al.~\cite{bercea2018cost} developed methods for fair $k$-means, while Ahmadian et al.~\cite{ahmadian2020fair} defined approximation algorithms for fair correlation clustering. Concurrently with our work, Chhabra et al.~\cite{chhabra2020fair} introduced a possible approach to ensuring fairness in hierarchical clustering. However, their fairness definition differs from ours (in particular, they do not ensure that all levels of the tree are fair), and the methods they introduce are heuristic, without formal fairness or quality guarantees.
Beyond clustering, the same balance notion that we use has been utilized to capture fairness in other contexts, for instance: fair voting~\cite{voting}, fair optimization~\cite{matroids}, as well as other problems~\cite{Ranking}.
\vspace{-0.1in}
\iffalse
\section{Introduction}
The unprecedented growth in the adoption of machine learning solutions in the business world as well as in the scientific community has created new opportunities; but it also poses new challenges. Among those, a significant attention has been devoted to risk of machine learning solutions inadvertently resulting in unfair outcomes~\cite{elzayn2019fair,bera2019fair,chierichetti}.
Clustering is a major pillar of unsupervised machine learning and, as such, the importance of fair clustering research has been gaining recent recognition. Consider the task of data organization and summarization, which is a major application of clustering~\cite{dash2019summarizing}. In this context, it is sometimes necessary to prevent the clusters from over-representing a group to the detriment of another group. For instance, in a clustering of news articles by topic, one may want to prevent any news source from being over-represented in any cluster. When clustering is used to select representatives to summarize the data~\cite{pmlr-v97-kleindessner19a}, it is often preferable for the representatives to reflect the underlying data characteristics faithfully. Finally, when clustering is used for feature generation and data enhancement in a decision-making system~\cite{fang2019achieving}, one may want the clusters to be balanced to prevent a disproportionate effect on a protected class~\cite{bera2019fair,fang2019achieving}.
So far, the problem of fair clustering has been exclusively studied in the context of {\it flat} clustering, i.e. partitioning of dataset in a set of disjoint clusters~\cite{bera2019fair,chierichetti,ahmadian,davidson2019making}. However, the same fairness issues also affect {\it hierarchical} clustering~\cite{dasgupta} (i.e. collections of laminar families of clusters), a well-studied problem that to our knowledge has not been explored under fairness constraints.
In this paper, we initiate the study of fairness in hierarchical clustering. Our work is motivated by the wide applicability of hierarchical clustering in exploratory data analysis~\cite{dubes1980clustering}, social networks analysis~\cite{rajaraman2011mining,mann2008use}, image and text organization~\cite{karypis2000comparison}. We first introduce a notion of fairness in hierarchical clustering, which ensures proportional representation of protected categories in each level of the hierarchy. This can, for instance, prevent the over-representation of a news source in any sub-clustering of a hierarchy. Similarly, fair hierarchies can be used to allow the exploratory data analysis to faithfully represent the underlying population at each granularity level.
After introducing this formal notion of fairness, we design algorithms to optimize well-known objectives functions for hierarchical clustering while respecting this fairness constraint.
\fi
\section*{Appendix}
\input{appendix}
\end{appendix}
\fi
\end{document}
\section{Formulation}
\subsection{Objectives for hierarchical clustering}
Let $G = (V, s)$ be an input instance, where $V$ is a set of $n$ data points, and $s:V^2 \rightarrow \mathbb{R}^{\geq 0}$ is a similarity function over vertex pairs. For two sets, $A, B \subseteq V$, we let $s(A, B) = \sum_{a \in A, b\in B} s(a, b)$ and $S(A) = \sum_{\{i,j\} \in A^2}s(i,j)$. For problems where the input is $G = (V, d)$, with $d$ a distance function, we define $d(A,B)$ and $d(A)$ similarly.
We also consider the \emph{vertex-weighted} versions of the problem, i.e. $G = (V, s, m)$ (or $G = (V, d, m)$), where $m : V \rightarrow \mathbb{Z}^{+}$ is a weight function on the vertices. The vertex-unweighted version can be interpreted as setting $m(i) = 1, \forall i \in V$. For $U \subseteq V$, we use the notation $m(U) = \sum_{i \in U} m(i)$.
A \emph{hierarchical clustering} of $G$ is a tree whose leaves correspond to $V$ and whose internal vertices represent the merging of vertices (or clusters) into larger clusters until all data merges at the root. The goal of hierarchical clustering is to build a tree to optimize some objective.
To define these objectives formally, we need some notation. Let $T$ be a hierarchical clustering tree of $G$. For two leaves $i$ and $j$, we say $i\lor j$ is their least common ancestor.
For an internal vertex $u$ in $T$, let $T[u]$ be the subtree in $T$ rooted at $u$. Let $\mathrm{leaves}(T[u])$ be the leaves of $T[u]$
We consider three different objectives---{\em revenue}, {\em value}, and {\em cost}---based on the seminal framework of~\cite{dasgupta}, and generalize them to the vertex-weighted case.
\textbf{Revenue.} Moseley and Wang~\cite{moseleywang} introduced the revenue objective for hierarchical clustering. Here the input instance is of the form $G = (V, s, m)$, where $s: V^2 \rightarrow \mathbb{R}^{\geq 0}$ is a \emph{similarity} function.
\begin{definition}[Revenue]
\label{def:rev}
The \emph{revenue} ($\mathrm{rev}$) of a tree $T$ for an instance $G = (V, s, m)$, where $s(\cdot, \cdot)$ denotes similarity between data points, is:
$\mathrm{rev}_G(T) = \sum_{i,j\in V} s(i,j) \cdot \big(m(V) - m(\mathrm{leaves}(T[i\lor j])) \big).$
\end{definition}
Note that in this definition, each weight is scaled by (the vertex-weight of) the non-leaves. The goal is to find a tree of maximum revenue. It is known that average-linkage is a $\nicefrac{1}{3}$-approximation for vertex-unweighted revenue~\cite{moseleywang}; the state-of-the-art is a $0.585$-approximation~\cite{YossiNogaHC}.
As part of the analysis, there is an upper
bound for the revenue objective~\cite{cohenaddad,moseleywang}, which is easily extended to the vertex-weighted setting:
\begin{equation}
\label{eq:maxrevenue}
\mathrm{rev}_G(T) \leq \Big( m(V) - \min_{u, v \in V, u \neq v} m(\{u, v\}) \Big) \cdot s(V).
\end{equation}
Note that in the vertex-unweighted case, the upper bound is just $(|V| - 2) s(V)$.
\textbf{Value.}
A different objective was proposed by Cohen-Addad et al.~\cite{cohenaddad}, using distances instead of similarities. Let $G=(V,d,m)$, where $d:V^2\to\mathbb{R}^{\geq0}$ is a distance (or dissimilarity) function.
\begin{definition}[Value]
\label{def:val}
The \emph{value} ($\mathrm{val}$) of a tree $T$ for an instance $G = (V, d, m)$ where $d(\cdot, \cdot)$ denotes distance is: $\mathrm{val}_G(T) = \sum_{i,j\in V}d(i,j) \cdot m(\mathrm{leaves}(T[i\lor j])).$
\end{definition}
As in revenue, we aim to find a hierarchical clustering to maximize value.
Cohen-Addad et al.~\cite{cohenaddad} showed that both average-linkage and a locally $\epsilon$-densest cut algorithm achieve a $\nicefrac{2}{3}$-approximation for vertex-unweighted value. They also provided an upper bound for value, much like that in \eqref{eq:maxrevenue}, which in the vertex-weighted context, is:
\begin{equation}
\label{eq:maxvalue}
\mathrm{val}_G(T) \leq m(V) \cdot s(V).
\end{equation}
\textbf{Cost.}
The original objective introduced by Dasgupta \cite{dasgupta} for analyzing hierarchical clustering algorithms introduces the notion of cost.
\begin{definition}[Cost]
\label{def:cost}
The $\mathrm{cost}$ of a tree $T$ for an instance $G = (V, s)$ where $s(\cdot, \cdot)$ denotes similarity is: $\mathrm{cost}_G(T) = \sum_{i,j\in V} s(i,j) \cdot |\mathrm{leaves}(T[i\lor j])|.$
\end{definition}
The objective is to find a tree of minimum cost. From a complexity point of view, cost is a harder objective to optimize.
Charikar and Chatziafratis~\cite{charikar17} showed that cost is not constant-factor approximable under the Small Set Expansion hypothesis, and the current best approximations are $O\left(\sqrt{\log n}\right)$ and require solving SDPs.
{\bf Convention.} Throughout the paper we adopt the following convention: $s(\cdot, \cdot)$ will always denote similarities and $d(\cdot, \cdot)$ will always denote distances. Thus, the inputs for the cost and revenue objectives will be instances of the form $(V, s, m)$ and inputs for the value objective will be instances of the form $(V, d, m)$. All the missing proofs can be found in the Supplementary Material.
\subsection{Notions of fairness}
Many definitions have been proposed for fairness in clustering. We consider the setting in which each data point in $V$ has a \emph{color}; the color corresponds to the protected attribute.
\textit{Disparate impact.} This notion is used to capture the fact that decisions (i.e., clusterings) should not be overly favorable to one group versus another.
This notion was formalized by Chierichetti et al.~\cite{chierichetti} for clustering when the protected attribute can take on one of two values, i.e., points have one of two colors.
In their setup, the \emph{balance} of a cluster is the ratio of the minimum to the maximum number of points of any color in the cluster. Given a balance requirement $t$, a clustering is fair if and only if each cluster has a balance of at least $t$.
\textit{Bounded representation.} A generalization of disparate impact, bounded representation focuses on mitigating the imbalance of the representation of protected classes (i.e., colors) in clusters and was defined by Ahmadian et al.~\cite{ahmadian}. Given an over-representation parameter $\alpha$, a cluster is fair if the \emph{fractional representation} of each color in the cluster is at most $\alpha$, and a clustering is fair if each cluster has this property.
An interesting special case of this notion is when there are $c$ total colors and $\alpha=1/c$. In this case, we require that every color is equally represented in every cluster. We will refer to this as \emph{equal representation}. These notions enjoy the following useful property:
\begin{definition}[Union-closed]
A fairness constraint is \emph{union-closed} if for any pair of fair clusters $A$ and $B$, $A\cup B$ is also fair.
\end{definition}
This property is useful in hierarchical clustering: given a tree $T$ and internal node $u$, if each child cluster of $u$ is fair, then $u$ must also be a fair cluster.
\begin{definition}[Fair hierarchical clustering]
For any fairness constraint, a \emph{hierarchical clustering is fair} if all of its clusters (besides the leaves) are fair.
\end{definition}
Thus, under any union-closed fairness constraint, this definition is equivalent to restricting the bottom-most clustering (besides the leaves) to be fair. Then given an objective (e.g., revenue), the goal is to find a fair hierarchical clustering that optimizes the objective. We focus on the bounded representation fairness notion with $c$ colors and an over-representation cap $\alpha$. However, the main ideas for the revenue and value objectives work under any notion of fairness that is union-closed.
\section{Optimizing revenue with fairness}\label{sec:rev}
This section considers the revenue objective. We will obtain an approximation algorithm for this objective in three steps: (i) obtain a fairlet decomposition such that the maximum fairlet size in the decomposition is small, (ii) show that any $\beta$-approximation algorithm to (\ref{eq:maxrevenue}) plus this fairlet decomposition can be used to obtain a (roughly) $\beta$-approximation for fair hierarchical clustering under the revenue objective, and (iii) use average-linkage, which is known to be a $\nicefrac{1}{3}$-approximation to (\ref{eq:maxrevenue}). (We note that the recent work~\cite{AhmadianBisect,YossiNogaHC} on improved approximation algorithms compare to a bound on the optimal solution that differs from (\ref{eq:maxrevenue}) and therefore do not fit into our framework.)
First, we address step (ii). Due to space, this proof can be found in~\refappendix{sec:thmproofsec}.
\begin{theorem} \label{thm:fair_moseley_wang}
Given an algorithm that obtains a $\beta$-approximation to (\ref{eq:maxrevenue}) where $\beta \leq 1$, and a fairlet decomposition with maximum fairlet size $m_f$, there is a $\beta \left(1-\frac{2m_f}{n}\right)$-approximation for fair hierarchical clustering under the revenue objective.
\end{theorem}
Prior work showed that average-linkage is a $\nicefrac{1}{3}$-approximation to (\ref{eq:maxrevenue}) in the vertex-unweighted case; this proof can be easily modified to show that it is still $\nicefrac{1}{3}$-approximation even with vertex weights. This accounts for step (iii) in our process.
Combined with the fairlet decomposition methods for the two-color case~\cite{chierichetti} and for multi-color case (Supplementary Material) to address step (i),
we have the following.
\begin{cor} \label{cor:revenue}
There is polynomial time algorithm that constructs a fair tree that is a $\frac{1}{3}\left(1-\frac{2m_f}{n}\right)$-approximation for revenue objective, where $m_f$ is the maximum size of fairlets.
\end{cor}
\iffalse
In this section the optimization function of interest is revenue (Definition~\ref{def:rev}). We show that any $\alpha$-approximation for revenue can be modified to maintain an asymptotic $\alpha$-approximation in many fairness settings. To do this, we will start by finding any fair clustering such that the maximum cluster size is small. After this, we simply proceed with the approximation algorithm. We will show the following.
\begin{theorem}
\label{thm:rev}
Given any fairlet decomposition that always produces fairlets of size $o(n)$ and any $\alpha$-approximation algorithm for optimizing revenue, we can design a $(\alpha-o(1))$-approximation algorithm for optimizing revenue with any union-closed fairness constraint.
\end{theorem}
All that remains is to find a fairlet decomposition with max fairlet size of $o(n)$. In the bounded representation setting, \cite{chierichetti} showed how to do this for $c=2$ colors and~\cite{rosner} showed how to do this for $c$ colors and $\alpha=1/c$. Thus we have the following.
\begin{cor}
Given any graph with either (i) only red and blue vertices or (ii) vertices colored with $c=o(n)$ colors and $\alpha=1/c$, and any $\alpha$-approximation algorithm for optimizing revenue, we can design a $(\alpha-o(1))$-approximation algorithm for optimizing revenue with any union-closed fairness constraint.
\end{cor}
We note that the current best approximation algorithm for revenue is \cite{charikar19}'s SDP solution, which achieves a $(1/3+\epsilon)$-approximation. Thus, as of this paper, all of these results are asymptotic $(1/3+\epsilon)$-approximations.
One of the most notable qualities of this algorithm is that it works for \textit{any} union-closed fairness constraint. In fact, in any situation where you must begin with some arbitrary small clustering, we can still maintain (asymptotically) \textit{any} approximation factor that we can otherwise achieve.
\fi
\section{Optimizing value with fairness}\label{sec:val}
In this section we consider the value objective. As in the revenue objective, we prove that we can reduce fair hierarchical clustering to the problem of finding a good fairlet decomposition for the proposed fairlet objective \eqref{obj:fairlet_obj}, and then use any approximation algorithm for weighted hierarchical clustering with the decomposition as the input.
\begin{theorem}
\label{thm:reduction}
Given an algorithm that gives a $\beta$-approximation to \eqref{eq:maxvalue} where $\beta\leq 1$, and a fairlet decomposition $\mathcal{Y}$ such that $\phi(\mathcal{Y}) \leq \epsilon \cdot d(V)$, there is a $\beta(1 - \epsilon)$ approximation for \eqref{eq:maxvalue}.
\end{theorem}
We complement this result with an algorithm that finds a good fairlet decomposition in polynomial time under the bounded representation fairness constraint with cap $\alpha$.
Let $R_1,\ldots,R_c$ be the $c$ colors and let $\mathcal{Y} = \{Y_1, Y_2 \ldots\}$ be the fairlet decomposition.
Let $n_i$ be the number of points colored $R_i$ in $V$. Let $r_{i, k}$ denote the number of points colored $R_i$ in the $k$th fairlet.
\begin{theorem}
\label{thm:localsearch}
There exists a local search algorithm that finds a fairlet decomposition $\mathcal{Y}$ with $\phi(\mathcal{Y}) \leq (1 +\epsilon) \max_{i,k} \frac{r_{i,k}}{n_i} d(V)$ in time $\tilde{O}(n^3 / \epsilon)$.
\end{theorem}
We can now use the fact that both average-linkage and the $\frac{\epsilon}{n}$-locally-densest cut algorithm give a $\frac{2}{3}$- and $(\frac{2}{3}-\epsilon)$-approximation respectively for vertex-weighted hierarchical clustering under the value objective. Finally, recall that fairlets are intended to be minimal, and their size depends only on the parameter $\alpha$, and not on the size of the original input. Therefore, as long as the number of points of each color increases as input size, $n$, grows, the ratio $r_{i,k}/n_i$ goes to $0$. These results, combined with Theorem \ref{thm:reduction} and Theorem \ref{thm:localsearch}, yield Corollary \ref{cor:main}.
\begin{cor} \label{cor:main}
Given bounded size fairlets, the fairlet decomposition computed by local search combined with average-linkage constructs a fair hierarchical clustering that is a $\frac{2}{3}(1-o(1))$-approximation for the value objective. For the $\frac{\epsilon}{n}$-locally-densest cut algorithm in \cite{cohenaddad}, we get a polynomial time algorithm for fair hierarchical clustering that is a $(\frac{2}{3}-\epsilon)(1-o(1))$-approximation under the value objective for any $\epsilon > 0$.
\end{cor}
Given at most a small fraction of every color is in any cluster, Corollary \ref{cor:main} states that we can extend the state-of-the-art results for value to the $\alpha$-capped, multi-colored constraint. Note that the preconditions will always be satisfied and the extension will hold in the two-color fairness setting or in the multi-colored equal representation fairness setting.
\paragraph{Fairlet decompositions via local search}
In this section, we give a local search algorithm to construct a fairlet decomposition, which proves Theorem \ref{thm:localsearch}. This is inspired by the $\epsilon$-densest cut algorithm of \cite{cohenaddad}. To start, recall that for a pair of sets $A$ and $B$ we denote by $d(A,B)$ the sum of interpoint distances, $d(A,B)=\sum_{u \in A, v \in B}d(u,v)$. A fairlet decomposition is a partition of the input $ \{Y_1, Y_2, \ldots \}$ such that each color composes at most an $\alpha$ fraction of each $Y_i$.
Our algorithm will recursively subdivide the cluster of all data to construct a hierarchy by finding cuts. To search for a cut, we will use a \textit{swap} method.
\begin{definition}[Local optimality] \label{def:ep_opt_decomp}
Consider any fairlet decomposition $\mathcal{Y} = \{Y_1, Y_2, \ldots \}$ and $\epsilon >0$. Define a \emph{swap} of $u \in Y_i$ and $v \in Y_j$ for $j\neq i$ as updating $Y_i$ to be $(Y_i \setminus \{u\}) \cup \{v\}$ and $Y_j$ to be $(Y_j \setminus \{v\}) \cup \{u\}$. We say $\mathcal{Y} $ is \emph{$\epsilon$-locally-optimal} if any swap with $u,v$ of the same color reduces the objective value by less than a $(1+\epsilon)$ factor.
\end{definition}
The algorithm constructs a $(\epsilon/n)$-locally optimal algorithm for fairlet decomposition, which runs in $\tilde{O}(n^3/\epsilon)$ time. Consider any given instance $(V, d)$. Let $d_{\max}$ denote the maximum distance, $m_f$ denote the maximum fairlet size, and $\Delta = d_{\max} \cdot \frac{m_f}{n}$. The algorithm begins with an arbitrary decomposition. Then it swaps pairs of monochromatic points until it terminates with a locally optimal solution. By construction we have the following.
\begin{claim}
\label{claim:fairdecomp}
Algorithm \ref{alg:eps_local_opt_decomp} finds a valid fairlet decomposition.
\end{claim}
We prove two things: Algorithm~\ref{alg:eps_local_opt_decomp} optimizes the objective (\ref{obj:fairlet_obj}), and has a small running time. The following lemma gives an upper bound on $\mathcal{Y}$'s performance for \eqref{obj:fairlet_obj} found by Algorithm~\ref{alg:eps_local_opt_decomp}.
\begin{algorithm}[t!]
\renewcommand{\algorithmicrequire}{\textbf{Input: }}
\renewcommand{\algorithmicensure}{\textbf{Output: }}
\caption{Algorithm for $(\epsilon/n)$-locally-optimal fairlet decomposition.}
\label{alg:eps_local_opt_decomp}
\begin{algorithmic}[1]
\REQUIRE A set $V$ with distance function $d \geq 0$, parameter $\alpha$, small constant $\epsilon \in [0,1]$.
\ENSURE An $\alpha$-capped fairlet decomposition $\mathcal{Y}$.
\STATE Find $d_{\max}$, $\Delta \leftarrow \frac{m_f}{n}d_{\max}$.
\STATE Arbitrarily find an $\alpha$-capped fairlet decomposition $\{Y_1, Y_2, \ldots \}$ such that each partition has at most an $\alpha$ fraction of any color.
\WHILE{$\exists u \in Y_i, v \in Y_j, i \neq j$ of the same color, such that for the decomposition $\mathcal{Y}'$ after swapping $u,v$, $\frac{\sum_{Y_k \in \mathcal{Y}}d(Y_k)}{\sum_{Y_k \in \mathcal{Y}'}d(Y_k)} \geq (1+\epsilon/n)$ {\bf{and}} $\sum_{Y_k \in \mathcal{Y}}d(Y_k) > \Delta$}
\STATE Swap $u$ and $v$ by setting $Y_i \gets (Y_i \setminus \{u\}) \cup \{v\}$ and $Y_j \gets (Y_j \setminus \{v\}) \cup \{u\}$.
\ENDWHILE
\end{algorithmic}
\end{algorithm}
\begin{lem}
\label{lem:algo_is_correct}
The fairlet decomposition $\mathcal{Y}$ computed by Algorithm \ref{alg:eps_local_opt_decomp} has an objective value for (\ref{obj:fairlet_obj}) of at most $(1+\epsilon)\max_{i,k}\frac{r_{i,k}}{n_i}d(V)$.
\end{lem}
Finally we bound the running time. The algorithm has much better performance in practice than its worst-case analysis would indicate. We will show this later in Section~\ref{sec:exp}.
\begin{lem}
\label{lem:algo_is_fast1}
The running time for Algorithm~\ref{alg:eps_local_opt_decomp} is $\tilde{O}(n^3/\epsilon)$.
\end{lem}
Together, Lemma~\ref{lem:algo_is_correct}, Lemma~\ref{lem:algo_is_fast1}, and Claim~\ref{claim:fairdecomp} prove Theorem~\ref{thm:localsearch}. This establishes that there is a local search algorithm that can construct a good fairlet decomposition.
\iffalse
Similar to our theorem for revenue, these results generalize to any union-closed constraint, but they are limited to only extend Average Linkage. At this point in time, however, this is the best approximation we can expect to achieve for value.
\begin{theorem}
Given any fairlet decomposition algorithm that always produces a decomposition of cost at most $o(\sum_{e\in E(G)} w(e))$, we can design a tight $(2/3 - o(1))$-approximation algorithm for optimizing value with any union-closed fairness constraint.
\end{theorem}
In addition to this result, we also show the tightness of Average Linkage's approximation generally (ie, with or without fairness constraints).
The fairlet prerequisite in this case is a bit more difficult to achieve. We can, at the very least, achieve this for the following constraint:
\begin{cor}
Given any graph with two of vertices and $\alpha=1/2$, we can design a tight $(2/3 - o(1))$-approximation algorithm for optimizing value with any union-closed fairness constraint.
\end{cor}
\fi | {'timestamp': '2020-06-22T02:09:01', 'yymm': '2006', 'arxiv_id': '2006.10221', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10221'} | arxiv |
\section{Introduction}
Compared to (simple) clustering data into $K$ clusters, hierarchical
clustering is much more complex and much less understood. One of the
few seminal advances in hierarchical clusterings is the
introduction by \cite{Dasgupta:16} of a general yet simple paradigm of
hierarchical clustering as loss minimization. This paradigm was
expanded by \cite{charikar:16} and \cite{royPokutta:hierarchical16}. The latter work also
introduces a new set of techniques for obtaining hierarchical
clusterings by showing that optimizing the loss can be relaxed to a
Linear Program (LP).
This paper introduces the first method to obtain optimality guarantees in the context of hierarchical clustering. Specifically, it is shown that the {\em Sublevel Set (SS)} paradigm invented by \cite{meila2018tell} for simple, non-hiearchical clustering, can be extended as well to hierarchical clustering. The main contribution is show that there is a natural distance between hierarchical clusterings whose properties can be exploited in the setting of the SS problem we will present in Section \ref{sec:ss}.
The Sublevel Set method produces {\em stability theorems} of the following form.
\begin{theorem}[Informal Stability Theorem] \label{thm:stabi} If a clustering ${\cal C}$ has low enough loss for a data set ${\cal D}$, then, subject to some conditions verifiable from the data, any other clustering ${\cal C}'$ that has lower or equql loss to ${\cal C}$ cannot
be more than $\epsilon$ different from ${\cal C}$.
\end{theorem}
When a stability theorem holds in practice, it means that ${\cal C}$ is not just a ``good'' clustering; ${\cal C}$ must be the only good clustering
supported by the data ${\cal D}$, up to small variations. This
property is called \mydef{stability}. It is obvious that, even though a Stability Theorem does not guarantee optimality, it implies that the optimal clustering of the data is within distance $\epsilon$ of ${\cal C}$. The value $\epsilon$ which bounds the amount of variaation in the above theorem, defines a ball of radius $\epsilon$ around ${\cal C}$ that contains all the good clusterings, including the optimal one. This ball is called an {\em optimality interval (OI)} and with a slight abuse we will also refer to its radius $\epsilon$ as an OI.
The main result of this paper is Theorem \ref{thm:ss} in Section
\ref{sec:ss} which will give an OI for hierarchical clustering in the
paradigm of \cite{Dasgupta:16}, along with a simple algorithm for
calculating the OI $\epsilon$, based on the LP relaxation of
\cite{royPokutta:hierarchical16}. We formally define the distance in
the space of hierarchical clusterings in which the OI is to be
measured in the next section.
\section{Preliminaries and a distance between hierarchical clusterings}
\label{sec:background}
\paragraph{A loss function for hierarchical clustering}
Let $n$ be the number of points to be clustered, and $T$ be a hierarchical clustering, or {\em tree} for short, whose leaves are the $n$ nodes. All trees have $n$ levels, and between one level and the level below, a single cluster is split into two non-empty sets; at level $t$, with $t=0:n-1$, there are $n-t$ clusters. A tree $T$ can be represented as a set of $n$ matrices $X(T)\equiv X=[x_{ij}^t]_{i,j=1:n}^{t=1:n-1}$. The variable $x_{ij}^T=1$ if nodes $i,j$ are separated at level $t$ of $T$, and 0 otherwise. The levels of the tree are numbered from the botton up, with 0 the level of all leaves ($x_{ij}^0\equiv 1$ implicitly), and the highest split at level $n-1$. Let $X^t=[x_{ij}^t]_{i,j=1:n}$ denote the matrix representing the clustering at level $t$. Each $X^t$ matrix is symmetric with 0 on the diagonal. Note also that $\sum_{t=1}^{n-1} x_{ij}^t = l_T(i,j)$, where $l_T$ is the path length from $i$ or $j$ to their {\em lowest common ancestor} ($\operatorname{lca}$).
Denote by $S\in{\mathbb R}^{n\times n}$ a symmetric matrix of similarities, such that $S_{ij}$ is the cost of {\em not} having $i,j$ together at any level in the clustering. The cost of a hierarchical clustering $T$ is the sum of the costs for each pair of nodes $i,j=1:n$, and each level $t$. It is assumed that $S_{ii}\equiv 0$ to simplify the algebraic expressions. This cost was introduced by \cite{Dasgupta:16} who showed that it has many interesting properties.
With the $X$ notation for a hierarchical clustering, the cost can be re-written as shown by \cite{royPokutta:hierarchical16}
\begin{equation}\label{eq:loss}
\ensuremath{\operatorname{Loss}}(S,X)=\sum_{i,j=1}^n\sum_{t=1}^{n-1} S_{ij}x_{ij}^t+\sum_{i,j=1}^nS_{ij}\;=\;\sum_{i,j=1}^nS_{ij}\left(\sum_{t=1}^{n-1}x_{ij}^t\right)+\sum_{i,j=1}^nS_{ij}.
\end{equation}
Note that the second term is a constant independent of the structure of $T$.
In \cite{royPokutta:hierarchical16} is it shown that minimizing $\ensuremath{\operatorname{Loss}}$ over hierarchical clusterings $X$ can be formulated as an Integer Linear Program, which can be relaxed as usual to a Linear Program (LP).
\paragraph{The Matrix Hamming distance between hierarchical clusterings}
For any two matrices $A,B\in{\mathbb R}^{n\times n}$, let $\langle A,B\rangle=\sum_{i,j=1}^na_{ij}b_{ij}$ denote the {\em Frobenius scalar product}, and $||A||^2_F=\langle A,A\rangle$ denote the {\em Frobenius norm}, squared. For two hierarchical clusterings $X,Y$, we define $\langle X,Y\rangle=\sum_{i,j=1}^n\sum_{t=1}^{n-1}x_{ij}^t y_{ij}^t=\sum_{t=1}^{n-1}\langle X^t,Y^t\rangle$. This is clearly a scalar product on the space of hierarchical clusterings, and
\begin{equation}
||X||^2_F\;=\;\langle X,X\rangle=\sum_{i,j=1}^n\sum_{t=1}^{n-1}(x_{ij}^t)^2\;=\;\sum_{i,j=1}^n\sum_{t=1}^{n-1}x_{ij}^t.
\end{equation}
The last equality holds because all $x_{ij}^t$ are either 0 or 1.
Moreover, in \cite{Dasgupta:16} it is proved that
\begin{equation}
\sum_{i,j=1}^n\sum_{t=1}^{n-1}x_{ij}^t\;=\; \tfrac{n^3-n}{3}.
\end{equation}
Therefore, we have the following simple results.
\begin{prop} \label{prop:xnorm} For any hierarchical clustering over $n$ points $X$, $\|X\|^2_F=\tfrac{n^3-n}{3}$.
\end{prop}
For any two binary matrices $A,B\in\{0,1\}^{n\times n}$, we define the {\em Matrix Hamming (MH) distance} $d_H(A,B)$ to be the number of entries in which $A$ differs from $B$, i.e. $d_H(A,B)=\sum_{i,j=1}^nA_{ij}\oplus B_{ij}$, where $\oplus$ denotes the exclusive-or Boolean operator. We further extend the MH distance to hierarchical clusterings by $d_H(X,Y)=\sum_{t=1}^{n-1}d_H(X^t,Y^t)$.
\begin{prop}\label{prop:dham} Let $X,Y$ be two hierarchical clusterings over $n$ points. Then $d_H(X,Y)=\|X-Y\|^2_F$.
\end{prop}
{\bf Proof}
\begin{eqnarray}
||X-Y||^2_F&=&||X||_F^2+||Y||_F^2-2\langle X,Y\rangle\\
&=&2\tfrac{n^3-n}{3}-2\langle X,Y\rangle\\
&=&\sum_{i,j=1}^n\sum_{t=1}^{n-1}\left(x_{ij}^t+y_{ij}^t-2x_{ij}^t y_{ij}^t\right)\\
&=&\sum_{i,j=1}^n\sum_{t=1}^{n-1}\left(x_{ij}^t \oplus y_{ij}^t\right)\\
&=&d_H(X,Y).\label{eq:dham} \hfill\Box
\end{eqnarray}
For simple, non-hierachical clusterings, $d_H$ is equivalent to the unadjusted Rand Index \cite{M:compare-jmva}. The (unadjusted) Rand Index has long been abandoned in the analysis of simple clusterings because, when the number of clusters $K$ is larger than 4 or 5, all ``usual'' clusterings appear very close under this distance. This was further formalized by \cite{M:compare-icml05}.
This disadvantage for simple clusterings may turn to be an advantage in the hierarchical setting. We expect that, for small values of the level $t$, near the leaves of the tree, $d_H$ will be very small w.r.t. the upper bound $n^2-n$. Indeed, for $t=1$, $X^1$ and $Y^1$ contain each one pair of merged points, hence $d_H(X^1,Y^1)=2$, whenever $X^1\neq Y^1$. Hence, in $d_H(X,Y)$, the levels of the cluster tree below the very top ones are strongly down-weighted, letting the top splits dominate the distance.
\section{Sublevel Set method}
\label{sec:ss}
Now we are ready to apply the SS method of \cite{meila2018tell} to a hierarchical clustering.
From Proposition \ref{prop:dham} it follows that maximizing $d_H(X,Y)$ is equivalent to minimizing $\langle X,Y\rangle$. Therefore, we can obtain a stability theorem and an OI as folows. Assume we have data $S$, a hierarchical clustering $T$, obtained by minimizing $\ensuremath{\operatorname{Loss}}(S,X)$ as well as possible. Hence we assume $X$ is fixed; $Y$ is any other arbitrary other clustering.
We define the following optimization problem, which we call a {\em Sublevel Set} problem.
\begin{eqnarray}
(SS)\quad \delta\; =&\min_{\,Y}&\langle X,Y\rangle\\
&\text{s.t.}&\ensuremath{\operatorname{Loss}}( S,Y)\leq \ensuremath{\operatorname{Loss}}( S,X) \label{eq:ss-sublevel}\\
&& y_{ij}^t\geq y_{ij}^{t+1},\text{ for all $t,i,j$}\label{eq:ss1}\\
&&y_{ij}^t+y_{jk}^t\geq y_{ik}^t,\text{ for all $t,i,j, k$}\label{eq:ss2}\\
&&\sum_{j\in S}x_{ij}^t \geq |S|-t,\text{ for } t,\, S\subseteq [n] \text{ with } |S|>t,\,i\in S \label{eq:ss-powerset}\\
&&x_{ij}^t\in[0,1],\text{ for all $t,i,j$}\label{eq:ss3}\\
&&x_{ij}^t=x_{ji}^t,\,x_{ii}^t=0,\text{ for all $t,i,j$}\label{eq:ss4}
\end{eqnarray}
The problem above maximizes $\|Y-X\|^2_F$ over a relaxed space of non-binary matrices $Y$ that satisfy contraints \eqref{eq:ss1}--\eqref{eq:ss4}; all matrices representing cluster trees also satisfy these constraints. Constraint \eqref{eq:ss-sublevel} restricts the feasible set to those $Y$ that have lower or equal cost to $X$, therefore this set is called a {\em sublevel set} for $\langle S,Y\rangle$. We note that $\ensuremath{\operatorname{Loss}}(S,Y)$ is linear in $Y$, therefore the (SS) problem is a Linear Program.
The Sublevel Set problem above follows the (LP-ultrametric) problem formulation from Section 4 of \cite{royPokutta:hierarchical16}, with the addition of the sublevel set constraint \eqref{eq:ss-sublevel} and replacing $S$ with with $X$ in the objective. Note that in \eqref{eq:ss-powerset} are an exponential number of constraints; \cite{royPokutta:hierarchical16} claim that the LP can still be optimized in poly$(n,\max \log S_{ij})$ operations. In \cite{meila2018tell} the SDPNAL software \cite{yang2015sdpnal} was used, and this software can also solve LPs.
\begin{theorem}[Stability Theorem for hierarchical clustering] \label{thm:ss} Let $S,X,n$ be defined as above, and let $\delta=\delta(S,X)$ be the optimal value of the (SS) problem. Then, any other clustering $Y$ with $\ensuremath{\operatorname{Loss}}(S,Y)\leq \ensuremath{\operatorname{Loss}}(S,X)$ satisfies $d_H(Y,X)\leq \epsilon$, with $\epsilon=2(\tfrac{n^3-n}{3}-\delta)$.
\end{theorem}
The proof of the Theorem is immediate from the constraint
\eqref{eq:ss-sublevel} and Propositions \ref{prop:xnorm} and
\ref{prop:dham}. In more detail, $Y^*$ the solution of (SS) may not
be an integer solution. However, the (SS) problem guarantees that for
any hierarchical clustering $Y$ that has $\ensuremath{\operatorname{Loss}}(S,Y)\leq \ensuremath{\operatorname{Loss}}(S,X)$,
$\langle X,Y\rangle \geq\langle X,Y^*\rangle \geq \delta$. From
Propositions \ref{prop:xnorm} and \ref{prop:dham}, it follows that
$d_H(X,Y)\leq \epsilon$. Hence, all good clusterings of the data must
be in a ball of radius $\epsilon$ from $X$, and
$\epsilon=2(\tfrac{n^3-n}{3}-\delta)$ gives an {\em Optimality
Interval} for $T$, in terms of Hamming distance.
The (SS) optimization problem can be solved numerically, to obtain $\epsilon$.
\begin{enumerate}
\item Given similarity matrix $S$, use a hierarchical clustering method to obtain a clustering $X$.
\item Compute $\ensuremath{\operatorname{Loss}}(S,X)$.
\item Set up and solve the (SS) problem by calling an LP solver. Let $\delta,Y^*$ be the optimal value and optimal solution of (SS).
\item Compute $\epsilon=2(\tfrac{n^3-n}{3}-\delta)$
\item[Output] The optimality interval $\epsilon$
\end{enumerate}
In \cite{M:equivalence-ML10} are formulas that bound the clustering {\em misclassification error distance} (also known as {\em earthmover's distance}) by the Matrix Hamming distance. They can be used to translate the $\epsilon$ bound into a bound on the more intuitive missclassification distance; this would come with a further relaxation of the bound.
\comment{What is this??
\begin{equation}
\sum_t(x_{ij}^t-y_{ij}^t)\;=\;d_{(T(X)}(i,j)-d_{(T(Y)}(i,j)
\quad
d_H(X,Y)\;=\;\sum_t d_H([x_{ij}^t], [y_{ij}^t])
\end{equation}
}
\section{Conclusion}
\label{sec:discussion}
In this paper we have used the SS method to develop an algorithm that outputs optimality guarantees, in the form Optimality Intervals in the metric space of hierarchical clusterings defined by the matrix Hamming distance $d_H$. Besides guaranteeing (sub)-optimality, the OI also guarantees stability, provided that it is small enough. In other words, when the OI is small, not only is the cost of the estimated clustering $X$ almost optimal, we are also guaranteed that there is no other very different way to partition the data that will give the same or better cost. Much remains still to be studied, in particular how small must $\epsilon$ be for the bound to be truly meaningful.
\section*{Acknowledgement}
The author acknowledges support from NSF DMS award 1810975. This work was initiated at the Simons Institute for Theoretical Computer Science during the time Meila was a long term visitor, and continued at the Institute for Pure and Applied Mathematics (IPAM). The author gratefully acknowledges a Simons Fellowship from IPAM, that made her stay during Fall 2019 possible.
\mmp{To see if levels can be weighted non-linearly. Can we use the same non-linearity in cost as in distance and does this make sense?}
\mmp{To think whether rounding the $Y^*$ can give us any benefit. I think no, unless we get a better $\delta$, guaranteed. Otherwise we can stay with the exact $\delta$ we have.}
\mmp{Roy and Pokutta have a more recent journal paper published in JMLR, which should be referenced instead of the NiPS paper.}
| {'timestamp': '2020-07-07T02:22:18', 'yymm': '2006', 'arxiv_id': '2006.10274', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10274'} | arxiv |
\section{Introduction}
Distributionally robust optimization (DRO) has received tremendous attention in machine learning due to its capability to handle noisy data, adversarial data and imbalanced classification data~\cite{rahimian2019distributionally,namkoong2017variance,chen2017robust}.
Given a set of observed data $\{\mathbf{z}_1, \ldots, \mathbf{z}_n\}$, where $\mathbf{z}_i = (\mathbf{x}_i, y_i)$, a DRO formulation can be written as:
\begin{align}\label{eqn:pd}
\min_{\mathbf{w}\in\mathbb{R}^d}\max_{\mathbf{p}\in\Delta_n}F_\mathbf{p}(\mathbf{w})= \sum_{i=1}^np_i\ell(\mathbf{w}; \mathbf{z}_i) - h(\mathbf{p}, \mathbf 1/n) + r(\mathbf{w}),
\end{align}
where $\mathbf{w}$ denotes the model parameter, $\Delta_n=\{\mathbf{p}\in\mathbb{R}^n: \sum_ip_i =1, p_i\geq 0\}$ denotes a $n$-dimensional simplex, $\ell(\mathbf{w}; \mathbf{z})$ denotes a loss function on data $\mathbf{z}$, $h(\mathbf{p}, \mathbf 1/n)$ is a divergence measure between $\mathbf{p}$ and uniform probabilities $\mathbf 1/n$, and $r(\mathbf{w})$ is convex regularizer of $\mathbf{w}$. When $\ell(\mathbf{w}; \mathbf{z})$ is a convex function (e.g., for learning a linear model), many stochastic primal-dual methods can be employed for solving the above min-max problem~\cite{nemirovski2009robust,juditsky2011solving,yan2019stochastic,yan2020sharp,namkoong2016stochastic}. When $\ell(\mathbf{w}; \mathbf{z})$ is a non-convex function (e.g., for learning a deep neural network), some recent studies also proposed stochastic primal-dual methods~\cite{rafique2018non,yan2020sharp}.
However, stochastic primal-dual methods for solving DRO problems with a non-convex $\ell (\mathbf{w};\mathbf{z})$ loss function (e.g., the predictive model is a deep neural network) suffer from several drawbacks. First, primal-dual methods need to maintain and update a high-dimensional dual variable $\mathbf{p}\in\mathbb{R}^n$ for large-scale data, whose memory cost is as high as $O(n)$ per-iteration.
Second, existing primal-dual methods usually need to sample data according to probabilities $\mathbf{p}$ in order to update $\mathbf{w}$, which brings additional costs than random sampling. Although random sampling can be used for computing the stochastic gradient in terms of $\mathbf{w}$, the resulting stochastic gradient could have $n$-times larger variance than using non-uniform sampling according to $\mathbf{p}$ {(please refer to the supplement for a simple illustration)}.
Third, due to the constraint on $\mathbf{p}\in\Delta_n$, the min-max formulation~(\ref{eqn:pd}) is not friendly to online learning in which the data is received sequentially and $n$ is rarely known in prior.
\ovalbox{\begin{minipage}[t]{0.95\columnwidth}%
\it Can we design an efficient online algorithm to address the DRO formulation~(\ref{eqn:pd}) without dealing with $\mathbf{p}\in\mathbb{R}^n$ {for a non-convex objective that is applicable to deep learning?}%
\end{minipage}}
\noindent
To address this question, we restrict our attention to a family of DRO problems, in which the KL divergence $h(\mathbf{p}, \mathbf 1/n)=\lambda\sum_i p_i\log(np_i)$ is used for regularizing the dual variables $\mathbf{p}$, where $\lambda>0$ is a regularization parameter. We note that this consideration does not impose strong restriction to the modeling capability. It has been shown that for a family of divergence functions $h(\mathbf{p}, \mathbf 1/n)$, different DRO formulations are statistically equivalent to a certain degree~\cite{duchi2016statistics}. The proposed method is based on an equivalent minimization formulation for $h(\mathbf{p}, \mathbf 1/n)=\lambda\sum_i p_i\log(np_i)$. In particular, by maximizing over $\mathbf{p}$ exactly,~(\ref{eqn:pd}) is equivalent to
\vspace{-0.1in}
\begin{align}
\label{eqn:cp-fs}
\min_{\mathbf{w}\in\mathbb{R}^d}&\Big\{F_{dro}(\mathbf{w}) = \lambda \log\left(1/n\sum_{i=1}^n\exp(\ell(\mathbf{w}; \mathbf{z}_i)/\lambda))\right)+ r(\mathbf{w})\Big\}.
\end{align}
In an online learning setting, we can consider a more general formulation:
\begin{align}\label{eqn:cp}
\min_{\mathbf{w}\in\mathbb{R}^d}\Big\{F_{dro}(\mathbf{w}) = \lambda \log\left(\mathbb{E}_{\mathbf{z}}\exp\left(\ell(\mathbf{w}; \mathbf{z})/\lambda\right)\right) + r(\mathbf{w})\Big\}.
\end{align}
The above problem is an instance of stochastic compositional problems of the following form:
\begin{equation}
\label{equ:p}
\begin{aligned}
\min\limits_{\mathbf{w}\in \mathbb{R}^d} F(\mathbf{w}) :=f(\mathbb{E}_{\mathbf{z}}[g_{\mathbf{z}}(\mathbf{w})]) + r(\mathbf{w}),
\end{aligned}
\end{equation}
by setting $f(s)=\lambda\log(s), s\geq 1$ and $g_\mathbf{z}(\mathbf{w}) = \exp(\ell(\mathbf{w};\mathbf{z})/\lambda)$. Stochastic algorithms have been developed for solving the above compositional problems.~\cite{wang2017stochastic} proposed the first stochastic algorithms for solving~(\ref{equ:p}), which are easy to implement. However, their sample complexities are sub-optimal for solving~(\ref{equ:p}). Recently, a series of works have tried to improve the convergence rate by using {advanced variance reduction techniques (e.g., SVRG~\cite{johnson2013accelerating}}, SPIDER~\cite{fang2018spider}, SARAH~\cite{nguyen2017sarah}). However, most of them require using {a mega mini-batch size in the order of $O(n)\ \text{or}\ O(1/\epsilon)\footnote{$\epsilon$ is either the objective gap accuracy $F(\mathbf{w}) -\min F(\mathbf{w})\leq \epsilon$ or the gradient norm square bound $\|\nabla F(\mathbf{w})\|^2\leq \epsilon$}$} {\bf at every iteration or many iterations} for updating $\mathbf{w}$, which {hinders their applications on large-scale problems}.
In addition, these algorithms usually use a constant step size, which may harm the generalization performance.
This paper aims to develop more practical stochastic algorithms for solving~(\ref{eqn:cp}) without suffering from the above issues in order to enable practitioners to explore the capability of DRO for deep learning with irregular data (e.g., imbalanced data, noisy data). To this end, we proposed an online stochastic method (COVER) and its restarted variant (RECOVER). We establish a state-of-the-art complexity of COVER for finding an $\epsilon$-stationary solution and a state-of-the-art complexity of RECOVER under a Polyak-\mathcal{L} ojasiewicz (PL) condition of the problem. PL condition has been widely explored for developing practical optimization algorithms for deep learning~\cite{yuan2019stagewise}.
Compared with other stochastic algorithms, the practical advantages of RECOVER are:
\begin{enumerate}
\item RECOVER is an online duality-free algorithm for addressing large-scale KL regularized DRO problem that is independent of the high dimensional dual variable $\mathbf{p}\in \mathbb{R}^n$, which makes it suitable for deep learning applications.
\item RECOVER also enjoys the benefits of stagewise training similar to existing stochastic methods for deep learning~\cite{yuan2019stagewise}, i.e., the step size is decreased geometrically in a stagewise manner.
\end{enumerate}
In addition, this paper also makes several important theoretical contributions for stochastic non-convex optimization, including
\begin{enumerate}
\item We establish a nearly optimal complexity for finding $\epsilon$-stationary point, i.e., $\|\nabla F(\mathbf{w})\|^{2}\leq \epsilon$, for a class of two-level compositional problems in the order of $\widetilde O(1/\epsilon^{3/2})$ without a large mini-batch size, which is better than existing results~\cite{wang2017stochastic,wang2017accelerating,ghadimi2020single,chen2020solving}.
\item We etablish an optimal complexity for finding $\epsilon$-optimal solution under an $\mu-$PL condition for a class of two-level compositional problems in the order of $O(1/(\mu\epsilon))$ without a large mini-batch size, which is better than existing results~\cite{zhang2019stochastic}.
\end{enumerate}
A theoretical comparison between our results and existing results is shown in Table~\ref{tab:comparision}. Empirical studies vividly demonstrate the effectiveness of RECOVER for deep learning on imbalanced data
\section{Related Work}
DRO has been extensively studied in machine learning~\cite{mohri2019agnostic,deng2020distributionally,qi2020simple}, statistics, and operations research~\cite{rahimian2019distributionally}. In~\cite{namkoong2017variance}, the authors proved that minimizing the DRO formulation with a quadratic regularization in a constraint form is equivalent to minimizing the sum of the empirical loss and a variance regularization defined on itself. Variance regularization can enjoy better generalization error compared with the empirical loss minimization~\cite{namkoong2017variance}, and was also observed to be effective for imbalanced data~\cite{namkoong2017variance,zhu2019robust}. Recently, \cite{duchi2016statistics} also establishes this equivalence for a broader family of regularization function $h(\mathbf{p}, \mathbf 1/n)$ including the KL divergence.
Several recent studies have developed stochastic primal-dual methods for solving DRO with a non-convex loss function $\ell(\mathbf{w}; \mathbf{z})$ assuming it is smooth or weakly convex~\cite{rafique2018non,lin2020gradient,arXiv:2001.03724, yan2020sharp}. \cite{rafique2018non} proposed the first primal-dual methods for solving weakly convex concave problems. For online problems, their algorithms for finding an $\epsilon$-stationary solution whose gradient norm square is less than $\epsilon$ have a sample complexity of $O(1/\epsilon^2)$ or $O(1/\epsilon^3)$ with or without leveraging the strong concavity of $h(\mathbf p, \mathbf 1/n)$ for finding an $\epsilon$-stationary point.
Recently Liu et al.~\cite{liu2019stochastic} proposed to leverage the PL condition of the objective function to improve the convergence for a non-convex min-max formulation of AUC maximization. Then, a PES-SGDA algorithm is proposed to solve a more general class of non-convex min-max problems by leveraging the PL condition \citep{guo2020fast}. Both \cite{liu2019stochastic} and \cite{guo2020fast} have used geometrically decreasing step sizes in a stagewise manner. However, their algorithms' complexity is in the order of $O(1/\mu^2\epsilon)$, which is worse than $O(1/\mu\epsilon)$ achieved in this paper. Similarly, \cite{yang2020global} also leveraged PL conditions to solve non-convex min-max problems and has a sample complexity of $O(1/\mu^2\epsilon)$. Nevertheless, the step size of their algorithm is decreased polynomially in the order of $O(1/t)$, which usually yields poor performance for deep learning.
\begin{table*}[t]
\centering
\caption{Summary of properties of state-of-the-art algorithms for solving our DRO problem.
The sample complexity is measured in terms of finding an $\epsilon$-stationary point w/o PL condition, i.e., $\|\nabla F(\mathbf{w})\|^{2}\leq \epsilon$, or achieving $\epsilon$-objective gap, i.e,
$F(\mathbf{w}) - \min_{\mathbf{w}}F(\mathbf{w}) \leq \epsilon$ with PL condition. $\widetilde{O}$ omits a logarithmic dependence over $\epsilon$. $n$ represents the size of datasets for a finite sum problem, $d$ denotes the dimension of $\mathbf{w}$. GDS represents whether the step size is geometrically decreased.
}\label{tab:comparision}
\scalebox{0.8}{\begin{tabular}{c|c|c|c|c|c|c} \hline
Settings & Algorithms & Sample Complexity & batch size & GDS $\eta$&\makecell{Memory\\ Cost} &Style\\ \hline
\multirow{4}{*}{w/o PL} & PG-SMD2~\cite{rafique2018non} & $ O(n/\epsilon + 1/\epsilon^{2})$ & $O(1) $ & x &$O(n+d)$ & Primal-Dual \\
& ASC-PG~\cite{wang2017accelerating} & $ O(1/\epsilon^{2})$ & $O(1)$ & x &$O(d)$ &Compositional\\
& CIVR ~\cite{zhang2019stochastic} & $ O(1/\epsilon^{3/2})$ & $ O(1/\epsilon) $ & x &$O(d)$ &Compositional\\
& \textbf{COVER} (This paper) & $ \widetilde O(1/\epsilon^{3/2})$ & $ O(1) $ & x & $O(d)$ &Compositional\\ \hline
\multirow{4}{*}{w/ PL} & Stoc-AGDA~\cite{yang2020global} & $O(1/\mu^{2}\epsilon)$ &$O(1)$ & x &$O(n+d)$&Primal-Dual \\
& PES-SGDA~\cite{guo2020fast} & $O(1/\mu^{2}\epsilon)$ &$O(1)$ & \checkmark &$O(n+d)$& Primal-Dual \\
& RCIVR~\cite{zhang2019stochastic} & $\widetilde{O}(1/\mu \epsilon)$ &$O(1/\epsilon)$ & x &$O(d)$& Compositional \\
& \textbf{RECOVER }(This paper) & \textcolor{red}{$O(1/\mu \epsilon)$ }& \textcolor{red}{$O(1)$} & \textcolor{red}{\checkmark} &\textcolor{red}{$O(d)$}&Compositional \\ \hline
\end{tabular}}
\end{table*}
All the methods reviewed above require maintaining and updating both the primal variable $\mathbf{w}$ and a high dimensional dual variable $\mathbf{p}\in \mathbb{R}^n$. Recently, Levy et al.~\citep{levy2020large} considered different formulations of DRO, which includes our considered KL-regularized DRO formulation as a special case. Their assumed that the loss function is convex and proposed a stochastic method with a sample complexity $O(1/\epsilon^3)$ for sovling the KL-regularized DRO formulation. In contrast, we provide a better sample complexity in the order of $O(1/\epsilon)$ under a PL condition without convexity assumption. Additionally, their method requires a large batch size in the order of $O(1/\epsilon)$, while our method only requires a constant batch size which is more practical.
We also notice that a recent work~\cite{li2020tilted} and its extended version~\cite{li2021tilted} have considered a formulation similar to~(\ref{eqn:cp-fs}) and proposed a stochastic algorithm. However, their algorithm has a slower convergence rate with an $O(1/\epsilon^2)$ complexity for finding an $\epsilon$-stationary point and an $O(1/(\mu^2\epsilon))$ complexity for finding an $\epsilon$-optimal solution under a PL condition. Our work is a concurrent work appearing online earlier than~\cite{li2020tilted}. To the best of our knowledge, this is the first work trying to solve the non-convex DRO problem with a duality-free stochastic method by formulating the min-max formulation into an equivalent stochastic compositional problem.
\noindent
There are extensive studies for solving stochastic compositional problems.~\cite{wang2017stochastic} considered a more general family of stochastic compositional problems and proposed two algorithms. When the objective function is non-convex, their algorithm's complexity is $O(1/\epsilon^{7/2})$ for finding an $\epsilon$-stationary solution. This complexity was improved in their later works~\cite{ghadimi2020single}, reducing to $O(1/\epsilon^2)$. When the objective is smooth, several papers proposed to use variance reduction techniques (e.g., SPIDER, SARAH) to improve the complexity for finding a stationary point~\cite{zhang2019stochastic, DBLP:conf/aaai/HuoGLH18,zhou2019momentum,DBLP:journals/corr/abs-1809-02505}. The best sample complexity achieved for online problems is $O(1/\epsilon^{3/2})$~\cite{zhang2019stochastic,zhou2019momentum}. ~\cite{zhang2019stochastic} also considered the PL condition for developing a faster algorithm called restarted CIVR, whose sample complexity is $O(1/\mu\epsilon)$. However, these variance reduction-based methods require using a very large mini-batch size at many iterations, which has detrimental influence on training deep neural networks~\cite{smith2018don}. To address this issue, ~\cite{cutkosky2019momentum} proposed a new technique called STORM that integrates momentum and the recursive variance reduction technique for solving stochastic smooth non-convex optimization. Their algorithm does not require a large mini-batch size at every iterations and enjoys a sample complexity of $O(\log^{2/3}(1/\epsilon)/\epsilon^{3/2})$ for finding an $\epsilon$-stationary point. However, their algorithm uses a polynomially decreasing step size, which is not practical for deep learning, and is not directly applicable to stochastic composite problems.
\section{Preliminaries}
In this section, we provide some definitions and assumptions for next section. For more generality, we consider the stochastic compositional problem~(\ref{equ:p}):
\begin{equation}
\label{eqn:p}
\begin{aligned}
\min\limits_{\mathbf{w}\in \mathbb{R}^d} F(\mathbf{w}) :=f(\mathbb{E}_{\mathbf{z}}[g_{\mathbf{z}}(\mathbf{w})]) + r(\mathbf{w})
\end{aligned}
\end{equation}
where $g_\mathbf{z}(\mathbf{w}): \mathbb{R}^d\rightarrow \mathbb{R}^p$. Define $g(\mathbf{w}) = \mathbb{E}_{\mathbf{z}}[g_\mathbf{z}(\mathbf{w})]$. Let $\|\cdot\|$ denote the Euclidean norm of a vector or the Frobenius norm of a matrix. We make the following standard assumptions regarding the problem~(\ref{eqn:p}).
\begin{ass} Let $C_f, L_f, C_g$ and $L_g$ be positive constants. Assume that
\label{ass:1}
\begin{enumerate}
\item[(a)] $f:\mathbb{R}^p \rightarrow \mathbb{R}$ is a $C_f$-Lipschitz function and its gradient $\nabla f$ is $L_f$-Lipschitz.
\vspace{-0.05in}
\item[(b)] $g_\mathbf{z}:\mathbb{R}^d\rightarrow \mathbb{R}^p$ satisfies $\mathbb{E}\|g_\mathbf{z}(\mathbf{w}_1) -g_\mathbf{z}(\mathbf{w}_2)\|^2]\leq C^2_g\|\mathbf{w}_1-\mathbf{w}_2\|^2$ for any $\mathbf{w}_1,\mathbf{w}_2$ and its Jacobian $\nabla g_\mathbf{z}$ satisfies $\mathbb{E}[\|\nabla g_\mathbf{z}(\mathbf{w}_1) - \nabla g_\mathbf{z}(\mathbf{w}_2)\|^2]\leq L_g^2\|\mathbf{w}_1 - \mathbf{w}_2\|^2$.
\vspace{-0.05in}
\item[(c)] $r: R^d\rightarrow \mathbb{R} \cup \{\infty\}$ is a convex and lower-semicontinuous function.
\vspace{-0.05in}
\item[(d)] $F_* = \inf_{\mathbf{w}} F(\mathbf{w}) \geq -\infty$ and $F(\mathbf{w}_1) - F_* \leq \Delta_F $ for the initial solution $\mathbf{w}_1$.
\end{enumerate}
\end{ass}
{\bf Remark:} When $f(s)=s$ is a linear function, the assumption $\mathbb{E}\|g_\mathbf{z}(\mathbf{w}_1) -g_\mathbf{z}(\mathbf{w}_2)\|^2]\leq C^2_g\|\mathbf{w}_1-\mathbf{w}_2\|^2$ is not needed. To upper bound continuity and smoothness of function $F$, we denote $L = 2\max\{ L_gC_gL_f, C_fC_gL_f, C_f^2,L_gC_f, C_g^2L_f, C_f, C_gL_f$, $C_f^2, C_g^2, C_g^2L_f^2\}$ for simple derivation in the appendix.
\begin{ass}
\label{ass:2}
Let $\sigma_g$ and $\sigma_{g'}$ be positive constants and $\sigma^2 = \sigma_g^2 + \sigma_{g'}^2$. Assume that
\begin{equation*}
\begin{aligned}
&\mathbb{E}_\mathbf{z}[\| g_\mathbf{z}(\mathbf{w}) - g(\mathbf{w})\|^2] \leq \sigma_g^2,\ \mathbb{E}_\mathbf{z}[\| \nabla g_\mathbf{z}(\mathbf{w}) - \nabla g(\mathbf{w})\|^2] \leq \sigma_{g'}^2.
\end{aligned}
\end{equation*}
\end{ass}
\vspace*{-0.1in}
{\bf Remark:} We remark how the minimization formulation of DRO problem~(\ref{eqn:cp}) can satisfy Assumption~\ref{ass:1}, in particular Assumption~\ref{ass:1}(a) and (b). In order to satisfy Assumption~\ref{ass:1}(b), we can define a bounded loss function $\ell(\mathbf{w}, \mathbf{z})\in[0, \ell_{\max}]$ and then use a shifted loss $\ell(\mathbf{w}; \mathbf{z}) - \ell_{\max}$ in~(\ref{eqn:cp}). Then $g_\mathbf{z}(\mathbf{w}) = \exp((\ell(\mathbf{w}; \mathbf{z}) - \ell_{\max})/\lambda)$ is Lipchitz continuous and smooth if $\ell(\mathbf{w}; \mathbf{z})$ is Lipchitz and smooth. $f(s) = \lambda\log(s)$ is Lipschitz continuous and smooth since $s\geq \exp(-\ell_{\max}/\lambda)$.
For more generality, we allow for a non-smooth regularizer $r(\cdot)$ in this section. To handle non-smoothness of $r$, we can use the proximal operator of $r$:
$ \textbf{prox}^{\eta}_r(\bar\mathbf{w}) = \arg\min_{\mathbf{w}}\frac{1}{2}\|\mathbf{w} - \bar\mathbf{w}\|^2 + \eta r(\mathbf{w})$.
When $r=0$, the above operator reduces to the standard Euclidean projection. Correspondingly, we define the proximal gradient measure for the compositional problem~(\ref{eqn:p}):
\begin{align*}
\mathcal G_{\eta}(\mathbf{w}) = \frac{1}{\eta}(\mathbf{w} - \textbf{prox}^{\eta}_r(\mathbf{w} - \eta\nabla g(\mathbf{w})^{\top}\nabla f(g(\mathbf{w}))) ).
\end{align*}
When $r=0$, the proximal gradient reduces to the standard gradient measure, i.e., $\mathcal G_{\eta}(\mathbf{w}) = \nabla F(\mathbf{w})$. To facilitate our discussion, we define sample complexity below.
\begin{defi}
The {\bf sample complexity} is defined as the number of samples $\mathbf{z}$ in order to achieve $\mathbb{E}[\|\mathcal G_{\eta}(\mathbf{w})\|^2]\leq \epsilon$ for a certain $\eta>0$ or $\mathbb{E}[F(\mathbf{w}) - F_*]\leq \epsilon$.
\end{defi}
\section{Basic Algorithm: COVER}
\label{sec:COVER}
We present our Algorithm~\ref{alg:COVER},which serves as the foundation for proving the the convergence of the objective gap under a PL condition in next section. The convergence results in this section might be of independent interest to those who are interested in convergence analysis without a PL condition. The motivation is to develop a stochastic algorithm with fast convergence in terms of gradient norm. We refer to the algorithm as Compositional Optimal VariancE Reduction (COVER). It will be clear shortly why it is called optimal variance reduction. Note that in order to compute a stochastic estimator of the gradient $f(g(\mathbf{w}))$ given by $\nabla g(\mathbf{w})^{\top}\nabla f(g(\mathbf{w}))$, we maintain and update two estimators denoted by $\{\mathbf{u}\}_{t=1}^T$ and $\{\mathbf{v}\}_{t=1}^T$ sequence, respectively. The $\{\mathbf{u}_{t}\}_{t=1}^T$ sequence maintains an estimation of $\{g(\mathbf{w}_{t})\}_{t=1}^T$ and the $\{\mathbf{v}_{t}\}_{t=1}^T$ sequence maintains an estimation of $\{\nabla g(\mathbf{w}_{t})\}_{t=1}^T$. The strategy of maintaining and updating two individual sequences was first proposed in~\cite{wang2017stochastic} and has been widely used for solving compositional problems~\cite{zhou2019momentum, zhang2019stochastic}. However, the key difference from previous algorithms lies in the method for updating the two sequences. COVER is inspired by the STROM technique~\cite{cutkosky2019momentum}. To understand the update,
let us consider update that applied to the DRO problem~(\ref{eqn:cp}) by let $f(\cdot) = \lambda \log(\cdot)$, $g_\mathbf{z}(\cdot) = \exp(\frac{\ell(\cdot;\mathbf{z})}{\lambda})$ and ignoring $r$ for the moment. Plugging the gradient of $f(\cdot)$ and $g_\mathbf{z}(\cdot)$, we have
\begin{align*}
\mathbf{w}_{t+1} &= \mathbf{w}_t - \eta_t\frac{1}{u_t}\widetilde\mathbf{v}_t,\\
\widetilde\mathbf{v}_{t+1} = \exp(\frac{\ell(\mathbf{w}_{t+1};\mathbf{z}_{t+1})}{\lambda})\nabla\ell(\mathbf{w}_{t+1};\mathbf{z}_{t+1}) &+ (1-a_{t+1})(\widetilde\mathbf{v}_t -\exp(\frac{\ell(\mathbf{w}_{t};\mathbf{z}_{t+1})}{\lambda})\nabla\ell(\mathbf{w}_{t};\mathbf{z}_{t+1})),
\end{align*}
where $u_t$ becomes a scalar, which is an online variance-reduced estimator of $\mathbb{E}_{\mathbf{z}}[\exp(\ell(\mathbf{w}_t; \mathbf{z})/\lambda)]$, and $\widetilde\mathbf{v}_t$ is a scaled version of $\mathbf{v}_t$, which is an online variance-reduced estimator of $\mathbb{E}_{\mathbf{z}}[\exp(\ell(\mathbf{w}_t; \mathbf{z})/\lambda)\nabla\ell(\mathbf{w}_t; \mathbf{z})]$.
Finally, we notice that a similar method for updating the $\mathbf{u}_t$ sequence for estimating $g(\mathbf{w}_t)$ has been adopted in a recent work~\cite{chen2021solving}. However, different from the present work they just use an unbiased stochastic gradient to estimate $\nabla g(\mathbf{w}_t)$, which yields a worse convergence rate.
\begin{algorithm}[t]
\centering
\caption{COVER ($ \mathbf{w}_1, \mathbf{u}_1, \mathbf{v}_1, \{\eta_t\}, T, \text{PL} = \text{False}) $}\label{alg:COVER}
\begin{algorithmic}[1]
\STATE Let $a_t=c\eta_t^2$
\IF{not PL}
\STATE Draw a samples $\mathbf{z}$ and construct the estimates:
$\mathbf{u}_1 =g_{\mathbf{z}}(\mathbf{w}_1), \ \mathbf{v}_1=\nabla g_{\mathbf{z}}(\mathbf{w}_1)$
\ENDIF
\FOR {$t = 1,\ldots, T - 1$}
\STATE $\mathbf{w}_{t+1}\leftarrow \textbf{prox}^{\eta_t}_r(\mathbf{w}_t-\eta_t\mathbf{v}_t^\top\nabla f(\mathbf{u}_t))$
\STATE Draw a samples $\mathbf{z}_{t+1}$, and update
$$\mathbf{u}_{t+1} = g_{\mathbf{z}_{t+1}}(\mathbf{w}_{t+1}) + (1-a_{t+1})(\mathbf{u}_t - g_{\mathbf{z}_{t+1}}(\mathbf{w}_t))$$
$$\mathbf{v}_{t+1} = \nabla g_{\mathbf{z}_{t+1}}(\mathbf{w}_{t+1}) + (1-a_{t+1})(\mathbf{v}_t - \nabla g_{\mathbf{z}_{t+1}}(\mathbf{w}_t)) $$
\ENDFOR
\STATE \textbf{Return:} ($\mathbf{w}_\tau, \mathbf{u}_\tau, \mathbf{v}_\tau$) for randomly selected $\tau\in\{1, \ldots, T\}$.
\end{algorithmic}
\end{algorithm}
\subsection{Convergence of Proximal Gradient}
In this section, we present the convergence result of COVER.
\begin{thm}
\label{thm:2}
Assume the Assumption~\ref{ass:1} and~\ref{ass:2}, for any $C>0$, $k = \frac{C\sigma^{2/3}}{L}$, $c = 128L + \sigma^2/(7Lk^3)$, $w = \max ((16Lk^3), 2\sigma^2, (\frac{ck}{4L})^3)$, and $\eta_t = k/(w+\sigma^2t)^{1/3}$.
The output of COVER satisfies
\begin{equation}
\begin{aligned}
\mathbb{E}[\|\mathcal{G}_{\eta_{t^*}}(\mathbf{w}_{t_*})\|^2] & \leq \widetilde O\left(\frac{\Delta_F}{T^{2/3}} + \frac{\sigma^2}{T^{2/3}}\right)
\end{aligned}
\end{equation}
where $t_*$ is sampled from $\{1, \ldots, T\}$
\end{thm}
\textbf{Remark:}
Theorem~\ref{thm:2} implies that with a polynomially decreasing step size, COVER is able to find an $\epsilon$-stationary point, i.e., $\mathbb{E}[\|\mathcal{G}_{\eta_{t^*}}(\mathbf{w}_{t_*})\|^2]\leq \epsilon$ for a regularized objective and $\mathbb{E}[\|\nabla F(\mathbf{w})\|^2] \leq \epsilon$ for a non-regularized objective, with a near-optimal sample complexity $\widetilde O(\frac{1}{\epsilon^{3/2}})$. Note that the complexity $\widetilde O(1/\epsilon^{3/2})$ is optimal up to a logarithmic factor for making the (proximal) gradient's norm smaller than $\epsilon$ in expectation for solving non-convex smooth optimization problems~\cite{arjevani2019lower}.
\section{A Practical Variant (RECOVER) under a PL condition}\label{sec:main}
The issue of COVER is that the polynomially decreasing step size is not practical for deep learning applications and obstacles its generalization performance~\cite{yuan2019stagewise}. A stagewise step size is widely and commonly used~\cite{he2016deep,krizhevsky2012imagenet,yuan2019stagewise} for deep learning optimization. To this end, we develop a multi-stage REstarted version of COVER, called RECOVER, which uses a geometrically decreasing step size in a stagewise manner.
In oder to analyze RECOVER, we assume the following PL condition of the objective with a smooth regularization $r$ term~\cite{yuan2019stagewise}.
\begin{ass}
\label{ass:PL}
$F(\mathbf{w})$ satisfies the $\mu$-PL condition if there exists $\mu>0$ such that
\begin{equation}
\label{eqn:PL}
\begin{aligned}
2\mu(F(\mathbf{w}) -\min\limits_{\mathbf{w}\in \mathbb{R}^d}F(\mathbf{w}))\leq \|\nabla F(\mathbf{w})\|^2.
\end{aligned}
\end{equation}
\end{ass}
In the following, we simply consider the objective $F(\mathbf{w}) = f(\mathbb{E}_{\mathbf{z}}[g_\mathbf{z}(\mathbf{w})])$, where $r(\cdot)$ is absorbed into $f(\mathbb{E}_\mathbf{z}[g_\mathbf{z}(\mathbf{w})])$.
As a result, $\mathcal{G}_{\eta}(\mathbf{w}) = \nabla F(\mathbf{w})$.
Although the PL condition has been considered in various papers for developing stagewise algorithms and improving the convergence rate of non-convex optimization~\cite{zhang2019stochastic,yuan2019stagewise,liu2019stochastic,guo2020fast}. In order to establish the improved rate, we have innovations in twofold (i) at the algorithmic level, we utilize the variance reduction techniques at the inner and outer level without using mega large mini-batch size at any iterations; (ii) at the analysis level, we innovatively prove that the estimation error of the two sequences, $\mathbf{u}$ and $\mathbf{v}$, are decreasing geometrically after a stage (Lemma 3). These innovations at two levels yield the optimal convergence rate in the order of $O(1/(\mu\epsilon))$.
\subsection{Theoretical Verification of PL Assumption for KL-regularized DRO}
Before presenting the proposed algorithm and its convergence, we discuss how the $F_{dro}$ can satisfy Assumption~\ref{ass:PL}. First, we note that a PL condition of the weighted loss implies that of the primal objective.
\begin{lem}
Let $F_\mathbf{p}(\mathbf{w}) = \sum_{i=1}^n p_i \ell(\mathbf{w}; \mathbf{z}_i) $. If for any $\mathbf{p}\in\Delta_n$, $F_\mathbf{p}(\mathbf{w})$ satisfies a $\mu$-PL condition, then $F_{dro}(\mathbf{w}) = \lambda\log(\frac{1}{n}\sum_i\exp(\ell(\mathbf{w}; \mathbf{z}_i)/\lambda))$ satisfies the $\mu$-PL condition.
\label{lem:pl_dro_1}
\end{lem}
{\bf Remark:} The assumption that the weighted loss satisfies a PL condition can be proven for a simple square loss $\ell(\mathbf{w}; \mathbf{z}_i)= (\mathbf{w}^{\top}\mathbf{x}_i - y_i)^2$, where $\mathbf{z}_i=(\mathbf{x}_i, y_i)$ consists of a feature vector $\mathbf{x}_i$ and a label $y_i$. In order to see this, we can write $F_p(\mathbf{w}) = \sum_{i=1}^n(\mathbf{w}^{\top}\mathbf{x}_i\sqrt{p_i} - y_i\sqrt{p_i})^2 = \|A\mathbf{w} - \mathbf{b}\|^2 $, where $A=(\mathbf{x}_1\sqrt{p_1}, \ldots, \mathbf{x}_n\sqrt{p_n})^{\top}, \mathbf{b}=(y_1\sqrt{p_1}, \ldots, y_n\sqrt{p_n})^{\top}$. It has been shown in many previous studies that such $F_\mathbf{p}(\mathbf{w})$ satisfies a PL condition~\cite{DBLP:conf/icml/XuLY17,DBLP:journals/jmlr/YangL18,RePEc:cor:louvrp:3000}. Hence, the above lemma indicates $F_{dro}(\mathbf{w})$ satisfies a PL condition.
We can also justify that $F_{dro}(\mathbf{w})$ satisfies a PL condition for deep learning with ReLU activation function in a neighborhood around a random initialized point following the result in~\cite{allen2018convergence}.
\begin{lem}
Assume that input $\{(\mathbf{x}_1, y_1),\ldots, (\mathbf{x}_n, y_n)\}$ satisfies $\|\mathbf{x}_i\|=1$ and $\|\mathbf{x}_i - \mathbf{x}_j\|\geq \delta$, where $\mathbf{x}_n\in\mathbb{R}^{d_1}$, $y_i\in\mathbb{R}^{d_0}$ and $\|y_i\| \leq O(1)$. Consider a deep neural network with $h_{i,0} = \phi(A\mathbf{x}_i), h_{i,l} = \phi(W_lh_{i, l-1}), l=1,\ldots, \tilde{L}, \hat y_i = Bh_{i,\tilde{L}}$ where $A\in\mathbb{R}^{d_2 \times d_1}$ $W_l\in \mathbb{R}^{d_2\times d_2}$, $B\in \mathbb{R}^{d_0\times d_2}$, $\phi$ is the ReLU activation function, and $\ell(W; \mathbf{z}_i) = (\hat y_i - y_i)^2$ is a square loss. Suppose that for any $W$, $p_i^* = \exp(\ell(W; \mathbf{z}_i)/\lambda)/\sum_{i=1}^n\exp(\ell(W; \mathbf{z}_i)/\lambda)\geq p_0>0$, then with a high probability over randomness of $W_0, A, B$ for every $W$ with $\|W - W_0\|\leq O(1/\text{poly}(n,\tilde{L},p_0^{-1},\delta^{-1})$, there exists a small $\mu>0$ such that $\|\nabla F_{dro}(W)\|_F^2 + O(\epsilon)\geq \mu (F_{dro}(W) - \min_{W}F_{dro}(W))$.
\label{lem:pl_dro_2}
\end{lem}
{\bf Remark: } The $O(\epsilon)$ term in the left side of the PL condition is caused by using the covering net argument for proving the high probability result. Nevertheless, it does not affect the final convergence rate.
\subsection{Theoretical Analysis of RECOVER}
Now, we are ready to present the proposed algorithm under the PL condition and its convergence result. The algorithm is described in Algorithm~\ref{alg:RECOVER}.
The first key feature of RECOVER is equipped with the practical geometrical decreases step size between stages. At each stage, we adopt a constant step size $\eta_k$ rather than the polynomial decreases step size used by COVER as in Theorem~\ref{thm:2}.
Another key feature of RECOVER is that it uses not only $\mathbf{w}_k$ for restarting but also $\mathbf{u}_k,\mathbf{v}_k$, the corresponding online estimator of $g(\mathbf{w}_k)$ and $\nabla g(\mathbf{w}_k)$, for restarting the next stage.
It is this feature that allows us to avoid the large batch size required in other variance reduction methods to achieve the optimal sample complexity. With this feature, we can show that the variance of $\mathbf{u}_k,\mathbf{v}_k$ is decreased by a constant factor stagewisely as shown in the following lemma.
\begin{lem}
\label{lem:stage-variance}
Define constants $\epsilon_1=\frac{c^2 \sigma^2}{64 \mu L^3}$ and $\epsilon_k=\epsilon_1/2^{k-1}$, with $\eta_k =\min \{ \frac{\sqrt{\mu \epsilon_k} L}{2 c\sigma}, \frac{1}{16L}\}$, $T_k = O(\max \{\frac{96 c\sigma}{\mu^{3/2}\sqrt{\epsilon_k}L}, \frac{16c^2\sigma^2}{\mu L^2 \epsilon_k}, \frac{\Delta_F}{\sigma^2}\})$,
the variance of the stochastic estimator of Algorithm~\ref{alg:RECOVER} at $\mathbf{w}_{k}$ satisfies:
\begin{equation}
\begin{aligned}
\mathbb{E}[ \|\mathbf{u}_{k} -g(\mathbf{w}_{k}))\|^2+\|\mathbf{v}_{k} -\nabla g(\mathbf{w}_{k}))\|^2] \leq \mu\epsilon_{k}.
\end{aligned}
\end{equation}
\end{lem}
With the above lemma and the convergence bound for $\mathbb{E}[\|\nabla F(\mathbf{w}_k)\|^2]$ at the $k$-th stage, we can show that the objective gap $\mathbb{E}[F(\mathbf{w}_k) - F_*]$ is decreased by a factor of $2$ after each stage under the PL condition. Hence, we have the following convergence for RECOVER.
\begin{thm}\label{thm:main}
Assume that assumption~\ref{ass:1},\ref{ass:2},\ref{ass:PL} hold. Define constants $\epsilon_1=\frac{c^2 \sigma^2}{64 \mu L^4}$ and $\epsilon_k=\epsilon_1/2^{k-1}$. By setting $\eta_k =\min \{ \frac{\sqrt{\mu \epsilon_k}L}{2 c\sigma}, \frac{1}{16L}\}$, $T_k = O(\max \{\frac{96 c\sigma}{\mu^{3/2}\sqrt{\epsilon_k}L}, \frac{2c^2\sigma^2}{\mu L^2 \epsilon_k}, \frac{\Delta_F}{\sigma^2}\})$, $c = 104L^2$, then after $K=O(\log(\epsilon_1/\epsilon))$ stages, the output of RECOVER satisfies $\mathbb{E}[F(\mathbf{w}_K) - F_*]\leq \epsilon$.
\end{thm}
{\bf Remark: }
It is not difficult to derive the sample complexity of RECOVER is $O(\max \{\frac{1 }{\mu^{3/2}\sqrt{\epsilon}}, \frac{1}{\mu\epsilon}))=O(\frac{1}{\mu\epsilon})$ for $\epsilon\leq \mu$. It is notable this complexity is optimal for the considered general stochastic compositional problem, which includes stochastic strongly convex optimization as a special case, whose lower bound is $O(1/(\mu\epsilon))$~\cite{hazan2014beyond}.
In addition, it is notable that the proposed multi-stage algorithm is very different from many other multi-stage algorithms for non-convex optimization that are based on the proximal point framework~\cite{chen2018universal, yan2020sharp,rafique2018non,guo2020fast}. In particular, in these previous studies, a quadratic function $\gamma/2\|\mathbf{w} - \mathbf{w}_{k-1}\|^2$ with an appropriate regularization parameter $\gamma$ is added into the objective function at the $k$-th stage in order to convextify the objective function. In RECOVER, no such regularization is manually added. Nevertheless, we can still obtain strong convergence guarantee.
\begin{algorithm}[t]
\centering
\caption{RECOVER($\mathbf{w}_0, \epsilon_{0} ,c$)}
\label{alg:RECOVER}
\begin{algorithmic}[1]
\STATE \textbf{Initialization}: Draw a sample $\mathbf{z}_0$ and construct the estimates
$\mathbf{u}_0 =g_{\mathbf{z}_0}(\mathbf{w}_0), \ \mathbf{v}_0=\nabla g_{\mathbf{z}_0}(\mathbf{w}_0)$
\FOR {$k = 1,\ldots,K$}
\STATE \hspace*{-0.1in}$(\mathbf{w}_k, \mathbf{u}_k,\mathbf{v}_k)$ = COVER($\mathbf{w}_{k-1}, \mathbf{u}_{k-1}, \mathbf{v}_{k-1}, \eta_k, T_k, \text{True}$)
\STATE \hspace*{-0.1in}change $\eta_k, T_k$ according to Theorem~\ref{thm:main}
\ENDFOR
\STATE \textbf{Return:} $\mathbf{w}_K
\end{algorithmic}
\end{algorithm}
\section{Experimental Results}
We focus on the task of classification with imbalanced data in our experiments.
Firstly, we compare RECOVER with five State-Of-The-Art (SOTA) baselines from two categories: (i) primal-dual algorithms for solving the primal-dual formulation of DRO~(\ref{eqn:pd}), and (ii) algorithms that are designed for the stochastic compositional formulation of DRO~(\ref{eqn:cp}). Secondly, we verify the advantages of DRO over Emperical Risk Minimization (ERM) for imbalanced data problems by comparing the test accuracy learned by optimizing DRO using RECOVER and optimizing ERM using SGD on the imbalanced datasets. Then we show the RECOVER is also an effective fine-tuning algorithm for large-scale imbalanced data training. The code for reproducing the results is released here~\cite{code}.
\subsection{Comparison with SOTA DRO Baselines}
\label{sec:SOTA}
We compare RECOVER with five baselines: Restarted CIVR~\cite{zhang2019stochastic} (RCIVR), ASC-PG~\cite{wang2017accelerating}, Stoc-AGDA~\cite{yang2020global}, PG-SMD2~\cite{rafique2018non} and PES-SGDA~\cite{guo2020fast}.
RCIVR and ASC-PG are the state-of-the-art algorithms for solving stochastic compositional problems.
RCVIR uses variance reduction techniques and leverages the PL condition, while ASC-PG does neither. Stoc-AGDA and PG-SMD2 are the primal-dual algorithms with and without leveraging the PL condition explicitly, respectively. PES-SGDA is a variant of PG-SMD2 and was proposed by leveraging the PL condition for achieving faster convergence. Please note that ASC-PG and Stoc-AGDA use polynomially decreasing step sizes, RECOVER, PG-SMD2 and PES-SGDA use stagewise decreasing step size, and RCIVR uses a constant step size. The parameters of each algorithm are appropriately tuned for the best performance. All the algorithms are implemented using Pytorch and run on GeForce GTX 1080 Ti GPU.
We conduct experiments on four datasets, namely STL10 \cite{DBLP:journals/jmlr/CoatesNL11}, CIFAR10, CIFAR100 \cite{krizhevsky2009learning}, and iNaturalist2019~\cite{wittmann2019using}. The original STL10, and CIFAR10, CIFAR100 are balanced data, where STL10 has 10 classes and each class has 500 training images, CIFAR10 (resp. CIFAR100) has 10 (resp. 100) classes and each class has 5K (resp. 500) training images. For STL10, CIFAR10 and CIFAR100, we artificially construct imbalanced training data, where we only keep the last 100 images of each class for the first half classes. iNaturallist2019 itself is an imbalanced dataset that contains 265,213 images with 1010 classes. We train ResNet-20 on STL10, CIFAR10, CIFAR100, and Inception-V3 on iNaturalist2019.
For fair comparison, we use the same constant batch size $b$ for all methods except for RCIVR in which the inner loop batch size $b'$ and outer loop batch size $B_k$ are hyperparameters that relate to convergence. We use the constant batch size $b$ = 128 on CIFAR10, CIFAR100, and $b$ = 64 on iNaturalist2019, and $b = 32$ on STL.
For RCIVR, both the fixed inner loop batch size $b'$ and the initial outer loop batch size $B_0$ are tuned in $\{32,64,128 \}$. The outer loop mini-batch size $B_k$ is also increased by a factor of 10 per-stage according to the theory.
\begin{figure*}[t]
\centering
\hspace*{-0.1in} \includegraphics[width =0.25\textwidth]{STL10_val_error1_overall_training_time-eps-converted-to.pdf} \hspace*{-0.1in} \
\includegraphics[width =0.25\textwidth]{CIFAR10_val_error1_overall_training_time-eps-converted-to.pdf} \hspace*{-0.1in} \
\includegraphics[width =0.25\textwidth]{CIFAR100_val_error1_overall_training_time-eps-converted-to.pdf} \hspace*{-0.1in} \
\includegraphics[width =0.25\textwidth]{iNaturalist2019_val_error1_overall_training_time-eps-converted-to.pdf}
\caption{Testing accuracy (\%) vs running time}
\label{fig:RT}
\centering
\hspace*{-0.1in} \includegraphics[width=0.25\textwidth]{STL10_val_error1_sample_complexity-eps-converted-to.pdf} \hspace*{-0.1in}
\includegraphics[width=0.25\textwidth]{CIFAR10_val_error1_sample_complexity-eps-converted-to.pdf} \hspace*{-0.1in}
\includegraphics[width=0.25\textwidth]{CIFAR100_val_error1_sample_complexity-eps-converted-to.pdf} \hspace*{-0.1in}
\includegraphics[width=0.25\textwidth]{iNaturalist2019_val_error1_sample_complexity-eps-converted-to.pdf} \hspace*{-0.1in}
\caption{Testing accuracy (\%) vs \# of processed training examples}
\label{fig:RC}
\end{figure*}
For RECOVER, the initial step size $\eta_0$ and the momentum parameter $a_0$ at the first stage are tuned in $\{0.1, 0.2,...,1\}$, and $\eta_k$ is divided by 10 after each stage and $a_k$ is updated accordingly. For RCIVR, the constant step size is tuned $\eta \in \{0.1,0.2,\cdots, 1\}$. For the ASC-PG, the step size is set to be $\eta = c_0/t^a$, and the momentum parameter is set to be $\beta = 2c_0/t^b$, where $c_0$ is tuned from $0.01\sim 1$ and $a,b$ are tuned ranging from $0.1$ to $0.9$ by grid search, $t$ is the number of iterations. For Stoc-AGDA, the step size for primal variable is set to be $\beta_1/(\tau_1 + t)$ and the step size for dual variable $\mathbf{p}$ is set to be $\beta_2/(\tau_2 + t)$. $\beta_1, \beta_2$ are tuned in $[10^{-1}, 1, 10, 10^2, 500, 10^3]$ and $\tau_1,\tau_2$ are tuned in $[1, 10, 10^2, 500, 10^3]$. For PES-SGDA and PG-SMD2, the algorithm have multiple stages, where each stage solves a strongly-convex strongly-concave subproblem, and step size decrease after each stage. For PES-SGDA, the number of iteration per-stage is increased by a factor of $10$ and step sizes for the primal and the dual variables are decreased by 10 times after each stage, with their initial values tuned. In particular, $\eta_1$ (for primal variable) is tuned in $\{0.1, 0.2,\cdots 1\}$ and $\eta_2$ (for the dual variable) is tuned in $\{10^{-5}, 10^{-4}, 10^{-3}\}$, $T_0$ (the number of iterations for the first stage) is tuned in $\{5, 10, 30, 60\}\frac{n}{b}$, where $n$ is the number of training examples.
\begin{table*}[t]
\centering
\caption{Test accuracy (\%), mean (variance), of SGD for ERM and RECOVER for DRO. Bold numbers represent better performance.}
\label{tab:test-acc-RECOVER-SGD}
\resizebox{.95\textwidth}{!}{
\begin{tabular}{c|cc|cc|cc}
\hline
\multirow{2}{*}{IMRATIO} & \multicolumn{2}{c|}{STL10} & \multicolumn{2}{c|}{CIFAR10} & \multicolumn{2}{c}{CIFAR100} \\ \cline{2-7}
& SGD & RECOVER & SGD & RECOVER & SGD & RECOVER \\ \hline
0.02 & {37.97 (0.78) } & {\bf 38.08 (0.59)} & 65.36(0.64) & {\bf 66.14 (0.48)} & 38.99 (0.62) & {\bf 39.45 (0.56)} \\ \hline
0.05 & 41.12 (0.94) & {\bf 42.68 (0.60)} & 74.74 (0.71) & {\bf 75.90 (0.33) } & 45.79 (0.69) & {\bf 44.47 (0.66)} \\ \hline
0.1 & 46.03 (0.96) & {\bf 48.94 (0.86)} & 79.32 (0.42) & {\bf{80.93 (0.31)} } & 49.45 (0.5) & {\bf 50.84 (0.86) } \\ \hline
0.2 & 51.75 (1.14) & {\bf 56.06 (1.26)} & 84.84 (0.51) & {\bf 85.93 (0.14) } & 55.80 (0.74) & \textbf{56.90 (0.42)} \\ \hline
\end{tabular}
}
\vspace*{0.1in}
\end{table*}
As we aim to compare the optimization for the same objective in this section, $\lambda$ is set to 5 both in the compositional objective~(\ref{eqn:cp}) and min-max formulation of~(\ref{eqn:pd}) with
regularizer $h(\mathbf{p}, \mathbf 1/n)=\lambda\sum_i p_i\log(np_i)$. Following the standard training strategy, we run all algorithms 120 epochs and set the time threshold 150 hours for early stopping on iNaturalist data.
We compare testing accuracy vs running time and vs the number of processed training examples separately. We present the convergence of testing accuracy in terms of running time in Figure~\ref{fig:RT} and in terms of processed training examples in~Figure~\ref{fig:RC}. From the results, we can observe that: (i) in terms of running time RECOVER converges faster than all baselines on all data except on the smallest data STL10, on which PES-SGDA has similar running time performance as RECOVER. The reason is that STL10 is the smallest data, which only has 3000 imbalanced training data samples and hence PES-SGDA has marginal overhead per-iteration; (ii) when the training data size is moderately large, the primal dual methods (PES-SGDA, PG-SMD2, Stoc-AGDA) have significant overhead, which makes them converge much slower than RECOVER in terms of running time. On the large iNaturalist2019 data, RECOVER can save days of training time; (iii) RECOVER is much faster than RCIVR on all datasets; (iv) ASC-PG performs reasonably well but is still not as good as RECOVER in terms of both running time and sample complexity. The convergence instability of ASC-PG verifies the robustness of RECOVER for addressing the compositional problems.
\subsection{Comparison between SGD and DRO.}
\begin{figure}[t]
\hspace*{-0.1in}\begin{tabular}{c@{\hspace{0em}}c@{\hspace{1em}}c@{\hspace{0em}}c}
\hspace*{-0.06in} \includegraphics[scale=0.2]{lamda.png}
\end{tabular}
\hspace*{0.2in}
\resizebox{0.5\textwidth}{!}{
\begin{tabular}{c|c|c}\hline
Model & ImageNet-LT & Places-LT \\ \hline
Pretrained &40.50 &23.28 \\ \hline
CE (SGD) & 41.29 (3e-3) & 27.47 (1e-3) \\
Focal (SGD) & 41.10 (2e-2) & 27.64 (6e-3) \\ \hline
DRO (RECOVER) & \textbf{42.30} (4e-4) & \textbf{28.75} (4e-5)\\
\hline
\end{tabular}}
~\vspace{-1em}
\caption{Left: Test Accuracy vs $\lambda$ on CIFAR10 data; Right: Test accuracy (\%) of finetuned models by different methods.}
\label{fig:last}
~\vspace{-2.em}
\end{figure}
We compare the generalization performance of DRO optimized by RECOVER with traditional ERM optimized by SGD for imbalance multi-classification tasks on STL10, CIFAR10, CIFAR100.
The IMbalance RATIO (IMRATIO) is defined as the number of samples in the minority classes over the number of samples in the majority classes. We mannually construct different training sets with different IMRATIO, i.e., we only keep the last IMRATIO portion of images in the first half of classes.
Different from previous experiments, we tune $\lambda$ in a certain of range $\{1, 5, 10, 20, 100\}$ by a cross-validation approach and report the best testing results. Other parameters of RECOVER is tuned according to the setting in previous experiments. We use ResNet-32 for CIFAR10, CIFAR100, and ResNet-20 for STL10. For SGD, the step size is set as $\eta_0$ in the first 60 epochs, and is decreased by a factor of $10$ at 60, and 90 epochs following the practical strategy \cite{he2016deep}, where $\eta_0$ is tuned in $\{0.1, 0.5, 1\}$ and 1 epoch means one pass of training data.
We report averaged test accuracy over 5 runs with mean (variance) in Table~\ref{tab:test-acc-RECOVER-SGD}. We can see that DRO with RECOVER achieves higher test accuracy with smaller variance over multiple runs on all datasets than ERM with SGD. In addition, we report the results over $5$ runs of different $\lambda$ on CIFAR10 with different IMRATIO in Figure~\ref{fig:last} (left). It is obvious to see that an appropriate regularization on the dual variable can improve the performance
\subsection{Effectiveness of RECOVER as a Fine-tuning Method}
Fine-tuning high level layers from a pertained model is widely used for transfer learning and is also an effective method to update the models without increasing the computational cost too much when receiving new samples.
For this purpose, we demonstrate that DRO is a better objective than the Cross Entropy (CE) loss and focal loss for fine-tuning on imbalanced datasets.
ImageNet-LT~\citep{liu2019large} and Places-LT~\citep{liu2019large} are two popular imbalanced data sets and are the Long-Tailed (LT) version of ImageNet-2012~\citep{deng2009imagenet} and Places-2~\citep{zhou2017places} by sampling a subset following the Pareto distribution ~\citep{arnold2014pareto} with the power value $6$. ImageNet-LT has 115.8K images from 1000 categories, and Places-LT contains 62.5K training images from 365 classes. The head class is 4980 images and the tail class contains 5 images in both datasets.
To verify that DRO is a better objective and that RECOVER is an efficient optimization algorithm, we compare the test accuracy of the model trained with different objectives: DRO, CE loss and focal loss, where DRO is optimized by RECOVER and the other two losses are optimized by SGD. All methods start from the same pretrained model. We apply the ImangeNet pretrained ResNet152 as the pre-trained model for Places-LT. For ImageNet-LT, we train ResNet50 using CE loss for 90 epochs following the standard training strategy proposed in~\citep{he2016deep} as the pre-trained model. We then fine tune the last block of the convolutions layer and the classifier layer for 30 epochs by using RECOVER for optimizing DRO and using SGD for optimizing ERM, respectively.
The initial step size for RECOVER and SGD are both tuned in $\eta_0 \in \{0.1, 0.5, 1\}$. For DRO, $\lambda$ is tunes in $\{1,5,10 \}$.
The test accuracy over 3 runs with mean (variance) is reported in Figure~\ref{fig:last} (right). It is clear to see that DRO optimized by RECOVER outperforms ERM with the CE loss and focal loss optimized by SGD more than 1(\%) on both datasets.
This vividly verifies the effectiveness of RECOVER as a fine-tuning method on imbalanced data.
\section{Conclusion}
In this paper, we proposed a duality-free online method for solving a class of distributionally robust optimization problems. We used a KL divergence regularization on the dual variable and transformed the problem into a two-level stochastic compositional problem. By leveraging a practical PL condition, we developed a practical method RECOVER based on recursive variance-reduced estimators and established an optimal sample complexity. Experiments verify the effectiveness of the proposed algorithm in terms of both running time and prediction performance on large-scale imbalanced data. An open question remains is how to solve the DRO problem with a KL constraint on the dual variable by a pratical stochatic algorithm without maintaining and updating the high dimensional dual variable. We plan to address this challenge in the future work.
\section*{Acknowledgments}
The authors thank anonymous reviewers for constructive comments. This work was supported by NSF Career Award \#1844403, NSF Award \#2110545 and NSF Award \#1933212.
| {'timestamp': '2021-11-15T02:21:23', 'yymm': '2006', 'arxiv_id': '2006.10138', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10138'} | arxiv |
\section{Acknowledgments}
This research was supported by TRI, Intel, NSF (\#1651565, \#1522054, \#1733686), and ONR. The survey datasets are generously provided by Marshall Burke at Stanford University.
\section{Proofs}
\orderbound*
\begin{proof}[Proof of Proposition~\ref{prop:validity}]
Whenever $\mathbb{E}[Z] \leq Z_{(m-k)} + r$ and $\mathbb{E}[Z] \geq Z_{(1+k)} - r$, we have
\begin{align*}
&\lvert \hat{\mu} - \mathbb{E}[Y] \rvert = \left\lvert \mathbb{E}[Z] - \frac{Z_{(m-k)} + Z_{(1+k)}}{2} \right\rvert \\
&= \max\left(\mathbb{E}[Z] - \frac{Z_{(m-k)} + Z_{(1+k)}}{2}, \right. \\ &\qquad\qquad \left. \frac{Z_{(m-k)} + Z_{(1+k)}}{2} - \mathbb{E}[Z] \right) \\
&\leq \max\left(Z_{(m-k)} + r - \frac{Z_{(m-k)} + Z_{(1+k)}}{2}, \right. \\ &\qquad\qquad \left. \frac{Z_{(m-k)} + Z_{(1+k)}}{2} - Z_{(1+k)} + r \right) \\
&= \frac{Z_{(m-k)} - Z_{(1+k)}}{2} + r
\end{align*}
In other words, we cannot have
\[\lvert \hat{\mu} - \mathbb{E}[Y] \rvert > \frac{Z_{(m-k)} - Z_{(1+k)}}{2} + r \]
unless either $\mathbb{E}[Z] >Z_{(m-k)} + r$ or $\mathbb{E}[Z] < Z_{(1+k)} - r$ is true, which implies that
\begin{align*}
&\Pr\left[\lvert \hat{\mu} - \mathbb{E}[Y] \rvert > r + \frac{Z_{(m-k)} - Z_{(1+k)}}{2} \right] \\
&\leq \Pr[\mathbb{E}[Z] > Z_{(m-k)} + r \text{ or } \mathbb{E}[Z] < Z_{(1+k)} - r] \\
&\leq \Pr[\mathbb{E}[Z] > Z_{(m-k)} + r] + \Pr[\mathbb{E}[Z] < Z_{(1+k)} - r] \\
&\leq \zeta
\end{align*}
\end{proof}
\singledim*
\begin{proof}[Proof of Theorem~\ref{thm:resilient}]
Before proving Theorem~\ref{thm:resilient}, we first need a Lemma.
\begin{lemma}
\label{lemma:single_bound}
If $Z$ is $s$-resilient from above, then $\forall \delta \in (0, 1)$,
$$
\Pr\left[Z \leq \mathbb{E}[Z] - s(\delta)\frac{1-\delta}{\delta}\right] \leq \delta.
$$
\end{lemma}
For some $r \in \mathbb{R}$, let $B_r$ be the event $Z \leq \mathbb{E}[Z] - r$.
\begin{align*}
&\Pr\left[Z_{(m-k)} \leq \mathbb{E}[Z] - r\right] \\
&= \Pr\left[ \sum_{j=0}^m \mathbb{I}(Z_j \not\in B_r) \leq k \right] \\
&= \sum_{i=0}^k \binom{m}{i} \Pr[B_r]^{m-i} (1 - \Pr[B_r])^i \numberthis\label{eq:order_stats} \\
&\leq \left( \sum_{i=0}^k \binom{m}{i}(1 - \Pr[B_r])^{i} \right) \Pr[B_r]^{m-k} \\
&\leq \left( \sum_{i=0}^k (m(1 - \Pr[B_r]))^{i} \right) \\
&\leq (m(1 - \Pr[B_r])+1)^k \Pr[B_r]^{m-k}
\end{align*}
Now we will show that the algorithm chooses $v_i$, $i=0, \dotsc, T$ such that
\begin{align*}
(m(1 - v_i)+1)^k v_i^{m-k} \leq \zeta \numberthis\label{eq:rhs}
\end{align*}
To show this we first show that $v_{i+1} \geq v_i$, $\forall i = 0, \dotsc, T-1$. This is obviously true for $i=0$ because $0 \leq v_0 \leq 1$ so
\begin{align*}
v_0 &= \stuffn \\
&\leq \left(\frac{\zeta}{(m(1-v_0)+1)^k}\right)^{\frac{1}{m-k}}= v_1
\end{align*}
and we can proceed to use induction and conclude
\begin{align*}
v_i &= \left(\frac{\zeta}{(m(1-v_{i-1})+1)^k}\right)^{\frac{1}{m-k}} \\
&\leq \left(\frac{\zeta}{(m(1-v_{i})+1)^k}\right)^{\frac{1}{m-k}} = v_{i+1}
\end{align*}
Now we use induction to show that Eq.(\ref{eq:rhs}) is true.
First at iteration 0 this is true because
\begin{align*}
(m(1 - v_0)+1)^k v_0^{m-k} \leq (m+1)^k v_0^{m-k}
\end{align*}
which is less than $\zeta$ as long as
\begin{align*}
v_0 \leq \stuffn
\end{align*}
Suppose Eq.(\ref{eq:rhs}) is true at iteration $i$, then at iteration $i+1$ it is still true. Denote the values as $v_i$ and $v_{i+1}$. Because we choose $v_{i+1}$ such that
\begin{align*}
(m(1-v_i)+1)^k v^{m-k}_{i+1} = \zeta
\end{align*}
Observe that $v_{i+1} \geq v_i$ it must be true that
\begin{align*}
(m(1-v_{i+1})+1)^k v^{m-k}_{i+1} \leq \zeta
\end{align*}
After we have established Eq.(\ref{eq:rhs}) we can apply Lemma~\ref{lemma:single_bound} to achieve $\Pr[B_r] \leq v$ it suffices to have
$$
r \geq s\left( v \right) \left(v^{-1} - 1 \right)
$$
What remains is to prove Lemma~\ref{lemma:single_bound}
\begin{proof}[Proof of Lemma~\ref{lemma:single_bound}]
Let $B_r$ be the event $Z \leq \mathbb{E}[Z] - r$ for any $r \geq 0$. Suppose it is true that $\Pr[B_r] = \delta_r$ for some $\delta_r \in (0, 1)$, we have
\begin{align*}
\mathbb{E}[Z] &= \mathbb{E}[Z\vert B_r]\Pr[B_r] + \mathbb{E}[Z \vert \bar{B}_r] (1 - \Pr[B_r]) \\
&\leq (\mathbb{E}[Z] - r)\delta_r + (\mathbb{E}[Z] + s(\delta_r))(1 - \delta_r)
\end{align*}
which implies that
$$
r \leq s(\delta_r)\frac{1 - \delta_r}{\delta_r}
$$
which implies
$$
\Pr\left[Z \leq \mathbb{E}[Z] - s(\delta)\frac{1-\delta}{\delta}\right] \leq \delta
$$
\end{proof}
\end{proof}
\asymptote*
\begin{proof}[Proof of Corollary~\ref{cor:asymptote}]
Denote $\epsilon = \stuffn$. We know that
\begin{align*}
\lim_{m \to \infty} \log \epsilon &= \frac{1}{m-k} \left( \log \zeta - k\log(m+1) \right) = 0
\end{align*}
which implies $\lim_{m \to \infty} \epsilon = 1$, so $\forall a < 0$
there must exist a $M$ such that $\forall m \geq M$, $(1 - \epsilon)^a + b \leq 2(1 - \epsilon)^a$, and $\epsilon > 1/2$
\begin{align*}
r &\leq 2(1 - \epsilon)^a (\epsilon^{-1} - 1) = \frac{2(1 - \epsilon)^{1+a}}{\epsilon} \leq 4(1 - \epsilon)^{1+a} \\
\end{align*}
Observe that $\epsilon < 1$ so $1 - \epsilon < -\log \epsilon$ so we have (for sufficiently large $m$)
\begin{align*}
r &\leq 4(-\log \epsilon)^{1+a} \\
&= 4 \left( -\frac{1}{m-k} \log \zeta + \frac{k}{m-k} \log (m+1)\right)^{1+a} \\
&\leq \frac{5}{m^{1+a}} \left( \log \frac{1}{\zeta} + k \log m \right)^{1+a} \\
&\leq \frac{5}{m^{1+a}} \left( \log \frac{1}{\zeta} + k \log m \right)
\end{align*}
Now we only need the special case of $a = 0$, where
\begin{align*}
r \leq (1+b) (\epsilon^{-1}-1) \leq 2(1+b) (1 - \epsilon)
\end{align*}
and the proof will follow as before.
\end{proof}
\resilient*
\begin{proof}[Proof of Lemma~\ref{lemma:example_resilient}]
Part 1 is trivial to prove. Part 2 is proved in \citet{steinhardt2018robust}, Example 2.7. Part 3 is proven here.
Let $F$ denote the CDF of $Z$. For convenience, let ${\bar{\epsilon}} = 1 - \epsilon$, $\tau = F^{-1}({\bar{\epsilon}})$, and without loss of generality assume $\mathbb{E}[Z] = 0$. We first consider lower bounds on $\mathbb{E}[Z \mid Z \in B]$ where $B$ is any subset of $\mathcal{Z}$ such that $\Pr[Z \in B] \geq {\bar{\epsilon}}$. It is easy to see that for any such $B$ we have
\[ \mathbb{E}[Z \mid Z \leq \tau] \leq \mathbb{E}[Z \mid Z \in B] \]
so we only have to provide a lower bound for $\mathbb{E}[Z \mid Z \leq \tau]$. Without loss of generality we can also assume $\tau \leq 0$ because suppose $\tau > 0$ then consider an alternative random variable $\tilde{Z}$ defined by $\tilde{Z} = \max(Z, 0)$. Then $\tilde{Z}$ is $\sigma^2$ sub-Gaussian, and
\[ \mathbb{E}[Z \mid Z \leq \tau] \geq \mathbb{E}[\tilde{Z} \mid \tilde{Z} \leq \tau] \]
Then we can provide a lower bound for $\mathbb{E}[\tilde{Z} \mid \tilde{Z} \leq \tau]$ instead. Given the above setup we have
\begin{align*}
& {\bar{\epsilon}}\, \mathbb{E}[Z \vert Z \leq \tau] \\
&= \int_{x=-\infty}^{\tau} x F'(x)\, dx
= \int_{x=-\infty}^{\tau} F'(x) \int_{y = x}^0 (-1)\, dy\, dx \\
&= -\int_{x=-\infty}^{\tau} \int_{y = x}^0 F'(x)\, dy\, dx \\
&= -\int_{x=-\infty}^{\tau} \int_{y = -\infty}^0 \mathbb{I}(y > x) F'(x)\, dy\, dx \\
&= -\int_{y=-\infty}^0 \int_{x=-\infty}^{\tau} \mathbb{I}(y > x) F'(x)\, dx\, dy \\
&= -\int_{y=\tau}^0 \int_{x=-\infty}^{\tau} \mathbb{I}(y > x) F'(x)\, dx \, dy \\
&\qquad - \int_{y=-\infty}^{\tau} \int_{x=-\infty}^{\tau} \mathbb{I}(y > x) F'(x)\, dx\, dy \\
&= -\int_{y = \tau}^0 {\bar{\epsilon}}\, dy
- \int_{y = -\infty}^{\tau} \int_{x=-\infty}^{y} F'(x)\, dx\, dy \\
&= {\bar{\epsilon}} \tau - \int_{y=-\infty}^{\tau} F(y)\, dy \\
&= {\bar{\epsilon}} \tau - \int_{x=-\infty}^{\tau} F(x)\, dx
\end{align*}
Let $ {\tilde{F}}(x) = e^{-\frac{x^2}{2\sigma^2}} $. Since $Z$ is $\sigma^2$ sub-Gaussian, by Chernoff bound we know that $\forall x < 0.\ F(x) \leq {\tilde{F}}(x)$, which also implies that whenever $F^{-1}({\bar{\epsilon}}) < 0$, ${\tilde{F}}^{-1}({\bar{\epsilon}}) \leq F^{-1}({\bar{\epsilon}})$, Then
\begin{align*}
&{\bar{\epsilon}} \mathbb{E}[Z \vert Z \leq F^{-1}({\bar{\epsilon}})] \\
&= {\bar{\epsilon}} F^{-1}({\bar{\epsilon}}) - \int_{x = -\infty}^{F^{-1}({\bar{\epsilon}})} F(x) dx \\
&= {\bar{\epsilon}} F^{-1}({\bar{\epsilon}}) - \int_{x = -\infty}^{{\tilde{F}}^{-1}({\bar{\epsilon}})} F(x) dx - \int_{x = {\tilde{F}}^{-1}({\bar{\epsilon}})}^{F^{-1}({\bar{\epsilon}})} F(x) dx \\
&\geq {\bar{\epsilon}} F^{-1}({\bar{\epsilon}}) - \int_{x = -\infty}^{{\tilde{F}}^{-1}({\bar{\epsilon}})} {\tilde{F}}(x) dx - \int_{x = {\tilde{F}}^{-1}({\bar{\epsilon}})}^{F^{-1}({\bar{\epsilon}})} {\bar{\epsilon}} dx \\
&= {\bar{\epsilon}} {\tilde{F}}^{-1}({\bar{\epsilon}}) - \int_{x = -\infty}^{{\tilde{F}}^{-1}({\bar{\epsilon}})} {\tilde{F}}(x) dx
\end{align*}
Finally, denote $\phi_\sigma(x)$ as the PDF of ${\mathcal{N}}(0, \sigma^2)$ and $\Phi_\sigma$ be its CDF, we have
\begin{align*}
\int_{x = -\infty}^{{\tilde{F}}^{-1}({\bar{\epsilon}})} {\tilde{F}}(x) dx &= \sqrt{2\pi}\sigma \int_{x = -\infty}^{{\tilde{F}}^{-1}({\bar{\epsilon}})} \phi_\sigma(x) dx \\
&= \sqrt{2\pi}\sigma \Phi_\sigma({\tilde{F}}^{-1}({\bar{\epsilon}})) \leq \sqrt{2\pi}\sigma{\bar{\epsilon}}
\end{align*}
Combining these results we get
\begin{align*}
&\mathbb{E}[Z \vert Z \leq F^{-1}({\bar{\epsilon}})] \\
&\geq {\tilde{F}}^{-1}({\bar{\epsilon}}) - \sqrt{2\pi}\sigma = -\sqrt{2\sigma\log\frac{1}{{\bar{\epsilon}}}} - \sqrt{2\pi}\sigma
\end{align*}
\end{proof}
\boundedexample*
\begin{proof}[Proof of Corollary~\ref{cor:bounded_example}]
By Theorem~\ref{thm:resilient} we have
\begin{align*}
\zeta \geq &\Pr\left(Z_{(1+k)} \geq \mathbb{E}[Z] + (\mathbb{E}[Z] - a) (v_T^{-1} - 1) \right)\\
& = \Pr\left(Z_{(1+k)} \geq v^{-1}_T \mathbb{E}[Z] - v^{-1}_T a + a \right) \\
&= \Pr\left(v_T Z_{(1+k)} \geq v_T a - a + \mathbb{E}[Z] \right) \\
&= \Pr\left( \mathbb{E}[Z] \leq a + v_T(Z_{(1+k)} - a) \right)
\end{align*}
Similarly we can conclude
\begin{align*}
\zeta \geq \Pr\left( \mathbb{E}[Z] \geq b - v_T(b - Z_{(m-k)}) \right)
\end{align*}
\end{proof}
\multidim*
\begin{proof}[Proof of Theorem~\ref{thm:multi-dim}]
Let
\[
v^* = \argsup_{v, {\lVert v \rVert_*}=1} \langle v, \mathbb{E}[Z] \rangle
\]
then $\lVert \mathbb{E}[Z] \rVert = \langle v^*, \mathbb{E}[Z] \rangle$. Let ${\tilde{Z}}_{(1)}, \dotsc, {\tilde{Z}}_{(m)}$ be ranked such that
\[
\langle v^*, {\tilde{Z}}_{(1)} \rangle \leq \dotsc \leq \langle v^*, Z_{(m)} \rangle.
\]
Denote the event $B \subset \mathcal{Z}$ as $\{ Z, \langle v^*, Z \rangle \leq \langle v^*, \mathbb{E}[Z] \rangle - r\}$ as before we have
\begin{align*}
\Pr\left[ \langle v^*, {\tilde{Z}}_{(m-k)} \rangle \leq \langle v^*, \mathbb{E}[Z] \rangle - r \right] \leq (m+1)^k \Pr[B]^{m-k}
\end{align*}
and we set the RHS $\leq \zeta$. It suffices to have
\[ \Pr[B] \leq \stuffn \]
Similar to Lemma~\ref{lemma:single_bound}, denote $\delta = \Pr[B]$
\begin{align*}
&\langle v^*, \mathbb{E}[Z] \rangle = \mathbb{E}[ \langle v^*, Z \rangle] \\
&= \mathbb{E}[ \langle v^*, Z \rangle \mid B]\Pr[B] + \mathbb{E}[ \langle v^*, Z \rangle \mid \bar{B}](1 - \Pr[B]) \\
&\leq (\langle v^*, \mathbb{E}[Z] \rangle - r) \delta + (\langle v^*, \mathbb{E}[Z] \rangle + s(\delta))(1 - \delta)
\end{align*}
which implies that $\Pr[B] \leq \delta$ when $r \geq s(\delta)\frac{1-\delta}{\delta} = s(\delta)(\delta^{-1} - 1)$. When this is true we have
\begin{align*}
\Pr[\langle v^*, {\tilde{Z}}_{(m-k)} \rangle \leq \lVert \mathbb{E}[Z] \rVert - r] \leq \zeta
\end{align*}
If we also rank $Z_{(1)}, \dotsc, Z_{(m)}$ by
\begin{align*}
\lVert Z_{(1)} \rVert \leq \cdots \leq \lVert Z_{(m)} \rVert
\end{align*}
we have $\forall i \geq m-k$
\begin{align*}
\langle v^*, {\tilde{Z}}_{(m-k)} \rangle \leq \langle v^*, {\tilde{Z}}_{(i)} \rangle \leq \lVert \tilde{Z}_{(i)} \rVert
\end{align*}
so there are at least $k$ samples $Z_{(i)}$ with norm at least $\langle v^*, {\tilde{Z}}_{(m-k)} \rangle$, and we can conclude that $ \langle v^*, {\tilde{Z}}_{(m-k)} \rangle \leq \lVert Z_{(m-k)} \rVert$ which implies
\begin{align*}
\Pr[\lVert Z_{(m-k)} \rVert \leq \lVert \mathbb{E}[Z] \rVert - r] \leq \zeta
\end{align*}
\end{proof}
\section{Applications}
\subsection{Certifying Classification and Regression Performance}
From \corref{cor:bounded_example}, for $\epsilon \in [-1, 1]$, this means that with probability $> 1 - 2\zeta$,
$$
\mathbb{E}[\epsilon] \in \left[
\zeta^{1/m} \epsilon_{(1)} - (1 - \zeta^{1/m}),
\zeta^{1/m} \epsilon_{(m)} + (1 - \zeta^{1/m})
\right]
$$
Since we define $y = \hat{y} - \epsilon$, thus $\mathbb{E}[Y] = \frac{1}{n}\sum_{i=1}^n f(X_i) - \mathbb{E}[\epsilon]$, so
\begin{align*}
\mathbb{E}[Y] \in \Bigg[
& \frac{1}{n}\sum_{i=1}^n f(X_i) - \zeta^{1/m} \epsilon_{(m)} - (1 - \zeta^{1/m}), \\
& \frac{1}{n}\sum_{i=1}^n f(X_i) - \zeta^{1/m} \epsilon_{(1)} + (1 - \zeta^{1/m}) \Bigg]
\end{align*}
\subsection{Semi-Supervised Mean Estimation} \label{sec:semisup_mean}
Consider two jointly-distributed random variables $X \in \mathcal{X}$ and $Y \in \mathbb{R}$ where we have $m$ labeled pairs $\{(x_i, y_i)\}_{i=1}^m$ and $n \gg m$ additional unlabeled examples $\{x'_i\}_{i=1}^n$. Let $f: \mathcal{X} \to \mathbb{R}$ be an arbitrary regression model, and define ${\tilde{Y}} = f(X)$ to be the control variate for $Y$. By the Law of Large Numbers, $\frac{1}{n} \sum_{i=1}^n f(x'_i)$ is a very accurate estimate of $\mathbb{E}[{\tilde{Y}}]$ for large $n$. We now have the setup described in Section~\ref{sec:control_variates}: $m$ samples $\{(y_i, {\tilde{y}}_i)\}_{i=1}^m$ along with a known value for $\mathbb{E}[{\tilde{Y}}]$. We can calculate confidence intervals for $\mathbb{E}[Y]$ using our method of order statistics.
\subsection{Semi-Supervised Covariance Estimation}
In addition to setting described previously in Section~\ref{sec:semisup_mean}, we can additionally consider the case where we have a third random variable $W \in \mathbb{R}$, and suppose that we have a sample of $W$ corresponding to each sample of $X$. Our goal is to learn the covariance between $Y$ and $W$.
We can pose this estimation problem as a mean estimation task as follows. Defining $Z = YW - Y \mathbb{E}[W] = Y(W - \mathbb{E}[W])$, we have
\begin{align*}
\Cov[Y, W]
&= \mathbb{E}[YW] - \mathbb{E}[Y]\mathbb{E}[W] \\
&= \mathbb{E}\left[YW - Y \mathbb{E}[W]\right]
= \mathbb{E}[Z]
\end{align*}
Letting $\hat{Z} = f(X) (W - \mathbb{E}[W])$ and letting $\epsilon = \hat{Z} - Z$, we can directly apply the mean estimation technique for getting a confidence interval for the covariance, $\mathbb{E}[Z]$.
\section{Conclusion}
In this paper we propose a framework for estimating the confidence interval given a control variate random variable as side information. We show that under certain conditions on the control variate, the estimation algorithms out-performs classic minimax optimal estimation algorithms both asymptotically and empirically.
A major weakness of the estimator is diminished performance when we have a large number of samples. Because of no-free-lunch results, trade-offs are unavoidable, but it is an interesting direction of future research to find either better trade-offs or prove its impossibility.
\section{Experiments}
\subsection{Certifying Regression Performance}
\label{sec:exp1}
\begin{figure*}
\centering
\begin{tabular}{cc}
\includegraphics[width=0.38\linewidth]{plots/mpg_example_hoeffding.png} & \includegraphics[width=0.38\linewidth]{plots/mpg_example_chebyshev.png} \\
\includegraphics[width=0.38\linewidth]{plots/housing_example_crime_hoeffding.png} & \includegraphics[width=0.38\linewidth]{plots/housing_example__chebychev.png} \\
\end{tabular}
\caption{Confidence intervals (both upper and lower bounds) on $\mathbb{E}[Z]$ from different estimation algorithms. For our algorithm, we try different values of $k$ (the $k$-th largest / smallest). For the MPG dataset, we also evaluate the regression error conditioned on different country of origin (top). For housing dataset, we evaluate the regression error conditioned on different crime rate level (bottom). In most of the experiments, our estimation algorithm performs better (outputs smaller confidence intervals). Chebychev sometimes performs better, especially with large sample size. Hoeffding always performs worse in this setup.}
\label{fig:mpg}
\end{figure*}
\begin{figure*}
\centering
\includegraphics[width=0.8\linewidth]{plots/bound_vs_error.png}
\caption{Size of the confidence interval as a function of the error of the control variate. We scale up (>1.0) or scaled down (<1.0) the error (i.e. $Z_{\mathrm{new}} = \alpha Z_{\mathrm{old}}$ for $\alpha \in [0, 2]$). When the control variate has smaller error the confidence interval is significantly better compared to Hoeffding or Chebychev.}
\label{fig:bound_scale}
\end{figure*}
Our first task is to upper and lower bound the difference between the output of a regression function ${\tilde{Y}}$ and the true target attribute $Y$. For this task, our goal is to bound the expected error $Z = Y - {\tilde{Y}}$ of the regression function. We are not directly interested in the expected value of the target attribute $\mathbb{E}[Y]$; instead we only want to show bounds $\mathrm{LB} \leq \mathbb{E}[Z] \leq \mathrm{UB}$. In addition, instead of a single global accuracy, we might care about accuracy for sub-groups in the data (e.g., based on some feature or sensitive attribute). In other words, let $U$ be some random variable taking a finite set of values, we want to know the regression error $\mathbb{E}[Z \vert U=u]$ for each value of $U=u$. This can be important for fairness or identifying particular failure cases.
If the regression function is accurate, $Z$ should be concentrated around $0$, making it feasible to obtain better bounds with order statistics. We compare the bounds of Section~\ref{sec:order_bounds} with the baseline bounds of Section~\ref{sec:baseline}. Code is available at https://github.com/ermongroup/ControlVariateBound
\textbf{Datasets}: We use two classic regression datasets in the UCI repository~\citep{asuncion2007uci}: Auto MPG, where the task is to predict the miles per gallon (MPG) of a vehicle based on 10 features; and Boston housing price prediction, where the task is to predict the housing price from 13 features.
\textbf{Assumptions}: As explained in Section~\ref{sec:baseline}, all estimation algorithms require some assumptions. Here, we either assume bounded support or bounded variance. Optimal choice of these assumptions usually relies on domain knowledge about the problem and is beyond the scope of this paper. Here, we simply assume that the error is bounded by $\pm b/2$ where $b$ is the maximum MPG in the entire dataset. The reason is that any regression algorithm can trivially output $b/2$ and achieve this error. In the bounded variance case, we first compute an upper bound on $\mathbb{E}[Z^2]$ that holds with $1-\zeta/2$ probability by Hoeffding inequality as an upper bound on the variance.
\textbf{Results:} The results are shown in Figure~\ref{fig:mpg}. Our order statistics bound works better in general if the number of test samples $m$ is small. Here both datasets contain approximately 100 test samples, and our bound performs on-par with Chebychev and better than Hoeffding. Our bound also performs better when the control variate is more accurate (i.e. $Z$ is concentrated around zero). This is empirically verified in Figure~\ref{fig:bound_scale}.
Our bound also depends on the choice of $k$. In general, with more data choosing a larger value of $k$ is preferable, and vice versa.
\begin{figure}[h]
\centering
\includegraphics[width=0.45\linewidth]{plots/poverty_mean_cheb.png}
\includegraphics[width=0.45\linewidth]{plots/poverty_mean_hoef.png}
\caption{Histograms of 99\%-confidence interval sizes for the average household-level asset wealth within a province, for 36 provinces across 13 countries in DHS surveys of sub-Saharan Africa. 1000 random subsets of size $m$ are sampled from each province. We assume that household-level asset wealth is a random variable either with finite variance (left), or bounded in $[0, 1]$ (right).
The histograms show interval sizes pooled over all 36 test provinces.
For small sample size per province (i.e. <20 samples per province) our method achieves smaller confidence intervals. With more samples, the bias of our estimation algorithm dominates and our method performs worse.}
\label{fig:poverty_mean}
\end{figure}
\subsection{Poverty Estimation Task}
\label{sec:exp2}
We apply our estimation algorithm on a real world task, where we estimate the average household-level asset wealth across provinces of countries in 23 sub-Saharan African countries. We used DHS Survey collected between 2009-16 and constructed an average household asset wealth index for 19,669 villages following the procedure described in \cite{jean2016combining}.
\textbf{Setup}: We emulate the setup where we have survey results from several countries, and train a regressor (a convolutional neural network) to predict asset wealth from satellite images (multispectral Landsat and nighttime VIIRS). To estimate the average asset wealth for a new country, we apply this regressor to satellite images
from that country; we use the output of the regressor as a control variate.
More specifically, we randomly pick 80\% of the countries to train the regressor, and test the performance of our estimation algorithm on the remaining countries. We also use cross validation to more accurately evaluate our performance.
\textbf{Assumptions}: As in Section~\ref{sec:exp1}, for estimation with bounded random variables, we upper- and lower-bound household wealth by the maximum and minimum wealth across the entire dataset. For estimation with bounded moment random variables, we use the empirical standard deviation estimated across the entire country, multiplied by an additional margin of 1.5$\times$. Because of the small sample size, Chernoff bounding the standard deviation as in Section~\ref{sec:exp1} is infeasible.
\textbf{Results}: The results are shown in Figure~\ref{fig:poverty_mean}. Although our regression model is trained on all 23 countries in our dataset, we only test our method on the 36 provinces across 13 countries from which we have at least 90 labeled survey examples. Compared to Chernoff bound or Chebychev our estimation algorithm perform better when sample size is small, and worse when sample size is large. Because of the difficulty of predicting wealth from satellite images, the control variate is not very accurate, and further improvements are possible with improved prediction accuracy.
\subsection{Covariance Estimation}
The DHS surveys also include other demographic variables besides household asset wealth. Policy makers may be interested in the covariance of these demographic quantities, such as between maternal education level and household asset wealth.
More formally let $W$ be the random variable that represents the average level of maternal education in a village, and $U$ represent the average household asset wealth in the same village. The random variable we actually want to estimate is $Y = UW - U\mathbb{E}[W]$ because
\[
\mathbb{E}[Y] = \mathbb{E}[UW] - \mathbb{E}[U]\mathbb{E}[W] = \mathrm{Cov}(U, W)
\]
We assume that $W$ is a quantity that is easy to survey, or has available data, so $\mathbb{E}[W]$ is known. This is commonly the case, when certain demographic variables are more widely surveyed than others. As before, we can train a regressor to predict $U$ from satellite images, and we denote it's output as $\tilde{U}$. Our control variate is then ${\tilde{Y}} = \tilde{U}W - \tilde{U}\mathbb{E}[W]$. By using these new definitions for $Y$ and ${\tilde{Y}}$ we can apply our estimation algorithm.
\textbf{Setup}: The setup is identical to Section~\ref{sec:exp2}, where we train the asset wealth regression model on 80\% of the countries and test our estimation algorithm on the remaining countries. However, we only have maternal education survey data on 9 countries, so we only estimate confidence intervals of covariance in these countries. Maternal education level is measured at each household on an integer scale from 0 to 3, then averaged within each village. All the other assumptions are also identical to before.
\textbf{Result}: The results are shown in Figure~\ref{fig:poverty_cov}. As expected, our estimation algorithm achieves superior performance compared to baseline estimators when the sample size $m$ is small.
\begin{figure}
\centering
\includegraphics[width=0.45\linewidth]{plots/poverty_cov_cheb.png}
\includegraphics[width=0.45\linewidth]{plots/poverty_cov_hoef.png}
\caption{Histograms of confidence interval sizes at $\zeta = 0.01$ for the covariance between maternal education and household asset wealth, for 9 countries in DHS surveys of sub-Saharan Africa. 1000 random subsets of size $m$ are sampled from each province. The confidence interval derived from order statistics outperforms both the Hoeffding interval and the Chebychev interval.}
\label{fig:poverty_cov}
\end{figure}
\section{Introduction}
Many real world problems require estimation of the mean of a random variable from unbiased samples. In high risk applications, the estimation algorithm should output a confidence interval, with the guarantee that the true mean belongs to the interval with e.g. 99\% probability. The classic tools for this task are concentration inequalities, such as the Chernoff, Bernstein, or Chebychev inequalities~\citep{hoeffding1962probability,bernstein1924modification,vershynin2010introduction}.
However, for many tasks, obtaining unbiased samples is expensive. For example, when estimating demographic quantities, such as income or political preference, drawing unbiased samples can require field survey. To make the situation worse, often we seek more granular estimates, e.g. for each individual district or county, meaning that we need to draw a sufficient number of samples for every district or county. Another difficulty can arise when we need high accuracy (i.e. a small confidence interval), since confidence intervals produced by typical concentration inequalities have size $O(1/\sqrt{\mathrm{number\ of\ samples}})$. In other words, to reduce the size of a confidence interval by a factor of 10, we need 100 times more samples.
This dilemma is generally unavoidable because concentration inequalities such as Chernoff or Chebychev are minimax optimal: there exist distributions for which these inequalities cannot be improved. No-free-lunch results~\citep{van2000asymptotic} imply that any alternative estimation algorithm that performs better (i.e. outputs a confidence interval with smaller size) on some problems, must perform worse on other problems. Nevertheless, we can identify a subset of problems where better estimation algorithms are possible.
We consider the class of problems where we have side information. We formalize side information as a random variable with known expectation and whose value is close (with high probability) to the random variable we want to estimate. Following the terminology in the Monte Carlo simulation literature, we call this side information random variable a ``control variate''~\citep{lemieux2017controlvariates}. Instead of the original estimation task, we can estimate the expected difference between the original random variable and the control variate. The hope is that the distribution of this difference is concentrated around $0$.
Some estimation algorithms output very good (small sized) confidence intervals for distributions concentrated around $0$ compared to classic methods such as Chernoff bounds.
Many practical problems have very good control variates. One important class of problems is when we have a predictor for the random variable, and we can use the prediction as the control variate.
For example, if we would like to estimate a neighborhood's average voting pattern, then we might have a prediction function for political preference from Google Street View images of that neighborhood~\citep{gebru13108streetview}; if we would like to estimate the average asset wealth of households in a certain geographic region, we might have a regressor that predicts income from satellite images~\citep{jean2016combining}. These classifiers could be trained on past data (e.g. previous year survey results) or similar datasets, or they could even be crafted by hand.
For these problems we propose concentration bounds based on order statistics. In particular, we draw a connection between the recently proposed concept of \emph{resilience}~\citep{steinhardt2018robust} and concentration bounds on order statistics. We show how to use these concentration inequalities to design estimation algorithms that output better confidence intervals when we have a good control variate (e.g. output confidence intervals of size $O(1/\mathrm{number\ of\ samples})$).
Our proposed estimation algorithm always produces valid confidence intervals, i.e. the true mean belongs to the interval with a specified probability. The only risk is that when the control variate is poor, the confidence interval could be worse (larger) than classic baselines such as Chernoff inequalities. We empirically show superior performance of the proposed estimation algorithm on three real world tasks: bounding regression error, estimating average wealth with satellite images, and estimating the covariance between wealth and education level.
\subsubsection*{\bibname}}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[hidelinks]{hyperref}
\usepackage{url}
\usepackage{booktabs}
\usepackage{amsfonts}
\usepackage{nicefrac}
\usepackage{microtype}
\usepackage{algorithmicx,algpseudocode,algorithm}
\usepackage{comment}
\usepackage{enumitem}
\usepackage{thmtools, thm-restate}
\usepackage{wrapfig,tikz}
\usepackage{amsmath,longtable,fancyhdr,multirow,graphicx,float}
\usepackage{amssymb,xcolor,amsthm}
\usepackage{subfigure}
\usepackage{color}
\usepackage{colortbl}
\usepackage{theoremref}
\newcommand{\abs}[1]{\lvert#1\rvert}
\newcommand{\intercal}{\intercal}
\newcommand{\mbf}[1]{\mathbf{#1}}
\newcommand{\bs}[1]{\boldsymbol{#1}}
\newcommand{\mbb}[1]{\mathbb{#1}}
\newcommand{\mathrm{d}}{\mathrm{d}}
\newcommand{\mathrm}{\mathrm}
\def\mathrm{\mathchar'26\mkern-12mu d}{\mathrm{\mathchar'26\mkern-12mu d}}
\newcommand{\sim}{\sim}
\newcommand{\mathcal}{\mathcal}
\newcommand{\norm}[1]{\left\lVert#1\right\rVert}
\newtheorem{problem}{Problem}
\newtheorem{lemma}{Lemma}
\newtheorem{theorem}{Theorem}
\newtheorem{corollary}{Corollary}
\newtheorem{remark}{Remark}
\newtheorem{observation}{Observation}
\newtheorem{proposition}{Proposition}
\newtheorem{assumption}{Assumption}
\newtheorem{innercustomthm}{Theorem}
\newtheorem{definition}{Definition}
\newenvironment{customthm}[1]
{\renewcommand\theinnercustomthm{#1}\innercustomthm}
{\endinnercustomthm}
\newtheorem{innercustomlem}{Lemma}
\newenvironment{customlem}[1]
{\renewcommand\theinnercustomlem{#1}\innercustomlem}
{\endinnercustomlem}
\newtheorem{innercustomhyp}{Hypothesis}
\newenvironment{customhyp}[1]
{\renewcommand\theinnercustomhyp{#1}\innercustomhyp}
{\endinnercustomhyp}
\newtheorem{innercustomprop}{Proposition}
\newenvironment{customprop}[1]
{\renewcommand\theinnercustomprop{#1}\innercustomprop}
{\endinnercustomprop}
\newcommand{\begin{equation}}{\begin{equation}}
\newcommand{\end{equation}}{\end{equation}}
\definecolor{Gray}{gray}{0.85}
\definecolor{LightCyan}{rgb}{0.88,1,1}
\newcolumntype{a}{>{\columncolor{Gray}}c}
\newcolumntype{b}{>{\columncolor{white}}c}
\DeclareMathOperator*{\argmin}{arg\,min}
\DeclareMathOperator*{\argmax}{arg\,max}
\DeclareMathOperator*{\argsup}{arg\,sup}
\DeclareMathOperator*{\arginf}{arg\,inf}
\makeatletter
\usepackage{xspace}
\def\@onedot{\ifx\@let@token.\else.\null\fi\xspace}
\DeclareRobustCommand\onedot{\futurelet\@let@token\@onedot}
\newcommand{\figref}[1]{Figure~\ref{#1}}
\newcommand{\eqnref}[1]{Eq\onedot~\eqref{#1}}
\newcommand{\secref}[1]{Section~\ref{#1}}
\newcommand{\tabref}[1]{Tab\onedot~\ref{#1}}
\newcommand{\thmref}[1]{Theorem~\ref{#1}}
\newcommand{\prgref}[1]{Program~\ref{#1}}
\newcommand{\clmref}[1]{Claim~\ref{#1}}
\newcommand{\lemref}[1]{Lemma~\ref{#1}}
\newcommand{\corref}[1]{Corollary~\ref{#1}}
\newcommand{\propref}[1]{Proposition~\ref{#1}}
\newcommand{\ptyref}[1]{Property~\ref{#1}}
\newcommand{\boldsymbol{\theta}}{\boldsymbol{\theta}}
\newcommand{\boldsymbol{\alpha}}{\boldsymbol{\alpha}}
\def\emph{e.g}\onedot{\emph{e.g}\onedot}
\def\emph{E.g}\onedot{\emph{E.g}\onedot}
\def\emph{i.e}\onedot{\emph{i.e}\onedot}
\def\emph{I.e}\onedot{\emph{I.e}\onedot}
\def\emph{cf}\onedot{\emph{cf}\onedot}
\def\emph{Cf}\onedot{\emph{Cf}\onedot}
\def\emph{etc}\onedot{\emph{etc}\onedot}
\def\emph{vs}\onedot{\emph{vs}\onedot}
\defw.r.t\onedot{w.r.t\onedot}
\defd.o.f\onedot{d.o.f\onedot}
\defa.k.a\onedot{a.k.a\onedot}
\defi.i.d\onedot{i.i.d\onedot}
\def\emph{et al}\onedot{\emph{et al}\onedot}
\newcommand\numberthis{\addtocounter{equation}{1}\tag{\theequation}}
\newcommand{\mathbb{R}}{\mathbb{R}}
\newcommand{\mathbb{E}}{\mathbb{E}}
\newcommand{\mathbb{E}}{\mathbb{E}}
\newcommand{{\mathcal{N}}}{{\mathcal{N}}}
\newcommand{\mathcal{X}}{\mathcal{X}}
\newcommand{\mathcal{Z}}{\mathcal{Z}}
\newcommand{\mathcal{T}}{\mathcal{T}}
\newcommand{{\mathcal{Y}}}{{\mathcal{Y}}}
\newcommand{\mathcal{P}_x}{\mathcal{P}_x}
\newcommand{\mathcal{A}}{\mathcal{A}}
\newcommand{\tilde{A}}{\tilde{A}}
\newcommand{\hat{y}}{\hat{y}}
\newcommand{\mathbf{x}}{\mathbf{x}}
\newcommand{\mathbf{y}}{\mathbf{y}}
\newcommand{{\mathrm{KL}}}{{\mathrm{KL}}}
\DeclareMathOperator{\tr}{tr}
\DeclareMathOperator{\diag}{diag}
\DeclareMathOperator{\Cov}{Cov}
\DeclareMathOperator{\Var}{Var}
\newcommand{\chris}[1]{ {\color{cyan} [Chris: #1]}}
\newcommand{\sj}[1]{ {\color{magenta} [SJ: #1]}}
\newcommand{\ys}[1]{\textcolor{blue}{Yang: #1}}
\newcommand{\s}[1]{\textcolor{blue}{SE: #1}}
\bibliographystyle{unsrtnat}
\begin{document}
\twocolumn[
\aistatstitle{A Framework for Sample Efficient Interval Estimation with Control Variates}
\aistatsauthor{ Shengjia Zhao \And Christopher Yeh \And Stefano Ermon }
\aistatsaddress{ Stanford University \And Stanford University \And Stanford University } ]
\begin{abstract}
We consider the problem of estimating confidence intervals for the mean of a random variable, where the goal is to produce the smallest possible interval for a given number of samples. While minimax optimal algorithms are known for this problem in the general case, improved performance is possible under additional assumptions. In particular, we design an estimation algorithm to take advantage of side information in the form of a control variate, leveraging order statistics. Under certain conditions on the quality of the control variates, we show improved asymptotic efficiency compared to existing estimation algorithms. Empirically, we demonstrate superior performance on several real world surveying and estimation tasks where we use the output of regression models as the control variates.
\end{abstract}
\input{introduction.tex}
\input{setup.tex}
\input{method.tex}
\input{related.tex}
\input{experiments.tex}
\input{conclusion.tex}
\input{acknowledgments.tex}
\section{Control Variates Interval Estimation}
\subsection{Estimation by Order Statistics}
\label{sec:estimation_procedure}
For convenience we denote $Z = Y - {\tilde{Y}}$ and $z_i = y_i - {\tilde{y}}_i$. Given the samples $z_1, \dotsc, z_m$ we can compute their order statistics, which are the $m$ samples in sorted order such that $Z_{(1)} \leq \dotsb \leq Z_{(m)}$.
We first study the one dimensional real valued case (i.e. $Z \in \mathcal{Z} = \mathbb{R}$).
Our control variate estimation algorithm consists of three steps: given input samples $z_1, \dotsc, z_m$, $\mathbb{E}[{\tilde{Y}}] \in \mathbb{R}$ and desired confidence $\zeta \in (0, 1)$
\textbf{1)} Choose some value of $k \in \{0, \dotsc, m-1\}$. Set
\begin{equation}
\hat{\mu} = \mathbb{E}[{\tilde{Y}}] + \frac{Z_{(m-k)} + Z_{(1+k)}}{2}
\label{eq:hat_mu}
\end{equation}
\textbf{2)} Let $r$ be the smallest value such that the following concentration inequalities are true:
\begin{align*}
\Pr\left[Z_{(m-k)} < \mathbb{E}[Z] - r\right] &\leq \zeta/2 \\
\Pr\left[Z_{(1+k)} > \mathbb{E}[Z] + r\right] &\leq \zeta/2
\numberthis\label{eq:order_bound}
\end{align*}
Algorithm~\ref{alg:bound} computes such a value of $r$.
\textbf{3)} Output $\hat{\mu}$ as the estimate of $\mathbb{E}[Y]$ and $r + \frac{Z_{(m-k)} - Z_{(1+k)}}{2}$ as the confidence interval size.
The following proposition guarantees the correctness of the control variate estimation algorithm.
\begin{restatable}{proposition}{orderbound}
\label{prop:validity}
Let $\hat{\mu}$ be defined as in Eq.(\ref{eq:hat_mu}). If Eq.(\ref{eq:order_bound}) is satisfied for some $\zeta \in (0, 1)$ and $c > 0$, then
\begin{align*}
\Pr\left[\lvert \hat{\mu} - \mathbb{E}[Y] \rvert > r + \frac{Z_{(m-k)} - Z_{(1+k)}}{2} \right] \leq \zeta. \numberthis\label{eq:concentration_order}
\end{align*}
\end{restatable}
\begin{proof}[Proof of Proposition~\ref{prop:validity}] See Appendix.
\end{proof}
Note that in Eq.(\ref{eq:concentration_order}), the confidence interval size consists of two parts: $\frac{Z_{(m-k)} - Z_{(1+k)}}{2}$ and $c$. We will show that $c$ is much smaller (in fact, has asymptotically better rates) compared to baselines previously discussed in Section~\ref{sec:baseline}. If we have a good control variate ${\tilde{Y}}$ (close to $Y$), then $\frac{Z_{(m-k)} - Z_{(1+k)}}{2}$ will be small. On the other hand, if the control variate ${\tilde{Y}}$ is poor, this algorithm could produce worse (larger) confidence intervals. This trade-off is unavoidable because of ``no-free-lunch results''~\citep{van2000asymptotic}.
\subsection{Order Statistics Concentration Inequalities}
\label{sec:order_bounds}
We will now show several bounds on the order statistics in Eq.(\ref{eq:order_bound}). There are several known bounds~\citep{de2007extreme,castillo2012extreme} that can be applied to satisfy Eq.(\ref{eq:order_bound}). However, these bounds are distribution dependent: we must assume that $Z$ either is distributed as some known distribution (e.g. Gaussian), or asymptotically converges to some fixed distribution (e.g. Gumbel, Weibull or Frechet using the Fisher–Tippett–Gnedenko theorem) when $m$ is very large~\citep{fisher1928limiting}.
Our contribution is to associate bounds on the order statistics with the notion of resilience used in the robust statistics literature. Many distribution independent conditions for resilience are known, which imply \emph{distribution independent bounds on the order statistics}.
We first reproduce the definition of resilience from \citet{steinhardt2018robust} with a small modification.
\begin{definition}
\label{def:resilience}
Let $s: [0, 1] \to \mathbb{R}^+$ be any function. We say a random variable $Z \in \mathcal{Z}$ is $s$-resilient from above if for any $\epsilon \in [0, 1]$ and measurable $B \subseteq \mathcal{Z}$ such that $\Pr[Z \in B] \geq 1 - \epsilon$, we have
\[
\mathbb{E}[Z|Z\in B] - \mathbb{E}[Z] \leq s(\epsilon).
\]
It is $s$-resilient from below if
\[
\mathbb{E}[Z] - \mathbb{E}[Z|Z\in B] \leq s(\epsilon).
\]
We say that $Z$ is $s$-resilient if it is both $s$-resilient from above and $s$-resilient from below.
\end{definition}
When a random variable is $s$-resilient, we are essentially bounding the probability that $Z$ takes a value much larger (or smaller) than $\mathbb{E}[Z]$. To see this, suppose for some $\epsilon \in (0, 1)$, we choose $B = \lbrace Z: Z > \mathbb{E}[Z] + s(\epsilon) \rbrace$, then $\mathbb{E}[Z\vert Z \in B] - \mathbb{E}[Z] > s(\epsilon)$, then by our requirement of resilience, it must be that $\Pr[Z \in B] < 1 - \epsilon$. Similar to other types of assumptions such as sub-Gaussian or bounded moments, resilience is also an assumption on how much a random variable can differ from its expectation. What is special about resilience is that it is particularly convenient for showing bounds on the order statistics.
Without loss of generality, we also assume that $s(\epsilon)$ is monotonically non-decreasing. If a random variable is $\hat{s}$-resilient, but $\hat{s}$ is not monotonically non-decreasing, we can define $s(\epsilon) = \inf_{\epsilon \leq \epsilon' \leq 1} \hat{s}(\epsilon')$, which is monotonically non-decreasing. It is easy to show that $Z$ is $s$-resilient if and only if it is $\hat{s}$-resilient.
Many assumptions on the random variable $Z$ can be converted into assumptions on resilience. For example, in the following Lemma~\ref{lemma:example_resilient}, (1) is trivial to show, (2) is proved in \citep{steinhardt2018robust}, and (3) we prove in the appendix.
\begin{restatable}{lemma}{resilient}
\label{lemma:example_resilient}
The following random variables are resilient:
\begin{enumerate}
\item \textbf{Bounded:} If $\mathcal{Z} \subseteq [a, b]$, then $Z$ is $(b-\mathbb{E}[Z])$-resilient from above and $(\mathbb{E}[Z]-a)$-resilient from below. It is $(b-a)$-resilient.
\item \textbf{Bounded Moments:} If $\mathbb{E}\left[ |Z-\mathbb{E}[Z]|^l \right] \leq \sigma^l$ for some $l > 1$, then $Z$ is $s$-resilient for $s(\epsilon)=\frac{\sigma}{(1-\epsilon)^{1/l}}$.
\item \textbf{Sub-Gaussian:} If $Z - \mathbb{E}[Z]$ is $\sigma^2$ sub-Gaussian, then $Z$ is $s$-resilient for $s(\epsilon)=\sqrt{2\sigma\log\frac{1}{1 - \epsilon}} + \sqrt{2\pi}\sigma$.
\end{enumerate}
\end{restatable}
Given the definition and examples of resilience, we can now use the following theorem to provide bounds on the order statistics when resilience holds.
\begin{restatable}{theorem}{singledim}
\label{thm:resilient}
Let $Z_{(1)}, \dotsc, Z_{(m)}$ denote the order statistics of $m$ independent samples of a random variable $Z$.
If $Z$ is $s$-resilient, $\forall \zeta \in (0, 1), T \in \mathbb{N}$ and $0 \leq k < m/2$, then letting $r$ be the output of Algorithm~\ref{alg:bound}, we have
\begin{align}
\Pr\left[Z_{(m-k)} \leq \mathbb{E}[Z] - r\right] &\leq \zeta \label{eq:upper_bound} \\
\Pr\left[Z_{(1+k)} \geq \mathbb{E}[Z] + r\right] &\leq \zeta \label{eq:lower_bound}
\end{align}
If $Z$ is $s$-resilient from above/below, then only Eq.(\ref{eq:upper_bound})/Eq.(\ref{eq:lower_bound}) holds.
\end{restatable}
\begin{proof}[Proof of Theorem~\ref{thm:resilient}] See Appendix.
\end{proof}
Note that the algorithm has an additional hyper-parameter $T$ which is the number of iterations. We can choose any value of $T \in \mathbb{N}$, but choosing a large $T$ always leads to a better confidence interval compared to choosing a smaller $T$. We observe in the experiments that choosing any $T \geq 10$ is optimal (up to floating point errors). Note that the choice of $T$ does not affect the asymptotic performance in Corollary~\ref{cor:asymptote}.
\begin{algorithm}
Input: sample size $m \in \mathbb{N}^+$; order $k < m/2$; confidence $\zeta \in (0, 1)$; resilience $s: (0, 1) \to \mathbb{R}^+$; and number of iterations $T \in \mathbb{N}$
\begin{algorithmic}
\State Set $v_0 = \stuffn$
\For {$i=1, \dotsc, T$}
\State Set $v_i= \left(\frac{\zeta}{(m(1-v_{i-1})+1)^k}\right)^{\frac{1}{m-k}}$
\EndFor
\State Set $r = s(v_T) (v_T^{-1} - 1)$
\State Return $v_T$ and $r$
\end{algorithmic}
\caption{Order Statistics Confidence Interval}
\label{alg:bound}
\end{algorithm}
Theorem~\ref{thm:resilient} involves expressions with good constants. This obscures the asymptotic performance of the bound, which we reveal in the following corollary.
\begin{restatable}{corollary}{asymptote}
\label{cor:asymptote}
If $Z$ is $b_1(1-\epsilon)^a + b_2$ resilient for any constants $a \in [-1, 0]$ and $b_1, b_2 \in \mathbb{R}^+$, then there exists $\lambda > 0$ such that for sufficiently large $m$
\begin{align*}
\Pr&\left[\mathbb{E}[Z] \leq Z_{(1+k)} - \lambda\frac{\log \frac{1}{\zeta} + k\log m}{m^{1+a}} \right] \leq \zeta \\
\Pr&\left[\mathbb{E}[Z] \geq Z_{(m-k)} + \lambda\frac{\log \frac{1}{\zeta} + k\log m}{m^{1+a}} \right] \leq \zeta.
\end{align*}
\end{restatable}
\begin{proof}[Proof of Corollary~\ref{cor:asymptote}] See Appendix.
\end{proof}
Based on different assumptions on resilience in Lemma~\ref{lemma:example_resilient}, we can further simplify Corollary~\ref{cor:asymptote} and obtain more concrete bounds in Section~\ref{sec:comparison}.
Finally, in Lemma~\ref{lemma:example_resilient}, a random variable $Z$ bounded in $[a, b]$ is $s$-resilient, but $s$ depends on $\mathbb{E}[Z]$ which is unknown. Therefore, we cannot evaluate $s$ in Algorithm~\ref{alg:bound}. One option is to use the weaker conclusion that $Z$ is $(b-a)$-resilient and obtain a bound with worse constants (we choose this option in our asymptotic rate analysis in Section~\ref{sec:comparison}).
In practice it is possible to compute a bound with better constants: we only compute $v_T$ in Algorithm~\ref{alg:bound} which does not depend on $s$, and use the following improved bound.
\begin{restatable}{corollary}{boundedexample}
\label{cor:bounded_example}
Let $Z_{(1)}, \dotsc, Z_{(m)}$ denote the order statistics of $m$ independent samples of a random variable $Z$. If $Z$ is bounded in $[a, b]$, $\forall \zeta \in (0, 1), T \in \mathbb{N}$ and $0 \leq k < m/2$, then letting $v_T$ be computed as in Algorithm~\ref{alg:bound}, we have
\begin{align*}
\Pr\left[ \mathbb{E}[Z] \leq a + v_T(Z_{(1+k)} - a) \right] & \leq \zeta \\
\Pr\left[ \mathbb{E}[Z] \geq b - v_T(b - Z_{(m-k)}) \right] & \leq \zeta.
\end{align*}
\end{restatable}
\begin{proof}[Proof of Corollary~\ref{cor:bounded_example}] See Appendix.
\end{proof}
Instead of the standard estimation procedure in Section~\ref{sec:control_variates}, we directly output
$$
\left[a + v_T(Z_{(1+k)} - a),\ b - v_T(b - Z_{(m-k)})\right]
$$
as our confidence interval for $\mathbb{E}[Z]$ (that holds with $1-2\zeta$ probability) in the experiments.
\subsection{Multi-Dimensional Extension}
We will extend the above results to multi-dimensional estimation problems. We first provide a multi-dimensional definition of resilience that extends Definition~\ref{def:resilience}.
\begin{definition}
Let $Z$ be a random variable on $\mathcal{Z} \subseteq \mathbb{R}^d$, and $\lVert \cdot \rVert, \lVert \cdot \rVert_*$ be a pair of dual norms on $\mathbb{R}^d$. We say $Z$ is $s$-resilient if $\forall v \in \mathbb{R}^d$ such that ${\lVert v \rVert_*} = 1$, and for all measurable $B \subseteq \mathcal{Z}$ such that $\Pr[B] \geq 1 - \epsilon$, we have
$$
\mathbb{E}[\langle Z, v \rangle \vert B] - \mathbb{E}[\langle Z, v \rangle ] \leq s(\epsilon).
$$
\end{definition}
As before, resilience in multiple dimensions also implies concentration bounds on the order statistics. The following theorem is the analog of Theorem~\ref{thm:resilient}.
\begin{restatable}{theorem}{multidim}
\label{thm:multi-dim}
Let $Z_{(1)}, \dotsc, Z_{(m)}$ be independent samples of $Z$ ordered such that
$\lVert Z_{(1)} \rVert \leq \dotsb \leq \lVert Z_{(m)} \rVert$.
If $Z$ is $s$-resilient, then for any $r$ output by Algorithm~\ref{alg:bound} and for any $\zeta \in (0, 1)$, we have
$$
\Pr\left[\lVert Z_{(m-k)} \rVert \leq \lVert \mathbb{E}[Z] \rVert - r \right] \leq \zeta.
$$
\end{restatable}
\begin{proof}[Proof of Theorem~\ref{thm:multi-dim}] See Appendix.
\end{proof}
\subsection{Rate Comparison}
\label{sec:comparison}
Table~\ref{table:rate} summarizes the asymptotic performance of our method compared to the baselines. Even though we consider the low sample setup (i.e. $m$ is small), these asymptotic rates still provide insight into the trade-off between different methods.
In particular, as shown in Proposition~\ref{prop:validity} our method has two terms that determine the confidence interval: $r$ and $\frac{Z_{(m-k)} - Z_{(1+k)}}{2}$.
\begin{align*}
\Pr\left[\lvert \hat{\mu} - \mathbb{E}[Y] \rvert > r + \frac{Z_{(m-k)} - Z_{(1+k)}}{2} \right] \leq \zeta.
\end{align*}
The latter term we will denote as $B$ and it is determined by the quality of the control variate. For baseline methods there is only a single term $c$ that determines the size of the confidence interval:
\begin{align*}
\Pr\left[\lvert \hat{\mu} - \mathbb{E}[Y] \rvert > c \right] \leq \zeta.
\end{align*}
In Table~\ref{table:rate}, we show that under each class of assumptions, $r$ in our proposed algorithm always has a better rate compared to $c$ (i.e. it is smaller when $m, \zeta$ are sufficiently large). Whether the improvement can justify the additional term $B$ determines whether our algorithm performs well in practice.
\begin{table*}
\begin{center}
\begin{tabular}{c|c|c}
Conditions on $Z$ & Bounded in $[a, b]$ & Finite $\mathbb{E}[Z^2]$ \\
\hline
Mean $\frac{1}{m} \sum_i Z_i$
& $\Theta\left( \sqrt{\frac{1}{m}\log \frac{1}{\zeta}} \right)$ (Chernoff)
& $\Theta\left( \frac{1}{\sqrt{m \zeta}}\right)$ (Chebyshev) \\
\hline
Maximum (Minimum) $Z_{(m)}, Z_{(1)}$
& $B + O\left( \frac{1}{m}\log \frac{1}{\zeta} \right)$
& $B + O\left( \frac{1}{\sqrt{m}}\log \frac{1}{\zeta} \right)$ \\
\hline
$k$-th largest (smallest) $Z_{(m-k)}, Z_{(1+k)}$
& $B + O\left( \frac{k\log m}{m} \log \frac{1}{\zeta} \right)$
& $B + O\left( \frac{k\log m}{\sqrt{m}} \log \frac{1}{\zeta} \right)$
\end{tabular}
\end{center}
\caption{Summary of asymptotic size of the confidence interval for estimation algorithms using different concentration inequalities. $B$ is some value that corresponds to the bias of our method because of the $\frac{Z_{(m-k)} - Z_{(1+k)}}{2}$ term in Proposition~\ref{prop:validity}.}
\label{table:rate}
\end{table*}
\subsection{Special Case: Weighted Average}
Suppose $Y \in [0, 1]$ with $\mathbb{E}[Y] = \mu$ and $\Cov[Y] = \Sigma \in \mathbb{R}^{d \times d}$. We start by considering a particular property $\theta = \mathbb{E}[\tilde{A} Y] = \tilde{A} \mathbb{E}[Y] = \tilde{A} \mu$ for some arbitrary given matrix $\tilde{A} \in \mathbb{R}^{k \times d}$. This setting represents a weighted average of $Y$. For example:
\begin{itemize}
\item If $\tilde{A} = I_d$, then $\theta = \mathbb{E}[Y] = \mu$ is the element-wise average of $Y$.
\item If $\tilde{A} = \mathbf{1}_d^T$, then $\theta = \mathbb{E}[\mathbf{1}_d^T Y] = \mathbf{1}_d^T \mu$ is the average sum of $Y$.
\item If $\tilde{A} = (W^T W)^{-1} W^T$ for some fixed matrix $W \in \mathbb{R}^{d \times k}$, then $\theta = (W^T W)^{-1} W^T \mu$ minimizes $\|W \theta - Y\|_2$.
\end{itemize}
From Section \ref{sec:linear_case}, we know that our unbiased estimator is
$$
A(y_{1:l}) = \frac{1}{l} \sum_i \tilde{A} y_i.
$$
By the Real Spectral Theorem, since $\tilde{A}^T \tilde{A}$ is a real symmetric matrix, it is diagonalizable with respect to an orthonormal basis of its eigenvectors. Concretely, there exists a set of orthonormal eigenvectors $q_1, \dotsc, q_d$ with corresponding eigenvalues $\lambda_1, \dotsc, \lambda_d$ such that $\tilde{A}^T \tilde{A} = Q \Lambda Q^T \in \mathbb{R}^{d \times d}$, where $Q = [q_1, \dotsc, q_d]$ and $\Lambda = \diag(\lambda_1, \dotsc, \lambda_d)$. $Q$ is an orthogonal matrix. Furthermore, $\tilde{A}^T \tilde{A}$ is positive semi-definite, so all of the eigenvalues are non-negative: $\lambda_i \geq 0$.
\paragraph{Option 1.}
We draw $m$ independent examples $(x_i, y_i)$.
$$
\Cov[A(y_{1:m})] = \frac{1}{m} \tilde{A} \Sigma \tilde{A}^T
$$
Since the bias of our estimator is 0, the MSE of our estimator is
\begin{align*}
\mathbb{E}[\| A(y_{1:m}) - \tilde{A} \mu \|_2^2]
&= \tr \Cov[A(y_{1:m})]
= \frac{\tr(\tilde{A}\Sigma \tilde{A}^T)}{m}
= \frac{\tr(\Sigma \tilde{A}^T\tilde{A})}{m} \\
&= \frac{\tr(\Sigma Q \Lambda Q^T)}{m}
= \frac{1}{m} \sum_{i=1}^d \lambda_i q_i^T \Sigma q_i
\end{align*}
\paragraph{Option 2.}
We sample $n \gg m$ examples of $x_i$, then compute $\hat{y}_i = f(x_i)$. Suppose that for each $x_i$, the true label is $y_i = \mathbb{E}_{Y|X=x_i}[Y]$. Let $\epsilon_i$ denote the error from $f(x_i)$, so $\hat{y}_i = y_i + \epsilon_i$. Then
$$
A(\hat{y}_{1:n}) = \frac{1}{n} \sum_i \tilde{A} y_i + \tilde{A} \epsilon_i
$$
The bias-variance decomposition of MSE gives
$$
\mathbb{E}[\| A(\hat{y}_{1:n}) - \tilde{A}\mu \|_2^2]
= \| \mathbb{E}[A(\hat{y}_{1:n})] - \tilde{A}\mu \|_2^2 + \tr \Var[A(\hat{y}_{1:n})].
$$
Suppose that $\Cov[f(X)] = \hat\Sigma$. Then, the bias and variance terms can be written as follows.
\begin{align*}
\mathbb{E} [A(\hat{y}_{1:n})] - \tilde{A}\mu
&= \tilde{A} \mathbb{E} [y_i] + \tilde{A} \mathbb{E}[\epsilon_i] - \tilde{A}\mu
= \tilde{A} \mathbb{E}[\epsilon] \\
\tr\Var[A(\hat{y}_{1:n})]
&= \tr(\tilde{A} \hat\Sigma \tilde{A}^T) / n
\end{align*}
For large enough $n$, we can assume the variance to be negligible. Therefore, we only care about the bias. We can write the bias as follows:
\begin{align*}
\| \mathbb{E}[A(\hat{y}_{1:n})] - \tilde{A}\mu \|_2^2
&= \| \tilde{A} \mathbb{E}[\epsilon] \|_2^2
= \tr\left( \| \tilde{A} \mathbb{E}[\epsilon] \|_2^2 \right) \\
&= \tr\left( Q^T \mathbb{E}[\epsilon] \mathbb{E}[\epsilon]^T Q \Lambda \right)
= \sum_{i=1}^d \lambda_i q_i^T \mathbb{E}[\epsilon] \mathbb{E}[\epsilon]^T q_i \\
&= \sum_{i=1}^d \lambda_i (q_i^T \mathbb{E}[\epsilon])^2
\end{align*}
\chris{This section is still a work in progress.} Therefore, the difference in MSE between Option 1 and Option 2 is as follows. We aim to show that the following quantity is positive:
\begin{align*}
\frac{1}{m} \sum_{i=1}^d \lambda_i q_i^T \Sigma q_i - \sum_{i=1}^d \lambda_i (q_i^T \mathbb{E}[\epsilon])^2
&= \sum_{i=1}^d \lambda_i q_i^T \left( \frac{1}{m} \Sigma - \mathbb{E}[\epsilon] \mathbb{E}[\epsilon]^T \right) q_i
\end{align*}
\begin{align*}
\| \mathbb{E}[A(\hat{y}_{1:n})] - \tilde{A}\mu \|_2^2
&= \tr\left( Q^T \mathbb{E}[\epsilon] \mathbb{E}[\epsilon]^T Q \Lambda \right) \\
&\leq \tr\left( Q^T \mathbb{E}[\epsilon] \mathbb{E}[\epsilon]^T Q \right) \tr(\Lambda)
= \tr\left( Q Q^T \mathbb{E}[\epsilon] \mathbb{E}[\epsilon]^T \right) \tr(\Lambda) \\
&= \tr\left(\mathbb{E}[\epsilon] \mathbb{E}[\epsilon]^T\right) \tr(\Lambda)
= \left( \sum_{i=1}^d \mathbb{E}[\epsilon_i] \right) \left( \sum_{i=1}^d \lambda_i \right)
\end{align*}
Since we assume $Y \in [0, 1]$, this means that $\epsilon \in [-1, 1]$. From Lemma~\ref{lemma:max}, we know that
$$
\Pr\left( \mathbb{E}[\epsilon] > \max_i \epsilon_i - 2 (1 - \zeta^{1/m}) \right)
< \zeta.
$$
We aim to show something like:
$$
\Pr\left[ \| \mathrm{Bias} \|_2^2 > 3 \| \epsilon \tilde{A} \|_2^2 + 3\frac{c^2}{m} \| \tilde{A} \mathbf{1} \|_2^2 \right] < \zeta
$$
\subsection{Mean Estimation}
Using the lemmas above, we get the following confidence intervals. For $\zeta \in [0, 1]$, with probability $\geq 1 - 2\zeta$:
$$
\mathbb{E}[Y] \in \left[
\frac{1}{n} \sum_{i=1}^n f(X_i) - \epsilon_{(m)} - 2(1-\zeta^{1/m}),
\frac{1}{n} \sum_{i=1}^n f(X_i) - \epsilon_{(1)} + 2(1-\zeta^{1/m})
\right]
$$
$$
\mathbb{E}[Y] \in \left[
\bar{Y} - \sqrt{-\frac{\ln \zeta}{2m}},
\bar{Y} + \sqrt{-\frac{\ln \zeta}{2m}}
\right]
$$
\newpage
\chris{Below this is old}
Now, we will try to show that even if we have 0 error on the $m$ labeled data points, our estimator may still have large bias. Consider a particularly perverse $\epsilon$. Suppose for a subset $\mathcal{X}_\mathrm{bad} \subset \mathcal{X}$ where $\Pr[\mathcal{X}_\mathrm{bad}] = \delta$, we have $\epsilon(x) = \mathbf{1}$, while for all other $x$, $\epsilon(x)=\mathbf{0}$. Then
$$
\Pr\left[\forall i=1, \dotsc, m.\quad \epsilon(x_i) = \mathbf{0}\right]
= (1-\delta)^m
= \zeta > 0
$$
Solving for $\delta$ gives $\delta = 1 - e^{(\ln \zeta)/m} \leq -(\ln \zeta)/m$, using the inequality that $\forall x.\ e^x \geq x + 1$.
\chris{The following claim still doesn't make sense to me. We want to say something like $$\Pr[\mathbb{E}[\epsilon] > b \mid \epsilon_1 = \dotsb = \epsilon_m = \mathbf{0}] = \zeta$$ but how can you properly compute this conditional probability? We don't know $\Pr[\mathbb{E}[\epsilon] > b]$ and we don't know $\Pr[\epsilon_1 = \dotsb = \epsilon_m = \mathbf{0}]$.}
In other words, even when we observe $\epsilon_1, \dotsc, \epsilon_m = \mathbf{0}$, it is still the case that with probability $\zeta$,
$$
\mathbb{E}[\epsilon] \geq \frac{-\log \zeta}{m} \mathbf{1}
$$
This implies that
\[ \lVert \tilde{A} \mathbb{E}[\epsilon] \rVert^2 \geq \left(\frac{-\log \zeta}{m} \right)^2 \mathrm{tr}(\mathrm{1}\mathrm{1}^T \tilde{A} \tilde{A}^T) \]
\subsection{Linear Case}\label{sec:linear_case}
We first show the simpler case where $A$ is linear in $y_{1:l}$. For any given set of $x_{1:l}$, for $A$ to be linear in $y_{1:l}$ there must be a sequence of $A_1, A_2, \dotsc, A_l \in \mathbb{R}^{k \times d}$, and $A(y_{1:l}) = \sum_i A_i y_i$. In addition, because it must also be unbiased, so there must be some $\theta$ independent of $l$, such that
$$
\theta
= \mathbb{E}\left[\sum_i A_i y_i\right]
= \sum_i A_i \mathbb{E}[y_i]
= \left( \sum_i A_i \right) \mu
$$
\chris{Why is the following claim true?}
This implies that $A_i = \frac{1}{l} \tilde{A}(x_i)$. Therefore any such unbiased estimator linear in $y_{1:l}$ must be equal to
$$
A(x_{1:l}, y_{1:l}) = \frac{1}{l} \sum_i \tilde{A}(x_i) y_i
$$
where $\tilde{A}: \mathcal{X} \to \mathbb{R}^{k \times d}$. Without loss of generality we assume this is how $A$ is defined.
\subsection{Non-linear Case}
Suppose we know that our estimator has asymptotically normal error, which is true for any MLE estimator.
$$
\lim_{l \to \infty} A(y_1, \dotsc, y_l) \to \mathcal{N}(\mu^*, \Sigma/l) $$
The MSE error will be $ \mathbb{E}[(A(y_{1:l}) - \mu^*)^2] $
$$
\mathbb{E}[(A(y_{1:l}) - \mu^*)^2] = \tr \Sigma / l
$$
Consider how a small perturbation can affect $A$. Let $\partial_i$ denote the gradient with respect to the $i$-th argument, and let $\epsilon_i = y_i - f(x_i)$. We use a Taylor expansion and get (with notational shorthand of $Y^* = g^*(x_1), \cdots, g^*(x_n)$)
\begin{align*}
A(y_1, \cdots, y_n) &\approx A(Y^*) + \sum_{i=1}^n \partial_i A(Y^*) \epsilon_i \\
\end{align*}
The bias of our approach is therefore
$$
\mathbb{E} [A(y_1, \dotsc, y_n) - A(Y^*)]
\approx \sum_{i=1}^n \partial_i A(Y^*) \mathbb{E}[\epsilon_i]
$$
Consider a particularly perverse $\epsilon$. Suppose for a subset $\mathcal{X}_\mathrm{bad} \subset \mathcal{X}$, such that $\Pr[\mathcal{X}_\mathrm{bad}] = \delta$, we have $\epsilon(x) = 1$, while for all other $x$, $\epsilon(x)=0$ then we know that
$$
\Pr[\forall i=1, \dotsc, m.\quad \epsilon(x_i) = 0] = (1-\delta)^m = \zeta
$$
That is we know that $\delta = 1 - e^{(\ln \zeta) / m} \leq -\ln \zeta/m$. Then there is no way to conclude that
$$
\mathbb{E} [\| A(y_1, \cdots, y_n) - A(Y^*) \|_2^2]
\leq \frac{-\log \zeta}{m}
$$
For comparison need some method of saying: if $\partial_i A$ is small, then $A$ is stable, and direct estimation should also yield low error.
\section{Appendix}
\subsection{Hoeffding's Inequalities}
If $X_1, \dotsc, X_n \in [a, b]$ are independent random variables, then for any $t > 0$,
\begin{gather}
\Pr[\bar X - \mathbb{E}[X] \geq t] \leq \exp(-2n t^2 / (b-a)^2) \\
\Pr[\bar X - \mathbb{E}[X] \leq -t] \leq \exp(-2n t^2 / (b-a)^2) \\
\Pr\left[\left| \bar X - \mathbb{E}[X] \right| \geq t \right] \leq 2 \exp(-2n t^2 / (b-a)^2)
\end{gather}
In particular,
$$
\Pr\left( X > \mathbb{E}[X] - t \right)
\quad=\quad
1 - \Pr\left( X \leq \mathbb{E}[X] - t \right)
\quad\geq\quad
1 - e^{-2 t^2 / (b-a)^2}
$$
\subsection{Cantelli's Inequality}
$$
\Pr(X > \mathbb{E}[X] - c) \geq 1 - \frac{\sigma^2}{\sigma^2 + c^2}
$$
\subsection{Trace}
\begin{lemma}
Consider two matrices $K, B \in \mathbb{R}^{n \times n}$ where $B$ can be diagonalized as $Q \Lambda Q^T$. Let $q_1, \dotsc, q_n$ be the columns of $Q$, and let $\Lambda = \diag(\lambda_1, \dotsc, \lambda_n)$. Then
$$
\tr(K B) = \sum_{i=1}^n \lambda_i q_i^T K q_i.
$$
\end{lemma}
\begin{proof}
\begin{align*}
\tr(KB)
&= \tr(K Q \Lambda Q^T) \\
&= \tr(Q^T K Q \Lambda) \\
&= \sum_{i=1}^n (Q^T K Q)_{ii} \lambda_i \\
&= \sum_{i=1}^n \lambda_i q_i^T K q_i.
\end{align*}
\end{proof}
\begin{lemma} Let $D = \diag(\bar{d}) \in \mathbb{R}^{n \times n}$ be a diagonal matrix with non-negative entries. For any square matrix $A \in \mathbb{R}^{n \times n}$ with non-negative entries on the diagonal $\bar{a}$,
$$ \tr(A D) \leq \tr(A) \tr(D). $$
The inequality is tight iff $\bar{a}$ and $\bar{d}$ are scalar multiples of each other and each has at most 1 non-zero entry.\footnote{https://math.stackexchange.com/q/853696}
\end{lemma}
\begin{proof}
Let $\bar{a} = (A_{11}, \dotsc, A_{nn})$ denote the diagonal of $A$, and let $\bar{d} = (d_1, \dotsc, d_n)$ denote the diagonal of $D$. Then,
$$ \tr(A D) = \sum_{i=1}^n A_{ii} d_i = \bar{a}^T \bar{d}. $$
Applying the Cauchy-Schwarz Inequality and the fact\footnote{https://math.stackexchange.com/q/245052} that $\forall x.\ \|x\|_2 \leq \|x\|_1$, we have
$$
| \tr(A D) |
= | \bar{a}^T \bar{d} |
\leq \|\bar{a}\|_2 \|\bar{d}\|_2
\leq \|\bar{a}\|_1 \|\bar{d}\|_1.
$$
The 1st inequality is tight iff $\bar{a}$ and $\bar{d}$ are scalar multiples of each other, and the 2nd inequality is tight iff $\bar{a}$ and $\bar{d}$ each have at most 1 non-zero entry.
If the diagonals of both $A$ and $D$ only have non-negative entries, then
$$
\bar{a}^T \bar{d} > 0,
\qquad
\|\bar{a}\|_1 = \tr(A),
\qquad\text{and}\qquad
\|\bar{d}\|_1 = tr(D).
$$
Therefore, $\tr(AD) \leq \tr(A) \tr(D)$.
\end{proof}
\section{Related Work}
Semi-supervised domain adaptation, especially few shot, one shot
Semi-supervised learning
\verb|https://docs.google.com/document/d/1sVsXDsRtx-tJAz_sJ3YLV7iaYKHcTlFgqQZVnUPeMbI/edit?usp=sharing|
\section{Experiments}
\section{Related Work}
Extreme value theory~\citep{de2007extreme,castillo2012extreme} studies the probability of rare events or large deviation. Most results are asymptotic~\citep{de2007extreme} and are not applicable to our setup assuming small sample size. Several non-asymptotic results are also used in our proofs such as Eq.(\ref{eq:order_stats}).
The notion of resilience~\citep{steinhardt2017resilience,steinhardt2018robust} is most commonly used in analyzing robust estimation. Our paper draws the connection between resilience and order statistics concentration bounds. We hope this connection can be further exploited in future work to transfer results between the two fields of research.
A line of research related to ours is semi-supervised transfer learning and domain adaptation~\citep{daume2010frustratingly, donahue2013semi, kumar2010co, ding2018semi, lopez2012semi, Saito2019}. In both setups, we have a pretrained classifier or regressor; in the target domain, there is a small amount of labeled data. The difference is in the objective: domain adaptation use the labeled data to fine-tune our classifier or regressor, while our objective is confidence interval estimation on the target domain. The different objectives lead to different sets of tools and desiderata.
\subsubsection*{\bibname}}
\begin{document}
\twocolumn[
\aistatstitle{Instructions for paper submissions to AISTATS 2020}
\aistatsauthor{ Author 1 \And Author 2 \And Author 3 }
\aistatsaddress{ Institution 1 \And Institution 2 \And Institution 3 } ]
\begin{abstract}
The Abstract paragraph should be indented 0.25 inch (1.5 picas) on
both left and right-hand margins. Use 10~point type, with a vertical
spacing of 11~points. The \textbf{Abstract} heading must be centered,
bold, and in point size 12. Two line spaces precede the
Abstract. The Abstract must be limited to one paragraph.
\end{abstract}
\section{GENERAL FORMATTING INSTRUCTIONS}
The camera-ready versions of the accepted papers are 8 pages,
plus any additional pages needed for references.
Papers are in 2 columns with the overall line width of 6.75~inches (41~picas).
Each column is 3.25~inches wide (19.5~picas). The space
between the columns is .25~inches wide (1.5~picas). The left margin is 1~inch (6~picas).
Use 10~point type with a vertical spacing of
11~points. Please use US Letter size paper instead of A4.
Paper title is 16~point, caps/lc, bold, centered between 2~horizontal rules.
Top rule is 4~points thick and bottom rule is 1~point thick.
Allow 1/4~inch space above and below title to rules.
Author descriptions are center-justified, initial caps. The lead
author is to be listed first (left-most), and the Co-authors are set
to follow. If up to three authors, use a single row of author
descriptions, each one center-justified, and all set side by side;
with more authors or unusually long names or institutions, use more
rows.
Use one-half line space between paragraphs, with no indent.
\section{FIRST LEVEL HEADINGS}
First level headings are all caps, flush left, bold, and in point size
12. Use one line space before the first level heading and one-half line space
after the first level heading.
\subsection{Second Level Heading}
Second level headings are initial caps, flush left, bold, and in point
size 10. Use one line space before the second level heading and one-half line
space after the second level heading.
\subsubsection{Third Level Heading}
Third level headings are flush left, initial caps, bold, and in point
size 10. Use one line space before the third level heading and one-half line
space after the third level heading.
\paragraph{Fourth Level Heading}
Fourth level headings must be flush left, initial caps, bold, and
Roman type. Use one line space before the fourth level heading, and
place the section text immediately after the heading with no line
break, but an 11 point horizontal space.
\subsection{CITATIONS, FIGURES, REFERENCES}
\subsubsection{Citations in Text}
Citations within the text should include the author's last name and
year, e.g., (Cheesman, 1985). References should follow any style that
you are used to using, as long as their style is consistent throughout
the paper. Be sure that the sentence reads correctly if the citation
is deleted: e.g., instead of ``As described by (Cheesman, 1985), we
first frobulate the widgets,'' write ``As described by Cheesman
(1985), we first frobulate the widgets.''
\subsubsection{Footnotes}
Indicate footnotes with a number\footnote{Sample of the first
footnote.} in the text. Use 8 point type for footnotes. Place the
footnotes at the bottom of the column in which their markers appear,
continuing to the next column if required. Precede the footnote
section of a column with a 0.5 point horizontal rule 1~inch (6~picas)
long.\footnote{Sample of the second footnote.}
\subsubsection{Figures}
All artwork must be centered, neat, clean, and legible. All lines
should be very dark for purposes of reproduction, and art work should
not be hand-drawn. Figures may appear at the top of a column, at the
top of a page spanning multiple columns, inline within a column, or
with text wrapped around them, but the figure number and caption
always appear immediately below the figure. Leave 2 line spaces
between the figure and the caption. The figure caption is initial caps
and each figure should be numbered consecutively.
Make sure that the figure caption does not get separated from the
figure. Leave extra white space at the bottom of the page rather than
splitting the figure and figure caption.
\begin{figure}[h]
\vspace{.3in}
\centerline{\fbox{This figure intentionally left non-blank}}
\vspace{.3in}
\caption{Sample Figure Caption}
\end{figure}
\subsubsection{Tables}
All tables must be centered, neat, clean, and legible. Do not use hand-drawn tables.
Table number and title always appear above the table.
See Table~\ref{sample-table}.
Use one line space before the table title, one line space after the table title,
and one line space after the table. The table title must be
initial caps and each table numbered consecutively.
\begin{table}[h]
\caption{Sample Table Title} \label{sample-table}
\begin{center}
\begin{tabular}{ll}
\textbf{PART} &\textbf{DESCRIPTION} \\
\hline \\
Dendrite &Input terminal \\
Axon &Output terminal \\
Soma &Cell body (contains cell nucleus) \\
\end{tabular}
\end{center}
\end{table}
\section{SUPPLEMENTARY MATERIAL}
If you need to include additional appendices during submission, you
can include them in the supplementary material file.
\section{INSTRUCTIONS FOR CAMERA-READY PAPERS}
For the camera-ready paper, if you are using \LaTeX, please make sure
that you follow these instructions. (If you are not using \LaTeX,
please make sure to achieve the same effect using your chosen
typesetting package.)
\begin{enumerate}
\item Download \texttt{fancyhdr.sty} -- the
\texttt{aistats2020.sty} file will make use of it.
\item Begin your document with
\begin{flushleft}
\texttt{\textbackslash documentclass[twoside]\{article\}}\\
\texttt{\textbackslash usepackage[accepted]\{aistats2020\}}
\end{flushleft}
The \texttt{twoside} option for the class article allows the
package \texttt{fancyhdr.sty} to include headings for even and odd
numbered pages. The option \texttt{accepted} for the package
\texttt{aistats2020.sty} will write a copyright notice at the end of
the first column of the first page. This option will also print
headings for the paper. For the \emph{even} pages, the title of
the paper will be used as heading and for \emph{odd} pages the
author names will be used as heading. If the title of the paper
is too long or the number of authors is too large, the style will
print a warning message as heading. If this happens additional
commands can be used to place as headings shorter versions of the
title and the author names. This is explained in the next point.
\item If you get warning messages as described above, then
immediately after $\texttt{\textbackslash
begin\{document\}}$, write
\begin{flushleft}
\texttt{\textbackslash runningtitle\{Provide here an alternative
shorter version of the title of your paper\}}\\
\texttt{\textbackslash runningauthor\{Provide here the surnames of
the authors of your paper, all separated by commas\}}
\end{flushleft}
Note that the text that appears as argument in \texttt{\textbackslash
runningtitle} will be printed as a heading in the \emph{even}
pages. The text that appears as argument in \texttt{\textbackslash
runningauthor} will be printed as a heading in the \emph{odd}
pages. If even the author surnames do not fit, it is acceptable
to give a subset of author names followed by ``et al.''
\item Use the file sample\_paper.tex as an example.
\item The camera-ready versions of the accepted papers are 8
pages, plus any additional pages needed for references.
\item If you need to include additional appendices,
you can include them in the supplementary
material file.
\item Please, don't change the layout given by the above
instructions and by the style file.
\end{enumerate}
\subsubsection*{Acknowledgements}
Use the unnumbered third level heading for the acknowledgements. All
acknowledgements go at the end of the paper.
\subsubsection*{References}
References follow the acknowledgements. Use an unnumbered third level
heading for the references section. Any choice of citation style is
acceptable as long as you are consistent. Please use the same font
size for references as for the body of the paper---remember that
references do not count against your page length total.
\section{Problem Setup}
Our objective is to estimate the mean of some random variable $Y$ taking values in ${\mathcal{Y}} \subseteq \mathbb{R}^d$. Given i.i.d. samples $y_1, \dotsc, y_m \sim Y$ and some choice of confidence level $\zeta \in (0, 1)$, an estimation algorithm outputs $\hat{\mu} \in \mathbb{R}^d$ and an confidence interval size $c \in \mathbb{R}^+$.
The estimation algorithm must satisfy
\begin{equation} \Pr\left[ \lVert \hat{\mu} - \mathbb{E}[Y] \rVert > c \right] \leq \zeta \label{eq:problem_def} \end{equation}
where the probability $\Pr$ is with respect to the random samples of $y_1, \dotsc, y_m$ and any additional randomness in the execution of the (randomized) algorithm, and $\lVert \hat{\mu} - \mathbb{E}[Y] \rVert$ is any choice of semi-norm.
We will first focus on one dimensional problems where $Y \in \mathbb{R}$, and choose the norm $\lVert \hat{\mu} - \mathbb{E}[Y] \rVert = \lvert \hat{\mu} - \mathbb{E}[Y] \rvert$, then extend several results to more general setups.
\subsection{Baseline Estimators and Optimality}
\label{sec:baseline}
The classical approach is to estimate $\mathbb{E}[Y]$ with the empirical mean ${\mu_{\mathrm{mean}}} = \frac{1}{m}\sum_{i=1}^m y_i$, and its estimation error $ \lvert {\mu_{\mathrm{mean}}} - \mathbb{E}[Y] \rvert$
can be controlled using
concentration inequalities.
To obtain concentration inequalities, we need some assumptions on ${\mathcal{Y}}$. For example, if there is some very small probability that $Y = +\infty$, then $\mathbb{E}[Y]$ is unbounded, but ${\mu_{\mathrm{mean}}}$ can be finite, which makes it impossible to bound $\lvert {\mu_{\mathrm{mean}}} - \mathbb{E}[Y] \rvert$. Common assumptions include sub-Gaussian, bounded moments, sub-exponential, etc~\citep{vershynin2010introduction}. We will consider the sub-Gaussian and bounded moments assumptions in this paper.
\textbf{Sub-Gaussian}: If we assume $\forall t \in \mathbb{R},\ \mathbb{E}[e^{t(Y-\mathbb{E}[Y])}] \leq e^{\sigma^2 t^2/2}$, then Chernoff-Hoeffding is the classic concentration inequality for confidence interval estimation~\citep{hoeffding1962probability}
\begin{align*}
\Pr\left[ \lvert \hat{\mu} - \mathbb{E}[Y] \rvert > \sqrt{\frac{2\sigma^2}{m}\log \frac{2}{\zeta}} \right] \leq \zeta.
\end{align*}
In particular, when $Y$ is supported on $[a, b]$ we have
\begin{align*}
\Pr\left[ \left\lvert \hat{\mu} - \mathbb{E}[Y] \right\rvert > \sqrt{\frac{(b-a)^2}{2m}\log \frac{2}{\zeta}} \right] \leq \zeta.
\end{align*}
\textbf{Bounded Moments}: Another common assumption is that the $k$-th order moment of $Y$ is bounded, i.e. $\mathbb{E}[\lvert Y - \mathbb{E}[Y] \rvert^k] \leq \sigma^k$ for some $\sigma > 0$.
Under bounded moment assumptions, several concentration inequalities are known, such as the Chebychev inequality, Kolmogorov inequality~\citep{hajek1955generalization} and Bernstein inequality~\citep{bernstein1924modification}. For example, when $Y$ has a bounded second order moment, the Chebychev inequality states the following:
\begin{equation}
\Pr\left[ \left\lvert \hat{\mu} - \mathbb{E}[Y] \right\rvert \geq \frac{\sigma}{\sqrt{\zeta m}} \right] \leq \zeta
\label{eq:chebychev}
\end{equation}
It is known that these bounds are (asymptotically in $m$) minimax optimal. There exist random variables $Y$ that satisfy the respective assumptions of each inequality, and the inequality cannot be improved~\citep{hoeffding1962probability}. Therefore, to further improve these estimation algorithms, additional assumptions will be necessary.
\subsection{Control Variates}\label{sec:control_variates}
Suppose ${\tilde{Y}}$ is another random variable jointly distributed with $Y$ and that we know its mean $\mathbb{E}[{\tilde{Y}}]$ (or have a very accurate estimate of it).
We also have samples drawn from their joint distribution $(y_1, {\tilde{y}}_1), \dotsc, (y_m, {\tilde{y}}_m) \sim Y, {\tilde{Y}}$.
For ${\tilde{Y}}$ to be useful for our application, its value needs to be close to $Y$.
In other words, $Y - {\tilde{Y}}$ should be a random variable that is concentrated around $0$. The purpose of this variable ${\tilde{Y}}$ is
similar to
a ``control variate'' in the Monte Carlo community, but we use it here for a different task of interval estimation.
For example, in our household wealth estimation example, let $Y$ denote the household-level wealth in a randomly sampled village, and let ${\tilde{Y}}$ be the predicted household-level wealth based on the satellite image of that village. If our predictor is accurate (i.e. $Y \approx {\tilde{Y}}$ with high probability), then ${\tilde{Y}}$ could be an effective control variate for $Y$. In addition, we can also estimate $\mathbb{E}[{\tilde{Y}}]$ very accurately because a very large number of satellite images
are available with little cost~\citep{wulder2012landsat}, so obtaining samples from ${\tilde{Y}}$ (without the corresponding $Y$) is inexpensive.
We would like to design an estimation algorithm that takes as input the samples $(y_1, {\tilde{y}}_1), \dotsc, (y_m, {\tilde{y}}_m)$ and the known value of $\mathbb{E}[{\tilde{Y}}]$, and outputs a $\hat{\mu}$ along with an estimation error $c \in \mathbb{R}^+$ such that Eq.(\ref{eq:problem_def}) holds. The hope is that because of the additional information ${\tilde{Y}}$ we are no longer restricted by the mini-max bounds on the confidence interval size $c$, and can output confidence intervals of smaller size.
| {'timestamp': '2020-06-19T02:09:16', 'yymm': '2006', 'arxiv_id': '2006.10287', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10287'} | arxiv |
\section{Introduction}
GANs\cite{goodfellow2014generative} have achieved great success in many tasks like image generation\cite{brock2018large}\cite{karras2019style}, super resolution\cite{ledig2017photo} and image translation\cite{lample2017fader}\cite{choi2018stargan}. However, due to the great number of parameters and a complex cascade of nonlinear activations, we can hardly understand the intrinsic logic of GANs and the quantitative relationship between input values of variables in latent space and semantic content in output generated images. Moreover, GANs still suffer some severe issues, such as unstable training, mode drop and mode collapse, etc. Many works toward mitigating these issues have been proposed: designing new architectures\cite{karras2017progressive}\cite{brock2018large}, new loss functions\cite{arjovsky2017wasserstein}\cite{gulrajani2017improved} or new training methologies\cite{karras2017progressive}\cite{karras2019style}. Compared to the large number of works that aim at improving train stability and generation quality, few works have been done to explore the intrinsic working mechanism of GANs, i.e. the interpretability of GANs. This motivated the work of this paper.
Recently, along with the success of deep learning, interpreting deep neural models have become a hot topic in research. The methods can be generally divided into three categories according to the corresponding interpreting results: visualizing pre-trained models\cite{zeiler2014visualizing}\cite{mahendran2015understanding}, diagnose pre-trained models\cite{ribeiro2016should}\cite{lakkaraju2017identifying} and construct interpretable models\cite{zhang2019interpreting}\cite{zhang2018interpretable}. The first kind of methods use activation maximization or de-convolution techniques to visualize neurons or derive an input that maximizes semantic outputs; the second kind of methods diagnose pre-trained deep models by adding understandable disturbance to the inputs or quantify the importance of features; the last kind of methods impose constraints on neurons or reconstruct deep models to make deep models more interpretable. As for GANs, researchers proposed various methods to make them more interpretable and controllable, such as concatenating latent code with conditional information\cite{mirza2014conditional}\cite{goetschalckx2019ganalyze}, interpolating in latent manifolds\cite{shen2019interpreting}\cite{jahanian2019steerability} and latent disentanglement\cite{lample2017fader}\cite{donahue2017semantically}. Bau et.al\cite{bau2018gan} proposed to quantify the effect or importance of different layer nodes on content changes by utilizing a pre-trained segmentation model to calculate IoU scores on generated image variations. However, previous methods did not give any quantitative evaluation of contribution each variable in latent space provides for generating specific semantic contents.
For the interpretability of GANs, due to the black-box property of deep neural models, hardly can we understand how the latent variables affect the generation process. To investigate if the variables in latent space contain the necessary information to distinguish different semantic contents in generated images, we use t-SNE\cite{maaten2008visualizing} to analyze the latent representations of Fashion-MNIST samples and find that the latent representations of samples from different classes can be well-separated, as shown in Figure \ref{fig:tsne}. This indicates that for samples from the same one class, there may be exist closely-related latent variables that made their latent representations distinguishable. This motivated us to quantify the importance of different latent dimensions for specific concept generation. We propose to analyze the correlation between the latent inputs and the corresponding generated outputs by utilizing a pre-trained classifier to provide quantitative evaluations on the semantic content changes in generated images, then to interpret the meaning of variables in the latent space of GANs. We also propose two methods for locating high-correlated latent dimensions for specific concept generation or manipulation: one is by sequential intervention and the other is by optimization. Moreover, given a specific class concept, we can also intervene in the derived controlling set of latent variables for controllable content manipulation. Specifically, the main contributions of this paper are:
\begin{itemize}
\item We first propose to interpret the latent space of GANs by quantifying the correlation between the latent inputs and the generated outputs.
\item We demonstrate that for generating contents of specific concept, the importance of different latent variables may varies greatly. Moreover, we propose an optimization-based method to find controlling latent variables for specific concept.
\item The proposed method can fulfill controllable concept manipulation in generated images via controlling variables discovering and intervention.
\end{itemize}
The remaining part of this paper is organized as follows: in section 2, we give a brief introduction to the backgrounds of this work. In section 3, we introduc the proposed method for interpreting the latent space of GANs in detail. The experiment results and implementation details are given in section 4 and finally is the conclusion of this paper.
\begin{figure*}[h]
\includegraphics[width=0.75\textwidth]{figures/Latent_GAN.pdf}
\centering
\caption{The proposed method for analyzing the correlation between latent space and output image space of GANs. Top part illustrate the process of finding high-correlated latent dimensions by sequential intervention or adding weights on latent variables. Bottom part denote the process of latent intervention on top or bottom ranked latent dimensions.}
\label{fig:CorrelationGAN}
\end{figure*}
\section{Preliminaries}
\subsection{Generative Adversarial Networks}
Generative adversarial nets (GANs) aimed at modeling the train data distribution through an adversarial process. It mainly contains two models that play against each other, a generator G and a discriminator D, G maps noise inputs from latent space to image space and tries to let D classify the generated samples as true, whereas D wants to clearly distinguish real data from generated ones. The adversarial process can be formulated as below:
\begin{align}
\begin{split}
\min_{G}\max_{D}V(D,G)=&\mathbb{E}_{\mathbf{x}\sim p_{data}(\mathbf{x})}[\log D\left( \mathbf{x}\right)]\\
&+\mathbb{E}_{\mathbf{z}\sim p_{z}(\mathbf{z})}[\log \left( 1-D\left( G\left( \mathbf{z}\right) \right)\right) ]
\end{split}
\end{align}
where $V(D,G)$ is the value function of the min-max game, $p_{data}(\mathbf{x})$ and $p_{z}(\mathbf{z})$ represent the distribution of train data and latent noise respectively. In practice, people tend to train G to maximize $\log D(G(\mathbf{z}))$ rather than to minimize $\log (1-D(G(\mathbf{z})))$ for the reason that equation 1 may not provide sufficient gradient for G in the early training stage. In this paper, we choose a pre-trained WGAN\cite{arjovsky2017wasserstein} model for latent space analysis.
\begin{comment}
\begin{align}
\begin{split}
\theta_{D}^*=\arg\max_{\theta_{D}}\big[&\mathbb{E}_{\mathbf{x}\sim p_{data}(\mathbf{x})}[\log D_{\theta_{D}}\left( \mathbf{x}\right)]\\
&+\mathbb{E}_{\mathbf{z}\sim p_{z}(\mathbf{z})}[\log \left( 1-D_{\theta_{D}}\left( G\left( \mathbf{z}\right) \right)\right) ]\big]\\
\theta_{G}^*=\arg\max_{\theta_{G}}\big[&\mathbb{E}_{\mathbf{z}\sim p_{z}(\mathbf{z})}[\log D\left( G_{\theta_{G}}\left( \mathbf{z}\right) \right) ]\big]
\end{split}
\end{align}
\end{comment}
\subsection{GAN Dissection}
In \cite{bau2018gan}, the author proposed an analytic framework to visualize and understand GANs at unit-, object- and scene level respectively by identifying interpretable units that are closely related to some object concepts through a segmentation network. Moreover, the authors also quantify the causal effect of interpretable units and offer an empirical method to mitigate the artifacts problem in generation results. The method for characterizing units by dissection can be formulated as below:
\begin{equation}
IoU_{u,c}\equiv \frac{\mathbb{E}_{\mathbf{z}}\left|\left(\mathbf{r}_{u,\mathbb{P}}^{\uparrow}>t_{u,c}\right)\wedge\mathbf{s}_{c}\left(\mathbf{x}\right)\right|}{\mathbb{E}_{\mathbf{z}}\left|\left(\mathbf{r}_{u,\mathbb{P}}^{\uparrow}>t_{u,c}\right)\vee\mathbf{s}_{c}\left(\mathbf{x}\right)\right|}
\end{equation}
where $u$ denotes the layer node in GANs and $c$ means concepts like classes, $\mathbf{r}_{u,\mathbb{P}}^\uparrow$ denote the feature map of unit $u$, $\wedge$ and $\vee$ represent intersection and union operation respectively, $t_{u,c}$ is a chosen threshold for producing binary mask and $s_{c}\left( \mathbf{x}\right)$ is the segmentation result of the generated image $\mathbf{x}$. This method uses the IoU (Intersection of Union) score to quantify the spatial agreement between a unit's feature map and the segmentation map of a generated image, which can reflect the importance of a unit for generating a specific concept.
\begin{comment}
The GAN dissection method also proposed to measuring the causal relationship between a group of units and a concept by intervention, i.e. ablation or insertion operations on some unit. By observing the intervened generation results and comparing the corresponding IoU score with that derived from the original generated image, the method can also derive the casual effect of an unit.
\end{comment}
\section{Correlation Analysis between Latent and Output Spaces}
In this paper, we propose to interpreting the latent space of GANs by analyzing the correlation between latent dimensions and the corresponding content changes in generated images. A thing that needs to notice is that the proposed method aimed at analyzing a pre-trained GAN model other than training a new one during the correlation analysis. The target was to semantically interpret the latent space and quantify the importance of different latent dimensions, below are the details of the proposed method.
\subsection{Problem Statement}
Given a pre-trained generator $\mathbf{G}\left(\mathbf{z}\right)$, the target was to analyze the latent space and quantify the importance of different latent dimensions for a generation. As for specific semantic concepts like classes or objects, we want to analyze which dimensions influence the contents of the generated results most. The problem can be formulated as below:
\begin{align}
\begin{split}
\mathbf{X}=&\mathbf{G}\left(\mathbf{Z}\right)=\mathbf{G}\left(\left[z_1,z_2,\dots,z_N\right]\right)\\
\Delta z_i \Longrightarrow &\Delta \mathbf{X} \Longrightarrow \Delta \mathbf{C}_l, \quad \textrm{for} \,\, i=1,\dots,N
\end{split}
\end{align}
where $\left[z_1,z_2,...,z_N\right]=\mathbf{z}\in \mathbb{R}^N$ is denoted as the latent variable, $\Delta\mathbf{X}$ and $\Delta \mathbf{C}_l$ ($\mathbf{C}\in \mathbb{R}^L$, $L$ classes) represent the content change and concept(here we choose class labels as different concepts) change in the corresponding generated image. For each latent dimension, we adjust the value of this dimension and observe how much can the intervention influence the generation results. Practically, as will be introduced in the latter part, for most concepts, there may be more than one latent dimension that closely related to that concept, thus we also try to find these controlling dimensions for different concepts. The problem can be simply formulated as:
\begin{equation}
\begin{split}
\alpha_i \in \{0,1\},\quad &i=1,\dots,N\\
\left[\alpha_1 \cdot z_1,\dots,\alpha_N \cdot z_N\right] &\Longleftrightarrow \Delta\mathbf{X} \Longleftrightarrow \Delta \mathbf{C}_l
\end{split}
\end{equation}
where $\alpha_i \in \{0,1\}$ represents whether the corresponding dimension is high-correlated with a given concept $\mathbf{C}_l$ or not. In the next two subsections, we will introduce the proposed method for finding important latent dimension by quantifying the semantic content change and finding controlling dimensions for the given concept through optimization.
\subsection{High-correlated latent dimensions for specific concept generation}
To analyze the correlation between latent space and the output image space, we adopted a pre-trained classifier $\mathbf{Q}\left(\mathbf{x}\right)$ to assign a score on the generated image and its variations. The pre-trained classifier $\mathbf{Q}$ can quantify the content change of the base generated image as a softmax score, which can be used for latent dimension importance analysis. For i-th latent dimension and j-th class
\begin{align}
\mathbf{Z}^k=&\mathbf{Z}+k\cdot \delta\cdot\left[0,\dots,1,\dots,0\right]\quad k\in\left[-m,m\right]\\
\mathbf{X}^k=&\mathbf{G}\left(\mathbf{Z}^k\right)=\mathbf{G}\left(\left[z_1,\dots,z_i+\delta\cdot k,\dots,z_N\right]\right)\\
&\mathbf{S}_{i,j}^k=\mathbf{Q}_j\left(\mathbf{X}^k\right)=\mathbf{Q}_j\left(\mathbf{G}\left(\mathbf{Z}^k\right)\right)
\end{align}
where $\mathbf{Z}^k$, $\mathbf{X}^k$ and $\mathbf{S}_{i,j}^k$ represent the latent variable(intervened the i-th dimension), the generated image and the corresponding classification softmax score of class $j$ while $k$ adjust the value of i-th latent dimension bi-directional k steps(the stepsize was $\delta$). It's easy to find that when $k=0$, $\mathbf{Z}^0$ and $\mathbf{X}^0$ is just the same as $\mathbf{Z}$ and $\mathbf{X}$, i.e., the base reference generated image and latent variable. To measure the i-th latent dimension's effect on the generation of j-th class contents, we use the averaged probability change ratio (APCR) as the quantitative evaluation metric.
\begin{align}
\begin{split}
{APCR}_{i,j}=&\left\|\frac{\sum_{k=1}^{m}\left(\mathbf{S}_{i,j}^k-\mathbf{S}_{i,j}^{k-1}\right)}{2\cdot m}\right\|_1\\
+&\left\|\frac{\sum_{k=-1}^{-m}\left(\mathbf{S}_{i,j}^k-\mathbf{S}_{i,j}^{k-1}\right)}{2\cdot m}\right\|_1
\end{split}
\end{align}
As can be seen from the above equation, the metric calculates the averaged value changes of the probability that the generated image variations belong to a specified class over the latent dimension changes. Here we use the L-1 norm to calculate the probability changes separately along with two variation directions. Then, for each class, we will get $n$ (dimension of the latent space) APCR scores and find the most correlated dimension for this class by ranking the scores. Similarly, we can also derive $L$ APCR scores for each latent dimension.
\subsection{Controlling set of latent dimensions for controllable concept manipulation}
As mentioned above, for a given specific class, there may have multi latent dimensions that closely related to it, hence we propose to find these important dimensions, which we called controlling latent dimension here. We propose to intervene in all the latent dimensions by assigning different weights to these dimensions and observe the corresponding classification score changes. The optimization objective was to maximize the classification score changes by updating the coefficients on the latent dimensions. The model weights were keep frozen during the optimization process. To derive the controlling dimensions for j-th class, we firstly add differentiated distortions to the latent dimensions by utilizing a weight vector $\mathbf{w}=\left[w_1,\dots,w_N\right]$:
\begin{equation}
\mathbf{Z}^{'}=\mathbf{Z}+\mathbf{w}*\xi=\left[z_1+w_1\cdot \xi,\dots,z_N+w_N\cdot \xi\right]
\end{equation}
where $\xi$ represent an experimental constant for latent intervention, and $w_i\in[-1,1]$ represent the latent intervention coefficients. Positive coefficients denote positive intervention direction and vise versa. For j-th class to be analyzed, we first calculate the probability changes with respect to latent interventions. Then we can derive the optimization objective of the weight vector $\mathbf{w}$:
\begin{align}
\Delta\mathbf{S}_j=\mathbf{S}_j^{'}-\mathbf{S}_j=\mathbf{Q}_j\left(\mathbf{G}\left(\mathbf{Z}^{'}\right)\right)-\mathbf{Q}_j\left(\mathbf{G}\left(\mathbf{Z}\right)\right)\\
\mathbf{w}^*=\arg\max \mathbf{L}_{\mathbf{w}}=\arg\max\left(\left|\Delta\mathbf{S}_j\right|\right)
\end{align}
For easy optimization and make the coefficients on latent dimensions sparse, we add the L-2 norm regularization and rewrite the optimization objective, the optimal $\mathbf{w}$ can be derived through the optimization of equation (12). Finally, we add a threshold $t_j$ on the optimized coefficients $\mathbf{w}$ to filter out uncorrelated dimensions for each class $j$, hence the controlling dimensions can be derived.
\begin{align}
\mathbf{w}^*=\arg\min\left(1-\left|\Delta\mathbf{S}_j\right|+\lambda\cdot\left\|\mathbf{w}\right\|_2\right)\\
\mathbf{w}_{>t_j}\Longleftarrow\left[\left|w_{j,1}^*\right|>t_j,\dots,\left|w_{j,N}^*\right|>t_j\right]
\end{align}
Moreover, for controllable concept manipulation, we can just modify the optimization objective as below and derive the controlling set of latent dimensions for class-to-class translation (class j and class k).
\begin{align}
\begin{split}
\Delta\mathbf{S}_{k\rightarrow j}&=\mathbf{Q}_j\left(\mathbf{G}\left(\mathbf{Z}_k-w*\xi\right)\right)-\mathbf{Q}_j\left(\mathbf{G}\left(\mathbf{Z}_k\right)\right)\\
\Delta\mathbf{S}_{j\rightarrow k}&=\mathbf{Q}_k\left(\mathbf{G}\left(\mathbf{Z}_j+w*\xi\right)\right)-\mathbf{Q}_k\left(\mathbf{G}\left(\mathbf{Z}_j\right)\right)
\end{split}
\end{align}
\begin{align}
\begin{split}
\mathbf{w}^*&=\arg\max \mathbf{L}_{\mathbf{w}}=\arg\max\left(\left|\Delta\mathbf{S}_{k\rightarrow j}\right|+\left|\Delta\mathbf{S}_{j\rightarrow k}\right|\right)\\
&=\arg\min\left(2-\left|\Delta\mathbf{S}_{k\rightarrow j}\right|-\left|\Delta\mathbf{S}_{j\rightarrow k}\right|+\lambda\cdot\left\|\mathbf{w}\right\|_2\right)
\end{split}
\end{align}
Thus for $Z_j$ and $Z_k$ that belong to class $j$ and $k$, we can achieve class j $\leftrightarrow$ class k translation by $Z_j+w*\xi$ and $Z_k-w*\xi$ respectively. The proposed method was depicted in Figure \ref{fig:CorrelationGAN}, where the top part denotes the process of finding high-correlated latent dimensions for the specific concept by sequential intervention and adding weights on latent variables. The bottom part denotes the process of controllable manipulation through latent intervention on top-ranked and bottom-ranked dimensions.
\section{Experiments}
In this section, we will present the experiment results to demonstrate the effectiveness of the proposed method along with some interesting findings. The experiments can be divided into four parts, the first one is designed to find high-correlated latent dimensions for the specific concept by intervening latent dimensions sequentially, the second one solve the same problem as the first but with an optimization-based method, the third experiment is about controllable concept manipulation using controlling latent dimensions and the last one is about class2class image translations.
\subsection{Datasets and Implementation Details}
In this paper, we conducted designed experiments on two datasets: Fashion-MNIST\cite{xiao2017/online} and UT Zappos50K\cite{semjitter}. Fashion-MNIST is a dataset of Zalando's article images—consisting of 60k training samples and 10k testing samples, just the same with the original MNIST dataset. Each example is a 28x28 grayscale image, associated with a label from 10 classes: [\textit{T-shirt, Trouser, Pullover, Dress, Coat, Sandal, Shirt, Sneaker, Bag, Ankle boot}]. UT Zappos50K is a large shoe dataset consisting of 50,025 catalog images collected from Zappos.com. The images are divided into 4 major categories — shoes, sandals, slippers, and boots — followed by functional types and individual brands. As for the implementation, we use a pre-trained WGAN\_GP model for correlation analysis. Moreover, we adopt the LeNet-5 model as the choice for classification network and EmbedNet. The length of latent variables is set to 100.
\begin{comment}
\begin{figure}[h]
\includegraphics[width=0.45\textwidth]{dataset}
\caption{Example train data samples for Fashion-MNIST and UT Zappos50K.}
\end{figure}
\end{comment}
\subsection{Find High-Correlated Latent Dimensions by Sequential Latent Intervention}
As having been introduced in Section 3.2, given a specific class concept, we intervene in the latent dimensions sequentially and get corresponding APCR scores for each latent dimension. Then we rank the latent dimensions for each concept according to the APCR values, thus high-correlated latent dimensions can be derived. Here we use the softmax score to indicate the concept changes in generated images. The softmax score changes w.r.t latent offsets for each latent dimension was shown in Figure \ref{fig:Sequential}, from which we can clearly see that the slope of different curves varies greatly. It indicates that semantic concepts are sensitive to several latent dimensions, i.e., intervening on some high-correlated latent dimensions will lead to greater semantic concept changes compared to intervene on less important dimensions. Moreover, we also give the APCR distribution information in Figure \ref{fig:APCR}, where the x-axis denote the range-index number (larger index number represents larger APCR values) of APCR values and the y-axis denote the number of dimensions belongs to each range. It furthermore demonstrated that the amount of high-correlated latent dimensions for each concept is small.
\begin{figure}[h]
\centering
\includegraphics[width=0.45\textwidth]{figures/MostCorrelated_Crop}
\caption{Classification score change with respect to intervention on different latent dimensions. Each color represent a latent dimension.}
\label{fig:Sequential}
\end{figure}
\begin{figure}[h]
\centering
\includegraphics[width=0.45\textwidth]{figures/APCR_Value_Plot_Crop}
\caption{Number distribution of latent dimensions with respect to different APCR value range.}
\label{fig:APCR}
\end{figure}
\subsection{Find Controlling Set of Latent Dimensions via Optimization}
We use the optimization-based method described in Section 3.2 to derive the coefficients vector ($w\in[-1,1]$) on latent dimensions for each concept, then we impose thresholds on the coefficients to filter out a positive and negative controlling set of latent dimensions. Larger positive values and smaller negative values denote higher correlation when intervening along the positive and negative direction respectively. We randomly select two classes to demonstrate the controlling latent dimensions, which can be seen in Figure \ref{fig:ControllingSet} (top and bottom parts represent intervention results of class 8 and class9 respectively). As illustrated in Figure \ref{fig:ControllingSet}, the first three rows represent the intervention results of $R_0$,$R_{50}$,$R_{99}$ dimensions respectively, where the numbers denoted as the ranked order, thus $R_0$ and $R_{99}$ represent most correlated latent dimension along bi-directional intervention. The bottom two rows give the intervention results of top-5 positive/ negative correlated dimensions. From the top three rows, we can see that positive intervention results of $R_0$ are similar to negative intervention results of $R_{99}$ while intervene on $R_{50}$ car hardly leads to any generation changes. Moreover, we intervene in top-5 positive and negative dimensions and get better results, which can be seen from the bottom two rows. This indicates that for a given specific concept, we can derive the controlling set of latent dimensions of it, hence concept manipulation can be achieved by intervening on these dimensions (furthermore results can be seen in the next subsection).
\begin{figure}[h]
\centering
\includegraphics[width=0.45\textwidth]{figures/experiments-2-1.pdf}
\caption{Intervene on controlling set of latent dimensions.}
\label{fig:ControllingSet}
\end{figure}
We also propose to use intersection ration ($IR_{ctrl}$) as an evaluation metric of the concordance of the controlling dimensions derived by sequential intervention and optimization. The results can be seen in Table \ref*{tab:IntersectionDim}, it indicates that controlling dimensions derived by two methods were quite similar with an average IR score of 0.75. It furthermore demonstrated that latent dimensions contribute differently to specific concept generation.
\begin{table}[h]
\centering
\begin{tabular}{c|ccccc}
\toprule
Classes & class0 & class1 & class2 & class3 & class4\\
\midrule
$IR_{ctrl}$& 0.7 & 0.9 & 0.7 & 0.8 & 0.4\\
\midrule
Classes& class5 & class6 & class7 & class8 & class9\\
\midrule
$IR_{ctrl}$& 1 & 0.7 & 0.9 & 0.7 & 0.7\\
\bottomrule
\end{tabular}
\caption{Intersection ration of high-correlated latent dimensions derived by sequential intervention and optimization}
\label{tab:IntersectionDim}
\end{table}
\subsection{Controllable Concept Manipulation with Controlling Latent Dimensions}
As introduced in the above section, we can achieve controllable concept manipulation by intervening the controlling set of latent dimensions. The controllable manipulation results of Fashion-MNIST and UT Zappos50k can be seen in Figure \ref{fig:Ctrl_Fashion} and Figure \ref{fig:Ctrl_UT} respectively. In Figure \ref{fig:Ctrl_Fashion}, the leftmost column denotes the reference images come from different classes of Fashion-MNIST, and the right 10 column denote the corresponding directional manipulation results, i.e. translate the reference image to different classes. Similarly, in Figure \ref{fig:Ctrl_UT}, the middle column in the yellow bounding-box denotes the reference image in UT Zappos50k and other columns denote bi-directional manipulation results. From the results, we can see that controllable concept manipulation can be achieved by intervention on controlling set of latent dimensions.
\begin{figure}[h]
\centering
\includegraphics[width=0.45\textwidth]{figures/ContrSyn_Fashion.pdf}
\caption{Controllable concept manipulation on Fashion-MNIST through intervening on controlling set of latent dimensions (final manipulation results).}
\label{fig:Ctrl_Fashion}
\end{figure}
\begin{figure}[h]
\includegraphics[width=0.45\textwidth]{figures/experiments-1-3.pdf}
\caption{Controllable concept manipulation on UT Zappos50k through intervening on controlling set of latent dimensions.}
\label{fig:Ctrl_UT}
\end{figure}
\subsection{Interesting Findigns of Extreme Intervention on Latent Dimensions}
We also have some interesting findings of the latent interventions, which are demonstrated in Figure \ref{fig:extreme}. Usually, the common choice of latent variables is drawn from a Gaussian normal distribution, by now, researchers have not explored extreme cases of latent values. We propose to add positive and negative impulse stimuli on latent dimensions and observe the corresponding semantic content change in the generated image. The results are demonstrated in Figure \ref{fig:extreme}, where the middle row represents the original images come from different classes, the top and bottom row denote positive/ negative extreme intervention results respectively. From the results, we can see that for images from different classes, if we extremely intervene in some latent dimension (adding impulse stimuli), the final manipulation results will converge to some specific classes. Inspired by this finding, we can find these unique dimensions for various class pairs and achieve controllable class-to-class translation (Figure \ref{fig:class2class}).
\begin{figure}[h]
\includegraphics[width=0.45\textwidth]{figures/Extreme-Cases.pdf}
\caption{Extreme intervention results by adding impulse stimuli on specific latent dimensions bidirectionally.}
\label{fig:extreme}
\end{figure}
\begin{figure}[h]
\includegraphics[width=0.45\textwidth]{figures/experiments-1-2.pdf}
\caption{Controllable Class-to-Class translation by extreme intervening on some specific latent dimensions (final translation results).}
\label{fig:class2class}
\end{figure}
\begin{comment}
\begin{figure}[h]
\includegraphics[width=0.45\textwidth]{experiments-1-1}
\caption{Controllable image translation between classes (intermediate translation results).}
\end{figure}
\end{comment}
\section{Conclusion}
In this paper, we proposed a method to interpret the latent space of GANs with correlation analysis for controllable concept manipulation. We utilized a pre-trained classifier to evaluate the concept changes in the generation variations. We first illustrated that the importance of different latent dimensions that contribute to specific concept generation varies greatly. Moreover, we also proposed two methods to find the controlling set of latent dimensions for different concepts, with which we can fulfill controllable concept manipulation. These interesting findings provide a new route for controllable generation and image editing, moreover, it also gives us some thoughtful insight into the interpretability of GANs' latent space.
\section*{Acknowledgments}
This work was partially supported by the National Natural Science Foundation of China under grand No.U19B2044 and No.61836011.
\ifCLASSOPTIONcaptionsoff
\newpage
\fi
\bibliographystyle{IEEEtran}
| {'timestamp': '2020-07-24T02:18:33', 'yymm': '2006', 'arxiv_id': '2006.10132', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10132'} | arxiv |
\section{Introduction}
For a chosen null hypothesis, there may be many ways to compute a p-value given a measurement, but all these ways share a common structure. A summary statistic is chosen, the cumulative distribution function (CDF) for the summary statistic is computed, and finally the value of the CDF at the observed value of the summary statistic is reported as the p-value. Because this process must always pass through a CDF in this manner, p-values can be reasoned about without knowing exactly which summary statistics were used in their computation.
Given a series of experiments designed to test the same null hypothesis, \href{https://en.wikipedia.org/wiki/Fisher's_method}{Fisher's method} provides a way to determine a p-value for the combined set of experiments, given the p-values for the individual experiments. However, Fisher's method is not equipped to incorporate prior differential confidences that a reasoner may have in the individual experiments. We will begin by describing the original Fisher's method before deriving a corresponding method that utilizes weights.
\section{Background}
We will describe the original Fisher's method here, beginning with proofs for two relevant, well-known results.
\begin{lemma}
Conditioned on the null hypothesis being true, the p-value of any observation will be uniformly distributed between $0$ and $1$.
\end{lemma}
\begin{proof}
Let $p(x)$ be the probability density function (PDF) and $P(x)$ be the cumulative density function (CDF) for observation $x$ under the null-hypothesis, and let $q(y)$ be the probability density function for the p-value obtained in such an experiment. Equating the parameterizations (under $x$ and $y$) of the probability mass over an infinitesimal region of space, we have
\begin{equation}
\label{eq:1}
q(y) dy = p(x) dx \implies \frac{dy}{dx} = \frac{p(x)}{q(y)}
\end{equation}
However, we also have that $y = P(x)$ by definition, which gives
\begin{equation}
\label{eq:2}
\frac{dy}{dx} = \frac{dP}{dx} = p(x)
\end{equation}
\noindent Equating \eqref{eq:1} and \eqref{eq:2} gives $q(y) = 1$, as desired.
\end{proof}
\begin{lemma}
The negative log of a random variable drawn from the uniform distribution between 0 and 1 will follow an exponential distribution.
\end{lemma}
\begin{proof}
Let the original (uniformly distributed) variable be $x$ and the new variable and distribution be $y = -\log{x}$ and $p(y)$ respectively. The probability mass of an infinitesimal region under the $x$-parameterization is $1 * |dx|$, while the probability mass under the $y$-parameterization is
\begin{equation}
\label{eq:3}
p(y) |dy| = p(y) |\frac{dy}{dx} dx| = p(y) \frac{|dx|}{x}
\end{equation}
Equating both expressions and simplifying gives $p(y) = x = e^{-y}$, as desired.
\end{proof}
Let \{$x_i$\} be the p-values obtained from a set of experiments testing the same null hypothesis. The original Fisher's method \cite{reference} uses
\begin{equation}
\label{eq:4}
S = -\sum_{i}{\log{x_i}}
\end{equation}
as a summary statistic, noting that under the null hypothesis, $2S$ should follow a Chi-Squared distribution. However, if we were to introduce confidence weights $w_i$ corresponding to our $x_i$, then
\begin{equation}
\label{eq:5}
S(\{w_i\}) = -\sum_{i}{w_i \log{x_i}}
\end{equation}
would still be a valid summary statistic, but $2S$ would no longer follow a Chi-Squared distribution. In the final section of this paper, we derive a method, with proof, for computing the CDF of (and thus the combined p-value associated with) $S(\{w_i\})$
\section{Weighted Fisher's Method}
Let $\{v_i, \forall i \in \mathbb{Z} | 1 \leq i \leq k\}$ be a set of exponentially distributed random variables and $\{w_i, \forall i \in \mathbb{Z} | 1 \leq i \leq k\}$ be a set of fixed positive weights. In order to use Fisher's method with weights, we need to characterize the PDF and CDF of $V = \sum_{i}{w_i v_i}$. In the next two subsections, we will consider two kinds of weight sets - those in which all weights are distinct, and those in which all weights are identical. In the third subsection, we will describe how to handle an arbitrary weight set using the results from these two cases. We do note that the latter case (identical weights) is already handled by the standard implementation of Fisher's method, but we include it here for completeness.
Before we present our results and associated proofs, it's worth first stating that the distribution of $v = w_i v_i$ for any $i$ is
\begin{equation}
\label{eq:6}
\displaystyle p(v) = \frac{1}{w_i} e^{-\frac{v}{w_i}}
\end{equation}
Also, while we have seen neither the proofs we present here nor the full generality of our results in prior work, we have observed specific cases \cite{alves}\cite{good} of our derived results in use throughout the broader statistics community.
\subsection{Distinct Weights}
Before we begin the main proof, we would like to establish a smaller result.
\begin{lemma}
\begin{equation}
\label{eq:7}
\sum_{i=1}^{k+1}{\frac{{w_i}^{k-1}}{\prod_{j \neq i}{(w_i - w_j)}}} = 0
\end{equation}
\end{lemma}
\begin{proof}
Let $\displaystyle h(z) = \frac{z^{k-1}}{\prod_{j=1}^{k+1}{(z-w_j)}}$. Now consider the path $C$ running counterclockwise along the circle of radius $R$ centered at the origin in the complex plane. For arbitrarily large $R$, $C$ contains all the residues of $h$, which are in fact just the various $w_i$. As such, the residue theorem gives us that
\begin{equation}
\label{eq:8}
\sum_{i=1}^{k+1}{\frac{{w_i}^{k-1}}{\prod_{j \neq i}{(w_i - w_j)}}} = \frac{1}{2\pi i}\int_{C}{h(z)dz}
\end{equation}
\noindent The magnitude of the integral on the right hand side of \eqref{eq:8} can be bounded above by
\begin{equation}
\label{eq:9}
\int_{C}{\frac{\|z\|^{k-1}}{\prod_{j}{\|z-w_j\|}}\|dz\|} \leq \frac{2 \pi R^k}{(R - \max_i(w_i))^{k+1}}
\end{equation}
\noindent Taking $R \rightarrow \infty$, we have that
\begin{equation}
\label{eq:10}
|\sum_{i=1}^{k+1}{\frac{{w_i}^k}{\prod_{j \neq i}{(w_i - w_j)}}}| = \frac{1}{2\pi} \|\int_{C}{h(z)dz}\| \leq \frac{R^k}{(R - \max_i(w_i))^{k+1}} \rightarrow (R - \max_i(w_i))^{-1} \rightarrow 0
\end{equation}
\noindent proving the desired result.
\end{proof}
\begin{theorem}
The PDF for the weighted sum $V$ of $k$ exponentially distributed variables when all weights are distinct is
\begin{equation}
\label{eq:11}
p_k(V) = \sum_{i=1}^{k}{\frac{{w_i}^{k-2} e^{-\frac{V}{w_i}}}{\prod_{j \neq i}{(w_i - w_j)}}}
\end{equation}
\end{theorem}
\begin{proof}
We will prove this result using induction. For the base case of $k=1$, it is easily confirmed that \eqref{eq:11} matches \eqref{eq:6}. Now for the inductive hypothesis, suppose we add weight $w_{k+1}$ and variable $v_{k+1}$ to our sets and redefine $V$ to include $w_{k+1}v_{k+1}$ in the sum. It follows that
\begin{equation}
\label{eq:12}
p_{k+1}(V) = \int_{0}^{V}{p_k(z) \frac{1}{w_{k+1}} e^{-\frac{V-z}{w_{k+1}}} dz}
\end{equation}
\noindent To evaluate this integral, we first perform an intermediate computation for $i\leq k$:
\begin{equation}
\label{eq:13}
f(i) = \int_{0}^{V}{\frac{1}{w_i}e^{-\frac{z}{w_i}}\frac{1}{w_{k+1}} e^{-\frac{V-z}{w_{k+1}}} dz} = \frac{1}{w_i-w_{k+1}}\left(e^{-\frac{V}{w_i}} - e^{-\frac{V}{w_{k+1}}}\right)
\end{equation}
\noindent Substituting \eqref{eq:11} into \eqref{eq:12}, exchanging the summation with the integral, and simplifying with \eqref{eq:13} gives
\begin{equation}
\label{eq:14}
p_{k+1}(V) = \sum_{i=1}^{k}{\frac{{w_i}^{k-1} f(i)}{\prod_{(j \leq k) \neq i}{(w_i - w_j)}}} = \left(\sum_{i=1}^{k}{\frac{{w_i}^{k-1} \left(e^{-\frac{V}{w_i}} - e^{-\frac{V}{w_{k+1}}}\right)}{\prod_{j \neq i}{(w_i - w_j)}}}\right)
\end{equation}
\noindent \eqref{eq:14} can be separated into two sums as
\begin{equation}
\label{eq:15}
p_{k+1}(V) = \left(\sum_{i=1}^{k}{\frac{{w_i}^{k-1} e^{-\frac{V}{w_i}}}{\prod_{j \neq i}{(w_i - w_j)}}}\right) - e^{-\frac{V}{w_{k+1}}}\left(\sum_{i=1}^{k}{\frac{{w_i}^{k-1} }{\prod_{j \neq i}{(w_i - w_j)}}}\right)
\end{equation}
\noindent and multiplying \eqref{eq:7} by $\displaystyle e^{-\frac{V}{w_{k+1}}}$ and adding the result to \eqref{eq:15} gives
\begin{equation}
\label{eq:16}
p_{k+1}(V) = \sum_{i=1}^{k+1}{\frac{{w_i}^{k-1} e^{-\frac{V}{w_i}}}{\prod_{j \neq i}{(w_i - w_j)}}}
\end{equation}
\noindent thus proving the inductive hypothesis and the desired result.
\end{proof}
\begin{theorem}
The right-tail p-value for the weighted sum $V$ of $k$ exponentially distributed variables when all weights are distinct is
\begin{equation}
\label{eq:17}
\sum_{i=1}^{k}{\frac{{w_i}^{k-1} e^{-\frac{V}{w_i}}}{\prod_{j \neq i}{(w_i - w_j)}}}
\end{equation}
\end{theorem}
\begin{proof}
\begin{equation}
\label{eq:18}
\int_{V}^{\infty}{p_k(z) dz} = \sum_{i=1}^{k}{\frac{{w_i}^{k-2} \int_{V}^{\infty}{e^{-\frac{z}{w_i}}dz}}{\prod_{j \neq i}{(w_i - w_j)}}} = \sum_{i=1}^{k}{\frac{{w_i}^{k-1} e^{-\frac{V}{w_i}}}{\prod_{j \neq i}{(w_i - w_j)}}}
\end{equation}
\end{proof}
\subsection{Identical Weights}
\begin{theorem}
The PDF for the weighted sum $V$ of $k$ exponentially distributed variables when all weights are identical ($w_i = w$ $\forall$ $i$) is
\begin{equation}
\label{eq:19}
p_k(V) = \frac{1}{(k-1)!w}\left(\frac{V}{w}\right)^{k-1}e^{-\frac{V}{w}}
\end{equation}
\end{theorem}
\begin{proof}
We will prove this result using induction. For the base case of $k=1$, it is easily confirmed that \eqref{eq:19} matches \eqref{eq:6}. Now for the inductive hypothesis, we have that $p_{k+1}(V)$ is
\begin{equation}
\label{eq:20}
\int_{0}^{V}{p_k(z) \frac{1}{w} e^{-\frac{V-z}{w}} dz} = \frac{w^{-k-1}e^{-\frac{V}{w}}}{(k-1)!}\int_{0}^{V}{z^{k-1} dz} = \frac{e^{-\frac{V}{w}}}{k!w}\left(\frac{V}{w}\right)^{k}
\end{equation}
\noindent thus proving the inductive hypothesis.
\end{proof}
\noindent Before we extend this to find an expression for the p-value we're interested in, we will prove an intermediate result using differentiation under the integral sign.
\begin{lemma}
\begin{equation}
\label{eq:21}
\int_{c}^{\infty}{u^n e^{-au} du} = c^n \left(\sum_{j=0}^{n}{j!\binom{n}{j}(ca)^{-j}}\right)\frac{e^{-ca}}{a}
\end{equation}
\end{lemma}
\begin{proof}
\begin{equation}
\label{eq:22}
\int_{c}^{\infty}{u^n e^{-au} du} = \int_{c}^{\infty}{(-1)^n \left(\frac{d}{da}\right)^n \left(e^{-au}\right) du}
\end{equation}
\noindent Exchanging the order of differentiation and integration in (20) gives
\begin{equation}
\label{eq:23}
\left(\frac{d}{da}\right)^n\int_{c}^{\infty}{(-1)^n e^{-au} du} = (-1)^n \left(\frac{d}{da}\right)^n\left(a^{-1}e^{-ca}\right)
\end{equation}
\noindent Using the binomial expansion of the product rule, we have
\begin{equation}
\label{eq:24}
\left(\frac{d}{da}\right)^n\left(a^{-1}e^{-ca}\right) = \sum_{j=0}^{n}{\binom{n}{j}\left(\frac{d}{da}\right)^j(a^{-1})\left(\frac{d}{da}\right)^{n-j}(e^{-ca})}
\end{equation}
\noindent Simplifying \eqref{eq:24}, we have that this expression becomes
\begin{equation}
\label{eq:25}
\sum_{j=0}^{n}{\binom{n}{j}(-1)^j j! (a^{-j-1}) (-c)^{n-j} e^{-ca}} = (-c)^n\left(\sum_{j=0}^{n}{j!\binom{n}{j} (ca)^{-j}}\right) \frac{e^{-ca}}{a}
\end{equation}
\noindent We substitute \eqref{eq:25} back into \eqref{eq:23} and simplify to obtain the desired result.
\end{proof}
\begin{theorem}
The right-tail p-value for the weighted sum $V$ of $k$ exponentially distributed variables when all weights are identical is
\begin{equation}
\label{eq:26}
\left(\sum_{i=0}^{k-1}{\frac{1}{i!}\left(\frac{V}{w}\right)^i}\right)e^{-\frac{V}{w}}
\end{equation}
\end{theorem}
\begin{proof}
Let $u = \frac{z}{w}$. Then we have
\begin{equation}
\label{eq:27}
\int_{V}^{\infty}{p_k(z) dz} = \frac{1}{(k-1)!}\int_{\frac{V}{w}}^{\infty}{u^{k-1} e^{-u} du}
\end{equation}
\noindent Substituting \eqref{eq:21}, with $c = \frac{V}{w}, a=1,$ and $n=k-1$, into \eqref{eq:27}, reversing the order of the summation, and reducing the binomials and factorials gives the desired result.
\end{proof}
\subsection{Handling Arbitrary Sets of Weights}
In most situations, we may not expect our weights to be uniformly identical or pair-wise distinct. In these cases, we cannot directly apply our derived expressions to the full set of weighted p-values. However, we propose here a computational method that will allow for handling arbitrary sets of weights.
Let $V$ again denote the weighted sum of the negative log p-values. Additionally, let $\{w_i\}$ denote the set of \textit{unique} weights and $\{n_i\}$ denote the multiplicities of the weights, i.e. $w_i$ appears $n_i$ times. Finally, for every $i$, let $a_i = (w_i)^{-1}$ and let $V_i$ denote the weighted sum of all $n_i$ negative log p-values associated with $w_i$. Having proven theorem 3.4, we know that the PDF $p_i$ for $V_i$ follows the form given by \eqref{eq:19}, with $k=n_i$ and $w=w_i$.
Let $p(V)$ denote the PDF for $V$. Since $V = \sum_{i}{V_i}$, it follows that $p(V)$ is the convolution of all the $p_i$. Now, let $f(s)$ be the Laplace Transform (LT) of $p(V)$ and let $f_i$ be the LT of $p_i$ for each $i$. Using \eqref{eq:19}, along with the fact that the LT converts convolutions to products, we have that
\begin{equation}
\label{eq:28}
f(s) = \prod_{i}{f_i(s)} = \prod_{i}{\frac{{a_i}^{n_i}}{(s+a_i)^{n_i}}}
\end{equation}
Furthermore, we have that the LT, $F$, of the left-tail p-value for $V$ is given by
\begin{equation}
\label{eq:29}
F(s) = \frac{f(s)}{s} = \frac{1}{s}\prod_{i}{\frac{{a_i}^{n_i}}{(s+a_i)^{n_i}}}
\end{equation}
As can be seen in \eqref{eq:29}, $F(s)$ is a rational fraction, and so can be decomposed into the following form:
\begin{equation}
\label{eq:30}
F(s) = \frac{c}{s} + \sum_{i}{\sum_{j=1}^{n_i}{\frac{c_{ij}}{(s+a_i)^{j}}}}
\end{equation}
and consequently the reverse LT can be applied to \eqref{eq:30} to obtain
\begin{equation}
\label{eq:31}
P(V) = c + \sum_{i}{\sum_{j=1}^{n_i}{\frac{c_{ij}}{(j-1)!} V^{j-1} e^{-a_i V}}}
\end{equation}
Determining the values of $c$ and the $c_{ij}$ that will render \eqref{eq:29} and \eqref{eq:30} equal is a special case of partial fraction decomposition, a problem that has been very well studied \cite{brugia} \cite{pfe}. Recursive expressions for these coefficients exist that can be computed quite efficiently \cite{pfe}.
In fact, these recursions can be solved explicitly to obtain analytic expressions for $c$ and the $c_{ij}$, but we leave such expansions as exercises for the interested reader. The derivation of such expansions should not require tools or techniques beyond those used in this paper. Additionally, the LT-based methodology we have outlined in this subsection for deriving an expression for $P(V)$ can be used, even without the more sophisticated results on partial fraction decomposition, to provide alternative proofs for theorems 3.2, 3.3, 3.4, and 3.6.
As we have stated, the values of $c$ and the $c_{ij}$, and through them the function $P$, are accessible to us for an arbitrary set of weights. By construction, $P(V)$ denotes the left-tail p-value of $V$, and so $1-P(V)$ is the right-tail p-value of $V$, i.e. the combined p-value that we set out to compute.
An implementation of this procedure for computing the combined p-value for an arbitrary set of weights can be found on GitHub, under arvindthiagarajan/multimodal-statistics.
\bibliographystyle{plain}
| {'timestamp': '2020-06-19T02:02:45', 'yymm': '2006', 'arxiv_id': '2006.10126', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10126'} | arxiv |
\subsection{Problem setting and notations}
In an unsupervised domain adaptation framework, we have access to a set of labeled source data $\{(\boldsymbol{x}_s^i, y_s^i) \in (\mathcal{X} \times \mathcal{Y})\}_{i=1}^n$, sampled i.i.d. from the source domain distribution $\mathcal{D}_S$ and a set of unlabeled target data $\{\boldsymbol{x}_t^j \in \mathcal{X}\}_{j=1}^m$ sampled i.i.d. from the target domain distribution $\mathcal{D}_T$.
A domain is defined as a pair comprised of a distribution $\mathcal{D}$ in the input space $\mathcal{X}$ and a labeling function $f: \mathcal{X} \rightarrow \mathcal{Y}$, where the output space $\mathcal{Y}$ is $[0, 1]$ in the theoretical analysis.
Consequently, we use $\langle \mathcal{D}_S, f_S \rangle$ and $\langle \mathcal{D}_T, f_T \rangle$ to denote the source and target domains, respectively.
The goal of unsupervised domain adaptation is to learn a hypothesis function $h: \mathcal{X} \mapsto \mathcal{Y}$ that provides a good generalization in the target domain.
Formally, the error of a hypothesis $h$ with respect to a labeling function $f_T$ under the target domain distribution $\mathcal{D}_T$ is defined as $\epsilon_T(h, f_T) \coloneqq \mathbb{E}_{\boldsymbol{x} \sim \mathcal{D}_T}[\@ifstar{\oldabs}{\oldabs*}{h(\boldsymbol{x}) - f_T(\boldsymbol{x})}]$.
\subsection{Theoretical background for domain adaptation}
We review the theoretical basis of domain adaptation~\cite{ben2010theory}.
The ideal joint hypothesis is defined as,
\begin{definition} [\cite{ben2010theory}]
Let $\mathcal{H}$ be a hypothesis space.
The \textit{ideal joint hypothesis} is the hypothesis which minimizes the combined error: $h^* \coloneqq \argmin_{h \in \mathcal{H}} \epsilon_S (h, f_S) + \epsilon_T (h, f_T)$. We denote the combined error of the ideal hypothesis by $\lambda \coloneqq \epsilon_S (h^*, f_S) + \epsilon_T (h^*, f_T)$.
\end{definition}
\citet{ben2010theory} proposed the following theorem for the upper bound on the target error, which is used as the theoretical background for numerous unsupervised domain adaptation methods.
\begin{restatable}[\cite{ben2010theory}]{thm}{bendavid}
\label{bendavid_theorem}
Let $\mathcal{H}$ be a hypothesis space, then the expected target error is upper bounded as,
\[\epsilon _{T}(h, f_T) \leq \epsilon_{S}(h, f_S) + \frac{1}{2}d_{\mathcal{H}\Delta\mathcal{H}}(\mathcal{D}_S, \mathcal{D}_T) + \lambda,\]
where $d_{\mathcal{H}\Delta\mathcal{H}}(\mathcal{D}_S, \mathcal{D}_T)$ is $\mathcal{H}\Delta\mathcal{H}$-distance between the source and target distributions.
Formally,
\[d_{\mathcal{H}\Delta\mathcal{H}}(\mathcal{D}_S, \mathcal{D}_T) \coloneqq 2 \sup_{h, h^\prime \in \mathcal{H}} \@ifstar{\oldabs}{\oldabs*}{\mathrm{Pr}_{\boldsymbol{x} \sim \mathcal{D}_S} [h(\boldsymbol{x}) \neq h^\prime(\boldsymbol{x})] - \mathrm{Pr}_{\boldsymbol{x} \sim \mathcal{D}_T} [h(\boldsymbol{x}) \neq h^\prime(\boldsymbol{x})]}.\]
\end{restatable}
Theorem~\ref{bendavid_theorem} shows that the target error is upper bounded by the sum of the source error, $\mathcal{H}\Delta\mathcal{H}$-distance between the domains, and the error of the ideal joint hypothesis, $\lambda$.
The last term $\lambda$ is often considered to be minute.
Accordingly, many recent works on domain adaptation endeavored to allow a feature encoder $g: \mathcal{X} \mapsto \mathcal{Z}$ to learn such that the induced distributions of the domains in feature space $\mathcal{Z}$ have a minimal $\mathcal{H}\Delta\mathcal{H}$-distance, while also minimizing the source error~\cite{pmlr-v37-ganin15, JMLR:v17:15-239, NIPS2018_8075, pei2018multi}.
However, as demonstrated in~\cite{chen2019transferability}, $\lambda$ can become substantial as feature transferability is enhanced.
In particular, it was observed in~\cite{chen2019transferability} that the optimal joint error on the learned feature representation of Domain Adversarial Neural Network (DANN)~\cite{pmlr-v37-ganin15} is much higher than that of pre-trained ResNet-50~\cite{he2016deep}.
This suggests that learning domain-invariant features is not sufficient to tightly bound the target error.
\subsection{Unsupervised domain adaptation}
\paragraph{Marginal distribution alignment.}
As suggested by the theoretical analysis in~\cite{ben2010theory}, aligning the marginal distributions can result in reducing target error, and is common practice in domain adaptation~\cite{tzeng2014deep, sun2016deep, pmlr-v37-ganin15, tzeng2017adversarial, pmlr-v37-long15, long2017deep}.
\citet{pmlr-v37-long15, long2017deep} utilized the Maximum Mean Discrepancy (MMD) and Joint MMD, respectively, for estimating and minimizing the domain discrepancy over the domain-specific layers.
Inspired by Generative Adversarial Networks (GANs)~\cite{goodfellow2014generative}, \citet{pmlr-v37-ganin15} introduced a domain discriminator to convert the domain confusion into a minmax optimization.
However, \citet{shu2018a} and \citet{pmlr-v97-zhao19a} theoretically demonstrated that finding invariant representations is not sufficient to guarantee a small target error, and \citet{chen2019transferability} empirically revealed an unexpected deterioration in discriminability while learning transferable representations.
\paragraph{Discriminative representation learning.}
Researchers have attempted to learn class-level discriminative features using two main technologies: first-order statistics matching and Siamese-networks training~\cite{bromley1994signature, luo2018smooth, schroff2015facenet}.
\citet{xie2018learning} aligned the source and target centroids to learn semantic representations of the target data.
Utilizing the MMD measurement, \citet{kang2019contrastive} proposed the minimization of intra-class discrepancy and maximizing the inter-class margin.
\citet{deng2019cluster} employed pairwise margin loss to learn discriminative features and minimized the distances between the first-order statistics to align the conditional distributions.
However, there are two main differences between the proposed JCL approach and these methods.
First, with the theoretical analysis that explicitly handles the joint hypothesis error, we propose to jointly optimize the source and target domains to have class-wise discriminative representations.
Second, we theoretically guarantee learning discriminative features from the perspective of JS divergence by maximizing the MI between a feature and its label.
Previous pairwise loss or triplet loss-based methods cannot properly bound and maximize the MI.
\paragraph{Contrastive learning.}
Contrastive learning has been adopted for self-supervised learning and has led to significant performance enhancement.
\citet{oord2018representation} introduced \textit{InfoNCE} loss to estimate and maximize the MI between a present context and a future signal.
In the image domain, \citet{hjelm2018learning}, \citet{bachman2019learning}, and \citet{chen2020simple} maximized the MI between features that originated from the same input with different augmentations.
From the information-theoretic perspective, \citet{Tschannen2020On} suggested that these methods could be subsumed under the same objective, \textit{InfoMax}~\cite{linsker1988self} (see Section~\ref{sec:4_2_1_Theoretical_guarantees} for more details), and provided a different perspective on the success of these methods.
As opposed to these methods, the proposed approach maximizes the MI between features from the same class to maximize the JS divergence between different class-conditional distributions.
\subsection{Alternative Tractable Joint Hypothesis Error}
\subsection{An alternative upper bound}
\label{sec:4_1_Alternative_Error}
In the past, it was assumed that the ideal joint hypothesis error was insignificant, and therefore, it was neglected.
However, recent studies~\cite{chen2019transferability, pmlr-v97-zhao19a} have suggested that this error can become substantial, and so must be addressed adequately.
Computations of the ideal joint hypothesis in Theorem~\ref{bendavid_theorem} are usually intractable, because of which addressing the optimal joint error is challenging.
With the proposed method, we therefore aim to provide an alternative upper bound on the target error, which clearly incorporates the concept of joint error, and is free from the optimal hypothesis.
A small ideal joint hypothesis error implies that there exists a joint hypothesis, which generalizes well on both the source and target domains.
Intuitively, it is natural to consider jointly optimizing within the domains to minimize the joint error.
From this point of view, we define a combined domain $\langle \mathcal{D}_U, f_U \rangle$ as below.
\begin{definition}
Let $\phi_S$ and $\phi_T$ be the density functions of the source and target distributions, respectively.
Then, the distribution of the combined domain $\mathcal{D}_U$ is the mean distribution of the source and target distributions: $\phi_U(\boldsymbol{x}) \coloneqq \frac{1}{2} (\phi_S(\boldsymbol{x}) + \phi_T(\boldsymbol{x}))$.
The labeling function $f_U$ of the combined domain is defined similarly: $f_U(\boldsymbol{x}) \coloneqq \frac{1}{2} (f_S(\boldsymbol{x}) + f_T(\boldsymbol{x}))$.
\end{definition}
With the definition of the combined domain, the following theorem holds:
\begin{restatable}{thm}{alternative}
\label{alternative_theorem}
Let $\mathcal{H}$ be a hypothesis space, then the expected target error is upper bounded as,
\[\epsilon_{T}(h, f_T) \leq \epsilon_{S}(h, f_S) + \frac{1}{4}d_{\mathcal{H}\Delta\mathcal{H}}(\mathcal{D}_S, \mathcal{D}_T) + 2 \epsilon_{U}(h, f_U).\]
\end{restatable}
\begin{proof}
The proof is provided in Appendix A.
\end{proof}
\paragraph{Comparison with Theorem~\ref{bendavid_theorem}.}
The main difference between Theorem~\ref{bendavid_theorem} and Theorem~\ref{alternative_theorem} lies in $\lambda$ in Theorem~\ref{bendavid_theorem} and $2 \epsilon_{U}(h, f_U)$ in Theorem~\ref{alternative_theorem}.
To illustrate, $\lambda$ in Theorem~\ref{bendavid_theorem} is composed of the ideal joint hypothesis, which is neither tractable nor manageable, and hence, it has been obliquely addressed~\cite{deng2019cluster, chen2019progressive, chen2019joint, saito2017asymmetric}.
On the contrary, $2 \epsilon_{U}(h, f_U)$, the alternative term in Theorem~\ref{alternative_theorem}, is directly affected by the hypothesis $h$, and thus, it is straightforward to utilize.
Differ from the previous studies that attempt to only alter $\lambda$ from Theorem~\ref{bendavid_theorem}, Theorem~\ref{alternative_theorem} cannot be directly derived from Theorem~\ref{bendavid_theorem}, because the second term in Theorem~\ref{alternative_theorem} is smaller than that in Theorem~\ref{bendavid_theorem}.
The main idea here is that joint optimization in the source and target domains is demanded upon simply matching the marginal distributions of the domains.
As the target labels are not provided, we must rely on the source labels.
However, optimization of the source domain alone can result in poor generalization of the target domain.
We therefore combine the source and target domains and propose their joint optimization.
To estimate the joint hypothesis error, we resort to target pseudo-labels, and the following theorem holds:
\begin{restatable}{thm}{pseudo}
\label{pseudo_alternative_theorem}
Let $\mathcal{H}$ be a hypothesis space, and $f_{\hat{T}}$ be a target pseudo-labeling function.
Accordingly, $f_{\hat{U}}$ is defined as, $f_{\hat{U}}(\boldsymbol{x}) \coloneqq \frac{1}{2} (f_S(\boldsymbol{x}) + f_{\hat{T}}(\boldsymbol{x}))$.
Then the expected target error is upper bounded as,
\[\epsilon_{T}(h, f_T) \leq \epsilon_{S}(h, f_S) + \frac{1}{4}d_{\mathcal{H}\Delta\mathcal{H}}(\mathcal{D}_S, \mathcal{D}_T) + 2 \epsilon_{U}(h, f_{\hat{U}}) + \epsilon_{T}(f_T, f_{\hat{T}}).\]
\end{restatable}
\begin{proof}
The proof is provided in Appendix A.
\end{proof}
\subsection{Joint Contrastive Learning}
\label{sec:4_2_Joint_Contrastive_Learning}
As the learned feature representation has a substantial impact on classification error, it is important to learn discriminative features to minimize this error.
For instance, in unsupervised learning, which is similar to unsupervised domain adaptation because the target true labels are not available, discriminative feature learning has brought remarkable progress in a variety of tasks~\cite{chen2020simple, he2019momentum, oord2018representation}.
At a high level, the main idea here is that segregating the features of dissimilar samples helps a classifier to generalize well without requiring high model complexity.
Our proposed method also utilizes the notion of learning discriminative feature representation in minimizing the joint hypothesis error.
\subsubsection{Theoretical guarantees}
\label{sec:4_2_1_Theoretical_guarantees}
Formally, we aim to learn discriminative features on the intermediate representation space $\mathcal{Z}$ induced through the feature transformation $g$.
We denote the induced distribution of the combined domain $\mathcal{D}_U$ over the representation space $\mathcal{Z}$ as $\mathcal{D}^{\mathcal{Z}}_{U}$, and its class-conditional distribution as $\mathcal{D}^{\mathcal{Z}}_{U|y}$, where $y$ is a class label.
We can then formalize our objective with JS divergence $D_{\mathrm{JS}}$ as follows:
\begin{equation}
\max_{\theta_g} D_{\mathrm{JS}}(\mathcal{D}^{\mathcal{Z}}_{U|0} \| \mathcal{D}^{\mathcal{Z}}_{U|1}),
\end{equation}
where $\theta_g$ denotes the parameters of the feature encoder $g$.
The values 0 and 1 are the class labels, and hence, the objective means maximizing the divergence between different class-conditional distributions.
We consider binary classification for the theoretical analysis here, but this approach can also be generalized to a multiclass classification problem (see Appendix B for more details).
Suppose that the label distribution of the combined domain is uniform, i.e., $P(y=0) = P(y=1)$.
In practice, this can be achieved by reformulating a dataset to be class-wise uniform, as described in Section~\ref{sec:4_2_2_Training_procedure}.
Let $Y$ be a uniform random variable that takes the value in $\{0, 1\}$ and let the distribution $\mathcal{D}^{\mathcal{Z}}_{U|Y}$ be the mixture of $\mathcal{D}^{\mathcal{Z}}_{U|0}$ and $\mathcal{D}^{\mathcal{Z}}_{U|1}$, according to $Y$.
We denote the induced feature random variable with the distribution $\mathcal{D}^{\mathcal{Z}}_{U|Y}$ as $\boldsymbol{Z}_{U|Y}$.
From the relation between JS divergence and MI, $D_{\mathrm{JS}}(\mathcal{D}^{\mathcal{Z}}_{U|0} \| \mathcal{D}^{\mathcal{Z}}_{U|1}) = I(Y;\boldsymbol{Z}_{U|Y})$ holds.
Therefore, we can transform our objective as follows:
\begin{equation}
\max_{\theta_g} I(Y;\boldsymbol{Z}_{U|Y}).
\end{equation}
The MI between a label and a feature that is induced from the distribution conditioned on the label can be maximized using the following approach.
We employ the InfoNCE loss proposed by~\citet{oord2018representation} to estimate and maximize the MI.
InfoNCE is defined as,
\begin{equation}
I(X;Y)
\geq \E \Bigg[\frac{1}{K} \sum_{i=1}^K \log \frac{e^{c(x_i, y_i)}}{\frac{1}{K} \sum_{j=1}^K e^{c(x_i, y_j)}}\Bigg]
\triangleq I_{\mathrm{NCE}}(X;Y),
\end{equation}
where the expectation is over $K$ independent samples from the joint distribution $p(x, y)$~\cite{pmlr-v97-poole19a}.
$c(x, y)$ is a \textit{critic} function used to predict whether the inputs $x$ and $y$ were jointly drawn by yielding high values for the jointly drawn pairs and low values for the others~\cite{Tschannen2020On}.
The proposed JCL framework does not directly pair a feature and its label to maximize the MI between them.
Instead, features from the same conditional distribution are paired, and we use $I_{\mathrm{NCE}}$ to maximize the MI between them.
For a given $Y$, let $\boldsymbol{Z}_{U|Y}^{(1)}$ and $\boldsymbol{Z}_{U|Y}^{(2)}$ be two different features that are sampled from the same conditional distribution $\mathcal{D}^{\mathcal{Z}}_{U|Y}$.
Then, $I(\boldsymbol{Z}_{U|Y}^{(1)}; \boldsymbol{Z}_{U|Y}^{(2)}) \leq I(Y;\boldsymbol{Z}_{U|Y}^{(1)}, \boldsymbol{Z}_{U|Y}^{(2)})$ holds, with the data processing inequality (see Appendix C for more details).
Therefore, $\max_{\theta_g} I(\boldsymbol{Z}_{U|Y}^{(1)}; \boldsymbol{Z}_{U|Y}^{(2)})$ can be seen as a lower bound for our objective $\max_{\theta_g} I(Y;\boldsymbol{Z}_{U|Y})$, and we optimize it with our InfoNCE loss $\mathcal{L}_{\mathrm{c}}$, as described below.
\paragraph{Comparison with InfoMax objective.}
Comparing our objective $\max_{\theta_g} I(Y;\boldsymbol{Z}_{U|Y})$ with the InfoMax objective $\max_{\theta_g} I(\boldsymbol{X};g(\boldsymbol{X}))$~\cite{linsker1988self} provides instructive insights.
Recent progress on unsupervised representation learning~\cite{chen2020simple, oord2018representation, hjelm2018learning, tian2019contrastive} can be subsumed under the same objective $\max_{\theta_{g_1}, \theta_{g_2}} I(g_1(\boldsymbol{X}^{(1)});g_2(\boldsymbol{X}^{(2)}))$, where $\boldsymbol{X}^{(1)}$ and $\boldsymbol{X}^{(2)}$ are instances that originate from the same data~\cite{Tschannen2020On}.
Using the process similar to that derived above, it can be shown that the objective is a lower bound on the InfoMax objective.
The main difference is that the InfoMax principle essentially aims to maximize the MI between data and its representation, whereas our objective focuses on maximizing the divergence between different class-conditional distributions in the feature space.
\paragraph{Comparison with triplet loss-based methods.}
The multi-class-K-pair loss~\cite{sohn2016improved}, which is the generalized triplet loss~\cite{weinberger2009distance}, can be shown to be a special case of InfoNCE loss~\cite{Tschannen2020On}, and triplet loss is the same as in the $K=2$ case.
The drawback of using triplet loss to learn discriminative features is that it cannot tightly bound the MI when the MI is larger than $\log K$ because $I_{\mathrm{NCE}}$ is upper bounded by $\log K$.
Pairwise margin loss also compares only two features, and hence, it is also expected to have a loose bound.
Thus, triplet loss or pairwise loss-based domain adaptation methods~\cite{deng2019cluster, chen2019joint, dai2019contrastively} cannot guarantee class-level discriminative features from an information-theoretic perspective.
\subsubsection{Training procedure}
\label{sec:4_2_2_Training_procedure}
\begin{figure}[t]
\centering
\includegraphics[width=\linewidth]{Figures/model_overview_cropped.pdf}
\caption{An overview of the JCL training process. To alleviate the problem of tradeoff between a small joint error and marginal distribution alignment when the label distributions are substantially different~\cite{pmlr-v97-zhao19a}, we propose rearranging the datasets to obtain uniform label distributions. For contrastive learning, we adopt \textit{Momentum Contrast}~\cite{he2019momentum}, which maintains a queue and a moving-averaged encoder on-the-fly to enable a large and consistent dictionary. After the encoders, a fully connected (FC) layer is applied for classification, and another FC layer is employed for contrastive loss.}
\label{fig:jcl_overview}
\end{figure}
In this section, we formulate the loss functions and architecture of the method based on the aforementioned theoretical frameworks.
The overview of JCL is illustrated in Figure~\ref{fig:jcl_overview} and its pseudo-code is provided in Appendix D.
\textit{Momentum Contrast} (MoCo)~\cite{he2019momentum} is adopted as the proposed contrastive learning structure, with an encoder $g_q$ with parameters $\theta_q$ and a momentum-updated encoder $g_k$ with parameters $\theta_k$ for feature transformation $\mathcal{X} \mapsto \mathcal{Z}$.
$\theta_k$ are updated by $\theta_k \leftarrow m\theta_k + (1-m)\theta_q$, where $m \in [0, 1)$ is a momentum coefficient.
A fully connected (FC) layer projection head $l: \mathcal{Z} \mapsto \mathcal{W}$ is implemented to map the encoded representations to the space where the InfoNCE loss is applied.
Empirical tests determine that it is beneficial to define InfoNCE loss in the projected space $\mathcal{W}$ rather than $\mathcal{Z}$, which is in agreement with the results of~\citet{chen2020simple}.
For the feature pairs in the InfoNCE loss, an encoded query $\boldsymbol{w}_q=l_q(g_q(\boldsymbol{x}))$ and a key $\boldsymbol{w}_k=l_k(g_k(\boldsymbol{x}))$ from the queue of encoded features are used, where $l_q$ and $l_k$ are defined in a similar manner to $g_q$ and $g_k$, respectively.
We obtain the new keys on-the-fly by the momentum encoder and retain the queue of keys.
For the critic function $c$, we employ a cosine similarity function $\mathrm{sim}(\boldsymbol{u}, \boldsymbol{v}) = \boldsymbol{u}^\intercal \boldsymbol{v} / \|\boldsymbol{u}\| \|\boldsymbol{v}\|$ with a temperature hyper-parameter $\tau$ according to~\cite{wu2018unsupervised}.
Our InfoNCE loss $\mathcal{L}_\mathrm{c}$ is then formulated as follows:
\begin{equation}
\mathcal{L}_{\mathrm{c}} = \E_{w_q \sim \mathcal{D}_U^W} \Bigg[ \E_{w_k^{+}} \Bigg[ -\log \frac{\exp (\mathrm{sim}(w_q, w_k^{+})/\tau)}{\sum_{w_k \in N_k \cup \{w_k^{+}\}}\exp (\mathrm{sim}(w_q, w_k) / \tau)} \Bigg] \Bigg],
\end{equation}
where $w_k^{+}$ is a feature that has the same label as $w_q$ and $N_k$ is a set of features that have different labels from $w_q$.
For the classification task, we have another FC layer $h$ as a classification head.
To guarantee a small source error, we employ the broadly used cross-entropy loss,
\begin{equation}
\mathcal{L}_{\mathrm{s}} = \E_{(\boldsymbol{x}_s, y_s) \sim \mathcal{D}_S} \Big[ -\log h(g_q(\boldsymbol{x}_s))_{y_s} \Big].
\end{equation}
Combining $\mathcal{L}_\mathrm{s}$ and $\mathcal{L}_\mathrm{c}$ with a hyper-parameter $\gamma$, the overall objective is formulated as follows:
\begin{equation}
\min_\theta \mathcal{L}_\mathrm{s} + \gamma \mathcal{L}_\mathrm{c}.
\end{equation}
The labels of the target data are required to recognize whether or not the two samples of the combined domain have the same label.
To facilitate this, we generate the pseudo-labels of the target data.
In particular, we perform spherical K-means clustering of target data on the feature space $\mathcal{Z}$ and assign labels at the begining of each epoch.
If the distance between a target sample and its assigned cluster center is larger than a constant $d$, then the target sample is excluded from the combined dataset.
\citet{pmlr-v97-zhao19a} showed that if the marginal label distributions of source and target domains are substantially different, a small joint error is not achievable while finding an invariant representation.
To address this problem, we suggest the reformulation of datasets to provide uniform label distributions, in which the number of data per class is equalized by data rearrangement.
\subsection{Datasets and baselines}
\textbf{ImageCLEF-DA}\footnote{\url{https://www.imageclef.org/2014/adaptation}}
is a real-world dataset consisting of three domains: \textit{Caltech-256} (\textbf{C}), \textit{ImageNet ILSVRC 2012} (\textbf{I}), and \textit{Pascal VOC 2012} (\textbf{P}).
Each domain contains 600 images from 12 common classes.
We evaluated all six possible transfer tasks among these three domains.
\textbf{VisDA-2017}~\cite{visda2017}
is a dataset for the synthetic-to-real transfer task and has a high dataset shift.
It includes 152,397 synthetic 2D renderings of 3D models and 55,388 real images across 12 classes.
\textbf{Baselines.}
We compare JCL with marginal distribution matching methods: Deep Adaptation Network (\textbf{DAN})~\cite{pmlr-v37-long15}, Domain Adversarial Neural Network (\textbf{DANN})~\cite{JMLR:v17:15-239}, and Joint Adaptation Network (\textbf{JAN})~\cite{long2017deep} and
also with methods that endeavor to learn discriminative features: Multi-Adversarial Domain Adaptation (\textbf{MADA})~\cite{pei2018multi}, Conditional Domain Adversarial Network (\textbf{CDAN})~\cite{long2018conditional}, Adversarial Dropout Regularization (\textbf{ADR})~\cite{saito2018adversarial}, Maximum Classifier Discrepancy (\textbf{MCD})~\cite{saito2018maximum}, Cluster Alignment with a Teacher (\textbf{CAT})~\cite{deng2019cluster}, and Contrastive Adaptation Network (\textbf{CAN})~\cite{kang2019contrastive}.
\subsection{Implementation details}
We follow the standard experimental protocols for unsupervised domain adaptation~\cite{pmlr-v37-ganin15, long2017deep} and report the average accuracy over three independent runs.
To select the hyper-parameters, we use the same protocol as the one described in~\cite{pmlr-v37-long15}:
we train a source classifier and a domain classifier on a validation set that consists of labeled source data and unlabeled target data, and then, we jointly evaluate the test errors of the classifiers.
The selected hyper-parameters are detailed in Appendix E.
We adopt \textbf{ResNet-50} and \textbf{ResNet-101}~\cite{he2016deep} as base networks for ImageCLEF-DA and VisDA-2017, respectively, and we employ domain-specific batch normalization layers.
We finetune from ImageNet~\cite{deng2009imagenet} pre-trained models, with the exception of the last FC layer, which we replace with the task-specific FC layer.
We also add another FC layer with an output dimension of 256 for contrastive learning.
We utilize mini-batch SGD with momentum of 0.9 and follow the same learning rate schedule as~\cite{pmlr-v37-long15, JMLR:v17:15-239, long2017deep}: the learning rate $\eta_p$ is adjusted according to $\eta_p = \eta_0 (1+\alpha p)^{-\beta}$, where $p$ is the training progress that increases from 0 to 1.
The $\eta_0$ is the initial learning rate, which is set to 0.001 for the pre-trained layers and 0.01 for the added FC layers.
The $\alpha$ and $\beta$ are fixed to 10 and 0.75, respectively.
More details about the implementation is provided in Appendix F.
\subsection{Results}
\input{Tables/table_image-clef_result}
The results obtained using the ImageCLEF-DA dataset are reported in Table~\ref{imageclef_result}.
For all six adaptation scenarios, our proposed method outperforms the other baseline methods and achieves state-of-the-art accuracy.
In particular, the proposed method surpasses CAT by a substantial margin, validating the effectiveness of jointly learning discriminative features and the discussed information-theoretic guarantees.
Moreover, the methods that consider conditional distributions achieve higher accuracies than those that focus on marginal distribution matching.
These results suggest that learning discriminative features to minimize the joint hypothesis error is more crucial than general alignment.
\begin{figure}
\parbox[t]{0.45\textwidth}{\null
\centering
\small
\vskip-\abovecaptionskip
\captionof{table}[t]{Accuracy (\%) on VisDA-2017 for unsupervised domain adaptation (ResNet-101).}%
\vskip\abovecaptionskip
\label{visda_result}
\begin{tabular}{lccc}
\toprule
Method
& car
& truck
& Average
\\
\midrule
ResNet-101~\cite{he2016deep} & \textbf{91.7} & 25.9 & 49.4 \\
DANN~\cite{JMLR:v17:15-239} & 44.3 & 7.8 & 57.4 \\
DAN~\cite{pmlr-v37-long15} & 87.0 & 42.2 & 62.8 \\
JAN~\cite{long2017deep} & 86.3 & 54.5 & 65.7 \\
MCD~\cite{saito2018maximum} & 64.0 & 25.8 & 71.9 \\
ADR~\cite{saito2018adversarial} & 65.3 & 32.3 & 74.8 \\
SE~\cite{french2018selfensembling} & 58.6 & 47.9 & 84.3 \\
CAN~\cite{kang2019contrastive} & 74.3 & 59.9 & 87.2 \\
\midrule
JCL & 66.8 & \textbf{71.8} & \textbf{87.6} \\
\bottomrule
\end{tabular}
}
\hfill
\parbox[t]{0.55\textwidth}{\null
\begin{subfigure}[b]{0.27\textwidth}
\centering
\includegraphics[width=\textwidth]{Figures/dann_tsne.pdf}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.27\textwidth}
\centering
\includegraphics[width=\textwidth]{Figures/jcl_tsne.pdf}
\end{subfigure}
\captionof{figure}{Visualization for different methods (best viewed in color). \textbf{Left}: t-SNE of DANN. \textbf{Right}: JCL.}%
\label{fig:tsne}
}
\end{figure}
In Table~\ref{visda_result}, the accuracies obtained for two particular classes and the average accuracy over all twelve classes on the VisDA-2017 transfer task are reported.
All the results pertaining to the VisDA-2017 transfer task are provided in Appendix G owing to space constraints in the main manuscript.
The selected classes are "\textit{car}," wherein the proposed method achieves the lowest accuracy among the twelve objects and "\textit{truck}," which is the most challenging object among the twelve objects.
Notably, the proposed method boosts the accuracy of the \textit{truck} class by a significant margin, and, on average, it outperforms the other baseline methods.
In particular, it advances the lowest accuracy among the twelve objects of CAN (59.9\%) by 6.9\%.
These results can be attributed to the MI maximization between a feature and its label which trades-off maximizing entropy $H(\boldsymbol{z})$ and minimizing conditional entropy $H(\boldsymbol{z}|y)$, and thus avoids degenerate solutions~\cite{caron2018deep} (see Appendix B for more details).
We visualize the learned target representations of the VisDA-2017 task by t-SNE~\cite{maaten2008visualizing} in Figure~\ref{fig:tsne} to compare our method with DANN in terms of feature discriminability.
While aligning the marginal distributions of the source and target domains, the features are not well discriminated with DANN.
On the contrary, the target features learned using our method are clearly discriminated, demonstrating that our objective to maximize the JS divergence between conditional distributions is achieved.
\subsection{Ablation studies}
\label{sec:ablation_studies}
\begin{figure}
\centering
\begin{subfigure}[b]{0.32\textwidth}
\centering
\includegraphics[width=\textwidth]{Figures/ideal_hypothesis.pdf}
\caption{}
\label{fig:error_rate}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.32\textwidth}
\centering
\includegraphics[width=\textwidth]{Figures/sensitivity_i_p.pdf}
\caption{}
\label{fig:sensitivity_i_p}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.32\textwidth}
\centering
\includegraphics[width=\textwidth]{Figures/sensitivity_p_i.pdf}
\caption{}
\label{fig:sensitivity_p_i}
\end{subfigure}
\caption{(a) Classification error rate on the learned representations. (b-c) The accuracy sensitivity of JCL to $\gamma$ on \textbf{I} $\rightarrow$ \textbf{P} (b) and \textbf{P} $\rightarrow$ \textbf{I} (c). The results for other tasks are similar.}
\label{fig:ablation_studies}
\end{figure}
To investigate the effectiveness of our method in minimizing the joint hypothesis error by learning discriminative representations, we conduct the same pilot analysis as~\citet{chen2019transferability};
we train a linear classifier on the representations learned using DANN and our method.
The linear classifier is trained on both source and target data using the labels.
The average error rate of the linear classifier corresponds to half of the ideal joint hypothesis error.
The results are shown in Figure~\ref{fig:error_rate}.
We can observe that the ideal joint hypothesis error of the representation learned using our method is significantly lower than that learned using DANN.
This implies that the proposed method is effective in achieving our objective to enhance feature discriminability.
We investigate the sensitivity of JCL to the weight hyper-parameter $\gamma$, and the results are shown in Figure~\ref{fig:sensitivity_i_p} and~\ref{fig:sensitivity_p_i}.
We could observe that JCL is not sensitive to the change in the value of $\gamma$.
\section{Proofs}
In this section, we provide the proofs of Theorem~\ref{alternative_theorem} and Theorem~\ref{pseudo_alternative_theorem} in the main manuscript.
We first introduce lemmas that are useful in proving the theorems.
\begin{lemma}
\label{triangle_inequality}
Let $\mathcal{H}$ be a hypothesis space and $\mathcal{D}$ be any distribution over input space $\mathcal{X}$. Then $\forall h, h^\prime, h^{\prime\prime} \in \mathcal{H}$, the following triangle inequality holds:
\[\epsilon_\mathcal{D} (h, h^\prime) \leq \epsilon_\mathcal{D} (h, h^{\prime\prime}) + \epsilon_\mathcal{D} (h^{\prime\prime}, h^\prime).\]
\end{lemma}
\begin{proof}
From the definition of the error and the triangle inequality of norm, we have
\[
\begin{split}
\epsilon_\mathcal{D} (h, h^\prime)
&= \mathbb{E}_{\boldsymbol{x} \sim \mathcal{D}}[\@ifstar{\oldabs}{\oldabs*}{h(\boldsymbol{x}) - h^\prime(\boldsymbol{x})}] \\
&= \mathbb{E}_{\boldsymbol{x} \sim \mathcal{D}}[\@ifstar{\oldabs}{\oldabs*}{h(\boldsymbol{x}) - h^\prime(\boldsymbol{x}) + h^{\prime\prime}(\boldsymbol{x}) - h^{\prime\prime}(\boldsymbol{x})}] \\
&\leq \mathbb{E}_{\boldsymbol{x} \sim \mathcal{D}}[\@ifstar{\oldabs}{\oldabs*}{h(\boldsymbol{x}) - h^{\prime\prime}(\boldsymbol{x})} + \@ifstar{\oldabs}{\oldabs*}{h^{\prime\prime}(\boldsymbol{x}) - h^\prime(\boldsymbol{x})}] \\
&= \mathbb{E}_{\boldsymbol{x} \sim \mathcal{D}}[\@ifstar{\oldabs}{\oldabs*}{h(\boldsymbol{x}) - h^{\prime\prime}(\boldsymbol{x})}] + \mathbb{E}_{\boldsymbol{x} \sim \mathcal{D}}[\@ifstar{\oldabs}{\oldabs*}{h^{\prime\prime}(\boldsymbol{x}) - h^\prime(\boldsymbol{x})}] \\
&= \epsilon_\mathcal{D} (h, h^{\prime\prime}) + \epsilon_\mathcal{D} (h^{\prime\prime}, h^\prime).
\end{split}
\]
\end{proof}
\begin{lemma}[\cite{ben2010theory}]
\label{h_divergence_inequality}
For any hypothesis $h, h^\prime \in \mathcal{H}$, the following inequality holds:
\[
\@ifstar{\oldabs}{\oldabs*}{\epsilon_S (h, h^\prime) - \epsilon_T (h, h^\prime)} \leq \frac{1}{2}d_{\mathcal{H}\Delta\mathcal{H}}(\mathcal{D}_S, \mathcal{D}_T).
\]
\end{lemma}
\begin{proof}
From the definition of the $\mathcal{H}\Delta\mathcal{H}$-distance, we have
\[
\begin{split}
d_{\mathcal{H}\Delta\mathcal{H}}(\mathcal{D}_S, \mathcal{D}_T)
&= 2 \sup_{h, h^\prime \in \mathcal{H}} \@ifstar{\oldabs}{\oldabs*}{\mathrm{Pr}_{\boldsymbol{x} \sim \mathcal{D}_S} [h(\boldsymbol{x}) \neq h^\prime(\boldsymbol{x})] - \mathrm{Pr}_{\boldsymbol{x} \sim \mathcal{D}_T} [h(\boldsymbol{x}) \neq h^\prime(\boldsymbol{x})]} \\
&= 2 \sup_{h, h^\prime \in \mathcal{H}} \@ifstar{\oldabs}{\oldabs*}{\epsilon_S (h, h^\prime) - \epsilon_T (h, h^\prime)} \\
&\geq 2 \@ifstar{\oldabs}{\oldabs*}{\epsilon_S (h, h^\prime) - \epsilon_T (h, h^\prime)}.
\end{split}
\]
\end{proof}
\alternative*
\begin{proof}
From Lemma~\ref{triangle_inequality}, Lemma~\ref{h_divergence_inequality}, and the definition of $\mathcal{D}_U$ and $f_U$, we have
\[
\begin{split}
\epsilon_{T}(h, f_T)
&\leq \epsilon_{T}(h, f_U) + \epsilon_{T}(f_U, f_T) \\
&= \epsilon_{S}(h, f_U) + \epsilon_{T}(h, f_U) + \epsilon_{T}(f_U, f_T) - \epsilon_{S}(h, f_U) \\
&\leq \epsilon_{S}(h, f_U) + \epsilon_{T}(h, f_U) + \epsilon_{T}(f_U, f_T) + \epsilon_{S}(h, f_S) - \epsilon_{S}(f_U, f_S) \\
&= \epsilon_{S}(h, f_S) + \epsilon_{S}(h, f_U) + \epsilon_{T}(h, f_U) \\
&\phantom{--------}+ \mathbb{E}_{\boldsymbol{x} \sim \mathcal{D}_T}[\@ifstar{\oldabs}{\oldabs*}{f_U(\boldsymbol{x}) - f_T(\boldsymbol{x})}] - \mathbb{E}_{\boldsymbol{x} \sim \mathcal{D}_S}[\@ifstar{\oldabs}{\oldabs*}{f_U(\boldsymbol{x}) - f_S(\boldsymbol{x})}] \\
&= \epsilon_{S}(h, f_S) + \epsilon_{S}(h, f_U) + \epsilon_{T}(h, f_U) \\
&\phantom{--------}+ \frac{1}{2}\mathbb{E}_{\boldsymbol{x} \sim \mathcal{D}_T}[\@ifstar{\oldabs}{\oldabs*}{f_S(\boldsymbol{x}) - f_T(\boldsymbol{x})}] - \frac{1}{2}\mathbb{E}_{\boldsymbol{x} \sim \mathcal{D}_S}[\@ifstar{\oldabs}{\oldabs*}{f_S(\boldsymbol{x}) - f_T(\boldsymbol{x})}] \\
&= \epsilon_{S}(h, f_S) + \epsilon_{S}(h, f_U) + \epsilon_{T}(h, f_U) + \frac{1}{2}\epsilon_{T}(f_S, f_T) - \frac{1}{2}\epsilon_{S}(f_S, f_T) \\
&\leq \epsilon_{S}(h, f_S) + \epsilon_{S}(h, f_U) + \epsilon_{T}(h, f_U) + \frac{1}{2}\@ifstar{\oldabs}{\oldabs*}{\epsilon_{T}(f_S, f_T) - \epsilon_{S}(f_S, f_T)} \\
&\leq \epsilon_{S}(h, f_S) + \epsilon_{S}(h, f_U) + \epsilon_{T}(h, f_U) +
\frac{1}{4}d_{\mathcal{H}\Delta\mathcal{H}}(\mathcal{D}_S, \mathcal{D}_T) \\
&= \epsilon_{S}(h, f_S) + \frac{1}{4}d_{\mathcal{H}\Delta\mathcal{H}}(\mathcal{D}_S, \mathcal{D}_T) \\
&\phantom{--------}+ \int \phi_S(\boldsymbol{x}) \@ifstar{\oldabs}{\oldabs*}{h(\boldsymbol{x}) - f_U(\boldsymbol{x})} \mathrm{d}\boldsymbol{x} + \int \phi_T(\boldsymbol{x}) \@ifstar{\oldabs}{\oldabs*}{h(\boldsymbol{x}) - f_U(\boldsymbol{x})} \mathrm{d}\boldsymbol{x} \\
&= \epsilon_{S}(h, f_S) + \frac{1}{4}d_{\mathcal{H}\Delta\mathcal{H}}(\mathcal{D}_S, \mathcal{D}_T) + 2 \int \frac{1}{2}(\phi_S(\boldsymbol{x}) + \phi_T(\boldsymbol{x})) \@ifstar{\oldabs}{\oldabs*}{h(\boldsymbol{x}) - f_U(\boldsymbol{x})} \mathrm{d}\boldsymbol{x} \\
&= \epsilon_{S}(h, f_S) + \frac{1}{4}d_{\mathcal{H}\Delta\mathcal{H}}(\mathcal{D}_S, \mathcal{D}_T) + 2 \int \phi_U(\boldsymbol{x}) \@ifstar{\oldabs}{\oldabs*}{h(\boldsymbol{x}) - f_U(\boldsymbol{x})} \mathrm{d}\boldsymbol{x} \\
&= \epsilon_{S}(h, f_S) + \frac{1}{4}d_{\mathcal{H}\Delta\mathcal{H}}(\mathcal{D}_S, \mathcal{D}_T) + 2 \epsilon_{U}(h, f_U).
\end{split}
\]
\end{proof}
\pseudo*
\begin{proof}
By Lemma~\ref{triangle_inequality}, the following inequality holds.
\[
\epsilon_{T}(h, f_T) \leq \epsilon_{T}(h, f_{\hat{T}}) + \epsilon_{T}(f_T, f_{\hat{T}}).
\]
Meanwhile, using the same process in the proof of Theorem~\ref{alternative_theorem}, we know that
\[\epsilon_{T}(h, f_{\hat{T}}) \leq \epsilon_{S}(h, f_S) + \frac{1}{4}d_{\mathcal{H}\Delta\mathcal{H}}(\mathcal{D}_S, \mathcal{D}_T) + 2 \epsilon_{U}(h, f_{\hat{U}}).\]
Combining the above two inequalities yields the proof.
\end{proof}
\section{Generalization to multiclass classification}
Here, we introduce how the proposed theoretical background can be generalized to a multiclass classification problem and explain why degenerate solutions can be avoided from an information-theoretic perspective.
The generalized Jensen-Shannon (JS) divergence is defined as:
\begin{definition} [\cite{lin1991divergence}]
Let $\mathcal{D}_1, \mathcal{D}_2, \cdots, \mathcal{D}_n$ be n probability distributions with weights $\pi_1, \pi_2, \cdots, \pi_n$, respectively, and let $Z_1, Z_2, \cdots, Z_n$ be random variables with distributions $\mathcal{D}_1, \mathcal{D}_2, \cdots, \mathcal{D}_n$, respectively.
Then, the generalized JS divergence is defined as:
\[
D_{\mathrm{JS}}^\pi (\mathcal{D}_1, \mathcal{D}_2, \cdots, \mathcal{D}_n) = H (Z) - \sum_{i=1}^n \pi_i H(Z_i),
\]
where $\pi$ is $(\pi_1, \pi_2, \cdots, \pi_n)$ and $Z$ is a random variable with the mixture distribution of $\mathcal{D}_1, \mathcal{D}_2, \cdots, \mathcal{D}_n$ with weights $\pi_1, \pi_2, \cdots, \pi_n$, respectively.
\end{definition}
The generalized JS divergence measures the overall difference among a finite number of probability distributions.
Notably, for a fixed $\pi$, the Bayes probability of error~\cite{hellman1970probability} is minimized if the generalized JS divergence is maximized~\cite{lin1991divergence}.
With this divergence, we can generalize our objective to learn discriminative features in the representation space, $\mathcal{Z}$, as follows.
\begin{equation}
\max_{\theta_g} D_{\mathrm{JS}}^\pi(\mathcal{D}^{\mathcal{Z}}_{U|0}, \mathcal{D}^{\mathcal{Z}}_{U|1}, \cdots, \mathcal{D}^{\mathcal{Z}}_{U|C-1}),
\end{equation}
where $\pi$ denotes the marginal label distribution and $C$ denotes the number of classes.
From the definition of the generalized JS divergence, we know that
\begin{equation}
\label{general_js_and_mi}
\begin{split}
D_{\mathrm{JS}}^\pi(\mathcal{D}^{\mathcal{Z}}_{U|0}, \mathcal{D}^{\mathcal{Z}}_{U|1}, \cdots, \mathcal{D}^{\mathcal{Z}}_{U|C-1})
&= H (\boldsymbol{Z}_{U|Y}) - \sum_{y=1}^n \pi_y H(\boldsymbol{Z}_{U|y}) \\
&= H (\boldsymbol{Z}_{U|Y}) - \sum_{y=1}^n P(Y=y) H(\boldsymbol{Z}_{U|Y} | Y=y) \\
&= H (\boldsymbol{Z}_{U|Y}) - H (\boldsymbol{Z}_{U|Y} | Y) \\
&= I (Y;\boldsymbol{Z}_{U|Y}).
\end{split}
\end{equation}
Therefore, we can transform our objective as follows:
\begin{equation}
\max_{\theta_g} I(Y;\boldsymbol{Z}_{U|Y}).
\end{equation}
With the same theoretical framework introduced in the main manuscript, we can optimize this objective with the InfoNCE loss.
\paragraph{Avoiding degenerate solutions}
Algorithms that learn discriminative representations by alternating pseudo-labeling and updating the parameters of the network are susceptible to trivial solutions~\cite{caron2018deep}, referred to as degenerate solutions.
For example, if the majority of samples are assigned to a few clusters, it is easy to discriminate between features, but this is unfavorable for downstream tasks.
The proposed approach can avoid the tendency towards degenerate solutions since the method maximizes the mutual information (MI) between a feature and its label.
From Equation~\ref{general_js_and_mi}, we can observe that maximizing the MI, $I (Y;\boldsymbol{Z}_{U|Y})$, trades off maximizing the entropy, $H (\boldsymbol{Z}_{U|Y})$, and minimizing the conditional entropy, $H (\boldsymbol{Z}_{U|Y} | Y)$.
Only minimizing the conditional entropy can be vulnerable to the degenerate solutions, but the objective also includes the entropy maximization, which cannot be achieved in the degenerate solutions.
Therefore, the objective naturally balances discriminative representation learning with dispersed features and avoids the degenerate solutions.
\section{More details about the data processing inequality}
Here, we provide the formal derivation of $I(\boldsymbol{Z}_{U|Y}^{(1)}; \boldsymbol{Z}_{U|Y}^{(2)}) \leq I(Y;\boldsymbol{Z}_{U|Y}^{(1)}, \boldsymbol{Z}_{U|Y}^{(2)})$, presented in the main manuscript, using the \textit{data processing inequality}.
For a given $Y$, we sample two different data, $\boldsymbol{X}_{U|Y}^{(1)}$ and $\boldsymbol{X}_{U|Y}^{(2)}$, from the same conditional distribution, $\mathcal{D}^{\mathcal{X}}_{U|Y}$.
Then, we obtain $\boldsymbol{Z}_{U|Y}^{(1)}$ and $\boldsymbol{Z}_{U|Y}^{(2)}$ from $\boldsymbol{X}_{U|Y}^{(1)}$ and $\boldsymbol{X}_{U|Y}^{(2)}$, respectively, through the feature transformation, $g$.
Therefore, $Y$, $\boldsymbol{X}_{U|Y}^{(1)}$, $\boldsymbol{X}_{U|Y}^{(2)}$, $\boldsymbol{Z}_{U|Y}^{(1)}$, and $\boldsymbol{Z}_{U|Y}^{(2)}$ satisfy the Markov relation:
\begin{equation}
\boldsymbol{Z}_{U|Y}^{(1)} \leftarrow \boldsymbol{X}_{U|Y}^{(1)} \leftarrow Y \rightarrow \boldsymbol{X}_{U|Y}^{(2)} \rightarrow \boldsymbol{Z}_{U|Y}^{(2)},
\end{equation}
and this is Markov equivalent to
\begin{equation}
\boldsymbol{Z}_{U|Y}^{(1)} \rightarrow \boldsymbol{X}_{U|Y}^{(1)} \rightarrow Y \rightarrow \boldsymbol{X}_{U|Y}^{(2)} \rightarrow \boldsymbol{Z}_{U|Y}^{(2)}.
\end{equation}
By the data processing inequality, we know that
\begin{equation}
I(\boldsymbol{Z}_{U|Y}^{(1)}; \boldsymbol{Z}_{U|Y}^{(2)}) \leq I(Y; \boldsymbol{Z}_{U|Y}^{(1)}).
\end{equation}
Meanwhile, we can observe that the following Markov relation holds.
\begin{equation}
Y \rightarrow (\boldsymbol{X}_{U|Y}^{(1)}, \boldsymbol{X}_{U|Y}^{(2)}) \rightarrow (\boldsymbol{Z}_{U|Y}^{(1)}, \boldsymbol{Z}_{U|Y}^{(2)}) \rightarrow \boldsymbol{Z}_{U|Y}^{(1)}.
\end{equation}
Therefore, by the data processing inequality, we have
\begin{equation}
I(Y; \boldsymbol{Z}_{U|Y}^{(1)}) \leq I(Y; (\boldsymbol{Z}_{U|Y}^{(1)}, \boldsymbol{Z}_{U|Y}^{(2)})).
\end{equation}
Combining the above two inequalities yields the desired derivation.
\section{Pseudo-code}
\begin{algorithm}[H]
\SetAlgoLined
\SetKwInOut{Input}{Input}
\SetKwInOut{Output}{Output}
\Input{Labeled source data from $\mathcal{D}_S$ and unlabeled target data from $\mathcal{D}_T$.}
Initialize encoders $g_q$ and $g_k$; classification head $h$; projection heads $l_q$ and $l_k$; and a queue of K keys\;
\While{iteration < max\_iteration}{
Cluster the target data using spherical K-means\;
Split them into a certain dataset with pseudo-labels and an uncertain dataset\;
Rearrange the source and certain target datasets to obtain uniform label distributions\;
\For{$i \leftarrow 1$ \KwTo iterations\_per\_epoch}{
Sample mini-batches of the source data $(\boldsymbol{x}_s, y_s)$, certain target data $(\boldsymbol{x}_{tc}, \hat{y}_{tc})$, and uncertain target data $(\boldsymbol{x}_{tu})$\;
$\boldsymbol{x}_s^q = \mathrm{pre}\text{-}\mathrm{process}(\boldsymbol{x}_s)$,
$\boldsymbol{x}_s^k = \mathrm{pre}\text{-}\mathrm{process}(\boldsymbol{x}_s)$\;
$\boldsymbol{x}_{tc}^q = \mathrm{pre}\text{-}\mathrm{process}(\boldsymbol{x}_{tc})$,
$\boldsymbol{x}_{tc}^k = \mathrm{pre}\text{-}\mathrm{process}(\boldsymbol{x}_{tc})$,
$\boldsymbol{x}_{tu} = \mathrm{pre}\text{-}\mathrm{process}(\boldsymbol{x}_{tu})$\;
$\boldsymbol{z}_s^q = g_q(\boldsymbol{x}_s^q)$, $\boldsymbol{z}_s^k = g_k(\boldsymbol{x}_s^k)$\;
Compute $\mathcal{L}_\mathrm{s}$ on $(h(\boldsymbol{z}_s^q), y_s)$ using Equation (5)\;
$\boldsymbol{w}_s^q = l_q(\boldsymbol{z}_s^q)$,
$\boldsymbol{w}_s^k = l_k(\boldsymbol{z}_s^k)$\;
$\boldsymbol{w}_{tc}^q = l_q(g_q(\boldsymbol{x}_{tc}^q))$,
$\boldsymbol{w}_{tc}^k = l_k(g_k(\boldsymbol{x}_{tc}^k))$\;
Forward the uncertain target data to train the batch normalization layers, $g_q(\boldsymbol{x}_{tu})$\;
Merge $\boldsymbol{w}_s^q$ and $\boldsymbol{w}_{tc}^q$ to obtain $\boldsymbol{w}_u^q$,
and merge $\boldsymbol{w}_s^k$ and $\boldsymbol{w}_{tc}^k$ to obtain $\boldsymbol{w}_u^k$\;
$\mathrm{enqueue}(\mathrm{queue}, \boldsymbol{w}_u^k)$\;
$\mathrm{dequeue}(\mathrm{queue})$\;
Compute $\mathcal{L}_\mathrm{c}$ on $(\boldsymbol{w}_u^q, \mathrm{queue})$ using Equation (4)\;
Update the query network parameters, $\theta_q$\, with SGD\;
Momentum update the key network parameters, $\theta_k$\;
}
}
\caption{Training procedure for JCL}
\end{algorithm}
\section{Selected hyper-parameters}
We tuned the weight hyper-parameter, $\gamma$, and distance threshold, $d$, for filtering the certain target data.
The weight hyper-parameter, $\gamma$, was searched within $\{0.1, 0.5, 1.0, 2.0\}$ and $\{0.2, 0.3, 0.4, 0.5\}$ for ImageCLEF-DA and VisDA-2017 datasets, respectively.
The distance threshold hyper-parameter, $d$, was searched within $\{0.05, 0.1, 1.0\}$.
The selected hyper-parameters for each task are listed in Table~\ref{selected_hyper_parameters}.
\input{Tables/table_hyper_parameter}
\section{Additional implementation details}
The temperature parameter, $\tau$, for the critic function was fixed to 0.05.
For ImageCLEF-DA and VisDA-2017 datasets, the queue size, considering the dataset sizes, was set to 4,096 and 32,768, respectively, and the momentum coefficient, m, of the momentum encoder to 0.9 and 0.99, respectively.
For the metric measuring the distances in the feature space, $\mathcal{Z}$, cosine dissimilarity was applied.
At the end of the encoders, we added L2 normalization layers.
Unlike other contrastive learning methods, we did not utilize additional data augmentation for fair comparison with domain adaptation baselines;
only random crop and horizontal flip were used.
We empirically found that it is beneficial to forward pass the uncertain target data to train the batch normalization layers.
For computing infrastructure, we used a GeForce RTX 2080 Ti GPU for all experiments.
The total iterations for the ImageCLEF-DA and VisDA-2017 experiments were 20,000 and 50,000, respectively, and they took 4 h and 15 h, respectively, on an average.
\section{VisDA-2017 full results}
\input{Tables/table_visda_result}
\section{Introduction}
\label{sec:introduction}
\input{1_Introduction}
\section{Preliminary}
\label{sec:preliminary}
\input{2_Preliminary}
\section{Related work}
\label{sec:related_work}
\input{3_Related_work}
\section{Method}
\label{sec:method}
\input{4_Method}
\section{Experiments}
\label{sec:experiments}
\input{5_Experiments}
\section{Conclusion}
\label{sec:conclusion}
\input{6_Conclusion}
\section{Broader impact}
\label{sec:broader_impact}
\input{7_Broader_impact}
\medskip
\begin{small}
\bibliographystyle{abbrvnat}
| {'timestamp': '2020-06-19T02:09:40', 'yymm': '2006', 'arxiv_id': '2006.10297', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10297'} | arxiv |
\section{Introduction}
In the planar 2-center problem we are given a set $S$ of $n$ points in the
plane and want to find two congruent disks of the smallest radius covering the
points. This is a special case (with 2 supply points) of the facility location problem in
which given a set of demands in $\mathbb{R}^d$ we are to find a set of
supply points in $\mathbb{R}^d$ minimizing the maximum distance from a
demand point to its closest supply point.
There has been a fair amount of work on the planar 2-center problem in
the 1990s. Hershberger and Suri~\cite{HERSHBERGER1996453} considered
a decision version of the problem: given a radius $r$, determine if
$S$ can be covered by two disks of radius $r$. They gave an
$O(n^2\log n)$-time algorithm for the problem. This was improved
slightly by Hershberger to $O(n^2)$ time~\cite{HERSHBERGER199323}.
By combining this result with the parametric-search paradigm of
Megiddo~\cite{Megiddo1983}, Agarwal and Sharir~\cite{Agarwal1994} gave
an $O(n^2\log^3 n)$-time algorithm for the planar 2-center problem. A few
other results include the expander-based approach by Katz and
Sharir~\cite{Katz1993} avoiding the parametric search, a randomized
algorithm with expected $O(n^2\log^2n\log\log n)$ time by
Eppstein~\cite{Eppstein1992}, and a deterministic $O(n^2\log n)$-time
algorithm by Jaromczyk and Kowaluk~\cite{Jaromczyk1994} using new
geometric insights.
In 1997, Sharir made a
substantial breakthrough by
dividing the problem into cases, depending on the optimal radius $r^*$ and
the distance $d$
between the optimal centers. He presented a $O(n\log^9 n)$-time algorithm
by combining an $O(n\log^2 n)$-time algorithm
deciding for a given radius $r$ if the points can be covered by two
disks of radius $r$ and parametric search.
Later, Eppstein~\cite{Eppstein1997} considered the case
that
$d\geq cr^*$ for any positive constant $c$
and presented an $O(n\log^2 n)$-time algorithm.
For the case that the distance between the two optimal centers is
$cr^*$ for a fixed constant $c\in [0,2)$,
the overlap of the optimal disks is a constant
fraction of the disk area. It is known that one can generate a constant number of
points in linear time such that at least one of them lies in the overlap of the optimal
disks~\cite{Sharir1997,Eppstein1997}.
Thus, the problem reduces to the following restricted problem.
See Figure~\ref{fig:restricted} for an illustration.
\vspace{-.5em}
\begin{quote}
\textbf{The restricted 2-center problem.} Given a set $S$ of $n$ points
and a point $o$ in the plane, find two congruent disks $D_1,D_2$ of
the smallest radius such that $o\in D_1\cap D_2$ and
$S$ is covered by $D_1$ and $D_2$.
\end{quote}
\vspace{-.5em}
\begin{figure}[tb]
\centering
\includegraphics[width=.3\textwidth]{restricted.pdf}
\caption{The restricted 2-center problem: two congruent disks of the smallest radius enclosing the points overlap.}
\label{fig:restricted}
\end{figure}
\noindent
The restricted 2-center problem can be solved by Sharir's algorithm in
$O(n\log^9 n)$ time~\cite{Sharir1997}.
Eppstein gave a randomized algorithm which solves the restricted
2-center problem in $O(n\log n\log\log n)$ expected
time~\cite{Eppstein1997}.
In 1999, Chan~\cite{CHAN1999189} made an improvement to
Eppstein's algorithm by showing that the restricted 2-center problem
can be solved in $O(n\log n)$ time with high probability.
He also presented a deterministic
$O(n\log^2 n\log^2\log n)$-time algorithm for the restricted 2-center problem
by using parametric search. Together with the $O(n\log^2 n)$-time algorithm for the
well-separated case by Eppstein~\cite{Eppstein1997}, the planar
2-center problem is solved in $O(n\log^2 n)$ time with high
probability, or in $O(n\log^2 n\log^2\log n)$ deterministic time.
Since then there was no improvement over 20 years until
Wang~\cite{WANG2020} very recently gave an $O(n\log n\log\log n)$-time
deterministic algorithm for the restricted 2-center problem, improving
on Chan's method by a $\log n\log\log n$ factor. Combining Eppstein's
$O(n\log^2 n)$-time algorithm for the well-separated case, the planar
2-center problem can be solved in $O(n\log^2 n)$ time
deterministically.
The improvement is from a new $O(n)$-time sequential decision algorithm,
precomputing the intersections of disks that are frequently used
in the parallel algorithms, and a dynamic data structure called \emph{the circular hull}
that maintains the intersection of
the disks containing a fixed set of points. See the right figure in~Figure~\ref{fig:intersection-chull}.
Eppstein showed that
any deterministic algorithm for the two-center problem requires
$\Omega(n\log n)$ time in the algebraic decision tree model of computation
by reduction from max gap problem~\cite{Eppstein1997}. So there is
some gap between the best known running time and the lower bound.
\subsection{Our results}
We consider the restricted 2-center problem and show
that the problem can be solved in $O(n\log n)$ time
deterministically. This improves the previous best
$O(n\log n\log\log n)$ bound by Wang by a $\log\log n$
factor.
Our algorithm follows the framework by Wang~\cite{WANG2020} (and thus
by Chan~\cite{CHAN1999189}) and uses the $O(n)$-time sequential
decision algorithm by Wang. But for the parallel algorithm,
we use a different approach of running a decision algorithm in $O(\log n)$
parallel steps using $O(n)$ processors after $O(n \log n)$-time preprocessing.
By following Wang's approach, our algorithm divides the points into a certain number of groups,
computes for each group the common intersection of the disks centered at
some points in the group and applies binary search on the intervals of indices independently.
Wang used $O(\log n)$ processors to compute the intersections in $O(\log n \log \log n)$ time.
In our algorithm, we increase the number of processors to $O(\log^2 n)$ so that
the time complexity to compute the intersections decreases to $O(\log n)$.
Another difference to the approach by Wang is that
for each group, we additionally construct a data structure that
determines the emptiness of intersections with respect to some common intersection.
This can be done in $O(\log n)$ time using $O(\log^6 n)$ processors.
We use this data structure in binary search steps.
It takes $O(\log^3\log n)$ time to determine if the common intersection is empty or not,
which improves the $O(\log n)$-time result by Wang.
Thus our decision algorithm takes $O(\log n)$ time using $O(n)$ processors,
after $O(n\log n)$-time preprocessing. We apply Cole's parametric
search technique~\cite{Cole-parametric} to compute $r^*$ in $O((T_S+Q)(T_P+ \log Q))$ time,
where $T_S=O(n)$ is sequential decision time,
$T_P=O(\log n)$ is parallel decision time and $Q=O(n)$
is number of processor for parallel decision algorithm.
Thus the optimal radius $r^*$ for
the restricted 2-center can be computed in $O(n\log n)$ time.
We also consider the 2-center problem for the special case that the input points
are in convex position. Kim and Shin~\cite{kim2000} considered a variant
of this problem for convex polygons:
Given a convex polygon, find two smallest congruent
disks whose union contains the polygon.
They presented an $O(n\log^2 n)$-time algorithm for a convex $n$-gon
and
claimed that the 2-center problem for $n$ points in
convex position can be solved similarly in the same time. But Tan~\cite{Tan2017}
pointed out a mistake in the time analysis, and presented an $O(n\log^2 n)$-time algorithm for the problem.
But Wang~\cite{WANG2020} showed a counterexample to the algorithm by Tan,
and gave an $O(n\log n\log\log n)$-time algorithm for this problem~\cite{WANG2020}.
We present a deterministic $O(n\log n)$-time algorithm
that computes the optimal 2-center for the points in convex position.
We first spend $O(n\log n)$ time
to find a point contained in the overlap of the two optimal disks
and a line separating the input points into two subsets.
Then we apply our algorithm
for the restricted 2-center problem to find an optimal pair of disks
covering the input points.
\section{Preliminaries}
For a point set $X$ in the plane, we denote by $I_r(X)$ the common
intersection of the disks with radius $r$, one centered at each point in
$X$.
The circular hull $\alpha_r(X)$ of $X$
is the common intersection of all disks of radius $r$ containing $X$.
See Figure~\ref{fig:intersection-chull} for an illustration.
\begin{figure}[tb]
\centering
\includegraphics[scale=0.9]{intersection-chull.pdf}
\caption{Five points (black dots) in $X$. (a) The intersection $I_r(X)$. (b) The circular hull $\alpha_r(X)$.}
\label{fig:intersection-chull}
\end{figure}
Clearly, both
$I_r(X)$ and $\alpha_r(X)$ are convex. Observe that $I_r(X)$ and
$\alpha_r(X)$ are dual to each other in the sense that every arc of
$I_r(X)$ is on the circle of radius $r$ centered at a vertex of
$\alpha_r(X)$ and every arc of $\alpha_r(X)$ is on the circle of
radius $r$ centered at a vertex of $I_r(X)$. We may simply use $I(X)$
and $\alpha(X)$ instead of $I_r(X)$ and $\alpha_r(X)$ if they are
understood from the context.
For a compact set $C$ in the plane, we use $\partial C$ to denote
the boundary of $C$. For any two points $p,q\in\partial C$, we use $C[p,q]$
to denote the part of the boundary
of $C$ from $p$ to $q$ in counterclockwise order.
Let $S$ be a set of $n$ points in the plane, and let $D^*_1$ and
$D^*_2$ be the two congruent disks of an optimal solution for the
restricted 2-center problem on $S$.
We can find in $O(n)$ time
a constant number of points such that at least one of them lies in
$D^*_1\cap D^*_2$. We use $o$ to denote a point in $D^*_1\cap D^*_2$.
Without loss of generality, we assume that $o$ is at the origin of the
coordinate system.
Let $S^+$ denote the set of points of $S$ that lie above the $x$-axis, and
$S^-$ denote $S\setminus S^+$. For ease of description, we assume that
both $S^+$ and $S^-$ have $n$ points. Let
$s^+_1,s^+_2,\ldots, s^+_n$ be the points of $S^+$ sorted around
$o$ in counterclockwise order and $s^-_1,s^-_2,\ldots, s^-_n$ be the
points of $S^-$ sorted around $o$ in counterclockwise order such
that they appear in order from $s^+_1$ to $s^+_n$ and then $s^-_1$ to
$s^-_n$ around $o$ in counterclockwise order.
For any
$1\leq i\leq j\leq n$, let $S^+[i,j]=\{s^+_i, s^+_{i+1},\ldots, s^+_j\}$ and
$S^-[i,j]=\{s^-_i, s^-_{i+1},\ldots, s^-_j\}$.
There are two rays
$\mu_1, \mu_2$ emanating from $o$ that separate the points of $S$ into two
subsets, each covered by one optimal disk. See Figure~\ref{fig:restricted}.
Since such two rays
are always separated by the $x$-axis or the $y$-axis~\cite{CHAN1999189},
we simply assume that
$\mu_1$ goes upward and $\mu_2$ goes downward.
For two indices $i,j\in[0,n]$, let $A[i,j]$ denote the radius of the smallest disk enclosing
$S^+[i+1,n] \cup S^-[1,j]$, and let $B[i,j]$ denote the radius of the smallest
disk enclosing $S^+[1,i] \cup S^-[j+1,n]$. For convenience, we let
$S^+[n+1,n]=S^+[1,0]=S^-[n+1,n]=S^-[1,0]=\emptyset$.
For two points $p$ and $q$ in the plane, we use
$\overrightarrow{pq}$ to denote a ray emanating from $p$ going towards $q$.
\section{Improved algorithm for the restricted 2-center problem}
\label{sec:ours}
Our algorithm follows the framework by Wang~\cite{WANG2020} (and thus
by Chan~\cite{CHAN1999189}), and uses the $O(n)$-time sequential
decision algorithm (after $O(n\log n)$-time preprocessing) by Wang.
But for the parallel algorithm,
we use a different approach of running a decision algorithm in $O(\log n)$
parallel steps using $O(n)$ processors after $O(n \log n)$-time preprocessing.
Let $r_{ij} = \max (A[i,j],B[i,j])$ and
$r^*_{i}= \min_{0 \leq j \leq n} r_{ij}$.
Then
$r^*=\min_{0 \leq i \leq n} r^*_{i}$, where $r^*$ is
the optimal radius for the restricted 2-center problem on $S$.
Let $R=(r_{ij})$ be the $n\times n$ matrix whose $(i,j)$-entry is $r_{ij}$.
Let $j(i)=\arg_j\min r_{ij}$.
Observe that $R$ is \emph{monotone} by the definition of $r_{ij}$, that is,
for any two indices $i_1> i_2$ we have $j(i_1)\geq j(i_2)$.
We search for $r^*$ among the entries in $R$.
We can determine whether $r^*<r $ by checking if there is some $i$ with $r^*_i < r$.
Observe that for a fixed $i$, $A[i,j]$ increases and $B[i,j]$ decreases as $j$ increases.
Therefore, $r_{ij}$ decreases and then increases as $j$ increases.
By this property we can apply binary search in determining for a given $r$ if $r^*_i< r$ or not.
However, it takes too much time for our purpose to apply binary search directly
on the entries of $R$.
Instead, we restrict binary search to certain elements of $R$ using the monotone property of $R$,
and construct a few data structures to speed up the decision procedure as follows.
The algorithm consists of three phases.
In Phase 1, our algorithm constructs a data structure on $S$ such that
given a query consisting of $r>0$ and an interval $[i,j]$ it returns
$I_r(S^+[i,j])$ or $I_r(S^-[i,j])$.
It also reduces the search space
in $R$ by evaluating on $r_{ij}$ at every
$(\log^6 n)$-th $j$ values from $j=1$. This gives us a set of $O(n/\log^6 n)$
disjoint submatrices of $R$ with height $\log^6 n$. Then it divides
each of these submatrices further such that its width is at most $\log^6 n$.
So there are $O(n/\log^6 n)$ groups. See Figure~\ref{fig:monotone}.
In Phase 2, given $r>0$, our algorithm constructs
a data structure for each submatrix obtained from Phase 1 such that
given two indices $i$ and $j$ with $r_{ij}$ in the submatrix it determines whether
$I_r(S^+[i,n])\cap I_r(S^-[1,j])=\emptyset$ or not.
In Phase 3, our algorithm applies binary search to find a radius smaller than
$r$ among the elements in each submatrix using the intersection emptiness
queries on the data structure
in Phase 2.
\subsection{Phase 1: Preprocessing}
In Phase 1, we construct a data structure on $S$ and reduce the search space in $R$.
\subsubsection{Data structure}
In this section, $r$ is a certain radius such that $I_r(\cdot)$ and $I_{r^*}(\cdot)$
have the same combinatorial structure.
We build a balanced BST(binary search tree) on $S$ as follows.
Let $\bbst{S}$ denote a balanced BST on an ordered point set $S$.
Each leaf node corresponds to an ordered point in $S$ in order, from left to right.
Each nonleaf node corresponds to the points of $S$ corresponded to by
the leaf nodes of the subtree rooted at the node.
For a node $w$, let $S_w$ denote the set of points corresponding to $w$.
See Figure~\ref{fig:canonical}(a).
Observe that any interval $[i,j]$ of points of $S$ can be presented by
$O(\log n)$ nodes and they can be found in $O(\log n)$ time
as a range can be represented by $O(\log n)$ subtrees
in the 1-dimensional range tree on $S$.
We call these nodes \emph{the canonical nodes} of the interval in $\bbst{S}$.
For instance, the internal node corresponding to $\{p_1,p_2\}$ and
the leaf node corresponding to $p_3$
are the canonical nodes of interval $[1,3]$ in Figure~\ref{fig:canonical}(a).
At each nodes $w$ in $\bbst{S}$, we store $I_r(S_w)$ as an additional information.
The boundary of $I_r(S_w)$ is represented by a balanced binary search tree
and stored at $w$.
The balanced binary search trees for the nodes in $\bbst{S}$ are
computed in bottom-up manner in $O(n\log n)$ total time.
See Figure~\ref{fig:canonical}.
Thus, $\bbst{S}$ can be constructed in $O(n\log n)$ time.
\begin{figure}[ht]
\centering
\includegraphics[width=.9\textwidth]{canonical-subset.pdf}
\caption{(a) The balanced binary search tree $\bbst{S}$ for $S=\{p_1,p_2,p_3,p_4\}$. (b) The boundary of $I_r(S_w)$ for a node $w$ in the tree in (a) is represented by
a balanced binary search tree and stored at $w$.}
\label{fig:canonical}
\end{figure}
The following two technical lemmas can be shown by lemmas
in Wang's paper~\cite{WANG2020} as $I_r(S_w)$ is the dual of the circular hull $\alpha_r(S_w)$.
\begin{lemma}[Lemma~$6$ in~\cite{WANG2020}]
\label{lem:TS}
$\bbst{S}$ can be constructed in $O(n\log n)$ time such that the combinatorial structure of $I_r(S_w)$ is same as $I_{r^*}(S_w)$ for any $w \in \bbst{S}$.
\end{lemma}
\begin{lemma}[Lemma~$5$ in~\cite{WANG2020}]\label{lem:tangent}
Let $L$ and $R$ be the point sets in the plane such that $L$ and $R$
are separated by a line and the arcs of $I_r(L)$ and $I_r(R)$ are stored
in a data structure supporting binary search. One can
do the following operation in $O(\log(|L|+|R|))$ time: determine
whether $I_r(L) \cap I_r(R)=\emptyset$ or not; if
$I_r(L) \cap I_r(R)\neq\emptyset$, either determine whether
$I_r(L) \subseteq I_r(R)$ or $I_r(R) \subseteq I_r(L)$,
or find the two intersection points of $\partial I_r(L)$ and
$\partial I_r(R)$.
\end{lemma}
\subsubsection{Speeding up intersection queries}
Given a query range $[i,j]$, we can compute
the common intersection $I(S^+[i,j])$ for points in $S^+[i,j]$
by computing the common intersection of $I(S_w)$'s
for all canonical nodes $w$ of $S^+[i,j]$ in $\bbst{S^+}$
by Lemma~\ref{lem:tangent}, and by splitting and gluing
the binary search trees stored in the canonical nodes.
Wang showed a parallel algorithm for this process
using $O(\log n)$ processors and running in $O(\log n \log \log n)$ time.
Wang's algorithm handles gluing two binary trees at a processor.
We can improve the query time for our purpose by using
more processors, and by splitting and gluing
multiple (more than two) binary trees simultaneously to compute
the boundary arcs of common intersections
using the order of the boundary arcs.
Our algorithm computes the part of $\partial I_i$ that appears on the boundary
of the common intersection.
To compute the boundary part of $I_i$ efficiently, we represent the intersection
of two regions in a number of intervals on its boundary.
\begin{figure}[ht]
\centering
\includegraphics[width=.6\textwidth]{boundary-partition.pdf}
\caption{$I(L) \cap I(R)$ consists of two boundary parts, $f(L,R)$ and $f(R,L)$.}
\label{fig:f_function}
\end{figure}
For a set of points in the plane,
let $L$ and $R$ be the subsets of the points separated by a line.
Then $\partial I(L)$ and $\partial I(R)$ intersect as most twice.
Thus, we can represent $I(L)\cap I(R)$ by two boundary parts,
one from $\partial I(L)$ and one from $\partial I(R)$, as follows.
Let $f(L,R)$ and $f(R,L)$ denote the parts of $\partial I(L)$ and $\partial I(R)$,
respectively, such that $f(L,R)$ and $f(R,L)$ together form the boundary of
$I(L)\cap I(R)$. We can represent $f(L,R)$ by the two intersection points
$\partial I(L)\cap \partial I(R)$ and the counterclockwise direction along
$\partial I(L)$.
For two intersection points $s,e$ of $\partial I(L)\cap \partial I(R)$, we use
$f(L,R)=I(L)[s,e]$ if $s$ appears before $e$ on $\partial I(L)\cap \partial I(R)$
along $\partial I(L)$ in counterclockwise direction. See Figure~\ref{fig:f_function}.
For a family $\mathcal{W}$ of point sets, let $I(\mathcal{W})=I(\bigcup_{W\in\mathcal{W}} W)$
for ease of use.
The boundary $\partial I(\mathcal{W})$ consists of
$I(\mathcal{W}) \cap \partial I(W)$ for each subset $W \in \mathcal{W}$.
To compute $I(\mathcal{W}) \cap \partial I(W)$, we need following lemma.
We use $U^+(i,j)$ (and $U^-(i,j)$) to denote the set of the canonical nodes of
range $[i,j]$ for $\bbst{S^+}$ (and $\bbst{S^-}$).
\begin{lemma}\label{lem:intersection}
Let $X$ be a fixed point set and let $\mathcal{W}$ be a family of
point sets. If we have $f(X,W)$ for every $W \in \mathcal{W}$ and
a point $x \in I(X)$, there are at most $|\mathcal{W}|$ connected components of
$I(\mathcal{W})\cap \partial I(X)$, each of which can be represented by a connected part of $\partial I(X)$,
and we can compute them in $O(|\mathcal{W}| \log |\mathcal{W}|)$ time.
If $X=S_w$ for a node $w \in U^+(i,j)$ and $\mathcal{W}=\{S_{w'} \mid w' \in U^+(i,j)\}$,
there are at most two such connected components and we can compute them
in $O(|\mathcal{W}|)$ time .
\end{lemma}
\begin{proof}
For a set $W \in
\mathcal{W}$, consider $f(X,W)=I(X)[s,e]$. For a point $x\in I(X)$,
$I(X)[s,e]$ can be considered as an angle interval $[\theta_{s},\theta_{e}]$
with respect to $x$, where $\theta_s$ and
$\theta_e$ are the angles of $\overrightarrow{xs}$ and $\overrightarrow{xe}$.
(Note that the endpoints of $I(X)[s,e]$ can be represented as algebraic functions
of $r$ with constant degree for $r$.
For ease of description, we simply use the angles instead.)
By sorting the endpoints of the angle intervals, we can compute
$\bigcap_{W \in \mathcal{W}} f(X,W)$, which is $I(\mathcal{W})\cap \partial I(X)$.
However, there are only two such angle intervals if $X=S_w$ for a node
$w \in U^+(i,j)$ and $\mathcal{W}=\{S_{w'} \mid w' \in U^+(i,j)\}$,
and thus we can compute $I(\mathcal{W})\cap \partial I(X)$ in $O(|\mathcal{W}|)$ time
as follows.
Let $S_w=S^+[i',j']$, then $\mathcal{W}$ can be partitioned into three subfamilies
$\{S_w\}, \mathcal{W}_L=U^+(j'+1,j)$, and $\mathcal{W}_R=U^+(i,i'-1)$. Observe
that the subfamilies are separated by the two lines, both through the origin,
one through $p_{j'}$ and one through $p_{i'}$.
Let $A_L$ be the set of angle intervals from $f(X,W_L)$ for $W_L \in \mathcal{W}_L$ and
let $I_L$ be the common intersection of the angle intervals in $A_L$.
The common intersection of the angle intervals
of any subset of $A_L$ consists of at most one angle interval by Lemma~\ref{lem:tangent}, because
any set of $\mathcal{W}_L$ is separated from $S_w$ by a line.
Consider an angle interval $[\theta_s,\theta_e]$ of $A_L$. Then the intersection of
$[\theta_s,\theta_e]$ with every other angle interval in $A_L$ is connected.
Thus, we compute the common intersection $I_L$ of
the angle intervals of $A_L$ within $[\theta_s,\theta_e]$ in $O(|A_L|)$ time.
For the set of angle intervals from $f(X,W_R)$ for $W_R \in \mathcal{W}_R$,
we can compute the common intersection of those intervals in a similar way.
Thus there are at most two such connected components and we can compute
them in $O(|\mathcal{W}|)$ time.
\end{proof}
In the following, we abuse $I(i,j)$ to denote $I(S^+[i,j])$ for any two indices $i,j$ satisfying
$1\leq i\leq j\leq n$.
To merge the boundaries we need to know their appearing order in boundary of common intersection.
\begin{lemma}\label{lem:boundary}
The indices of the points corresponding to the arcs of $\partial I(i,j)$ are increasing and decreasing consecutively
at most once while traversing along $\partial I(i,j)$.
\end{lemma}
\begin{proof}
We use circular hulls $\alpha_r(\cdot)$ to prove the lemma.
Since $I_r(\cdot)$ and $\alpha_r(\cdot)$ are dual to each other,
the proof also holds for $I_r(\cdot)$.
We simply use $\alpha(\cdot)$ to denote $\alpha_r(\cdot)$.
For any two indices $i$ and $j$, we show that
the indices of the vertices that appear on the boundary of $\alpha(S^+[i,j])$ are increasing and decreasing consecutively at most once.
Consider the case that $\alpha(S^+[i,j])$ does not contain $o$.
Let $x_1$ and $x_2$ be the contact points
of the right and left tangent lines to $\alpha(S^+[i,j])$ from $o$.
For a point $p$ on the boundary of $\alpha(S^+[i,j])$, the angle between $\overrightarrow{op}$ and the $x$-axis
is increasing while moving along the boundary of $\alpha(S^+[i,j])$ from $x_1$ to $x_2$ in counterclockwise order.
Similarly, the angle between $\overrightarrow{op}$ and the $x$-axis is decreasing while moving
along the boundary of $\alpha(S^+[i,j])$ from $x_2$ to $x_1$ in counterclockwise order.
Thus, the indices of the vertices of the circular hull are increasing and decreasing at most once.
Now consider the case that $\alpha(S^+[i,j])$ contains $o$.
By the definitions of $o$ and $S^+$, there is no vertex of $\alpha(S^+[i,j])$ lying below the $x$-axis.
Thus, for a vertex $v$ of $\alpha(S^+[i,j])$, the angle between $\overrightarrow{ov}$ and the $x$-axis is
increasing while moving along the boundary of $\alpha(S^+[i,j])$ from $p_s$ to $p_t$ in counterclockwise,
where $s$ and $t$ are the smallest and largest indices of the vertices of $\alpha(S^+[i,j])$.
Since the order of the vertices on the boundary $\alpha(S^+[i,j])$ is the same as the order of the indices of points
corresponding to the arcs of $\partial I(i,j)$, the lemma holds.
\end{proof}
We construct $\bbst{S^+}$ (and $\bbst{S^-}$) in $O(n\log n)$ time using Lemma~\ref{lem:TS}.
Now, we have basic lemmas on queries to $\bbst{S^+}$ (and $\bbst{S^-}$).
Let $(r_1,r_2]$ be the range of radius $r$ for which $I_r(S_w)$ and $I_{r^*}(S_w)$ have the same
combinatorial structure for any $w\in\bbst{S^+}$.
\begin{lemma}\label{lem:query}
Once $\bbst{S^+}$ is constructed,
we can process the following queries in $O(\log n)$ time
using $O(\log^2 n)$
processors: given $r \in (r_1,r_2]$ and any pair $(i,j)$ of indices,
determine whether $I(i,j)=\emptyset$ or not, and if
$I(i,j)\neq\emptyset$, return the root of a balanced binary search
tree representing $I(i,j)$.
\end{lemma}
\begin{proof}
Observe that $\partial I(i,j)$ consists of parts of
$\partial I(S_w)$ for all canonical nodes $w \in U^+(i,j)$. For a fixed
$w \in U^+(i,j)$, we compute $I(i,j) \cap \partial I(S_w)$ by
taking $f(S_w,S_{w'})$ for every canonical node $w' \in U^+(i,j)$ and applying
Lemma~\ref{lem:intersection}.
For a fixed $w\in U^+(i,j)$, we can compute $f(S_w,S_{w'})$ for every $w'\in U^+(i,j)$
in $O(\log n)$ parallel steps using $O(\log n)$ processors.
By Lemma~\ref{lem:intersection},
there are at most two boundary parts representing $I(i,j) \cap \partial I(S_w)$, and we can
find them in $O(\log n)$ time using one processor.
For a part $I(S_w)[s,e]$, we construct a binary search tree for
$I(S_w)[s,e]$ using $I(S_w)$ stored at $w \in \bbst{S^+}$
and the path copying~\cite{drisco1989} in $O(\log n)$ time.
Since there are $O(\log n)$ nodes in $U^+(i,j)$, we can find
$O(\log n)$ binary search trees, at most two for each node,
in $O(\log n)$ parallel steps using $O(\log^2 n)$ processors. Observe that the
binary search trees for a point set $S_w$ represents $I(i,j) \cap \partial I(S_w)$.
Then we merge all these binary search trees
into a binary search tree representing $\partial I(i,j)$. By
Lemma~\ref{lem:boundary}, the indices of the points in $S^+[i,j]$ corresponding to the arcs of
$\partial I(i,j)$ are increasing and then decreasing consecutively at most once while traversing along $\partial I(i,j)$.
For any two distinct canonical nodes $w,w'$ of $U^+(i,j)$, we use $w<w'$
if the indices of the points in $S_w$ are smaller than the indices of the points in $S_{w'}$.
Since the canonical nodes of $U^+(i,j)$ can be ordered by their corresponding point sets,
the binary trees can also be ordered accordingly,
by following the orders of their corresponding canonical nodes.
Each canonical node $w$ has at most two parts of $I(i,j) \cap \partial I(S_w)$,
and the order between the binary search trees on the parts is decided by the order
of their corresponding canonical nodes
in $\bbst{S^+}$.
Following this order, we merge the $O(\log n)$ binary search trees
in $O(\log n)$ time.
Recall that there are at most two binary search trees $T, T'$ for each node $U^+(i,j)$,
which are at the same position in the order. Thus,
the merge process is done in two passes, one in the order and one in
reverse of the order, and $T$ is merged as a boundary part of $I(i,j)$ in one pass
and $T'$ is merged as a boundary part of $I(i,j)$ the other pass.
By repeating this process on the binary search trees in order,
we can construct $\partial I(i,j)$. Finally we
can return the root of the merged binary search tree representing
$I(i,j)$ in $O(\log n)$ time using $O(\log^2 n)$ processors.
\end{proof}
\subsubsection{Reducing the search space to submatrices}
Our algorithm reduces the set of candidates for $r^*$ from the elements
in the $n\times n$ matrix $R=(r_{ij}$) to the elements in $O(n/\log^6 n)$
disjoint submatrices of size $\log^6 n\times \log^6 n$ in $R$.
This is done by evaluating on $r_{ij}$ at every
$\log^6 n$-th $j$ values from $j=1$, which results in a set of $O(n/\log^6 n)$
disjoint submatrices of of $R$ with height $\log^6 n$.
Then we divide each of these submatrices further such that its width is at most $\log^6 n$.
See Figure~\ref{fig:monotone}.
Precisely, let $m=\lfloor n / \log^6 n \rfloor$, $j_t= t \times \lfloor n/m \rfloor$ for $t = 0,1, \ldots, m$.
For each $t \in [0,m]$, let $i_t$ be the largest index in $[0,n]$
satisfying $A[i_t,j_t] \geq B[i_t,j_t]$. Observe that
$i_0 \leq i_1\leq \ldots \leq i_m$. Each $i_t$ can be found in
$O(\log^7 n)$ time after $O(n\log n)$-time preprocessing.
Since there are $O(m)$ such $i_t$'s, we can compute them in
$O(n\log n)$ time~\cite{CHAN1999189}.
The algorithm determines whether $r_i^* \leq r$ or not, for all $i =0,1,\ldots, n$, as follows.
For each $i$, let $t$ be an index in $[0,m-1]$ satisfying $i_t < i \leq i_{t+1}$.
If $A[i,j_t] > r$, then the algorithm returns $r^*_i> r$. Otherwise,
it finds the largest index $j \in [j_t,j_{t+1}]$ satisfying $A[i,j] \leq r$, and returns $r_i^* \leq r$ if and only if $B[i,j] \leq r$. See Algorithm 2 of~\cite{WANG2020} and Theorem 4.2
of~\cite{CHAN1999189}.
Our algorithm divides the indices $i$ from 0 to $n$ into at most $2m$ groups.
For each $t=0,1,\ldots,m-1$, if $i_{t+1}-i_t \leq \log ^6 n$ , the algorithm forms a group of at most $\log^6 n$ indices. Otherwise it forms a group for every consecutive $\log^6 n$ indices up to $i_{t+1}$. Then there are at most $2m$ groups. Each group $G=[a,b]$ is contained in one of $[i_t,i_{t+1}]$. We identify group $G$ as $G(a,b,t)$. See Figure~\ref{fig:monotone}.
\begin{figure}[ht]
\centering
\includegraphics[width=\textwidth]{monotone-matrix.pdf}
\caption{(a) Matrix $R=(r_{ij})$. (b) Reducing the search space into $O(n/\log^6 n)$
submatrices of height $\log^6 n$ using the
monotone property, at every $(\log^6 n)$-th entries of index $j$. (c) Dividing each submatrix further
into one with width at most $\log^6 n$. A submatrix (a group of indices) $G(a,b,t)$ represents the
index ranges of $i$ from $a$ to $b$ and of $j$ from $j_t$ to $j_{t+1}$.}
\label{fig:monotone}
\end{figure}
For each group $G(a,b,t)$, we construct $\bbst{S^+[a,b]}$ and
$\bbst{S^-[j_t,j_{t+1}]}$, which will be used to construct a data structure for determining
the emptiness of intersections.
This can be done for all groups in $O(n\log n)$ time in total.
\subsection{Phase 2 - Group information}
Given a value $r>0$, we determine if $A[i,j] \leq r$ for a group $G(a,b,t)$
with $a \leq i \leq b$ and $j_t \leq j \leq j_{t+1}$.
Observe that the points of $S^+[b,n]$ and the points of $S^-[1,j_t]$ are used
commonly in the process. See Figure~\ref{fig:dividingsets}.
\begin{figure}[ht]
\centering
\includegraphics[width=.35\textwidth]{ray-divides.pdf}
\caption{To determine if $A[i,j]\leq r$ for a $G(a,b,t)$ with $a \leq i \leq b$, $j_t \leq j \leq j_{t+1}$,
we use four subsets $S_1=S^+[i,b], S_2=S^+[b,n], S_3=S^-[1,j_t],$ and $S_4=S^-[j_t,j]$.
Observe that $b,j_t$ and $n$ are constant, and $|b-a|,|j_{t+1}-j_t|\leq \log^6 n$.}
\label{fig:dividingsets}
\end{figure}
The decision algorithm consists of
computing group information and binary search.
We simply use $I(\cdot)$ to denote $I_r(\cdot)$.
For for each group $G(a,b,t)$, the algorithm computes
$I(S^+[b,n])$ and $I(S^-[1,j_t])$. And then it
constructs a data structure such that given query indices $i$ and $j$ with $a \leq i \leq b$ and $j_t \leq j \leq j_{t+1}$, it determines if $I(S^+[i,n]) \cap I(S^-[1,j]) =\emptyset$ or not
using $I(S^+[b,n])$ and $I(S^-[1,j_t])$.
In the binary search, we determine $A[i,j] \leq r$ or not (and $B[i,j] \leq r$ or not) using
emptiness queries on this data structure.
For an ordered point set $L$ and any point set $R$
separated by a line in the plane,
let $\mathcal{D}(L,R)$ be a balanced BST on the ordered set $L$ with respect to $R$
constructed from $\bbst{L}$ such that for each node $w$ in $\bbst{L}$,
we store $f(S_w,R)$ and $f(R,S_w)$ instead of $I(S_w)$.
This data structure will be used to determine if $I(L' \cup R)=\emptyset$ or not for
any interval $L' \subseteq L$.
\begin{lemma}\label{lem:data3}
$\mathcal{D}(L,R)$ can be constructed in $O(\log (|L|+ |R|))$ time using $O(|L|)$ processors
once we have $\bbst{L}$ and $I(R)$, where $L$ and $R$ are line separated continuous ordered point set.
\end{lemma}
\begin{proof}
First we assign a processor to a node $w \in \bbst{L}$.
Since there are $O(|L|)$ nodes in $\bbst{L}$ and the tree depth is $O(\log |L|)$,
we can assign $O(|L|)$ processors in $O(\log |L|)$ time. For each nodes $w$, we compute
$f(S_w,R)$ and $f(R,S_w)$. This can be done using $I(S_w), I(R),$ and Lemma~\ref{lem:tangent} in $O(\log (|S_w| +|R|)$ time.
Since $S_w \subseteq L$, $\mathcal{D}(L,R)$ can be constructed in $O(\log (|L| +|R|))$ time
using $O(|L|)$ processors.
\end{proof}
We will apply binary search for each index $i$. Each index $i$ is contained in one of the $2m$ groups. Each group $G(a,b,t)$ consists of continuous $O(\log^6 n)$ indices $\lbrace a,a+1, \ldots, a+b \rbrace$.
For an index $i \in G(a,b,t)$, the decision on $A[i,j] \leq r$ is equivalent to the decision on
$I_{ij} = \bigcap_{k=1}^4 I(S_k)\neq\emptyset$,
where $S_1=S^+[i,b], S_2=S^+[b,n], S_3=S^-[1,j_t],$ and $S_4=S^-[j_t,j]$.
The emptiness of $I_{ij}$ is equivalent to the emptiness of $\partial I_{ij}$.
Since $\partial I_{ij}$ consists of boundary parts of
$I(S_k)$ for each $k=1,\ldots, 4$, the emptiness of $I_{ij}$ is equivalent to the
emptiness of $I_{ij} \cap \partial I(S_k)$ for every $k=1,\ldots, 4$.
Now we list all the information we need in computing $\partial I(S_1)$ and $I_{ij} \cap \partial I(S_2)$.
Observe that $I_{ij} \cap \partial I(S_1)$ consists of parts of the boundaries $I_{ij} \cap \partial I(S_w)$ for the
canonical nodes $w \in U^+(i,b)$.
To compute $I_{ij} \cap \partial I(S_w)$ for a node $w \in U^+(i,b)$ using Lemma~\ref{lem:intersection},
we need $f(S_w,S_1)$, $f(S_w,S_2)$, $f(S_w,S_3)$ and $f(S_w,S_4)$.
We compute $f(S_w,S_2)$ and $f(S_w,S_3)$ in this Phase.
Then we compute $f(S_w,S_1)$ and $f(S_w,S_4)$ in Phase 3.
To compute $I_{ij} \cap \partial I(S_2)$ using lemma~\ref{lem:intersection},
we need $f(S_2,S_3)$ and $f(S_2,S_w)$ for every node $w \in U^+(i,b) \cup U^-(j_t,j)$.
We compute them all in this Phase.
We can compute $I_{ij} \cap \partial I(S_4)$ and $I_{ij} \cap \partial I(S_3)$ in a similar way.
To cover the query range, we need to compute $f(S_w,S_2)$, $f(S_w,S_3)$,
$f(S_2,S_w)$ and $f(S_3,S_w)$ for every
$w \in \bbst{S^+[a,b]} \cup \bbst{S^-[j_t,j_{t+1}]}$
because $i\in[a,b]$ and $j\in [j_t,j_{t+1}]$ while applying the binary search on the group.
We compute the followings for each group $G(a,b,t)$ in this phase.
\begin{enumerate}
\item \label{item:CommonGroup} $I(S_2)$ and $I(S_3)$.
\item \label{item:CommonGroup2} $f(S_2,S_3)$ and $f(S_3,S_2)$.
\item \label{item:treeInformation1} $\mathcal{D}(S^+[a,b],S_2)$, $\mathcal{D}(S^+[a,b],S_3)$, $\mathcal{D}(S^-[j_t,j_{t+1}],S_2)$ and $\mathcal{D}(S^-[j_t,j_{t+1}],S_3)$.
\end{enumerate}
Part~\ref{item:CommonGroup} can be done in $O(\log n)$ time using
$O(\log^2 n)$ processors by Lemma~\ref{lem:query}.
Part~\ref{item:CommonGroup2} can be done in $O(\log n)$ time by
Lemma~\ref{lem:tangent}.
Part~\ref{item:treeInformation1} can be done $O(\log n)$ time using $O(\log^6 n)$ processors by Lemma~\ref{lem:data3}.
Since there are $2m= O(n/\log^6 n)$ such groups, the three parts can be done $O(\log n)$
time with $O(n)$ processors in total.
\subsection{Phase 3 - Binary search}
For an index $i \in G(a,b,t)$, we apply binary search over range $j \in [j_t,j_{t+1}]$.
Since $|j_{t+1}-j_t|=O(\log^6 n)$, our algorithm performs $O(\log\log n)$ steps of
binary search to determine whether $r_i^* \leq r$ or not.
To determine $I_{ij}\neq\emptyset$, we determine $I_{ij} \cap \partial I(S_1)\neq\emptyset$, $I_{ij} \cap \partial I(S_2)\neq\emptyset$, $I_{ij} \cap \partial I(S_3)\neq\emptyset$, or $I_{ij} \cap \partial I(S_4)\neq\emptyset$.
To determine $I_{ij} \cap \partial I(S_1) \neq \emptyset$, we determine $I_{ij} \cap \partial I(S_w) \neq \emptyset$
for every canonical node $w \in U^+(i,b)$.
To determine $I_{ij} \cap \partial I(S_w)\neq\emptyset$ by Lemma~\ref{lem:intersection},
we compute $f(S_w,S_2)$, $f(S_w, S_3),$ and $f(S_w, S_{w'})$ for all $ w' \in U^+(i,b) \cup U^-(j_{t},j)$,
because the union of the intersections for $S_2$, $S_3$ and all $S_{w'}$ is $I_{ij}$.
We can compute $f(S_w, S_2)$ and $f(S_w, S_3)$ in $\mathcal{D}(S^+[a,b], S_2)$ and
$\mathcal{D}(S^+[a,b], S_3)$, respectively, at the corresponding nodes $w$.
We can compute $f(S_w, S_{w'})$ using $I(S_w)$ and $I(S_{w'})$, and
the intersections $I(S_w)$ and $I(S_{w'})$ can be found in
$\bbst{S^+[a,b]}$ or $\bbst{S^-[j_t,j_{t+1}]}$.
Since $|S_w|=O(\log^6 n)$ and $|S_{w'}|=O(\log^6 n)$, it takes $O(\log \log n)$ time to compute
$f(S_w,S_{w'})$ for fixed $w$ and $w'$ by Lemma~\ref{lem:intersection}.
Since $|U^+(i,b) \cup U^-(j_{t},j)|=O(\log \log n)$, it takes $O(\log^2 \log n)$ time to compute
$f(S_w,S_{w'})$ for all $w' \in |U^+(i,b) \cup U^-(j_{t},j)|$.
Thus we can determine $I_{ij} \cap \partial I(S_w)\neq\emptyset$ in $O(\log^2 \log n)$ time.
Since $|U^+(i,b)|= O(\log \log n)$,
$I_{ij} \cap \partial I(S_1)$ can be determined $O(\log^3 \log n)$ time with one processor.
To determine $I_{ij} \cap \partial I(S_2)\neq\emptyset$,
we need $f(S_2,S_3)$ and $f(S_2,S_w)$ for all $w \in U^+(i,b) \cup U^-(j_t,j)$.
We already have $f(S_2,S_3)$ and $f(S_2,S_w)$ can be computed from $\mathcal{D}(S^+[a,b],S_2)$ and $\mathcal{D}(S^-[j_t,j_{t+1}],S_2)$ in $O(\log \log n)$ time.
So we can determine $I_{ij} \cap \partial I(S_2)\neq\emptyset$ in $O(\log \log n\log\log\log n)$ time with one processor.
Therefore, for a fixed $i$ and a given $j$, we can determine whether
$I_{ij}$ is empty or not in $O(\log^3 \log n)$ time. Remind that the search range for an index
is $O(\log^6 n)$. There are $O(\log \log n)$ steps of binary search and there are $n+1$ indices
for $i$. The decision step can be done in $O(\log^4 \log n)$ time using $O(n)$ processors.
\begin{theorem}
The decision problem for the restricted 2-center problem can be
solved in $O(\log n)$ time using $O(n)$ processors after
$O(n\log n)$-time preprocessing.
\end{theorem}
\begin{theorem}
The restricted 2-center problem can be solved in $O(n\log n)$ time.
\end{theorem}
\begin{proof}
We use Cole's parametric search technique~\cite{Cole-parametric} to compute the optimal radius $r^*$.
To apply the technique, the parallel algorithm must satisfy a bounded fan-in/bounded fan-out requirement.
Instead of analyzing the parallel algorithm directly, we divide the algorithm to
a constant number of parts such that each part satisfies a bounded fan-in/bounded fan-out.
Our parallel decision algorithm computes some information for each group and
applies binary search on indices.
In the group information phase,
we compute $I(S_2)$ by computing $I(S_2) \cap \partial I(S_w)$
for every $w \in U^+(b,n)$ and merging them.
Each $I(S_2) \cap \partial I(S_w)$ is computed by computing $f(S_w,S_{w'})$ for every
$w' \in U^+(b,n)$ and merging them.
Thus, a processor activates at most one processor, and the fan-out is bounded.
We also compute $f(S_2,S_3)$ for each group independently by a processor,
and thus the fan-in and fan-out are bounded.
We assign processors for all nodes $w$ without knowing the decision parameter $r$ in advance.
Then each processor computes $f(S_2,S_w)$ and $f(S_w,S_2)$ for a node $w$ independently,
and thus the fan-in and fan-out are bounded.
In the binary search phase, each binary search for an index is performed by a processor
independently, and thus the fan-in and fan-out are bounded.
Therefore, our parallel algorithm consists of a constant number of fan-in or fan-out
bounded networks. Thus we can apply Cole's parametric
search technique to compute $r^*$ in $O((T_S+Q)(T_P+ \log Q))$ time,
where $T_S$ is the sequential decision time, $T_P$ is the parallel decision time and
$Q$ is the number of processors for parallel decision algorithm.
Since we have $T_S=O(n)$, $T_P=O(\log n)$ and $Q=O(n)$,
$r^*$ can be computed in $O(n\log n)$ time.
\end{proof}
\section{Optimal 2-center for points in convex position}
In this section, we consider the 2-center problem for points in convex position.
Wang gave an $O(n\log n\log\log n)$-time algorithm for
this problem.
Let $S$ be a point set consisting of $n$ points in convex position in the plane.
We denote by $\mathsf{CH}(S)$ the convex hull of $S$.
It is known that there is an
optimal solution $(D_1^*, D_2^*)$ such that $D_1^*$ covers a set of
consecutive vertices (points of $S$) along $\partial \mathsf{CH}(S)$ and
$D_2^*$ covers the remaining points of $S$~\cite{kim2000}. Since the
points are in convex position, for any point $q$ contained in
$\mathsf{CH}(S)$, the points of $S$ appears in the same order around $q$.
Let $\mu_1$ and $\mu_2$ be the two rays from $o$ that separate the
point set $S$ into two subsets, one covered by $D_1^*$ and the other
covered by $D_2^*$. We need to find a line $\ell$ that separates
$\mu_1$ and $\mu_2$. The line $\ell$ partitions the points of $S$ to $S^+$ and
$S^-$. Then $o$ can be any point in $\ell$.
Wang gave an algorithm that finds the optimal two disks or the line
$\ell$ in $O(n\log n)$ time~\cite{WANG2020}. The algorithm first
sorts the points of $S$ along the boundary of $\mathsf{CH}(S)$ and pick any
point $p_1\in S$. Then it finds $p^*\in S$ such that the two congruent
smallest disks $(D_1, D_2)$ with $D_1$ covering $\mathsf{CH}(S)[p_1,p^*]$
and $D_2$ covering $S\setminus \mathsf{CH}(S)[p_1,p^*]$ have the minimum
radius over all $p\in S$.
The radius of $D_1$ covering $\mathsf{CH}(S)[p_1,p_j]$ does not decrease
while $p_j$ moves along the boundary of $\mathsf{CH}(S)$. Similarly, $D_2$
has this property. In each step of binary search, we compute $D_1$
and $D_2$ in $O(n)$ time. Thus, the algorithm can find $p^*$ in
$O(n\log n)$ time using binary search.
If $\mu_1$ passes through $p_1$, we already have the minimum radius.
Otherwise, $\mu_1$ or $\mu_2$ passes through $p^*$ or one of its two
neighboring point along $\mathsf{CH}(S)$, or $\mu_1$ crosses
$\mathsf{CH}(S)[p_1,p^*]$ and $\mu_2$ crosses $\mathsf{CH}(S)[p^*,p_1]$. So we
can find the optimal disks or the line $\ell$ that separates $\mu_1$
and $\mu_2$ in $O(n\log n)$ time.
Therefore, we can apply our algorithm in Section~\ref{sec:ours} to the
points in convex position. From this, we improve the running time
by a $\log\log n$ factor over the $O(n\log n\log\log n)$-time algorithm
by Wang.
\begin{theorem}
The 2-center problem for $n$ points in convex position in the plane
can be solved in $O(n\log n)$ time.
\end{theorem}
\section{Conclusions}
We presented a deterministic $O(n \log n)$-time algorithm for the case that the centers of
the two optimal disks are close together, that is, the overlap of the two optimal disks
is a constant fraction of the disk area.
Now for the planar 2-center problem, the bottleneck of the time bound
is the case that the two optimal disks are disjoint, and
Eppstein's $O(n\log^2 n)$-time algorithm is best for the case.
Thus, the time for the planar 2-center problem still
remains to be $O(n\log^2 n)$ due to the well-separated case.
We also presented a deterministic $O(n\log n)$-time algorithm for
$n$ points in convex position in the plane. This closes the long-standing
question for the convex-position case.
| {'timestamp': '2020-07-09T02:05:50', 'yymm': '2006', 'arxiv_id': '2006.10365', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10365'} | arxiv |
\section{Introduction}
\label{intro}
We faced the need to solve the problem when determined the start times for oil and gas field development projects in compliance with the annual production limits \cite{Erzin20}.
Mathematically the problem is as follows. Let us have a semi-infinite unit-height horizontal strip and a set of bar charts consisting of two bars, each with a height of at most $1$ and unit length. For convenience, BC, with $b$ bars, we will denote by $b$-BC. All 2-BCs are required to pack in a strip of minimum length. When packing BCs, crossing bars are naturally prohibited. Moreover, the bars of each BC can move vertically, but they are inseparable horizontally and cannot be interchanged. An example of feasible packing is in Fig. 1.
\begin{figure*}
\includegraphics[width=\textwidth]{fig1.eps}
\caption{The example of feasible packing. \emph{a}) Set of 2-BCs; \emph{b}) Packing of length 11.}
\label{fig1}
\end{figure*}
A similar well-studied problem is the Bin Packing Problem (BPP) \cite{Baker85,Dosa07,Johnson73,Johnson85,Li97,Yue91,Yue95}. In the BPP, we have a set of items $L$ with the sizes not more than $1$ and a set of unit-size containers (bins). It is required to put all items in a minimum number of bins. One packing algorithm is First Fit Decreasing (FFD). All items in the decreasing order placed in the first suitable bin. Johnson proved that the FFD algorithm uses no more than $11/9\ OPT(L)+4$ bins \cite{Johnson73}. Backer reduced the additive constant to 3 \cite{Baker85}. Yue proved that $FFD(L)\leq 11/9\ OPT (L)+1$ \cite{Yue91}. Then together with Li \cite{Li97}, he improved the result to $FFD(L)\leq 11/9\ OPT (L)+7/9$. D\'{o}sa found the tight boundary of the additive constant and gave an example when $FFD(L)=11/9\ OPT(L)+6/9$ \cite{Dosa07}. A Modified First Fit Decreasing (MFFD) algorithm improves FFD by dividing items into groups by size and packing items from different groups separately. Johnson and Garey proposed this modification and showed that $MFFD(L)\leq 71/60\ OPT(L)+31/6$ \cite{Johnson85}. Subsequently, the result was improved by Yue and Zhang to $MFFD(L)\leq 71/60\ OPT(L)+1$ \cite{Yue95}.
The problem under consideration is also a particular case of the project scheduling problem when each job during a one-time slot consumes the limited non-accumulative resource \cite{Hartmann02,Kolisch06}. For the case of an accumulative resource, an exact algorithm has been developed \cite{Gimadi03}. In the case of a limited renewable resource, the problem is NP-hard, and polynomial algorithms with guaranteed accuracy estimates are not known \cite{Goncharov14,Goncharov17,Hartmann02,Kolisch06}.
The rest of the paper is organized as follows. Section 2 provides a statement of the packing problem for 2-BCs as a Boolean Linear Programming (BLP). Section 3 describes the $O(n^{3.5})$-time algorithm $M$ for packing of 2-BCs, which in the case when the 2-BCs are non-increasing, and the first bar is more than 1/2 yields a 3/2-approximate solution. Section 4 presents the $O(n^4)$-time algorithm $M_w$, which is in the case when at least one bar is more than 1/2 builds a 3/2-approximate solution. In section 5, we summarize and outline directions for further research.
\section{Formulation of the problem}
On the plane, we have a unit-height semi-infinite horizontal strip and a set of 2-BCs $S$ ($|S|=n$). Each 2-BC $i\in S$ consists of two unit-length bars. The height of the first bar is $a_i\in (0,1]$ and of the second $b_i\in (0,1]$. Let us divide the strip into equal rectangles (cells) of unit length and height and renumber them starting from the origin of the strip with integers $1,2,\ldots$.
\begin{definition}
2-BC $i$ is \emph{non-increasing} (\emph{non-decreasing}) if $a_i\geq b_i$ ($a_i\leq b_i$).
\end{definition}
\begin{definition}
\emph{Packing} is a function $p:S\rightarrow Z^+$, which associates with each BC $i$ the cell number of the strip $p(i)$ into which the first bar of BC $i$ falls.
\end{definition}
As a result of packing $p$, bars from 2-BC $i$ occupy the cells $p(i)$ and $p(i)+1$.
\begin{definition}
The packing is \emph{feasible} if the sum of the bar's heights that fall into one cell does not exceed 1.
\end{definition}
\begin{definition}
The packing \emph{length} $L(p)$ is the number of strip cells in which falls at least one bar.
\end{definition}
We assume that any packing $p$ begins from the first cell, and in each cell from 1 to $L(p$), there is at least one bar. If this is not the case, then all or part of the packing can be moved to the left.
The BLP formulation for 2-BCPP made in \cite{Erzin20_2}. Since \cite{Erzin20_2} is still arXiv paper, we repeat the BLP for convenience here. To do this, we introduce the variables:\\
$$
x_{ij}=\left\{
\begin{array}{ll}
1, & \hbox{if the first bar of BC $i$ is in the cell $j$;} \\
0, & \hbox{else.}
\end{array}
\right.
$$
$$
y_j=\left\{
\begin{array}{ll}
1, & \hbox{if the cell $j$ contains at least one bar;} \\
0, & \hbox{else.}
\end{array}
\right.
$$
Then 2-BCPP is written as follows.
\begin{equation}\label{e1}
\sum\limits_j y_j \rightarrow\min\limits_{x_{ij},y_j\in\{0,1\}};
\end{equation}
\begin{equation}\label{e2}
\sum\limits_j x_{ij} =1,\ i\in S;
\end{equation}
\begin{equation}\label{e3}
\sum\limits_i a_ix_{ij} + \sum\limits_k b_kx_{k,j-1}\leq y_j,\ \forall j.
\end{equation}
The 2-BCPP is strongly NP-hard as the generalizations of the BPP \cite{Johnson73}. Moreover, the problem is $(3/2-\varepsilon)$-inapproximable unless P=NP \cite{Vazirani01}.
In \cite{Erzin20_2}, we proposed an $O(n^2)$-time algorithm, which packs the 2-BCs in the strip of length at most $2\cdot OPT+1$, where $OPT$ is the minimum packing length. In this paper, we propose two new $O(n^{3.5})$- and $O(n^4)$-time packing algorithms based on the sequential matching and prove that if at least one bar of each BC has a height greater than 1/2, then the constructed solution is 3/2-approximate. We show that this is a tight estimation.
\section{Algorithm $M$}
\begin{definition}
If two BCs share three (two) cells, then we call this situation 1-union (2-union).
\end{definition}
Using the set $S$, we construct a graph $G_1=(V_1,E_1)$ in which the vertices are the images of BCs ($|V_1|=|S|=n$), and an edge connects two BCs if they can create ether 1- or 2-union.
Algorithm $M$ consists of a sequence of the steps. At the first step, in the graph $G_1$, the maximum matching of cardinality $m_1$ is constructed. The result are $n-m_1$ 2- and 3-BCs, which are the prototypes of vertices forming the set $V_2$ of the new graph $G_2=(V_2,E_2)$. The edge $(i,j)\in E_2$ if BCs $i$ and $j$ form a union. At an arbitrary step in the corresponding graph $G_k$, we construct the next maximum matching of cardinality $m_k$. The algorithm stops when in the graph $G_{p+1}$, there are no more pairs of BCs to combine. In Fig. 2, we illustrated the operation of the algorithm.
\begin{figure*}
\includegraphics[width=\textwidth]{fig2.eps}
\caption{Illustration of algorithm $M$ operation. \emph{a}) First matching, $m_1=4$; \emph{b}) Second matching, $m_2=2$; \emph{b}) Third matching, $m_3=1$.}
\label{fig2}
\end{figure*}
The length of the packing constructed by the algorithm $M$ is
\begin{equation}\label{e4}
L_M(n)=2n-m_1-m_2-\ldots - m_p,\ p\geq 1.
\end{equation}
\begin{definition}
If at least one bar in BC has height more than 1/2, then such BC we call \emph{big}.
\end{definition}
Let each BC is big and non-increasing. Then in each cell can be no more than two bars, and two BCs can form only a 1-union.
\begin{figure*}
\includegraphics[width=\textwidth]{fig3.eps}
\caption{Disassembling of optimal packing. \emph{a}) Optimal packing; \emph{b}) First optimal matching.}
\label{fig3}
\end{figure*}
Any packing, including the optimal one, can be disassembled into BCs obtained from the first matching. Let there be optimal packing. Let us single out independent unions, the beginning, and end of which is determined by the presence of one bar in the cell (there are 3 of them in the example in Fig. 3). Each union we will disassemble independently from left to right, separating 3-BCs consisting of two 2-BCs. If the union has an odd number of 2-BCs, then the last one will be one 2-BC (in the example in Figure 3, these are BCs 3, 6, and 9 in different unions).
Thus, the procedure for constructing optimal packing can be represented as a process of sequential construction of maximum matchings. Denote by $m_k^*$ the cardinality of the $k$th matching in the optimal packing. Then the length of optimal packing is
\begin{equation}\label{e5}
OPT=2n-m_1^*-m_2^*-\ldots -m_q^*,\ q\geq 1.
\end{equation}
\begin{lemma}
\begin{equation}\label{e6}
m_2^*+\ldots +m_q^*\leq m_1^*\leq m_1.
\end{equation}
\end{lemma}
\begin{proof}
We will need the following obvious
\begin{property}
If there are $X$ BCs occupying a total of $Y$ cells, then after packing them, they will occupy at least $Y-(X-1)$ cells, i.e., packing length will decrease by no more than $X-1$.
\end{property}
Suppose that the optimal packing consists of $U\geq 1$ unions (which means $OPT=n+U$), and after disassembling, there are $B\in [0,U]$ separate 2-BCs. In Fig. 3 for example $U=3$, $B=3$, and $m_1^*=3$. $B$ 2-BCs cannot unite with each other. Otherwise, the disassembled packing is not optimal. Each of them is the last 2-BCs in each union. Total number of BCs after disassembling is $B+(n-B)/2=B+m_1^*$ since $(n-B)/2=m_1^*$. The first matching effects reduction in the number of occupied cells at most $B$ cells due to the union of $B$ 2-BCs. There are remain another $n-B$ 3-BCs, which can be combined only in their unions. Therefore, it is still possible to reduce the packing length by a maximum of $(n-B)/2-U$ cells (Property 1). Total, after the first matching, we can still reduce the packing length by
$$
m_2^*+\ldots +m_q^*\leq B+(n-B)/2-U=B+m_1^*-U\leq m_1^*\leq m_1,
$$
since $B\leq U$ and by construction, $m_1 \geq m_1^*$. The lemma is proved.
\end{proof}
\begin{theorem}
If all 2-BCs are big and non-increasing, then the algorithm $M$ constructs a 3/2-approximate solution for the 2-BCPP with time complexity $O(n^{3.5})$.
\end{theorem}
\begin{proof}
From (\ref{e4}), (\ref{e5}), (\ref{e6}) and $m_1\leq n/2$ it follows that $L=L_M(n)\leq 2n-m_1$, $OPT\geq 2n-2m_1$ and hence
$$
\frac{L}{OPT}\leq \frac{2n-m_1}{2n-2m_1}=1+\frac{m_1}{2n-2m_1}\leq 1+\frac{n/2}{2n-n}=\frac{3}{2}.
$$
The algorithm, $M$, uses the procedure for constructing the maximum matching at most $O(n)$ times. In \cite{Xie18}, an $O(n^{2.5})$-time algorithm proposed for constructing the maximum matching. So the time complexity of the proposed algorithm is $O(n^{3.5})$.
\end{proof}
Naturally, in the case of non-decreasing big 2-BCs, the algorithm $M$ also constructs a 3/2-approximate solution.
In \cite{Vazirani01}, Theorem 9.2 states that for any $\varepsilon > 0$, there is no approximation algorithm having a guarantee of $3/2-\varepsilon$ for the bin packing problem, assuming $P\neq NP$. Since the 2-BCPP is the generalization of BPP, this is the case for 2-BCPP too. However, if all BCs are big, we need to prove the tightness of the estimate, and we will do it in the next section.
\section{Algorithm $M_w$}
Now let all BCs are big, but not necessarily non-increasing or non-decreasing. There are more union options, and we will distinguish 1-unions and 2-unions (refer to Definition 5). We will construct now a \emph{weighted} graph $G_1=(V_1, E_1)$, in which, as before, the vertices are images of BCs. An edge between the vertices exists if these vertices can create a union. The weight of the edge $(i,j)\in E_1$ equals 1 if BCs $i$ and $j$ create a 1-union and 2 if they form a 2-union. In the algorithm, $M_w$, instead of the maximum matching at each step, a \emph{max-weight matching} constructed. There are no more differences from the algorithm $M$. We introduce the following additional notation:
\begin{itemize}
\item $w_k^*$ is the weight of the $k$th matching in the optimal packing;
\item $w_k$ is the weight of the $k$th matching in the packing constructed by algorithm $M_w$;
\item $k_1^*$ is the number of 2-unions in the first matching in the optimal packing;
\item $k_1$ is the number of 2-unions in the first matching of maximum weight constructed by algorithm $M_w$.
\end{itemize}
Since each BC with the above properties can participate in the 2-union only once, the following property is valid.
\begin{property}
2-unions can only be when constructing the first matching.
\end{property}
Then $w_k^*=m_k^*,\ k\geq 2$. One can see the example of disassembling of optimal packing in Fig. 4.
\begin{figure*}
\includegraphics[width=\textwidth]{fig4.eps}
\caption{Disassembling of optimal packing. \emph{a}) Optimal packing; \emph{b}) First optimal matching.}
\label{fig4}
\end{figure*}
\begin{lemma}
The minimal length of packing $n$ big BCs is at least $n$ ($OPT\geq n$).
\end{lemma}
\begin{proof}
Suppose that the optimal packing contains $k$ 2-unions (which, according to Property 2, can no longer be combined). They reduce packing length by $2k$ cells. The remaining $n-2k$ BCs can only be combined into 1-unions, either with each other or with 2-unions, reducing the packing length by a maximum of $n-2k$ cells (Property 1). Therefore, $OPT\geq 2n-2k-(n-2k)=n$.
\end{proof}
\begin{theorem}
If all 2-BCs are big, then with time complexity of $O(n^4)$, the algorithm $M_w$ constructs a 3/2-approximate solution to the 2-BCPP.
\end{theorem}
\begin{proof}
The first matching of maximum weight contains $k_1$ 2-unions. In the optimal packing, after disassembling, the first matching contains $k_1^*$ 2-unions. Because of Lemma 1, we have:
$$
OPT=2n-w_1^*-m_1^*-\ldots -m_q^*\geq 2n-w_1^*-m_1^*.
$$
Therefore, taking into account inequality $L=L_{M_w}(n)\leq 2n-w_1$, we have
$$
\varepsilon=\frac{L}{OPT}\leq\frac{2n-w_1}{2n-w_1^*-m_1^*}\leq\frac{2n-w_1}{2n-w_1-n/2}=1+\frac{1}{3-2w_1/n}=f(x),
$$
where $x=w_1/n$.
On the other hand (by Lemma 2) $OPT\geq n$. Hence
$$
\varepsilon=\frac{L}{OPT}\leq\frac{2n-w_1}{n}=2-w_1/n=g(x).
$$
Therefore, $\varepsilon\leq\min\{f(x),g(x)\}$. The function $f(x)$ is increasing, and $g(x)$ is decreasing. Let $f(x_0)=g(x_0)$. Then $\varepsilon\leq f(x_0)=g(x_0)$. To find $x_0$, solve the equation $1+\frac{1}{3-2x}=2-x$, or $2x^2-5x+2=0$. There is one suitable solution $x=1/2$. Then $\varepsilon\leq g(1/2)=3/2$.
The time complexity of constructing a max-weight matching is $O(n^3)$ \cite{Gabow90,Galil86}, then the complexity of algorithm $M_w$ is $O(n^4)$.
\end{proof}
In Fig. 5, we give an example of the asymptotical attainability of the obtained estimate. In this example, $4k$ big 2-BCs: $2k$ of them are green non-increasing, and $2k$ are red non-decreasing. In the optimal packing, we construct the first matching shown in Fig. 5\emph{a}. Then the optimal packing is in Fig. 5\emph{b}, and $OPT=4k+1$. Algorithm $M_w$ can construct first max-weight matching, as in Fig. 5\emph{c}, and then there is no any more matching, and the length of the packing is $L=L_{M_w}=8k-2k$. Therefore, when $k$ tends to $\infty$, $L/OPT=6k/(4k+1)$ tends to 3/2.
\begin{figure*}
\includegraphics[width=\textwidth]{fig5.eps}
\caption{\emph{a}) 3-BCs after the first optimal matching; \emph{b}) Optimal packing; \emph{b}) First max-weight matching built be $M_w$.}
\label{fig5}
\end{figure*}
\section{Conclusion}
We considered a new problem, in which it is necessary to pack two-bar charts in a unit-height strip of minimum length. The problem is a generalization of the bin packing problem. Earlier, we proposed an $O(n^2)$-time algorithm, which builds packing of length at most $2\cdot OPT+1$ for the general case. In this paper, we proposed an $O(n^4)$-time 3/2-approximate algorithm for the case when each BC has at least one bar greater than 1/2.
In future research, we plan to get a new estimate not only for big but also for arbitrary BCs.
| {'timestamp': '2020-06-19T02:11:25', 'yymm': '2006', 'arxiv_id': '2006.10361', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10361'} | arxiv |
\section{Introduction}
Regularization methods have been introduced to a linear model to improve the prediction accuracy and interpretability by introducing a penalty term to the least squares criterion; lasso that implements $l_1$ penalty \citep{Tibshirani1996}, ridge that adds $l_2$ penalty \citep{Tikhonov1943}, elastic net (EN) that introduces a combination of $l_1$ and $l_2$ penalties \citep{Zou2005}, and non-convex penalties \citep{Fan2001,Zhang2010}.
It is known that EN shows better performances compared to the lasso while preserving a sparse variable selection property \citep{Zou2005,buhlmann2011statistics}. EN also identifies influential variables better than the lasso and has lower false positives than ridge regression \citep{tutz2009penalized}.
The penalized regression approaches have an intuitive Bayesian counterpart stemming from introducing penalty terms in the form of priors. For instance, Bayesian lasso (BL) \citep{bayeslasso} uses a double-exponential
prior, and Bayesian elastic net (BEN) \citep{Ben2010} uses an informative prior that is a compromise between normal and Laplace priors.
The non-convex penalties also have been implemented including spike-and-slab prior \citep{ishwaran2005}, horseshoe prior \citep{Carvalho2010}, and hyperlasso \citep{Griffin2011}.
Motivated by \cite{Ben2010}, various BEN studies have been conducted including applications to gene-expression data \citep{chen2010detection}, empirical BEN \citep{huang2015empirical}, and regressions \citep{alhamzawi2016bayesian,alshaybawee2017bayesian,alhamzawi2018bayesian}.
The Bayesian approaches on regularization regression have several advantages. First, the Bayesian methods provide a natural interpretation of parameter uncertainty. For example, the standard errors of our parameter of interest can be estimated as the posterior standard deviations because the Bayesian method provides the entire posterior distribution.
Second, the Bayesian methods provide valid standard errors compared to the variances of the non-Bayesian penalized regressions estimated by the sandwich or bootstrap \citep{kyung2010}.
Third, the penalty parameters in the Bayesian methods can be estimated simultaneously with model parameters. When the non-Bayesian models have multiple penalty parameters such as EN, multi-stage cross-validations are used to estimate the penalty terms. However, the sequential estimation of penalties may incur the over-shrinkage of parameters that leads to larger bias \citep{Ben2010}. Lastly, the Bayesian penalized regression approaches show similar or better performances compared to the corresponding non-Bayesian approaches \citep{Hans2009,kyung2010,Ben2010}.
Lastly, the Bayesian penalized regression approaches show similar or better performances compared to the corresponding non-Bayesian approaches \citep{Hans2009,kyung2010,Ben2010}.
\cite{Owen1988,Owen1990} introduces empirical likelihood (EL), a nonparametric likelihood method to make inference for statistical functionals. EL does not require an assumption that the data follow a certain distribution while maintaining similar properties of a conventional likelihood method such as Wilk's theorem and Bartlett correctability \citep{Owen1990,Diciccio1991,Chen2006}.
The EL approach has been extended to complex inferences, including general estimating equation \citep{Qin94}, density estimation \citep{Hall1993}, area under the receiver operating characteristic curve \citep{Qin2006}, and data imputation \citep{wang2009}. We refer to \cite{Chen2009} for a review of EL methods on regression.
EL has extended to high dimensional data.
\cite{hjort2009} and \cite{Chen2009b} show that the asymptotic normality of the EL ratio holds when the dimension of data grows.
\cite{Tang2010} and \cite{Leng2012} propose the penalized EL and show that it has the oracle property \citep{Fan2001,fan2004}. \cite{lahiri2012} propose the penalized EL for estimating population means when the dimension of data is larger than the number of observations. \cite{chang2018} also suggest implementing two penalty functions to penalized models and Lagrange multipliers.
Also, the EL-based Bayesian methods have been developed. \cite{Lazar2003} replaces the likelihood function in Bayesian settings by EL and shows the validity of the resulting posterior distribution.
In addition, \cite{Grendar2009} show that Bayesian empirical likelihood (BEL) is consistent under the misspecification of the model.
BEL has been studied in various areas; the higher-order asymptotic and coverage properties of the posterior distribution for the population mean \citep{Mukerjee2006,Mukerjee2008}, the survey sampling \citep{Wu2010}, small area estimation \citep{Sanjay2011}, quantile regression \citep{Yunwen2012}, Bayesian computation \citep{Mengersen:etal:2012}, sampling method \citep{Chaudhuri2017}, and lasso and ridge regressions \citep{Adel2020}.
In this paper, we suggest a Bayesian approach for EN where the likelihood function is replaced by the profile EL of the linear model. We place a special prior distribution on the parameter of interest, which combines the $l_1$ and $l_2$ penalties leading to the EN approach. The proposed approach takes advantage of the interpretability and robustness of the results achieved by the Bayesian perspective and EL method, respectively. We implement the HMC sampling for BEL suggested by \cite{Chaudhuri2017} and propose the leapfrog step size tuning algorithm based on the bisection method.
The proposed algorithm enables more efficient sampling than hand-tuning or grid-searching HMC parameters. In addition, our method extends the BEL method for penalized regressions of \cite{Adel2020} by proposing efficient HMC sampling rather than utilizing the tailored Metropolis–Hasting of \cite{Chib1995}.
The outline of the remaining sections is as follows. In Section~\ref{sec:el}, we briefly describe the Bayesian linear model based on EL. In Section~\ref{sec:BNEN}, we propose BEN based on EL and discuss the HMC sampling implementations, along with variable selection procedures. In Section~\ref{sec:sim}, we compare the proposed method with other penalized regression methods using various simulation studies. The real data analysis is presented in Section~\ref{sec:real}. Section~\ref{sec:conclusion} contains conclusion and future work.
\section{Linear model based on empirical likelihood}
\label{sec:el}
We first outline how EL is implemented in a linear model.
Let $X=[\pmb{x_1}, \cdots, \pmb{x_p}]$ be a collection of independent $p$ covariate vectors of size $n$.
We consider the linear model
\[
y_i=\pmb{x_i}^T\pmb{\theta} + \epsilon_i.
\]
where the error is independent and identically distributed and follows an unknown distribution with mean zero and variance $\sigma^2$.
The empirical likelihood function for $\pmb{\theta}$ is defined as
\begin{equation}
L_{EL}(\pmb{\theta})=\sup_{w_i} \Bigl{\{ } \prod\limits_{i=1}^{n} nw_i|\; w_i \geq 0,\; \sum\limits_{i=1}^{n} w_i=1,\; \sum\limits_{i=1}^{n}w_i\pmb{x_i}(y_i-\pmb{x_i}^{T}\pmb{\theta})=\pmb{0} \Bigr{\}},
\label{eq4}
\end{equation}
and $\pmb{w}= (w_1,\cdots,w_n)^T$ is the weights on the data points.
The coefficients $\pmb{\theta}$ can be estimated by maximizing equation (\ref{eq4}) using the Lagrange multipliers. The profile empirical log-likelihood becomes
\begin{equation}
\begin{split}
l_{EL}(\pmb{\theta}) &=-n\log(n) -\sum_{i=1}^{n} \log \left \lbrace 1+\pmb{\gamma}^T\pmb{x_i} (y_i -\pmb{x_i}^T\pmb{\theta})\right \rbrace, \\
& \propto -\sum_{i=1}^{n} \log \left \lbrace 1+\pmb{\gamma}^T\pmb{x_i} (y_i -\pmb{x_i}^T\pmb{\theta})\right \rbrace,\\
\end{split}
\label{eq5}
\end{equation}
where $\pmb{\gamma}=\pmb{\gamma}(\pmb{\theta})$ solves the equation
\begin{equation*}
\sum_{i=1}^{n} \dfrac{\pmb{x_i} (y_i -\pmb{x_i}^T\pmb{\theta})}{1+\pmb{\gamma}^T\pmb{x_i} (y_i -\pmb{x_i}^T\pmb{\theta})} =\pmb{0}.
\label{eqLambda}
\end{equation*}
Here, numerical approaches such as the Newton-Raphson method can be used to find the Lagrange multipliers $\pmb{\gamma}$ \citep{Owen2001}.
The regularization method can be implemented to EL for linear models in different ways. First, the penalty terms can be introduced in the model through the priors $
\pi(\pmb{\theta}) \propto p_n(\pmb{\theta})
$, where $p_n$ is a penalty function. Second, \cite{Tang2010} introduce the penalty terms in EL $l(\pmb{\theta})
\propto -\sum_{i=1}^{n} \log \left \lbrace 1+\pmb{\gamma}^T\pmb{x_i} (y_i -\pmb{x_i}^T\pmb{\theta})\right \rbrace - n\sum_{j=1}^{p}p_n(\theta_j)$. In our study, the $l_1$ and $l_2$ penalties are introduced in the form of priors.
\section{Bayesian elastic net based on empirical likelihood}
\label{sec:BNEN}
EN uses both the $l_1$ and $l_2$ penalties for $p_t(\pmb{\theta}) $\citep{Zou2005}. The EN estimator $\hat{\pmb{\theta}}_{EN}$ is defined as the minimizer of
\begin{equation}
L(\pmb{\theta})= \dfrac{1}{2}||\pmb{y} - \mathit{X}\pmb{\theta}||_2^2 + \lambda_1||\pmb{\theta}||_1 + \lambda_2||\pmb{\theta}||^2_2,
\label{M2}
\end{equation}
where
\[
\begin{split}
&\lambda_1, \lambda_2 \geq 0,\\
& \pmb{\theta}\;\text{is a }p\times 1\;\text{vector},\\
& ||\pmb{\theta}||_1 = \sum_{j=1}^{p}|\theta_j| \text{ and } ||\pmb{\theta}||^2_2 = \sum_{j=1}^{p}\theta_j^2,\\
& \pmb{y}\;\text{is a }n\times 1\;\text{vector},\\
& \mathit{X}\;\text{is a }n\times p\;\text{matrix}.\\
\end{split}
\]
Here, $\lambda_1$ and $\lambda_2$ are $l_1$ and $l_2$ penalty parameters that control the amount of shrinkage. Without loss of generality, we assume that
\[
\sum_{i=1}^{n} x_{ij} =0,\; \sum_{i=1}^{n} y_i=0,\; \sum_{i=1}^{n}x_{ij}^2=1 \text{ for } j=1,\cdots,p.
\]
Penalized linear regression models have their Bayesian counterpart models. The Bayesian penalized models introduce priors for $\pmb{\theta}$ where the hyperparameters are functions of the penalty terms. For example, from the form of the EN penalty term in (\ref{M2}), the EN regression parameters can be presented by the following prior
\begin{equation*}
\pi(\pmb{\theta}) \propto \exp\left( -\lambda_1||\pmb{\theta}||_1 - \lambda_2||\pmb{\theta}||^2_2\right).
\label{M3}
\end{equation*}
\cite{Ben2010} propose the Bayesian counterpart of EN by placing normal and Laplace priors to $l_1$ and $l_2$ penalties, respectively.
The shrinkage parameters, $\lambda_1$ and $\lambda_2$, are introduced into the model in the form of hyperparameters.
The BEL approach for linear models replaces the likelihood with EL and places parametric priors. Then, the posterior density of EN under the BEL approach $\pi(\pmb{\theta}|\;\mathit{X},\pmb{y})$ becomes
\begin{equation*}
\pi(\pmb{\theta} \mid \mathit{X},\pmb{y})=\dfrac{L_{EL}(\pmb{\theta})\pi(\pmb{\theta})}{\int\limits_{\Theta}^{}L_{EL}(\pmb{\theta})\pi(\pmb{\theta})d\pmb{\theta}} \;\propto\;L_{EL}(\pmb{\theta})\pi(\pmb{\theta}).
\label{M4}
\end{equation*}
The hierarchical representation of the full model becomes
\begin{equation}
\begin{split}
L_{EL}(\pmb{\theta}) & \sim \exp\left( l_{EL} (\pmb{\theta})\right), \\
\pmb{\theta}|\sigma^2 &\sim \exp\left( -\dfrac{1}{2\sigma^2} \left[ \lambda_1||\pmb{\theta}||_1 + \lambda_2||\pmb{\theta}||^2_2\right]\right),\\
\sigma^2 &\sim IG(a,b).\\
\end{split}
\label{M5}
\end{equation}
where $L_{EL}(\pmb{\theta})$ is the profile empirical likelihood for the linear model in (\ref{eq5}), IG is an inverse gamma whose probability density function is $\dfrac{b^a}{\Gamma\left(a\right)} x^{-a -1}\exp\left(-\dfrac{b}{x}\right),$ for $x>0$, and $X$ and $\pmb{y}$ are omitted in $L_{EL}\left(\pmb{\theta}\right)$ for simplicity.
We condition $\pmb{\theta}$ on $\sigma^2$ to guarantee the unimodality of the posterior distributions \citep{bayeslasso,Ben2010}.
One can also choose a noninformative prior on $\sigma^2$ of the form of $1/\sigma^2$.
The prior of $\pmb{\theta}$ given $\sigma^2$ defined in (\ref{M5}) is a multiplication of normal and Laplace densities. \cite{andrews1974} show that the Laplace distribution can be represented as a scale mixture of normals with an exponential mixing density
\begin{equation*}
\dfrac{a}{2}e^{-a|z|} = \int_{0}^{\infty} \dfrac{1}{\sqrt{2\pi s}} e^{-z^2/(2s)} \dfrac{a^2}{2}e^{-a^2s/2}ds,\;\;\;a\;>\;0.
\label{eq:laplace2}
\end{equation*}
\cite{Ben2010} also showed that the prior defined in (\ref{M5}) can be presented as a scale mixture of normals with a truncated gamma mixing density. The hierarchical scheme in (\ref{M5}) becomes as follows
\begin{equation}
\begin{split}
L_{EL}(\pmb{\theta}) & \sim \exp\left( l_{EL} (\pmb{\theta})\right), \\
\pmb{\theta}|\pmb{\tau},\sigma^2 &\sim \prod_{j=1}^{p} N\left(0, \left(\dfrac{\lambda_2}{\sigma^2} \dfrac{\tau_j}{\tau_j-1} \right)^{-1}\right),\\
\pmb{\tau}|\sigma^2 &\sim \prod_{j=1}^{p} TG\left(\dfrac{1}{2}, \dfrac{\lambda_1^2}{8\lambda_2\sigma^2}, (1,\infty)\right),\\
\sigma^2 &\sim IG(a,b),\\
\end{split}
\label{M6}
\end{equation}
where $\pmb{\tau}$ follows the truncated gamma distribution from 1 to $\infty$ with the shape parameter $1/2$ and the rate parameter $\lambda_1^2/\lambda_2\sigma^2$. The full joint posterior density is as follows
\begin{equation}
\begin{split}
\pi\left(\pmb{\theta},\;\pmb{\tau},\,\sigma^2|X,\;\pmb{y}\right) \propto& L_{EL}\left(\pmb{\theta}\right)\times \prod_{j=1}^{p}\left(\dfrac{\lambda_2}{\sigma^2}\dfrac{\tau_j}{\tau_j-1} \right)^{\frac{1}{2}} \exp\left( -\dfrac{1}{2}\dfrac{\lambda_2}{\sigma^2}\dfrac{\tau_j}{\tau_j-1}\theta_j^2\right)\\
&\times \prod_{j=1}^{p} \left(\frac{\lambda_1^2}{8\lambda_2\sigma^2}\right)^{\frac{1}{2}} \tau_j^{-\frac{1}{2}}\exp\left(-\tau_j\dfrac{\lambda_1^2}{8\lambda_2\sigma^2} \right)I\left(\tau_j \in (1,\infty) \right) \\
& \times \left(\frac{1}{\sigma^2}\right)^{a+1} \exp\left(-\frac{b}{\sigma^2}\right).
\end{split}
\label{M7}
\end{equation}
To sample from the posterior $\pi\left(\pmb{\theta},\;\pmb{\tau},\,\sigma^2|X,\;\pmb{y}\right)$, we draw from the following conditional distributions
\begin{enumerate}
\item[1.] Sample $\pmb{\theta}$ from
\[L_{EL}\left(\pmb{\theta}\right)\exp\left( -\dfrac{\lambda_2}{2\sigma^2}\sum_{j=1}^{p}\dfrac{\tau_j}{\tau_j-1}\theta_j^2 \right).
\]
\item[2.] Sampling $\tau_j$ is equivalent to sampling $\tau_j-1$ from
\[
\text{GIG}\left(\nu= \dfrac{1}{2},\; \psi=\;\dfrac{\lambda_1^2}{4\lambda_2\sigma^2},\;\chi=\dfrac{\lambda_2}{\sigma^2}\theta_j^2\right) \text{ for } j=1,\cdots,p.
\]
\item[3.] Sample $\sigma^2$ from
\[
\text{IG}\left(a+p,\;b+ \dfrac{1}{2}\sum_{j=1}^{p}\left[ \lambda_2\dfrac{\tau_j}{\tau_j -1}\theta_j^2 + \dfrac{\lambda_1^2}{4\lambda_2}\tau_j \right] \right).
\]
\end{enumerate}
Here, $\text{GIG}(\nu,\;\psi,\;\chi)$ is the generalized inverse Gaussian distribution with probability density function $\dfrac{\left(\psi/\chi\right)^{\nu/2}}{2K_{\nu}\left(\sqrt{\psi\chi} \right)}x^{\nu-1}\exp\left\{-\dfrac{1}{2}\left(\chi x^{-1} +\psi x\right) \right\}$ for $x>0$, where $K_{\nu}\left(\cdot\right)$ is the modified Bessel function of the third kind with order $\nu$. We use the rejection algorithm proposed by \cite{Hormann2014} to generate samples from the generalized inverse Gaussian distribution.
The posterior estimates of BEN based on EL estimates are consistent.
As the sample size increases, the estimates converge to the true value of the parameter being estimated.
The consistency of the estimators under the BEL framework has been proved for the quantile regression \citep{Yunwen2012} and the penalized regression \citep{Adel2020}, and it can be easily extended to the proposed estimates.
\subsection{Hamiltonian Monte Carlo sampling for Bayesian empirical likelihood}
Implementing traditional sampling methods like Gibbs sampler and Metropolis-Hastings (MH) under the Bayesian empirical likelihood framework is a daunting task. First, the conditional distribution of $\pmb{\theta}$ has a non-closed form, which makes the implementation of the Gibbs sampler impossible. Second, implementing MH is suitable to sample from a distribution that lacks a closed form, but it may fail to achieve convergence. In addition, the nature of the posterior density support complicates the process of finding an efficient proposal density. The support of the posterior EL is nonconvex with many local optima where its surface is rigid. In these cases, the chain can be trapped in a region and not reach the global optimum. Therefore, it is challenging to find the proper proposal density that provides a high acceptance right with the appropriate location and dispersion parameters.
We use HMC \citep{HMC2011} to sample $\pmb{\theta}$, inspired by \cite{Chaudhuri2017}.
Let $\pmb{\theta}$ be the current position vector and $\pmb{m}\sim N(0,M)$ be the momentum vector where $M$ is the dispersion matrix.
The Hamiltonian is defined by the joint distribution of $\pmb{\theta}$ and $\pmb{m}$ that can be represented as the the sum of potential energy $U(\pmb{\theta})$ and kinetic energy $K(\pmb{m})$,
\begin{eqnarray}
H(\pmb{\theta},\pmb{m}) &=& U(\pmb{\theta}) + K(\pmb{m}) \nonumber \\
&=& - \log \pi (\pmb{\theta}) + \frac{1}{2}\pmb{m}^TM^{-1}\pmb{m}
\label{eq:potential}
\end{eqnarray}
The partial derivatives of Hamiltonian determine how the $\pmb{\theta}$ transits to a new state,
\begin{eqnarray*}
\frac{d \pmb{\theta}}{d t} &=& \frac{\partial H}{\partial \pmb{m}} \\
\frac{d \pmb{m}}{d t} &=& -\frac{\partial H}{\partial \pmb{\theta}}.
\end{eqnarray*}
The Hamiltonian dynamics has reversible, invariant, and volume-preserving properties that enable MCMC updates \citep{HMC2011}. The Hamiltonian equations are computed by discretizing the small time interval $\omega$. The leapfrog integrator is the most widely-used method to implement HMC.
First, given the current time $t$ and the position $\pmb{\theta}$, the momentum $\pmb{m}$ is independently drawn from $N(0,M)$. Then the position and the momentum at time $t+\omega$ is updated as follows:
\begin{eqnarray*}
\pi\left( t+\frac{1}{2}\omega \right) &=& \pi(t)-\frac{\omega}{2}\frac{\partial U}{\partial \pmb{\theta}} \\
\pmb{\theta}(t+\omega) &=& \pmb{\theta}(t) + \omega M^{-1}\pi\left( t+\frac{1}{2}\omega \right) \\
\pi\left( t+\omega \right) &=& \pi\left( t+\frac{1}{2}\omega \right) -\frac{1}{2}\frac{\partial U}{\partial \pmb{\theta}}(\pmb{\theta}(t+\omega)).
\end{eqnarray*}
The proposed state $(\pmb{\theta^*},\pmb{m^*})$ is obtained after repeating the above updates $T$ times. Here, $\omega$ and $T$ are also called the step size and leapfrog steps, respectively. The proposed state is accepted with the probability
\begin{equation*}
\min \left[ 1, \exp (-H(\pmb{\theta^*},\pmb{m^*})+H(\pmb{\theta},\pmb{m})) \right].
\end{equation*}
HMC is known to be more efficient than random-walk-based MH in sampling from the posterior for Bayesian EL. First, \cite{Chaudhuri2017} show that once the parameters are inside the support, the HMC chain does not go outside and return to the interior of the support if they reach its boundary under certain assumptions. This is due to the property of $l_{EL}(\pmb{\theta})$, whose gradient diverges at the boundary. Second, HMC converges quickly towards the target distribution and enables faster convergence. In HMC, distances between successively generated points are large. Thus, fewer iterations are required to obtain a representative sample.
The performance of an HMC depends on its parameters, and it is known that tuning them is important \citep{HMC2011, hoffman2014no}. However, the optimal HMC parameter tuning procedure for BEL is not discussed in \cite{Chaudhuri2017}. It is generally suggested to set a sufficiently small leapfrog step size $\omega$ to ensure that the discretization is good and use sufficiently large leapfrog steps $T$ so that the overall trajectory length $\omega T$ is not too short. However, setting a large $T$ could be inefficient for HMC used in the BEL framework. This is because each leapfrog step requires computationally expensive EL computation. Therefore, we fix the leapfrog steps to $T=10$ and find the optimal step size $\omega$ in our study.
We develop the leapfrog step size tuning algorithm for BEL based on the bisection method \citep{burden2015numerical}. The optimal step size will achieve the known theoretical optimal acceptance rate of 65.1\% \citep{beskos2013optimal}. For a fixed $T$, a larger step size tends to lower an acceptance rate and vice versa. For given lower and upper tolerance levels for acceptance rates, $\iota_l$ and $\iota_u$, respectively, the proposed algorithm searches for $\omega$ that results in a high acceptance rate, greater than $0.651+\iota_u$, while increasing it by $\varepsilon$. If the acceptance rate is within the target range $[0.651-\iota_l,0.651+\iota_u]$, then $\omega$ is selected. On the other hand, if the step size makes the acceptance rate $>0.651+\iota_u$, the method bisects the interval $[\omega-\varepsilon,\omega]$. The bisection procedure is repeated until the acceptance rate reaches the target range. Compared to the grid search algorithm, the proposed algorithm converges to the target acceptance rate range linearly and enables finer and computationally efficient step size tuning. The detailed bisection algorithm is given in Algorithm~\ref{alg:cap}. One can also consider implementing the No-U-Turn sampler (NUTS) \citep{hoffman2014no} that automatically selects the leapfrog steps and step size. We discuss this in Section~\ref{sec:conclusion}.
\begin{algorithm}
\caption{Bisection leapfrog step size tuning algorithm for Bayesian EL}\label{alg:cap}
\begin{algorithmic}
\Require itermax, (initial) $\omega$, $T$, and lower and upper tolerances $\iota_l$ and $\iota_u$
\Ensure acceptance rate and (updated) $\omega$
\State $\varepsilon \gets \omega$
\State scounter $\gets 0$
\State iter $\gets 1$
\While{$\text{iter} \leq \text{itermax} $}
\State Simulate HMC chain using step size $\omega$ for a given $T$ and compute acceptance rate
\If{acceptance rate $ \in [0.651 - \iota_l, 0.651 + \iota_u]$}
\State \textbf{break}
\ElsIf{acceptance rate $ > (0.651 + \iota_u)$}
\If{scounter = 0}
\State $\varepsilon \gets \varepsilon$ \Comment{Do not change $\varepsilon$ if $\omega$ has not decreased before}
\Else
\State $\varepsilon \gets \varepsilon/2$
\EndIf
\State $\omega \gets \omega + \varepsilon$ \Comment{Update $\omega$ by increasing $\varepsilon$}
\ElsIf{acceptance rate $ < (0.651 - \iota_l)$}
\State scounter $+= 1$
\State $\varepsilon \gets \varepsilon/2$
\State $\omega \gets \omega - \varepsilon$ \Comment{Update $\omega$ by decreasing $\varepsilon$}
\EndIf
\State iter $+=1$
\EndWhile
\end{algorithmic}
\end{algorithm}
We run a single chain of length 2,000 with 1,000 burn-ins for quicker step size tuning. For the estimation of $\pmb{\theta}$, we simulate four chains of length 2,000 with 1,000 burn-ins, respectively.
The convergence of simulated chains are examined with the split-$\widehat{R}$ of \cite{vehtari2021rank}
\begin{eqnarray*}
\widehat{R}=\sqrt{\frac{\widehat{\text{var}}^{+}(\pmb{\theta}\mid X,\pmb{y})}{W}},
\end{eqnarray*}
where $\widehat{\text{var}}^{+}(\pmb{\theta}\mid X,\pmb{y})=\frac{N_s-1}{N_s} W + \frac{1}{N_s} B$, $W$ and $B$ are the within- and between-chain variances, and $N_s$ is the number of draws of one chain. Followed by \cite{vehtari2021rank}, we use the posterior samples that satisfy the convergence criteria $\widehat{R}<1.01$.
\subsection{Choosing Bayesian elastic net penalty parameters}
\label{subsec:pp}
The proposed EL based approach needs to specify the penalty parameters $\pmb{\lambda}=(\lambda_1,\lambda_2)$. We consider two approaches: empirical Bayes (EB) and full Bayes (FB).
First, the EB method estimates the penalty parameter from data and plugs the estimated parameters into the model.
\cite{bayeslasso} use the EB method to estimate the shrinkage parameter in BL.
It treats the parameters as missing data and uses the Monte Carlo expectation-maximization (EM) algorithm approach proposed by \cite{Casella2001}.
The EM algorithm is iteratively used to approximate the parameters of interest by substituting Monte Carlo estimates for any expected values that cannot be computed explicitly.
For our proposed model, $\pmb{\theta},\;\pmb{\tau},$ and $\sigma^2$ are treated as missing data whereas $\lambda_1$ and $\lambda_2$ are treated as fixed parameters.
We use a building block of HMC and the Gibbs sampler to sample $\pmb{\theta}$, $\pmb{\tau}$ and $\sigma^2$. The negative log empirical posterior density of $\pmb{\theta}$ in (\ref{eq:potential}) is defined as
\[
-\log\left\{ \pi\left(\pmb{\theta}|\sigma^2,\tau_1^2,\cdots,\tau_p^2 \right)\right\} =\sum_{i=1}^{n}\log \left\{ 1+\pmb{\gamma}^T\pmb{x_i}\left( y_i-\pmb{x_i}^{T}\pmb{\theta} \right) \right\}+\dfrac{\lambda_2}{2\sigma^2}\pmb{\theta}^T\mathit{D}_{\tau}^{-1}\pmb{\theta},
\]
where $\mathit{D}_{\tau} = \text{diag}\left( \dfrac{\tau_1}{\tau_1 -1},\cdots, \dfrac{\tau_p}{\tau_p -1}\right)$ and its gradient is defined as
\[
-\dfrac{\partial \log\left\{ \pi\left(\pmb{\theta}|\sigma^2,\tau_1^2,\cdots,\tau_p^2 \right)\right\}}{\partial \pmb{\theta}}=\sum_{i=1}^{n} \dfrac{-\pmb{\lambda}^T\pmb{x_ix_i}^T}{1+\pmb{\gamma}^T\pmb{x_i}\left( y_i-\pmb{x_i}^{T}\pmb{\theta}\right) }+ \dfrac{\lambda_2}{\sigma^2}\pmb{\theta}^T\mathit{D}_{\tau}^{-1}.
\]
The hierarchical model presented in (\ref{M7}) yields the complete-data log-likelihood
\begin{equation*}
p\log(\lambda_1)-\frac{\lambda_2}{2\sigma^2}\sum\limits_{j=1}^{p} \frac{\tau_j}{\tau_j-1}\theta_j^2 - \frac{\lambda_1^2}{8\lambda_2\sigma^2} \sum\limits_{j=1}^p \tau_j+\text{terms not involving $\lambda_1$ and $\lambda_2$}.
\end{equation*}
So at the $k$th step of the Monte Carlo EM algorithm, the conditional log-likelihood on $\pmb{\lambda}^{(k-1)}=\left( \lambda_1^{(k-1)},\lambda_2^{(k-1)} \right)$ and $\pmb{y}$ is
\begin{equation*}
\begin{split}
&Q(\pmb{\lambda}|\pmb{\lambda}^{(k-1)})\\
&= p\log(\lambda_1)-\frac{\lambda_2}{2}\sum\limits_{j=1}^{p} E\left[ \frac{\tau_j}{\tau_j-1} \frac{\theta_j^2}{\sigma^2} \middle| \pmb{\lambda}^{(k-1)},\pmb{y} \right] - \frac{\lambda_1^2}{8\lambda_2} \sum\limits_{j=1}^p E\left[\frac{\tau_j}{\sigma^2} \middle| \pmb{\lambda}^{(k-1)},\pmb{y} \right] \\
& + \text{terms not involving $\lambda_1$ and $\lambda_2$} \\
&= R(\pmb{\lambda}|\pmb{\lambda}^{(k-1)}) + \text{terms not involving $\lambda_1$ and $\lambda_2$}.
\end{split}
\end{equation*}
Then we find $\lambda_1$ and $\lambda_2$ that maximize $ R(\pmb{\lambda}|\pmb{\lambda}^{(k-1)})$. The maximization procedure can be obtained by using the partial derivatives of $R(\pmb{\lambda}|\pmb{\lambda}^{(k-1)})$
\begin{equation*}
\begin{split}
\frac{\partial R}{\partial \lambda_1}&= \frac{p}{\lambda_1}- \frac{\lambda_1}{4\lambda_2} \sum\limits_{j=1}^p E\left[\frac{\tau_j}{ \sigma^2} \middle| \pmb{\lambda}^{(k-1)},\pmb{y} \right] \\
\frac{\partial R}{\partial \lambda_2}&= -\frac{1}{2}\sum\limits_{j=1}^{p} E\left[ \frac{\tau_j}{\tau_j-1}\frac{\theta_j^2}{\sigma^2} \middle| \pmb{\lambda}^{(k-1)},\pmb{y} \right] + \frac{\lambda_1^2}{8\lambda_2^2} \sum\limits_{j=1}^p E\left[\frac{\tau_j}{\sigma^2} \middle| \pmb{\lambda}^{(k-1)},\pmb{y} \right].
\end{split}
\end{equation*}
Here, the expectations in $Q$ and $R$ are evaluated by using the means of sampled $\pmb{\theta}$, $\pmb{\tau}$, and $\sigma^2$.
Second, the FB approach treats $\pmb{\lambda}$ as unknown model parameters and specify a prior for them. \cite{bayeslasso} suggest to use the gamma prior for the squared value of $l_1$ penalty for Bayesian Lasso. We also assume the $\text{Gamma}(r_1,\delta_1)$ prior on $\lambda_1^2$. Also, we place a $\text{GIG}(\nu_2,\;\psi_2,\;\chi_2)$ prior on $\lambda_2$, which is a conjugate prior \citep{Ben2010}. The full joint posterior density becomes
\begin{equation*}
\begin{split}
\pi\left(\pmb{\theta},\;\pmb{\tau},\,\sigma^2,\lambda_1^2, \lambda_2|X,\;\pmb{y}\right) \propto& L_{NP}\left(\pmb{\theta}\right)\times \prod_{j=1}^{p}\left(\dfrac{\lambda_2}{\sigma^2}\dfrac{\tau_j}{\tau_j-1} \right)^{\frac{1}{2}} \exp\left( -\dfrac{1}{2}\dfrac{\lambda_2}{\sigma^2}\dfrac{\tau_j}{\tau_j-1}\theta_j^2\right)\\
&\times \prod_{j=1}^{p} \left(\frac{\lambda_1^2}{8\lambda_2\sigma^2}\right)^{\frac{1}{2}}\tau_j^{-\frac{1}{2}}\exp\left(-\tau_j\dfrac{\lambda_1^2}{8\lambda_2\sigma^2} \right)I\left(\tau_j \in (1,\infty) \right) \\
& \times \left(\frac{1}{\sigma^2}\right)^{a+1} \exp\left(-\frac{b}{\sigma^2}\right) \times \left(\lambda_1^2\right)^{r_1-1} \exp\left(-\delta_1\lambda_1^2\right) \\
& \times \left(\lambda_2\right)^{\nu_2-1} \exp\left\{-\frac{1}{2}\left(\chi_2\frac{1}{\lambda_2}+ \psi_2\lambda_2\right) \right\}.
\end{split}
\label{M13}
\end{equation*}
The full conditional distributions for the penalty parameters are
\begin{equation*}
\begin{split}
\lambda_1^2 | \pmb{\tau}, \sigma^2, \lambda_2 &\sim \text{Gamma}\left( \frac{p}{2}+ r_1,\sum_{j=1}^p \frac{\tau_j}{8\lambda_2\sigma^2}+\delta_1\right) \\
\lambda_2 | \pmb{\tau}, \sigma^2, \lambda_1^2, \pmb{\theta} &\sim \text{GIG} \left(\nu = \nu_2, \psi = \sum\limits_{j=1}^p \frac{\tau_j}{\tau_j-1}\frac{\theta_j^2}{\sigma^2} + \psi_2, \chi = \sum\limits_{j=1}^p \frac{\tau_j \lambda_1^2}{4\sigma^2} + \chi_2 \right).
\end{split}
\end{equation*}
An alternative prior for $\lambda_2$ to consider is $\text{Gamma}(r_2,\delta_2)$. Then, the full conditional distribution becomes
\begin{equation*}
\begin{split}
\lambda_2 | \pmb{\tau}, \sigma^2, \lambda_1^2, \pmb{\theta} &\sim \text{GIG} \left(\nu = r_2, \psi = \sum\limits_{j=1}^p \frac{\tau_j}{\tau_j-1}\frac{\theta_j^2}{\sigma^2} + 2\delta_2, \chi = \sum\limits_{j=1}^p \frac{\tau_j \lambda_1^2}{4\sigma^2} \right).
\end{split}
\end{equation*}
The gamma distribution is a special case of the GIG distribution family with $\chi=0$. Thus, placing a gamma prior on $\lambda_2$ results on a posterior distribution that follows a GIG distribution
\subsection{Variable selection methods}
\label{sec:CI}
The Bayesian regularization approaches require additional variable selection methods. In most non-Bayesian penalized methods, the estimated coefficients shrink to zero. On the other hand, the outputs of Bayesian models are the posterior distributions, which are not necessarily equal to zero. We present two variable selection methods: Bayesian credible interval and scaled neighborhood criteria.
First, the Bayesian credible interval can be used to select variables whose credible regions do not include zero for a given probability level $\alpha$ \citep{li2011bayesian}.
\cite{Lazar2003} proves that under standard regularity conditions and as $n \rightarrow \infty$, the posterior EL distribution $\pmb{\theta}(F)$ converges to the normal distribution.
\cite{Adel2020} show that the asymptotic posterior distribution of the BEL version of ridge and lasso regressions follows the normal distribution.
Lemma~\ref{lemma} shows that the posterior EL distribution of $\pmb{\theta}$ for the elastic net model converges to a normal distribution as $n \rightarrow \infty$. However, we want to note that the Bayesian credible interval may include zero in the presence of strong correlation among explanatory variables because of bimodality of the posterior of the regression parameters \citep{pasanen2015bayesian}.
\begin{lemma} Assume standard regularity conditions, $\nabla \log\left( \pi(\pmb{\theta}) \right) = 0$ and $\nabla \log\left( \pi(X,\pmb{y}| \pmb{\theta})\right) = 0$. The posterior EL distribution of $\pmb{\theta}$ for the Bayesian elastic net converges to the normal distribution with mean $\pmb{m}$ and covariance $\mathit{J_n}$ as $ n \rightarrow \infty$, where
\[
\begin{split}
\mathit{J_n}&=\dfrac{\lambda_2}{\sigma^2}D_{\tau} + \mathit{J}(\pmb{\hat{\theta}}_n),\\
\pmb{m}&= \mathit{J_n}^{-1}
\left( \dfrac{\lambda_2}{\sigma^2}D_{\tau} \pmb{\theta_0} +\mathit{J}(\pmb{\hat{\theta}}_n)\pmb{\hat{\theta}}_n\right),\\
\end{split}
\]
$\pmb{\theta_0}$ is the prior mode,
$\pmb{\hat{\theta}}_n$ is the profile maximum likelihood estimate of $\pmb{\theta}$ and
\[
\mathit{J}(\pmb{\hat{\theta}}_n) = \left[ \dfrac{\partial^2}{\partial \theta_i\partial \theta_j}\sum_{i=1}^{n}\log \left\{ 1+\pmb{\gamma}^T\pmb{x_i}(y_i-\pmb{x_i}^T\pmb{\theta})\right\} \right]_{\pmb{\theta}=\pmb{\hat{\theta}}_n}.
\]
Also, $-2\log\left(\pi(\pmb{\theta}|\bm \tau, \sigma^2,\mathit{X},\pmb{y}) \right) \xrightarrow{d} \chi_p^2$ as $ n \rightarrow \infty$.
\label{lemma}
\end{lemma}
\begin{proof}
Under the standard regularity conditions, the prior term is dominated by the likelihood function, and the log posterior distribution of $\pmb{\theta}$ can be expressed using up to quadratic order terms \citep{Bernardo1994},
\begin{equation*}
-2\log\left(\pi(\pmb{\theta}|\bm \tau, \sigma^2,\mathit{X},\pmb{y}) \right) \propto (\pmb{\theta}-\pmb{m})^TJ_n^{-1}(\pmb{\theta}-\pmb{m}).
\end{equation*}
\cite{Lazar2003} shows that the posterior distribution of $\pmb{\theta}$ converges to normal distribution with mean $\pmb{m}$ and variance $J_n$ as $n\rightarrow \infty$. Then, showing $J_n$ is symmetric and positive semi-definite completes the proof.
First, the first term of $J_n$, the diagonal matrix $\dfrac{\lambda_2}{\sigma^2}D_{\tau}$, is the minus second derivative of the log prior distribution of $\pmb{\theta}$ in (\ref{M6}) evaluated at $\pmb{\theta}_0$.
Also, the second term of $J_n$, $J(\pmb{\theta})$, can be approximated as Fisher information matrix \citep{Bernardo1994}, which is a positive semi-definite matrix by definition.
Therefore, $J_n$ is positive semi-definite because both $\dfrac{\lambda_2}{\sigma^2}D_{\tau}$ and $\mathit{J}(\pmb{\hat{\theta}}_n)$ positive semi-definite. Thus, $-2\log\left(\pi(\pmb{\theta}|\bm \tau, \sigma^2,\mathit{X},\pmb{y}) \right) \xrightarrow{d} \chi_p^2$ as $ n \rightarrow \infty$.
\end{proof}
Second, the scaled neighborhood criterion uses the posterior probability to select variables \citep{Ben2010}. The variable $\theta_j$ is excluded when the posterior probability $P\left(|\theta_j| \leq \sqrt{\text{Var} (\theta_j \mid \pmb{y})} \mid \pmb{y}\right)$ is greater than $\eta$ for a given threshold $\eta$.
\section{Simulation studies}
\label{sec:sim}
We conduct Monte Carlo simulations to compare the performance of the proposed Bayesian elastic net based on the empirical likelihood (BEN-EL) model with four different models: BEN, BL, EN, and lasso applied to the least absolute deviation regression (LADL). LADL is known to be robust to heavy tail errors and outliers \citep{wang2007robust}.
We generate data from the linear model
\begin{equation*}
\pmb{y}=\pmb{X}\pmb{\theta}+\epsilon.
\end{equation*}
Note that BEN-EL and LADL assume that the mean and the median of errors are zero, respectively. On the other hand, BEN, BL, and EN assume normal errors.
\subsection{Prediction performance}
\label{subsec:sim.pred}
\paragraph{Simulation 1}
In Simulation 1, we set $\pmb{\theta}=(3,1.5,0,0,2,0,0,0)^T$. The explanatory variables $X_{ij}$'s are generated from the standard normal distribution with pairwise correlations $\rho(x_i,x_j)=0.5^{|i-j|}$ for all $i,j\in\{1,...,8\}$. We generate training data sets with three different sizes ($n=50, 100, 200$). For each setting, we generate test data sets of size $400$.
The error is generated from three different distributions: 1) normal distribution, $\epsilon \sim N(0,3^2)$, 2) non-normal distribution, $\epsilon \sim N(-3,1)$ or $\epsilon \sim N(3,1)$ with probability of 0.5, respectively, and 3) skew Student $t$ distribution proposed by \cite{fernandez1998bayesian}, $\epsilon \sim ST(\nu=30,\xi=1.5)$ with mean 0 and standard deviation 3. We use the R package fGarch \citep{fGarch} to sample from the skew Student $t$ distribution. The sampling procedures are repeated 100 times for each simulation setting.
The shrinkage parameters $\lambda_1$ and $\lambda_2$ are estimated using the EB method for BEN-EL, BEN, and BL methods. For BEN-EL, the hyperparameters $a=10$ and $b=10$ are used. For the bisection step size tuning, the initial step size $\omega=0.5$ and tolerances $\iota_l=\iota_u=0.05$ are used.
For BEN and BL, we use MCMC with 2,000 burn-ins and 12,000 iterations.
The optimal value for $\lambda_2$ in EN is selected from $\{10^n \mid n = -2,-1,0,1,2,3 \}$.
In all cases, the simulated HMC chains meet the convergence criteria $\widehat{R}<1.01$. The trace plots and histograms of estimated $\pmb{\theta}$ by BEN-EL for one dataset of skew Student $t$ errors and $n=50$ are given in Figures~\ref{sfig:sim1theta} and \ref{sfig:sim1hist} in Supplementary material.
\begin{table}[!ht]
\centering
\caption{The median of mean squared prediction errors (MMSPE) along with the standard errors (SE) of BEN-EL, BEN, BL and EN methods for Simulation 1. The smallest MMSPEs are marked in bold.}\label{tb:sim1.rmse}
\resizebox{\columnwidth}{!}{
\begin{tabular}{clrrrrr}
\hline
\multicolumn{1}{c}{Error} & \multicolumn{1}{l}{} & \multicolumn{5}{c}{MMSPE (SE)} \\ \cline{3-7}
& & \multicolumn{1}{c}{BEN-EL} & \multicolumn{1}{c}{BEN} & \multicolumn{1}{c}{BL} & \multicolumn{1}{c}{EN}
& \multicolumn{1}{c}{LADL}
\\ \hline
$N(0,3^2)$ & $n=50$ & 10.24 (0.18) & 11.33 (0.25) & \textbf{10.00 (0.16)} & 10.43 (0.15) & 11.07 (0.18) \\
& $n=100$ & 9.61 (0.10) & 11.65 (0.19) & \textbf{9.55 (0.10)} & 9.73 (0.10) & 9.96 (0.15) \\
& $n=200$ & 9.13 (0.07) & 11.65 (0.10) & \textbf{9.10 (0.08)} & 9.17 (0.07) & 9.36 (0.12) \\ \hline
$N(3,1)$ & $n=50$ & \textbf{10.80 (0.12)} & 12.33 (0.25) & 10.91 (0.12) & 11.20 (0.17) & 14.37 (0.29) \\
or & $n=100$ & \textbf{10.49 (0.11)} & 12.36 (0.21) & 10.49 (0.11) & 10.68 (0.09) & 13.09 (0.18) \\
$N(-3,1)$ & $n=200$ & 10.29 (0.05) & 12.66 (0.13) & \textbf{10.27 (0.06)} & 10.34 (0.07) & 12.52 (0.10) \\ \hline
Skew & $n=50$ & \textbf{90.20 (0.99)} & 91.38 (1.30) & 91.83 (1.22) & 93.93 (1.30) & 92.29 (0.76) \\
Student $t$ & $n=100$ & 86.31 (1.26) & 86.77 (1.07) & \textbf{86.09 (1.12)} & 88.50 (1.48) & 88.15 (1.08) \\
& $n=200$ & \textbf{83.56 (0.80)} & 83.95 (0.68) & 83.66 (0.76) & 84.51 (0.89) & 84.81 (1.05) \\ \hline
\end{tabular}
}
\end{table}
BEN-EL outperforms the other methods when the number of observations is small ($n=50,100$) and the normality assumption in errors is violated.
Table~\ref{tb:sim1.rmse} presents the median of mean squared prediction error (MMSPE) and the standard error (SE) results based on Simulation 1. For Bayesian methods, the explanatory variables are selected based on the scaled neighborhood criterion with $\eta>0.5$ in computing MMSPE. The SE is computed as a standard deviation of 1,000 bootstrap samples of mean squared prediction error values.
\begin{table}[!ht]
\centering
\caption{The empirical frequency (\%) that the regression coefficient is dropped for Simulation 1 with errors from $N(3,1)$ or $N(-3,1)$. For BEN-EL, BEN, and BL, the scaled neighborhood criterion with $\eta>0.5$ is used. }\label{tb:sim1.num}
\begin{tabular}{lcrrrrrrrr}
\hline
& \multicolumn{1}{l}{} & \multicolumn{8}{c}{Empirical frequency of exclusion} \\ \cline{3-10}
& \multicolumn{1}{l}{} & \multicolumn{1}{c}{$\theta_1$} & \multicolumn{1}{c}{$\theta_2$} & \multicolumn{1}{c}{$\theta_3$} & \multicolumn{1}{c}{$\theta_4$} & \multicolumn{1}{c}{$\theta_5$} & \multicolumn{1}{c}{$\theta_6$} & \multicolumn{1}{c}{$\theta_7$} & \multicolumn{1}{c}{$\theta_8$} \\ \hline
\multirow{3}{*}{$n=50$} & BEN-EL & 0 & 0 & 58 & 69 & 0 & 65 & 75 & 64 \\
& BEN & 0 & 0 & 34 & 39 & 0 & 53 & 80 & 76 \\
& BL & 0 & 3 & 69 & 76 & 0 & 77 & 82 & 75
\\
& LADL & 0 & 18 & 70 & 76 & 9 & 86 & 90 & 82\\ \hline
\multirow{3}{*}{$n=100$} & BEN-EL & 0 & 0 & 70 & 61 & 0 & 59 & 72 & 69 \\
& BEN & 0 & 0 & 13 & 15 & 0 & 34 & 73 & 74 \\
& BL & 0 & 0 & 80 & 73 & 0 & 75 & 82 & 77 \\
& LADL & 0 & 12 & 76 & 73 & 5 & 81 & 88 & 84 \\ \hline
\multirow{3}{*}{$n=200$} & BEN-EL & 0 & 0 & 56 & 66 & 0 & 68 & 74 & 62 \\
& BEN & 0 & 0 & 2 & 3 & 0 & 17 & 68 & 82 \\
& BL & 0 & 0 & 69 & 69 & 0 & 75 & 82 & 75 \\
& LADL & 0 & 6 & 77 & 71 & 0 & 81 & 88 & 84 \\ \hline
\end{tabular}
\end{table}
Table~\ref{tb:sim1.num} reports the number of exclusion of each variable for 100 simulated data sets for BEN-EL, BEN, BL, and LADL. The variable selection results for EN are not included because all the estimated coefficients are nonzero. LADL performs the best in dropping variables with zero coefficients ($\theta_3$, $\theta_4$, $\theta_6$, $\theta_7$, and $\theta_8$) but some nonzero coefficients ($\theta_1$, $\theta_2$, and $\theta_5$) are also excluded. Among the Bayesian methods, BL best identifies the zero coefficients. However, the MMSPEs for BL are larger than BEN-EL for $n=50,100$. This implies that BEN-EL makes more accurate estimates even though their zero variables exclusion rate is worse than BL.
\paragraph{Simulation 2}
Simulation 2 dataset has a more complex correlation structure than Simulation 1.
First, we generate $Z_1$, $Z_2$, and $Z_3$ independently from $N(0,1)$. Then, we add normal errors so that $x_i=Z_1+\upsilon_i$ for $i=1,\ldots,5$, $x_i=Z_2+\upsilon_i$ for $i=6,\ldots,10$, $x_i=Z_3+\upsilon_i$ for $i=11,\ldots,15$, and $x_i \sim N(0,1)$ for $i=16,\ldots,30$, where $\upsilon_i \sim N(0,0.01)$ for $i=1,\ldots,15$. As a result, the variables in the first three groups are highly correlated within each group. We set the true parameters of the linear model as
\begin{equation*}
\pmb{\theta}=(\underbrace{3,\cdots,3}_{5},\underbrace{3,\cdots,3}_{5},\underbrace{3,\cdots,3}_{5},\underbrace{0,\cdots,0}_{15})^T.
\end{equation*}
We generate error $\epsilon$ using three different distributions: 1) normal distribution, $\epsilon \sim N(0,15^2)$, 2) Student $t$ distribution with degrees of freedom 3, $\epsilon \sim 10 \times t_3 $, and 3) skew Student $t$ distribution, $\epsilon \sim ST(\nu=30,\xi=1.5)$.
The normal and $t$ distributions are symmetric and have similar variances, but the $t$ distribution has a thicker tail than the normal distribution. On the other hand, the skew Student $t$ distribution is right-skewed.
We use training data sets with two different sizes ($n=100,200$) and fix the size of testing data sets to $400$. We generate 100 data sets for each simulation setting.
For the other simulation parameters, we use the same setting used in Simulation 1.
For BEN-EL, the simulated HMC chains converge with $\widehat{R}<1.01$ in all simulation settings. We also present the trace plots and histograms of four nonzero coefficients $(\theta_1,\theta_2,\theta_3,\theta_4)$ and four zero elements $(\theta_{16},\theta_{17},\theta_{18},\theta_{19})$ estimated by BEN-EL for one dataset of the skew Student $t$ errors and $n=100$ in Figures~\ref{sfig:sim2theta} and \ref{sfig:sim2hist} in Supplementary material.
\begin{table}[!ht]
\centering
\caption{The median of mean squared prediction errors (MMSPE) along with the standard errors (SE) of BEN-EL, BEN, BL, EN, and LADL methods for Simulation 2. The smallest MMSPEs are marked in bold.}\label{tb:sim2.rmse}
\resizebox{\columnwidth}{!}{%
\begin{tabular}{clrrrrr}
\hline
\multicolumn{2}{l}{\multirow{2}{*}{}} & \multicolumn{5}{c}{MMSPE (SE)} \\ \cline{3-7}
\multicolumn{2}{l}{} & \multicolumn{1}{c}{BEN-EL} & \multicolumn{1}{c}{BEN} & \multicolumn{1}{c}{BL} & \multicolumn{1}{c}{EN} & \multicolumn{1}{c}{LADL} \\ \hline
\multirow{2}{*}{Normal} & \multicolumn{1}{c}{$n=100$} & \textbf{281.98 (3.70)} & 291.44 (4.50) & 295.28 (4.16) & 309.52 (5.36) & 332.72 (3.42) \\
& \multicolumn{1}{c}{$n=200$} & 255.06 (2.58) & \textbf{254.12 (3.02)} & 258.17 (3.35) & 263.62 (3.42) & 323.32 (3.73) \\ \hline
\multirow{2}{*}{Student $t$} & $n=100$ & \textbf{334.10 (10.75)} & 344.72 (7.61) & 345.03 (7.79) & 380.51 (12.33) & 374.70 (5.78) \\
& $n=200$ & 313.37 (6.77) & \textbf{302.26 (6.46)} & 307.12 (6.62) & 311.59 (6.13) & 351.81 (7.51) \\ \hline
Skew & $n=100$ & \textbf{289.95 (4.03)} & 297.96 (4.43) & 301.23 (4.64) & 318.13 (8.88) & 344.05 (2.83) \\Student $t$
& $n=200$ & \textbf{253.97 (3.06)} & 255.24 (2.74) & 256.02 (2.97) & 262.62 (3.52) & 310.68 (4.33) \\ \hline
\end{tabular}
}
\end{table}
The simulation results suggest that BEN-EL outperforms when the sample size is small or the error follows the asymmetric distribution.
Table~\ref{tb:sim2.rmse} reports the MMSPE and SE results of Simulation 2.
In all cases, the Bayesian methods (BEN-EL, BEN, and BL) perform better than the non-Bayesian methods (EN and LADL), and the Bayesian EN methods (BEN-EL and BEN) perform better than the BL. This corresponds to the findings that the EN-based methods perform better than the lasso-based methods under the complex correlation structure \citep{Zou2005}.
For the symmetric error distributions (normal and Student $t$), BEN-EL provides the smallest MMSPE and SE values compared to BEN when the sample size is small. However, BEN-EL performs the best under the skewed error distribution regardless of the sample size.
Table~\ref{tb:sim2.var} presents the variable selection results. For the Bayesian methods, variables are selected using the scaled neighborhood criterion with $\eta>0.5$. The variable selection results for EN are not reported because its estimated coefficients are nonzero.
BEN-EL tends to keep more variables than BEN and BL for both nonzero and zero coefficients.
BEN and BL perform poorly in keeping nonzero variables when the sample size is small, but they improve as the sample size increases. LADL shows the highest exclusion rate for zero coefficients but removes many nonzero coefficients.
\begin{table}[!ht]
\centering
\caption{The empirical frequency (\%) that the 15 nonzero and 15 zero regression coefficients are dropped for Simulation 2. For Bayesian methods, the scaled neighborhood criterion with $\eta>0.5$ is used. }\label{tb:sim2.var}
\resizebox{\columnwidth}{!}{%
\begin{tabular}{ccrrrrrrrr}
\hline
\multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{8}{c}{Empirical frequency of exclusion} \\ \cline{3-10}
& & \multicolumn{2}{c}{BEN-EL} & \multicolumn{2}{c}{BEN} & \multicolumn{2}{c}{BL}
& \multicolumn{2}{c}{LADL} \\ \cline{3-10}
& & \multicolumn{1}{c}{Nonzero} & \multicolumn{1}{c}{Zero} & \multicolumn{1}{c}{Nonzero} & \multicolumn{1}{c}{Zero} & \multicolumn{1}{c}{Nonzero} & \multicolumn{1}{c}{Zero} & \multicolumn{1}{c}{Nonzero} & \multicolumn{1}{c}{Zero}\\ \hline
Normal & $n=100$ & 22.26 & 63.33 & 34.60 & 74.07 & 42.33 & 87.53 & 71.20 & 92.93 \\
& $n=200$ & 5.47 & 68.47 & 5.60 & 69.27 & 9.87 & 82.20 & 48.87 & 94.40 \\ \hline
\multirow{2}{*}{Student $t$} & $n=100$ & 23.73 & 59.13 & 41.73 & 78.40 & 48.93 & 88.47 &64.67 & 94.40 \\
& $n=200$ & 10.53 & 58.80 & 12.13 & 70.07 & 16.60 & 83.20 & 35.93 & 93.87 \\ \hline
Skew & $n=100$ & 21.53 & 61.07 & 32.53 & 76.00 & 38.67 & 87.53 & 72.07 & 94.00 \\
Student $t$ & $n=200$ & 5.40 & 65.47 & 5.67 & 66.53 & 8.40 & 81.07 & 45.67 & 92.73\\ \hline
\end{tabular}
}
\end{table}
\subsection{Sensitivity of Hyperparameters}
We examine the sensitivity of the hyperparameters of the penalty parameters $\lambda_1$ and $\lambda_2$ in BEN-EL for the FB approach.
\cite{Ben2010} suggest that the BEN posterior samples may be heavily dependent on the hyperparameters on the penalty parameters based on their experience. Still, it has not been investigated for BEN-EL.
Therefore, we investigate how the priors affect posterior inferences by changing hyperparameters: 1) $(r_1,\delta_1)$ of the gamma prior for $\lambda_1^2$ and 2) $(\psi_2, \chi_2)$ of the GIG prior for $\lambda_2$. In both simulations, we use one data set from Simulation 1 with $n=50$ and normal errors $N(0,3^2)$. For the gamma prior, 1,600 combinations of the shape and rate parameters $r_1$ and $\delta_1 \in \{ 0.25, 0.5, \ldots, 9.75, 10 \}$ are used. For the GIG prior, we fix $\chi_2=1$ and use 1,640 combinations of $\nu_2 \in \{-5, -4.75, \ldots ,4.75, 5\}$ and $\psi_2 \in \{ 0.25, 0.5, \ldots , 9.75, 10 \}$.
The shape and rate parameters $r_1$ and $\delta_1$ for the gamma prior and $\nu_2$ and $\chi_2$ for the GIG prior affect in the opposite directions for nonzero and zero coefficients. For example, as $r_1$ and $\nu_2$ increase and $\delta_1$ and $\chi_2$ decrease, the estimated nonzero coefficients will decrease, whereas the estimated zero coefficients will increase.
The step size $\omega$ is estimated by the proposed bisection algorithm using the same input parameters used in Simulation 1. We run four HMC chains of 2,000 iterations with 1,000 burn-ins. In all cases, the split-$\widehat{R}$'s are less than 1.01 and the HMC chains converge.
The estimated coefficients are affected by choice of the hyperparameters, but the variability is not large enough to interrupt overall inference. Figure~\ref{fig:senstivity} shows heatmaps of estimated coefficients of $\theta_1$ and $\theta_4$ according to different combinations of the hyperparameters.
The estimated coefficients are the median of the posteriors of $\theta_1$ and $\theta_4$ whose true values are 3 and 0, respectively.
We see the estimated coefficients vary according to the hyperparameters, but they are close to the true coefficients.
For example, the estimated $\theta_1$ differs only up to 0.15 and 0.4 for the various combinations of the hyperparameters of $\lambda_1^2$ and $\lambda_2$, respectively.
\begin{figure}[!ht]
\centering
{\hspace{0.1in} $\theta_1$ \hspace{3in} $\theta_4$}\\
{\rotatebox{90}{$\lambda_1^2$}}
\begin{subfigure}{0.47\textwidth}
\includegraphics[width=1\linewidth]{plot/l1x1.pdf}
\end{subfigure}
\begin{subfigure}{0.47\textwidth}
\includegraphics[width=1\linewidth]{plot/l1x4.pdf}
\end{subfigure}
{\rotatebox{90}{$\lambda_2$}}
\begin{subfigure}{0.47\textwidth}
\includegraphics[width=1\linewidth]{plot/l2x1.pdf}
\end{subfigure}
\begin{subfigure}{0.47\textwidth}
\includegraphics[width=1\linewidth]{plot/l2x4.pdf}
\end{subfigure}
\caption{Estimated $\theta_1$ (first column) and $\theta_4$ (second column) with respect to the hyperparameters of the gamma prior of $\lambda_1^2$ (first row) and the GIG prior of $\lambda_2$ (second row).}
\label{fig:senstivity}
\end{figure}
\section{Air pollution data analysis}
\label{sec:real}
We use the air pollution to mortality data \citep{mcdonald1973instabilities}.
The data set includes the mortality rate ($\pmb{y}$) and 15 explanatory variables of weather, socioeconomics, and air pollution in 60 metropolitan areas of the United States from 1959 to 1961. See Table~\ref{stab:air} in Supplementary material for a description of the variables.
The air pollution set has a complicated correlation structure. The correlation plot is presented in Figure~\ref{sfig:corr}. For example, the nitroc oxide level $nox$ is highly correlated with other air pollution variable hydrocarbon pollution $hc$, but also correlated with the weather variable $prec$ and population variable $popn$.
\begin{figure}[!ht]
\centering
\includegraphics[width=0.65\linewidth]{plot/correlation.pdf}
\caption{The correlation matrix of the air pollution data.}
\label{sfig:corr}
\end{figure}
We randomly split the data into a training set with 30 observations and a test set of 30 observations.
The five models, BEN-EL, BEN, BL, EN, and LADL, are conducted using the training set, and the prediction errors are obtained using the test set. For Bayesian methods, the EB approach is used to select the penalty parameters, and the Bayesian credible interval with the probability level $\alpha=0.5$ is used to select the variables. We repeat the procedure 100 times.
Table~\ref{tb:airpollution} reports the mean prediction error and standard deviation of the five models. BEN-EL yields the smallest mean prediction error, but its standard deviation is the second largest. The relatively large standard deviation of BEN-EL is due to one large prediction error. BEN-EL has the smallest median, mean, the first quartile (Q1), and the third quartile (Q3) than the other methods. Figure~\ref{sfig:box} in Supplementary material shows boxplots of prediction errors of BEN-EL, BEN, BL, LADL. The results imply that the proposed method outperforms the other methods when data have a complex correlation structure and a small number of observations.
\begin{table}[!ht]
\centering
\caption{The mean prediction errors along with the standard errors (SE) of BEN-EL, BEN, BL and EN methods for air pollution data analysis. The smallest mean prediction error is marked in bold.}\label{tb:airpollution}
\begin{tabular}{rrrrr}
\hline
\multicolumn{5}{c}{Mean Prediction Error (SE)} \\ \hline
\multicolumn{1}{c}{BEN-EL} & \multicolumn{1}{c}{BEN} & \multicolumn{1}{c}{BL} & \multicolumn{1}{c}{EN}
& \multicolumn{1}{c}{LADL}
\\ \hline
\textbf{1950 (679)} & 2118 (518) & 2133 (665) & 3044 (2903) & 1974 (620)
\\ \hline
\end{tabular}
\end{table}
\section{Conclusion}
\label{sec:conclusion}
We propose a new Bayesian approach for EN based on EL. Accordingly, the profile EL for the linear model replaces the ordinary likelihood function in the Bayesian setting.
We use the HMC algorithm because the resulting posterior EL distribution lacks a closed form, and the implementation of even standard MCMC methods is challenging.
A new HMC parameter tuning algorithm based on the bisection method is proposed for BEL.
Simulation studies and the air pollution data application show that our approach outperforms the other methods when the sample size is small, data are correlated, and error distributions are misspecified.
BEL methods share the same limitations of EL in the sense that the number of variables cannot increase as the sample size decreases. The reason is that the estimating equations are included in the convex hull to maximize the profile EL ratio. However, $X^TX$ is not of full rank when $p$ > $n$ and hence it is non-invertible. To address this shortcoming, several approaches have been proposed, such as penalized EL \citep{lahiri2012} and double penalization \citep{chang2018}. Thus, it might be worth a formal investigation whether the proposed method could be extended for $p>n$ case for future work.
Another interesting topic is implementing the NUTS algorithm of \citep{hoffman2014no} to the BEL framework. NUTS automatically tunes leapfrog steps and step sizes and has been used as a default sampler in popular MCMC software such as Stan \citep{stan} and PyMC3 \citep{salvatier2016probabilistic}. However, the proper introduction of NUTS into BEL has not been studied. We observe that HMC chains often diverge when the NUTS algorithm is used for BEN-EL. Also, BEL is not supported by most MCMC libraries because EL cannot be used as a likelihood function. Developing a BEL computational pipeline compatible with Stan or PyMC3 for practitioners will be of further interest.
\bibliographystyle{asa}
| {'timestamp': '2022-02-15T02:02:50', 'yymm': '2006', 'arxiv_id': '2006.10258', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10258'} | arxiv |
\section{Conclusion}\label{conclusion}
This work is the first to show that learning a dense 3D map and 6-DoF localisation can be accomplished in a deep generative probabilistic framework using variational inference.
The proposed spatial model features an expressive predictive distribution suitable for downstream control tasks, it is fully-differentiable and can be optimised end-to-end with SGD.
We further propose a probabilistic method for learning agent dynamics from prerecorded data, which significantly boosts predictive performance when incorporated in the full model.
The proposed framework was used to model quadcopter flight data, exhibiting performance close to that of state-of-the-art visual SLAM systems and bearing promise for real-world applications.
In the future, we will address the current model's speed limitations and move towards downstream applications based on the learned representation.
\section{Introduction}\label{introduction}
We address the problem of learning representations of spatial environments, perceived through \mbox{RGB-D} and inertial sensors, such as in mobile robots, vehicles or drones.
Deep sequential generative models are appealing, as a wide range of inference techniques such as state estimation, system identification, uncertainty quantification and prediction is offered under the same framework \citep{curi20a,dvbf,vrnn}.
They can serve as so-called \emph{world models} or environment simulators \citep{envsims,worldmodels}, which have shown impressive performance on a variety of simulated control tasks due to their predictive capability.
Nonetheless, learning such models from realistic spatial data and dynamics has not been demonstrated. Existing spatial generative representations are limited to simulated 2D and 2.5D environments \citep{gtmsm}.
On the other hand, the state estimation problem in spatial environments---SLAM---has been solved in a variety of real-world settings, including cases with real-time constraints and on embedded hardware \citep{cadena2016past,dso,vinsmono,orbslam2}.
While modern visual SLAM systems provide high inference accuracy, they lack a predictive distribution, which is a prerequisite for downstream perception--control loops.
Our approach scales the above deep sequential generative models to real-world spatial environments.
To that end, we integrate assumptions from multiple-view geometry and rigid-body dynamics commonly used in modern SLAM systems.
With that, our model maintains the favourable properties of generative modelling and enables prediction.
We use the recently published approach of \citet{abise} as a starting point, in which a variational state-space model, called DVBF-LM, is extended with a spatial map and an attention mechanism. Our contributions are as follows:
\begin{itemize}[topsep=0pt]
\item We use multiple-view geometry to formulate and integrate a differentiable raycaster, an attention model and a volumetric map.
\item We show how to integrate rigid-body dynamics into the learning of the model.
\item We demonstrate the successful use of variational inference for solving direct dense SLAM for the first time, obtaining performance close to that of state-of-the-art localisation methods.
\item We demonstrate strong predictive performance using the learned model, by generating spatially-consistent real-world drone-flight data enriched with realistic visuals.
\item We demonstrate the model's applicability to downstream control tasks by estimating the cost-to-go for a collision scenario.
\end{itemize}
The contributions allow the reformulated model to tackle realistic RGB-D scenarios with 6 DoF.
\begin{figure}
\centering
\includegraphics[width=0.8\linewidth]{figures/front_matter_wide.pdf}
\caption{
Illustration of the proposed quadcopter localisation and dense mapping.
Left: top-down view of the localisaton estimate.
Right: generative depth and colour reconstructions for one time step.
}
\label{fig:intro}
\end{figure}
\section{Method}\label{methods}
\paragraph{Background} We adhere to the graphical model of DVBF-LM \citep{abise}, but we introduce novel design choices for every model component and implement the overall inference differently, to allow for real-world 3D modelling.
In the following, we will first describe the assumed factorisation and then explain the introduced modifications.
The assumed joint distribution of all variables is:
\eq{
&\p*{\bobs_{1:T},\bpose_{1:T},\bmap_{1:T},\Map}{\bcontrol_{1:T-1}}\\[-0.5em]
&\qquad =\p*{\Map} \rho(\bpose_1) \prod_{t=1}^T \p*{\bobs_t}{\bmap_t} \p*{\bmap_t}{\bpose_t, \Map} \prod_{t=1}^{T-1}\p*{\bpose_{t+1}}{\bpose_t, \bcontrol_{t}}, \numberthis \label{eq:pgm}\\[-1.5em]
}
where $\bobs\Ts$ are observations, $\bpose\Ts$ agent states, $\bmap\Ts$ map charts and $\bcontrol\Tsm$ conditional inputs (controls).
The factorisation defines a traditional state-space model extended with a global map variable $\Map$.
For a single step $t$, an observation $\bobs_t$ is generated from a map chart $\bmap_t$---the relevant extract from the global $\Map$ around the current agent pose $\bpose_t$ (cf. \cref{fig:pgm}).
Chart extraction is given by $\p*{\bmap_t}{\bpose_t, \Map}$, which can be seen as an attention mechanism.
In this graphical model, SLAM is equivalent to inference of the agent states $\bpose\Ts$ and the map $\Map$.
For the remainder of this work, we assume all observations $\bx_t \in \mathbb{R}^{w \times h \times 4}$ are RGB-D images.
Next, we will describe the functional forms of the map $\Map$, the attention $\p*{\bmap_t}{\bpose_t, \Map}$, the emission $\p{\bobs_t}{\bmap_t}$ and the states $\bpose\Ts$.
\paragraph{Geometric map}
The map random variable $\Map = (\Map^{\text{occ}}, \Map^{\text{col}})$ consists of two components.
$\Map^{\text{occ}} \in \RR^{l \times m \times n}$ is a spatially arranged 3D grid of scalar values that represent occupancy.
$\Map^{\text{col}}$ represents the parameters of a feed-forward neural network $f_{\Map^{\text{col}}}: \RR^3 \rightarrow [0, 255]^3$.
The network assigns an RGB colour value to each point in space.
In this work, the network weights are deterministic and point-estimated via maximum likelihood, the fully-Bayesian treatment of the colour map is left for future work.
The prior and approximate posterior distributions over the occupancy map are:
\eq{
\p*{\Map^{\text{occ}}} = \prod_{i,j,k} \gauss*{\Map_{i,j,k}^{\text{occ}}}{0, 1}, \quad \q*[\varpars]{\Map^{\text{occ}}} = \prod_{i,j,k}\gauss*{\Map^{\text{occ}}_{i,j,k}}{\mu_{i,j,k},\sigma_{i,j,k}^2}.\\[-1.8em]
}
Here and for the rest of this work $\q*[\varpars]$ will denote a variational approximate posterior distribution, with all its optimisable parameters summarised in $\varpars$.
We assume $\p*{\Map_{\text{occ}}}$ and $\q*[\varpars]{\Map_{\text{occ}}}$ factorise over grid cells.
The variational parameters $\mu_{i,j,k},\sigma_{i,j,k}$ are optimised with Bayes by Backprop \citep{bayesbybackprop}.
\paragraph{Attention}
In the proposed model, the composition of the attention $\p*{\bm_t \mid \bz_t, \Map}$ and the emission $\p*{\bx_t \mid \bm_t}$ implements volumetric raycasting.
We engineer them based on our understanding of geometry to ensure generalisation across unseen environments.
The attention $\p*{\bm_t \mid \bz_t, \Map}$ forms latent charts $\bm_t$, which correspond to extracts from the map $\Map$ around $\bz_t$.
We identify $\bm_t$ with the part of the map contained in the frustum of the current camera view.
To attend to that region, first the intrinsic camera matrix $\intrinsic$ (assumed to be known) and the agent pose $\bz_t$ are used to cast a ray for any pixel $[i,j]^T$ in the reconstructed observation.
The ray is then discretised equidistantly along the depth dimension into $r$-many points, resulting into a collection of 3D world coordinates $\bcoord_t \in \RR^{w \times h \times r \times 3}$.
Depth candidate values $d \in \{k\resolution\}_{1 \le k \le r}$ are associated with each point along a ray, where $\resolution$ is a resolution hyperparameter.
The latent chart $\bm_t = (\chartocc_t, \chartcolor_t)$ factorises into an occupancy chart $\chartocc_t \in \RR^{w \times h \times r}$ and a colour chart $\chartcolor_t \in \RR^{w \times h \times r \times 3}$.
Let $\coord^{ijk}_t \in \RR^3$ be a 3D point in the spanned camera frustum.
To form the occupancy chart $\chartocc_t$, cells from the map $\Map^{occ}$ around $\coord^{ijk}_t$ are combined with a weighted kernel $o^{ijk}_t = \sum_{l,h,s} \Map^{\text{occ}}_{l,h,s}\attention_{l,h,s}(\coord^{ijk})$.
Note that here $l,h,s$ are indices of the occupancy map voxels.
We choose a trilinear interpolation kernel for $\attention$, merging only eight map cells per point.
This makes the attention fast and differentiable w.r.t $\bz_t$.
The colour chart $\chartcolor_t = f_{\Map^{\text{col}}}(\bcoord_t)$ is formed by applying $f_{\Map^{\text{col}}}$, the colour neural network, \emph{point-wise} to each 3D point.
In this work, we keep the chart $\bm_t$ deterministic.
The full attention procedure can be described as:
\eq{
\p*{\bm_t \mid \bz_t, \Map} = \prod_{ijk} \dirac*{\bm_t^{ijk} = f_A(\Map, \coord^{ijk})}, \quad \coord^{ijk} = \mathbf{T}(\bz_t)\mathbf{K}^{-1}[i, j, 1]^T\underbrace{d}_{:= k\resolution}.\\[-1.0em]
}
Here $\transform(\bz_t) \in \SE$ denotes the rigid camera transformation defined by the current agent state $\bz_t$ and $i,j,k$ index the points lying inside the attended camera frustum.
\begin{figure}[t]
\centering
\begin{subfigure}{0.30\linewidth}
\resizebox{1.0\columnwidth}{!}{\input{tex/pgm.tex}\unskip}
\caption{}
\label{fig:pgm}
\end{subfigure}
\begin{subfigure}{0.60\linewidth}
\centering
\includegraphics[width=1.0\linewidth]{figures/raycasting.pdf}
\caption{}
\label{fig:raycasting}
\end{subfigure}
\caption{
(\subref{fig:pgm}) One time step of the proposed probabilistic graphical model.
(\subref{fig:raycasting}) Linear interpolation during ray casting for a single ray in the emission model.
$d_k$ is the depth corresponding to the first ray value that exceeds $\tau$.
The output depth $d$ is formed by linearly interpolating between $d_{k-1}$ and $d_k$ based on the occupancy values $\chartocc^{i,j,k-1}$ and $\chartocc^{i,j,k}$.
}
\end{figure}
\paragraph{Emission through ray casting}
The emission model factorises over the observed pixels:
\eq{
\p*{\bobs_t \mid \bmap_t} = \prod_{ij} \p*{\bobs^{ij}_t \mid \bmap_t}, \quad \p*{\bobs^{ij}_t \mid \bmap_t} = \p*{d_t^{ij}, \tilde \chartcolor_t^{ij}}{\chartocc_t, \chartcolor_t}.\\[-2em]
}
It operates on the extracted chart $\bm_t = (\chartocc_t,\chartcolor_t)$.
Here $\bobs^{ij}_t \in \RR^4$ denotes an RGB-D pixel value, i.e.\, for each pixel $[i,j]^T$ we reconstruct a depth $d^{ij}_t$ and a colour value $\tilde \chartcolor^{ij}_t$.
The mean of the depth value $d_t^{ij}$ is formed by a function $f_E$:
\eq{
f_E(\chartocc_t)^{ij} &= \resolution \cdot \min_{k \in [r]} k \quad \text{s.t.} \quad \chartocc_t^{ijk} > \tau.\\[-1.5em]
}
$f_E$ traces the ray for pixel $[i,j]^T$, searching for the minimum depth $d=\resolution k$ for which the occupancy value $\chartocc_t^{ijk}$ exceeds a threshold $\tau$ (a hyperparameter).\footnote{$\chartocc_t^{ijk}$ is set to $0$ for $k \le 1$ and $f_E(\chartocc_t) = r\resolution$ if no value exceeds $\tau$ along the ray.}
Since the above $\min$ operation is not differentiable in $\chartocc_t$, we linearly interpolate between the depth value for the first ray hit and its predecessor to form the mean of the emitted depth (cf. \cref{fig:raycasting}):
\vspace{-0.5em}
\eq{
\mu_{d_t}^{ij} = \alpha f_E(\chartocc_t)^{ij} + (1 - \alpha)(f_E(\chartocc_t)^{ij} - \resolution), \quad \alpha = \frac{\tau - \chartocc_t^{i,j,k-1}}{\chartocc_t^{i,j,k} - \chartocc_t^{i,j,k-1}}.\\[-1.5em]
}
The mean of the emitted colour $\bmu_{\tilde \chartcolor_t}^{ij} = \chartcolor_t^{ijk}$ directly corresponds to the $k$-th element of the attended colour values, where $k$ is the index of the first hit from raycasting above.
A heteroscedastic Laplace distribution is assumed for both the emitted depth and colour values:
\eq{
\p*{\bx^{ij}_t \mid \bm_t} &= \text{Laplace}(\bx^{ij}_t; (\mu_{d_t}^{ij}, \bmu_{\tilde \chartcolor_t}^{ij}), \diag(\bsigma^{ij}_E)).\\[-2em]
}
\paragraph{Agent states}\label{statesapprox}
All agent states are represented as vectors $\bz_t = (\zloc_t, \zori_t, \zrest_t) \in \mathbb{R}^{d_{\bz}}$.
$\zloc_t \in \mathbb{R}^3$ is the agent location in space.
$\zori_t \in \mathbb{H}^4$ is the agent orientation, represented as a quaternion.
$\zrest_t \in \mathbb{R}^{d_\bz - 7}$ is a remainder.
Depending on the used transition model, $\zrest_t$ can be $\dot \zloc_t$ alone or it can contain an abstract latent portion not explicitly matching physical quantities.
The approximate posterior variational family over the agent states factorises over time:
\eq{
\q*[\varpars]{\bz\Ts} = \prod_t \q*[\varpars]{\bz_t} = \prod_t \gauss*{\bz_t}{\bmu^\bz_t, \diag(\bsigma^\bz_t)^2}.
}
Here $\bmu^\bz_t \in \mathbb{R}^{d_{\bz}}$ and $\bsigma^\bz_t \in \mathbb{R}^{d_\bz}$ are free variables for each latent state and are optimised with SGVB~\citep{vae}.
Notably, the above factorisation over states bears similarity to pose-graph optimisation.
One can see the individual terms $\q[\varpars]{\bz_t}$ as graph nodes, and the loss terms induced by the transition and emission in the objective presented next as the edge constraints.
\paragraph{Overall objective}
The elements described so far, together with the transition $\p*{\bpose_{t+1} \mid \bpose_t, \bcontrol_t}$ discussed in the next section, form the probabilistic graphical model in \cref{eq:pgm}.
The assumed variational approximate posterior is
\eq{
\q*[\varpars]{\bpose\Ts}\q*[\varpars]{\Map} \approx \p*{\bpose\Ts, \Map}{\bobs\Ts, \bcontrol\Tsm}.
}
For the optimisation objective we use the negative \emph{evidence lower bound} (ELBO) \citep{introvi}, given as
\vspace{-0.5em}
\eq{
&\elbo = -\expc*[q]{\sum_{t=1}^T \log \p*{\bobs_t}{\bmap_t}} \\[-1em]
&\quad + \kl*{\q*[\varpars]{\Map}}{\p*{\Map}} + \expc*[q]{\sum_{t=2}^T \kl*{\q*[\varpars]{\bpose_t}}{\p*{\bpose_t}{\bpose_{t-1}, \bcontrol_{t-1}}}}. \numberthis \label{eq:elbo}\\[-1.5em]
}
We employ the approximate particle optimisation scheme from \citep{abise} to deal with long data sequences.
The only optimised parameters are $\varpars$, containing the parameters of the map and the agent states.
\paragraph{Making image reconstruction tractable}
Using the full observations during inference is not feasible, as raycasting for all pixels is too computationally demanding.
To ensure tractability of the inference method we therefore use reconstruction sampling \citep{vaesubsampling}, emitting a random part of $\bx_t$ at a time, by randomly selecting $c$-many pixel coordinates $[i,j]^T$ for every gradient step.
Here $c$ is a constant much smaller than the image size $wh$, speeding up gradient updates by a few orders of magnitude.
Note that this results in an unbiased, faster and more memory-efficient Monte Carlo approximation of the original objective, avoiding loss of information due to subsampling or sparse feature selection.
\section{Learning rigid-body dynamics}\label{dynamics}
The introduced model factorisation includes a transition $\p*{\bz_{t+1}}{\bz_t, \bu_t}$, which allows the natural inclusion of agent movement priors.
This is reflected in the corresponding KL terms in \cref{eq:elbo}.
Note that using variational inference lets us integrate any differentiable transition model as-is, without additional linearisation.
In the following, we assume the agent has an inertial measurement unit (IMU) providing readings $\ddlocimu_t$ (linear acceleration) and $\doriimu_t$ (angular velocity) over time, which we choose to treat as conditional inputs $\bu_t = (\ddlocimu_t, \doriimu_t)$.
\paragraph{Engineering rigid-body dynamics}
In the absence of learning, one can use an engineered transition prior that integrates the IMU sensor readings over time.
The latent state $\bz_t = (\zloc_t, \zori_t, \dot \zloc_t)$ then contains the location, orientation and linear velocity of the agent at every time step.
The transition is defined as:
\eq{
\p*{\bz_{t+1}}{\bz_t, \bu_t} = \gauss*{\bz_{t+1}}{f_T(\bz_t, \bu_t), \diag(\bsigma_T)^2}.
}
The state update $f_T$ implements standard rigid-body dynamics using Euler integration (see \cref{app:engtrans}).
This engineered model will serve as a counterpart for the learned transition model presented next.
\paragraph{Learning a dynamics model}
Engineered models of the agent movement are often imperfect or not available.
We therefore provide a method for learning a fully-probabilistic transition model from streams of prerecorded controls and agent pose observations, which we can then seamlessly include as a prior in the full model.
We do not learn the transition with per-step, fully-supervised regression.
Instead we formulate a generative sequence model for $T$ time steps.
This allows us to separate the aleatoric uncertainty in the observed agent states from the uncertainty in the transition itself.
We follow the literature on variational state-space models \citep{srnn,dvbf}.
We assume we have a sequence of locations $\hat \zloc\Ts$ and orientations $\hat \zori\Ts$ as observations, and a sequence of IMU readings, as well as per-rotor revolutions per minute (RPM) and pulse-width modulation (PWM) signals, as conditional inputs $\bu\Tsm=(\ddlocimu\Tsm,\doriimu\Tsm,\bcontrol^{\text{rpm}}\Tsm,\bcontrol^{\text{pwm}}\Tsm)$.
We define the generative state-space model:
\vspace{-0.5em}
\eq{
\p*{\hat \zloc\Ts, \hat \zori\Ts, \bz\Ts}{\bu\Tsm} = \dirac*{\bz_1} \p*{\hat \zloc_1, \hat \zori_1}{\bz_1} \prod_{t=1}^{T - 1} \p*[\genpars_T]{\bz_{t + 1}}{\bz_{t}, \bu_{t}} \p*{\hat \zloc_{t+1}, \hat \zori_{t+1}}{\bz_{t+1}}.\\[-1.5em]
}
The objective is to learn generative transition parameters $\genpars_T$, such that the marginal likelihood of observed agent poses $\p*[\genpars_T]{\hat \zloc\Ts, \hat \zori\Ts}{\bcontrol\Tsm}$ is maximised.
The latent state is $\bz_t = (\zloc_t, \zori_t, \dot \zloc_t, \zrest_t)$, identifying its first three components with location, orientation and linear velocity.
The remainder $\zrest_t$ acts as an abstract state part.
Its role is to absorb any quantities that might affect the transition, for example higher moments of the dynamics or sensor biases accumulated over previous time steps.
The transition is implemented as a residual neural network on top of Euler integration:
\eq{
&\p*[\genpars_T]{\bz_{t + 1}}{\bz_t, \bu_t} = \gauss*{\bz_{t+1}}{\bmu_{t+1}, \diag(\bsigma_{t+1})^2} \\
&\bmu_{t+1} = \begin{bmatrix}
f_T(\bpose_t, \bcontrol_t) \\
\mathbf{0} \\
\end{bmatrix} + \mlp_{\bmu}(\bz_t, \bu_t), \quad \bsigma_{t+1} = \mlp_{\bsigma}(\bz_t, \bu_t),
}
where $f_T$ is the engineered Euler integration from the previous section and the abstract remainder of the latent state is formed entirely by the network (MLP).
This strong inductive bias shapes the transition to resemble regular integration in the beginning of training, exploiting engineering knowledge, while still allowing the MLP to eventually take over and correct biases as necessary.
The emission isolates the location and orientation from the latent state as its mean:
\eq{
\p*{\hat \zloc_t, \hat \zori_t}{\bz_t} = \gauss*{\hat \zloc_t, \hat \zori_t}{(\zloc_t, \zori_t), \diag(\bsigma)^2}.\\[-1.5em]
}
The inference over the latent states uses Gaussian fusion as per \citep{empowerment} and the necessary inverse emission is given by a bidirectional RNN that looks into all observations and conditions:
\eq{
\hat{q}(\bz_t \mid \hat \zloc\Ts, \hat\zori\Ts, \bu\Tsm) = \gauss*{\bz_t}{\rnn(\hat \zloc\Ts, \hat\zori\Ts, \bu\Tsm)}.
}
We minimise the negative ELBO w.r.t. $\genpars_T$, omitting the conditions in $q$ for brevity:
\eq{
\loss*{\genpars_T} = -\expc*[q]{\sum_{t=1}^T \log \p*{\hat \zloc_t, \hat \zori_t}{\bz_t}} + \expc*[q]{\sum_{t=2}^T \kl{\q{\bz_t}}{\p[\genpars_T]{\bz_{t}}{\bz_{t-1}, \bu_{t-1}}}}.\\[-2em]
}
\section{Case study: drone landing} \label{app:landing}
In terms of the integrated transition $\p*{\bpose_{t+1}}{\bpose_t, \bcontrol_t}$, we find that the learned transition performs on par with its engineered counterpart when used for inference in the full model.
However, when inspecting the absolute RMSE in \cref{table:rmse}, there appear to be two outliers---\emph{picasso, max speed 4.0 m/s} and \emph{star, max speed 2.0 m/s}, when using the learned transition.
A closer examination showed that this is entirely due to a large localisation error during landing at the end of the trajectories.
In both cases the agent fails to land correctly or falls over, leading to out-of-distribution conditions $\bcontrol_t$ from the IMU sensor (cf. \cref{fig:fallcontrols}), for which the learned model does not generalise.
Such behaviour is not unexpected when it comes to neural networks.
Localisation beforehand is stable along the whole trajectory, the landing tracking failure happens only during the last $2$ seconds of movement.
\begin{figure}[h]
\includegraphics[width=1.0\linewidth]{figures/fall_error}
\caption{
Illustration of the discussed failure landing of the quadcopter at the end of the two test set trajectories, taking \emph{star, max speed 2.0 m/s} as an example.
The problematic segment of the trajectory is marked with a red vertical band.
Note the outlier controls at the end.
Top left: angular velocity IMU readings.
Top right: linear acceleration IMU readings.
Bottom left: absolute Euclidean distance error w.r.t. the ground truth MOCAP locations.
Note how the error is large only at the end of the trajectory, and directly coincides with the outlier controls.
Bottom right: comparison of the distribution of linear accelerations in $y$ during flight (red) vs. during landing (gray).
The controls during landing are out of distribution for the learned transition model.
} \label{fig:fallcontrols}
\end{figure}
\section{Model details}\label{app:modeldetails}
This section lists all model and optimisation hyperparameters used for generating the results reported in the paper.
\subsection{Full spatial model}
The full spatial model uses either the learned or the engineered transition, see \cref{app:learnedtrans} and \cref{app:engtrans} for their respective hyperparameters.
\subsubsection{Optimisation}
After subsampling, the trajectories in the Blackbird dataset can still contain thousands of time steps.
To deal with this, during inference the proposed model follows the approximate particle optimisation scheme introduced by \citet{abise}, using chunks of $5$ time steps for every gradient update, using $50$ approximating state particles and refreshing the respective particles after every gradient step.
Adam \citep{adam} is used to optimise the parameters $\varpars$ for the approximate posterior distribution $\q[\varpars]{\bpose\Ts, \Map}$.
\Cref{table:spatialadamparams} lists the used optimiser hyperparameters.
Note that due to the employed attention $\p{\bmap_t}{\bpose_t, \Map}$, due to the reconstruction sampling in the emission and due to the approximate optimisation scheme mentioned above (which uses only a chunk of the trajectory at a time), only a part of the parameters for the occupancy map and the full trajectory of agent states is used for a gradient step.
In other words, gradient updates happen locally in the spatially arranged occupancy map parameters, based on the currently selected local chunk of the agent trajectory.
Because of this, momentum is disabled in Adam for both the occupancy map and the agent states, to avoid accidental drift in regions currently not covered by the optimisation.
For every variable in question, the same optimiser is used to optimise the mean and scale of the assumed distribution (where applicable).
For any scale distribution parameters (e.g. standard deviations for the assumed Gaussian distributions), the optimisation is performed in log-space to satisfy the positive value constraint.
\subsubsection{Initialisation of new poses}
While performing SLAM, data is added incrementally to the spatial model, to emulate online usage of the method.
A new time step $t$ is explored every $500$ gradient steps, effectively adding a new observation $\bobs_t$ and a new conditional input $\bcontrol_t$ to the data.
Whenever a new time step is added, the parameters of the corresponding state $\bpose_t$ are unlocked for optimisation and initialized according to \cref{table:componenthypers}.
\subsubsection{Choice of approximate posterior over states}
In \citep{abise} a bootstrap particle filter is used to implement the variational posterior over agent states.
The increased model complexity due to the presented raycasting model makes the application of particle filters with sufficiently many particles costly.
In \cref{statesapprox} we therefore introduce an approximate posterior over the agent states $\q*[\varpars]{\bz\Ts}$, with free state parameters $\varpars$, that factorises over time.
The chosen variational states approximation represents a shift in perspective---from filtering towards a method more similar to pose-graph optimisation.
\begin{table}[t]
\caption{Model details.}
\begin{subtable}[t]{1.0\linewidth}
\small
\centering
\caption{Hyperparameters of the individual spatial model components.} \label{table:componenthypers}
\begin{tabular}{lrr}
\toprule
\textbf{Component} & \textbf{Parameter} & \textbf{Value} \\
\midrule
$\bpose_t$ & init. value for $\bmu_t$& mean of $\p*[\genpars_T]{\bpose_t}{\bmu_{t-1}, \bcontrol_t}$\\
& init. value for $\bsigma_t$& $0.01 \times \mathbf{1}$\\
\midrule
$\Map^{occ}$ & grid size & $200 \times 200 \times 200$ \\
& init. value for $\mu_{i,j,k}$ & $-0.5$ \\
& init. value for $\sigma_{i,j,k}$ & $0.1$ \\
\midrule
$\Map^{col}$ & \# hidden layers & $5$ \\
& \# hidden units & $256$ \\
& activation & softsign \\
& residual connections & true \\
\midrule
$\p*{\bmap_t}{\bpose_t, \Map}$ & $\resolution$ (ray resolution) & $0.1$m \\
& max depth ($k\resolution$) & $20$m \\
& \# reconstr. pixels & 200 \\
\bottomrule
\vspace{1em}
\end{tabular}
\end{subtable}
\begin{subtable}[t]{0.4\linewidth}
\small
\centering
\caption{Optimisation hyperparameters for the full spatial model.}\label{table:spatialadamparams}
\begin{tabular}{lrr}
\toprule
\textbf{Variables} & \textbf{Parameter} & \textbf{Value} \\
\midrule
$\bpose\Ts$ & Adam, learning rate & $0.001$ \\
& Adam, $\beta_1$ & $0.0$ \\
& Adam, $\beta_2$ & $0.999$ \\
\midrule
$\Map^{occ}$ & Adam, learning rate & $0.05$ \\
& Adam, $\beta_1$ & $0.0$ \\
& Adam, $\beta_2$ & $0.999$ \\
\midrule
$\Map^{col}$ & Adam, learning rate & $0.001$ \\
& Adam, $\beta_1$ & $0.9$ \\
& Adam, $\beta_2$ & $0.999$ \\
\bottomrule
\end{tabular}
\end{subtable}
\hfill
\begin{subtable}[t]{0.55\linewidth}
\centering
\caption{Hyperparameters of the learned transition model.} \label{table:learnedtranshypers}
\begin{tabular}{lrr}
\toprule
\textbf{Component} & \textbf{Parameter} & \textbf{Value} \\
\midrule
$\p*[\genpars_T]{\bpose_{t+1}}{\bpose_t,\bcontrol_t}$ & \# hidden layers & 5 \\
& \# hidden units & 64 \\
& activation & relu \\
& residual connections & true \\
& size of $\bpose^{\text{rest}}$ & 8 \\
\midrule
$\hat q(\bpose_{t} \mid \hat \zloc\Ts, \hat\zori\Ts, \bu\Ts)$ & RNN type & LSTM \\
& \# RNN units & $64$ \\
\bottomrule
\end{tabular}
\end{subtable}
\end{table}
\subsubsection{Handling orientations}
The portions $\zori_t$ of the sampled latent states $\bz_t$ are identified with quaternions and are explicitly normalised to unit quaternions after gradient updates before they are used in the rest of the model.
This means that the assumed Gaussian distribution is not directly expressed on the manifold $\mathbb{SO}(3)$, but we found that this parameterisation works well enough.
\subsubsection{Component parameters}
The rest of the hyperparameters for the full spatial model, including initial values for the optimised variational parameters, are specific to the individual model components and are listed in \cref{table:componenthypers}.
The scale $\bsigma_E$ for the heteroscedastic Laplace emission $\p*{\bobs_t}{\bmap_t}$ is learned with gradient descent (applied in log-space).
The colour part of $\bsigma_E$ is forced to be $10$ times smaller than that for the depth part, to account for the different scales of the observed values (colour range is $[0, 1]$, depth range is $[0, 20]$).
\subsection{Learned transition}\label{app:learnedtrans}
The learned transition is obtained by training the generative parameters $\genpars_T$ in the context of the model defined in \cref{dynamics}.
When reconstructing orientations in that model, we do not reconstruct quaternions directly because of the ambiguity $\mathbf{q} = -\mathbf{q}$.
Instead we reconstruct the rotation matrix corresponding to the observed orientation $\hat \zori_t$, i.e. the mean of the emission $\p*{\hat \zori_t}{\bz_t}$ is a rotation matrix constructed from the quaternion $\zori_t$ that's part of the latent state $\bpose_t$.
When used in the full spatial model, the weights of the transition neural network $\genpars_T$ are fixed to their pretrained values.
This is done to avoid accidental overfitting of the transition parameters to the current trajectory and current environment for which SLAM is performed.
The selected hyperparameters of the learned transition are listed in \cref{table:learnedtranshypers}.
\subsection{Engineered transition}\label{app:engtrans}
The mean of the engineered transition prior $\p*{\bz_{t+1}}{\bz_t, \bu_t}$ from \cref{dynamics} is formed by a function $f_T$, which implements the rigid body dynamics
\eq{
f_T(\bz_t, \bu_t) = \begin{bmatrix}
\zloc_{t+1} \\
\zori_{t+1} \\
\dot \zloc_{t+1} \\
\end{bmatrix} =
\begin{bmatrix}
\zloc_t + \dot \zloc_t \dt \\
\zori_t \oplus \rot(\zori_t) \doriimu_t \dt \\
\dot \zloc_t + \rot(\zori_t) \ddlocimu_t (\dt)^2
\end{bmatrix}.
}
Here $\oplus$ denotes standard quaternion integration.
The standard deviation $\bsigma_T$ of $\p*{\bz_{t+1}}{\bz_t, \bu_t}$ (a Gaussian) is a hyperparameter, estimated via search on the validation set.
Its diagonal entries are $0.01$ for the location state dimensions, $0.001$ for the orientation state dimensions and $0.001$ for the velocity state dimensions.
The gravitational force $\mathbf{g}$ is subtracted from the IMU readings when applying the Euler integration given by $f_T$.
The time delta for the integration is set to $\dt = 0.1$, to match the $10$Hz data subsampling.
\section{Use of domain knowledge when designing learned spatial models} \label{app:domainknowledge}
\begin{figure}[h]
\centering
\begin{subfigure}[t]{0.49\linewidth}
\centering
\includegraphics[width=1.0\linewidth]{figures/emission_issue.png}
\caption{When the attention to the map is too narrow, emitting from observed but yet unvisited places suffers from non-local generalisation issues in an online setting.}
\label{fig:emissionissue}
\end{subfigure}
\hfill
\begin{subfigure}[t]{0.49\linewidth}
\centering
\includegraphics[width=1.0\linewidth]{figures/corrected_emission_issue.png}
\caption{A 2D illustration of attending to the whole field of view of the agent. Note that in our method the occupancy map is a 3D volume, and the attended camera frustum resembles a pyramid.}
\label{fig:correctedemissionissue}
\end{subfigure}
\caption{Simplified 2D examples of the conceptual difference the chosen attention can have on generating observations.}
\end{figure}
What distinguishes our method from DVBF-LM \citep{abise} and other previous 2D and 2.5D deep generative sequence models is that we introduce geometric inductive biases (multiple-view geometry, rigid-body dynamics) in a deep generative sequence model (inferred via the ELBO).
We hope the following overview of DVBF-LM's methodology will exemplify why such assumptions could be necessary and motivate our design choices.
DVBF-LM models the world as a 2D chessboard where the content of each grid cell describes a 360° horizontal panoramic view around the z-axis, centered at the agent 2D location.
Observation predictions are cropped from that view, relative to the way the agent is facing in 2D (and transformed by an MLP).
This already consitutes a set of basic geometric assumptions, but they can be limiting, as explained below.
First of all, the agent movement is restricted to a plane, with rotations around one axis (no 6-DoF modelling).
The main problem, however, is that the map is updated very locally, only at the 2D location of the agent, because the attention of DVBF-LM only considers four map cells directly underneath.
For example, if the agent is standing 5m in front of a wall and facing it, DVBF-LM only stores this information at that location in the map.
If the agent moves 2m closer to the wall, it is now accessing different cells, whose content is completely arbitrary (see \cref{fig:emissionissue}).
These cells will have to learn the presence of the wall again.
The map is thus unnecessarily redundant and the agent would have to visit virtually all map cells to infill everything.
This means observation predictions from cells which have not been visited before will not be meaningful, even when they were already in the field of view (FoV) of the agent.
Localisation also suffers, as the map is more easily allowed to establish multiple modes for the pose posterior because of the redundancy (same content can be stored at different places by mistake), further complicating the perceptual aliasing problem of spatial environments.
By contrast, in our method we use raycasting and attend to the whole camera frustum, accessing all map content in the field of view of the agent, as shown in \cref{fig:correctedemissionissue}.
Note that the depiction is intentionally simplified to 2D for the sake of clarity, while the actual attention in our approach operates in 3D.
In the above example, the wall and the empty space in front of the agent would be captured as soon as the agent sees the wall for the first time, and can be predicted from all regions in the FoV.
This constitutes a strong geometric inductive bias that will generalise across different environments.
In general, the lack of geometric assumptions in previous deep spatial generative models (e.g. the ones described in the first paragraph of \cref{related}) is attractive, as it lessens the need for domain knowledge, instead attempting to learn the whole system end-to-end.
However, learning everything becomes problematic (not just in terms of runtime) when the inference needs to happen on-the-fly and data is scarce, as is the case for autonomous agents.
When the agent cannot afford to exhaustively observe the whole environment, insufficient data for learning from scratch can lead to problems with consistency in the map, consistency in the long-term predictions and ambiguous agent localisation.
One option is to address this through learning certain components in advance (e.g. as we do with the dynamics model, see \cref{dynamics}).
Once image data is involved, however, the generalisation of learned components is much harder to ensure because of the curse of dimensionality.
Observations can vary greatly from one scene to the next, and free 6-DoF movement of the agent exacerbates the problem further.
Instead of collecting data exhaustively, in an attempt to pretrain a network to learn how to render, we rely on the geometric knowledge that is already available to us to design the map, the attention and the emission in \cref{methods}.
Such assumptions are also at the core of many of the models discussed in the second paragraph in the related work (\cref{related}).
In contrast to these models, however, in our work we weave the aforementioned inductive biases into the deep generative framework, which is fully-probabilistic, implies end-to-end differentiability and eases the introduction of new learned components when needed.
Therefore, our goal is to maintain an expressive predictive distribution $\p*{\bpose_{2:T}, \bobs\Ts}{\bcontrol\Tsm, \bpose_1}$ that lets us predict the future, precisely aligning with the performed inference based on past data at the same time.
We stress that maintaining a full probabilistic predictive model is needed to quantify uncertainty when planning for future actions of the agent.
\section{Hyperparameter search and execution details}\label{hps}
All models are implemented in python using TensorFlow \citep{tensorflow}, making use of automatic differentiation to optimise model parameters.
This allows for the easy integration of neural networks and makes end-to-end optimisation straightforward.
In TensorFlow 1.15, one gradient step of the model takes 0.0607s on average, without XLA compilation.
In TensorFlow 2.3 one gradient step of the model takes 0.0073s on average, with XLA compilation enabled.
The inference experiments in the paper currently assume 500 iterations per added data point (once every 0.1s for a 10Hz stream), which amounts to 36.5s of inference runtime per 1s of real-time movement in the newer TensorFlow version.
As already mentioned in the main text, we have not yet optimised the model for real-time inference, and we will address this in our future work.
The large speed-up achieved by simply enabling XLA and switching to a higher version of TensorFlow indicates that a lot of the computations in the model can be improved further (e.g. by moving to a C++ runtime or writing dedicated CUDA kernels).
We also anticipate that better initialisation and careful tuning of the model hyperparameters will let the system reach interactive operation rates.
All probabilistic modelling aspects were implemented using Edward \citep{edward}.
Hyperparameter search (HPS) experiments were executed in a cluster with 8 Tesla V100 GPUs and 40 Intel Xeon E5-2698 CPU cores.
Because of the large amount of Blackbird data (4.7 TB) and the current model's speed limitations, the search was performed for a subset of all possible hyperparameters.
The performed model selection is therefore not exhaustive, possibly leaving potential for improvement.
In the following we list the considered hyperparameter search ranges and the number of trials for each model.
\subsection{HPS: full spatial model}
The hyperparameters for the full spatial model were selected based on localisation RMSE for 500-step segments of trajectories in the validation set.
A total of 200 experiments were conducted, randomly picking a trajectory segment on which SLAM inference is performed.
The considered parameter ranges are listed in \cref{table:hpsspatial}.
\subsection{HPS: learned transition model}
The learned transition hyperparameters were selected based on the validation set ELBO value from the model discussed in \cref{dynamics}.
A total of 400 experiments were conducted, using all of the blackbird training and validation data.
The considered parameter ranges are listed in \cref{table:hpslearnedtrans}.
\subsection{HPS: engineered transition model}
The engineered transition hyperparameters were selected in the same HPS for the full model discussed above, based on localisation RMSE for 500-step segments of trajectories in the validation set.
The considered parameter ranges are listed in \cref{table:hpsengtrans}.
\begin{table}[t]
\centering
\caption{HPS details.}
\begin{subtable}[t]{0.45\linewidth}
\centering
\caption{HPS ranges for the full spatial model.}
\label{table:hpsspatial}
\input{tex/appendix/full_hps}
\end{subtable}
\hfill
\begin{subtable}[t]{0.45\linewidth}
\centering
\caption{HPS ranges for the learned transition model.}
\label{table:hpslearnedtrans}
\input{tex/appendix/learned_trans_hps}
\end{subtable}
\begin{subtable}[t]{1.0\linewidth}
\centering
\caption{HPS ranges for the engineered transition model.}
\label{table:hpsengtrans}
\input{tex/appendix/eng_trans_hps}
\end{subtable}
\end{table}
\section{Further inference examples}\label{app:examples}
\begin{figure}[h]
\begin{subfigure}{0.48\linewidth}
\includegraphics[width=\linewidth]{figures/appendix_clover.pdf}
\end{subfigure}
\hfill
\begin{subfigure}{0.48\linewidth}
\includegraphics[width=\linewidth]{figures/appendix_patrick.pdf}
\end{subfigure}
\begin{subfigure}{0.48\linewidth}
\includegraphics[width=\linewidth]{figures/appendix_sphinx.pdf}
\end{subfigure}
\hfill
\begin{subfigure}{0.48\linewidth}
\includegraphics[width=\linewidth]{figures/appendix_sid.pdf}
\end{subfigure}
\caption{
Examples of inference in the full spatial model, expressed in localisation and mapping for segments of the following trajectories: \emph{clover, forward yaw, max speed 3.0 m/s}, \emph{patrick, forward yaw, max speed 3.0 m/s}, \emph{sphinx, forward yaw, max speed 3.0 m/s} and \emph{sid, forward yaw, max speed 3.0 m/s}.
Left on every subfigure: top-down view of the localisaton estimate.
Right on every subfigure: depth and colour reconstructions from the generative model for one time step.
}
\end{figure}
\clearpage
\section{Data set splits}\label{splits}
\centering
\scriptsize
\begin{tabular}[t]{lrr}
\toprule
\multicolumn{3}{c}{\textbf{Training set}} \\
\input{tex/appendix/train_set_info}
\bottomrule
\end{tabular}
\qquad
\begin{tabular}[t]{lrr}
\toprule
\multicolumn{3}{c}{\textbf{Test set}} \\
\input{tex/appendix/test_set_info}
\bottomrule
\toprule
\multicolumn{3}{c}{\textbf{Validation set}} \\
\input{tex/appendix/val_set_info}
\bottomrule
\end{tabular}
\section{Data details and overall setup} \label{app:data}
For all presented experiments we used the Blackbird data set \citep{blackbird}, which can be found here: \url{https://github.com/mit-fast/Blackbird-Dataset}.
In the following we describe the exact pre-processing of the data.
\subsection{Data partitioning and usage}
The data was partitioned into a training, a validation and a test set.
The trajectory shapes (e.g. \emph{star}, \emph{picasso}, \emph{patrick}, etc.) in every split were different.
This was done to prevent accidental overfitting of the learned transition model to any particular trajectory shape.
In particular, the test set contains the trajectories \emph{star, forward yaw} and \emph{picasso, constant yaw}, traversed at different speeds, everything else is used for training and validation.
This is the same test setup as the one used by \citet{vimo} (considered as a baseline).
\Cref{splits} lists the exact trajectories used for each split, along with the number of steps in each trajectory after pre-processing (which includes subsampling).
The training set was used only to train the learned transition model $\p[\genpars_T]{\bpose_{t+1}}{\bpose_t, \bcontrol_t}$, following the method described in \cref{dynamics}.
The learned transition model is trained separately before it is used as a prior in the full spatial model.
Pretraining the model on multiple trajectories beforehand, as opposed to training it from scratch during SLAM inference, ensures that the transition really captures the agent dynamics and does not overfit the currently explored environment.
The training trajectories were further randomly rotated around the $z$ axis and linearly translated in space, to promote generalisation.
The validation set was used for checkpointing and selecting the best weights $\genpars_T$ of the neural network in the learned transition model, based on the ELBO defined in \cref{dynamics}.
The validation set was also used for hyperparameter selection for the engineered transition model, the learned transition model and the full spatial model.
The best hyperparameters for all models (cf.\, \cref{app:modeldetails}) were selected with random search.
You can find details for the search ranges in \cref{hps}.
The test set was used for evaluation only---all results reported in the experimental section of the paper were done on the test data.
The full spatial model was tested with the forward yaw \emph{star} trajectories, speeds $1.0$ m/s to $4.0$ m/s and with the constant yaw \emph{picasso} trajectories, speeds $1.0$ m/s to $4.0$ m/s, to match the evaluation by \citet{vimo}.
These trajectories take place in the \emph{NYC subway station} environment.
\subsection{Data preprocessing}
Each trajectory contains IMU, RPM and PWM readings, MOCAP ground truth pose observations, as well as simulated grayscale images from a forward-facing stereo pair and a downward-facing camera.
We pre-processed every trajectory in the following way:
\begin{itemize}
\item Ground truth MOCAP state readings were extracted from the provided ROS bags.
\item Downward-facing images were ignored.
\item The remaining data was subsampled to $10$ Hz, using nearest neighbour subsampling based on the provided time stamps.
\item Depth was then precomputed from the left and right images using OpenCV's SGBM \citep{sgbm}.
\item For every time step, the right colour image was then ignored, while the left image and the depth estimate were together treated as an RGB-D observation $\bobs_t \in \RR^{w \times h \times 4}$.
\item The provided IMU readings are measured in the coordinate frame of the IMU sensor. Therefore, they had to be rotated to the body frame of the agent, using the respective quaternion provided with the data set: $\mathbf{q} = [0.707, 0.005, -0.004, 0.706]^T$.
\end{itemize}
The intrinsic parameters of the camera, specifying the intrinsic camera matrix $\mathbf{K}$, and the stereo baseline were fixed to the values provided with the data set:
\begin{itemize}
\item Stereo baseline: $0.1$m.
\item Image size: $1024 \times 768$.
\item Focal length, x: $665.1$.
\item Focal length, y: $665.1$.
\item Principal point offset, x: $511.5$.
\item Principal point offset, y: $383.5$.
\end{itemize}
Depth was computed based on the disparity values produced by SGBM.
We used the following parameters, keeping the default values for everything else:
\begin{itemize}
\item Block size: $5$.
\item Min. disparity: $0$.
\item Max. disparity: $256$.
\end{itemize}
We did not filter the images and the produced depth values in any way and treated them as direct observations, to limit the pre-processing steps as much as possible and rely on the defined spatial model instead.
Note that due to the simplicity of the method used for depth estimation, the depth observations contain significant amounts of noise (e.g. \cref{fig:pointclouds}).
The pixel values for the color images were normalized to be in the range $[0, 1]$.
\section{Experiments}\label{experiments}
The experiments are designed to validate three model aspects---the usefulness of the reconstructed 3D world maps, multi-step prediction given future controls and the localisation quality.
For evaluation, we use the Blackbird data set \citep{blackbird}.
It consists of over ten hours of real quadcopter flight data.
The ground truth poses are recorded by a motion capture (MOCAP) system.
For each trajectory, Blackbird contains realistic simulated stereo images.
We obtain depth from these images using OpenCV's Semi-Global Block Matching (SGBM) \citep{sgbm} and treat the left RGB camera image and the estimated depth as an observation $\bobs_t$.
We evaluate our method on the test trajectories used in \citep{vimo}.
Other trajectories with no overlap are used for training the learned dynamics model and model selection.
All model hyperparameters are fixed to the same values for all evaluations.
More details can be found in \cref{app:data,app:modeldetails}.
\subsection{Dense geometric mapping}
A fused dense map, obtained as an approximate variational posterior $\q*[\varpars]{\Map}$, allows us to simulate (emit) the environment from any novel view point.
We take the \emph{NYC subway station} Blackbird environment as an example, in which the test set trajectories take place.
\Cref{fig:emissions} shows image reconstructions, generated along an example trajectory segment.
The model can successfully generate both colour and depth based on $\q*[\varpars]{\Map}$.
Note that the true observations are not needed for this, as all of the information is recorded in $\Map$ through gradient descent.
Even though we use reconstruction sampling during training, on average all image pixels contribute to learning the map.
This leads to dense predictions of the agent's sensors.
The inferred map correctly filters out wrong observations, as can be seen in the top-down point-cloud comparison in \cref{fig:pointclouds}, noting the subway station columns.
\subsection{Using maps for downstream tasks}
Besides parameterising predictive emissions, a map can be used to define downstream navigation and exploration tasks.
Since the map is modelled as a random variable, the approximate posterior $\q*[\varpars]{\Map}$ also gives us an uncertainty estimate, in this work only applying to $\Map^{occ}$.
\Cref{fig:mapuncertainty} shows a horizontal slice from the occupancy grid, along which the map uncertainty is evaluated.
The uncertainty is low inside the subway station, and high on the outside where the agent has not visited.
Meaningful map uncertainty is useful for information-theoretic exploration \citep{abise}.
The occupancy map can also be used to construct navigation plans, by computing a collision cost-to-go $J(\bpose_1)~=~\mathbb{E}_{\bcontrol\Ts,\bpose\Ts \sim \p{\cdot}}[\sum_t c(\bcontrol_t, \bpose_{t})]$ \citep{bertsekas}.
For example, the cost $c(\bcontrol, \bpose)$ can be the occupancy value in the map at $\bpose_t$, defining a collision cost.
To simulate a control policy, we use an empirical distribution of randomly picked $40$-step sequences of IMU readings $\bcontrol\Ts$ from the test data.
Then we generatively sample future states $\bpose\Ts$ for these controls and evaluate the respective costs.
\Cref{fig:costtogo} shows $J(\bpose)$ evaluated for all states along the considered 2D slice of the map.
The cost-to-go is high near the walls and columns, and gradually drops off in the free space.
\begin{figure}[t]
\begin{subfigure}[b]{0.54\linewidth}
\centering
\includegraphics[width=1.0\linewidth]{figures/emissions.pdf}
\caption{}
\label{fig:emissions}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.45\linewidth}
\centering
\includegraphics[width=1.0\linewidth]{figures/generative_comparison.pdf}
\caption{}
\label{fig:generative}
\end{subfigure}
\caption{
(\subref{fig:emissions}) Emissions at different trajectory points, sampled at a one second interval.
Top to bottom: predicted colour, observed colour, predicted depth, observed depth.
(\subref{fig:generative}) Generative predictions using the engineered transition vs. the learned transition in the complete model.
Left: top-down view of 200-step location predictions.
Right: predicted colour and depth for the same step for both models.
}
\end{figure}
\begin{figure}[t]
\centering
\begin{subfigure}{0.24\linewidth}
\centering
\includegraphics[width=\linewidth]{figures/map_uncertainty.pdf}
\caption{}
\label{fig:mapuncertainty}
\end{subfigure}
\begin{subfigure}{0.24\linewidth}
\centering
\includegraphics[width=\linewidth]{figures/map_mean.pdf}
\caption{}
\label{fig:mapmean}
\end{subfigure}
\begin{subfigure}{0.24\linewidth}
\centering
\includegraphics[width=\linewidth]{figures/cost_to_go.pdf}
\caption{}
\label{fig:costtogo}
\end{subfigure}
\begin{subfigure}{0.24\linewidth}
\centering
\includegraphics[width=\linewidth]{figures/point_clouds.png}
\caption{}
\label{fig:pointclouds}
\end{subfigure}
\caption{
An illustration of a reconstructed dense map for the \emph{NYC subway station} environment.
Note that columns from the subway are captured in the reconstructed map.
The figures show a horizontal map slice.
(\subref{fig:mapuncertainty}) Occupancy map uncertainty (white means low uncertainty).
(\subref{fig:mapmean}) Occupancy map mean (white means occupied).
(\subref{fig:costtogo}) Collision cost-to-go (red means high cost).
(\subref{fig:pointclouds}) Generated point cloud (black, for inferred agent poses) vs. data point cloud (red, for ground truth MOCAP poses).
}
\end{figure}
\subsection{Generating future predictions}\label{predictive}
The proposed model can predict the agent movement and observations for a sequence of future conditional inputs, i.e.\, $\p*{\bpose_{2:T}, \bobs\Ts}{\bcontrol\Tsm, \bpose_1}$.
Such predictions are crucial for model-based control, and typically not readily available from modern visual SLAM systems.
\Cref{fig:generative} shows predictions of the full spatial model for 200 steps in the future, comparing both the engineered and learned transition priors.
Long-term prediction is significantly better with the learned transition, indicating that it corrects biases present in the agent sensors.
Conversely, with the engineered transition localisation drift is higher and wrong map regions are queried for generation, translating into wrong depth and colour predictions.
We refer to the supplementary video for more examples using the predictive model.
Evaluated on $200$ test set trajectories with $100$ steps, the learned transition leads to better predictions than its engineered counterpart, with an average translational RMSE of $1.156$ and rotational RMSE of $0.096$, compared to $13.768$ and $0.111$ for the engineered model.
Similarly, the pixel-wise log-likelihood of the observation predictions is $-1.23$ when the learned model is used, and $-1.85$ for the engineered model, averaged over 1000 images.
This evaluation clearly illustrates the positive effect of the learned transition on the model's predictive performance.
\begin{figure}[t]
\begin{center}
\begin{subfigure}{0.24\textwidth}
\centering
\includegraphics[width=\linewidth]{figures/trajectory_star.pdf}
\caption{}
\label{fig:trajstar}
\end{subfigure}
\begin{subfigure}{0.24\textwidth}
\centering
\includegraphics[width=\linewidth]{figures/trajectory_picasso.pdf}
\caption{}
\label{fig:trajpicasso}
\end{subfigure}
\begin{subfigure}{0.5\textwidth}
\centering
\includegraphics[width=\linewidth]{figures/blackbird_benchmarks.pdf}
\caption{}
\label{fig:blackbirdbenchmarks}
\end{subfigure}
\end{center}
\caption{
(\subref{fig:trajstar},\subref{fig:trajpicasso}) Top-down view of localisation for \emph{star, forward yaw, max speed $4.0 m/s$} and \emph{picasso, constant yaw, max speed $4.0 m/s$}.
(\subref{fig:blackbirdbenchmarks}) Localisation with our method compared to the benchmark results reported by \citet{blackbird} for \emph{picasso, constant yaw} and \emph{star, forward yaw}, $1$ to $4 m/s$.
}\label{fig:trajectories}
\end{figure}
\setlength{\tabcolsep}{4pt}
\begin{table}[t]
\centering
\caption{
Absolute localisation RMSE for each test trajectory.
See \cref{app:landing} for a discussion of the two noticeable translation RMSE outliers with the learned transition.
}
\label{table:rmse}
\begin{tabular}[b]{rlcrrrrcrrrr}
\toprule
&&& \multicolumn{4}{c}{\textbf{Translational RMSE [m]}} && \multicolumn{4}{c}{\textbf{Rotational RMSE [rad]}}\\[-.7em]
&&& \thead{\hfill proposed \\ \tiny (eng. trans.)} & \thead{\hfill proposed\\ \tiny (learn. trans)} & VIMO & VINS && \thead{\hfill proposed\\ \tiny (eng. trans.)} & \thead{\thead{\hfill proposed\\ \tiny (learn. trans.)}} & VIMO & VINS\\[-.7em]
\midrule \csvreader[
head to column names,
late after line=\\,
]{eval.csv}{}%
{\small\trajectory & \small\velocity && \small \engineeredtransrmse & \small\hybridssmtransrmse & \small\vimotransrmse & \small \vinstransrmse && \small\engineeredrotrmse & \small\hybridssmrotrmse & \small\vimorotrmse & \small\vinsrotrmse}%
\bottomrule
\end{tabular}
\end{table}
\subsection{Agent localisation}
Finally, we evaluate localisation performance during SLAM inference.
\Cref{fig:trajectories} shows estimates for the fastest trajectories in the test set (up to $4m/s$).
We refer to \cref{app:examples} and the supplementary video for more inference examples in different environments.
\Cref{table:rmse} summarises the average absolute RMSE for all test trajectories, evaluated following \citet{rpgeval}.
Here we compare to the results reported by \citet{vimo}, including VIMO \citep{vimo} and VINS-MONO \citep{vinsmono}---two state-of-the art visual odometry methods.
In this case both systems are carefully tuned to the environment.
While the RMSE of our method is not as low as that of the baselines, we note that these are absolute values.
The online translational error of our method does not exceed $0.4m$, which is practical considering the average $232m$ trajectory length.
Our method also succeeds on the fastest \emph{star} test trajectory, for which both baselines have been reported to fail without specific retuning.
We note that the two systems run in real-time, whereas currently our method does not---we will tackle real-time inference in our future work (see \cref{hps}).
We also compare to the system benchmarks provided by \citet{blackbird}, including results for VINS-MONO, VINS-Fusion \citep{vinsfusion} and ORB-SLAM2 \citep{orbslam2}.
We use the same \emph{star} and \emph{picasso} trajectories reported in \cref{table:rmse}, and refer to \citet{blackbird} for the exact evaluation assumptions.
We also explicitly restate a note made by the authors: the benchmarked systems are not carefully tuned to the Blackbird environment and their loop-closure modules are disabled, which might not be reflective of their best possible performance.
Therefore, these baselines represent the performance of an off-the-shelf visual odometry system without changing its hyperparameters.
\Cref{fig:blackbirdbenchmarks} summarises the comparison, reporting error statistics for segments of different length ($x$-axis) divided by the distance travelled.
Localisation with our method is robust and drift does not compound, which we attribute to the global map variable $\Map$ serving as an anchor.
Overall, localisation is successful for all test trajectories and its accuracy is practical and close to that of state-of-the-art systems, while all merits of deep probabilistic generative modelling are retained.
\section{Related work}\label{related}
\paragraph{Generative models for spatial environments}
GTM-SM \citep{gtmsm} focuses on long-term predictions with a non-metric deterministic external memory.
\citet{activeloc} formulate an end-to-end learning model for active global localisation, filtering with a likelihood update predicted by a neural network.
The agent can turn in four directions and move on a plane, perceiving images of the environment.
VAST \citep{vast} assumes a discrete state space for a generative model applied to the 2.5D Vizdoom environment.
\citet{placecells} model agents moving on a 2D grid with latent neurologically-inspired grid and place cells.
Other works propose end-to-end learnable generative scene models \citep{gqn,genesis}, without considering the agent dynamics.
Like in the above, we put major emphasis on the generative predictive distribution of our model.
With it, the agent can imagine the consequences of its future actions, a prerequisite for data-efficient model-based control \citep{deepmbrl,dreamer,planet,learntofly}.
However, the aforementioned deep generative spatial models have only been applied on simulated 2D, 2.5D (movement restricted to a plane) and very simplified 3D environments.
A major challenge when scaling to the real world is to ensure that the learned components, and in turn the generative predictions, generalise to observed but yet unvisited places.
\citet{gregor2019} highlight another problem, that of long-term consistency when predicting ahead, and address it by learning with overshooting.
In contrast, our method resolves these issues by injecting a sufficient amount of domain knowledge, without limiting the flexibility \wrt learning.
To this end, we begin by sharing the probabilistic factorisation of DVBF-LM \citep{abise}, a deep generative model that addresses the tasks of localisation, mapping, navigation and exploration in 2D.
We then redefine the map, the attention, the states, the generation of observations and the overall inference, allowing for real-world 3D modelling and priming our method for data-efficient online inference in the future.
We discuss why these changes are necessary more thoroughly in \cref{app:domainknowledge}.
\paragraph{Combining learning and spatial domain knowledge}
Fully-learned spatial models with an explicit memory component have been studied by \citet{parisotto2018neural,neuralslam,Oh2016Control}.
Further relying on geometric knowledge, \citet{banet} propose learning through the whole bundle adjustment optimisation, formulated on CNN feature maps of the observed images.
\citet{deepfactors} define a SLAM system based on learned latent feature codes of depth images, a continuation of the works by \citet{scenecode,codeslam}.
Factor-graph maximum a posteriori optimisation is then conducted, substituting the observations for their respective low-dimensional codes, leading to point estimates of the individual geometry of $N$ keyframes and the agent poses over time.
\citet{deepsfm} maintain cost volumes \citep{dtam} for discretised poses and depth, and let a 3D CNN learn how to predict the correct geometry and pose estimates from them.
Depth cost volumes are also used by \citet{deeptam} in learning to predict depth and odometry with neural networks.
In the work by \citet{d3vo}, networks that predict odometry and depth are combined with DSO, leading to a SLAM system that utilises learning to its advantage.
\citet{gradslam} investigate differentiable SLAM, treating odometry estimation and mapping separately.
The considered rendering gradients in that method are from the fused map to the observations, which is the opposite of the gradient paths used for learning in our work.
As in our approach, the geometric assumptions in the majority of these works allow the systems to generalise more easily to unseen cases and real-world data.
What distinguishes our method is an explicit generative model, able to predict the agent movement and observations in the future.
Additionally, our approach is fully-probabilistic, maintaining complete distributions over the variables of interest, whereas the aforementioned approaches are not.
Our method is also end-to-end differentiable and can be implemented in auto-diff frameworks, welcoming learned components.
We are bridging the gap between probabilistic generative models, learning and spatial domain knowledge.
\paragraph{Depth estimation and differentiable rendering}
Recent promising approaches combine learning and non-parametric categorical distributions for depth estimation \citep{probdepthfusion,neuralrgbd}, fusing likelihood terms into a consistent depth estimate.
Such depth estimation is compatible with our system and can be used to formulate priors, but for now we rely on a traditional method as a first step \citep{sgbm}.
Inferring whole scenes parameterised with neural networks by backpropagation through realistic differentiable rendering has also become a prevalent direction of research \citep{neuralreflect,nerf,siren}.
In our method the occupancy and colour map are inferred in a similar way, but the raycasting scheme we follow is simple, meant only to illustrate the framework as a whole.
We note that the current inference times of e.g. \citet{neuralreflect} amount to days (see appendix of that work), which is hard to scale to online inference.
Extending our approach with a more advanced rendering method is the subject of future work.
\paragraph{Bayesian SLAM inference}
To keep exposition brief, we refer to \citep{cadena2016past} for an overview of modern SLAM inference and focus only on approaches that have applied fully-Bayesian methods to SLAM.
The inference in this work can be categorised as probabilistic SLAM, other prominent examples of which are FastSLAM \citep{fastslam} and RBPF SLAM \citep{rbpfslam}.
What distinguishes our method is the application of variational inference with SGVB \citep{vae}.
Our model does not restrict the used distributions and allows any differentiable functional form, which enables us to use neural networks.
The contribution by Murphy \citep{murphymap} is one of the first to infer a global map with Bayesian methods.
Bayesian Hilbert maps \citep{bhm} focus on a fully Bayesian treatment of Hilbert maps for long-term mapping in dynamic environments.
Stochastic variational inference is used to infer agent poses from observed 2D image features in~\citep{svislam1,svislam2}.
DVBF-LM \citep{abise} uses Bayes by Backprop \citep{bayesbybackprop} for the inference of the global map variable.
| {'timestamp': '2021-03-16T01:40:12', 'yymm': '2006', 'arxiv_id': '2006.10178', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10178'} | arxiv |
\section{Introduction}
Whether building attribute predictors or taking measurements over a fixed space, combining multiple lists of predictions or measurements is a common final step. When these predictions or measurements are generated from identical processes, differing from each other only as a consequence of intrinsic noise, there will likely be principled and case-specific ways to combine these values across lists. This familiar scenario corresponds to independent, identically distributed measurements of a quantity of interest.
However, it is not uncommon to handle lists that are fundamentally different from one another. In such a scenario, each list corresponds to a different proxy, i.e. a value that is monotonically increasing with a common target quantity but otherwise following a functional relationship that we do not understand. When the problem of combining such lists is supervised, this corresponds to any situation in which we may employ boosting. When the problem is unsupervised, however, we can no longer extract information from the spacing between different scores within a list, and so the only meaningful information provided by each list is a ranking of elements. Given this, order statistics would seem to play a natural role.
\section{Definition}
We begin by defining the joint CDF value for an $n$-dimensional order statistic. Given a sorted (ascending) list $R = [r_1, r_2, \cdots, r_n]$, and fixing $s_0$ to be $0$, the joint CDF value of $R$ is defined to be $V(R) = V_1(R)$, where
\begin{equation}
\label{eq:1}
V_i(R) = \begin{cases}
\bigints_{s_{i-1}}^{r_i}{ds_i} & \text{if $i=n$} \\
\bigints_{s_{i-1}}^{r_i}{V_{i+1}(R) ds_i} & \text{if $0 < i < n$}
\end{cases}
\end{equation}
or, more intuitively,
\begin{equation}
V(R) = \int_{0}^{r_1}\int_{s_1}^{r_2}\cdots \int_{s_{n-1}}^{r_n}{ds_n ds_{n-1}\cdots ds_1} \label{eq:2}
\end{equation}
In addition, we would like to clarify terminology: throughout this paper, ranked lists of elements should be assumed sorted in descending order of score, with "larger rank" referring to smaller scoring elements appearing later in the list.
\section{Previous Usage}
We now describe how the joint CDF value was used in prior work \cite{aerts} \cite{stuart} to combine multiple lists of scores. Let us assume we begin with several ranked lists of elements. We choose as our null hypothesis that each ranked list is generated by randomly permuting a set of elements.
Define the \textbf{rank ratio} of an element in a list to be the rank of the element divided by the length of the list. For a particular element $e$, then, let $R_e$ be the sorted (ascending) list of rank ratios, computed over all the lists in which $e$ is present. \href{https://en.wikipedia.org/wiki/Majorization}{Majorization} induces a partial ordering over the space of such sorted lists as follows: for two such sorted lists $S = [s_i]$ and $R = [r_i]$ of rank ratios, we define $S \leq R$ to mean that $S$ is majorized by $R$, i.e that $s_i \leq r_i\text{ }\forall\text{ }i$. This aligns well with our intuition - if all the rank ratios for an element $e$ are smaller than the corresponding rank ratios for an element $f$, then we can unambiguously state that $e$ should come before $f$ in any merged ranking.
Using this partial ordering, we have that the p-value for a list $R$ under the chosen null hypothesis would be
\begin{equation}
n! \int_{S \leq R}{p(S) dS} = n! \int_{0}^{r_1}p(s_1)\int_{s_1}^{r_2}p(s_2 | s_1)\cdots \int_{s_{n-1}}^{r_n}{p(s_n | s_{n-1}) ds_n ds_{n-1}\cdots ds_1} \label{eq:3}
\end{equation}
where these probabilities are taken under the null hypothesis. It can be shown inductively that the expression in \eqref{eq:3} is equal to $Q(R) = n! V(R)$ if and only if $s_i \sim U(s_{i-1}, 1)\text{ }\forall \text{ }i$.
\begin{theorem}
$\exists \text{ } i | s_i \not\sim U(s_{i-1}, 1) $
\end{theorem}
\begin{proof}
\begin{equation}
P(s_1 \leq x) = 1 - P(s_1 > x) = 1 - \prod_{i}{P(s_i > x)} = 1 - (1-x)^n \label{eq:4}
\end{equation}
It follows that
\begin{equation}
p(s_1 = x) = \frac{d}{dx}P(s_1 \leq x) = n (1-x)^{n-1} \label{eq:5}
\end{equation}
which is not a uniform distribution, providing the desired counterexample.
\end{proof}
It follows that $Q(R)$ cannot be used directly as a p-value against the stated null hypothesis. Presumably unaware of this result, one previous approach \cite{stuart} used $Q(R_e)$ as a p-value for the corresponding element $e$, and produced a combined list by sorting (in ascending order) all elements $e$ according to these p-values . A second group \cite{aerts} demonstrated through numerical experiments that $Q(R)$, unlike a valid p-value, did not follow a uniform distribution under the null hypothesis. This group \cite{aerts} went on to measure the empirical distribution of $Q(R)$ under the null hypothesis and fitted it approximately to a $\beta$ distribution for $n \leq 5$ and a $\gamma$ distribution for larger $n$, ultimately using these fitted distributions to convert the joint CDF values to p-values.
\section{Proposed Usage}
While using the same input (several ranked lists of elements) and assuming the same null hypothesis, we impose one additional constraint: that every element present in at least one list is present in all lists. This constraint can be guaranteed as follows: for each list, add all missing elements to the end of the ranking. If $k$ elements are added in this manner to a list of original size $n$, then each of the added elements are assigned a rank of $n + \frac{k+1}{2}$, i.e. the average rank of all such elements had they been added in an arbitrary order.
After this is done, all ranked lists will be identical in size and in the set of elements they contain. Now, for a given element, let $f_i$ be the fraction of lists in which the element appears at rank $i$. It follows that $\sum_{i}{f_i} = 1$. Furthermore, let $g_i = g_{i-1} + f_i$ be the fraction of lists in which the element appears at rank no greater than $i$, with $g_1 = f_1$, and let $r_i = 1 - g_{n-i}$. In line with the intuition underlying the partial ordering we defined in Section 3, we define here a new partial ordering $e \leq h$ if and only if $g_{e,i} \geq g_{h,i}$ $\forall$ $i \iff r_{e, i} = g_{e, n-i} \leq g_{h, n-i} = r_{h, i}$ $\forall$ $i$, where $g_{e, i}$ and $r_{e,i}$ are the $g_i$ and $r_i$, respectively, for element $e$.
Given this, let us redefine $R_e$ to be the list $[r_{e,i}] = [r_i]$ for $1 \leq i \leq n-1$. Using this definition of $r_i$, we have
\begin{equation}
r_i = 1 - g_{n-i} = 1 - (g_{n-i+1} - f_{n-i+1}) = r_{i-1} + f_{n-i+1} \text{ }\forall \text{ }i > 0 \label{eq:6}
\end{equation}
\begin{theorem}
$r_{i+1} \sim U(r_i, 1)$ $\forall$ $i \geq 0$ under the null hypothesis.
\end{theorem}
\begin{proof}
The recursion in \eqref{eq:6} can be used to show inductively that
\begin{equation}
r_i = \sum_{k=n-i+1}^{n}{f_k} \label{eq:7}
\end{equation}
Given that, let us consider the distribution of $f_{n-i}$ conditioned on $\{f_k, k > n-i\})$ under the null hypothesis. Since each list is assumed to be randomly permuted, it follows that each element $e$ is equally likely to be in any position for a particular list. Thus, conditioned only on $\{f_k, k > n-i\}$, we have that the probability $p_{n-i}$ of $e$ appearing in position $n-i$ in a particular list, is given by the probability that $e$ hasn't already appeared further down in that list, i.e. $1 - r_i$, multiplied by a uniform probability density 1 over the remaining positions. Since $f_{n-i}$ is, by definition, the expectation of this probability $p_{n-i}$ over many lists, it follows that $f_{n-i} \sim U(0, 1-r_i) \iff r_{i+1} = r_i + f_{n-i} \sim U(r_i, 1)$, as desired.
\end{proof}
Thanks to this result, it follows that for $R_e$ \textit{as we have defined it in this section}, $V(R_e)$ can be used directly as a p-value.
\section{Previous Methods of Computation}
The first approach \cite{stuart} discussed earlier attempted to compute $V(R)$ using
\begin{equation}
V(R) = \frac{1}{n} \sum_{i = 1}^{n}{(r_i - r_{i-1})V(R_{-i})} \label{eq:8}
\end{equation}
where $R_{-i}$ is defined as $R$ with $r_i$ removed. A straightforward application of dynamic programming to the recursion in \eqref{eq:8} gives a runtime of $O(n!)$ for computing $V(R)$ using this method .
The second approach \cite{aerts} we referenced was able to derive another recursion over an intermediate function $T_k$:
\begin{equation}
T_k(R) = \sum_{i=1}^{k}{(-1)^{i-1} \frac{T_{k-i}}{i!} (r_{n-k+1})^i} \label{eq:9}
\end{equation}
where $V(R) = T_n(R)$. A straightforward application of dynamic programming to the recursion in \eqref{eq:9} gives a runtime of $O(n^2)$ for computing $V(R)$ using this method.
Both \eqref{eq:8} and \eqref{eq:9} can be derived via manipulations of \eqref{eq:2}, but we have not included these derivations here.
\section{Improved Method of Computation}
For the purposes of this section, let $R = [r_i]$ have length $n$ and let $R_k = [r_i \text{ }\forall\text{ }i \leq k]$ be the subsequence consisting of the first $k$ elements of $R$. We seek to compute $V(R)$ as given by the expression in \eqref{eq:2}. We note that this is simply the $n$-dimensional volume of space that lies on or strictly below the curve defined by $R$. To compute this, we begin by rearranging our integrals, such that the outermost integral is the integral in $s_n$ and the innermost integral is the integral in $s_1$. By construction, we know that $s_i \geq 0$, $s_i \leq r_i$, $s_i \leq s_{i+1}$, and $s_i \leq 1$. Given this, we can write $V(R) = Z_n(R)$ where
\begin{equation}
\label{eq:10}
Z_i(R) = \begin{cases}
\bigint_{0}^{\min{(s_2, r_1)}}{ds_1} & \text{if $i=1$} \\
\bigint_{0}^{\min{(s_{i+1}, r_i)}}{Z_{i-1}(R) ds_i} & \text{if $1 < i \leq n$}
\end{cases}
\end{equation}
with $s_{n+1} = 1$ set for consistency. Less formally, this can be written as
\begin{equation}
V(R) = \int_{0}^{r_n}\int_{0}^{\min{(r_{n-1},s_n)}}\cdots \int_{0}^{\min{(r_{1},s_2)}}{ds_1 ds_2\cdots ds_n} \label{eq:11}
\end{equation}
Substituting $R_k$ for $R$ into \eqref{eq:10} and rearranging, we have that
\begin{equation}
\label{eq:12}
V(R_k) = \int_{0}^{r_k}{Z_{k-1}(R_k) ds_k} = \int_{0}^{r_k}{V(R_{k-2} + [\min{(r_{k-1},s_k)}])ds_k}
\end{equation}
where list addition refers to concatenation. This can be further rewritten as
\begin{equation}
\label{eq:13}
V(R_k) = \int_{0}^{r_{k-1}}{V(R_{k-2} + [s_k])ds_k} + \int_{r_{k-1}}^{r_k}{V(R_{k-1})ds_k}
\end{equation}
Letting $V_k(x) = V(R_{k-1} + [x])$, we can substitute and simplify further to get
\begin{equation}
\label{eq:14}
V_k(r_k) = \left(\int_{0}^{r_{k-1}}{V_{k-1}(s_k)ds_k}\right) +(r_k - r_{k-1})V_{k-1}(r_{k-1})
\end{equation}
We note that
\begin{equation}
\label{eq:15}
\frac{\partial}{\partial x}V_k(x) = V_{k-1}(r_{k-1})
\end{equation}
i.e. $C = \left(V_k(x) - x V_{k-1}(r_{k-1})\right)$ is constant with respect to x. Consequently, integrating both sides of \eqref{eq:14} with respect to $r_k$ gives
\begin{equation}
\label{eq:16}
\int_{0}^{r_k}{V_k(x) dx} = \int_{0}^{r_k}{\left(x V_{k-1}(r_{k-1}) + C\right) dx} = \frac{{(r_k)}^2}{2} V_{k-1}(r_{k-1}) + r_k \left(V_k(r_k) - r_k V_{k-1} (r_{k-1})\right)
\end{equation}
which can be further simplified to
\begin{equation}
\label{eq:17}
\int_{0}^{r_k}{V_k(x) dx} = r_k V_k(r_k) - \frac{{(r_k)}^2}{2} V_{k-1}(r_{k-1})
\end{equation}
Substituting $k-1$ for $k$ in \eqref{eq:17}, substituting the resulting expression into \eqref{eq:14}, and simplifying gives
\begin{equation}
\label{eq:18}
V_k(r_k) = r_k V_{k-1}(r_{k-1}) - \frac{{(r_{k-1})}^2}{2} V_{k-2}(r_{k-2})
\end{equation}
Since we ultimately wish to find $V_n(r_n)$, \eqref{eq:18} provides us with a convenient recursive formula that we can use to compute $V_n(r_n)$ in $O(n)$ time. This will allow us to feasibly compute the statistic for the proposed usage in Section 4, as the number $n$ of elements being sorted is usually much greater than the number $n$ of lists being aggregated. To use this recursion, we note that the explicit base cases are
\begin{equation}
\label{eq:19}
V_1(r_1) = r_1
\end{equation}
\begin{equation}
\label{eq:20}
V_2(r_2) = r_2 r_1 - \frac{(r_1)^2}{2}
\end{equation}
and the implicit base cases are
\begin{equation}
\label{eq:21}
V_0 = V([]) = 1
\end{equation}
\section{Implementation}
An implementation of the proposed usage and the improved method of computation can be found on GitHub, under arvindthiagarajan/multimodal-statistics.
\bibliographystyle{plain}
| {'timestamp': '2020-06-19T02:02:39', 'yymm': '2006', 'arxiv_id': '2006.10124', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10124'} | arxiv |
\section{Introduction} \label{sec:int}
\subsection{Background}
Change-point analysis plays a significant role in various fields when a sequence of observations is collected. In general, the problem concerns testing whether or not a change has occurred, or several changes might have occurred, and identifying the locations of any such changes. In this paper, we consider the offline change-point detection problem where a sequence of independent observations $\{\by_{i}\}_{i=1,\ldotp\ldotp\ldotp,n}$ is completely observed at the time when data analysis is conducted. Here, $n$ is the length of the sequence, and $i$ is the time index or other meaningful index depending on the specific application. We consider testing the null hypothesis
\begin{equation} \label{eq1.1}
H_{0} : \by_{i} \sim F_{0}, \ i = 1,\ldotp\ldotp\ldotp,n,
\end{equation}
against the single change-point alternative
\begin{equation} \label{eq1.2}
H_{1} : \exists \ 1\le \tau\le n, \ \by_{i} \sim \left\{
\begin{tabular}{c}
$F_{1}$, \ $i > \tau$ \ \ \ \ \ \ \ \\
$F_{0}$, \ otherwise, \\
\end{tabular}
\right.
\end{equation}
or the changed-interval alternative
\begin{equation} \label{eq1.3}
H_{2} : \exists \ 1\le \tau_{1}\le \tau_{2}\le n, \ \by_{i} \sim \left\{
\begin{tabular}{c}
$F_{1}$, \ $i = \tau_{1}+1,\ldotp\ldotp\ldotp,\tau_{2}$ \\
$F_{0}$, \ otherwise, \ \ \ \ \ \ \ \ \ \ \ \ \\
\end{tabular}
\right.
\end{equation}
where $F_{0}$ and $F_{1}$ are two different distributions.
This problem has been extensively studied for univariate data; see \cite{chen2011parametric} for a survey. However, in many modern applications, $\by_i$ is high-dimensional or even non-Euclidean. For high-dimensional data, most methods are based on parametric models; see for example \citet{Zhang2010detecting, wang2017change, wang2018high}. To apply these methods, the data sequence needs to follow specific parametric models. In the nonparametric domain, \citet{harchaoui2009kernel} made use of kernel methods, \citet{lung2011homogeneity} utilized marginal rankings, and \citet{matteson2014nonparametric} made use of distances among observations. These methods can be applied to a wider range of problems than parametric methods. However, it is in general difficult to conduct theoretical analysis on nonparametric methods and none of these nonparametric methods provides analytic formulas for false discovery control, making them difficult to be applied to large datasets.
\subsection{Graph-based change-point methods} \label{restriction}
Recently, \citet{chen2015graph} and \citet{chu2019asymptotic} developed a graph-based framework to detect the change-point for high-dimensional and non-Euclidean data sequences. This framework is based on a similarity graph $G$, such as a minimum spanning tree (MST), which is a spanning tree that connects all observations with the sum of distances of the edges in the tree minimized, constructed on the sample space. Based on $G$ over $t$, test statistics rely on three basic quantities, $R_{0,G}(t)$, $R_{1,G}(t)$, and $R_{2,G}(t)$, where for each $t$ $R_{0,G}(t)$ is the number of edges connecting observations before and after $t$, $R_{1,G}(t)$ is the number of edges connecting observations prior to $t$, and $R_{2,G}(t)$ is the number of edges connecting observations after $t$. Then, four scan statistics were studied: the original edge-count scan statistic $Z(t)$, the weighted edge-count scan statistic $Z_{w}(t)$, the generalized edge-count scan statistic $S(t)$, and the max-type edge-count scan statistic $M(t)$ that can be applied to various alternatives. For detailed comparisons, see \cite{chu2019asymptotic}.
While the methods proposed by \citet{chen2015graph} and \citet{chu2019asymptotic} work well for continuous data, they are problematic for data with repeated observations, which is common for discrete data, such as network data. The reason is that these methods depend on the similarity graph constructed on observations. When there are repeated observations, the similarity graph is in general not uniquely defined and these methods are troublesome. For example, \citet{chen2015graph} analyzed a phone-call network dataset and the task was to test whether there is any change in the dynamics of the networks over time. In this dataset, a few networks in the sequence are exactly the same. \citet{chen2015graph} used the MST as the similarity graph.
More specifically, in the phone-call network dataset, there are in total 330 networks $\{\by_{1}, \ldots, \by_{330}\}$ in the sequence and among them are 290 distinct networks. For example, $\by_{1}$, $\by_{6}$, $\by_{16}$ are exactly the same. All repeated observations are listed in Supplement A. Due to this, there are numerous ways in assigning edges in the MST with repeated observations. Hence, the MST is not uniquely defined and existing graph-based methods are not reliable since they are formulated by the unique similarity graph on pooled observations.
\begin{table*} [h]
\caption{The $p$-values and corresponding test statistics (in parentheses) for four testing procedures proposed in \citet{chen2015graph} and \citet{chu2019asymptotic}: an original edge-count scan statistic $(\max_{n_0\leq t\leq n_1} Z_0(t))$, a generalized edge-count scan statistic $(\max_{n_0\leq t\leq n_1} S(t))$, a weighted edge-count scan statistic $(\max_{n_0\leq t\leq n_1} Z_w(t))$, and a max-type edge-count scan statistic $(\max_{n_0\leq t\leq n_1} M(t))$. Here, $n_0$ is set to be $\lceil0.05n\rceil$ = 17 and $n_{1} = 330-n_{0}$, where $\lceil x\rceil$ denotes the smallest integer greater than or equal to $x$.}
\label{tab:phone}
\centering
\begin{tabular}{clll}
& MST \#1 & MST \#2 & MST \#3 \\
$\max_{n_0\leq t\leq n_1} Z_0(t)$ & 0.09 (2.32)& 0.91 (0.92) & 0.51 (1.57) \\
$\max_{n_0\leq t\leq n_1} S(t)$ & 0.04 (13.61)& 0.08 (12.31) & 0.01 (16.36) \\
$\max_{n_0\leq t\leq n_1} Z_w(t)$ & 0.44 (2.11) & 0.02 (3.49) & 0.88 (1.54) \\
$\max_{n_0\leq t\leq n_1} M(t)$ & 0.09 (3.05) & 0.02 (3.49) & 0.05 (3.27) \\
\end{tabular}
\end{table*}
Table \ref{tab:phone} lists test statistics and their corresponding $p$-values of four testing procedures proposed in \citet{chen2015graph} and \citet{chu2019asymptotic} on three randomly chosen MSTs. We see that the $p$-value depends heavily on the choice of the MST: It could be very small under one MST, but very large on another MST, leading to completely different conclusions on whether the sequence is homogeneous or not. Moreover, since the number of possible MSTs is huge, it is impractical to compute the test statistics on all possible MSTs directly to get a summary.
\subsection{Our contribution}
We extend the methods in \cite{chen2013graph} and \cite{zhang2017graph} to the change-point settings and propose new graph-based testing procedures that can deal with repeated observations properly. This work fills the gap for the graph-based framework in dealing with discrete data. We show that the new tests are asymptotically distribution-free under the null hypothesis of no change and reveal that the limiting distributions for two approaches in \cite{chen2013graph} are the same, even for continuous data. We also derive analytic formulas to approximate permutation $p$-values for those modified test statistics, making them fast applicable to real datasets. To improve the analytical $p$-value approximations for finite sample sizes, skewness correction is also performed. We show that the proposed tests work well to detect the change when the data has repeated observations. We illustrate the new testing procedures through an analysis on phone-call network dataset. The new methods are implemented in an $\texttt{R}$ package $\texttt{gSeg}$ {available on CRAN}.
\section{Notations and related existing works} \label{not}
For data with repeated observations, we represent the data using a contingency table for each $t$. Suppose that there are in total $n$ observations and $K$ distinct values, which we also refer to as categories in the following. Each $t$ divides the sequence into two groups, before or at time $t$ (Group 1) and after time $t$ (Group 2). Let $n_{ik}(t)$ be the number of observations in group $i \ (i = 1, 2)$ and category $k \ (k = 1,\ldotp\ldotp\ldotp,K)$ and $m_{k} \ (k = 1,\ldotp\ldotp\ldotp,K)$ be the number of observations in category $k$. Notice that $m_{k} = n_{1k}(t) + n_{2k}(t) \ (k = 1,\ldotp\ldotp\ldotp,K)$, $\sum_{k=1}^{K}m_{k} = n$, $\sum_{k=1}^{K}n_{1k}(t) = t$, and $\sum_{k=1}^{K}n_{2k}(t) = n-t$.
\begin{table*}[h]
\centering
\caption{Notations at time $t$}
\label{t2}
\begin{tabular}{cccccc}
Index of distinct values & 1 & 2 & $\cdotp\cdotp\cdotp$ & $K$ & Total \\
Group 1 & $n_{11}(t)$ & $n_{12}(t)$ & $\cdotp\cdotp\cdotp$ & $n_{1K}(t)$ & $t$ \\
Group 2 & $n_{21}(t)$ & $n_{22}(t)$ & $\cdotp\cdotp\cdotp$ & $n_{2K}(t)$ & $n-t$ \\
Total & $m_{1}$ & $m_{2}$ & $\cdotp\cdotp\cdotp$ & $m_{K}$ & $n$ \\
\end{tabular}
\end{table*}
In \citet{chen2013graph} and \citet{zhang2017graph}, the authors studied ways to extend the underlying graph-based two-sample tests to accommodate data with repeated observations under the two-sample testing framework. When data has repeated observations, the similarity graph is not uniquely defined based on common optimization criteria, such as the MST, leading to multiple optimal graphs. The authors considered two ways to incorporate information from these graphs: averaging and union. To be more specific, they first construct the similarity graph on the distinct values, denoted by $C_{0}$. Here, $C_{0}$ could be the MST on all distinct values, the nearest neighbor link, the union of all possible MSTs on the distinct values, when the MST on the distinct values is not unique, or some other meaningful graphs. Then, the optimal graph initiated from $C_{0}$ is defined in the following way: For each pair of edges $(k_{1},k_{2}) \in C_{0}$, randomly choose an observation with the value indexed by $k_{1}$ and an observation with the value indexed by $k_{2}$, and connect these two observations; then, for each $k_{i} \ (i=1,2)$, if there are more than one observation (repeated observations) with the value indexed by $k_{i}$, connect them by a spanning tree (any edges in this spanning tree has distance 0). More detail explanations for $C_{0}$ are provided in Supplement B. Based on these optimal graphs, averaging statistic is defined by averaging the test statistic over all optimal graphs and union statistic is defined by calculating the test statistic on the union of all optimal graphs.
\section{Proposed tests} \label{sec:new}
\subsection{Extended test statistics for data with repeated observations} \label{sec:extended}
Here, we focus on extending the weighted, generalized, and max-type test statistics for repeated observations, which will turn out to be the asymptotic distribution-free tests. Details for extending the original edge-count test is in Supplement E. Based on the two-sample test statistics in \citet{chen2013graph} and \citet{zhang2017graph}, we could define the extended basic quantities at time $t$ under the averaging approach as follows:
\begin{align}
R_{1,(a)}(t) &= \sum_{k=1}^{K}\frac{n_{1k}(t)\left(n_{1k}(t)-1\right)}{m_{k}} + \sum_{(u,v)\in C_{0}}\frac{n_{1u}(t)n_{1v}(t)}{m_{u}m_{v}}, \\
R_{2,(a)}(t) &= \sum_{k=1}^{K}\frac{n_{2k}(t)\left(n_{2k}(t)-1\right)}{m_{k}} + \sum_{(u,v)\in C_{0}}\frac{n_{2u}(t)n_{2v}(t)}{m_{u}m_{v}},
\end{align}
and under the union approach as follows:
\begin{align}
R_{1,(u)}(t) &= \sum_{k=1}^{K}\frac{n_{1k}(t)\left(n_{1k}(t)-1\right)}{2}+ \sum_{(u,v)\in C_{0}}n_{1u}(t)n_{1v}(t), \\
R_{2,(u)}(t) &= \sum_{k=1}^{K}\frac{n_{2k}(t)\left(n_{2k}(t)-1\right)}{2}+ \sum_{(u,v)\in C_{0}}n_{2u}(t)n_{2v}(t).
\end{align}
These are discrete data version of $R_{1,G}(t)$ and $R_{2,G}(t)$ to address infeasibility of computing test statistics in data with repeated observations. Hence, relatively large value of the sum of $R_{1,(a)}(t)$ and $R_{2,(a)}(t)$ or $R_{1,(u)}(t)$ and $R_{2,(u)}(t)$ could be the evidence against the null hypothesis.
Under the null hypothesis $H_{0}$ (\ref{eq1.1}), the null distribution is defined to be the permutation distribution, which places $1/n!$ probabilities on each of the $n!$ permutations of $\{\by_{i}\}_{i=1,\ldotp\ldotp\ldotp,n}$. With no further specification, $\text{pr}$, $E$, $\textsf{Var}$, and $\text{cov}$ denote the probability, the expectation, the variance, and the covaraince, respectively, under the permutation null distribution. Then, analytic formulas for the expectation and the variance of extended basic quantities can be calculated through combinatorial analysis and detailed expressions and proof can be found in Supplement C.
For any candidate value $t$ of $\tau$, the extended test statistics can be defined as
\begin{alignat*}{2}
&\ \ Z_{w,(a)}(t) = \frac{R_{w,(a)}(t)-E\left(R_{w,(a)}(t)\right)}{\surd{\textsf{Var}\left(R_{w,(a)}(t)\right)}}, \quad &&Z_{w,(u)}(t) = \frac{R_{w,(u)}(t)-E\left(R_{w,(u)}(t)\right)}{\surd{\textsf{Var}\left(R_{w,(u)}(t)\right)}}, \\
& \ \ S_{(a)}(t) = Z_{w,(a)}^2(t) + Z_{d,(a)}^2(t), \quad &&S_{(u)}(t) = Z_{w,(u)}^2(t) + Z_{d,(u)}^2(t),\\
& \ \ M_{(a)}(t) = \max\left(Z_{w,(a)}(t),|Z_{d,(a)}(t)|\right), \quad
&&M_{(u)}(t) = \max\left(Z_{w,(u)}(t),|Z_{d,(u)}(t)|\right),
\end{alignat*}
where
\begin{align*}
R_{w,(a)}(t) = (1-w(t))R_{1,(a)}(t) + w(t)R_{2,(a)}(t),& \ \ R_{w,(u)}(t) = (1-w(t))R_{1,(u)}(t) + w(t)R_{2,(u)}(t), \\
Z_{d,(a)}(t) = \frac{R_{d,(a)}(t)-E\left(R_{d,(a)}(t)\right)}{\surd{\textsf{Var}\left(R_{d,(a)}(t)\right)}},& \ \ R_{d,(a)}(t) = R_{1,(a)}(t) - R_{2,(a)}(t), \\
Z_{d,(u)}(t) = \frac{R_{d,(u)}(t)-E\left(R_{d,(u)}(t)\right)}{\surd{\textsf{Var}\left(R_{d,(u)}(t)\right)}},& \ \ R_{d,(u)}(t) = R_{1,(u)}(t) - R_{2,(u)}(t),
\end{align*}
with $w(t) = (t-1)/(n-2)$. Relatively large values of test statistics are the evidence against the null.
\subsection{New scan statistics}
Based on the extended statistics, we could define the scan statistics for the single change-point alternative to handle data with repeated observations as follows:
\begin{enumerate}
\item Extended weighted edge-count scan statistic: $\max_{n_{0}\le t \le n_{1}}Z_{w,(a)}(t)$ \ \& \ $\max_{n_{0}\le t \le n_{1}}Z_{w,(u)}(t)$,
\item Extended generalized edge-count scan statistic: $\max_{n_{0}\le t \le n_{1}}S_{(a)}(t)$ \ \& \ $\max_{n_{0}\le t \le n_{1}}S_{(u)}(t)$,
\item Extended max-type edge-count scan statistic: $\max_{n_{0}\le t \le n_{1}}M_{(a)}(t)$ \ \& \ $\max_{n_{0}\le t \le n_{1}}M_{(u)}(t)$,
\end{enumerate}
where $n_0$ and $n_1$ are set to be pre-specified values. For example, we can set $n_{0} = \lceil0.05n\rceil$ and $n_{1} = n-n_{0}$ in order to contain enough observations to represent the distribution.
Each scan statistic has its own characteristics aimed for different situations (see Section \ref{sec:simu} for a comparison of them). For example, the extended weighted edge-count test is useful when a change-point occurs away from the middle of the sequence. The extended generalized edge-count test is effective under both location and scale alternatives. The extended max-type edge-count test is similar but gives more accurate $p$-value approximation. The null hypothesis is rejected if the maxima is greater than a certain threshold. How to choose the threshold to control the type I error rate is described in Section \ref{sec:asym}.
\begin{figure}[h]
\centering
\includegraphics[width=4.4in]{illustration.png}
\caption{Plots of $S_{(a)}(t)$ and $S_{(u)}(t)$ against $t$ from a typical observation from Multinomial$(10, prob_{1})$ and the second 50 observations from Multinomial$(10, prob_{2})$ where $prob_{1} = (0.2,0.3,0.3,0.2)^{T}$ and $prob_{2}= (0.4,0.3,0.2,0.1)^{T}$ (left panel), and all 100 observations from Multinomial$(10, prob_{1})$ (right panel). Here, $C_{0}$ is the nearest neighbor link on Euclidean distance.}
\label{f2}
\end{figure}
For illustration, Figure \ref{f2} plots the processes of $S_{(a)}(t)$ and $S_{(u)}(t)$ for the first 50 observation generated from Multinomial$\left(10, (0.2,0.3,0.3,0.2)^{T}\right)$ and the second 50 observations generated from Multinomial$\left(10, (0.4,0.3,0.2,0.1)^{T}\right)$ with $C_0$ the nearest neighbor link constructed on the Euclidean distance. We see that both $S_{(a)}(t)$ and $S_{(u)}(t)$ peak at the true change-point $\tau = 50$ (left panel). On the other hand, when there is no change-point, $S_{(a)}(t)$ and $S_{(u)}(t)$ have random fluctuations with smaller maximum values (right panel). Illustrations of other test statistics are provided in Supplement D.
For testing the null $H_{0}$ (\ref{eq1.1}) against the changed-interval alternative $H_{2}$ (\ref{eq1.3}), test statistics can be derived in a similar way to the single change-point case. For example, the extended generalized edge-count scan statistics are
\begin{equation*}
\max_{\substack{1<t_{1}<t_{2}\le n \\ n_{0}\le t_{2}-t_{1} \le n_{1}}}S_{(a)}(t_{1},t_{2}) \ \ \ \text{ and } \max_{\substack{1<t_{1}<t_{2}\le n \\ n_{0}\le t_{2}-t_{1} \le n_{1}}}S_{(u)}(t_{1},t_{2})
\end{equation*}
for the averaging and union approaches, respectively, where $S_{(a)}(t_{1},t_{2})$ and $S_{(u)}(t_{1},t_{2})$ are the extended generalized edge-count statistics on the two samples: observations within $[t_{1},t_{2})$ and observations outside $[t_{1},t_{2})$. The details of all statistics for the changed-interval alternative are in Supplement F.
\section{Analytical $p$-value approximation} \label{sec:asym}
\subsection{Asymptotic distributions of the stochastic processes} \label{s4.1}
{We first consider the averaging approach.} We are concerned with the tail distribution of the scan statistics under $H_{0}$. Take the extended generalized edge-count scan statistic as an example, we want to compute
\begin{equation} \label{e4.1}
\text{pr}\left(\max_{n_{0}\le t \le n_{1}}S_{(a)}(t)\right) , \ \ \text{pr}\left(\max_{n_{0}\le t \le n_{1}}S_{(u)}(t)\right)
\end{equation}
for the single change-point alternative, and
\begin{equation} \label{e4.2}
\text{pr}\left(\max_{\substack{1<t_{1}<t_{2}\le n \\ n_{0}\le t_{2}-t_{1} \le n_{1}}}S_{(a)}(t_{1},t_{2})\right) , \ \ \text{pr}\left(\max_{\substack{1<t_{1}<t_{2}\le n \\ n_{0}\le t_{2}-t_{1} \le n_{1}}}S_{(u)}(t_{1},t_{2})\right)
\end{equation}
for the changed-interval alternative.
Under the null hypothesis, the scan statistics are defined as the permutation distribution. For small sample size $n$, we can directly sample from the permutation distribution to compute the permutation $p$-value. However, when $n$ is large, one needs to draw a large number of random permutations to get a good estimate of the $p$-value, which is very time consuming. Hence, we seek to derive analytic approximations to these tail probabilities.
By the definition of $Z_{w,(a)}(t)$, $S_{(a)}(t)$, and $M_{(a)}(t)$, stochastic processes $\{Z_{w,(a)}(t)\}$, $\{S_{(a)}(t)\}$, and $\{M_{(a)}(t)\}$ boil down to two pairs of basic processes: $\{Z_{w,(a)}(t)\}$ and $\{Z_{d,(a)}(t)\}$ for the single change-point case and $\{Z_{w,(a)}(t_{1},t_{2})\}$ and $\{Z_{d,(a)}(t_{1},t_{2})\}$ for the changed-interval case in the similar way. Therefore, we first study the properties of these basic stochastic processes. Let $\mathcal{E}_{u}^{C_{0}}$ be the subgraph of $C_{0}$ containing all edges that connect to node $u$, $\mathcal{E}_{u,2}$ be the set of edges in $C_{0}$ that contains at least one node in $\mathcal{E}_{u}^{C_{0}}$, and $|\mathcal{E}_{u}^{C_{0}}|$ and $|\mathcal{E}_{u,2}^{C_{0}}|$ be the number of edges in the sets. To derive the asymptotic behavior of the stochastic processes in averaging approach, we work under the following conditions:
\begin{condition} \label{c4.1}
$|C_{0}|$, \ $\sum_{(u,v)\in C_{0}}(m_{u}m_{v})^{-1} = O(n)$.
\end{condition}
\begin{condition} \label{c4.2}
$\sum_{u=1}^{K}m_{u}\left(m_{u}+|\mathcal{E}_{u}^{C_{0}}|\right)\left(\sum_{v\in\mathcal{V}_{u}^{C_{0}}}m_{v}+|\mathcal{E}_{u,2}^{C_{0}}|\right) = o(n^{3/2})$.
\end{condition}
\begin{condition} \label{c4.3}
$\sum_{(u,v)\in C_{0}}\left(m_{u}+m_{v}+|\mathcal{E}_{u}^{C_{0}}|+|\mathcal{E}_{v}^{C_{0}}|\right)\big(\sum_{w\in\mathcal{V}_{u}^{C_{0}}\cup\mathcal{V}_{v}^{C_{0}}}m_{w}+|\mathcal{E}_{u,2}^{C_{0}}| + |\mathcal{E}_{v,2}^{C_{0}}|\big)$ \\ \indent\indent\indent\indent\indent\indent\indent\indent\indent $= o(n^{3/2})$.
\end{condition}
\begin{condition} \label{c4.4}
$\sum_{u=1}^{K}(|\mathcal{E}_{u}^{C_{0}}|-2)^2/(4m_{u})-(|C_{0}|-K)^2/n = O(n)$.
\end{condition}
Let $[x]$ denotes the largest integer that is no larger than $x$.
\begin{theorem} \label{thm:averaging}
Under Conditions \ref{c4.1}--\ref{c4.4}, as $n\rightarrow\infty$,
\begin{enumerate}
\item $\{Z_{w,(a)}([nw]) : 0 < w < 1\}$ and $\{Z_{d,(a)}([nw]) : 0 < w < 1\}$ converge to independent Gaussian processes in finite dimensional distributions, which we denote as $\{Z_{w,(a)}^{*}(w) : 0 < w < 1\}$ and $\{Z_{d,(a)}^{*}(w) : 0 < w < 1\}$, respectively.
\item $\{Z_{w,(a)}([nw_{1}],[nw_{2}]) : 0 < w_{1} < w_{2} < 1\}$ and $\{Z_{d,(a)}([nw_{1}],[nw_{2}]) : 0 < w_{1} < w_{2} < 1\}$ converge to independent Gaussian random fields in finite dimensional distributions, which we denote as $\{Z_{w,(a)}^{*}(w_{1},w_{2}) : 0 < w_{1} <w_{2} < 1\}$ and $\{Z_{d,(a)}^{*}(w_{1},w_{2}) : 0 < w_{1} < w_{2} < 1\}$, respectively.
\end{enumerate}
\end{theorem}
The proof for this theorem uses the technique developed in \cite{chen2015graph} that utilizes the Stein’s method \citep{ChenShao2005}. The details of the proof are in Supplement G.
Let $\rho_{w,(a)}^{*}(u,v) = \text{cov}(Z_{w,(a)}^{*}(u),Z_{w,(a)}^{*}(v))$ and $\rho_{d,(a)}^{*}(u,v) = \text{cov}(Z_{d,(a)}^{*}(u), Z_{d,(a)}^{*}(v))$. The next theorem states explicit expressions for the covariance functions of the limiting Gaussian process, $\{Z_{w,(a)}^{*}(w), \ 0<w<1\}$ and $\{Z_{d,(a)}^{*}(w), \ 0<w<1\}$. It is proved through combinatorial analysis and details are given in Supplement H.
\begin{theorem} \label{t4.7}
The covariance functions of the Gaussian processes $Z_{w,(a)}^{*}(w)$, and $Z_{d,(a)}^{*}(w)$ have the following expressions:
\begin{align*}
\rho_{w,(a)}^{*}(u,v) = \frac{(u\wedge v)\left\{1-(u\vee v)\right\} }{(u\vee v)\left\{ 1-(u\wedge v)\right\} }, \ \
\rho_{d,(a)}^{*}(u,v) = \left[\frac{(u\wedge v)\left\{1-(u\vee v)\right\} }{(u\vee v)\left\{1-(u\wedge v)\right\} }\right]^{1/2},
\end{align*}
where $u\wedge v = \min(u,v)$ and $u\vee v = \max(u,v)$.
\end{theorem}
{For the union approach}, let $\bar{G}$ be the set of graphs that the union of all possible optimal graphs between observations $\{y_{i}\}$, $\mathcal{E}_{i}^{\bar{G}}$ be the subgraph of $\bar{G}$ containing all edges that connect to node $y_{i}$, and $|\mathcal{E}_{i}^{\bar{G}}|$ be the number of edges in the set. We work under
\begin{condition} \label{c4.8}
$|\bar{G}| = O(n)$.
\end{condition}
\begin{condition} \label{c4.9}
$\sum_{u=1}^{K}m_{u}^3\sum_{v\in\mathcal{V}_{u}^{C_{0}}}m_{v} \sum_{v\in\mathcal{V}_{u}^{C_{0}}}m_{v}\left(m_{v}+\sum_{w\in\mathcal{V}_{v}^{C_{0}}\backslash\{v\}}m_{w}\right) = o(n^{3/2})$.
\end{condition}
\begin{condition} \label{c4.10}
$\sum_{(u,v)\in C_{0}}m_{u}m_{v}\left(m_{u}\sum_{w\in\mathcal{V}_{u}^{C_{0}}}m_{w}+m_{v}\sum_{w\in\mathcal{V}_{v}^{C_{0}}}m_{w}\right)$ \\
\indent\indent\indent\indent \indent\indent\indent\indent \indent\indent\indent $ \times \left\{\sum_{w\in\mathcal{V}_{u}^{C_{0}}\cup\mathcal{V}_{v}^{C_{0}}, \ y \in \mathcal{V}_{w}^{C_{0}}\backslash\{w\}}m_{w}\left(m_{w}+m_{y}\right)\right\} = o(n^{3/2}). $
\end{condition}
\begin{condition} \label{c4.11}
$\sum_{i=1}^{n}|\mathcal{E}_{i}^{\bar{G}}|^2-4|\bar{G}|^2/n = O(n)$.
\end{condition}
\begin{theorem} \label{thm:union}
Under Conditions \ref{c4.8}--\ref{c4.11}, as $n\rightarrow\infty$,
\begin{enumerate}
\item $\{Z_{w,(u)}([nw]) : 0 < w < 1\}$ and $\{Z_{d,(u)}([nw]) : 0 < w < 1\}$ converge to independent Gaussian processes in finite dimensional distributions, which we denote as $\{Z_{w,(u)}^{*}(w) : 0 < w < 1\}$ and $\{Z_{d,(u)}^{*}(w) : 0 < w < 1\}$, respectively.
\item $\{Z_{w,(u)}([nw_{1}],[nw_{2}]) : 0 < w_{1} < w_{2} < 1\}$ and $\{Z_{d,(u)}([nw_{1}],[nw_{2}]) : 0 < w_{1} < w_{2} < 1\}$ converge to independent Gaussian random fields in finite dimensional distributions, which we denote as $\{Z_{w,(u)}^{*}(w_{1},w_{2}) : 0 < w_{1} <w_{2} < 1\}$ and $\{Z_{d,(u)}^{*}(w_{1},w_{2}) : 0 < w_{1} < w_{2} < 1\}$, respectively.
\end{enumerate}
\end{theorem}
The details of the proof are in Supplement I.
Let $\rho_{w,(u)}^{*}(u,v) = \text{cov}(Z_{w,(u)}^{*}(u),Z_{w,(u)}^{*}(v))$ and $\rho_{d,(u)}^{*}(u,v) = \text{cov}(Z_{d,(u)}^{*}(u), Z_{d,(u)}^{*}(v))$. The next theorem states explicit expressions for the covariance functions of the limiting Gaussian processes, $\{Z_{w,(u)}^{*}(w), \ 0<w<1\}$, and $\{Z_{d,(u)}^{*}(w), \ 0<w<1\}$. Its proof is in Supplement J.
\begin{theorem} \label{t4.14}
The covariance functions of the Gaussian processes $Z_{w,(u)}^{*}(w)$, and $Z_{d,(u)}^{*}(w)$ have the follwoing expressions:
\begin{align*}
\rho_{w,(u)}^{*}(u,v) = \frac{(u\wedge v)\left\{1-(u\vee v)\right\} }{(u\vee v)\left\{ 1-(u\wedge v)\right\} }, \ \
\rho_{d,(u)}^{*}(u,v) = \left[\frac{(u\wedge v)\left\{1-(u\vee v)\right\} }{(u\vee v)\left\{1-(u\wedge v)\right\} }\right]^{1/2}.
\end{align*}
\end{theorem}
\begin{remark}
By Theorems \ref{t4.7}, \ref{t4.14}, we see that the limiting distributions for $\{Z_{w,(a)}([nw]) : 0<w<1\}$ and $\{Z_{w,(u)}([nw]) : 0<w<1\}$ are the same and do not depend on the graph at all. The same story for $Z_{d}$'s. In addition, their covariance functions in Theorem \ref{t4.7} and \ref{t4.14} are the same as Theorem 4.3 in \cite{chu2019asymptotic}. Hence, limiting distributions of the extended graph-based tests based on $Z_{w}$, $S$, $M$ are exactly the same as their corresponding versions for continuous data. On the other hand, the limiting distributions of the extended original edge-count scan statistics differ from their corresponding versions under the continuous setting (see details in Supplement E).
\end{remark}
\begin{remark} \label{reamark:averaging}
Conditions \ref{c4.1}--\ref{c4.11} all constrain the number of repeated observations. Conditions \ref{c4.1} and \ref{c4.8} can usually be satisfied with an appropriate choice of $C_{0}$. Conditions \ref{c4.2}, \ref{c4.3}, \ref{c4.9} and \ref{c4.10} constrain the degrees of nodes in the graph $C_{0}$ such that they cannot be too large. Condition \ref{c4.4} ensures that $(R_{1,(a)}(t),R_{2,(a)}(t))^{T}$ does not degenerate asymptotically so that $S_{(a)}(t)$ is well defined. Similar for Condition \ref{c4.11}.
{We check these conditions through simulation studies (Supplement L) and see that some of them could be violated even when the $p$-value approximation still works well.
\cite{zhu2021limiting} recently studied graph-based two-sample tests for continuous data and they proposed much more relaxed conditions than those in \cite{chu2019asymptotic}. They checked their conditions under both sparse and dense graphs and the conditions hold well. We believe that conditions for data with repeated observations under the change-point setting can also be relaxed. This requires substantial work and we leave this to our future research.}
\end{remark}
\subsection{Asymptotic $p$-value approximation} \label{s4.3}
We now examine the asymptotic behavior of tail probabilities. Following similar arguments in the proof for Proposition 3.4 in \citet{chen2015graph}, we can obtain the foundation for analytical approximations to the probabilities. Assume that $n_{0}, n_{1}, n, b \rightarrow \infty$ in a way such that for some $0 < x_{0} < x_{1} < 1$ and $b_{1} > 0$, $n_{0}/n \rightarrow x_{0}, \ n_{1}/n \rightarrow x_{1}, \ b/\surd{n} \rightarrow b_{1}$.
Based on Theorem \ref{thm:averaging} and \ref{thm:union}, as $n\rightarrow\infty$, for both averaging and union approaches, we have
\begin{align*}
\text{pr}\left(\max_{n_{0}\leq t \leq n_{1}}Z_{w}^{*}(t/n) > b\right) &\sim b\phi(b)\int_{x_{0}}^{x_{1}}h_{w}^{*}(x)\nu\left[b_{1}\left\{2h_{w}^{*}(x)\right\}^{1/2}\right]dx, \\
\text{pr}\left(\max_{n_{0}\leq t \leq n_{1}}|Z_{d}^{*}(t/n)| > b\right) &\sim 2b\phi(b)\int_{x_{0}}^{x_{1}}h_{d}^{*}(x)\nu\left[b_{1}\left\{2h_{d}^{*}(x)\right\}^{1/2}\right]dx,
\end{align*}
where $\nu(s) \approx (2/s)\left\{\Phi(s/2)-0.5\right\}/\left\{(s/2)\Phi(s/2)+\phi(s/2)\right\}$ \citep{siegmund2007statistics} with $\Phi(\cdot)$ and $\phi(\cdot)$ being the standard normal cumulative density function and probability density function, respectively, and
\begin{align*}
h_{w}^{*}(x) = \lim_{s\nearrow x}\frac{\partial\rho_{w,(a)}^{*}(s,x)}{\partial s} & = -\lim_{s\searrow x}\frac{\partial\rho_{w,(a)}^{*}(s,x)}{\partial s} = \lim_{s\nearrow x}\frac{\partial\rho_{w,(u)}^{*}(s,x)}{\partial s} = -\lim_{s\searrow x}\frac{\partial\rho_{w,(u)}^{*}(s,x)}{\partial s}, \\
h_{d}^{*}(x) = \lim_{s\nearrow x}\frac{\partial\rho_{d,(a)}^{*}(s,x)}{\partial s} & = -\lim_{s\searrow x}\frac{\partial\rho_{d,(a)}^{*}(s,x)}{\partial s}=\lim_{s\nearrow x}\frac{\partial\rho_{d,(u)}^{*}(s,x)}{\partial s} = -\lim_{s\searrow x}\frac{\partial\rho_{d,(u)}^{*}(s,x)}{\partial s}.
\end{align*}
It can be shown that $h_{w}^{*}(x) = \left\{x(1-x)\right\}^{-1}$ and $h_{d}^{*}(x) = \left\{2x(1-x)\right\}^{-1}$.
Since $Z_{w,(a)}^{*}(t)$ and $Z_{d,(a)}^{*}(t)$ are independent and $Z_{w,(u)}^{*}(t)$ and $Z_{d,(u)}^{*}(t)$ are independent, for both averaging and union approaches, we have
\begin{align*}
\text{pr}\left(\max_{n_{0}\leq t \leq n_{1}}M^{*}(t/n) > b\right) = 1-\text{pr}\left(\max_{n_{0}\leq t \leq n_{1}}|Z_{d}^{*}(t/n)| < b\right)\text{pr}\left(\max_{n_{0}\leq t \leq n_{1}}Z_{w}^{*}(t/n) < b\right).
\end{align*}
In addition, following similar arguments in the proof for Proposition 4.4 in \citet{chu2019asymptotic}, we obtain the analytical $p$-value approximations for the extended generalized edge-count test. Assume that $n_{0}, n_{1}, n, b_{S} \rightarrow \infty$ in a way such that for some $0 < x_{0} < x_{1} < 1$ and $b_{2} > 0$, $n_{0}/n \rightarrow x_{0}, \ n_{1}/n \rightarrow x_{1}, \ b_{S}/n \rightarrow b_{2}$.
Then, as $n\rightarrow\infty$, for both averaging and union approaches, we have
\begin{align*}
&\text{pr}\left(\max_{n_{0}\leq t \leq n_{1}}S^{*}(t/n) > b_{S}\right) \sim \frac{b_{S}e^{-b_{S}/2}}{2\pi}\int_{0}^{2\pi}\int_{x_{0}}^{x_{1}}h_{s}^{*}(x,w)\nu\left[\left\{2b_{2}h_{s}^{*}(x,w)\right\}^{1/2}\right]dxdw,
\end{align*}
where $h_{s}^{*}(x,w) = h_{d}^{*}(x)\cos^{2}(w) + h_{w}^{*}(x)\sin^{2}(w)$. The analytical $p$-value approximations for the changed-interval are in Supplement M.
\begin{remark}
In practice, we use $h_{w}(n,x)$ in place of $h_{w}^{*}(x)$, where $h_{w}(n,x)$ is the finite-sample equivalent of $h_{w}^{*}(x)$. That is,
\begin{equation*}
h_{w}(n,x) = n\lim_{s\nearrow nx}\frac{\partial \rho_{w}(s,nx)}{\partial s},
\end{equation*}
with $\rho_{w}(s,t) = \text{cov}\left(Z_{w}(s), Z_{w}(t)\right)$. The explicit expression for $h_{w}(n,x)$ is
\begin{equation*}
h_{w}(n,x) = \frac{(n-1)(2nx^2-2nx+1)}{2x(1-x)(n^2x^2-n^2x+n-1)}.
\end{equation*}
It is clear from above expression that $h_{w}(n,x)$ does not depend on the graph $C_{0}$ as well and it is easy to show that $\lim_{n\rightarrow\infty}h_{w}(n,x) = h_{w}^{*}(x)$. The finite-sample equivalent of $h_{d}^{*}(x)$ is exact the same as $h_{d}^{*}(x)$, that is,
\begin{equation*}
h_{d}(n,x) = n\lim_{s\nearrow nx}\frac{\partial \rho_{d}(s,nx)}{\partial s} = \frac{1}{2x(1-x)},
\end{equation*}
where $\rho_{d}(s,t) = \text{cov}\left(Z_{d}(s), Z_{d}(t)\right)$.
\end{remark}
\subsection{Skewness correction} \label{s4.4}
The analytic $p$-value approximations based on asymptotic results give ballpark estimates of the $p$-values. However, they are in general not accurate enough if we set $n_{0}$ and $n_{1}$ close to the two ends and when the dimension is high (see the table in Section \ref{s4.5}). The inaccuracy is largely attributed to the fact that the convergence of $Z_{w,(a)}(t), Z_{w,(u)}(t), Z_{d,(a)}(t), Z_{d,(u)}(t)$ to the Gaussian distribution is slow when $t/n$ is close to 0 or 1.
To improve the analytical $p$-value approximation, we add extra terms in the analytic formulas to correct for skewness. In our problem, the extent of the skewness depends on the value of $t$. Hence, we adopt a skewness correction approach discussed in \citet{chen2015graph} where different amount of the correction is done for different $t$:
In particular, this approach utilizes better approximation of the marginal probability by using the third moment, $\gamma$.
After skewness correction, the analytical $p$-value approximations for averaging approach are
\begin{align}
\text{pr}\left(\max_{n_{0}\leq t \leq n_{1}}Z_{w,(a)}(t) > b\right) \sim b\phi(b)\int_{n_{0}/n}^{n_{1}/n}H_{w,(a)}(nx)h_{w}(n,x)\nu\left[b\left\{2h_{w}(n,x)/n\right\}^{1/2}\right]dx, \label{e4.27}
\end{align}
where
\begin{equation*}
H_{w,(a)}(t) = \frac{\exp\big\{\frac{1}{2}(b-\hat{\theta}_{b,w,(a)}(t))^2+\frac{1}{6}\gamma_{w,(a)}(t)\hat{\theta}_{b,w,(a)}^{3}(t)\big\}}{\left\{1+\gamma_{w,(a)}(t)\hat{\theta}_{b,w,(a)}(t)\right\}^{1/2}}, \ \ \hat{\theta}_{b,w,(a)}(t) = \frac{\left\{1+2\gamma_{w,(a)}(t)b\right\}^{1/2}-1}{\gamma_{w,(a)}(t)},
\end{equation*}
\begin{align}
&\text{pr}\left(\max_{n_{0}\leq t \leq n_{1}}Z_{d,(a)}(t) > b\right) \sim b\phi(b)\int_{n_{0}/n}^{n_{1}/n}H_{d,(a)}(nx)h_{d}(n,x)\nu\left[b\left\{2h_{d}(n,x)/n\right\}^{1/2}\right]dx, \label{e4.29}
\end{align}
where
\begin{equation*}
H_{d,(a)}(t) = \frac{\exp\big\{\frac{1}{2}(b-\hat{\theta}_{b,d,(a)}(t))^2+\frac{1}{6}\gamma_{d,(a)}(t)\hat{\theta}_{b,d,(a)}^{3}(t)\big\}}{\left\{1+\gamma_{d,(a)}(t)\hat{\theta}_{b,d,(a)}(t)\right\}^{1/2}}, \ \ \hat{\theta}_{b,d,(a)}(t) = \frac{\left\{1+2\gamma_{d,(a)}(t)b\right\}^{1/2}-1}{\gamma_{d,(a)}(t)},
\end{equation*}
and $\gamma_{w,(a)}(t) =E\left(Z^3_{w}(t)\right), \gamma_{d,(a)}(t)= E\left(Z^3_{d}(t)\right)$, whose analytic expressions are provided in Supplement K. The skewness corrected analytical $p$-value approximations for union approach and the changed-interval can be derived in the similar manner and details are provided in Supplement M.
\begin{remark}
By jointly correcting for the marginal probabilities of $Z_{w}(t)$ and $Z_{d}(t)$, we can derive skewness corrected $p$-value approximations for $\max_{n_{0}\le t \le n_{1}}S(t) = \max_{0\le w \le 2\pi}\max_{n_{0}\le t \le n_{1}}\left\{Z_{w}(t)\sin(w)+Z_{d}(t)\cos(w)\right\}$ \citep{chu2019asymptotic}. However, the integrand could be easily non-finite, so the method heavily relies on extrapolation. We thus do not perform skewness correction on $S_{(a)}(t)$ and $S_{(u)}(t)$.
\end{remark}
\subsection{Checking analytical $p$-value approximations under finite $n$} \label{s4.5}
We check the performance of analytical $p$-value approximations obtained in Section \ref{s4.3} and \ref{s4.4}. In particular, we compare the critical values for 0.05 $p$-value threshold through analytical $p$-value approximations based on asymptotic results and skewness correction to those obtained from doing 10,000 permutations under various simulation settings to check how analytical approximation works well for finite samples. Here, we focus on the extended max-type scan statistic for the single change-point alternative. The results for other scan statistics and the changed-interval alternative are provided in Supplement N.
We consider three distributions with different dimensions (Multinomial $d=10$ with equal probabilities (C1), Gaussian with repeated observations $d = 100$ (C2), Multinomial $d=1000$ with equal probabilities (C3)) and let $C_{0}$ be the nearest neighbor link constructed on Euclidean distance. The analytic approximations depend on constraints, $n_{0}$ and $n_{1}$, on the region where the change-point is searched. To make things simple, we set $n_{1} = n - n_{0}$.
Since analytical $p$-value approximations without skewness correction do not depend on $C_{0}$ in the extended weighted, generalized, and max-type tests, the critical value is determined by $n$, $n_{0}$, and $n_{1}$ only. Notice that analytical $p$-value approximations without skewness correction provide the same result in both averaging and union approaches. On the other hand, the skewness corrected approximated $p$-values depend on certain characteristics of the graph structure. The structure of the nearest neighbor link depends on the underlying dataset, and thus the critical values vary by simulation runs.
Table \ref{t6} shows results of the extended max-type scan statistics. The first table labeled `A1' presents the analytical critical values without skewness correction. `A2 (a)' and `A2 (u)' represent skewness corrected analytical critical values in averaging and union approaches, respectively, and `Per $(a)$' and `Per $(u)$' represent permutation critical values in averaging and union cases, respectively. We also show results for 2 randomly simulated sequences in each setting. We see that the asymptotic $p$-value approximation is doing reasonably well. As window size decreases, the analytical critical values become less precise. However, skewness corrected approximation performs much better than the approximation without skewness correction. When the dimension is not too high, such as (C1), the skewness corrected analytical approximation is doing reasonably well for $n_{0}$ as low as 25. When the dimension is high, such as (C2) and (C3), the approximation performs well when $n_{0} \ge 50$.
\begin{table}[htp!]
\centering
\caption{Critical values for the single change-point scan statistic $\max_{n_0 \le t \le n_1} M_{(a)}(t)$ and $\max_{n_0 \le t \le n_1} M_{(u)}(t)$ based on the nearest neighbor link at 0.05 significance level. $n = 1000$}
\label{t6}
\begin{tabular}{ccccc}
& $n_0 = 100$ & $n_0 = 75$ & $n_0 = 50$ & $n_0 = 25$\\
A1 & 3.24 & 3.28 & 3.32 & 3.38\\
\end{tabular}
\vspace{3mm}
\begin{tabular}{p{0.7cm}cccccccc}
& \multicolumn{8}{c}{Critical Values $(a)$} \\
& \multicolumn{2}{c}{$n_0 = 100$} & \multicolumn{2}{c}{$n_0 = 75$} & \multicolumn{2}{c}{$n_0 = 50$} & \multicolumn{2}{c}{$n_0 = 25$} \\
& A2 $(a)$ & Per $(a)$ & A2 $(a)$ & Per $(a)$ & A2 $(a)$ & Per $(a)$ & A2 $(a)$ & Per $(a)$ \\
\multirow{2}{1.6cm}{(C1)}
& 3.30 & 3.30 & 3.36 & 3.37 & 3.43 & 3.43 & 3.54 & 3.58\\
& 3.30 & 3.30 & 3.35 & 3.36 & 3.43 & 3.46 & 3.55 & 3.62\\
\multirow{2}{1.6cm}{(C2)}
& 3.36 & 3.34 & 3.44 & 3.45 & 3.56 & 3.59 & 3.72 & 3.98\\
& 3.34 & 3.36 & 3.42 & 3.47 & 3.53 & 3.64 & 3.76 & 4.03\\
\multirow{2}{1.6cm}{(C3)}
& 3.30 & 3.30 & 3.38 & 3.41 & 3.48 & 3.57 & 3.67 & 3.93\\
& 3.30 & 3.28 & 3.38 & 3.39 & 3.48 & 3.56 & 3.67 & 3.87\\
\end{tabular}
\vspace{3mm}
\begin{tabular}{p{0.7cm}cccccccc}
& \multicolumn{8}{c}{Critical Values $(u)$} \\
& \multicolumn{2}{c}{$n_0 = 100$} & \multicolumn{2}{c}{$n_0 = 75$} & \multicolumn{2}{c}{$n_0 = 50$} & \multicolumn{2}{c}{$n_0 = 25$} \\
& A2 $(u)$ & Per $(u)$ & A2 $(u)$ & Per $(u)$ & A2 $(u)$ & Per $(u)$ & A2 $(u)$ & Per $(u)$ \\
\multirow{2}{1.6cm}{(C1)}
& 3.32 & 3.30 & 3.37 & 3.40 & 3.44 & 3.43 & 3.54 & 3.59\\
& 3.31 & 3.32 & 3.36 & 3.35 & 3.43 & 3.46 & 3.55 & 3.63\\
\multirow{2}{1.6cm}{(C2)}
& 3.35 & 3.36 & 3.42 & 3.43 & 3.51 & 3.52 & 3.62 & 3.80\\
& 3.34 & 3.39 & 3.40 & 3.46 & 3.48 & 3.55 & 3.67 & 3.84\\
\multirow{2}{1.6cm}{(C3)}
& 3.31 & 3.30 & 3.39 & 3.41 & 3.50 & 3.57 & 3.69 & 3.93\\
& 3.31 & 3.28 & 3.39 & 3.39 & 3.50 & 3.56 & 3.69 & 3.87\\
\end{tabular}
\end{table}
\vspace*{-0.4cm}
\section{Performance of the new tests} \label{sec:simu}
We study the performance of the new tests in two aspects: (1) whether the test can reject the null hypothesis of homogenity when there is a change, and (2) if the test can reject $H_{0}$, whether the test can estimate the location of the change-point accurately. We use the configuration model random graph $G(v,\overrightarrow{k})$ to generate networks. Here, $v$ is the number of vertices and $\overrightarrow{k} = (k_{1}, \ldotp\ldotp\ldotp,k_{v})$ is a degree sequence on $v$ vertices, with $k_{i}$ being the degree of vertex $i$. To generate configuration model random graphs, given a degree sequence, we choose a uniformly random matching on the degree stubs (half edges).
We generate a sequence of $n = 200$ networks from the following model:
\begin{equation*}
y_{i} \sim \left\{
\begin{tabular}{c}
$G(v,\overrightarrow{k}_{1})$, \ $i = 1,\ldotp\ldotp\ldotp,\tau$; \ \ \ \ \ \ \ \ \ \ \ \\
$G(v,\overrightarrow{k}_{2})$, \ $i = \tau+1,\ldotp\ldotp\ldotp,200$.
\end{tabular}
\right.
\end{equation*}
We explore two cases of the location of the change-point, in the middle $(\tau = 100)$ and close to one end $(\tau = 170)$ for $v=6$ vertices in this simulation. This dataset has repeated networks. Also, we consider two types of changes:
\begin{enumerate}
\item An equal degree changes in the network (all elements in $\overrightarrow{k}_{1}$ are 2 and 2 elements in $\overrightarrow{k}_{2}$ are 4 and the rest are 2),
\item A random degree changes in the network (all elements in $\overrightarrow{k}_{1}$ are 2 and 2 elements in $\overrightarrow{k}_{2}$ are randomly selected from 3 to 5 and the rest are 2).
\end{enumerate}
That is, we present the results for the four combinations: an equal degree change at $\tau=100$ (S1), a random degree change at $\tau=100$ (S2), an equal degree change at $\tau=170$ (S3), and a random degree change at $\tau=170$ (S4).
For network at $t$, we use an adjacency matrix $M_{t}$ to represent the network, with 1 for element $(i,j)$ if vertex $i$ and $j$ are connected, and 0 otherwise. We consider the dissimilarity defined as the number of different entries normalized by the geometric mean of the total edges in each of two networks, $\|M_{i}-M_{j}\|_{F}/\left(\|M_{i}\|_{F}\cdot\|M_{j}\|_{F}\right)^{1/2}$, where $\|\cdot\|_{F}$ is the Frobenius norm of a matrix. We set $C_{0}$ to be the nearest neighbor link as a similarity graph for our new methods.
\begin{table*} [htp!]
\caption{Estimated power of new tests}
\centering
\label{t7}
\begin{tabular}{ccccccc}
&$Z_{w,(a)}(t)$ & $Z_{w,(u)}(t)$ & $S_{(a)}(t)$ & $S_{(u)}(t)$ & $M_{(a)}(t)$ & $M_{(u)}(t)$ \\
(S1) & 0.98 (0.96) & 0.96 (0.89) & 0.96 (0.94)& 0.95 (0.89) &0.96 (0.95) & 0.95 (0.88) \\
(S2) & 0.88 (0.83) & 0.89 (0.85) & 0.90 (0.84)& 0.91 (0.85) &0.89 (0.83) & 0.90 (0.87) \\
(S3) & 0.86 (0.83) & 0.65 (0.59) & 0.85 (0.83)& 0.85 (0.82) &0.81 (0.80) & 0.70 (0.64) \\
(S4) & 0.81 (0.81) & 0.73 (0.70) & 0.86 (0.84)& 0.93 (0.91) &0.84 (0.81) & 0.86 (0.82) \\
\end{tabular}
\end{table*}
Table \ref{t7} shows the number of null rejection, out of 100, at 0.05 significance level for each method. For the accuracy of estimating the location of change-point, the count where the estimated change-point is within 20 from the true change-point is provided in parentheses when the null hypothesis is rejected. We see that all tests work well in the balanced equal degree changes case, while the extended generalized edge-count test outperforms in random degree changes case. In this simulation, equal degree changes would be considered the mean change and random degree changes would be considered the change in both location and scale. Hence, the extended generalized edge-count test and max-type edge-count test perform well in this general scenario. When the change-point is not in the center of the sequence, the extended weighted edge-count test outperforms, which complies with what we would expect. We see that the extended generalized edge-count test and max-type edge-count test work well when the change is in both mean and variance in the unbalnced sample size case.
\section{Phone-call network data analysis} \label{sec:phone}
Here, we apply the new tests to the phone-call network dataset mentioned in Section \ref{sec:int} in details. The MIT Media Laboratory conducted a study following 87 subjects who used mobile phones with a pre-installed device that can record call logs. The study lasted for 330 days from July 2004 to June 2005 \citep{eagle2009inferring}. Given the richness of this dataset, one question of interest to answer is that whether there is any change in the phone-call pattern among subjects over time. This can be viewed as the change of friendship along time.
We bin the phone-calls by day and we construct $t=330$ of networks in total with 87 subjects as nodes. We encode each network by the adjacency matrix $B_{t}$ with value 1 for element $(i,j)$ if subject $i$ called $j$ on day $t$ and 0 otherwise. We define the distance measure as the number of different entries, i.e., $d(B_{i}, B_{j}) = \|B_{i}-B_{j}\|_{F}^2$, where$\|\cdot\|_{F}$ is the Frobenius norm of a matrix. Due to the repeated observations, many equal distances among distinct values exist. We set $C_{0}$ to be the nearest neighbor link in this example.
We apply the single change-point detection method using the extended generalized scan statistic to the phone-call network dataset recursively so as to detect all possible change-points. As this dataset has a lot of noise, we focus on estimated change-points with $p$-value less than 0.001. Figure 2 shows estimated change-points by averaging approach and union approach. {We see that the two approaches produce quite a number of similar change-points. We define a change-point $\hat{\tau}$ to be detected by both approaches if they each finds a change-point within the set $[\hat{\tau}-2, \hat{\tau}+2]$. We then deem the location of the shared change-point to be the floor of the average of the two change-points detected by the two approaches.}
Since we do not know the underlying distribution of the dataset, we perform more sanity check with the distance matrix of the whole period (Figure \ref{heatmap}). It is evident that there are some signals in this dataset and they show comparably good match with our results from the new tests.
\begin{figure}[htp!]
\centering
\includegraphics[width=4.2in]{phonetime.png}
\\ \ \\
\begin{tabular}{cccccccccc}
(a) &53 & 68 & 97 & 140 & 164 & 247 & 289 & & \\
(u) & 28 & 52 & 66 & 79 &140 & 164 & 247 & 293 & 323 \\
Shared & 52 & 67 & 140 & 164 & 247 & 291 & & & \\
\end{tabular}
\label{phone1}
\caption{Estimated change-points and the order where change-points are detected for averaging and union approaches.}
\end{figure}
\begin{figure}[htp!]
\centering
\includegraphics[width=2.9in]{heatmap.png}
\caption{Heatmap of $L_{1}$ norm distance matrix corresponding to 330 networks. Red triangles, blue triangles, and purple triangles indicate estimated change-points by union approach, averaging approach, and their shared change-points, respectively.}
\label{heatmap}
\end{figure}
\vspace*{-0.7cm}
\section{Discussion}
{In general, the two approaches work similarly; while they inevitably produce different results sometimes. A brief comparison of the two approaches is provided in Supplement O}.
The proposed methods detect the most significant single change-point or the changed-interval in the sequence. If the sequence has more than one change-point, the proposed methods can be applied recursively using techniques, such as binary segmentation, circular binary segmentation, or wild binary segmentation \citep{vostrikova1981detecting, olshen2004circular, fryzlewicz2014wild}.
\section*{Acknowledgement}
Hoseung Song and Hao Chen are supported in part by NSF awards DMS-1513653 and DMS-1848579.
\bibliographystyle{biometrika}
| {'timestamp': '2021-09-16T02:00:47', 'yymm': '2006', 'arxiv_id': '2006.10305', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10305'} | arxiv |
\section{Experiments Details and Additional Results}
\subsection{Additional Theoretic Results}
\subsubsection{Relationship between PAIC and ECE}
\label{sec:appendix_ece}
Given a forecaster $\mathbf{H}$ we can define expected calibration error (ECE) as
\begin{align*}
{\mathrm{ECE}}(\mathbf{H}) = \int_{c=0}^1 \left\lvert \Pr[\mathbf{H}[\mathbf{X}]({\mathbf{Y}}) \leq c] - c \right\rvert dc
\end{align*}
\begin{restatable}{prop}{eqece}
\label{prop:eq_ece}
${\mathrm{ECE}}(\mathbf{H}) = d_{W1}({\cdf_{\fs[\xs](\ys)}}, {\cdf_\mathbf{U}})$.
\end{restatable}
Intuitively, both $d_{W1}({\cdf_{\fs[\xs](\ys)}}, {\cdf_\mathbf{U}})$ try to integrate the difference between the curve $c \mapsto \Pr[\mathbf{H}[\mathbf{X}]({\mathbf{Y}}) \leq c]$ and the curve $c \mapsto c$. The difference is that they integrate the difference in different ways (similar to the difference between Riemann and Lebesgue integral).
\subsubsection{Trivial Construction of mPAIC forecaster}
\label{sec:appendix_trivial_mpaic}
We construct a trivial forecaster that is always mPAIC. Let $\Phi$ be the standard Gaussian CDF, In particular for some $c > 0$, choose
\begin{align*}
\bar{h}[x, r](y) = \Phi(y/c - \Phi^{-1}(r))
\end{align*}
Then when $c \to \infty$, we have $ \bar{h}[x, r](y) = \Phi(\Phi^{-1}(r)) = r$. In other words, for any $\epsilon, \delta$, $\bar{h}$ is $(\epsilon,\delta)$-mPAIC for sufficiently large $c$. However, this forecaster is certainly not useful in practice because it outputs a distribution with variance $\to \infty$.
\subsection{Fairness Experiment Details}
We use the UCI crime and communities dataset~\citep{dua2019uci} and we predict the crime rate based on features about the neighborhood (such as racial composition). The prediction model is a fully connected deep network, where the additional input $r$ is concatenated into each hidden layer (except the last one).
Other than this difference, all other setups are standard --- with dropout and early stopping on validation data to prevent over-fitting. For details please refer to the code included with this paper.
During evaluation of calibration error for interpretable groups, we only consider groups with at least 150 samples to avoid excessive estimation error.
\subsection{Additional Plots and Comparisons for Fairness Experiments}
In Figure~\ref{fig:ece_crime2} we plot the same experimental results in Figure~\ref{fig:ece_crime}, where the only difference is we apply post-training recalibration~\citep{kuleshov2018accurate}. There is no qualitative difference between Figure~\ref{fig:ece_crime} and Figure~\ref{Fig:ece_crime2} because (average) calibration does not improve calibration for the worst group.
\begin{figure*}
\begin{center}
\includegraphics[width=0.94\linewidth]{plots_jpeg/ece_crime_recalibTrue}
\vspace{-3mm}
\caption{The same plot as Figure~\ref{fig:ece_crime}, but with recalibration by isotonic regression. The results are qualitatively the same with and without recalibration.
}
\label{fig:ece_crime2}
\end{center}
\vspace{-3mm}
\end{figure*}
\begin{table}
\centering
\begin{tabular}{c|c|c}
& No Recalibration & With Recalibration \\
\hline
$\alpha=0.1$ & population density (+) & pct immigrant 8yr (-) \\
(PAIC) & pct drug officer (-) & vac house boarded (-)\\ \hline
$\alpha=1.0$ & pct black (+) & pct immigrant (+) \\
(NLL) & pct < 3 bedroom (+) & pct dense house (+)
\end{tabular}
\caption{Least calibrated group for each setup. A + sign indicates this feature is above the median and a - sign indicates the feature is below the median. These are indeed groups where fairness can be a consideration (e.g. immigrants, race or economic condition).}
\label{table:groups}
\end{table}
\subsection{Experiment Details for Credit Approval}
\label{sec:appendix_credit_details}
\label{sec:appendix_credit_guarantee}
\paragraph{Dataset} We will use the "Give Me Some Credit" dataset on Kaggle. Because it is a binary classification dataset (credit delinquency vs. no delinquency), we first train a classifier to predict the Bernoulli probability, and use the probability (plus a small Gaussian noise) as the label. We synthesize a training set and a validation set, where the validation set is very large to simulate a stream of non-repeating customers. We train the bank's forecaster $\mathbf{H}$ on the training set, and apply it to interacting with customers sampled from the validation set.
\paragraph{Customer Model} The customer utility we use is
\begin{center}
\begin{tabular}{c|cc}
& $y \geq y_0$ & $y < y_0$ \\ \hline
'yes' & 0.2 & 1.0 \\
'no' & -0.5 & -0.5
\end{tabular}
\end{center}
We assume the customers knows their own credit worthiness $y$. Based on previous customers $x, y$ and the actual utility from playing the game, we learn a function $\psi(x, y) \to \mathbb{R}$ by gradient descent to predict the customer's utility. The prediction function $\psi$ is also a fully connected deep neural network. Each new customer $(x_{\text{new}}, y_{\text{new}}) \sim {\cdf_{\xs\ys}}$ will only apply if $\psi(x_{\text{new}}, y_{\text{new}}) \geq 0$.
\paragraph{Decision Rule}
The ``Bayesian'' decision rule in Eq.(\ref{eq:bayesian_decision}) can be written as
\begin{align*}
\phi_\mathbf{H}(x) = \left\lbrace \begin{array}{cc} \text{'yes'} & \mathbf{H}[x](y_0) \leq 1/4 \\ \text{'no'} & \text{otherwise} \end{array} \right. \numberthis\label{eq:bank_strategy}
\end{align*}
\textbf{Recalibration} Since post training recalibration~\citep{kuleshov2018accurate,malik2019calibrated} is usually beneficial, we will report both results with and without recalibration by isotonic regression. The results with recalibration is in Figure~\ref{fig:credit_simulation} and the results without recalibration is in Figure~\ref{fig:credit_simulation2}.
\subsection{Additional Plots for Credit Approval}
In Figure~\ref{fig:credit_simulation2} we plot the results without post training recalibration. They are qualitatively similar to Figure~\ref{fig:credit_simulation}. Post training recalibration has little effect on calibration of the worst sub-group, and therefore do not improve performance in this experiment.
\begin{figure}
\centering
\includegraphics[width=0.5\linewidth]{plots_jpeg/utility_credit_recalb}
\vspace{-5mm}
\caption{The experiment in Figure~\ref{fig:credit_simulation} without post training recalibration.
}
\label{fig:credit_simulation2}
\end{figure}
\section{Proofs}
\subsection{Proofs for Section 3}
\label{sec:appendix_impossibility}
\impossibledeterministic*
\begin{proof}[Proof of Proposition~\ref{prop:impossible_deterministic}]
Given a distribution ${\mathbb{F}}$ and forecaster $h$ such that
$\Pr_{{\mathcal{D}} \sim {\mathbb{F}}}[T({\mathcal{D}}, h) = {\mathrm{yes}}] = \kappa > 0$,
we will construct an alternative distribution ${\mathbb{F}}'$ by choosing some function $g: {\mathcal{X}} \to {\mathcal{Y}}$ (defined later), and define a new distribution $\mathbf{X}', {\mathbf{Y}}' \sim {\mathbb{F}}'_g$ by: $\mathbf{X}' \sim {\mathbb{F}}_\mathbf{X}$ and ${\mathbf{Y}}' \mid x$ is the delta distribution on $g(x)$. Then by Definition~\ref{def:individual_calibration}, $\forall x \in {\mathcal{X}}$
\begin{align*} {d_{\mathrm{W1}}}({\mathbb{F}}_{h[x]({\mathbf{Y}}')}, {\cdf_\mathbf{U}}) \geq 1/4 \numberthis\label{eq:trivial_solution} \end{align*}
In words, the above expression is because for any distribution $h[x]$ outputs, we can never rule out a possible ground truth distribution (${\mathbb{F}}'_g$) that is deterministic. Under a deterministic distribution ${\mathbb{F}}_{{\mathbf{Y}}' \mid x}$, it must be that Eq.(\ref{eq:trivial_solution}) holds. (An alternative construction can strengthen the theorem by choosing ${\mathbf{Y}}' \mid x$ to be a distribution with sufficiently small non-zero variance. It can become clear that Eq.(\ref{eq:trivial_solution}) is not an artifact of our requirement that $h$ must output a continuous CDF, but rather the the variance of the ground truth distribution cannot be known).
What remains to show is that there must exist a $g$ such that
\[ \Pr_{{\mathcal{D}} \sim {\mathbb{F}}'_g}[T({\mathcal{D}}, h) = {\mathrm{yes}}] \geq \kappa \]
We will do this with the probabilistic method. For convenience we will represent the value `yes' by 1 and the value `no' by 0. We can use the notation
\[ \Pr_{{\mathcal{D}} \sim {\mathbb{F}}} [T({\mathcal{D}}, h) = {\mathrm{yes}}] := {\mathbb{E}}_{{\mathcal{D}} \sim {\mathbb{F}}}[T({\mathcal{D}}, h)] \]
Because ${\mathbb{F}}_\mathbf{X}$ assigns zero measure to individual points, for any finite set of $x_1, \cdots, x_n \mathrel{\stackrel{\makebox[0pt]{\mbox{\scriptsize i.i.d.}}}{\sim}} {\mathbb{F}}_\mathbf{X}$, all the $x_i$ are distinct (i.e. $x_i \neq x_j, \forall i \neq j$) almost surely.
Suppose ${\mathbf{G}}$ is a random function on $\lbrace g: {\mathcal{X}} \to {\mathcal{Y}}\rbrace$ defined by ${\mathbf{G}}(x) \sim {\mathbb{F}}_{{\mathbf{Y}} \mid x}$, then random variables ${\mathcal{D}} = \lbrace (x_1, y_1), \cdots, (x_n, y_n) \rbrace$ defined by the following two sampling procedures are identically distributed (i.e. in the sense that they belong to any measurable subset of $({\mathcal{X}} \times {\mathcal{Y}})^n$ with the same probability)
\begin{align*}
&x_1, \cdots, x_n \mathrel{\stackrel{\makebox[0pt]{\mbox{\scriptsize i.i.d.}}}{\sim}} {\mathbb{F}}_\mathbf{X}, \qquad y_i \sim {\mathbb{F}}_{{\mathbf{Y}} \mid x_i} \\
&x_1, \cdots, x_n \mathrel{\stackrel{\makebox[0pt]{\mbox{\scriptsize i.i.d.}}}{\sim}} {\mathbb{F}}_\mathbf{X}, \qquad g \sim {\mathbf{G}}, \qquad y_i = g(x_i)
\end{align*}
In words, we could either 1. directly sample a dataset ${\mathcal{D}}$ from ${\mathbb{F}}$, or 2. we could first sample a value $g(x) \sim {\mathbb{F}}_{{\mathbf{Y}} \mid x}$ for each $x$, then sample $x_1, \cdots, x_n \sim {\mathbb{F}}_\mathbf{X}$ and directly evaluate $y_1 = g(x_1), \cdots, y_n = g(x_n)$.
Therefore any bounded random variable must have identical expectation under the probability law defined by the two sampling procedures
\[ \kappa = {\mathbb{E}}_{{\mathcal{D}} \sim {\mathbb{F}}}[T({\mathcal{D}}, h)] = {\mathbb{E}}_{g \sim {\mathbf{G}}}{\mathbb{E}}_{{\mathcal{D}} \sim {\mathbb{F}}'_g}[T({\mathcal{D}}, h)] \]
But this must imply there exists $g$ such that
\[ {\mathbb{E}}_{{\mathcal{D}} \sim {\mathbb{F}}'_g}[T({\mathcal{D}}, h)] \geq \kappa \]
because a random variable must be able to take a value that is at least its expectation
For any other divergence we can get similar results by replacing Eq.(\ref{eq:trivial_solution}). For example, for total variation distance we have
\begin{align*} d_{\mathrm{TV}}({\mathbb{F}}_{h[x]({\mathbf{Y}}')}, {\cdf_\mathbf{U}}) = 1 \numberthis\label{eq:trivial_solution} \end{align*}
\end{proof}
\begin{prop
\label{prop:impossible_deterministic_advgroup}
For any distribution ${\mathbb{F}}$ on ${\mathcal{X}} \times {\mathcal{Y}}$ such that ${\mathbb{F}}_\mathbf{X}$ assigns zero measure to individual points $\lbrace x \in {\mathcal{X}} \rbrace$ sample ${\mathcal{D}} = \lbrace (x_1, y_1), \cdots, (x_n, y_n) \rbrace \mathrel{\stackrel{\makebox[0pt]{\mbox{\scriptsize i.i.d.}}}{\sim}} {\mathbb{F}}$.
For any deterministic forecaster $h$ and any function
$ T({\mathcal{D}}, h) \to \lbrace {\mathrm{yes}}, {\mathrm{no}} \rbrace $
such that
\[ \Pr_{{\mathcal{D}} \sim {\mathbb{F}}}[T({\mathcal{D}}, h) = {\mathrm{yes}}] = \kappa > 0\,, \]
then there exists a distribution ${\mathbb{F}}'$, $h$ is not $\left( \epsilon, \delta \right)$-adversarial group calibrated with respect to ${\mathbb{F}}'$ for any $\epsilon < 1/8$ and $\delta < 1/2$, and
\[ \Pr_{{\mathcal{D}} \sim {\mathbb{F}}'}[T({\mathcal{D}}, h) = {\mathrm{yes}}] \geq \kappa \]
\end{prop}
\begin{proof}[Proof of Proposition~\ref{prop:impossible_deterministic_advgroup}]
The proof is almost identical to the proof of Proposition~\ref{prop:impossible_deterministic}. We construct a $g: {\mathcal{X}} \to {\mathcal{Y}}$ such that
\[ \Pr_{{\mathcal{D}} \sim {\mathbb{F}}'}[T({\mathcal{D}}, h) = {\mathrm{yes}}] \geq \kappa \]
We can pick the subgroup ${\mathcal{S}}_1, {\mathcal{S}}_2 \subset {\mathcal{X}}$ defined by
\[ {\mathcal{S}}_1 = \lbrace x, h[x](g(x)) \geq 1/2 \rbrace, {\mathcal{S}}_2 = \lbrace x, h[x](g(x)) < 1/2 \rbrace \]
Because ${\mathcal{S}}_1 \cup {\mathcal{S}}_2 = {\mathcal{X}}$, so at least one of ${\mathcal{S}}_1, {\mathcal{S}}_2$ must have probability measure at least $1/2$ under ${\mathbb{F}}_X$. Without loss of generality assume it's ${\mathcal{S}}_1$. Then for $\tilde{X} = X \mid {\mathcal{S}}_1$ we have $h[\tilde{X}](g(x)) \geq 1/2$ almost surely, ${\mathbb{F}}_{h[\tilde{X}](g(x))}(r) = 0, \forall r \in [0, 1/2]$, which implies
\[ d_{W1}({\mathbb{F}}_{h[\tilde{X}](g(x))}, {\cdf_\mathbf{U}}) \geq 1/8 \]
Therefore $h$ cannot be $(1/8, 1/2)$-adversarial group calibrated.
\end{proof}
\subsection{Proofs for Section 4.2}
\label{sec:appendix_mono_paic}
\paicmono*
\begin{proof}[Proof of Theorem~\ref{thm:paicmono_imply_paic}]
Recall the convention that ${\mathbf{Y}}$ is the random variable that always has the conditional distribution ${\mathbb{F}}_{{\mathbf{Y}} \mid x}$, and ${\mathbf{R}}$ is uniformly distributed in $[0,1]$. Denote
\[ {\mathrm{err}}(x, y) := d_{W_1}\left({\mathbb{F}}_{\bar{h}[x, {\mathbf{R}}](y)}, {\cdf_\mathbf{U}}\right), \qquad {\mathrm{err}}(x) := d_{W_1}\left({\mathbb{F}}_{\bar{h}[x, {\mathbf{R}}]({\mathbf{Y}})}, {\cdf_\mathbf{U}}\right) \]
Suppose $\bar{h}[x, \cdot](y)$ is a monotonically non-decreasing function for all $x, y$, then
\[ {\mathrm{err}}(x, y) = d_{W_1}\left({\mathbb{F}}_{\bar{h}[x, {\mathbf{R}}](y)}, {\cdf_\mathbf{U}}\right) = {\int_{r=0}^1} \lvert \bar{h}(x, r)(y) - r \rvert dr = {\mathbb{E}}\left[ \lvert \bar{h}(x, {\mathbf{R}})(y) - {\mathbf{R}} \rvert \right] \]
So in general for arbitrary $\bar{h}$ we have
\begin{align*}
{\mathrm{err}}(x, y) = d_{W_1}\left({\mathbb{F}}_{\bar{h}[x, {\mathbf{R}}](y)}, {\cdf_\mathbf{U}}\right) \leq {\int_{r=0}^1} \lvert \bar{h}(x, r)(y) - r \rvert dr = {\mathbb{E}}\left[ \lvert \bar{h}(x, {\mathbf{R}})(y) - {\mathbf{R}} \rvert \right] \numberthis\label{eq:mpaic_to_paic_0}
\end{align*}
In addition by Jensen's inequality we have ${\mathrm{err}}(x) \leq {\mathbb{E}}[{\mathrm{err}}(x, {\mathbf{Y}})]$ so
\begin{align*}
{\mathrm{err}}(x) \leq {\mathbb{E}}\left[ \lvert \bar{h}(x, {\mathbf{R}})({\mathbf{Y}}) - {\mathbf{R}} \rvert \right] \numberthis\label{eq:mpaic_to_paic_1}
\end{align*}
Suppose $\bar{h}$ is not $(\epsilon',\delta')$-PAIC, by definition we have
\[ \Pr[{\mathrm{err}}(\mathbf{X}) \geq \epsilon'] > \delta' \]
Define the notation
\begin{align*}
{\mathcal{S}}_b := \lbrace x \in {\mathcal{X}}, {\mathbb{E}}\left[ \lvert \bar{h}(x, {\mathbf{R}})({\mathbf{Y}}) - {\mathbf{R}} \rvert \right] \geq \epsilon' \rbrace
\end{align*}
by Eq.(\ref{eq:mpaic_to_paic_1}) we know that whenever ${\mathrm{err}}(x) \geq \epsilon'$ we have $x \in {\mathcal{S}}_b$, so we can conclude
\begin{align*}
\Pr[\mathbf{X} \in {\mathcal{S}}_b] > \delta' \numberthis\label{eq:mpaic_to_paic_3}
\end{align*}
Whenever $x \in {\mathcal{S}}_b$, for any $\epsilon < \epsilon'$, we have
\begin{align*}
\epsilon' &\leq {\mathbb{E}}[|\bar{h}(x, {\mathbf{R}})({\mathbf{Y}}) - {\mathbf{R}}|] \\
&\leq \epsilon \Pr[|\bar{h}(x, {\mathbf{R}})({\mathbf{Y}}) - {\mathbf{R}}| < \epsilon] + \Pr[|\bar{h}(x, {\mathbf{R}})({\mathbf{Y}}) - {\mathbf{R}}| \geq \epsilon] \\
&= \epsilon(1-\Pr[|\bar{h}(x, {\mathbf{R}})({\mathbf{Y}}) - {\mathbf{R}}| \geq \epsilon]) + \Pr[|\bar{h}(x, {\mathbf{R}})({\mathbf{Y}}) - {\mathbf{R}}| \geq \epsilon]
\end{align*}
where the second inequality is because $|\bar{h}(x, {\mathbf{R}})({\mathbf{Y}}) - {\mathbf{R}}| $ is bounded in $[0, 1]$. By simple algebra we get
\begin{align*}
\Pr[|\bar{h}(x, {\mathbf{R}})({\mathbf{Y}}) - {\mathbf{R}}| \geq \epsilon] \geq \frac{\epsilon'-\epsilon}{1 - \epsilon} \numberthis\label{eq:mpaic_to_paic_2}
\end{align*}
We can combine Eq.(\ref{eq:mpaic_to_paic_3}) and Eq.(\ref{eq:mpaic_to_paic_2}) to get
\begin{align*}
&\Pr[ \lvert \bar{h}(\mathbf{X}, {\mathbf{R}})({\mathbf{Y}}) - {\mathbf{R}} \rvert \geq \epsilon']\\
&= \Pr[ \lvert \bar{h}(\mathbf{X}, {\mathbf{R}})({\mathbf{Y}}) - {\mathbf{R}} \rvert \geq \epsilon \mid \mathbf{X} \in {\mathcal{S}}_b]\Pr[\mathbf{X} \in {\mathcal{S}}_b] + \Pr[ \lvert \bar{h}(\mathbf{X}, {\mathbf{R}})({\mathbf{Y}}) - {\mathbf{R}} \rvert \geq \epsilon \mid \mathbf{X} \not\in {\mathcal{S}}_b]\Pr[\mathbf{X} \not\in {\mathcal{S}}_b] \\
&> \frac{\epsilon' - \epsilon}{1 - \epsilon} \delta'
\end{align*}
Therefore, $\bar{h}$ is not $(\epsilon, \frac{\epsilon' - \epsilon}{1 - \epsilon} \delta')$-mPAIC. To summarize, we have concluded that whenever $\bar{h}$ is not $(\epsilon', \delta')$-PAIC, for any $\epsilon < \epsilon'$, it is not $(\epsilon, \frac{\epsilon' - \epsilon}{1 - \epsilon} \delta')$-mPAIC. This is equivalent to the statement: suppose $\bar{h}$ is $(\epsilon, \delta)$-mPAIC, then $\bar{h}$ is $(\epsilon', \delta \frac{1-\epsilon}{\epsilon'-\epsilon})$-PAIC.
\end{proof}
\concentration*
\begin{proof}[Proof of Proposition~\ref{prop:concentration}]
Consider the sequence of Bernoulli random variables $b_i = \mathbb{I}(\left\lvert \bar{h}(x_i, r_i)(y_i) - r_i \right\rvert \geq \epsilon)$. Suppose ${\mathbb{E}}[b_i] = \delta$, then by Hoeffding inequality
\[ Pr\left[\frac{1}{n}\sum_{i} b_i \geq \delta + \epsilon \right] \leq e^{-2\epsilon^2 n} \]
Plugging in $e^{-2\epsilon^2T}$ as $\gamma$ we have $ \epsilon = \sqrt{\frac{-\log \gamma}{2n}} $
\end{proof}
\subsection{Proofs for Section 5}
\label{sec:appendix_fairness}
\input{proof_pai_vs_calibration.tex}
\subsection{Proofs for Section 6}
\label{sec:appendix_decision_making}
\decision*
\label{sec:appendix_decision_making_proof}
\begin{proof}[Proof of Theorem~\ref{thm:markov}]
Choose any $x \in {\mathcal{X}}$, $h \in {\mathcal{H}}$ and $r \in (0, 1)$. For some action $a$ assume $l(x, \cdot, a)$ is monotonically non-decreasing. We consider the situation where $y < h[x]^{-1}(1-r)$, or equivalently $h[x](y) < 1-r$, then
\[ l_h(x) = \int_{y' \in {\mathcal{Y}}} l(x, y', a) dh[x](y') \geq \int_{y' \geq y} l(x, y', a) dh[x](y') \geq l(x, y, a) \int_{y' \geq y} dh[x](y') \geq r l(x, y, a) \]
because the above is true for any $a \in {\mathcal{A}}$, it must also be true for the action $\phi_h(x)$. On the other hand, assume $l(x, \cdot, a)$ is monotonically non-increasing, then by a similar argument we get whenever $h[x](y) > r$ we have
\[ l_h(x) \geq r l(x, y, a) \]
Consider the set ${\mathcal{S}}_r, {\mathcal{M}}_r, \bar{{\mathcal{M}}}_r \subset {\mathcal{X}} \times {\mathcal{Y}} \times {\mathcal{H}}$, defined by
\begin{align*}
{\mathcal{S}}_r = \lbrace x, y, h \mid l_h(x) \leq r l(x, y, a) \rbrace, \quad{\mathcal{M}}_r = \lbrace x, y, h \mid h[x](y) \leq r \rbrace, \quad \bar{{\mathcal{M}}}_r = \lbrace x, y, h \mid h[x](y) \geq 1-r \rbrace \\
\end{align*}
The above results would imply ${\mathcal{S}}_r \subset {\mathcal{M}}_r \cup \hat{{\mathcal{M}}}_r$. But we know that
\[ \Pr[\mathbf{X},{\mathbf{Y}},\mathbf{H} \in {\mathcal{S}}_r] \leq \Pr[\mathbf{X},{\mathbf{Y}}, \mathbf{H} \in {\mathcal{M}}_r \cup \hat{{\mathcal{M}}}_r] \leq 2r \]
taking $k=1/r$ gives us the desired statement.
If $\mathbf{H}$ is individually calibrated, then it is also adversarial group calibrated by Theorem~\ref{thm:pai_vs_calibration}. Define a function $\zeta: {\mathcal{X}} \times {\mathcal{H}} \to \lbrace 0, 1 \rbrace$ that represents whether $l$ is monotonically non-decreasing or non-increasing in ${\mathcal{Y}}$. Then
\begin{align*}
&\Pr[\mathbf{X},{\mathbf{Y}},\mathbf{H} \in {\mathcal{S}}_r] \\
&\leq \Pr[\mathbf{X},{\mathbf{Y}}, \mathbf{H} \in {\mathcal{M}}_r \mid \zeta(\mathbf{X}, \mathbf{H}) = 0]\Pr[\zeta(\mathbf{X}, \mathbf{H}) = 0] + \Pr[\mathbf{X},{\mathbf{Y}}, \mathbf{H} \in {\mathcal{M}}_r \mid \zeta(\mathbf{X}, \mathbf{H}) = 1]\Pr[\zeta(\mathbf{X}, \mathbf{H}) = 1] \\
&\leq r
\end{align*}
\end{proof}
\subsection{Proofs for Appendix}
\eqece*
\begin{proof}[Proof of Proposition~\ref{prop:eq_ece}]
This proposition depends on the following Lemma.
\begin{lemma}
\label{lemma:inverse_norm}
Let $\phi: [0, 1] \to [0, 1]$ be a monotonic differentiable function such that $\phi(0)=0$ and $\phi(1)=1$. Let $\psi(x) = x$, then for any $1 \leq s \leq +\infty$ we have
\[ {\int_{c=0}^1} \left\lvert \phi^{-1}(c) - \psi(c)\right\rvert^s dc = {\int_{r=0}^1}\left\lvert \phi(r) - \psi(r)\right\rvert^s dr \]
\end{lemma}
First observe that by the monotonicity of ${\cdf_{\fs[\xs](\ys)}}$ we have
\[ \Pr[\mathbf{H}[\mathbf{X}]({\mathbf{Y}}) \leq c] = {\int_{r=0}^1} \mathbb{I}({\cdf_{\fs[\xs](\ys)}} \leq c) dr = {\cdf_{\fs[\xs](\ys)}}^{-1}(c) \]
We get
\begin{align*}
{\mathrm{ECE}}(\mathbf{H}) &= \int_{c=0}^1 \left\lvert \Pr[\mathbf{H}[\mathbf{X}]({\mathbf{Y}}) \leq c] - c \right\rvert dc = \int_{c=0}^1 \left\lvert {\cdf_{\fs[\xs](\ys)}}^{-1}(c) - c \right\rvert dc \\
&= {\int_{r=0}^1} \left\lvert {\cdf_{\fs[\xs](\ys)}}(r) - r \right\rvert dr = d_{W1}({\cdf_{\fs[\xs](\ys)}}, {\cdf_\mathbf{U}})
\end{align*}
Finally we prove Lemma~\ref{lemma:inverse_norm}.
\begin{proof}[Proof of Lemma~\ref{lemma:inverse_norm}]
Let $[a, b]$ be an interval where $\phi(x)-x$ does not change sign, and $f(a)=a$, $f(b)=b$. Without loss of generality, assume it is positive. Then
\begin{align*}
\int_{x=a}^b \lvert \phi(x) - x \rvert^s dx &- \int_{y=a}^b ( f^{-1}(y) - y )^s dy
= \int_{x=a}^b ( \phi(x) - x )^s dx - \int_{x=a}^b ( -x + \phi(x) )^s f'(x) dx \\
&= \int_{x=a}^b (\phi(x) - x )^s (f'(x) - 1) dx = \frac{(\phi(x) - x)^{s+1}}{s+1} \vert_a^b = 0
\end{align*}
Let $0=a_1 < a_2 < \cdots < a_n=1$ be a set of points where $f(a_i)=a_i$, and $f$ does not change sign between $[a_i, a_{i+1}]$. Then we have
\begin{align*}
\int_{x=0}^1 & \lvert \phi(x) - x \rvert^s dx - \int_{y=0}^1 \lvert f^{-1}(y) - y \rvert^s dy \\
&= \sum_i \left( \int_{x=a_i}^{a_{i+1}} \lvert \phi(x) - x \rvert^s dx - \int_{y=a_i}^{a_{i+1}} \lvert f^{-1}(y) - y \rvert^s dy \right) = 0
\end{align*}
\end{proof}
\end{proof}
\section{Impossibility Results}
\newcommand{{\mathrm{yes}}}{{\mathrm{yes}}}
\newcommand{{\mathrm{no}}}{{\mathrm{no}}}
\section{Impossibility Results for Deterministic Forecasters}
We first present results showing that individual calibration and adversarial group calibration are impossible to verify with a deterministic forecaster. Therefore, there is no general method to train a classifier to achieve individual calibration. This motivates the need for randomized forecasters.
Given a finite dataset ${\mathcal{D}} = \lbrace (x_i, y_i) \rbrace$ and a deterministic forecaster $h: {\mathcal{X}} \to {\mathcal{F}}({\mathcal{Y}})$, suppose some verifier $T({\mathcal{D}}, h) \to \lbrace {\mathrm{yes}}, {\mathrm{no}} \rbrace$ aims to verify if $h$ is $(\epsilon,\delta)$-PAIC.
We claim that no verifier can correctly decide it (unless $\epsilon\ge 1/4$ or $\delta=1$ which means the calibration is trivially bad).
This proposition is for the Wasserstein-1 distance $d_{W1}$. Examples of other distances are given in the Appendix~\ref{sec:appendix_impossibility}.
\begin{restatable}{prop}{impossibledeterministic
\label{prop:impossible_deterministic}
For any distribution ${\mathbb{F}}$ on ${\mathcal{X}} \times {\mathcal{Y}}$ such that ${\mathbb{F}}_\mathbf{X}$ assigns zero measure to individual points $\lbrace x \in {\mathcal{X}} \rbrace$ sample ${\mathcal{D}} = \lbrace (x_1, y_1), \cdots, (x_n, y_n) \rbrace \mathrel{\stackrel{\makebox[0pt]{\mbox{\scriptsize i.i.d.}}}{\sim}} {\mathbb{F}}$.
For any deterministic forecaster $h$ and any function
$ T({\mathcal{D}}, h) \to \lbrace {\mathrm{yes}}, {\mathrm{no}} \rbrace $
such that
\[ \Pr_{{\mathcal{D}} \sim {\mathbb{F}}}[T({\mathcal{D}}, h) = {\mathrm{yes}}] = \kappa > 0\,, \]
there exists a distribution ${\mathbb{F}}'$ such that (a) $h$ is not $\left( \epsilon, \delta \right)$-PAIC w.r.t ${\mathbb{F}}'$ for any $\epsilon < 1/4$ and $\delta < 1$, and (b)
\[ \Pr_{{\mathcal{D}} \sim {\mathbb{F}}'}[T({\mathcal{D}}, h) = {\mathrm{yes}}] \geq \kappa \]
\end{restatable}
This additionally implies that no learning algorithm can guarantee to produce an individually calibrated forecaster.
because otherwise the learning algorithm and its guarantee can serve as a verifier.
Proofs of the proposition and a similar negative result for adversarial group calibration are in Appendix~\ref{sec:appendix_impossibility}.
In addition to impossibility of verification, it is also known (in the conformal prediction setup) that no forecaster can guarantee individual calibration in a non-trivial way~\citep{barber2019limits}. For a discussion see related works.
In light of these negative results, there are two options: one can make additional assumptions about the true distribution ${\cdf_{\xs\ys}}$, such as Lipschitzness. However, these assumptions are usually hard to verify, and their usefulness diminishes as the dimensionality of ${\mathcal{X}}$ increases. We propose an alternative: in contrast to deterministic forecasters, there is a sufficient condition for individual calibration for \emph{randomized} forecasters.
The sufficient condition is verifiable can be conveniently converted into a training objective.
\section{Individual Calibration with Randomized Forecasting}
\subsection{Reparameterized Randomized Forecaster}
We will consider randomized forecasters that are deterministic functions applied on the input feature vector $x$ and some fixed random seeds $R$. (For readers familiar with variational Bayesian inference~\citep{kingma2013auto}, this is reminiscent of the reparameterization trick.)
Concretely, we choose a deterministic function $\bar{h}: {\mathcal{X}} \times [0, 1] \to {\mathcal{F}}({\mathcal{Y}})$, and let $ {\mathbf{R}} \sim {\cdf_\mathbf{U}}$. Define the randomized forecaster $\mathbf{H}[x]$ as
\begin{align} \mathbf{H}[x] = \bar{h}[x, {\mathbf{R}}] \label{eqn:reparam}\end{align}
In addition, we would like $\bar{h}[x, r]$ to be a monotonic function of $r$ for all $x$. Any continuous function that is not monotonic can be transformed into one by shuffling $r$.
\subsection{Sufficient Condition for Individual Calibration}
\label{sec:appendix_additional_discussion}
In this subsection, we introduce sufficient (but not necessary) conditions of individual calibration for
randomized forecasters defined in Eq.~\eqref{eqn:reparam}.
First, recall that the definition of individual calibration requires $\mathbf{H}[x]({\mathbf{Y}}) := \bar{h}[x, {\mathbf{R}}]({\mathbf{Y}})$ to be a uniform distribution for most of $x \in {\mathcal{X}}$ sampled from ${\mathbb{F}}_\mathbf{X}$. This condition is hard to verify given samples, because for each $x$ in the training (or test) set, we typically only observe a single corresponding label $y \sim {\mathbb{F}}_{{\mathbf{Y}} \mid x}$.
As an alternative, we propose to verify whether $\bar{h}[x, {\mathbf{R}}](y)$ is uniformly distributed
(for the unique sample $y$). Therefore we introduce a stronger but verifiable condition:
\begin{align*}
\bar{h}[x, {\mathbf{R}}](y) \text{ is uniformly distributed} \numberthis\label{eq:weaker_cond}
\end{align*}
for most (random) choices of $x, y$ under ${\mathbb{F}}_{XY}$.
The benefit is that the condition --- $\bar{h}[x, {\mathbf{R}}](y)$ is uniformly distributed --- can be written in an equivalent form when $\bar{h}[x,r]$ is a monotonic function in $r$ (proved in Theorem~\ref{thm:paicmono_imply_paic}
\[ \bar{h}[x, r](y) = r, \forall r \in [0, 1], \]
We formalize a relaxed version of this condition (allowing for approximation errors) as follows:
\begin{definition}
\label{def:paic_monotonic}
A forecaster $\bar{h}$ is $(\epsilon,\delta)$-monotonically probably approximately individually calibrated (mPAIC) if
\[ \Pr \left[ \lvert \bar{h}[\mathbf{X}, {\mathbf{R}}]({\mathbf{Y}}) - {\mathbf{R}} \rvert \geq \epsilon\right] \leq \delta \]
\end{definition}
Note that even though we want to achieve $\bar{h}[x, r](y)=r, \forall r$, this does not mean that $\bar{h}$ ignores the input $x$ --- $\bar{h}[x, r](.)$ has the special form of a CDF, so $\bar{h}[x, r]$ must output a CDF concentrated around the observed label $y$ to satisfy mPAIC.
The following theorem formalizes our previous intuition that monotonic individual calibration (mPAIC) is obtained by imposing additional restrictions on individual calibration (PAIC) --- mPAIC is a sufficient condition for PAIC.
\begin{restatable}{theorem}{paicmono}
\label{thm:paicmono_imply_paic}
If $\bar{h}$ is $(\epsilon, \delta)$-mPAIC, then for any $\epsilon' > \epsilon$ it is $(\epsilon', \delta(1-\epsilon)/(\epsilon'-\epsilon))$-PAIC with respect to the 1-Wasserstein distance.
\end{restatable}
Proof can be found in Appendix~\ref{sec:appendix_mono_paic}.
This theorem shows that mPAIC implies PAIC (up to different constants $\epsilon,\delta$). In particular, if a forecaster achieves mPAIC perfectly (i.e. $\epsilon=0, \delta=0$), it is also perfectly PAIC.
\subsection{Calibrated Forecasters for Decision Making}
Machine learning predictions are often used to make decisions.
With good uncertainty quantification, the agent can consider different plausible outcomes, and pick the best action in expectation.
More formally, suppose there is a set of actions $a \in {\mathcal{A}}$,
and some loss function $l: {\mathcal{X}} \times {\mathcal{Y}} \times {\mathcal{A}} \to \mathbb{R}$. If we had a perfect forecaster (i.e. $\mathbf{H}[x] = {\cdf_{\ys \mid x}}$), then given input $x$, Bayesian decision theory would suggest to take the action that minimizes expected loss~\citep{fishburn1979two} under the predicted probability.
\begin{align*}
l_\mathbf{H}(x) &\mathrel{\stackrel{\makebox[0pt]{\mbox{\scriptsize def}}}{=}} \min_a {\mathbb{E}}_{\tilde{{\mathbf{Y}}} \sim \mathbf{H}[x]}[l(x, \tilde{{\mathbf{Y}}}, a)] \numberthis\label{eq:bayesian_loss} \\
\phi_\mathbf{H}(x) &\mathrel{\stackrel{\makebox[0pt]{\mbox{\scriptsize def}}}{=}} \arg\min_a {\mathbb{E}}_{\tilde{{\mathbf{Y}}} \sim \mathbf{H}[x]}[l(x, \tilde{{\mathbf{Y}}}, a)] \numberthis\label{eq:bayesian_decision}
\end{align*}
However, perfect forecaster is almost never possible in practice.
Nevertheless, calibration provides some guarantee on the decision rule in Eq.(\ref{eq:bayesian_decision}) for certain loss functions.
In particular, we consider loss functions $l(x, \cdot, a)$ that, for each $x, a$, are either monotonically non-increasing or non-decreasing in y. We call these loss functions \textbf{monotonic}.
For example,
if $y$ represents stock prices and $a \in \lbrace \text{buy}, \text{sell} \rbrace$, then when $a=\text{buy}$, loss is decreasing in $y$; when $a=\text{sell}$, loss is increasing in $y$.
In the following theorem (proof in Appendix~\ref{sec:appendix_decision_making}) we show that the actual loss cannot exceed the expected loss in Eq.(\ref{eq:bayesian_loss}) too often. This would be Markov's inequality if Eq.(\ref{eq:bayesian_loss}) takes expectation under the true distribution ${\cdf_{\ys \mid x}}$. Interestingly the inequality is still true when the expectation is under the predicted distribution $\mathbf{H}[x] \neq {\cdf_{\ys \mid x}}$.
\begin{restatable}{theorem}{decision}
\label{thm:markov}
Suppose $l: {\mathcal{X}}\times {\mathcal{Y}} \times {\mathcal{A}} \to \mathbb{R}$ is a monotonic non-negative loss, let $\phi_\mathbf{H}$ and $l_\mathbf{H}$ be defined as in Eq.(\ref{eq:bayesian_decision})
1. If $\mathbf{H}$ is $0$-average calibrated, then $\forall k > 0$
\begin{align*}
\Pr[l(\mathbf{X}, {\mathbf{Y}}, \phi_\mathbf{H}(\mathbf{X})) \geq k l_\mathbf{H}(\mathbf{X})] \leq 2/k
\end{align*}
2. If $\mathbf{H}$ is $(0, 0)$-PAIC, then $\forall x \in {\mathcal{X}}, k > 0$
\begin{align*}
\Pr[l(x, {\mathbf{Y}}, \phi_\mathbf{H}(x)) \geq k l_\mathbf{H}(x)] \leq 1/k
\end{align*}
\end{restatable}
\subsection{Case Study: Credit Prediction}
\begin{figure}
\centering
\includegraphics[width=1.0\linewidth]{plots_jpeg/utility_credit_recalb}
\caption{Comparison between individual calibration ($\alpha \approx 0$) and baseline ($\alpha = 1$). \textbf{Left}: Each dot represents a random roll-out for different values of $\alpha$, where we plot the bank's average utility when the customers either decide to apply randomly or rationally. Individually calibrated forecaster perform worse than baseline when the customers are random, but better when customers are rational. \textbf{Middle Left}: Proportion of exploitative customers (customers with $y < y_0$ but decide to apply). Random forecasters have less systematic bias and discourages exploitative customers.
}
\label{fig:credit_simulation}
\end{figure}
Suppose customers of a financial institution are represented with a feature vector $x$ and a real-valued credit worthiness score $y \in {\mathcal{Y}}$. The bank has a financial product (e.g. credit card or loan) with a minimum threshold $y_0 \in \mathbb{R}$ for credit worthiness.
If a customer chooses to apply for the product, the bank observes $x$, and uses forecaster $\mathbf{H}$ to predict
their true credit worthiness $y$.
There is a positive utility for saying 'yes' to a qualified customer, and a negative utility for saying 'yes' to a disqualified customer. More specifically, the utility (negative loss) for the bank is
\begin{center}
\begin{tabular}{c|cc}
& $y \geq y_0$ & $y < y_0$ \\ \hline
'yes' & 1 & -3 \\
'no' & 0 & 0
\end{tabular}
\end{center}
\paragraph{Guarantees from Average Calibration:} Suppose the bank uses the Bayesian decision rule in Eq.(\ref{eq:bayesian_decision}). If $\mathbf{H}$ is average calibrated,
Theorem~\ref{thm:markov} would imply that when the bank says 'yes', at most $25\%$ will be to unqualified customers (when customers truly come from the distribution ${\mathbb{F}}_\mathbf{X}$). For details see Appendix~\ref{sec:appendix_credit_guarantee}.
The Bayesian decision rule in Eq.(\ref{eq:bayesian_decision}) is fragile when $\mathbf{H}$ is only average calibrated
because the guarantee above is void if the customers do not come from the distribution ${\mathbb{F}}_\mathbf{X}$.
For example, suppose some unqualified customers know that their credit scores are overestimated by the bank,
then these customers are more likely to apply.
More concretely, if only the customers who would be mistakenly approved ended up applying, then the bank is guaranteed to lose (it will suffer a loss of -3 for each customer).
\noindent{\bf Guarantees from Individual Calibration:} If $\mathbf{H}$ is individually calibrated (and hence also calibrated with respect to any adversarial subgroup), the bank cannot be exploited --- no matter which subgroup of customers choose to apply, the fraction of unqualified approvals is at most $25\%$.
\subsubsection{Simulation}
We perform simulations
to verify that individual calibrated forecasters are less exploitable and can achieve higher utility in practice.
We model the customers as rational agents that predict their utility and exploit any mistake by the bank. For detailed setup, see Appendix~\ref{sec:appendix_credit_details}.
The results are shown in Figure~\ref{fig:credit_simulation}. We compare different values of $\alpha \in [0.1, 1.0]$ (recall when $\alpha \approx 0$ we almost exclusive optimize ${\mathcal{L}}_{\text{PAIC}}$, and when $\alpha = 1$ we exclusively optimize ${\mathcal{L}}_{\text{NLL}}$). We compare the average utility on random customers (customers drawn from ${\cdf_{\xs\ys}}$) and rational customers (Appendix~\ref{sec:appendix_credit_details}).
The main observations is that when customers are random, individual calibrated forecasters perform worse because average calibration is already sufficient.
On the other hand, when the customers are rational, and try to exploit any systematic bias with the decision maker, individually calibrated forecasters perform much better.
\section{Electronic Submission}
\label{submission}
Submission to ICML 2020 will be entirely electronic, via a web site
(not email). Information about the submission process and \LaTeX\ templates
are available on the conference web site at:
\begin{center}
\textbf{\texttt{http://icml.cc/}}
\end{center}
The guidelines below will be enforced for initial submissions and
camera-ready copies. Here is a brief summary:
\begin{itemize}
\item Submissions must be in PDF\@.
\item Submitted papers can be up to eight pages long, not including references, plus unlimited space for references. Accepted papers can be up to nine pages long, not including references, to allow authors to address reviewer comments. Any paper exceeding this length will automatically be rejected.
\item \textbf{Do not include author information or acknowledgements} in your
initial submission.
\item Your paper should be in \textbf{10 point Times font}.
\item Make sure your PDF file only uses Type-1 fonts.
\item Place figure captions \emph{under} the figure (and omit titles from inside
the graphic file itself). Place table captions \emph{over} the table.
\item References must include page numbers whenever possible and be as complete
as possible. Place multiple citations in chronological order.
\item Do not alter the style template; in particular, do not compress the paper
format by reducing the vertical spaces.
\item Keep your abstract brief and self-contained, one paragraph and roughly
4--6 sentences. Gross violations will require correction at the
camera-ready phase. The title should have content words capitalized.
\end{itemize}
\subsection{Submitting Papers}
\textbf{Paper Deadline:} The deadline for paper submission that is
advertised on the conference website is strict. If your full,
anonymized, submission does not reach us on time, it will not be
considered for publication.
\textbf{Anonymous Submission:} ICML uses double-blind review: no identifying
author information may appear on the title page or in the paper
itself. Section~\ref{author info} gives further details.
\textbf{Simultaneous Submission:} ICML will not accept any paper which,
at the time of submission, is under review for another conference or
has already been published. This policy also applies to papers that
overlap substantially in technical content with conference papers
under review or previously published. ICML submissions must not be
submitted to other conferences during ICML's review period. Authors
may submit to ICML substantially different versions of journal papers
that are currently under review by the journal, but not yet accepted
at the time of submission. Informal publications, such as technical
reports or papers in workshop proceedings which do not appear in
print, do not fall under these restrictions.
\medskip
Authors must provide their manuscripts in \textbf{PDF} format.
Furthermore, please make sure that files contain only embedded Type-1 fonts
(e.g.,~using the program \texttt{pdffonts} in linux or using
File/DocumentProperties/Fonts in Acrobat). Other fonts (like Type-3)
might come from graphics files imported into the document.
Authors using \textbf{Word} must convert their document to PDF\@. Most
of the latest versions of Word have the facility to do this
automatically. Submissions will not be accepted in Word format or any
format other than PDF\@. Really. We're not joking. Don't send Word.
Those who use \textbf{\LaTeX} should avoid including Type-3 fonts.
Those using \texttt{latex} and \texttt{dvips} may need the following
two commands:
{\footnotesize
\begin{verbatim}
dvips -Ppdf -tletter -G0 -o paper.ps paper.dvi
ps2pdf paper.ps
\end{verbatim}}
It is a zero following the ``-G'', which tells dvips to use
the config.pdf file. Newer \TeX\ distributions don't always need this
option.
Using \texttt{pdflatex} rather than \texttt{latex}, often gives better
results. This program avoids the Type-3 font problem, and supports more
advanced features in the \texttt{microtype} package.
\textbf{Graphics files} should be a reasonable size, and included from
an appropriate format. Use vector formats (.eps/.pdf) for plots,
lossless bitmap formats (.png) for raster graphics with sharp lines, and
jpeg for photo-like images.
The style file uses the \texttt{hyperref} package to make clickable
links in documents. If this causes problems for you, add
\texttt{nohyperref} as one of the options to the \texttt{icml2020}
usepackage statement.
\subsection{Submitting Final Camera-Ready Copy}
The final versions of papers accepted for publication should follow the
same format and naming convention as initial submissions, except that
author information (names and affiliations) should be given. See
Section~\ref{final author} for formatting instructions.
The footnote, ``Preliminary work. Under review by the International
Conference on Machine Learning (ICML). Do not distribute.'' must be
modified to ``\textit{Proceedings of the
$\mathit{37}^{th}$ International Conference on Machine Learning},
Vienna, Austria, PMLR 119, 2020.
Copyright 2020 by the author(s).''
For those using the \textbf{\LaTeX} style file, this change (and others) is
handled automatically by simply changing
$\mathtt{\backslash usepackage\{icml2020\}}$ to
$$\mathtt{\backslash usepackage[accepted]\{icml2020\}}$$
Authors using \textbf{Word} must edit the
footnote on the first page of the document themselves.
Camera-ready copies should have the title of the paper as running head
on each page except the first one. The running title consists of a
single line centered above a horizontal rule which is $1$~point thick.
The running head should be centered, bold and in $9$~point type. The
rule should be $10$~points above the main text. For those using the
\textbf{\LaTeX} style file, the original title is automatically set as running
head using the \texttt{fancyhdr} package which is included in the ICML
2020 style file package. In case that the original title exceeds the
size restrictions, a shorter form can be supplied by using
\verb|\icmltitlerunning{...}|
just before $\mathtt{\backslash begin\{document\}}$.
Authors using \textbf{Word} must edit the header of the document themselves.
\section{Format of the Paper}
All submissions must follow the specified format.
\subsection{Dimensions}
The text of the paper should be formatted in two columns, with an
overall width of 6.75~inches, height of 9.0~inches, and 0.25~inches
between the columns. The left margin should be 0.75~inches and the top
margin 1.0~inch (2.54~cm). The right and bottom margins will depend on
whether you print on US letter or A4 paper, but all final versions
must be produced for US letter size.
The paper body should be set in 10~point type with a vertical spacing
of 11~points. Please use Times typeface throughout the text.
\subsection{Title}
The paper title should be set in 14~point bold type and centered
between two horizontal rules that are 1~point thick, with 1.0~inch
between the top rule and the top edge of the page. Capitalize the
first letter of content words and put the rest of the title in lower
case.
\subsection{Author Information for Submission}
\label{author info}
ICML uses double-blind review, so author information must not appear. If
you are using \LaTeX\/ and the \texttt{icml2020.sty} file, use
\verb+\icmlauthor{...}+ to specify authors and \verb+\icmlaffiliation{...}+ to specify affiliations. (Read the TeX code used to produce this document for an example usage.) The author information
will not be printed unless \texttt{accepted} is passed as an argument to the
style file.
Submissions that include the author information will not
be reviewed.
\subsubsection{Self-Citations}
If you are citing published papers for which you are an author, refer
to yourself in the third person. In particular, do not use phrases
that reveal your identity (e.g., ``in previous work \cite{langley00}, we
have shown \ldots'').
Do not anonymize citations in the reference section. The only exception are manuscripts that are
not yet published (e.g., under submission). If you choose to refer to
such unpublished manuscripts \cite{anonymous}, anonymized copies have
to be submitted
as Supplementary Material via CMT\@. However, keep in mind that an ICML
paper should be self contained and should contain sufficient detail
for the reviewers to evaluate the work. In particular, reviewers are
not required to look at the Supplementary Material when writing their
review.
\subsubsection{Camera-Ready Author Information}
\label{final author}
If a paper is accepted, a final camera-ready copy must be prepared.
For camera-ready papers, author information should start 0.3~inches below the
bottom rule surrounding the title. The authors' names should appear in 10~point
bold type, in a row, separated by white space, and centered. Author names should
not be broken across lines. Unbolded superscripted numbers, starting 1, should
be used to refer to affiliations.
Affiliations should be numbered in the order of appearance. A single footnote
block of text should be used to list all the affiliations. (Academic
affiliations should list Department, University, City, State/Region, Country.
Similarly for industrial affiliations.)
Each distinct affiliations should be listed once. If an author has multiple
affiliations, multiple superscripts should be placed after the name, separated
by thin spaces. If the authors would like to highlight equal contribution by
multiple first authors, those authors should have an asterisk placed after their
name in superscript, and the term ``\textsuperscript{*}Equal contribution"
should be placed in the footnote block ahead of the list of affiliations. A
list of corresponding authors and their emails (in the format Full Name
\textless{}[email protected]\textgreater{}) can follow the list of affiliations.
Ideally only one or two names should be listed.
A sample file with author names is included in the ICML2020 style file
package. Turn on the \texttt{[accepted]} option to the stylefile to
see the names rendered. All of the guidelines above are implemented
by the \LaTeX\ style file.
\subsection{Abstract}
The paper abstract should begin in the left column, 0.4~inches below the final
address. The heading `Abstract' should be centered, bold, and in 11~point type.
The abstract body should use 10~point type, with a vertical spacing of
11~points, and should be indented 0.25~inches more than normal on left-hand and
right-hand margins. Insert 0.4~inches of blank space after the body. Keep your
abstract brief and self-contained, limiting it to one paragraph and roughly 4--6
sentences. Gross violations will require correction at the camera-ready phase.
\subsection{Partitioning the Text}
You should organize your paper into sections and paragraphs to help
readers place a structure on the material and understand its
contributions.
\subsubsection{Sections and Subsections}
Section headings should be numbered, flush left, and set in 11~pt bold
type with the content words capitalized. Leave 0.25~inches of space
before the heading and 0.15~inches after the heading.
Similarly, subsection headings should be numbered, flush left, and set
in 10~pt bold type with the content words capitalized. Leave
0.2~inches of space before the heading and 0.13~inches afterward.
Finally, subsubsection headings should be numbered, flush left, and
set in 10~pt small caps with the content words capitalized. Leave
0.18~inches of space before the heading and 0.1~inches after the
heading.
Please use no more than three levels of headings.
\subsubsection{Paragraphs and Footnotes}
Within each section or subsection, you should further partition the
paper into paragraphs. Do not indent the first line of a given
paragraph, but insert a blank line between succeeding ones.
You can use footnotes\footnote{Footnotes
should be complete sentences.} to provide readers with additional
information about a topic without interrupting the flow of the paper.
Indicate footnotes with a number in the text where the point is most
relevant. Place the footnote in 9~point type at the bottom of the
column in which it appears. Precede the first footnote in a column
with a horizontal rule of 0.8~inches.\footnote{Multiple footnotes can
appear in each column, in the same order as they appear in the text,
but spread them across columns and pages if possible.}
\begin{figure}[ht]
\vskip 0.2in
\begin{center}
\centerline{\includegraphics[width=\columnwidth]{icml_numpapers}}
\caption{Historical locations and number of accepted papers for International
Machine Learning Conferences (ICML 1993 -- ICML 2008) and International
Workshops on Machine Learning (ML 1988 -- ML 1992). At the time this figure was
produced, the number of accepted papers for ICML 2008 was unknown and instead
estimated.}
\label{icml-historical}
\end{center}
\vskip -0.2in
\end{figure}
\subsection{Figures}
You may want to include figures in the paper to illustrate
your approach and results. Such artwork should be centered,
legible, and separated from the text. Lines should be dark and at
least 0.5~points thick for purposes of reproduction, and text should
not appear on a gray background.
Label all distinct components of each figure. If the figure takes the
form of a graph, then give a name for each axis and include a legend
that briefly describes each curve. Do not include a title inside the
figure; instead, the caption should serve this function.
Number figures sequentially, placing the figure number and caption
\emph{after} the graphics, with at least 0.1~inches of space before
the caption and 0.1~inches after it, as in
Figure~\ref{icml-historical}. The figure caption should be set in
9~point type and centered unless it runs two or more lines, in which
case it should be flush left. You may float figures to the top or
bottom of a column, and you may set wide figures across both columns
(use the environment \texttt{figure*} in \LaTeX). Always place
two-column figures at the top or bottom of the page.
\subsection{Algorithms}
If you are using \LaTeX, please use the ``algorithm'' and ``algorithmic''
environments to format pseudocode. These require
the corresponding stylefiles, algorithm.sty and
algorithmic.sty, which are supplied with this package.
Algorithm~\ref{alg:example} shows an example.
\begin{algorithm}[tb]
\caption{Bubble Sort}
\label{alg:example}
\begin{algorithmic}
\STATE {\bfseries Input:} data $x_i$, size $m$
\REPEAT
\STATE Initialize $noChange = true$.
\FOR{$i=1$ {\bfseries to} $m-1$}
\IF{$x_i > x_{i+1}$}
\STATE Swap $x_i$ and $x_{i+1}$
\STATE $noChange = false$
\ENDIF
\ENDFOR
\UNTIL{$noChange$ is $true$}
\end{algorithmic}
\end{algorithm}
\subsection{Tables}
You may also want to include tables that summarize material. Like
figures, these should be centered, legible, and numbered consecutively.
However, place the title \emph{above} the table with at least
0.1~inches of space before the title and the same after it, as in
Table~\ref{sample-table}. The table title should be set in 9~point
type and centered unless it runs two or more lines, in which case it
should be flush left.
\begin{table}[t]
\caption{Classification accuracies for naive Bayes and flexible
Bayes on various data sets.}
\label{sample-table}
\vskip 0.15in
\begin{center}
\begin{small}
\begin{sc}
\begin{tabular}{lcccr}
\toprule
Data set & Naive & Flexible & Better? \\
\midrule
Breast & 95.9$\pm$ 0.2& 96.7$\pm$ 0.2& $\surd$ \\
Cleveland & 83.3$\pm$ 0.6& 80.0$\pm$ 0.6& $\times$\\
Glass2 & 61.9$\pm$ 1.4& 83.8$\pm$ 0.7& $\surd$ \\
Credit & 74.8$\pm$ 0.5& 78.3$\pm$ 0.6& \\
Horse & 73.3$\pm$ 0.9& 69.7$\pm$ 1.0& $\times$\\
Meta & 67.1$\pm$ 0.6& 76.5$\pm$ 0.5& $\surd$ \\
Pima & 75.1$\pm$ 0.6& 73.9$\pm$ 0.5& \\
Vehicle & 44.9$\pm$ 0.6& 61.5$\pm$ 0.4& $\surd$ \\
\bottomrule
\end{tabular}
\end{sc}
\end{small}
\end{center}
\vskip -0.1in
\end{table}
Tables contain textual material, whereas figures contain graphical material.
Specify the contents of each row and column in the table's topmost
row. Again, you may float tables to a column's top or bottom, and set
wide tables across both columns. Place two-column tables at the
top or bottom of the page.
\subsection{Citations and References}
Please use APA reference format regardless of your formatter
or word processor. If you rely on the \LaTeX\/ bibliographic
facility, use \texttt{natbib.sty} and \texttt{icml2020.bst}
included in the style-file package to obtain this format.
Citations within the text should include the authors' last names and
year. If the authors' names are included in the sentence, place only
the year in parentheses, for example when referencing Arthur Samuel's
pioneering work \yrcite{Samuel59}. Otherwise place the entire
reference in parentheses with the authors and year separated by a
comma \cite{Samuel59}. List multiple references separated by
semicolons \cite{kearns89,Samuel59,mitchell80}. Use the `et~al.'
construct only for citations with three or more authors or after
listing all authors to a publication in an earlier reference \cite{MachineLearningI}.
Authors should cite their own work in the third person
in the initial version of their paper submitted for blind review.
Please refer to Section~\ref{author info} for detailed instructions on how to
cite your own papers.
Use an unnumbered first-level section heading for the references, and use a
hanging indent style, with the first line of the reference flush against the
left margin and subsequent lines indented by 10 points. The references at the
end of this document give examples for journal articles \cite{Samuel59},
conference publications \cite{langley00}, book chapters \cite{Newell81}, books
\cite{DudaHart2nd}, edited volumes \cite{MachineLearningI}, technical reports
\cite{mitchell80}, and dissertations \cite{kearns89}.
Alphabetize references by the surnames of the first authors, with
single author entries preceding multiple author entries. Order
references for the same authors by year of publication, with the
earliest first. Make sure that each reference includes all relevant
information (e.g., page numbers).
Please put some effort into making references complete, presentable, and
consistent. If using bibtex, please protect capital letters of names and
abbreviations in titles, for example, use \{B\}ayesian or \{L\}ipschitz
in your .bib file.
\section*{Software and Data}
If a paper is accepted, we strongly encourage the publication of software and data with the
camera-ready version of the paper whenever appropriate. This can be
done by including a URL in the camera-ready copy. However, \textbf{do not}
include URLs that reveal your institution or identity in your
submission for review. Instead, provide an anonymous URL or upload
the material as ``Supplementary Material'' into the CMT reviewing
system. Note that reviewers are not required to look at this material
when writing their review.
\section*{Acknowledgements}
\textbf{Do not} include acknowledgements in the initial version of
the paper submitted for blind review.
If a paper is accepted, the final camera-ready version can (and
probably should) include acknowledgements. In this case, please
place such acknowledgements in an unnumbered section at the
end of the paper. Typically, this will include thanks to reviewers
who gave useful comments, to colleagues who contributed to the ideas,
and to funding agencies and corporate sponsors that provided financial
support.
\nocite{langley00}
\section{Experiments}
\subsection{From Individual Calibration to Group Calibration}
In high-stakes applications of machine learning (e.g., healthcare and criminal justice), it is imperative that
predictions are fair.
Many definitions of fairness are possible (see related work section), and calibration is a commonly used one.
For example, in a healthcare application we would like to prevent a systematic overestimation or underestimation of a predicted risk for different socio-economic groups~\citep{pfohl2019creating}.
One natural requirement is that predictions for every group are calibrated, that is, the true value below the $r$\% quantile exactly $r$\% of the times.
If the protected groups are known at training time, we could enforce group calibration as in Definition~\ref{def:group_calibration}.
However, it can be difficult to specify which groups to protect a priori. Some groups are also defined by features that are unobserved e.g. due to personal privacy.
We propose to address the problem by requiring a stronger notion of calibration, adversarial group calibration, where \emph{any group of sufficiently large size needs to be protected}. Moreover, we can achieve this stronger notion of calibration because it is implied by individual calibration.
\begin{restatable}{theorem}{advgroup}
\label{thm:pai_vs_calibration}
If a forecaster is $(\epsilon,\delta)$-PAIC with respect to distance metric ${\mathcal{W}}_p$, then $\forall \delta' \in [0, 1]$, $\delta' > \delta$, it is $(\epsilon + \delta/\delta', \delta')$-adversarial group calibrated with respect to ${\mathcal{W}}_p$.
\end{restatable}
We prove a stronger version of this theorem in Appendix~\ref{sec:appendix_fairness}.
We know from theory that a forecaster trained on the individual calibration objective Eq.(\ref{eq:training_objective}) can achieve good individual calibration (and thus group calibration) on the training data. We will now experimentally verify that the benefit generalizes to test data.
\subsection{Experiments}
\textbf{Experiment Details}. We use the UCI crime and communities dataset~\citep{dua2019uci} and we predict the crime rate based on features of the neighborhood (such as racial composition). For training details and network architecture see Appendix~\ref{sec:appendix_fairness}. \footnote{ https://github.com/ShengjiaZhao/Individual-Calibration}
\textbf{Recalibration.} Post training recalibration is a common technique to improve calibration.
For completeness we additionally report all results when combined with recalibration by isotonic regression as in \citep{kuleshov2018accurate}.
Post training recalibration improves average calibration, but as we show in the experiments, has limited effect on individual or adversarial group calibration.
\subsubsection{Performance Metrics}
\textbf{1) Sharpness metrics}: Sharpness measures whether the prediction $\mathbf{H}[x]$ is concentrated around the ground truth label $y$. We will use two metrics: negative log likelihood on the test data ${\mathbb{E}}\left[ -\log \bar{h}(\mathbf{X}, {\mathbf{R}})({\mathbf{Y}}) \right]$, and expected standard deviation of the predicted CDFs
$ {\mathbb{E}} \left[ \sqrt{{\mathrm{Var}}[ \bar{h}(\mathbf{X}, {\mathbf{R}})] } \right]$. Because forecaster outputs Gaussian distributions to represent uncertainty, this is simply the average standard deviation $\sigma$ predicted by the forecaster.
\textbf{2) Calibration metrics}: we will measure the ($\epsilon,\delta$)-adversarial group calibration (with 1-Wasserstein distance) defined in Definition~\ref{def:adv_group_calibration} and Eq.(\ref{eq:adv_group_calibration}).
In particular, we measure $\epsilon$ as a function of $\delta$ --- for a smaller group (smaller $\delta$) the $\epsilon$ should be larger (worse calibration), and vice versa. A better forecaster should have a smaller $\epsilon$ for any given value of $\delta$. We show in Appendix~\ref{sec:appendix_ece} that measuring $\epsilon$ is identical to the commonly used ECE~\citep{guo2017calibration} metric for miscalibration.
The worst adversarial group may be an uninterpretable set, which is argurably less important than interpretable groups. Therefore, we also measure group calibration with respect to a set of known and interpretable groups. In particular, for each input feature we compute its the median value in the test data, and consider the groups that are above/below the median. For example, if the input feature is income, we considers the group with above median income, and the group with below median income.
We also consider the intersection of any two groups.
\subsubsection{Results}
The results are shown in Figure~\ref{fig:ece_crime} and \ref{fig:ece_size}. We compare different values of $\alpha$ (with $\alpha \approx 0$ we learn with ${\mathcal{L}}_{\text{PAIC}}$, and with $\alpha \approx 1$ we learn with ${\mathcal{L}}_{\text{NLL}}$).
The main observation is forecasters learned with smaller $\alpha$ almost always achieve better group calibration (both adversarial group and interpretable group) and worse sharpness (log likelihood and variance of predicted distribution).
This shows a trade-off between calibration and sharpness.
Depending on the application, a practitioner can adjust $\alpha$ and find the appropriate trade-off, e.g. given some constraint on fairness (maximum calibration error) achieve the best sharpness (log likelihood).
We also observe that post training recalibration improves average calibration (i.e. when the size of adversarial group is 100\% in Figure~\ref{fig:ece_size}). However, we cannot expect recalibration to improve individual or adversarial group calibration --- we empirically confirm this in Figure~\ref{fig:ece_size}.
In Table~\ref{table:groups} in Appendix~\ref{sec:appendix_fairness} we also report the worst interpretable groups that are miscalibrated. These do correspond to groups that we might want to protect, such as percent of immigrants, or racial composition.
\section{Introduction}
\begin{figure*}
\centering
\begin{tabular}{cc}
\includegraphics[width=0.48\linewidth]{plots_jpeg/toy_example_nll_600} &
\includegraphics[width=0.48\linewidth]{plots_jpeg/toy_example_paic} 46
\end{tabular}
\vspace{-5mm}
\caption{Example of deterministic forecaster that is calibrated on average (\textbf{left}) and randomized forecaster that is individually calibrated (\textbf{right}). We plot the {\color{orange} 80\% credible interval} and the {\color{orange} median (orange dot)} the forecaster outputs, and {\color{cyan} shade in cyan the area} where the {\color{orange} predicted median} is less than the {\color{blue} true function value}. \textbf{Left}: the deterministic forecaster outputs a fixed credible interval (the left 2 plots are identical) and and can be miscalibrated on sub-groups of the data samples (e.g. it is not calibrated for the samples in the {\color{cyan} shaded area}, because the {\color{orange} predicted median} is always less than the {\color{blue}true function value}).
\textbf{Right}: The randomized forecaster outputs a different credible interval each time (the right 2 plots are different), and can remove systematic miscalibration on sub-groups of data samples. (The shaded area becomes random.
}
\label{fig:toy_example}
\end{figure*}
Many applications of machine learning, such as safety-critical systems and medical diagnosis, require accurate estimation of the uncertainty associated with each prediction.
Uncertainty is typically represented using a probability distribution on the possible outcomes.
To reflect the underlying uncertainty, these probabilities should be calibrated~\citep{cesa2006prediction,vovk2005algorithmic,guo2017calibration}. In the regression setup, for example, the true outcome should be below the predicted 50\% quantile (median) roughly 50\% of the times~\citep{kuleshov2018accurate}.
However, even when the probability forecaster is calibrated, it is possible that the true outcome is \emph{always} below the predicted median on a subgroup (e.g., men), and \emph{always} above the predicted median for another (e.g., women).
In other words, the standard notion of calibration is a property that needs to hold only \emph{on average across all predictions} made (i.e., on the set of all input data points).
The predicted probabilities can still be highly inaccurate for \emph{individual} data samples.
These predictions can lead to unfair or otherwise suboptimal decisions. For example, a bank might over-predict credit risk for one gender group and unfairly deny loans, or under-predict credit risk for a group that can then exploit this mistake to their advantage.
Group calibration~\citep{kleinberg2016inherent} partly addresses the short-comings of average calibration by requiring calibration on pre-specified groups
(e.g. men and women). In particular, \citep{hebert2017calibration} achieves calibration on any group that can be computed from input by a small circuit. However, these methods are not applicable when the groups are unknown or difficult to compute from the input. For example, groups can be defined by features that are unobserved e.g. due to personal privacy.
Ideally, we would like forecasters that are calibrated on each individual sample.
Our key insight is that individual calibration is possible when the probability forecaster is itself randomized.
Intuitively,
a randomized forecaster can output random probabilistic forecasts (e.g., quantiles) --- it is the predicted quantile that is randomly above or below a fixed true value with the advertised probability (see Figure~\ref{fig:toy_example}).
Randomization can remove systematic miscalibration on any group of data samples.
Useful forecasters also need to be sharp --- the predicted probability should be concentrated around the true value. We design a concrete learning objective that enforces individual calibration. Combined with an objective that enforces sharpness, such as traditional log-likelihood, we can learn forecasters that trade-off calibration and sharpness \textit{Pareto optimally}. The objective can be used to train any prediction model that takes an additional random source as input, such as deep neural networks.
We assess the benefit of forecasters trained with the new objective on two applications: fairness and decision making under uncertainty against adversaries.
Calibration on protected groups traditionally has been a definition for fairness~\citep{kleinberg2016inherent}. On a UCI crime prediction task, we show that forecasters trained for individual calibration achieve lower calibration error on protected groups without knowing these groups in advance.
For decision making we consider the Bayesian decision strategy --- choosing actions that minimize expected loss under the predicted probabilities. We prove strong upper bounds on the decision loss when the probability forecaster is calibrated on average or individually. However, when the input data distribution changes, forecasters calibrated on average lose their guarantee, while
individually calibrated forecasters are less affected.
We support these results by simulating a game between a bank and its customers. The bank approves loans based on predicted credit risk,
and customers exploit any mistake of the bank, i.e. the distribution of customers change adversarially for the bank.
We observe that the bank incurs lower loss when the credit risk forecaster is trained for individually calibration.
\section{Application I: Fairness}
\input{fairness.tex}
\section{Application II: Decision under Uncertainty}
\input{decision.tex}
\input{related.tex}
\section{Acknowledgements}
This research was supported by AFOSR (FA9550-19-1-0024), NSF (\#1651565, \#1522054, \#1733686), JP Morgan, ONR, TRI, FLI, SDSI, and SAIL.
Toyota Research Institute ("TRI") provided funds to assist the authors with their research but this article solely reflects the opinions and conclusions of its authors and not TRI or any other Toyota entity.
TM is also supported in part by Lam Research and Google Faculty Award.
We are thankful for valuable feedback from Kunho Kim (Stanford), Ananya Kumar (Stanford) and Wei Chen (MSRA).
\bibliographystyle{icml2020}
\section{Electronic Submission}
\label{submission}
Submission to ICML 2020 will be entirely electronic, via a web site
(not email). Information about the submission process and \LaTeX\ templates
are available on the conference web site at:
\begin{center}
\textbf{\texttt{http://icml.cc/}}
\end{center}
The guidelines below will be enforced for initial submissions and
camera-ready copies. Here is a brief summary:
\begin{itemize}
\item Submissions must be in PDF\@.
\item Submitted papers can be up to eight pages long, not including references, plus unlimited space for references. Accepted papers can be up to nine pages long, not including references, to allow authors to address reviewer comments. Any paper exceeding this length will automatically be rejected.
\item \textbf{Do not include author information or acknowledgements} in your
initial submission.
\item Your paper should be in \textbf{10 point Times font}.
\item Make sure your PDF file only uses Type-1 fonts.
\item Place figure captions \emph{under} the figure (and omit titles from inside
the graphic file itself). Place table captions \emph{over} the table.
\item References must include page numbers whenever possible and be as complete
as possible. Place multiple citations in chronological order.
\item Do not alter the style template; in particular, do not compress the paper
format by reducing the vertical spaces.
\item Keep your abstract brief and self-contained, one paragraph and roughly
4--6 sentences. Gross violations will require correction at the
camera-ready phase. The title should have content words capitalized.
\end{itemize}
\subsection{Submitting Papers}
\textbf{Paper Deadline:} The deadline for paper submission that is
advertised on the conference website is strict. If your full,
anonymized, submission does not reach us on time, it will not be
considered for publication.
\textbf{Anonymous Submission:} ICML uses double-blind review: no identifying
author information may appear on the title page or in the paper
itself. Section~\ref{author info} gives further details.
\textbf{Simultaneous Submission:} ICML will not accept any paper which,
at the time of submission, is under review for another conference or
has already been published. This policy also applies to papers that
overlap substantially in technical content with conference papers
under review or previously published. ICML submissions must not be
submitted to other conferences during ICML's review period. Authors
may submit to ICML substantially different versions of journal papers
that are currently under review by the journal, but not yet accepted
at the time of submission. Informal publications, such as technical
reports or papers in workshop proceedings which do not appear in
print, do not fall under these restrictions.
\medskip
Authors must provide their manuscripts in \textbf{PDF} format.
Furthermore, please make sure that files contain only embedded Type-1 fonts
(e.g.,~using the program \texttt{pdffonts} in linux or using
File/DocumentProperties/Fonts in Acrobat). Other fonts (like Type-3)
might come from graphics files imported into the document.
Authors using \textbf{Word} must convert their document to PDF\@. Most
of the latest versions of Word have the facility to do this
automatically. Submissions will not be accepted in Word format or any
format other than PDF\@. Really. We're not joking. Don't send Word.
Those who use \textbf{\LaTeX} should avoid including Type-3 fonts.
Those using \texttt{latex} and \texttt{dvips} may need the following
two commands:
{\footnotesize
\begin{verbatim}
dvips -Ppdf -tletter -G0 -o paper.ps paper.dvi
ps2pdf paper.ps
\end{verbatim}}
It is a zero following the ``-G'', which tells dvips to use
the config.pdf file. Newer \TeX\ distributions don't always need this
option.
Using \texttt{pdflatex} rather than \texttt{latex}, often gives better
results. This program avoids the Type-3 font problem, and supports more
advanced features in the \texttt{microtype} package.
\textbf{Graphics files} should be a reasonable size, and included from
an appropriate format. Use vector formats (.eps/.pdf) for plots,
lossless bitmap formats (.png) for raster graphics with sharp lines, and
jpeg for photo-like images.
The style file uses the \texttt{hyperref} package to make clickable
links in documents. If this causes problems for you, add
\texttt{nohyperref} as one of the options to the \texttt{icml2020}
usepackage statement.
\subsection{Submitting Final Camera-Ready Copy}
The final versions of papers accepted for publication should follow the
same format and naming convention as initial submissions, except that
author information (names and affiliations) should be given. See
Section~\ref{final author} for formatting instructions.
The footnote, ``Preliminary work. Under review by the International
Conference on Machine Learning (ICML). Do not distribute.'' must be
modified to ``\textit{Proceedings of the
$\mathit{37}^{th}$ International Conference on Machine Learning},
Vienna, Austria, PMLR 119, 2020.
Copyright 2020 by the author(s).''
For those using the \textbf{\LaTeX} style file, this change (and others) is
handled automatically by simply changing
$\mathtt{\backslash usepackage\{icml2020\}}$ to
$$\mathtt{\backslash usepackage[accepted]\{icml2020\}}$$
Authors using \textbf{Word} must edit the
footnote on the first page of the document themselves.
Camera-ready copies should have the title of the paper as running head
on each page except the first one. The running title consists of a
single line centered above a horizontal rule which is $1$~point thick.
The running head should be centered, bold and in $9$~point type. The
rule should be $10$~points above the main text. For those using the
\textbf{\LaTeX} style file, the original title is automatically set as running
head using the \texttt{fancyhdr} package which is included in the ICML
2020 style file package. In case that the original title exceeds the
size restrictions, a shorter form can be supplied by using
\verb|\icmltitlerunning{...}|
just before $\mathtt{\backslash begin\{document\}}$.
Authors using \textbf{Word} must edit the header of the document themselves.
\section{Format of the Paper}
All submissions must follow the specified format.
\subsection{Dimensions}
The text of the paper should be formatted in two columns, with an
overall width of 6.75~inches, height of 9.0~inches, and 0.25~inches
between the columns. The left margin should be 0.75~inches and the top
margin 1.0~inch (2.54~cm). The right and bottom margins will depend on
whether you print on US letter or A4 paper, but all final versions
must be produced for US letter size.
The paper body should be set in 10~point type with a vertical spacing
of 11~points. Please use Times typeface throughout the text.
\subsection{Title}
The paper title should be set in 14~point bold type and centered
between two horizontal rules that are 1~point thick, with 1.0~inch
between the top rule and the top edge of the page. Capitalize the
first letter of content words and put the rest of the title in lower
case.
\subsection{Author Information for Submission}
\label{author info}
ICML uses double-blind review, so author information must not appear. If
you are using \LaTeX\/ and the \texttt{icml2020.sty} file, use
\verb+\icmlauthor{...}+ to specify authors and \verb+\icmlaffiliation{...}+ to specify affiliations. (Read the TeX code used to produce this document for an example usage.) The author information
will not be printed unless \texttt{accepted} is passed as an argument to the
style file.
Submissions that include the author information will not
be reviewed.
\subsubsection{Self-Citations}
If you are citing published papers for which you are an author, refer
to yourself in the third person. In particular, do not use phrases
that reveal your identity (e.g., ``in previous work \cite{langley00}, we
have shown \ldots'').
Do not anonymize citations in the reference section. The only exception are manuscripts that are
not yet published (e.g., under submission). If you choose to refer to
such unpublished manuscripts \cite{anonymous}, anonymized copies have
to be submitted
as Supplementary Material via CMT\@. However, keep in mind that an ICML
paper should be self contained and should contain sufficient detail
for the reviewers to evaluate the work. In particular, reviewers are
not required to look at the Supplementary Material when writing their
review.
\subsubsection{Camera-Ready Author Information}
\label{final author}
If a paper is accepted, a final camera-ready copy must be prepared.
For camera-ready papers, author information should start 0.3~inches below the
bottom rule surrounding the title. The authors' names should appear in 10~point
bold type, in a row, separated by white space, and centered. Author names should
not be broken across lines. Unbolded superscripted numbers, starting 1, should
be used to refer to affiliations.
Affiliations should be numbered in the order of appearance. A single footnote
block of text should be used to list all the affiliations. (Academic
affiliations should list Department, University, City, State/Region, Country.
Similarly for industrial affiliations.)
Each distinct affiliations should be listed once. If an author has multiple
affiliations, multiple superscripts should be placed after the name, separated
by thin spaces. If the authors would like to highlight equal contribution by
multiple first authors, those authors should have an asterisk placed after their
name in superscript, and the term ``\textsuperscript{*}Equal contribution"
should be placed in the footnote block ahead of the list of affiliations. A
list of corresponding authors and their emails (in the format Full Name
\textless{}[email protected]\textgreater{}) can follow the list of affiliations.
Ideally only one or two names should be listed.
A sample file with author names is included in the ICML2020 style file
package. Turn on the \texttt{[accepted]} option to the stylefile to
see the names rendered. All of the guidelines above are implemented
by the \LaTeX\ style file.
\subsection{Abstract}
The paper abstract should begin in the left column, 0.4~inches below the final
address. The heading `Abstract' should be centered, bold, and in 11~point type.
The abstract body should use 10~point type, with a vertical spacing of
11~points, and should be indented 0.25~inches more than normal on left-hand and
right-hand margins. Insert 0.4~inches of blank space after the body. Keep your
abstract brief and self-contained, limiting it to one paragraph and roughly 4--6
sentences. Gross violations will require correction at the camera-ready phase.
\subsection{Partitioning the Text}
You should organize your paper into sections and paragraphs to help
readers place a structure on the material and understand its
contributions.
\subsubsection{Sections and Subsections}
Section headings should be numbered, flush left, and set in 11~pt bold
type with the content words capitalized. Leave 0.25~inches of space
before the heading and 0.15~inches after the heading.
Similarly, subsection headings should be numbered, flush left, and set
in 10~pt bold type with the content words capitalized. Leave
0.2~inches of space before the heading and 0.13~inches afterward.
Finally, subsubsection headings should be numbered, flush left, and
set in 10~pt small caps with the content words capitalized. Leave
0.18~inches of space before the heading and 0.1~inches after the
heading.
Please use no more than three levels of headings.
\subsubsection{Paragraphs and Footnotes}
Within each section or subsection, you should further partition the
paper into paragraphs. Do not indent the first line of a given
paragraph, but insert a blank line between succeeding ones.
You can use footnotes\footnote{Footnotes
should be complete sentences.} to provide readers with additional
information about a topic without interrupting the flow of the paper.
Indicate footnotes with a number in the text where the point is most
relevant. Place the footnote in 9~point type at the bottom of the
column in which it appears. Precede the first footnote in a column
with a horizontal rule of 0.8~inches.\footnote{Multiple footnotes can
appear in each column, in the same order as they appear in the text,
but spread them across columns and pages if possible.}
\begin{figure}[ht]
\vskip 0.2in
\begin{center}
\centerline{\includegraphics[width=\columnwidth]{icml_numpapers}}
\caption{Historical locations and number of accepted papers for International
Machine Learning Conferences (ICML 1993 -- ICML 2008) and International
Workshops on Machine Learning (ML 1988 -- ML 1992). At the time this figure was
produced, the number of accepted papers for ICML 2008 was unknown and instead
estimated.}
\label{icml-historical}
\end{center}
\vskip -0.2in
\end{figure}
\subsection{Figures}
You may want to include figures in the paper to illustrate
your approach and results. Such artwork should be centered,
legible, and separated from the text. Lines should be dark and at
least 0.5~points thick for purposes of reproduction, and text should
not appear on a gray background.
Label all distinct components of each figure. If the figure takes the
form of a graph, then give a name for each axis and include a legend
that briefly describes each curve. Do not include a title inside the
figure; instead, the caption should serve this function.
Number figures sequentially, placing the figure number and caption
\emph{after} the graphics, with at least 0.1~inches of space before
the caption and 0.1~inches after it, as in
Figure~\ref{icml-historical}. The figure caption should be set in
9~point type and centered unless it runs two or more lines, in which
case it should be flush left. You may float figures to the top or
bottom of a column, and you may set wide figures across both columns
(use the environment \texttt{figure*} in \LaTeX). Always place
two-column figures at the top or bottom of the page.
\subsection{Algorithms}
If you are using \LaTeX, please use the ``algorithm'' and ``algorithmic''
environments to format pseudocode. These require
the corresponding stylefiles, algorithm.sty and
algorithmic.sty, which are supplied with this package.
Algorithm~\ref{alg:example} shows an example.
\begin{algorithm}[tb]
\caption{Bubble Sort}
\label{alg:example}
\begin{algorithmic}
\STATE {\bfseries Input:} data $x_i$, size $m$
\REPEAT
\STATE Initialize $noChange = true$.
\FOR{$i=1$ {\bfseries to} $m-1$}
\IF{$x_i > x_{i+1}$}
\STATE Swap $x_i$ and $x_{i+1}$
\STATE $noChange = false$
\ENDIF
\ENDFOR
\UNTIL{$noChange$ is $true$}
\end{algorithmic}
\end{algorithm}
\subsection{Tables}
You may also want to include tables that summarize material. Like
figures, these should be centered, legible, and numbered consecutively.
However, place the title \emph{above} the table with at least
0.1~inches of space before the title and the same after it, as in
Table~\ref{sample-table}. The table title should be set in 9~point
type and centered unless it runs two or more lines, in which case it
should be flush left.
\begin{table}[t]
\caption{Classification accuracies for naive Bayes and flexible
Bayes on various data sets.}
\label{sample-table}
\vskip 0.15in
\begin{center}
\begin{small}
\begin{sc}
\begin{tabular}{lcccr}
\toprule
Data set & Naive & Flexible & Better? \\
\midrule
Breast & 95.9$\pm$ 0.2& 96.7$\pm$ 0.2& $\surd$ \\
Cleveland & 83.3$\pm$ 0.6& 80.0$\pm$ 0.6& $\times$\\
Glass2 & 61.9$\pm$ 1.4& 83.8$\pm$ 0.7& $\surd$ \\
Credit & 74.8$\pm$ 0.5& 78.3$\pm$ 0.6& \\
Horse & 73.3$\pm$ 0.9& 69.7$\pm$ 1.0& $\times$\\
Meta & 67.1$\pm$ 0.6& 76.5$\pm$ 0.5& $\surd$ \\
Pima & 75.1$\pm$ 0.6& 73.9$\pm$ 0.5& \\
Vehicle & 44.9$\pm$ 0.6& 61.5$\pm$ 0.4& $\surd$ \\
\bottomrule
\end{tabular}
\end{sc}
\end{small}
\end{center}
\vskip -0.1in
\end{table}
Tables contain textual material, whereas figures contain graphical material.
Specify the contents of each row and column in the table's topmost
row. Again, you may float tables to a column's top or bottom, and set
wide tables across both columns. Place two-column tables at the
top or bottom of the page.
\subsection{Citations and References}
Please use APA reference format regardless of your formatter
or word processor. If you rely on the \LaTeX\/ bibliographic
facility, use \texttt{natbib.sty} and \texttt{icml2020.bst}
included in the style-file package to obtain this format.
Citations within the text should include the authors' last names and
year. If the authors' names are included in the sentence, place only
the year in parentheses, for example when referencing Arthur Samuel's
pioneering work \yrcite{Samuel59}. Otherwise place the entire
reference in parentheses with the authors and year separated by a
comma \cite{Samuel59}. List multiple references separated by
semicolons \cite{kearns89,Samuel59,mitchell80}. Use the `et~al.'
construct only for citations with three or more authors or after
listing all authors to a publication in an earlier reference \cite{MachineLearningI}.
Authors should cite their own work in the third person
in the initial version of their paper submitted for blind review.
Please refer to Section~\ref{author info} for detailed instructions on how to
cite your own papers.
Use an unnumbered first-level section heading for the references, and use a
hanging indent style, with the first line of the reference flush against the
left margin and subsequent lines indented by 10 points. The references at the
end of this document give examples for journal articles \cite{Samuel59},
conference publications \cite{langley00}, book chapters \cite{Newell81}, books
\cite{DudaHart2nd}, edited volumes \cite{MachineLearningI}, technical reports
\cite{mitchell80}, and dissertations \cite{kearns89}.
Alphabetize references by the surnames of the first authors, with
single author entries preceding multiple author entries. Order
references for the same authors by year of publication, with the
earliest first. Make sure that each reference includes all relevant
information (e.g., page numbers).
Please put some effort into making references complete, presentable, and
consistent. If using bibtex, please protect capital letters of names and
abbreviations in titles, for example, use \{B\}ayesian or \{L\}ipschitz
in your .bib file.
\section*{Software and Data}
If a paper is accepted, we strongly encourage the publication of software and data with the
camera-ready version of the paper whenever appropriate. This can be
done by including a URL in the camera-ready copy. However, \textbf{do not}
include URLs that reveal your institution or identity in your
submission for review. Instead, provide an anonymous URL or upload
the material as ``Supplementary Material'' into the CMT reviewing
system. Note that reviewers are not required to look at this material
when writing their review.
\section*{Acknowledgements}
\textbf{Do not} include acknowledgements in the initial version of
the paper submitted for blind review.
If a paper is accepted, the final camera-ready version can (and
probably should) include acknowledgements. In this case, please
place such acknowledgements in an unnumbered section at the
end of the paper. Typically, this will include thanks to reviewers
who gave useful comments, to colleagues who contributed to the ideas,
and to funding agencies and corporate sponsors that provided financial
support.
\nocite{langley00}
\subsection{Verification of Individual Calibration}
The benefit of Definition~\ref{def:paic_monotonic} is that
it can be verified with a finite number of validation samples, and is amenable to uniform convergence bounds, so that we can train it following the standard empirical risk minimization framework.
\begin{restatable}{prop}{concentration}[Concentration]
\label{prop:concentration}
Let $\bar{h}$ be any $(\epsilon,\delta)$-mPAIC forecaster, and $(x_1, y_1), \cdots, (x_n, y_n) \mathrel{\stackrel{\makebox[0pt]{\mbox{\scriptsize i.i.d.}}}{\sim}} {\cdf_{\xs\ys}}$, $r_1, \cdots, r_n \mathrel{\stackrel{\makebox[0pt]{\mbox{\scriptsize i.i.d.}}}{\sim}} {\cdf_\mathbf{U}}$, then with probability $1-\gamma
\[ \frac{1}{n} \sum_{i=1}^n \mathbb{I}(\lvert \bar{h}[x_i, r_i](y_i) - r_i \rvert \geq \epsilon) \leq \delta + \sqrt{\frac{-\log \gamma}{2n}} \]
\end{restatable}
\paragraph{Applicability of Sufficient Condition}
Our results are most useful when ${\mathbf{Y}} \mid x$ is almost deterministic, i.e. the uncertainty comes from model ignorance instead of the environment. When ${\mathbf{Y}} \mid x$ takes a distribution with high variance, Definition~\ref{def:paic_monotonic} can still be achieved, but with a significant sacrifice to sharpness. This is because $\bar{h}[x, r]$ must be a high variance distribution to satisfy $\bar{h}[x, r]({\mathbf{Y}}) \approx r$ for all likely values for ${\mathbf{Y}} \mid x$.
\subsection{Learning Calibrated Randomized Forecasters}
Given training data $(x_i, y_i) \mathrel{\stackrel{\makebox[0pt]{\mbox{\scriptsize i.i.d.}}}{\sim}} {\cdf_{\xs\ys}}$ we would like to learn a forecaster that satisfy mPAIC. We propose a concrete set of forecasters and a learning algorithm we will use in all of our experiments.
We will model uncertainty with Gaussian distributions $\lbrace {\mathcal{N}}(\mu, \sigma^2), \mu \in \mathbb{R}, \sigma \in \mathbb{R}^+ \rbrace$.
We parameterize $\bar{h} = \bar{h}_\theta$ as a deep neural network with parameters $\theta$. The neural networks takes in concatenation of $x$ and $r$ and outputs the $\mu, \sigma$ that decides the returned CDF.
Inspired by Proposition~\ref{prop:concentration}, we optimize the mPAIC objective on the training data defined as~\footnote{In practice we always sample a new $r_i$ for each training step. }
\[ {\mathcal{L}}_{\text{PAIC}}(\theta) = \frac{1}{n}\sum_{i=1}^n \lvert \bar{h}_\theta[x_i, r_i](y_i) - r_i \rvert \]
Practically, this objective enforces the calibration but does not take into account the sharpness of the forecaster. For example, a simple $\bar{h}$ can be constructed that trivially outputs $r$ (Appendix~\ref{sec:appendix_trivial_mpaic}).
We would also like to minimize the variance $\sigma$ of the predicted Gaussian distribution. Therefore we also regularize with the log likelihood (i.e. log derivative of the CDF) objective which encourages the sharpness of the prediction
\[ {\mathcal{L}}_{\text{NLL}}(\theta) = - \frac{1}{n} \sum_{i=1}^n \log \frac{d}{dy} \bar{h}[x_i, r_i](y_i)\]
Because we model uncertainty with Gaussian distributions, the ${\mathcal{L}}_{\text{NLL}}$ objective is equivalent to the standard squared error (MSE) objective typically used in regression~\citep{myers1990classical} literature.
We use a hyper-parameter $\alpha$ to trade-off between the two objectives:
\begin{align*}
\mathcal{L}_\alpha(\theta) = (1- \alpha) {\mathcal{L}}_{\text{PAIC}}(\theta) + \alpha {\mathcal{L}}_{\text{NLL}}(\theta) \numberthis\label{eq:training_objective}
\end{align*}
In other words, when $\alpha \approx 0$ the objective is almost exclusively PAIC, while when $\alpha = 1$ we reduce to the standard log likelihood maximization (i.e. MSE) objective.
\section{Related Work}
\textbf{Randomized Forecast}:
Randomized forecast has been used in adversarial environments. In online learning where the true label can be adversarial, randomized forecasters can achieve low regret~\citep{cesa2006prediction,shalev2012online}. In security games / Stackelberg games~\citep{tsai2010urban, trejo2015stackelberg},
defender needs randomization to play against attackers.
\citep{perdomo2020performative} gives a theoretical characterization of prediction in (possibly adversarial) environments when the loss function is strongly convex.
\textbf{Calibration}:
Definitions of average calibration first appeared in the statistics literature \citep{brier1950verification, murphy1973new, dawid1984present,cesa2006prediction}. Recently there has been a surge of interest in recalibrating classifiers~\citep{platt1999probabilistic, zadrozny2001obtaining, zadrozny2002transforming, niculescu2005predicting}, especially deep networks~\citep{guo2017calibration, lakshminarayanan2017simple}. Average calibration in the regression setup has been studied by \citep{gneiting2007probabilistic,kuleshov2018accurate}.
Group calibration for a small number of pre-specified groups has been studied in~\citep{kleinberg2016inherent}. Interestingly \citep{hebert2017calibration,kearns2017preventing} can achieve calibration for any group computable by a small circuit, but is computationally difficult (likely no polynomial time algorithm). Similarly \citep{barber2019limits} achieve calibration for a set of groups, but only has efficient algorithms for special sets of groups.
\citep{kearns2019average} proposes a notion of individual calibration applicable when there are many prediction tasks, and each individual draws multiple prediction tasks.
\citep{joseph2016fairness} achieves a notion similar to individual calibration for fairness, but needs strong realizability assumptions that are difficult to verify.
\citep{liu2018implicit} proves an upper bound on calibration error for any group. However, it is unclear how to compute the upper bound if the group labels are not provided.
\textbf{Calibration for Regression} We extend the definition of regression calibration proposed in \citep{kuleshov2018accurate}. This is not the unique reasonable definition for regression calibration. For example, we can partition ${\mathcal{Y}}$ into bins to convert the regression problem into a classification problem, apply the classification calibration definition~\citep{vovk2005algorithmic,guo2017calibration}, and take the number of bins to infinity. This leads to a different definition for calibration than ours (even in the limit of infinitely many bins). Alternative definitions have also been proposed in~\citep{levi2019evaluating}. Individual calibration that extends these alternative definitions is beyond the scope of this paper.
\textbf{Conformal Prediction} Individual guarantees are also discussed in the conformal prediction literature \citep{vovk2005algorithmic}, where the objective is to produce an set that contains the true label with guaranteed high probability. \citep{vovk2012conditional,barber2019limits} show that if a conformal predictor \textit{always} satisfies conditional coverage (i.e. the true label belong to the predicted set with the advertised probability for each individual sample), then the size of the set must be impractically large. Therefore \citep{barber2019limits} instead achieves a notion of coverage for groups.
An individually calibrated forecaster can be converted into a conformal predictor that satisfies conditional coverage --- ${\mathbf{Y}} \mid x$ belongs to the set $[\mathbf{H}[x]^{-1}(\alpha/2), \mathbf{H}[x]^{-1}(1-\alpha/2)]$ with $1-\alpha$ probability if the forecaster is individually calibrated.
However, our algorithm is not bound by the impossibility result of \citep{barber2019limits,vovk2012conditional} because our algorithm do not \textit{always} produce individually calibrated forecasters --- success of the algorithm depends on the inductive bias and the data distribution. However, whenever the algorithm succeeds in producing individually calibrated forecasters, we do obtain post-training guarantees by Theorem~\ref{prop:concentration}.
\textbf{Fairness}:
In addition to calibration~\citep{kleinberg2016inherent,hebert2017calibration,kearns2017preventing}, other definitions of fairness include metric based fairness~\citep{dwork2012fairness}, equalized odds~\citep{hardt2016equality}, conterfactual fairness~\citep{kusner2017counterfactual, kilbertus2017avoiding}, and representation fairness~\citep{zemel2013learning,louizos2015variational,song2018learning}. The trade-off between these definitions are discussed in~\citep{pleiss2017fairness,kleinberg2016inherent,friedler2016possibility,corbett2017algorithmic}.
\section{Conclusion and Future Work}
In this paper we explore using randomization to achieve individual calibration for regression. We show that these individually calibrated predictions are useful for fairness or decision making under uncertainty.
One future direction is extending our results to classification.
The challenge is that there is no natural way to define a CDF for a discrete random variables.
Another open question is a good theoretical characterization of the trade-off between sharpness and individual calibration.
\section{Preliminary: Forecaster and Calibration}
\subsection{Notation}
We use bold capital letters $\mathbf{X}, {\mathbf{Y}}, {\mathbf{Z}}, \mathbf{H}$ to denote random variables, lower case letters $x, y, z, h$ to denote fixed values, and ${\mathcal{X}}, {\mathcal{Y}}, {\mathcal{Z}}, {\mathcal{H}}$ to denote the set of all possible values they can take.
For a random variable ${\mathbf{Z}}$ on ${\mathcal{Z}}$ we will use ${\mathbb{F}}_{\mathbf{Z}}$ to denote the distribution of ${\mathbf{Z}}$, and denote this relationship as ${\mathbf{Z}} \sim {\mathbb{F}}_{\mathbf{Z}}$. If ${\mathcal{Z}}$ is an interval in $\mathbb{R}$ we
overload ${\mathbb{F}}_{\mathbf{Z}}$ to denote the cumulative distribution function (CDF) ${\mathcal{Z}} \to [0, 1]$ of ${\mathbf{Z}}$.
$\mathbf{X}$ is a random variable on ${\mathcal{X}}$, if ${\mathcal{S}} \subset {\mathcal{X}}$ is a measurable set and $\Pr[\mathbf{X} \in {\mathcal{S}}] > 0$, we will use the notation $X_{\mathcal{S}}$ as the random variable distributed as $\mathbf{X}$ conditioned on $\mathbf{X} \in {\mathcal{S}}$.
Let ${\mathcal{Y}}$ be an interval in $\mathbb{R}$, we use ${\mathcal{F}}({\mathcal{Y}})$ denote the set of all CDFs on ${\mathcal{Y}}$.
We use $d: {\mathcal{F}}([0, 1]) \times {\mathcal{F}}([0, 1]) \to \mathbb{R}$ to denote a distance function between two CDFs on $[0, 1]$. For example, the Wasserstein-1 distance is defined for any ${\mathbb{F}}, {\mathbb{F}}' \in {\mathcal{F}}([0, 1])$ as
\[ d_{W1}({\mathbb{F}}, {\mathbb{F}}') = \int_{r=0}^1 \lvert {\mathbb{F}}(r) - {\mathbb{F}}'(r) \rvert dr \]
This is the distance we will use throughout the paper. We provide results for other distances in the appendix.
\subsection{Problem Setup}
Given an input feature vector $x \in {\mathcal{X}}$ we would like to predict a distribution on the label $y \in {\mathcal{Y}}$. We only consider regression problems where ${\mathcal{Y}}$ is an interval in $\mathbb{R}$.
Suppose there is a true distribution ${\mathbb{F}}_\mathbf{X}$ on ${\mathcal{X}}$, and a random variable $\mathbf{X} \sim {\mathbb{F}}_\mathbf{X}$.
For each $x \in {\mathcal{X}}$, we also assume there is some true distribution ${\cdf_{\ys \mid x}}$ on ${\mathcal{Y}}$, and a random variable ${\mathbf{Y}} \sim {\cdf_{\ys \mid x}}$.
As a convention, the random variable ${\mathbf{Y}}$ only appears in any expression along side $x$ or $\mathbf{X}$. Its distribution is always defined conditioned on $x$ (or after we have randomly sampled $x \sim {\mathbb{F}}_\mathbf{X}$).
A \textbf{probability forecaster} is a function $h: {\mathcal{X}} \to {\mathcal{F}}({\mathcal{Y}})$ that maps an input $x\in {\mathcal{X}}$ to a continuous CDF $h[x]$ over ${\mathcal{Y}}$. Note that $h[x]$ is a CDF, i.e. it is a function that takes in $y\in {\mathcal{Y}}$ and returns a real number $h[x](y) \in [0, 1]$. We use $[\cdot]$ to denote function evaluation for $x$ and $(\cdot)$ for $y$.
Let ${\mathcal{H}} \mathrel{\stackrel{\makebox[0pt]{\mbox{\scriptsize def}}}{=}} \lbrace h: {\mathcal{X}} \to {\mathcal{F}}({\mathcal{Y}}) \rbrace$ be the set of possible probability forecasters.
We consider \textbf{randomized} forecasters $\mathbf{H}$ which is a random function taking values in ${\mathcal{H}}$.
To clarify notation, $\mathbf{H}[\mathbf{X}]({\mathbf{Y}}), \mathbf{H}[x]({\mathbf{Y}})$ and $\mathbf{H}[x](y)$ are all random variables taking values in $[0, 1]$, but they are random variables on different sample spaces.
\begin{itemize}
\item $\mathbf{H}[\mathbf{X}]({\mathbf{Y}})$ is a random variable on the sample space ${\mathcal{H}} \times {\mathcal{X}} \times {\mathcal{Y}}$ --- All of $\mathbf{H}, \mathbf{X}, {\mathbf{Y}}$ are random.
\item $\mathbf{H}[x]({\mathbf{Y}})$ is a random variable on the sample space ${\mathcal{H}} \times {\mathcal{Y}}$, while $x$ is just a fixed value in ${\mathcal{X}}$.
\item $\mathbf{H}[x](y)$ is a random variable on the sample space ${\mathcal{H}}$, while $x, y$ are just fixed values in ${\mathcal{X}} \times {\mathcal{Y}}$.
\end{itemize}
Similarly $h[\mathbf{X}]({\mathbf{Y}}), h[x]({\mathbf{Y}})$ are also random variables taking values in $[0, 1]$, while $h[x](y)$ is just a number in $[0, 1]$ (there is no randomness).
This difference will be crucial to distinguishing different notions of calibration.
We use ${\cdf_{\fs[\xs](\ys)}}, {\cdf_{\fs[x](\ysx)}}$ and ${\cdf_{\fs[x](y)}}$, etc, to denote the CDF of these $[0, 1]$-valued random variables. These are in general different CDFs because the random variables have different distributions (they are not even defined on the same sample space).
If the $\mathbf{H}$ takes some fixed value in $h \in {\mathcal{H}}$ with probability $1$, we call it a deterministic forecaster. Because deterministic forecasters are a subset of randomized forecasters, we will use $\mathbf{H}$ to denote them as well
\subsection{Background: Perfect Probability Forecast}
We consider several criteria that a good probability forecaster $\mathbf{H}$ (randomized or deterministic) should satisfy, and whether they are achievable.
Given some input $x \in {\mathcal{X}}$, an ideal forecaster should always output the CDF of the true conditional distribution ${\cdf_{\ys \mid x}}$. We call such a forecaster a ``perfect forecaster''.
However, learning an (approximately) perfect forecaster from training data is almost never possible.
Usually each $x \in {\mathcal{X}}$ appear at most once in the training set (e.g. it is unlikely for the training set to contain identical images). It would be almost impossible to infer the entire CDF ${\mathbb{F}}_{Y \mid x}$ from a single sample $y \sim {\mathbb{F}}_{Y \mid x}$~\citep{vovk2005algorithmic} without strong assumptions.
\subsection{Individual Calibration}
Because perfect probability forecasters are difficult to learn, we relax our requirement, and look at which desirable property of a perfect forecaster to emulate.
We first observe that for some $x$, when the random variable ${\mathbf{Y}}$ is truly drawn from a continuous CDF ${\cdf_{\ys \mid x}} \in {\mathcal{F}}({\mathcal{Y}})$, by the inverse CDF theorem, ${\cdf_{\ys \mid x}}({\mathbf{Y}})$ should be a random variable with uniform distribution in $[0, 1]$ --- As a notation reminder, ${\cdf_{\ys \mid x}}$ is a fixed (CDF) function ${\mathcal{Y}} \to [0, 1]$, ${\mathbf{Y}}$ is a random variable taking values in ${\mathcal{Y}}$. Therefore, ${\cdf_{\ys \mid x}}({\mathbf{Y}})$ is a random variable taking values in $[0, 1]$. Also recall the convention that whenever ${\mathbf{Y}}$ appears in an expression, its distribution is always conditioned on $x$, i.e. ${\mathbf{Y}} \sim {\cdf_{\ys \mid x}}$.
If $\mathbf{H}$ is indeed a perfect forecaster, then $\forall x \in {\mathcal{X}}$, $\mathbf{H}[x]$ should always equal the true CDF: $\mathbf{H}[x] = {\cdf_{\ys \mid x}}$. Therefore $\mathbf{H}[x]({\mathbf{Y}})$ is a uniformly distributed random variable. In other words, ${\cdf_{\fs[x](\ysx)}}$ is the CDF function of a uniform random variable. Conversely, we can require this property for any good forecaster.
Formally, let $d: {\mathcal{F}}([0, 1]) \times {\mathcal{F}}([0, 1]) \to \mathbb{R}^+$ be any distance function (such as the Wasserstein-1 distance) between CDFs over $[0,1]$. For convenience we use ${\cdf_\mathbf{U}}$ to denote the CDF of a uniform random variable in $[0, 1]$.
We can measure
\[ {\mathrm{err}}_\mathbf{H}(x) \mathrel{\stackrel{\makebox[0pt]{\mbox{\scriptsize def}}}{=}} d({\cdf_{\fs[x](\ysx)}}, {\cdf_\mathbf{U}}) \]
and if ${\mathrm{err}}_\mathbf{H}(x) = 0$ for all $x \in {\mathcal{X}}$, we say the forecaster $\mathbf{H}$ satisfies individual calibration.
\paragraph{Deterministic vs randomized forecasters.}
Individual calibration for randomized forecasters has a weaker interpretation compared to deterministic forecasters. For example, the randomized forecaster that achieves individual calibration in Figure 1 has no deterministic counterpart. If one removes the randomness by averaging multiple random samples from $\mathbf{H}[x]$, the individual calibration property is lost.
In fact, if $\mathbf{H}$ is deterministic (we denote it as $h$ instead), then ${\mathrm{err}}_h(x) = 0$ implies that $h[x]$ is the same CDF (almost everywhere) as ${\cdf_{\ys \mid x}}$. In other words, the forecaster has to produce exactly the correct distribution to satisfy individual calibration, which is limited by strong impossibility results in \citep{barber2019limits,vovk2005algorithmic}. In fact, given finitely many data, we cannot even verify that a deterministic forecaster achieves individual calibration or not (Section 3).
On the other hand, for most prediction tasks there always exists a randomized forecaster that trivially achieves individual calibration (Appendix~\ref{sec:appendix_trivial_mpaic}). Individual calibration along is not sufficient to guarantee that a randomized forecaster is useful, and must be supplemented with an additional "sharpness" objective. We will discuss this issue in Section 4.3.
Even though individual calibration for randomized forecaster is a weaker definition, it has two key benefits. First, there is a sufficient condition to individual calibration that can be verified with a finite dataset (Section 4.1); second, with the additional "sharpness" objective, it is useful for several real world applications (Section 5,6).
\paragraph{Approximate Individual Calibration.} In practice individual calibration can only be achieved approximately, i.e. ${\mathrm{err}}_\mathbf{H}(x) \approx 0$ for most values of $x \in {\mathcal{X}}$, which we formalize in the following definition.
\begin{definition}[Individual calibration for randomized forecasters]
\label{def:individual_calibration}
A forecaster $\mathbf{H}$ is $(\epsilon,\delta)$-probably approximately individually calibrated (PAIC) (with respect to distance metric $d$) if
\[ \Pr \left[ {\mathrm{err}}_\mathbf{H}(\mathbf{X})\leq \epsilon \right] \geq 1- \delta \]
\end{definition}
This definition is intimately related to a standard definition of calibration for regression~\citep{gneiting2007probabilistic,kuleshov2018accurate}
which we restate slightly differently.
\begin{definition}[Average calibration]
\label{def:average_calibration}
A forecaster $\mathbf{H}$ is $\epsilon$-approximately average calibrated (with respect to distance metric $d$)
if
\[ d({\cdf_{\fs[\xs](\ys)}}, {\cdf_\mathbf{U}}) \leq \epsilon \]
\end{definition}
Note that $d({\cdf_{\fs[\xs](\ys)}}, {\cdf_\mathbf{U}}) = 0$ is equivalent to the original definition of calibrated regression in \citep{kuleshov2018accurate}
\begin{align*}
{\cdf_{\fs[\xs](\ys)}}(c) = \Pr[\mathbf{H}[\mathbf{X}]({\mathbf{Y}}) \leq c] = c = {\cdf_\mathbf{U}}(c), \forall c \in [0, 1]
\end{align*}
In words, under the ground truth distribution, $y$ should be below the $c$-th quantile of the predicted CDF exactly $c$ percent of the times. More generally, an $\epsilon$-approximately average calibrated forecaster with respect to Wasserstein-1 distance also has $\epsilon$ ECE (expected calibration error) --- a metric commonly used to measure calibration error~\citep{guo2017calibration}. For details see Appendix~\ref{sec:appendix_ece}.
Despite the similarity, individual calibration is actually much stronger compared to average calibration (Figure~\ref{fig:comparison}). Individual calibration requires $\mathbf{H}[x]({\mathbf{Y}})$ be uniformly distributed for \textit{every} $x$. average calibration only require this \textit{on average}: $\mathbf{H}[\mathbf{X}]({\mathbf{Y}})$ is uniformly distributed only if $\mathbf{X} \sim {\mathbb{F}}_\mathbf{X}$ --- it may not be uniformly distributed if $\mathbf{X}$ has some other distribution. For example, if ${\mathcal{X}}$ can be partitioned based on gender, the forecaster can be uncalibrated when $\mathbf{X}$ is restricted to a particular gender. On the other hand, average calibration is fairly easy to achieve with a deterministic forecaster~\citep{kuleshov2018accurate} --- there is no need or clear benefit from using a randomized forecaster.
\subsection{Group Calibration}
To address the short-coming of average calibration in Definition~\ref{def:average_calibration}, a stronger notion of calibration has been proposed~\citep{kleinberg2016inherent, hebert2017calibration}.
We choose in advance measurable subsets ${\mathcal{S}}_1, \cdots, {\mathcal{S}}_k \subset {\mathcal{X}}$ such that $\Pr[\mathbf{X} \in {\mathcal{S}}_i] \neq 0, \forall i\in [k]$ (for \citet{hebert2017calibration} these are sets that can be identified by a small circuit from the input), and define the random variables $\mathbf{X}_{{\mathcal{S}}_1}, \cdots, \mathbf{X}_{{\mathcal{S}}_k}$ (Recall that ${\xs_{{\mathcal{S}}_i}}$ is distributed by $\mathbf{X}$ conditioned on $\mathbf{X} \in {\mathcal{S}}_i$).
\begin{definition}[Group Calibration
\label{def:group_calibration}
A forecaster $\mathbf{H}$ is $\epsilon$-approximately group calibrated w.r.t. distance metric $d$ and ${\mathcal{S}}_1, \cdots, {\mathcal{S}}_k \subset {\mathcal{X}}$ if
\[ \forall i\in [k], d\left({\mathbb{F}}_{\mathbf{H}[{\xs_{{\mathcal{S}}_i}}]({\mathbf{Y}})}, {\cdf_\mathbf{U}}\right) \leq \epsilon \]
\end{definition}
This can alleviate some of the shortcomings of average calibration. However, the groups must be pre-specified or easy to compute from the input features $\mathbf{X}$.
A much stronger definition (Figure~\ref{fig:comparison}) is group calibration for any subset of ${\mathcal{X}}$ that is sufficiently large.
\begin{definition}[Adversarial Group Calibration]
\label{def:adv_group_calibration}
A forecaster $\mathbf{H}$ is $(\epsilon,\delta)$-adversarial group calibrated (with respect to distance metric $d$) if for $\forall {\mathcal{S}} \subset {\mathcal{X}}$ such that $\Pr[\mathbf{X} \in {\mathcal{S}}] \geq \delta$ we have
\begin{align*} d\left({\mathbb{F}}_{\mathbf{H}[\mathbf{X}_{\mathcal{S}}]({\mathbf{Y}})}, {\cdf_\mathbf{U}}\right) \leq \epsilon \numberthis\label{eq:adv_group_calibration} \end{align*}
\end{definition}
| {'timestamp': '2020-09-10T02:10:03', 'yymm': '2006', 'arxiv_id': '2006.10288', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10288'} | arxiv |
\section{Introduction}
League of Legends (LoL), originally released in 2009 by Riot Games, is one of the most widely played computer games in the world. There are an estimated 100 million active players each month as of 2016 \cite{volk_2016}. The game currently has over 140 playable characters, known as champions, from which players can choose from at the start of every match \cite{champlist}.
These champions have widely varied characteristics and abilities that allow a player to truly customize their way of playing LoL. With so many available champions, our aim was to create a recommendation system that would enable players to discover champions they might like based on their current champion preferences.
In this paper, we implemented a champion recommendation system using collaborative filtering, specifically the singular value decomposition (SVD) algorithm. We conducted a preliminary user study to evaluate our system. Our results indicate that players significantly preferred our system's recommendations over random recommendations.
\section{Related Work}
In the broader Multiplayer Online Battle Arena (MOBA) genre, of which LoL is firmly situated within, previous work on recommendation systems share one broad underlying assumption: that players are primarily motivated by maximizing win-rate. Under this assumption, previous MOBA recommendation systems provided recommendations that optimize either team champion synergy (draft-based recommenders) \cite{1hanke2017recommender, 3chen2018recommender, 5porokhnenko2019recommender, 6wang2016outcome, 7semenov2016outcome, 8summerville2016draft} or player item synergy (item-based recommenders) \cite{2smit2019recommender, 4looi2018recommender}. Our approach, however, does not follow this assumption and instead provides recommendations that focus on player enjoyment.
Multiple previous recommenders focused on maximizing win-rate through synergy. Smit \cite{2smit2019recommender} created a recommender system for items in LoL, allowing a dynamic approach to a recommender system that adapts to the game over defined phases, utilizing Artificial Neural Nets trained on game states and win-rate.
Smit's work focused on item synergy instead of champion synergy, but it is still a notable work on a recommender oriented towards maximizing win-rate in MOBAs. With respect to the draft-based recommenders, Chen et al. \cite{3chen2018recommender} modeled the champion drafting process as a combinatorial game and utilized a Monte Carlo Tree Search with a Neural Net reward function to simulate and back-propagate dynamically optimal champion picks with respect to win-rate. While their approach achieved promising results over baseline strategies, their system targeted teams of players that are primarily concerned with the win-rate of their team's champion synergy, whereas we focus on individual player enjoyment. Their approach also did not take into account any player specific proclivities such as desired roles or favored champions.
Our approach does not follow the underlying assumptions of the previous studies. The goal of our system is completely different from finding the optimal item or team. While previous works can be classified as player-win or team-win oriented, our work firmly targets player enjoyment. Our recommendations are centered on the following assumptions:
1) a player is primarily driven to play champions based on their enjoyment of those champions,
2) a player's current enjoyment of a champion is related to their historical engagement with that champion, and
3) player engagement is a suitable driver for a general-audience MOBA champion recommender.
Our approach draws inspiration from Paterek's \cite{paterek2007netflix} substantially successful work on Netflix movie recommendations, which has similar problem characteristics to our own, given their focus on user ratings and the presence of high user engagement.
\section{Champion Recommendation System}
\subsection{Collaborative Filtering}
We built our champion recommender based on a collaborative filtering approach \cite{Sarwar:2001}, specifically the SVD algorithm. LoL is suitable for collaborative filtering as there is a massive base of users with diverse tastes and high user engagement, thus avoiding the common issues of cold starts, rating sparsity, and user homogeneity.
We used an unbiased version of the SVD algorithm since we normalized the training data. The SVD algorithm was suitable as it provides low rank latent factor discovery and user-champion mapping onto this latent space. This helps mitigate popularity bias, which is a common issue in many recommender systems where popular items are frequently recommended over more niche items \cite{popbias}. Consequently, the SVD approach allows for closely tailored recommendations to a user's taste, which is important due to the diversity of champions available.
Our model maps both champions (i.e., items) and players (i.e., users) with a joint latent factor space of dimensionality $f$, such that user-item preferences are modeled as inner products of that space. Suppose each champion $i$ is associated with a vector $q_i \in \mathbb{R}^f$ and each player $u$ is associated with a vector $p_u \in \mathbb{R}^f$. For any champion $i$, $q_i$ represents the extent to which a champion $i$ possesses the corresponding factor. Similarly, for a user $u$, each row in $p_u$ represents $u$'s interest in the corresponding factor. We then follow the standard SVD algorithm described by Koren et al. \cite{koren2009matrix} to train our model using a Python implementation of the SVD algorithm from the Surprise library \cite{Surprise}.
\subsection{Building a training set}
SVD utilizes user ratings to build a model that can provide recommendations \cite{koren2009matrix}. While explicit ratings of how much a player enjoys a champion are not available, we are able to approximate their preferences by how often they have played a champion. Our recommendation system however, is further limited to the data made public by Riot Games. As Riot Games does not provide public access to how many times a player has played a champion, we instead make use of Champion Mastery Points $(C_{MP})$, a metric that is publicly accessible, which is an integer approximation of how often a player has played a certain champion.
A player has a $C_{MP}$ for each champion in the game, where $0 \ \leq C_{MP} < \infty$.
Every time a player selects a champion for a game, the player's $C_{MP}$ for that champion increases by an integer value depending on their performance. There is no way to decrease $C_{MP}$. However, due to these characteristics, a user that plays the game more frequently would have a higher overall $C_{MP}$ than a user who plays less frequently. To mitigate this issue, we normalized these scores to a linear scale between 1 and 100, such that a user's most played champion is rated as a 100, regardless of its raw $C_{MP}$ value. While players' $C_{MP}$ values generally follow a Poisson distribution, we found that a linear scaling performed the best in a pilot study, in part due to its mitigation of popularity bias. The use of $C_{MP}$ serves our aims well, as we believe that behaviorally observed preferences are more indicative of true preferences in this domain.
We pulled the $C_{MP}$ values of 2514 random active players (i.e., players who have played recently) using Riot’s official API \cite{riotapi} in order to train our model. We used this dataset of 2514 random players and their respective $C_{MP}$ values to build our recommender system. Our dataset and code is available at \cite{github}.
\subsection{Finding Recommendations}
To find recommendations for a player, we provided our system with a player's summoner name (their unique username) and queried Riot Games' API in order to find their top five champions sorted by $C_{MP}$. Table 1 displays an example of a sample player's top five $C_{MP}$ values and their normalized $C_{MP}$ ratings. For the queried user, we selected only the top five champions of a player because the sum total $C_{MP}$ of their top five champions typically account for a large majority of their sum total $C_{MP}$ among all champions. Furthermore, $C_{MP}$ values are not explicit ratings and a low $C_{MP}$ value does not necessarily mean that a player does not enjoy a champion. For example, a low $C_{MP}$ value could simply indicate that a player has not yet tried a champion very much. We used these five $C_{MP}$ values as the user's preferences to find ratings for all champions outside of their top five champions. After the system calculates ratings, it sorts these scores and outputs the top five respective champions as recommendations.
\begin{table}[htbp]
\caption{Example list of a player's top 5 champions and their $C_{MP}$ values}
\begin{center}
\begin{tabular}{| l | l | l |}
\hline
Champion & $C_{MP}$ & Normalized $C_{MP}$ \\ \hline
Nami & 367,191 & 100\\
Zyra & 136,709 & 38 \\
Cassiopeia & 106,064 & 29 \\
Janna & 89,306 & 25\\
Lulu & 59,486 & 17\\
\hline
\end{tabular}
\label{cmp-table}
\end{center}
\end{table}
\section{Survey Experiment}
We conducted a preliminary survey experiment to determine the practicality of our recommender system.
\subsection{Procedure}
Participants were asked for their summoner name which was used to generate recommendations. They were then given a survey that asked for their explicit champion ratings for 10 champions. 5 of these champions were our system's top recommendations and the other 5 were randomly selected from the remaining pool of champions. We chose to survey only 10 champions to keep the survey relatively short. The order of the champions presented was randomly determined to avoid introducing bias. We then analyzed the mean ratings given by the user and compared the recommendation ratings to the random ratings. Figure \ref{fig:survey} is an example of a survey given to a user.
\begin{figure}
\begin{flushleft}
\begingroup
\setlength{\tabcolsep}{10pt}
\resizebox{\linewidth}{!}{%
\begin{tabular}{|@{}c@{}|}
\hline
\renewcommand{\arraystretch}{1.2}
\resizebox{\linewidth}{!}{%
\begin{tabular}{l}
How would you rate your enjoyment of each champion from 1-10? \\
1 = I do not like playing this champion \\
10 = This champion is very enjoyable to play
\end{tabular}}\\
\renewcommand{\arraystretch}{1.5}
\resizebox{\linewidth}{!}{%
\begin{tabular}{l r l r}
Karma & \rule{1cm}{1pt} &
\hspace{2em}Graves * & \rule{1cm}{1pt} \\
Jax * & \rule{1cm}{1pt} &
\hspace{2em}Sona & \rule{1cm}{1pt} \\
Zilean & \rule{1cm}{1pt} &
\hspace{2em}Syndra * & \rule{1cm}{1pt} \\
Thresh & \rule{1cm}{1pt} &
\hspace{2em}Warwick * & \rule{1cm}{1pt} \\
Zed & \rule{1cm}{1pt} &
\hspace{2em}Draven * & \rule{1cm}{1pt} \\
\end{tabular}}\\
\hline
\end{tabular}}
\endgroup
\end{flushleft}
\caption{Sample survey given to a user where * indicates a random recommendation. This is not visible to the subject}
\label{fig:survey}
\end{figure}
\subsection{Participants}
We recruited 30 unpaid volunteers (24 male, 6 female) from the university club LOLUTD (League of Legends at The University of Texas at Dallas). Participants were active and experienced players.
\subsection{Research Questions and Hypotheses}
\textbf{RQ1: Do players enjoy our system's recommendations more than random recommendations?}
\textit{H1: Players will enjoy our system's recommendations more than random recommendations.} We expect that players will rate system recommendations higher than random recommendations.
\subsection{Results}
Since we have complete access to all survey data points, we tested for significance using a one-sided two sample Z-test for means. System recommendations had a mean of 6.46 and random recommendations had a mean of 5.18. Given $p=0.01257$, we reject the null hypothesis $H_0$ that the means are equal at the $\alpha=0.05$ level and can conclude that system recommendations are rated significantly higher. We can tentatively state that users prefer the system generated recommendations more than random recommendations. This preference is evident in the histograms of scores as seen in Figures \ref{fig:randomhist} and \ref{fig:systemhist}. In Figure \ref{fig:randomhist}, the distribution of user rated scores seems relatively normal, which is to be expected of random recommendations. In Figure \ref{fig:systemhist}, the distribution of user rated scores is skewed to the left, showing that users rate system recommendations fairly high. Therefore, our results support H1.
\begin{figure}[ht]
\centering
\includegraphics[width=\linewidth]{images/random.png}
\caption{Histogram of user rated scores given to random recommendations}
\label{fig:randomhist}
\vspace{1em}
\includegraphics[width=\linewidth]{images/generated.png}
\caption{Histogram of user rated scores given to system generated recommendations}
\label{fig:systemhist}
\end{figure}
\section{Discussion}
Our preliminary results indicate that an SVD-based collaborative filtering approach can recommend champions that players enjoy significantly more than random recommendations. This system could help introduce players to champions that they may have otherwise overlooked. Given the considerable number of champions in LoL, this can be a useful service to drive player engagement. Furthermore, our results show that $C_{MP}$ is a useful measure for player champion preference. These findings can help game designers and analysts identify player groups and preferences using $C_{MP}$. Additionally, our approach emphasizes recommending enjoyable champions to players rather than recommending champions that will increase a player's win rate.
\subsection{Exploration of other algorithms}
We also built models using the Slope One \cite{lemire2005slope} and SVD++ algorithms in the Surprise library and obtained lackluster results.
We found Slope One to be highly susceptible to popularity bias; popular champions such as Ezreal, Lee Sin, and Yasuo were consistently recommended for users regardless of user preferences.
While theoretically more accurate, the SVD++ model had a prohibitive run time for the aims of our project with only minor improvement in practical accuracy. We ran a test using an Intel i7-6700 with 32GB of RAM on our dataset of 311,727 rows. A single run using SVD++ in this environment took over an hour, which was not feasible for our application where users would want results in a reasonable timeframe.
\subsection{Limitations}
Metagames in LoL are what players perceive to be the best strategy at some given time in the game \cite{donaldson2017mechanics}. These different metagames skew the popularity of certain champions based on their strength in a specific metagame. While this does affect our system, we believe that this effect balances out due to both the evolving metagames that give every champion their time in the limelight and people's natural preference to play a champion that they enjoy, even though it may impact their chances of winning.
Another consideration is that champions may change considerably due to champion reworks. Reworks may change a champion's skills and appearance, but are infrequently done to old champions that are in need of an update \cite{champUpdate}. As $C_{MP}$ is maintained regardless of any changes to the champions, our model will be misled for some user preferences. Additionally, new champions are occasionally added to the game. Older champions will have higher average $C_{MP}$ in comparison and newer champions will be less likely to be recommended.
It is important to note that our survey is preliminary and was conducted to assess the potential of our recommendation system. Most participants were active, experienced players, while our system should ideally be suitable for the general, amateur player base. Additionally, our participants were also all college students and were mostly male.
\subsection{Conclusion and Future Work}
In this paper, we implemented a champion recommendation system for LoL using an SVD-based collaborative filtering approach. Our system uses champion mastery points to indicate player preferences. We conducted a preliminary user study that validates the practicality of our system and indicates that users enjoy our system's recommendations significantly more than random recommendations.
In the future, we plan to rerun our survey study using optimal parameters. The recommender tested in our user study made use of the naive SVD model in the Surprise library.
The default parameters are \cite{Surprise}: $epoch = 20$, $\lambda = 0.005$, and $\gamma = 0.02$, where $\lambda$ is the regularization term and $\gamma$ is the learning rate.
The results obtained in our preliminary study indicated that the SVD model is appropriate for a champion recommender system. Following this validation, we tuned these model parameters using a grid search to maximize theoretical accuracy by minimizing root mean square error \cite{Surprise}. The optimal parameters found are the following: $epoch = 20$, $\lambda=0.4$, and $\gamma = 0.0005$.
By using these parameters for model fitting, stronger results in a user study would likely be obtained. Furthermore, to better tailor our system to individual player profiles, we could dynamically adjust the number of reference champions used for generating recommendations. This would allow for recommendations that meet the needs of players whose $C_{MP}$ values are more uniformly distributed.
We also plan to run a more comprehensive survey study. We could compare our system recommendations to more naive recommendation systems, such as a selection of the most played champions. Additionally, we could follow a more standardized methodology and also survey a more diverse and representative population.
\section{Acknowledgments}
This project was initially conceived in a graduate machine learning course at The University of Texas at Dallas. The authors would like to thank Dr. Anjum Chida and Dr. Cuneyt Akcora for their valuable comments and teachings.
\bibliographystyle{IEEEtran}
| {'timestamp': '2020-06-19T02:05:33', 'yymm': '2006', 'arxiv_id': '2006.10191', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10191'} | arxiv |
\section{Introduction and Preliminaries}\label{sec:intro}
We continue the study of graphs associated with algebras that was initiated
in the first part of this paper \cite{Bulatov20:graph} (see also
\cite{Bulatov16:graph}).
The vertices of the graph ${\mathcal G}({\mathbb A})$ associated with an idempotent algebra
${\mathbb A}$ are the elements of ${\mathbb A}$, and the edges are pairs of vertices
that have certain properties with respect to term operations of
${\mathbb A}$, see the definitions below. Two kinds of edges were introduced,
`thick' and `thin', where the thin version is a more technical kind, perhaps
less intuitive, but also more suitable as a tool for the results of this part.
Thin edges are also directed converting ${\mathcal G}({\mathbb A})$ into a digraph.
In the second part we first focus on the connectivity properties of this
digraph, in particular, we show that more vertices are connected by directed paths
of thin edges than one might expect (Theorem~\ref{the:connectivity}).
Then we study the structure of subdirect products of algebras.
An important role here is played by so-called as-components of algebras,
which are subsets of algebras defined through certain connectivity properties.
We prove that subdirect products when restricted to as-components
have the property of rectangularity similar to Mal'tsev algebras, and also
similar to the Absorption Theorem (see, e.g.\ \cite{Barto12:absorbing}).
Finally, we show that,
again, modulo as-components any subdirect product is 2-decomposable,
similar to Baker-Pixley Theorem \cite{Baker75:chinese-remainder}.
\subsection{Thick edges}
We start with reminding the main definitions and results from
\cite{Bulatov20:graph}. Operation $x-y+z$ of a module ${\mathbb M}$ is said
to be \emph{affine}. Let ${\mathbb A}$ be a finite algebra with universe
$A$. Recall that for $B\sse A$ the subalgebra of ${\mathbb A}$ generated by
$B$ is denoted $\Sgg{\mathbb A} B$, or just $\Sg B$ if ${\mathbb A}$ is clear from the
context. Edges of ${\mathbb A}$ are defined as follows.
A pair $ab$ of vertices is an \emph{edge} if and only if
there exists a maximal congruence $\th$ of $\Sg{a,b}$ such that either
$\Sg{a,b}\fac\th$ is a set, or it is term equivalent to the full idempotent
reduct of a module (we will simply say that $\Sg{a,b}\fac\th$ is a module)
and there is a term operation of ${\mathbb A}$ such
that $f\fac\th$ is an affine operation of $\Sg{a,b}\fac\th$, or
there exists a term operation of ${\mathbb A}$ such that $f\fac\th$ is a semilattice
operation on $\{a^\th,b^\th\}$, or $f\fac\th$
is a majority operation on $\{a^\th,b^\th\}$.
If there exists a maximal congruence and a term operation of ${\mathbb A}$ such that
$f\fac\th$ is a semilattice operation on $\{a\fac\th,b\fac\th\}$ then $ab$ is
said to have the {\em semilattice} type. Edge $ab$ is of the
{\em majority} type if it is not of the semilattice type, and there are a
maximal congruence $\th$ and $f\in{\sf Term}({\mathbb A})$ such that $f\fac\th$
is a majority
operation on $\{a\fac\th,b\fac\th\}$. Pair $ab$ has the {\em affine type}
if there are a maximal congruence $\th$ and $f\in{\sf Term}({\mathbb A})$
such that $\Sg{a,b}\fac\th$ is a module and $f\fac\th$ is its
affine operation. Finally, $ab$ is of the
\emph{unary type} if $\Sg{a,b}\fac\th$ is a set. In all cases we say that
congruence $\th$ \emph{witnesses} the type of edge $ab$. The set
$\{a\fac\th, b\fac\th\}$ will often be referred to as a \emph{thick} edge.
In this paper we assume that ${\mathbb A}$ does not have edges of the unary type,
which is equivalent to the statement that $\var{\mathbb A}$, the variety generated by
${\mathbb A}$, omits type {\bf1}\ (Theorem 5(2) of \cite{Bulatov20:graph}).
We restate the relevant results from \cite{Bulatov20:graph}.
\begin{theorem}[Theorem~5(2,3) of \cite{Bulatov20:graph}]%
\label{the:connectedness}
Let ${\mathbb A}$ be an idempotent algebra ${\mathbb A}$ such that
$\var{\mathbb A}$ omits type {\bf1}. Then
\begin{itemize}
\item[(1)]
any two elements of ${\mathbb A}$ are connected by a sequence of edges of
the semilattice, majority, and affine types;
\item[(2)]
$\var{\mathbb A}$ omits types {\bf1}\ and {\bf2}\ if and only if ${\mathbb A}$
contains no edges of the unary and affine types.
\end{itemize}
\end{theorem}
Algebra ${\mathbb A}$ is said to be \emph{smooth} if for every edge $ab$ of
the semilattice or majority type, $a\fac\th\cup b\fac\th$, where $\th$ is a
congruence witnessing that $ab$ is an edge, is a subalgebra of ${\mathbb A}$.
\begin{theorem}[Theorem~12 of \cite{Bulatov20:graph}]%
\label{the:smooth}
For any idempotent algebra ${\mathbb A}$ such that ${\mathbb A}$ does not contain edges
of the unary type there is a reduct ${\mathbb A}'$ of ${\mathbb A}$ that is smooth
and ${\mathbb A}'$ does not contain edges of the unary type.
Moreover, if ${\mathbb A}$ does not contain edges of the affine types, ${\mathbb A}'$
can be chosen such that it does not contain edges of the affine type.
\end{theorem}
In the case of smooth algebras the operations involved in the
definition of edges can be significantly unified.
\begin{theorem}[Theorem~21, Corollary~22 of \cite{Bulatov20:graph}]%
\label{the:uniform}
Let ${\mathcal K}$ be a finite set of similar smooth idempotent algebras.
There are term operations $f,g,h$ of ${\mathcal K}$ such that for every
edge $ab$ of ${\mathbb A}\in{\mathcal K}$, where $\th$ is a congruence of $\Sg{a,b}$
witnessing that $ab$ is an edge and $B=\{a\fac\th,b\fac\th\}$
\begin{description}
\item[(i)]
$f\red B$ is a semilattice
operation if $ab$ is a semilattice edge, and it is the first projection if $ab$ is a
majority or affine edge;
\item[(ii)]
$g\red B$ is a majority operation if $ab$ is a majority edge, it is the first
projection if $ab$ is a affine edge, and $g\red B(x,y,z)=f\red B(x,f\red B(y,z))$
if $ab$ is semilattice;
\item[(iii)]
$h\red{\Sg{a,b}\fac\th}$ is an affine operation
operation if $ab$ is an affine edge, it is the first
projection if $ab$ is a majority edge, and
$h\red B(x,y,z)=f\red B(x,f\red B(y,z))$ if $ab$ is semilattice.
\end{description}
\end{theorem}
Operations $f,g,h$ from Theorem~\ref{the:uniform} above can be chosen
to satisfy certain identities.
\begin{lemma}[Lemma~23 of \cite{Bulatov20:graph}]\label{lem:fgh-identities}
Operations $f,g,h$ identified in Theorem~\ref{the:uniform} can be chosen
such that
\begin{itemize}\itemsep0pt
\item[(1)]
$f(x,f(x,y))=f(x,y)$ for all $x,y\in{\mathbb A}\in{\mathcal K}$;
\item[(2)]
$g(x,g(x,y,y),g(x,y,y))=g(x,y,y)$ for all $x,y\in{\mathbb A}\in{\mathcal K}$;
\item[(3)]
$h(h(x,y,y),y,y)=h(x,y,y)$ for all $x,y\in{\mathbb A}\in{\mathcal K}$.
\end{itemize}
\end{lemma}
\begin{prop}[Lemmas~8,10 of \cite{Bulatov20:graph}]\label{pro:edge-extend}
Let ${\mathbb A}$ be an idempotent algebra.
Then\\[1mm]
(1) if $ab$ an edge in ${\mathbb A}$, it is an edge of the same type in any
subalgebra ${\mathbb B}$ of ${\mathbb A}$ containing $a,b$;\\[1mm]
(2) if $\al$ is a congruence of ${\mathbb A}$ and $a\fac\al b\fac\al$, $a,b\in{\mathbb A}$,
is an edge in ${\mathcal G}({\mathbb A}\fac\al)$ then $ab$ is also an edge in ${\mathcal G}({\mathbb A})$
of the same type.
\end{prop}
We often use Proposition~\ref{pro:edge-extend}(2) as given
in the following statement that is obtained from
Proposition~\ref{pro:edge-extend}(2) by taking ${\mathbb A}$ to be $R$
and $\al$ to be the projection congruence on ${\mathbb A}$.
\begin{corollary}\label{cor:edge-extend}
Let ${\mathbb B}$ be an idempotent algebra and $ab$ an edge in ${\mathbb B}$.
Then if $R$ is a subalgebra of ${\mathbb B}\tm{\mathbb C}$ and ${\bf a},{\bf b}\inR$ with
${\bf a}[1]=a,{\bf b}[1]=b$, then ${\bf a}{\bf b}$ is an edge of the same type
as $ab$ in $R$.
\end{corollary}
Corollary~\ref{cor:edge-extend} can be straightforwardly
extended to the following claim: if $R$ is a subdirect product of
$\tms{\mathbb A} n$, $I\sse[n]$, and ${\bf a}{\bf b}$ is an edge in ${\rm pr}_IR$,
then for any ${\bf a}',{\bf b}'\inR$ with ${\rm pr}_I{\bf a}'={\bf a},{\rm pr}_I{\bf b}'={\bf b}$,
the pair ${\bf a}'{\bf b}'$ is an edge in $R$ of the same type as ${\bf a}{\bf b}$.
Also note that, as Example~9 from \cite{Bulatov20:graph} shows that
if $ab$ is an edge in ${\mathbb A}$ and $\al\in{\sf Con}({\mathbb A})$, then $a\fac\al b\fac\al$
does not have to be an edge even if $a\fac\al\ne b\fac\al$.
Several times we will also use the classification of simple idempotent
algebras from \cite{Kearnes96:idempotent}, see also Proposition~3 from
\cite{Bulatov20:graph}. Recall that an element $a$ of an algebra ${\mathbb A}$
is said to be {\em absorbing} if whenever $t(x,\vc yn)$ is an
$(n+1)$-ary term operation of ${\mathbb A}$ such that $t$ depends on $x$ and
$\vc bn\in{\mathbb A}$, then $t(a,\vc bn)=a$. A congruence $\th$ of
${\mathbb A}^2$ is said to be {\em skew} if it is the kernel of no projection
mapping of ${\mathbb A}^2$ onto its factors. The following theorem due to
Kearnes \cite{Kearnes96:idempotent} provides some information
about the structure of simple idempotent algebras.
\begin{theorem}[\cite{Kearnes96:idempotent}, Proposition~3 of
\cite{Bulatov20:graph}]\label{the:simple-idempotent}
Let ${\mathbb A}$ be a finite simple idempotent algebra. Then exactly
one of the following holds:
\begin{itemize}\itemsep0pt
\item[(a)]
${\mathbb A}$ is a set;
\item[(a')]
${\mathbb A}$ is the full idempotent reduct of a finite module;
\item[(b)]
${\mathbb A}$ has an absorbing element;
\item[(c)]
${\mathbb A}^2$ has no skew congruence.
\end{itemize}
\end{theorem}
\subsection{Thin edges}
Thin edges, also introduced in \cite{Bulatov20:graph}, offer a better
technical tool.
Fix a finite class ${\mathcal K}$ of smooth algebras closed under taking subalgebras
and homomorphic images. Let ${\mathbb A}\in{\mathcal K}$ be a smooth algebra, $a,b\in{\mathbb A}$,
${\mathbb B}=\Sg{a,b}$, and $\th$ a congruence of ${\mathbb B}$. Pair $ab$ is said to be
\emph{minimal} with respect to $\th$ if for any $b'\in b\fac\th$,
$b\in\Sg{a,b'}$. A ternary term $g'$ is said to satisfy the \emph{majority
condition} (with respect to ${\mathcal K}$) if it satisfies the conditions of
Lemma~\ref{lem:fgh-identities}(2), and $g'$ is a majority operation on every
thick majority edge of every algebra from ${\mathcal K}$. A ternary term operation
$h'$ is said to satisfy the \emph{minority condition} if it satisfies the conditions
of Lemma~\ref{lem:fgh-identities}(3), and $h'$ is a Mal'tsev
operation on every thick affine edge of every algebra from ${\mathcal K}$. By
Theorem~\ref{the:uniform} operations satisfying the majority and
minority conditions exist.
A semilattice edge $ab$ in ${\mathbb A}$
is called a \emph{thin semilattice edge} if the equality relation witnesses
that it is a semilattice edge; or in other words if there is a term operation
$f$ such that $f(a,b)=f(b,a)=b$.
A pair $ab$ is called a \emph{thin majority edge} if
\begin{itemize}
\item[(*)]
for any term operation $g'$ satisfying the majority condition,
the subalgebras $\Sg{a,g'(a,b,b)},\Sg{a,g'(b,a,b)},\Sg{a,g'(b,b,a)}$
contain $b$.
\end{itemize}
If $ab$ is also a majority edge, a congruence $\th$ witnesses that and
$ab$ is a minimal pair with respect to $\th$, $ab$ is said to be a
\emph{special thin majority edge}.
Fix an operation $h$ satisfying the minority condition, in particular it
satisfies the equation $h(h(x,y,y),y,y)=h(x,y,y)$. A pair $ab$ is called
a \emph{thin affine edge} (with respect to ${\mathcal K}$) if $h(b,a,a)=b$ and
for every term operation $h'$ satisfying the minority condition
\begin{itemize}
\item[(**)]
$b\in\Sg{a,h'(a,a,b)}$.
\end{itemize}
The operations $g,h$ from Theorem~\ref{the:uniform} do not
have to satisfy any specific conditions on the set $\{a,b\}$, when
$ab$ is a thin majority or affine edge, except what follows from their
definition. Also, both thin majority and thin affine edges are
directed, since $a,b$ in the definition occur asymmetrically. Note also, that
what pairs of an algebra ${\mathbb A}$ are thin majority and minority
edges depend not only on the algebra itself, but also on the underlying
class ${\mathcal K}$. If we are not interested in any particular class, set
${\mathcal K}={\sf H}{\sf S}({\mathbb A})$.
\begin{lemma}[Corollaries~25,29,33 Lemmas~28,32, \cite{Bulatov20:graph}]%
\label{lem:thin-semilattice}
Let ${\mathbb A}\in{\mathcal K}$ and let $ab$ be a semilattice (majority, affine) edge,
$\th$ a congruence of
$\Sg{a,b}$ that witnesses this, and $c\in a\fac\th$. Then, if $ab$ is
a semilattice or majority edge, then for any $d\in b\fac\th$ such that
$cd$ is a minimal pair with respect to $\th$ the pair $cd$ is a thin
semilattice or special majority edge. If $ab$ is affine then for any
$d\in b\fac\th$ such that $ad$ is a minimal pair with respect to
$\th$ and $h(d,a,a)=d$ the pair $ad$ is a thin affine edge. Moreover,
$d\in b\fac\th$ satisfying these conditions exists.
\end{lemma}
The binary operation $f$ from Theorem~\ref{the:uniform} can be
chosen to satisfy a special property.
\begin{prop}[Proposition~24, \cite{Bulatov20:graph}]\label{pro:good-operation}
Let ${\mathcal K}$ be a finite class of similar smooth idempotent algebras. There
is a binary term operation $f$ of ${\mathcal K}$ such that $f$ is a semilattice
operation on every thick semilattice edge of every ${\mathbb A}\in{\mathcal K}$ and for
any $a,b\in{\mathbb A}$, ${\mathbb A}\in{\mathcal K}$, either $a=f(a,b)$ or the pair $(a,f(a,b))$
is a thin semilattice edge.
\end{prop}
For a class ${\mathcal K}$ of similar smooth idempotent algebras we assume
that operation $f$ satisfying the conditions of
Proposition~\ref{pro:good-operation} is fixed, and use $\cdot$ to
denote it (think multiplication). If $ab$ is a thin semilattice edge,
that is, $a\cdot b=b\cdot a=b$, we write $a\le b$.
\begin{lemma}[Lemmas~27,31,35, \cite{Bulatov20:graph}]%
\label{lem:thin-combination}
(1) Let ${\mathbb A}_1,{\mathbb A}_2,{\mathbb A}_3\in{\mathcal K}$ be similar smooth idempotent algebras.
Let $a_1b_1$, $a_2b_2$, and $a_3b_3$ be thin majority edges in
${\mathbb A}_1,{\mathbb A}_2,{\mathbb A}_3$. Then there is an operation $g'$ such that
$g'(a_1,b_1,b_1)=b_1$, $g'(b_2,a_2,b_2)=b_2$,
$g'(b_3,b_3,a_3)=b_3$. In particular, for any thin majority edge
$ab$ there is an operation $g'$ satisfying the majority condition such that
$g'(a,b,b)=g'(b,a,b)=g'(b,b,a)=b$.\\[1mm]
(2) Let $ab$ and $cd$ be thin affine edges in ${\mathbb A}_1,{\mathbb A}_2\in{\mathcal K}$. Then
there is an operation $h'$ such that $h'(b,a,a)=b$ and
$h'(c,c,d)=d$. In particular, for any thin affine edge $ab$ there
is an operation $h'$ such that $h'(b,a,a)=h'(a,a,b)=b$.\\[1mm]
(3) Let $ab$ and $cd$ be thin edges in ${\mathbb A}_1,{\mathbb A}_2\in{\mathcal K}$.
If they have different types there is a binary term operation $p$ such that
$p(b,a)=b$, $p(c,d)=d$.
\end{lemma}
\subsection{Paths and fiters}
Let ${\mathbb A}\in{\mathcal K}$ be a smooth algebra. A \emph{path} in ${\mathbb A}$ is a sequence
$a_0,a_1,\ldots, a_k$ such
that $a_{i-1}a_i$ is a thin edge for all $i\in[k]$ (note that thin edges
are always assumed to be directed).
We will distinguish paths of several types depending on what types of
edges allowed. If $a_{i-1}\le a_i$ for all $i\in[k]$ then the path is
called a \emph{semilattice} or \emph{s-path}. If for every $i\in[k]$
either $a_{i-1}\le a_i$ or $a_{i-1}a_i$ is a thin
affine edge then the path is called \emph{affine-semilattice} or
\emph{as-path}. Similarly, if only semilattice and thin majority edges
are allowed we have a \emph{semilattice-majority} or
\emph{sm-path}. The path is called \emph{asm-path} when all types
of edges are allowed. If
there is a path $a=a_0,a_1,\ldots, a_k=b$ which is arbitrary (semilattice,
affine-semilattice, semilattice-majority) then $a$ is said to be
\emph{asm-connected} (or \emph{s-connected}, or
\emph{as-connected}, or \emph{sm-connected}) to $b$. We will also
say that $a$ is \emph{connected} to $b$ if it is asm-connected.
We denote this by $a\sqq^{asm}b$
(for asm-connectivity), $a\sqq b$, $a\sqq^{as}b$ and
$a\sqq^{sm}b$ for s-, as-, and sm-connectivity, respectively.
If all the thin majority edges in a sm- or asm-path are special,
we call such path special. The following is a direct inplication of
Theorem~\ref{the:connectedness} and Lemma~\ref{lem:thin-semilattice}.
\begin{corollary}\label{cor:oriented}
Any two elements of a smooth algebra ${\mathbb A}\in{\mathcal K}$ are connected with an
oriented path consisting of thin edges.
\end{corollary}
Let ${\mathcal G}_s({\mathbb A})$ (${\mathcal G}_{as}({\mathbb A}),{\mathcal G}_{asm}({\mathbb A})$) denote the digraph
whose nodes are the elements of ${\mathbb A}$, and the edges are the thin
semilattice edges (thin semilattice and affine edges, arbitrary thin edges,
respectively). The strongly connected component of ${\mathcal G}_s({\mathbb A})$
containing $a\in{\mathbb A}$ will be denoted by $\se a$. The set of strongly
connected components of ${\mathcal G}_s({\mathbb A})$ are ordered in the natural
way (if $a\le b$ then $\se a\le \se b$), the elements belonging to
maximal ones will be called \emph{maximal}, and the set of all
maximal elements from ${\mathbb A}$ will be denoted by $\max({\mathbb A})$.
The strongly connected component of ${\mathcal G}_{as}({\mathbb A})$ containing
$a\in{\mathbb A}$ will be denoted by $\mathsf{as}(a)$. A maximal strongly connected
component of this graph is called an
\emph{as-component}, an element from an as-component
is called \emph{as-maximal}, and the set of all as-maximal elements is
denoted by $\mathsf{amax}({\mathbb A})$.
Finally, the strongly connected component of ${\mathcal G}_{asm}({\mathbb A})$ containing
$a\in{\mathbb A}$ will be denoted by $\mathsf{asm}(a)$. A maximal strongly connected
component of this graph is called an \emph{universally maximal
component} (or \emph{u-maximal component} for short), an element
from a u-component is called \emph{u-maximal}, and the set of all
u-maximal elements is denoted by $\mathsf{umax}({\mathbb A})$.
Alternatively, maximal, as-maximal, and u-maximal elements
can be characterized as follows: an element $a\in{\mathbb A}$ is
maximal (as-maximal, u-maximal) if for every $b\in{\mathbb A}$ such
that $a\sqq b$ ($a\sqq^{as}b$, $a\sqq^{asm} b$)
it also holds that $b\sqq a$ ($b\sqq^{as}a$, $b\sqq^{asm}a$).
Sometimes it will be convenient to specify what the algebra is,
in which we consider maximal components, as-components,
or u-maximal components, and the corresponding connectivity.
In such cases we we will specify it by writing $\see {\mathbb A} a$,
$\mathsf{as}_{\mathbb A}(a)$, or $\mathsf{asm}_{\mathbb A}(a)$. For connectivity we will use
$a\sqq_{\mathbb A} b$, $a\sqq_{\mathbb A}^{as}b$, and $a\sqq_{\mathbb A}^{asm}b$.
By $\mathrm{Ft}_{\mathbb A}(a)=\{b\in{\mathbb A}\mid a\sqq_{\mathbb A} b\}$ we
denote the set of elements $a$ is connected to (in terms of
semilattice paths); similarly, by
$\mathrm{Ft}^{as}_{\mathbb A}(a)=\{b\in{\mathbb A}\mid a\sqq_{\mathbb A}^{as} b\}$ and
$\mathrm{Ft}^{asm}_{\mathbb A}(a)=\{b\in{\mathbb A}\mid a\sqq_{\mathbb A}^{asm} b\}$ we
denote the set of elements $a$ is as-connected and
asm-connected to. Also, $\mathrm{Ft}_{\mathbb A}(C)=\bigcup_{a\in C}\mathrm{Ft}_{\mathbb A}(a)$
($\mathrm{Ft}^{as}_{\mathbb A}(C)=\bigcup_{a\in C}\mathrm{Ft}^{as}_{\mathbb A}(a)$,
$\mathrm{Ft}^{asm}_{\mathbb A}(C)=\bigcup_{a\in C}\mathrm{Ft}^{asm}_{\mathbb A}(a)$,
respectively) for $C\sse {\mathbb A}$. Note that if $a$ is a maximal
(as-maximal or u-maximal) element then $\se a=\mathrm{Ft}_{\mathbb A}(a)$
($\mathsf{as}(a)=\mathrm{Ft}^{as}_{\mathbb A}(a)$, and $\mathsf{umax}(a)\sse\mathrm{Ft}^{asm}_{\mathbb A}(b)$).
\section{Maximality}\label{sec:maximality}
In this section we study properties of (s-, as-, asm-) paths and
(as-, asm-) maximal elements and the connections between
(as-, asm-) maximal elements of an algebra with those in a
quotient algebra or subdirect product.
We start with a simple observation that a path (of thin edges) in a
quotient algebra or subdirect product gives rise to a path in the
original algebra or a factor of the product.
\begin{lemma}\label{lem:quotient-edge}
Let ${\mathbb A}\in{\mathcal K}$ and $\th\in{\sf Con}({\mathbb A})$.\\[1mm]
(1) If $\ov a\ov b$ is a thin edge in ${\mathbb A}\fac\th$ and $a\in\ov a$,
then there is $b\in\ov b$ such that $ab$ is a thin edge in ${\mathbb A}$
of the same type.
Morever, if $\ov a\ov b$ is a special thin majority edge, then
so is $ab$. \\[1mm]
(2) If $ab$ is a thin edge in ${\mathbb A}$, then $a\fac\th b\fac\th$
is a thin edge in ${\mathbb A}\fac\th$.
\end{lemma}
\begin{remark}
Note that in Lemma~\ref{lem:quotient-edge}(2) if $ab$
is a special thin majority edge, there is no guarantee
that $a\fac\th b\fac\th$ is also a special edge.
\end{remark}
\begin{proof}
Note first that by the assumption ${\mathbb A}\fac\th\in{\mathcal K}$.
Pick an arbitrary $b\in\ov b$ such that the pair
$ab$ is minimal with respect to $\th$. Let
${\mathbb B}=\Sgg{\mathbb A}{a,b}$.
First, if $\ov a\ov b$ is a thin semilattice edge, then
$ab$ is a semilattice edge as witnessed by $\th'$,
the restriction of $\th$ on ${\mathbb B}$. Then by
Lemma~\ref{lem:thin-semilattice} $ab$ is a
thin semilattice edge.
Now suppose that $\ov a\ov b$ is a thin majority edge.
Let $g'$ be an operation satisfying the majority property for ${\mathbb A}$
with respect to ${\mathcal K}$; then
$g'$ also satisfies the majority property for ${\mathbb A}\fac\th$.
Let $c=g'(a,b,b)$. Since $\ov a\ov b$
is a thin majority edge, there is a binary term operation $t$
such that $t(\ov a,c\fac\th)=\ov b$. Note that
$t(a,c)\in{\mathbb B}$, as well. By the choice of $b$, it holds
that $b\in\Sg{a,t(a,c)}$. Therefore, $b\in\Sg{a,g'(a,b,b)}$.
That $b\in\Sg{a,g'(b,a,b)}$ and $b\in\Sg{a,g'(b,b,a)}$
can be proved in the same way. Suppose in addition that
$\ov a\ov b$ is a special thin majority edge, that is, it is
a majority edge in ${\mathbb A}\fac\th$ and it is witnessed by a
congruence $\eta$ of $\Sgg{{\mathbb A}\fac\th}{\ov a,\ov b}$.
It is then straightforward that $ab$ is a majority edge
as witnessed by the congruence
$\eta\fac\th=\{(d,e)\in{\mathbb B}^2\mid d\fac\th\eqc\eta e\fac\th\}$.
Finally, suppose that $\ov a\ov b$ is a thin affine edge, and set
$b'=h(b,a,a)$, where $h$ is the operation identified in
Theorem~\ref{the:uniform}(iii). By Lemma~\ref{lem:fgh-identities}(3)
$h(b',a,a)=b'$. Note that $ab'$ is a minimal pair as well.
Consider $c=h(a,a,b')$. Since $\ov a\ov b$
is a thin affine edge, $\ov b\in\Sgg{{\mathbb A}\fac\th}{\ov a,c\fac\th}$.
This means that there is $d\in\Sgg{\mathbb A}{a,c}$ such that
$d\in\ov b$. Since $d\in\Sgg{\mathbb A}{a,b'}$ and $ab'$ is a minimal
pair with respect to $\th$, we obtain $b'\in\Sgg{\mathbb A}{a,d}
\sse\Sgg{\mathbb A}{a,c}$. Thus $ab'$ is a thin affine edge.
\smallskip
(2) If $a\eqc\th b$, the statement of the lemma is trivial.
Otherwise if $a\le b$, then
$a\fac\th\cdot b\fac\th=b\fac\th\cdot a\fac\th=b\fac\th$ showing that
$a\fac\th\le b\fac\th$.
If $ab$ is a thin majority edge, then consider an abitrary
$g'$ satisfying the majority condition. Since
$b\in\Sgg{\mathbb A}{a,g'(a,b,b)}$, we also have
$b\fac\th\in\Sgg{{\mathbb A}\fac\th}{a\fac\th,g'(a\fac\th,b\fac\th,b\fac\th)}$.
The argument for the rest of condition (*) is similar.
If $ab$ is a thin affine edge, then $h(b,a,a)=b$, implying
$h(b\fac\th,a\fac\th,a\fac\th)=b\fac\th$. Also, as
$b\in\Sgg{\mathbb A}{a,h(a,a,b)}$, we have
$b\fac\th\in\Sgg{\mathbb A}{a\fac\th,h(a\fac\th,a\fac\th,b\fac\th)}$
\end{proof}
The next statement straightforwardly follows from
Lemma~\ref{lem:quotient-edge}.
\begin{corollary}\label{cor:quotient-path}
Let ${\mathbb A}\in{\mathcal K}$ and $\th\in{\sf Con}{\mathbb A}$.\\[1mm]
(1) If $\vc{\ov a}k$ is an s- (as-,asm-) path in ${\mathbb A}\fac\th$ and
$a\in \ov a_1$, then there are $a_i\in\ov a_i$ such that
$a_1=a$ and $\vc ak$ is an s- (as-, asm-) path in ${\mathbb A}$.
Morever, if $\vc{\ov a}k$ is a special asm-path, then
$\vc ak$ is also a special asm-path. \\[1mm]
(2) If $\vc ak$ is an s- (as-, asm-) path in ${\mathbb A}$, then
the sequence $a_1\fac\th,\ldots, a_\ell\fac\th$ is an s- (as-, asm-)
path in ${\mathbb A}\fac\th$
\end{corollary}
\begin{corollary}\label{cor:quotient-max}
Let ${\mathbb A}\in{\mathcal K}$ and $\th\in{\sf Con}{\mathbb A}$.\\[1mm]
(1) If $\ov a\in{\mathbb A}\fac\th$ is maximal (as-maximal, u-maximal) in
${\mathbb A}\fac\th$, then there is $a\in\ov a$ that is maximal (as-maximal,
u-maximal) in ${\mathbb A}$.\\[1mm]
(2) If $a$ is maximal (as-maximal, u-maximal) in ${\mathbb A}$, then $a\fac\th$ is
maximal (as-maximal, u-maximal) in ${\mathbb A}\fac\th$.
\end{corollary}
\begin{proof}
(1) We will use notation $c\sqq^x d$, $x\in\{s,as,asm\}$, to denote that
there is an $x$-path from $c$ to $d$. Pick an arbitrary $a'\in\ov a$ and
let $b$ be any $x$-maximal element of ${\mathbb A}$ such that $a'\sqq^x b$.
This means that there is an $x$-path from $a'$ to $b$, and by
Corollary~\ref{cor:quotient-path}(2) there is also an $x$-path from
$a'\fac\th$ to $b\fac\th$ in ${\mathbb A}\fac\th$. Since by the assumption $\ov a$
is $x$-maximal, there is also an $x$-path in ${\mathbb A}\fac\th$ from
$b\fac\th$ to $\ov a$. By Corollary~\ref{cor:quotient-path}(1)
there is an $x$-path in ${\mathbb A}$ from $b$ to some element $a''\in\ov a$.
Since $b$ is an $x$-maximal element, so is $a''$.
\smallskip
(2) Suppose that $a\fac\th\sqq^x b\fac\th$ for some $b\in{\mathbb A}$. It suffices
to show that in this case $b\fac\th\sqq^x a\fac\th$. By
Corollary~\ref{cor:quotient-path}(1) there is an $x$-path in ${\mathbb A}$
from $a$ to some $b'\in b\fac\th$. Since $a$ is $x$-maximal, there also
exists an $x$-path $b'=b_1,\ldots, b_k=a$ from $b'$ to $a$. By
Corollary~\ref{cor:quotient-path}(2)
$b\fac\th=b_1\fac\th,\ldots, b_k\fac\th=a\fac\th$
is an $x$-path in ${\mathbb A}\fac\th$ from $b\fac\th$ to $a\fac\th$.
\end{proof}
The following statements will allow us to extend thin edges and then
paths in a factor of a subdirect product to thin edges and paths
in the product itself. We start with a claim about the majority and
minority conditions.
\begin{lemma}\label{lem:condition-to-product}
Let operation $f$ satisfies the majority (minority) condition for a
class ${\mathcal K}$ of smooth algebras. Then it also satisfies this condition for
any subdirect product $R\sse\tms{\mathbb A} n$, where
$\vc{\mathbb A} n\in{\mathcal K}$.
\end{lemma}
\begin{proof}
Clearly, $f$ satisfies on $R$ the required conditions from
Lemma~\ref{lem:fgh-identities}. We need to prove that $f$ is a majority
(affine) operation on every thick majority (respectively, affine) edge
of $R$. Suppose ${\bf a}{\bf b}$ is such an edge and $\th$
is the congruence of ${\mathbb B}=\Sg{{\bf a},{\bf b}}$ witnessing that. Let
$I({\bf a}',{\bf b}')=\{i\in[n]\mid {\bf a}'[i]={\bf b}'[i]\}$ for ${\bf a}',{\bf b}'\in{\mathbb A}$. As is easily
seen, for any ${\bf a}'\in{\bf a}\fac\th, {\bf b}'\in{\bf b}\fac\th$, the congruence
$\th'=\th\cap{\mathbb D}^2$ of ${\mathbb D}=\Sg{{\bf a}',{\bf b}'}$ witnesses that ${\bf a}'{\bf b}'$
is an edge of ${\mathbb A}$ of the same type as ${\bf a}{\bf b}$. Therefore, tuples
${\bf a},{\bf b}$ can be assumed to be such that $I=I({\bf a},{\bf b})$
is maximal among pairs ${\bf a}',{\bf b}'$ with ${\bf a}'\in{\bf a}\fac\th$, ${\bf b}'\in{\bf b}\fac\th$.
Then for any ${\bf c}\in{\mathbb B}$ and any $i\in I$, ${\bf c}[i]={\bf a}[i]$.
Take $i\in[n]-I$ and set $A'=\{{\bf a}'[i]\mid {\bf a}'\in{\bf a}\fac\th\}$ and
$B'=\{{\bf b}'[i]\mid {\bf b}'\in{\bf b}\fac\th\}$. By the choice of ${\bf a},{\bf b}$,
$A'\cap B'=\eps$. We argue that this means that the projection $\eta$ of $\th$
on the $i$th coordinate, that is, the congruence of ${\mathbb C}={\rm pr}_i{\mathbb B}$ given by
the transitive closure of
$$
{\sf tol}_i = \{(a,b)\mid \text{ for some ${\bf c},{\bf d}\in{\mathbb B}$,
$a={\bf c}[i]$, $b={\bf d}[i], ({\bf c},{\bf d})\in\th$}\}
$$
is nontrivial. Indeed, if ${\bf a}{\bf b}$ is a majority edge, then
$\th$ has only two congruence blocks, whose restrictions on ${\mathbb C}$ are
$A',B'$, which are disjoint. If ${\bf a}{\bf b}$ is affine, then ${\mathbb C}\fac\eta$
is homomorphic image of ${\mathbb B}\fac\th$. Since the latter is a simple
module, ${\mathbb C}\fac\eta$ is isomorphic to ${\mathbb B}\fac\th$. Thus,
${\bf a}[i]{\bf b}[i]$ is a majority (affine) edge in ${\mathbb A}_i$.
By the assumption $f$ is a majority (or affine) operation on
${\bf a}[i]\fac\eta{\bf b}[i]\fac\eta$, implying it is also a majority (affine)
operation on ${\mathbb B}\fac\th$.
\end{proof}
Next we study connectivity in subalgebras of direct products.
\begin{lemma}\label{lem:product-edge}
Let $R$ be a subdirect product of $\tms{\mathbb A} n$, $I\sse[n]$.\\[1mm]
(1) For any ${\bf a}\inR$, ${\bf a}^*={\rm pr}_I{\bf a}$, ${\bf b}\in{\rm pr}_IR$
such that ${\bf a}^*{\bf b}$ is a thin edge, there is
${\bf b}'\inR$, ${\rm pr}_I{\bf b}'={\bf b}$, such that ${\bf a}{\bf b}'$ is a thin edge of the same
type. Moreover, if ${\bf a}^*{\bf b}$ is a special thin majority edge,
then so is ${\bf a}{\bf b}'$.\\[1mm]
(2) If ${\bf a}{\bf b}$ is a thin edge in $R$ then ${\rm pr}_I{\bf a}\,{\rm pr}_I{\bf b}$
is a thin edge in ${\rm pr}_IR$ of the same type (including the
possibility that ${\rm pr}_I{\bf a}={\rm pr}_I{\bf b}$).
\end{lemma}
\begin{proof}
Observe that we can consider ${\rm pr}_IR$ as the quotient algebra
$R\fac{\eta_I}$, where $\eta_I$ is the projection congruence
of $R$, that is, $({\bf c},{\bf d})\in\eta_I$ if and only if
${\rm pr}_I{\bf c}={\rm pr}_I{\bf d}$. Then item (1) can be rephrased as follows:
For any ${\bf a}\inR$ and $\ov b\inR\fac{\eta_I}$ such that
${\bf a}\fac{\eta_I}\ov b$ is a thin edge in $R\fac{\eta_I}$, there is
${\bf b}'\in\ov b$ such that ${\bf a}{\bf b}'$ is a thin edge of the same
type. It clearly follows from Lemma~\ref{lem:quotient-edge}(1).
Similarly, item (2) can be rephrased as: If ${\bf a}{\bf b}$ is a thin
edge in $R$, then ${\bf a}\fac{\eta_I}{\bf b}\fac{\eta_I}$ is a thin
edge in $R\fac{\eta_I}$ of the same type. It follows
straightforwardly from Lemma~\ref{lem:quotient-edge}(2).
\end{proof}
The next statement follows from
Lemma~\ref{lem:product-edge}.
\begin{corollary}\label{cor:product-path}
Let $R$ be a subdirect product of $\tms{\mathbb A} n$ and
$I\sse[n]$.\\[1mm]
(1) For any ${\bf a}\inR$, and an s- (as-, asm-) path
$\vc{\bf b} k\in{\rm pr}_IR$ with ${\rm pr}_I{\bf a}={\bf b}_1$, there is an
s- (as-, asm-) path $\vc{{\bf b}'}\ell\inR$ such that
${\bf b}'_1={\bf a}$ and ${\rm pr}_I{\bf b}'_\ell={\bf b}_\ell$. Moreover, if $\vc{\bf b} k$ is a
special asm-path, so is $\vc{{\bf b}'}\ell$.\\[1mm]
(2) If $\vc{\bf a} k$ is an s- (as-, asm-) path in $R$, then
${\rm pr}_I{\bf a}_1,\ldots,{\rm pr}_I{\bf a}_k$ is an s- (as-, asm-) path in ${\rm pr}_IR$.
\end{corollary}
There is a connection between maximal (as-maximal,
u-maximal) elements of a subdirect product and its projections.
\begin{corollary}\label{cor:product-maximal}
Let $R$ be a subdirect product of $\tms{\mathbb A} n$ and $I\sse[n]$.\\[1mm]
(1) For any maximal (as-maximal, u-maximal) (in ${\rm pr}_IR$) element
${\bf b}\in{\rm pr}_IR$, there is ${\bf b}'\inR$ which is maximal (as-maximal,
u-maximal) in $R$ and such that ${\rm pr}_I{\bf b}'={\bf b}$. In particular,
${\rm pr}_{[n]-I}{\bf b}'$ is an maximal (as-maximal, u-maximal) in
${\rm pr}_{[n]-I}R$.\\[1mm]
(2) If ${\bf a}$ is an maximal (as-maximal, u-maximal) in $R$, then
${\rm pr}_I{\bf a}$ is maximal (as-maximal, u-maximal) in ${\rm pr}_IR$.
\end{corollary}
\begin{proof}
(1) We again can use the isomorphism between ${\rm pr}_IR$ and
the quotient algebra $R\fac{\eta_I}$. Then the statement of the
lemma translates into: If $\ov a\inR\fac{\eta_I}$ is maximal (as-maximal,
u-maximal) in $R\fac{\eta_I}$, then there is $a\in\ov a$ that is maximal
(as-maximal, u-maximal) in $R$. The latter statement is true by
the second part of this corollary.
\smallskip
(2) Using the isomorphism between ${\rm pr}_IR$ and
the quotient algebra $R\fac{\eta_I}$, the statement follows from
Corollary~\ref{cor:quotient-max}(2).
\end{proof}
The following lemma considers a special case of maximal components
of various types in subdirect products.
\begin{lemma}\label{lem:as-product}
Let $R$ be a subdirect product of ${\mathbb A}_1\tm{\mathbb A}_2$, $B,C$
maximal components (as-components, u-components) of
${\mathbb A}_1,{\mathbb A}_2$, respectively, and $B\tm C\sseR$.
Then $B\tm C$ is a maximal component (as-component, u-component)
of $R$.
\end{lemma}
\begin{proof}
We need to show that for any ${\bf a},{\bf b}\in B\tm C$ there is an
s-path (as-path, asm-path) from ${\bf a}$ to ${\bf b}$. By the assumption
there is a (s-,as-,asm-) path ${\bf a}[1]=a_1,a_2,\ldots, a_k={\bf b}[1]$ from
${\bf a}[1]$ to ${\bf b}[1]$ and a (s-,as-,asm-) path
${\bf a}[2]=b_1,b_2,\ldots, b_\ell={\bf b}[2]$ from ${\bf a}[2]$ to ${\bf b}[2]$.
Then the sequence
${\bf a}=(a_1,b_1),(a_2,b_1),\ldots,(a_k,b_1)$, $(a_k,b_2),\ldots,(a_k,b_\ell)={\bf b}$
is a (s-,as,asm-) path from ${\bf a}$ to ${\bf b}$.
\end{proof}
\section{Connectivity}\label{sec:connectivity}
Recall that in this paper we only consider smooth idempotent
algebras omitting type {\bf1}.
\subsection{General connectivity}
In this section we show that all maximal elements are connected to
each other. The undirected connectivity easily follows from the definitions,
and Theorem~\ref{the:connectedness}, so the challenge is to prove
directed connectivity, as defined above. We start with an auxiliary lemma.
Let $R\le{\mathbb A}_1\tm\dots\tm{\mathbb A}_k$ be a relation. Also, let
${\sf tol}_i(R)$ (or simply ${\sf tol}_i$ if $R$ is clear from the context),
$i\in[k]$, denote the \emph{link} tolerance
\begin{align*}
& \{(a_i,a'_i)\in{\mathbb A}_i^2\mid (a_1,\ldots, a_{i-1},a_i,a_{i+1},\ldots, a_k),\\
& \quad
(a_1,\ldots, a_{i-1},a'_i,a_{i+1},\ldots, a_k)\inR, \text{ for some
$(a_1,\ldots, a_{i-1},a_{i+1},\ldots, a_k)$}\}.
\end{align*}
Recall that a tolerance is said to be \emph{connected} if its transitive
closure is the full relation. The transitive closure
${\sf lk}_i(R)$ of ${\sf tol}_i(R)$, $i\in[k]$, is called the
\emph{link congruence}, and it is, indeed, a congruence.
If $R$ is binary, that is, a subdirect product of ${\mathbb A}_1,{\mathbb A}_2$,
then by $R[c], R^{-1}[c']$ for $c\in{\mathbb A}_1,c'\in{\mathbb A}_2$
we denote the sets $\{b\mid (c,b)\inR\}, \{a\mid (a,c')\inR\}$,
respectively, and for $C\sse{\mathbb A}_1,C'\sse{\mathbb A}_2$ we use
$R[C]=\bigcup_{c\in C}R[c]$,
$R^{-1}[C']=\bigcup_{c'\in C'}R^{-1}[c']$, respectively.
Relation $R$ is said to be \emph{linked}
if the link congruences ${\sf lk}_1(R),{\sf lk}_2(R)$ are full
congruences.
\begin{lemma}\label{lem:going-maximal}
Let ${\mathbb A}\in{\mathcal K}$ and let $S$ be a
tolerance of ${\mathbb A}$. Suppose that $(a,b)$, $a,b\in{\mathbb A}$,
belongs to the transitive closure of $S$, that is,
there are $\vc d{k-1}$ such that $(d_i,d_{i+1})\inS$ for
$i\in\{0,1,\ldots, k-1\}$, where $d_0=a,d_k=b$. If for some
$i\in\{0,1,\ldots, k\}$ there is $d'_i\in{\mathbb A}$ such that $d_i\sqq d'_i$,
then there are $d'_j\in{\mathbb A}$ for $j\in\{0,1,,\ldots, k\}-\{i\}$
such that $d_j\sqq d'_j$ for $j\in\{0,1,\ldots, k\}$,
and $(d'_j,d'_{j+1})\inS$ for $j\in\{0,1,\ldots, k-1\}$.
Moreover, if $d_0,\ldots, d_{i-1}$ are maximal, there are
$d''_0,\ldots, d''_k$ such that $d''_j=d_j$ for $j\in\{0,\ldots, i-1\}$,
$d_i\sqq d'_i\sqq d''_i$, $d_j\sqq d''_j$ for $j\in\{i+1,\ldots, k\}$,
and $(d''_j,d''_{j+1})\inS$ for $j\in\{0,\ldots, k-1\}$.
\end{lemma}
\begin{proof}
Let $d_i=d_i^1\le\ldots\le d_i^s=d'_i$ be an s-path from
$d_i$ to $d'_i$. For each $j\in\{0,1,\ldots, k\}-\{i\}$, we construct a
sequence $d_j=d_j^1\le\ldots\le d_j^s$ by setting
\[
d_j^q=d_j^{q-1}\cdot d_i^q.
\]
Now, we prove by induction that $(d_j^q,d_{j+1}^q)\inS$ for all
$q\in[s]$ and $j\in\{0,1,\ldots, k-1\}$. For $q=1$ it follows from the
assumptions of the lemma. If $(d_j^q,d_{j+1}^q)\inS$, then
$(d_j^{q+1},d_{j+1}^{q+1})=
(d_j^q\cdot d_i^{q+1},d_{j+1}^q\cdot d_i^{q+1})\inS$, since
$S$ is a tolerance. The first part of the lemma is proved.
For the second statement we apply the same construction, but only to
elements $d_{i-1},\ldots, d_k$, and do not change $d_0,\ldots, d_{i-2}$, that
is, we set $d'_j=d_j$ for $j\in\{0,\ldots, i-2\}$. Then, as before, we have
$(d'_j,d'_{j+1})\inS$ for $j\in\{i-1,\ldots, k\}$ and for $j\in\{0,\ldots, i-3\}$.
However, there is no guarantee that $(d'_{i-2},d'_{i-1})\inS$.
To remedy this we again apply the same construction as follows. Since
$d_{i-1}$ is a maximal element and $d_{i-1}\sqq d'_{i-1}$, it also holds
$d'_{i-1}\sqq d_{i-1}$. Let $d'_{i-1}=e_{i-1}^1\le\dots\le
e_{i-1}^\ell=d_{i-1}$ be an s-path connecting $d'_{i-1}$ to $d_{i-1}$.
We set $d''_j=d_j$ for $j\in\{0,\ldots, i-2\}$, and $e^1_j=d'_j$,
$e^{q+1}_j=e^q_j\cdot e^{q+1}_{i-1}$ and $d''_j=e^\ell_j$ for
$j\in\{i-1,\ldots, k\}$. Then, as before, $(d''_j,d''_{j+1})\inS$ for
$j\in\{i-1,\ldots, k-1\}$ and for $j\in\{0,\ldots, i-3\}$. However, since
$d''_{i-2}=d_{i-2}$ and $d''_{i-1}=d_{i-1}$, we also have
$(d''_{i-2},d''_{i-1})\inS$. The result follows.
\end{proof}
\begin{corollary}\label{cor:going-maximal}
Let ${\mathbb A}\in{\mathcal K}$ be a smooth idempotent algebra and $S$ a
tolerance of ${\mathbb A}$. Suppose that $(a,b)$, $a,b\in{\mathbb A}$,
belongs to the transitive closure of $S$, that is, there are
$\vc d{k-1}$ such that $(d_i,d_{i+1})\inS$ for
$i\in\{0,1,\ldots, k-1\}$, where $d_0=a,d_k=b$.
If $a,b$ are maximal in
${\mathbb A}$, then there are $d'_0,\ldots, d'_k$ such that $d'_0=a$, each
$d'_j$ is maximal in ${\mathbb A}$, $(d'_j,d'_{j+1})\inS$ for
$j\in\{0,\ldots, k-1\}$, and $d'_k\in\see{\mathbb A} b$.
\end{corollary}
\begin{proof}
We show by induction on $i$ that there are $d'_0,\ldots, d'_k$ such that
$d'_0=a$, $(d'_i,d'_{i+1})\inS$ for $i\in\{0,\ldots, k-1\}$,
$d'_k\in\see{\mathbb A} b$ and $d'_0,\ldots, d'_i$ are maximal. The base case of
induction, $i=0$, follows from the conditions of the lemma. Suppose
some $d'_j$s with the required properties exist for $i\in\{0,1,\ldots, k-1\}$.
Let $d^*_{i+1}$ be a maximal element with $d'_{i+1}\sqq d^*_{i+1}$.
By Lemma~\ref{lem:going-maximal} there are $d''_{i+1},\ldots, d''_k$
such that $d^*_{i+1}\sqq d''_{i+1}$, $d'_j\sqq d''_j$ for
$j\in\{i+2,\ldots, k\}$, $(d'_i,d''_{i+1})\inS$,
and $(d''_j,d''_{j+1})\inS$ for $j\in\{i+1,\ldots, k-1\}$. Elements
$d'_0,\ldots, d'_i,d''_{i+1},\ldots, d''_k$ satisfy the required conditions.
\end{proof}
The next theorem is the main result of this section.
\begin{theorem}\label{the:connectivity}
Let ${\mathbb A}\in{\mathcal K}$.
Any $a,b\in\max({\mathbb A})$ (or $a,b\in\mathsf{amax}({\mathbb A})$, or $a,b\in\mathsf{umax}({\mathbb A})$)
are asm-connected. Moreover if $a,b\in\max({\mathbb A})$ or
$a,b\in\mathsf{amax}({\mathbb A})$, they are connected by a special path.
\end{theorem}
\begin{proof}
We start by showing asm-connectivity by a special path (most of the
time we will not mention that we are looking for a special path, except
it is essential) for maximal elements, so let
$a,b\in\max({\mathbb A})$. We proceed by induction on the size of ${\mathbb A}$
through a sequence of claims. In the base case of induction, when
${\mathbb A}=\{a,b\}$, elements $a,b$ are connected with a thin majority
or affine edge, as they are both maximal, and the claim is
straightforward.
\smallskip
{\sc Claim 1.}
${\mathbb A}$ can be assumed to be $\Sg{a,b}$.
\smallskip
If $a,b\in\max({\mathbb B})$, ${\mathbb B}=\Sg{a,b}$, and ${\mathbb B}\ne{\mathbb A}$, then we are
done by the induction hypothesis. Suppose one of them is not
maximal in ${\mathbb B}$, and let
$c,d\in\max({\mathbb B})$ be such that $a\sqq c$ and $b\sqq d$. By the
induction hypothesis $c$ is asm-connected to $d$. As $a\sqq c$, $a$ is
asm-connected to $c$. It remains to show that $d$ is asm-connected to $b$.
This, however, follows straightforwardly from the assumption that
$b$ is maximal. Indeed, it implies $d\in \see{\mathbb A} b$, and hence $d\sqq b$
in ${\mathbb A}$.
\smallskip
{\sc Claim 2.}
${\mathbb A}$ can be assumed simple.
\smallskip
Suppose ${\mathbb A}$ is not simple and $\al$ is its maximal congruence. Let
${\mathbb B}={\mathbb A}\fac\al$. By the induction hypothesis $a\fac\al$ is asm-connected to
$b\fac\al$ with a special path, that is, there is a sequence
$a\fac\al=\ov a_0,\ov a_1,\ldots, \ov a_k=b\fac\al$ such that $\ov a_i\le\ov a_{i+1}$
or $\ov a_i\ov a_{i+1}$ is a thin affine or special majority edge in ${\mathbb B}$.
By Corollary~\ref{cor:quotient-path}(1) there is a special path
$\vc ak$ such that $a_1=a$ and $a_i\in\ov a_i$ in ${\mathbb A}$.
It remains to show that $a_k$ is asm-connected to $b$. Since $b$ is
maximal, it suffices to take elements $a',b'$ maximal in $b\fac\al$
and such that $a_k\sqq_{\ov a_k} a'$ and $b\sqq_{\ov a_k} b'$.
Then $a_k\sqq_{\ov a_k} a'$, element $a'$ is asm-connected to $b'$
in $\ov a_k$ by the induction hypothesis, and $b'$ is
asm-connected to $b$ in ${\mathbb A}$, as $b'\in \see{\mathbb A} b$.
\smallskip
{\sc Claim 3.}
$\Sg{a,b}$ can be assumed to be equal to $\Sg{a',b'}$ for any
$a'\in\see{\mathbb A} a$, $b'\in\see{\mathbb A} b$.
\smallskip
If $\Sg{a',b'}\subset \Sg{a,b}$ for some $a'\in \see{\mathbb A} a$,
$b'\in\see{\mathbb A} b$, then by the induction hypothesis $a''$ is
asm-connected to $b''$ for some $a''\in \see{\mathbb A} a$, $b''\in \see{\mathbb A} b$.
Therefore $a$ is also asm-connected to $b$.
\smallskip
We say that elements $c,d\in\max({\mathbb A})$ are connected by proper
subalgebras of ${\mathbb A}$ if there are subalgebras $\vc{\mathbb B}\ell$ such
that ${\mathbb B}_i\ne{\mathbb A}$ for $i\in[\ell]$, $c\in B_1$, $d\in{\mathbb B}_\ell$, and
${\mathbb B}_i\cap{\mathbb B}_{i+1}\cap\max({\mathbb A})\ne\eps$ for $i\in[\ell-1]$.
\smallskip
{\sc Claim 4.}
Let $c,d\in\max({\mathbb A})$, ${\mathbb A}=\Sg{c,d}$ be simple, and let $R_{cd}$ be the
subalgebra of ${\mathbb A}^2$ generated by $(c,d),(d,c)$. Suppose also that
for any $d'\in\see{\mathbb A} d$ the algebra $\Sg{c,d'}$ equals ${\mathbb A}$. Then
either $R_{cd}$ is the graph of an automorphism $\vf$ of ${\mathbb A}$
such that $\vf(c)=d$, $\vf(d)=c$, or $c,d'$ are connected by
proper subalgebras of ${\mathbb A}$ for some $d\sqq d'$, or $c\le d$, or $d\le c$.
\smallskip
Suppose that $R_{cd}$ is not the graph of a mapping, or,
in other words, there is no automorphism of ${\mathbb A}$ that maps
$c$ to $d$ and $d$ to $c$. We consider the link tolerance
$S={\sf tol}_1(R_{cd})$. Since ${\mathbb A}$ is simple and $R$ is
not the graph of a mapping, the transitive closure of $S$
is the full relation. Suppose first that for every $e\in{\mathbb A}$ the set
$R^{-1}_{cd}[e]=\{d\mid (d,e)\inR\}$ (which is a
subalgebra of ${\mathbb A}$) does not equal ${\mathbb A}$. There are $\vc ek\in{\mathbb A}$
such that the subalgebras $\vc{\mathbb B} k$, ${\mathbb B}_i=R^{-1}_{cd}[e_i]$
are such that $c\in {\mathbb B}_1$, $d\in{\mathbb B}_k$, and
${\mathbb B}_i\cap{\mathbb B}_{i+1}\ne\eps$ for every $i\in[k-1]$.
Choose $d_i\in{\mathbb B}_i\cap{\mathbb B}_{i+1}$ for $i\in[k-1]$ and note that
$(d_i,d_{i+1})\inS$ and also $(c,d_1),(d_{k-1},d)\inS$.
By Lemma~\ref{lem:going-maximal} it is possible to choose
$\vc{d'}k\in{\mathbb A}$ such that $(a,d'_1)\inS$,
$(d'_i,d'_{i+1})\inS$ for $i\in[k-1]$, all the $d'_i$ are maximal, and
$d\sqq d'=d'_k$.
The conditions $(a,d'_1)\inS$, $(d'_i,d'_{i+1})\inS$ mean
that there are $e'_0\vc{e'}k\in{\mathbb A}$ such that
$d'_i,d'_{i+1}\inR^{-1}[e'_i]$ for $i\in\{2,\ldots, k\}$ and
$a,d'_1\inR^{-1}[e'_1]$. Therefore elements $c,d'$ are connected
by proper subalgebras of ${\mathbb A}$.
Suppose that there is $e\in{\mathbb A}$ such that ${\mathbb A}\tm\{e\}\sseR$.
If $e\not\in\max({\mathbb A})$, choose $e'\in\max({\mathbb A})$ with $e\sqq e'$.
By Corollary~\ref{cor:product-path} the path from $e$ to $e'$ can
be extended to a path from $(c,e),(d,e)$ to some $(c',e'),(e',d')$
respectively. Then, as $c\sqq c'$ and $c\in\max({\mathbb A})$, we also have
$c'\sqq c$. The path from $c'$ to $c$ can again be extended to
a path from $(c',e')$ to $(c,e'')$ for some $e''$. Also, the path from
$e'$ to $e''$ can be extended to a path from $(d',e')$ to $(d'',e'')$.
As is easily seen, $d''\in\se d$ and $e''$ is maximal.
Since ${\mathbb A}=\Sg{c,d''}$, we have
${\mathbb A}\tm\{e''\}\sseR$. Thus, $e$ can be assumed maximal.
We have therefore $(c,d),(c,e),(d,e),(d,c)\inR$. If both
$\Sg{d,e}$ and $\Sg{e,c}$ are proper subalgebras of ${\mathbb A}$,
then $c,d$ are connected by proper subalgebras of ${\mathbb A}$. Otherwise
suppose $\Sg{d,e}={\mathbb A}$. This means $\{c\}\tm{\mathbb A}\sseR$, and,
in particular, $(c,c)\inR_{cd}$. Therefore there is a binary term
operation $f$ such that $f(c,d)=f(d,c)=c$. This means $d\le c$
or $c\le d$, where the latter case is possible if there is also
another semilattice operation $f'$ on $\{c,d\}$ with $f'(c,d)=f'(d,c)=d$,
and this operation is picked for the relation $\le$.
If $\Sg{c,e}={\mathbb A}$ then by a similar argument we get $c\le d$ or $d\le c$.
\smallskip
From now on we assume ${\mathbb A}$ and $a,b$ to satisfy all the conditions of
Claims~1--3. Let $R=R_{ab}$.
We consider two cases.
\smallskip
{\sc Case 1.}
$R$ is not the graph of a mapping.
\smallskip
By Claim~4 there are two options. If $a\le b$ or $b\le a$, then,
since both elements are maximal, $b\in\see{\mathbb A} a$, implying they
are asm-connected. Therefore suppose that $a,b$ are asm-connected by
proper subalgebras.
There are proper subalgebras $\vc{\mathbb B} k$ of ${\mathbb A}$ such that $a\in {\mathbb B}_1$,
$b\in{\mathbb B}_k$, and ${\mathbb B}_i\cap{\mathbb B}_{i+1}\cap\max({\mathbb A})\ne\eps$ for every
$i\in[k-1]$. Let
$d_i\in B_i\cap B_{i+1}$ be an element maximal in ${\mathbb A}$.
For each $i\in[k-1]$ choose $c_i,c'_i\in\max({\mathbb B}_i)$ with
$d_{i-1}\sqq_{{\mathbb B}_i} c_i$ and $d_i\sqq_{{\mathbb B}_i} c'_i$. By the induction
hypothesis $c_i$ is asm-connected to $c'_i$ (in ${\mathbb B}_i$). Then clearly
$d_{i-1}$ is asm-connected to $c_i$, and, as $d_i$ is maximal in ${\mathbb A}$ and
$c'_i\in\see{\mathbb A}{d_i}$, $c'_i$ is asm-connected to $d_i$, as well.
\smallskip
{\sc Case 2.}
$R$ is the graph of a mapping, or, in other words, there is an
automorphism of ${\mathbb A}$ that maps $a$ to $b$ and $b$ to $a$.
\smallskip
We again consider several cases.
\smallskip
{\sc Subcase 2a.}
There is no nonmaximal element $c\le a'$ or $c\le b'$ for any
$a'\in\see{\mathbb A} a$, $b'\in\see{\mathbb A} b$. In other words, whenever $c\sqq a$
or $c\sqq b$, we have $c\in\see{\mathbb A} a$ or $c\in\see{\mathbb A} b$.
\smallskip
If there is a maximal $d$ such that $d'\le d$ for some nonmaximal
$d'\in{\mathbb A}$ (that is, ${\mathbb A}\ne\max({\mathbb A})$), then by Case~1 and
Subcases~2b, 2c $a$ is asm-connected to $d$ and $d$ is
asm-connected to $b$. Suppose all elements in ${\mathbb A}$ are maximal.
By Theorem~\ref{the:connectedness} there are
$a=a_1,a_2,\ldots, a_k=b$ such that for any $i\in[k-1]$ the pair
$a_ia_{i+1}$ or $a_{i+1}a_i$ is a semilattice, affine or majority
edge (not a thin edge). We need to show that
$a_i$ is asm-connected
to $a_{i+1}$. Let $\th$ be a congruence of ${\mathbb B}=\Sg{a_i,a_{i+1}}$
witnessing that $a_ia_{i+1}$ or $a_{i+1}a_i$ is a semilattice, affine,
or majority edge. Except for the case when $a_{i+1}a_i$ is a
semilattice edge, by Lemma~\ref{lem:thin-semilattice} there is
$b\in {\mathbb C}=a_{i+1}\fac\th$ such that $a_ib$ is a
thin edge. Then take $c,d\in\max({\mathbb C})$ such that $b\sqq_{\mathbb C} c$
and $a_{i+1}\sqq_{\mathbb C} d$. By the induction hypothesis $c$ is
asm-connected to $d$ in ${\mathbb C}$. Finally, as all elements in ${\mathbb A}$ are
maximal, $d$ is asm-connected with $a_{i+1}$ in ${\mathbb A}$ with a
semilattice path. If $a_{i+1}a_i$ is a semilattice edge, by
Lemma~\ref{lem:thin-semilattice} there is $b\in{\mathbb D}=a_i\fac\th$ such
that $a_{i+1}\le b$. Since $b\in\see{\mathbb A}{a_{i+1}}$, there is a
semilattice path from $b$ to $a_{i+1}$. Then again we choose
$c,d\in\max({\mathbb C})$ with $b\sqq_{\mathbb C} c$ and $a_i\sqq_{\mathbb C} d$.
By the induction hypothesis $d$ is asm-connected to $c$.
Since $a_i\sqq_{\mathbb C} d$ and $c\in\see{\mathbb A} b$, element $a_i$ is
asm-connected to $a_{i+1}$. Subcase~2a is thus completed.
\smallskip
{\sc Claim 5.}
Let $c\le b$, $c\not\in\max({\mathbb A})$, and $\Sg{a,c}={\mathbb A}$. Then either
$a$ and $b'$ for some $b'\in\see{\mathbb A} b$ are connected by proper
subalgebras, or $a$ is asm-connected to an element $d$ such that
$c\sqq d$, or $c\le a$.
\smallskip
Consider the relation $R=R_{ac}$, that is, the binary relation
generated by $(a,c)$ and $(c,a)$. Since $a$ is maximal and $c$
is not, there is no automorphism ${\mathbb A}$ that swaps $a$ and $c$.
Therefore ${\sf tol}_1(R)$ is a nontrivial tolerance, in particular,
$(a,b)$ is in its transitive closure. If $R^{-1}[e]={\mathbb A}$ for no $e\in{\mathbb A}$,
by Corollary~\ref{cor:going-maximal} $a$ and $b'$ for some
$b'\in\see{\mathbb A} b$ are connected by proper subalgebras. So, suppose
there is $e\in{\mathbb A}$ such that ${\mathbb A}\tm\{e\}\sseR$.
By Corollary~\ref{cor:product-path} there are $a'\in\see{\mathbb A} a$ and
$e''\in\max({\mathbb A})$ such that $(a',e')\inR$ and $(a,e)\sqq(a',e'')$ in $R$.
Again by Corollary~\ref{cor:product-path} there is $e'\in\max({\mathbb A})$
such that $(a,e')\inR$ and $(a,e)\sqq(a',e'')\sqq(a,e')$ in $R$. Let
$(a,e)=(a_1,e_1)\le\dots\le(a_k,e_k)=(a,e')$ in $R$. Consider three
sequences: $a=a'_1,\ldots, a'_k$, $c=c_1,\ldots, c_k$, and
$c=c'_1,\ldots, c'_k$ given by
\[
a'_{i+1}=a'_i\cdot e_{i+1},\qquad c_{i+1}=c_i\cdot a_{i+1},
\qquad c'_{i+1}=c'_i\cdot e_{i+1} \qquad \text{for $i\in[k-1]$}.
\]
Then, since $(a,c),(c,e),(c,a)\inR$, we have
$(a_1,c'_1),(c_1,e_1),(c_1,a'_1)\inR$, and
\begin{align*}
& \cl{a_{i+1}}{c'_{i+1}}=\cl{a_i}{c'_i}\cdot\cl{a_{i+1}}{e_{i+1}},
\qquad
\cl{c_{i+1}}{e_{i+1}}=\cl{c_i}{e_i}\cdot\cl{a_{i+1}}{e_{i+1}},\\
& \cl{c_{i+1}}{a'_{i+1}}=\cl{c_i}{a'_i}\cdot\cl{a_{i+1}}{e_{i+1}}
\qquad \text{for $i\in[k-1]$}
\end{align*}
implies that $(a,c^*),(a,e'),(c',e'),(c',a')\inR$, where $c'=c_k$, $c^*=c'_k$,
$e'=e_k$, and $a'=a'_k$.
We consider several cases. First, suppose that ${\mathbb B}=\Sg{a,c'}\ne{\mathbb A}$.
Then let $a'',c''\in\max({\mathbb B})$ be such that $a\sqq_{\mathbb B} a''$,
$c'\sqq_{\mathbb B} c''$. By the induction hypothesis $a''$ is asm-connected
to $c''$, and, hence, $a$ is asm-connected to $c''$. Since $c\sqq c''$,
take $c''$ for $d$ and the result follows.
Suppose $\Sg{a,c'}={\mathbb A}$. Then $(c,e')\inR$, as $(a,e'),(c',e')\inR$.
Therefore $(a,c^*),(a,e'),(c,e'),(c,a)\inR$.
If both ${\mathbb B}_1=\Sg{a,e'}$ and
${\mathbb B}_2=\Sg{e',c^*}$ are not equal to ${\mathbb A}$, then we choose
$a'', e''\in\max({\mathbb B}_1)$ and
$e^\dagger,c^\dagger\in\max({\mathbb B}_2)$ such that
$a\sqq_{{\mathbb B}_1}a''$, $e'\sqq_{{\mathbb B}_1}e''$,
$e'\sqq_{{\mathbb B}_2}e^\dagger$, and $c^*\sqq_{{\mathbb B}_2}c^\dagger$.
Then the following holds: $a$ is asm-connected to $a''$ as
$a\sqq_{{\mathbb B}_1}a''$; $a''$ is asm-connected to $e''$ by the
induction hypothesis; $e''\sqq_{\mathbb A} e'$, because $e'\in\max({\mathbb A})$
and $e''\in\see{\mathbb A}{e'}$; $e'$ is asm-connected to $e^\dagger$, as
$e'\sqq_{{\mathbb B}_2}e^\dagger$; and $e^\dagger$ is asm-connected
to $c^\dagger$ by the induction hypothesis. Finally, as
$c\sqq c^*\sqq c^\dagger$, taking $c^\dagger$ for $d$,
the result holds in this case as well.
Suppose $\Sg{a,e'}={\mathbb A}$ or $\Sg{e',c^*}={\mathbb A}$. Then
$(c,c)\inR$ or $(a,a)\inR$, which means there is a
binary operation $f$ such that $f(a,c)=f(c,a)=c$ or
$f(a,c)=f(c,a)=a$, implying $ac$ is a thin semilattice edge.
Since $c$ is not maximal, we have $c\le a$, the result follows.
\smallskip
Elements $a,b$ are said to be \emph{v-connected} if there is
$c\in\Sg{a,b}$ such that $c\sqq a$ and $c\sqq b$.
\smallskip
{\sc Case 2b.}
Elements $a,b$ are v-connected.
\smallskip
Recall that there is an automorphism of ${\mathbb A}$ that swaps $a$ and $b$.
Let $c\sqq d$ for some elements $c,d$. The \emph{s-distance}
from $c$ to $d$ is the length of the shortest semilattice path from
$c$ to $d$. The s-distance from $c$ to $\see{\mathbb A} d$ is the shortest
s-distance from $c$ to an element from $\see{\mathbb A} d$. The
\emph{depth} of an element $c$ is the greatest
s-distance to a maximal component, denoted $\mathsf{dep}(c)$. We proceed
by induction on the size of $\Sg{a,b}$ and minimal $\mathsf{dep}(c)$,
such that $c\sqq a$, $c\sqq b$.
Suppose first that $c\le a'\in\see{\mathbb A} a$, $c\le b'\in\see{\mathbb A} b$. In particular,
this happens when $\mathsf{dep}(c)=1$. We may assume that there is
an automorphism swapping $a'$ and $b'$, since otherwise we are
in the conditions of Case~1. Also, $a,a'$ are in the same
maximal component and thus connected to each other by an s-path.
The same holds for $b,b'$. Therefore, we can assume $a'=a,b'=b$.
As $c\in\Sg{a,b}$, there is a binary
term operation $f$ such that $f(a,b)=c$. Let $d=f(b,a)$. Since there
is an automorphism swapping $a$ and $b$, $d\le a$ and $d\le b$.
Set $g(x,y,z)=(f(y,x)\cdot f(y,z))\cdot f(x,z)$. We have
\begin{eqnarray*}
g(a,a,b) &=& (ac)c=a,\\
g(a,b,a) &=& (dd)a=a,\\
g(b,a,a) &=& (ca)d=a.
\end{eqnarray*}
Since $a$ and $b$ are automorphic, $g$ is a majority operation on
$\{a,b\}$. Therefore, $ab$ is not only a thin majority edge,
but also a majority edge, as is witnessed by the equality relation.
Since ${\mathbb A}$ is smooth, $\Sg{a,b}=\{a,b\}$, and this case is in fact
impossible.
Suppose the result is proved for all algebras and pairs of elements
v-connected through an element of depth less than $\mathsf{dep}(c)$. Let
$c=a_1\le a_2\le\dots\le a_k=a$ and $c=b_1\le b_2\le\ldots\le b_m=b$,
and $k>2$ or $m>2$. We may assume $m>2$ and $b_{m-1}$ to be a
nonmaximal element. Note that $\mathsf{dep}(b_{m-1})<\mathsf{dep}(c)$, because
$b_{m-1}$ is on an s-path from $c$ to a maximal element.
Consider ${\mathbb B}=\Sg{a,b_{m-1}}$. If ${\mathbb B}={\mathbb A}$ then by Claim~5
either $a,b'$ are connected by proper subalgebras of ${\mathbb A}$ for
some $b'\in\see{\mathbb A} b$, or $a$ is asm-connected to an element $d$
such that $b_{m-1}\sqq_{\mathbb A} d$. In the former case we use the
inductive hypothesis on the size of ${\mathbb A}$ and complete as in Case~1.
In the latter case, as $\mathsf{dep}(b_{m-1})<\mathsf{dep}(c)$ and $d,b$ are
v-connected through $b_{m-1}$, we use the inductive
hypothesis on the depth of an element through which $a$ and $b$
are v-connected. In either case $a$ and $b$ are asm-connected.
Suppose $B\ne{\mathbb A}$. Let $d\in\max({\mathbb B})$ be such that
$b_{m-1}\sqq_{\mathbb B} d$, let also $e\in\max({\mathbb A})$ be such that
$d\sqq_{\mathbb A} e$. By the induction hypothesis $a$ is asm-connected to
$d$ in ${\mathbb B}$, and therefore to $e$ in ${\mathbb A}$. Also, $e$
and $b$ are v-connected through $b_{m-1}$. If
$\Sg{e,b}={\mathbb C}\ne{\mathbb A}$, we choose $e',b'\in\max({\mathbb C})$ and such that
$e\sqq_{\mathbb C} e'$, $b\sqq_{\mathbb C} b'$. By the induction hypothesis
$e',b'$ are asm-connected in ${\mathbb C}$, which implies $e,b$ are
asm-connected in ${\mathbb A}$. If $\Sg{e,b}={\mathbb A}$, the result follows
by the induction hypothesis, since $\mathsf{dep}(b_{m-1})<\mathsf{dep}(c)$.
\smallskip
{\sc Subcase 2c.}
Elements $a,b$ are not v-connected
\smallskip
Note first that we may assume that, for any $b'\in\see{\mathbb A} b$, there is an
automorphism that sends $b'$ to $a$ and $a$ to $b'$, as otherwise we
are in the conditions of Case~1. Recall that we also assume
$\Sg{a,b'}={\mathbb A}$. Because of this and the automorphism swapping $a$
and $b$, without loss of generality we may assume that there is
nonmaximal $c\le b$. Consider $\Sg{a,c}$.
If $\Sg{a,c}={\mathbb A}$, by Claim~5 either $a,b'$ are connected by proper
subalgebras of ${\mathbb A}$ for some $b'\in\see{\mathbb A} b$ or $a$ is asm-connected
to $d$ such that $d$ is v-connected with $b$. In either case we
proceed by the induction hypothesis as before.
If ${\mathbb B}=\Sg{a,c}\ne{\mathbb A}$, take $d\in\max({\mathbb B})$ and such that
$c\sqq d$. By the induction hypothesis $a$ is asm-connected to $d$.
Now let $d\sqq d'$ such that $d'\in\max({\mathbb A})$. Since $d'$ is
v-connected to $b$, the result now follows from Case~2b.
\medskip
In the remaining statements of the theorem, when $a,b\in\mathsf{amax}({\mathbb A})$ or
$a,b\in\mathsf{umax}({\mathbb A})$, we let $a',b'\in{\mathbb A}$ be maximal elements of
${\mathbb A}$ such that $a\sqq a'$ and $b\sqq b'$. Then by what is proved
above $a'$ is asm-connected to $b'$, and so $a$ is asm-connected to $b'$.
Finally, as $b'\in\mathsf{as}(b)$ [respectively, $b'\in\mathsf{umax}({\mathbb A})$],
we have $b'\sqq_{as}b$ [respectively, $b'\sqq_{asm}b$], and
$b'$ is connected to $b$. Note that in the case of u-maximal elements
the path showing that $b'\sqq_{asm}b$ cannot be assumed special.
\end{proof}
As by Theorem~\ref{the:connectivity} any u-maximal elements
are connected by an asm-path, we have the following
\begin{corollary}\label{cor:unique-umax}
If ${\mathbb A}$ is a smooth algebra, there is a unique u-maximal component.
\end{corollary}
\section{Rectangularity}\label{sec:rectangularity}
In this section we prove a result that, on one hand, is a
generalization of the results by the author
\cite{Bulatov06:semilattice} (Lemma~3.5), \cite{Bulatov11:conservative}
(Lemma~4.2, Proposition~5.4), and, on the other
hand, is analogous to the Rectangularity Lemma from \cite{Barto12:absorbing}.
We will need two auxiliary lemmas.
\begin{lemma}\label{lem:as-rectangularity}
Let $R$ be a subalgebra of ${\mathbb A}_1\tm{\mathbb A}_2$ and let $a\in{\mathbb A}_1$
and $B=R[a]$. For any $b\in{\mathbb A}_1$ such that $ab$ is thin edge,
and any $c\inR[b]\cap B$, $\mathrm{Ft}^{as}_B(c)\sseR[b]$.
\end{lemma}
\begin{proof}
Let $D=\mathrm{Ft}^{as}_B(c)\capR[b]$. Set $D$ is nonempty, as
$c\in D$. If $D\ne \mathrm{Ft}^{as}_B(c)$, there are $b_1\in D$
and $b_2\in\mathrm{Ft}^{as}_B(c)-D$ such that $b_1b_2$ is a thin semilattice
or affine edge. Suppose that $ab$ is semilattice or majority. Then by
Lemma~\ref{lem:thin-combination}(3) there is a term operation $p$
such that $p(a,b)=b$ and $p(b_2,b_1)=b_2$ (if both $ab$ and $b_1b_2$
are of the semilattice type then $p$ can be chosen to be $\cdot$). Then
\[
\cl b{b_2}=p\left(\cl a{b_2},\cl b{b_1}\right)\inR.
\]
If $ab$ is affine, then by Lemma~\ref{lem:thin-combination}(2)
there is a term operations $h'$ such that $h'(a,a,b)=b$ and
$h'(b_2,b_1,b_1)=b_2$. Then
\[
\cl b{b_2}=h'\left(\cl a{b_2},\cl a{b_1},\cl b{b_1}\right)\inR.
\]
The result follows.
\end{proof}
\begin{lemma}\label{lem:buket}
Let $R$ be a subdirect product of algebras ${\mathbb A}_1,{\mathbb A}_2$, let
$B_1,B_2$ be as-components (maximal components)
of ${\mathbb A}_1,{\mathbb A}_2$, respectively, and $a\in{\mathbb A}_1$ such that
$R\cap(B_1\tm B_2)\ne\eps$
and $\{a\}\tm B_2\sseR$. Then $B_1\tm B_2\sseR$.
\end{lemma}
\begin{proof}
We prove the lemma for as-components; for maximal components
the proof is nearly identical.
Let $(b,c)\inR\cap(B_1\tm B_2)\ne\eps$. For every
$b'\in{\mathbb A}'_1=\Sg{a,b}$ we have
$(b',c)\inR$. By Lemma~\ref{lem:as-rectangularity} this means that
$\{b'\}\tm B_2\sseR$ for all $b'\in\mathrm{Ft}^{asm}_{{\mathbb A}_1}(a)$. Indeed,
let $C$ be the set of all elements $b'$ from $\mathrm{Ft}^{asm}_{{\mathbb A}_1}(a)$
such that $\{b'\}\tm B_2\sseR$. Set $C$ is nonempty, as $a\in C$.
If $C\ne\mathrm{Ft}^{asm}_{{\mathbb A}_1}(a)$, there are $b'\in C$ and
$b''\in\mathrm{Ft}^{asm}_{{\mathbb A}_1}(a)-C$ such that $b'b''$ is a thin edge. Then
by Lemma~\ref{lem:as-rectangularity} $\mathrm{Ft}^{as}_{R[b']}(c)\sseR[b'']$.
Since $B_2\sse\mathrm{Ft}^{as}_{R[b']}(c)$, we have a contradiction.
To complete the proof it suffices to observe that there is
an as-path from $a$ to, first, some as-maximal element $a'$, and
then, since every element $b'\in B_1$ is as-maximal, by
Theorem~\ref{the:connectivity} there is an asm-path from $a'$ to $b'$.
Therefore $B_1\sse \mathrm{Ft}^{asm}_{{\mathbb A}_1}(a)$.
\end{proof}
\begin{prop}\label{pro:max-gen}
Let $R\le{\mathbb A}_1\tm {\mathbb A}_2$ be a linked subdirect product and let
$B_1,B_2$ be as-components of ${\mathbb A}_1,{\mathbb A}_2$, respectively, such that
$R\cap(B_1\tm B_2)\ne\eps$. Then $B_1\tm B_2\sseR$.
\end{prop}
\begin{proof}
We prove by induction on the size of ${\mathbb A}_1,{\mathbb A}_2$ that for any
as-components $C_1,C_2$ of ${\mathbb A}_1,{\mathbb A}_2$, respectively, there are
$a_1\in{\mathbb A}_1$, $a_2\in{\mathbb A}_2$
such that $\{a_1\}\tm C_2\sseR$ or $C_1\tm\{a_2\}\sseR$.
The result then follows by Lemma~\ref{lem:buket}. The base
case of induction when $|{\mathbb A}_1|=1$ or $|{\mathbb A}_2|=1$ is obvious.
Take $b\in C_1$ and construct two sequences
of subalgebras $\vc{\mathbb B} k$ of ${\mathbb A}_1$ and $\vc{\mathbb C} k$ of ${\mathbb A}_2$, where
${\mathbb B}_1=\{b\}$, ${\mathbb C}_i=R[{\mathbb B}_i]$, and ${\mathbb B}_i=R^{-1}[{\mathbb C}_{i-1}]$,
such that $k$ is the minimal number with ${\mathbb B}_k={\mathbb A}_1$ or
${\mathbb C}_k={\mathbb A}_2$. Such a number exists, because $R$ is linked. Observe
that for each $i\le k$ the relation $R_i=R\cap({\mathbb B}_i\tm{\mathbb C}_i)$ is linked.
Therefore, there is a proper subalgebra ${\mathbb A}'_1$ of ${\mathbb A}_1$ or ${\mathbb A}'_2$
of ${\mathbb A}_2$ such that $R'=R\cap({\mathbb A}'_1\tm{\mathbb A}_2)$ or
$R'=R\cap({\mathbb A}_1\tm{\mathbb A}'_2)$, respectively, is linked and subdirect.
Without loss of generality suppose there is ${\mathbb A}'_1$ with the required
properties. By the induction hypothesis for any as-component $C_2$
of ${\mathbb A}_2$ there is $a_1\in{\mathbb A}'_1\sse{\mathbb A}_1$ with
$\{a_1\}\tm C_2\sseR'\sseR$.
\end{proof}
\begin{corollary}\label{cor:linkage-rectangularity}
Let $R$ be a subdirect product of ${\mathbb A}_1$ and ${\mathbb A}_2$,
${\sf lk}_1,{\sf lk}_2$ the link congruences, and let $B_1,B_2$ be
as-components of an ${\sf lk}_1$-block and an ${\sf lk}_2$-block, respectively,
such that $R\cap(B_1\tm B_2)\ne\eps$. Then $B_1\tm B_2\sseR$.
\end{corollary}
\begin{proof}
Let $C_1,C_2$ be the ${\sf lk}_1$- and ${\sf lk}_2$-blocks containing $B_1$
and $B_2$, respectively, and $Q=(C_1\tm C_2)\capR$. By definition
$Q$ is a subdirect product of $C_1\tm C_2$, as $R$ is subdirect,
and $Q$ is linked. The result follows by Proposition~\ref{pro:max-gen}.
\end{proof}
\begin{prop}\label{pro:umax-rectangular}
Let $R$ be a subdirect product of ${\mathbb A}_1$ and ${\mathbb A}_2$,
${\sf lk}_1,{\sf lk}_2$ the link
congruences, and let $B_1$ be an as-component of an ${\sf lk}_1$-block and
$B'_2=R[B_1]$; let $B_2=\mathsf{umax}(B'_2)$. Then $B_1\tm B_2\sseR$.
\end{prop}
\begin{proof}
Let $B'_2$ be a subset of a ${\sf lk}_2$-block $C$. By
Corollary~\ref{cor:product-maximal}(1) $B'_2$ contains an as-maximal
element $a$ of $C$. By Corollary~\ref{cor:linkage-rectangularity}
$B_1\tm\{a\}\sseR$. It then suffices to show that
$B_1\tm\mathrm{Ft}^{asm}_{B'_2}(a)\sseR$.
Suppose for $D\sse\mathrm{Ft}^{asm}_{B'_2}(a)$ it holds $B_1\tm D\sseR$.
If $D\ne \mathrm{Ft}^{asm}_{B'_2}(a)$, there are $b_1\in D$ and
$b_2\in\mathrm{Ft}^{asm}_{B'_2}(a)-D$ such that $b_1b_2$ is a thin edge.
By Lemma~\ref{lem:as-rectangularity} $B_1\tm\{b_2\}\sseR$; the
result follows.
\end{proof}
\section{Quasi-2-decomposability}\label{sec:quasi-2-decomposability}
An ($n$-ary) relation over a set $A$ is called
\emph{2-decomposable} if, for any tuple ${\bf a}\in A^n$, ${\bf a}\inR$ if
and only if, for any $i,j\in[n]$, ${\rm pr}_{ij}{\bf a}\in{\rm pr}_{ij}R$
\cite{Baker75:chinese-remainder,Jeavons98:consist}. 2-decomposability
is closely related to
the existence of majority polymorphisms of the relation.
Relations over general smooth algebras do not have a majority
polymorphism, but they
still have a property close to 2-decomposability. We say that a
relation $R$, a subdirect product of $\vc{{\mathbb A}}n$, is
\emph{quasi-2-decomposable}, if for any elements $\vc an$,
such that $(a_i,a_j)\in\mathsf{amax}({\rm pr}_{ij}R)$ for any
$i,j$, there is a tuple ${\bf b}\inR$ with $({\bf b}[i],{\bf b}[j])\in\mathsf{as}{(a_i,a_j)}$
for all $i,j\in[n]$.
\begin{theorem}\label{the:quasi-2-decomp}
Let $\vc{\mathbb A} n$ be similar smooth algebras. Then any subalgebra $R$ of
$\tms{\mathbb A} n$ is quasi-2-decomposable.
Moreover, if $X\sse[n]$, tuple ${\bf a}$ is such that
$({\bf a}[i],{\bf a}[j])\in\mathsf{amax}({\rm pr}_{i,j}R)$ for any $i,j$, and ${\rm pr}_X{\bf a}
\in\mathsf{amax}({\rm pr}_XR)$, there is a tuple ${\bf b}\inR$ with
$({\bf b}[i],{\bf b}[j])\in\mathsf{as}{({\bf a}[i],{\bf a}[j])}$ for any $i,j\in[n]$, and
${\rm pr}_X{\bf b}={\rm pr}_X{\bf a}$.
\end{theorem}
\subsection{Auxiliary lemmas}
We start with ternary relations.
\begin{lemma}\label{lem:3-quasi}
Let $R$ be a subdirect product of ${\mathbb A}_1\tm{\mathbb A}_2\tm{\mathbb A}_3$, and let
$(a_1,a_2,a_3)$ be such that $(a_i,a_j)\in\mathsf{amax}({\rm pr}_{ij}R)$ for
$i,j\in\{1,2,3\}$, $i\ne j$. Then there is $(a'_1,a'_2,a'_3)\inR$ such that
$(a'_i,a'_j)$ is in the as-component of ${\rm pr}_{ij}R$ containing $(a_i,a_j)$ for
$i,j\in\{1,2,3\}$, $i\ne j$.
\end{lemma}
\begin{proof}
We proceed by induction on the size of ${\mathbb A}_1,{\mathbb A}_2,{\mathbb A}_3$. The base case
of induction is when for each $i\in[3]$ either $|{\mathbb A}_i|=2$ and ${\mathbb A}_i$ is a
semilattice or a majority edge, or ${\mathbb A}_i$ is a module (not necessarily
2-element). By the assumption
some tuples ${\bf a}_1=(b_1,a_2,a_3)$, ${\bf a}_2=(a_1,b_2,a_3)$,
${\bf a}_3=(a_1,a_2,b_3)$ belong to $R$. If one of ${\mathbb A}_1,{\mathbb A}_2,{\mathbb A}_3$
is a semilattice edge, say, $b_1\le a_1$, then from the as-maximality of
$a_1,a_2,a_3$, we obtain $(a_1,a_2,a_3)={\bf a}_1\cdot{\bf a}_2\inR$. If one
of ${\mathbb A}_1,{\mathbb A}_2,{\mathbb A}_3$ is a module, say, ${\mathbb A}_1$ is, then ${\bf a}_1$ satisfies
the requirements of the lemma. Finally, if all ${\mathbb A}_1,{\mathbb A}_2,{\mathbb A}_3$ are
majority edges, then $(a_1,a_2,a_3)=g({\bf a}_1,{\bf a}_2,{\bf a}_3)$, where $g$ is
the operation from Theorem~\ref{the:uniform}. Note that
if one of the ${\mathbb A}_i$ has a unique maximal element (an absorbing element,
for example), the statement also holds, $b_i\sqq a_i$ in this case, and
we can apply Corollary~\ref{cor:product-maximal}(1).
Suppose that the lemma is proved for any subdirect product of
${\mathbb A}'_1\tm{\mathbb A}'_2\tm{\mathbb A}'_3$, where ${\mathbb A}'_i$ is a subalgebra or a factor
of ${\mathbb A}_i$, $i\in[3]$, and at least one of them is a proper subalgebra
or a factor. Let ${\bf a}_1,{\bf a}_2,{\bf a}_3\inR$ be as before. Also let ${\mathcal D}$
denote the set of $(c_1,c_2,c_3)\in{\mathbb A}_1\tm{\mathbb A}_2\tm{\mathbb A}_3$ such that
$(c_i,c_j)$, $i,j\in[3]$ belongs to the as-component of ${\rm pr}_{ij}R$
containing $(a_i,a_j)$, for $i\ne j$. Set ${\mathcal D}$ is nonempty, as
${\bf a}=(a_1,a_2,a_3)\in{\mathcal D}$.
\smallskip
{\sc Claim 1.}
Every ${\mathbb A}_i$ can be assumed to be $\Sg{a_i,b_i}$ and $b_i$ can be
chosen to be an as-maximal element.
\smallskip
Suppose ${\mathbb A}_1\ne{\mathbb B}=\Sg{a_1,b_1}$. Let $(a'_1,a'_2)$ be an
as-maximal element in $Q=({\mathbb B}\tm{\mathbb A}_2)\cap{\rm pr}_{12}R $ such
that $(a_1,a_2)\sqq_{as} (a'_1,a'_2)$ in $Q$. Let also
$(a_1,a_2)=(c^1_1,c^1_2),\ldots,(c^k_1,c^k_2)=(a'_1,a'_2)$ be an
as-path from $(a_1,a_2)$ to $(a'_1,a'_2)$ in $Q$. By
Corollary~\ref{cor:product-path}(1) it can be extended to an as-path
${\bf c}_1,\ldots,{\bf c}_k\inR$ with ${\bf c}_1=(a_1,a_2,b_3)$ in
$R'=({\mathbb B}\tm{\mathbb A}_2\tm{\mathbb A}_3)\capR$. Using
Lemma~\ref{lem:product-edge}(1) we
define a sequence $\vc{{\bf c}'}k$ in ${\mathcal D}$ as follows: ${\bf c}'_1={\bf a}$, and
${\bf c}'_{i+1}$ is such that
$({\bf c}'_{i+1}[1],{\bf c}'_{i+1}[2])=(c^{i+1}_1,c^{i+1}_2)$ and
${\bf c}'_i{\bf c}'_{i+1}$ is a thin semilattice or affine edge in
$\Sgg{{\mathbb A}_1\tm{\mathbb A}_2\tm{\mathbb A}_3}{{\bf c}'_i,{\bf c}_{i+1}}$. Note that
$({\bf c}'_i[u],{\bf c}'_i[v])({\bf c}'_{i+1}[u],{\bf c}'_{i+1}[v])$ is a thin edge of
the same type as ${\bf c}'_i{\bf c}'_{i+1}$ for $u,v\in[3]$. In particular,
$(a_u,a_v)\sqq_{as}({\bf c}'_{i+1}[u],{\bf c}'_{i+1}[v])$ in ${\rm pr}_{uv}R'$.
Replace ${\bf a}$ with ${\bf c}'_k$. Repeating the process for the other binary
projections if necessary we obtain $(a'_1,a'_2,a'_3)\in{\mathcal D}$ such
that $(a'_i,a'_j)$ is as-maximal in ${\rm pr}_{ij}R'$. By the induction
hypothesis there is
$(a''_1,a''_2,a''_3)\inR\cap({\mathbb B}\tm{\mathbb A}_2\tm{\mathbb A}_3)$
such that $(a''_i,a''_j)$ is in the as-maximal component containing
$(a'_i,a'_j)$. Clearly, $(a''_1,a''_2,a''_3)$ is as required.
If, say, $b_1$ is not an as-maximal element, then choose an as-path
$b_1=c_1\le\dots c_k$ and its extension ${\bf c}_1,\ldots,{\bf c}_k\inR$, ${\bf c}_1={\bf a}_1$,
such that $c_k$ is a maximal element.
Then we choose an as-path in ${\rm pr}_{23}R$
from $(a'_2,a'_3)$ to $(a_2,a_3)$. Extending this path as before
we get $(d,a_2,a_3)\inR$ such that $d\in\mathsf{amax}({\mathbb A}_1)$.
\smallskip
{\sc Claim 2.}
For every $i,j\in[3]$, $\{a_i\}\tm{\mathbb A}_j\sse{\rm pr}_{ij}R$,
$\mathsf{as}(a_i)\tm\mathsf{as}(a_j)\sse{\rm pr}_{ij}R$, and this set is an as-component
of ${\rm pr}_{ij}R$.
\smallskip
Since $(a_i,a_j),(a_i,b_j)\in{\rm pr}_{ij}R$ and ${\mathbb A}_j=\Sg{a_j,b_j}$,
we have $\{a_i\}\tm{\mathbb A}_j\sse{\rm pr}_{ij}R$. By Lemma~\ref{lem:buket}
$\mathsf{as}(a_i)\tm\mathsf{as}(a_j)\sse{\rm pr}_{ij}R$ and the first and the second
statements of the claim follows. The third statement is obvious.
\smallskip
{\sc Claim 3.}
Every ${\mathbb A}_i$ can be assumed simple.
\smallskip
Suppose $\th$ is a nontrivial congruence of ${\mathbb A}_1$ and
$R\fac\th=\{(c_1\fac\th,c_2,c_3)\mid (c_1,c_2,c_3)\inR\}$. By the
induction hypothesis there is $(a''_1,a'_2,a'_3)\inR\fac\th$ satisfying
the conditions of the lemma, that is, there is $(b_1,a'_2,a'_3)\inR$
such that $b_1\fac\th=a''_1$, and $(a_2,a_3)\sqq_{as}(a'_2,a'_3)$,
$(a_1\fac\th,a_i)\sqq_{as}(a''_1,a'_i)$ for $i\in\{2,3\}$, where the latter
as-paths are in ${\rm pr}_{1i}R\fac\th$. Let $a'_1\in b_1\fac\th$ be any
element such that $a_1\sqq_{as} a'_1$ and $a'_1$ is maximal
in $b_1\fac\th$. Such an element exists, because
$a_1\fac\th\sqq_{as}\in b_1\fac\th$. Then for $(a'_1,a'_2,a'_3)$ we have
$(a'_i,a'_j)\in\mathsf{as}(a_i)\tm\mathsf{as}(a_j)\sse{\rm pr}_{ij}R$, for any
$i,j\in\{1,2,3\}$, where the last inclusion is by Claim~2.
Therefore $(a_i,a_j)\sqq_{as}(a'_i,a'_j)$. Since
$\Sg{a'_1,b_1}\ne{\mathbb A}_1$, the claim follows by the induction hypothesis.
\smallskip
We now prove the induction step. Suppose now that $|{\mathbb A}_i|>2$
and ${\mathbb A}_i$ is not a
module for any $i$. For an $n$-ary relation $Q\le\tms{\mathbb A} n$,
$j\in[n]$, and $c_j\in{\mathbb A}_j$, let $Q[c_j]$ denote the set
$\{(c_1,\ldots, c_{j-1},c_{j+1},\ldots, c_n)\in{\rm pr}_{\{1,\ldots, j-1,j+1,\ldots, n\}}\mid
(\vc cn)\inQ\}$. We still use the tuples ${\bf a}_1,{\bf a}_2,{\bf a}_3\inR$.
There are two cases to consider.
\smallskip
{\sc Case 1.} For some $i\in[3]$ the set $R[b_i]$ contains
$\mathsf{as}(a_j)\tm\mathsf{as}(a_\ell)$, where $\{j,\ell\}=[3]-\{i\}$.
\smallskip
Assume $i=1$. Since $a_1$ is maximal, by Theorem~\ref{the:connectivity}
there is a special asm-path $P$ from $b_1$ to $a_1$. We prove that
for any element $c$ on this path $\{c\}\tm\mathsf{as}(a_2)\tm\mathsf{as}(a_3)\sseR$.
This is true for $c=b_1$ by the assumption made. Assume the
contrary, and let $c$ be the first element in $P$ for which this
property is not true. Let also $d$ be the element preceding $c$ in
$P$; we may assume $d=b_1$. If $b_1c$ is semilattice or affine,
then by Lemma~\ref{lem:product-edge}(1)
applied to $(b_1,a_2,a_3)$ and $c$ there is ${\bf c}=(c,a'_2,a'_3)\inR$
such that $(a'_2,a'_3)\in\mathsf{as}(a_2,a_3)$. Therefore by
Lemma~\ref{lem:as-rectangularity} $\{c\}\tm\mathsf{as}(a_2)\tm\mathsf{as}(a_3)\sseR$.
Let $b_1c$ be a special thin majority edge, ${\mathbb B}=\Sg{b_1,c}$, and $\th$
a congruence witnessing that $b_1c$ a majority edge; in particular,
${\mathbb B}=b_1\fac\th\cup c\fac\th$, as ${\mathbb A}_1$ is smooth.
If ${\mathbb B}={\mathbb A}_1$ then $\th$ is the equality relation, as
${\mathbb A}_1$ is simple, and so $|{\mathbb A}_1|=2$, a contradiction with the
assumptions about ${\mathbb A}_1$. Suppose ${\mathbb B}\ne{\mathbb A}_1$.
Consider $R'=R\cap({\mathbb B}\tm{\mathbb A}_2\tm{\mathbb A}_3)$ and take any
$e\in\max({\mathbb B})\cap c\fac\th$. Such an element exists, because by
Corollary~\ref{cor:quotient-path}(2) any as-path that starts in $c\fac\th$
remains inside $c\fac\th$. For the tuple $(e,a_2,a_3)$ we have
the following. Since $(a_1,a_i),(b_1,a_i)\inR$ and
${\mathbb A}_1=\Sg{a_1,b_1}$ by Claim~1, $(e,a_i)\in{\rm pr}_{1i}R'$ for
$i\in\{2,3\}$. Also, $(a_2,a_3)\in{\rm pr}_{23}R'$, as
$(b_1,a_2,a_3)\inR$ by the assumption made. By the induction
hypothesis there is $(e',a'_2,a'_3)\inR'$ with $e'\in\mathsf{as}_{\mathbb B}(e)$
(and so $e'\in c\fac\th$) and $a'_i\in\mathsf{as}_{{\mathbb A}_i}(a_i)$, $i\in\{2,3\}$.
Let $e''=g(b_1,e',e')$, where $g$ is an operation satisfying the majority
condition and the identities from by Lemma~\ref{lem:fgh-identities}(2).
Then $g(b_1,e'',e'')=e''$. Since $b_1c$ is a minimal pair with respect
to $\th$, it holds that $c\in\Sg{b_1,e''}$. By
Lemma~\ref{lem:thin-semilattice}
$b_1e''$ is also a thin majority edge. Moreover,
\[
\cll{e''}{a'_2}{a'_3}=g\left(\cll{b_1}{a'_2}{a'_3},
\cll{e'}{a'_2}{a'_3},\cll{e'}{a'_2}{a'_3}\right)\inR'.
\]
By Lemma~\ref{lem:as-rectangularity}
\[
\mathsf{as}(a_2)\tm\mathsf{as}(a_3)\sse\mathrm{Ft}^{as}_{{\rm pr}_{23}R'}((a'_2,a'_3))
\sseR(e'').
\]
Since $\Sg{b_1,e''}=\Sg{b_1,c}$, $c=r(b_1,e'')$ for some term
operation $r$. It remains to notice that
$$
\cll c{a''_2}{a''_3}=r\left(\cll{b_1}{a''_2}{a''_3},
\cll{e''}{a''_2}{a''_3}\right)\inR'
$$
for any $a''_2\in\mathsf{as}(a_2)$, $a'' _3\in\mathsf{as}(a_3)$, a contradiction
with the choice of $c$.
\smallskip
{\sc Case 2.} For all $i\in[3]$, $\mathsf{as}(a_j)\tm\mathsf{as}(a_\ell)\not\sseR(b_i)$,
where $\{j,\ell\}=[3]-\{i\}$.
\smallskip
Let ${\sf lk}_{j\ell}$ be the link congruence of ${\rm pr}_{j\ell}R$ when
$R$ is viewed as a subdirect product of ${\mathbb A}_i$ and
${\rm pr}_{j\ell}R$; and let ${\sf lk}_i$ be the link congruence of ${\mathbb A}_i$.
Since $b_i$ is as-maximal, if ${\sf lk}_i$ is the total congruence, then
by Proposition~\ref{pro:max-gen} $\mathsf{as}(a_j)\tm\mathsf{as}(a_\ell)\sseR[b_i]$, a
contradiction with the assumption made. Therefore ${\sf lk}_i$ is the equality
relation for all $i\in[3]$. Consider the ${\sf lk}_{j\ell}$-block
$Q=R[a_i]$. By Claim~2 $Q$ is a subdirect product of
${\mathbb A}_j\tm{\mathbb A}_\ell$. If $Q$ is linked, $\mathsf{as}(b_j)\tm\mathsf{as}(a_\ell)\sseQ$.
In this case, if $|\mathsf{as}(a_i)|=1$ then $\mathsf{as}(a_i)\tm\mathsf{as}(a_\ell)\sseR[b_j]$,
a contradiction with the assumptions of Case~2. If $|\mathsf{as}(a_i)|>1$, for
any $c_i\in{\mathbb A}_i$ such that $a_ic_i$ is a thin semilattice or affine edge
by Lemma~\ref{lem:product-edge}(1)
$(c_j,c_\ell)\inR[c_i]$ for some $(c_j,c_\ell)\in\mathsf{as}(b_j)\tm\mathsf{as}(a_\ell)$,
a contradiction with the assumption that ${\sf lk}_i$ is the equality relation.
Therefore $Q$ is not linked, and, since ${\mathbb A}_2,{\mathbb A}_3$ are simple,
$Q$ is the graph of a bijection. Thus, ${\mathbb A}_j$ and ${\mathbb A}_\ell$ are
isomorphic. In a similar way ${\mathbb A}_i$ and ${\mathbb A}_j$ are isomorphic.
In particular, $|{\mathbb A}_1|=|{\mathbb A}_2|=|{\mathbb A}_3|=k$. Therefore,
${\rm pr}_{j\ell}R$ contains $k$ ${\sf lk}_{j\ell}$-blocks
of size $k$ each. This means $|{\rm pr}_{j\ell}R|=k^2$, and so
${\rm pr}_{j\ell}R={\mathbb A}_j\tm{\mathbb A}_\ell$, which is isomorphic to ${\mathbb A}_j^2$.
Congruence ${\sf lk}_{j\ell}$ is a skew congruence of the square of a
simple idempotent algebra, which does not have an absorbing
element, by Theorem~\ref{the:simple-idempotent} this implies ${\mathbb A}_j$,
and therefore all of ${\mathbb A}_1,{\mathbb A}_2,{\mathbb A}_3$ are modules, and the result
follows by the base case of induction.
\end{proof}
\subsection{Proof of Theorem~\ref{the:quasi-2-decomp}}
In this section we prove Theorem~\ref{the:quasi-2-decomp}.
\begin{proof}[Proof of Theorem~\ref{the:quasi-2-decomp}]
Let ${\bf a}$ be a tuple satisfying the conditions of
quasi-2-decom\-po\-sa\-bi\-li\-ty. By induction on ideals of the
power set of $[n]$ (i.e.\ subsets of the power set closed under
taking subsets) we prove that for any ideal $I$ there is ${\bf a}'$
such that $({\bf a}'[i],{\bf a}'[j])\in\mathsf{as}({\bf a}[i],{\bf a}[j])$ for any $i,j\in[n]$,
${\rm pr}_X{\bf a}'\in\mathsf{as}({\rm pr}_X{\bf a})$, and for any
$U\in I$ it holds ${\rm pr}_U{\bf a}'\in\mathsf{amax}({\rm pr}_UR)$. Then if this
statement is proved for the entire power set,
${\bf a}'={\rm pr}_{[n]}{\bf a}'\in{\rm pr}_{[n]}R=R$ implies the result.
The base case, where the ideal consists of all at most 2-elements
sets, set $X$, and its subsets, is given by the assumptions of
the theorem and tuple ${\bf a}$.
Suppose that the claim is true for an ideal $I$, set $W$ does not
belong to $I$, but all its proper subsets do. Let ${\mathcal E}(I)$ be the set of
all tuples ${\bf c}$, not necessarily from $R$ such that
${\rm pr}_U{\bf c}\in{\rm pr}_UR$ for every $U\in I$. Clearly, $R\sse{\mathcal E}(I)$
and ${\mathcal E}$ is a subdirect product of $\tms{\mathbb A} n$. By ${\mathcal D}(I)$ we denote
the set of tuples ${\bf a}\in{\mathcal E}(I)$ such that
$({\bf a}[i],{\bf a}[j])\sqq_{as}({\bf c}[i],{\bf c}[j])$ in ${\rm pr}_{ij}R$ for $i,j\in[n]$, and
${\rm pr}_X{\bf a}\sqq_{as}{\rm pr}_X{\bf c}$. It does not have to be a subalgebra of
$\tms{\mathbb A} n$. If a tuple belongs to ${\mathcal D}(I)$ it is said to
\emph{support} $I$. We show that ${\mathcal D}(I)$ contains a tuple ${\bf b}$
such that ${\rm pr}_W{\bf b}\in{\rm pr}_WR$, that is, ${\bf b}$ supports $I\cup\{W\}$.
Assume that $W=[\ell]$. For a subalgebra $Q$ of ${\rm pr}_WR$ a
tuple ${\bf c}\in{\mathcal D}(I)$ is said to be $Q$-approximable
if for any $U\subset W$ there is ${\bf c}_U\inR$ with
${\rm pr}_U{\bf c}_U={\rm pr}_U{\bf c}$ and ${\rm pr}_W{\bf c}_U\inQ$. We prove the
following statement:
\begin{quote}
Let $Q$ be a subalgebra of ${\rm pr}_WR$. If there exists
a $Q$-approximable tuple from ${\mathcal D}(I)$, then there is
${\bf d}\in{\mathcal D}(I)$ such that ${\rm pr}_W{\bf d}\inQ$.
\end{quote}
Note that if $Q={\rm pr}_WR$, then any tuple in ${\mathcal D}(I)$
is $Q$-approximable. Therefore the statement
implies that ${\mathcal D}(I)$ contains a tuple ${\bf d}$ with
${\rm pr}_W{\bf d}\in{\rm pr}_WR$, which would prove the induction step.
We prove the statement by induction on the sum of sizes of unary
projections of $Q$. If one of these projections is 1-element then
the statement trivially follows from the assumption ${\rm pr}_U{\bf c}\in{\rm pr}_UQ$
for $U$ including all coordinate positions whose projections contain
more than 1 element, and so ${\rm pr}_W{\bf c}\in{\rm pr}_WR$. So suppose that
the statement is proved for all relations with unary projections
smaller than $Q$. Also let ${\bf c}$ be a $Q$-approximable tuple
from ${\mathcal D}(I)$. We will need the following auxiliary statements.
\smallskip
{\sc Claim 1.}
Let ${\bf d}\in{\mathcal D}(I)$ and $\vc{\bf e} k$ an as-path in ${\mathcal E}(I)$. Then every
tuple from an as-path $\vc{{\bf e}'}k$ constructed as follows belongs to
${\mathcal D}(I)$: ${\bf e}'_1={\bf d}$; if ${\bf e}_i{\bf e}_{i+1}$ is a semilattice edge
then ${\bf e}'_{i+1}={\bf e}'_i\cdot{\bf e}_{i+1}$; and if ${\bf e}_i{\bf e}_{i+1}$
is a thin affine edge then ${\bf e}'_i{\bf e}'_{i+1}$ is some thin affine edge
in $\Sgg{\tms{\mathbb A} n}{{\bf e}'_i,{\bf e}'_{i+1}}$.
\smallskip
Since ${\bf d},\vc{\bf e} k\in{\mathcal E}(I)$, we also have $\vc{{\bf e}'}k\in{\mathcal E}(I)$. Thus,
we only need to check that $({\bf e}'_s[i],{\bf e}'_s[j])\in\mathsf{as}({\bf a}[i],{\bf a}[j])$
for any $s\in[k]$ and $i,j\in[n]$. However, this condition follows from
the assumption ${\bf d}\in{\mathcal D}(I)$ --- thus,
$({\bf e}'_1[i],{\bf e}'_1[j])\in\mathsf{as}({\bf a}[i],{\bf a}[j])$, --- and that
${\rm pr}_{ij}{\bf e}'_1,\ldots,{\rm pr}_{ij}{\bf e}'_k$ is an as-path by
Corollary~\ref{cor:product-path}. In a similar way we observe that
${\rm pr}_X{\bf e}'_s\in\mathsf{as}({\rm pr}_X{\bf d})=\mathsf{as}({\rm pr}_X{\bf a})$.
\smallskip
{\sc Claim 2.}
Let ${\bf c}$ be $Q$-approximable, $U\subset W$, and let
${\bf e}\in{\rm pr}_UQ$ be such that ${\rm pr}_U{\bf c}\sqq_{as}{\bf e}$ in ${\rm pr}_UQ$.
Then there is ${\bf c}'\in{\mathcal D}(I)$ such that it is $Q$-approximable and
${\rm pr}_U{\bf c}'={\bf e}$.
\smallskip
Let ${\rm pr}_U{\bf c}={\bf b}_1,\ldots,{\bf b}_k={\bf e}$ be an as-path in ${\rm pr}_UQ$.
Since ${\bf b}_i\in{\rm pr}_UQ$ for each
$i\in[k]$, by Corollary~\ref{cor:product-path}(1) this path can
be extended to an as-path ${\rm pr}_W{\bf c}_U=\vc{{\bf b}'}k$ in $Q$.
Then, since ${\bf b}'_i\in{\rm pr}_WR$
for each $i\in[k]$, applying again Corollary~\ref{cor:product-path}(1)
the as-path $\vc{{\bf b}'}k$ can be extended to an as-path
$\vc{{\bf b}''}k$ in $R$ such that ${\rm pr}_W{\bf b}''_i={\bf b}'_i\inQ$,
${\rm pr}_U{\bf b}''_i={\bf b}_i$ for each $i\in[k]$. Using Claim~1
we define a sequence
$\vc{{\bf d}}k$ as follows: ${\bf d}_1={\bf c}$, and ${\bf d}_{i+1}$ is
such that ${\rm pr}_U{\bf d}_{i+1}={\bf b}_{i+1}$ and ${\bf d}_i\sqq_{as}{\bf d}_{i+1}$
in $\Sgg{\tms{\mathbb A} n}{{\bf d}_i,{\bf b}''_{i+1}}$. Now, set ${\bf c}'={\bf d}_k$. By Claim~1
${\bf c}'$ belongs to ${\mathcal D}(I)$.
To show that ${\bf c}'$ is $Q$-approximable,
for any $V\subset W$ we construct a tuple ${\bf c}'_V$ as follows.
Consider the sequence
${\rm pr}_V{\bf c}={\rm pr}_V{\bf c}_V={\bf e}_1,\ldots,{\bf e}_k={\rm pr}_V{\bf d}_k={\rm pr}_V{\bf e}$,
where ${\bf e}_i={\rm pr}_V{\bf d}_i$. By construction this is an as-path in
${\rm pr}_VQ$, so by Corollary~\ref{cor:product-path}(1) it can be
extended to an as-path ${\rm pr}_W{\bf c}_V={\bf e}'_1,\ldots,{\bf e}'_k$ in $Q$.
Then, as above, this as-path can be extended to an as-path
${\bf c}_V=\vc{{\bf e}''}k$ in $R$. Tuple ${\bf e}''_k$ can be chosen to serve
as ${\bf c}'_V$.
\smallskip
In particular, Claim~2 implies that ${\bf c}$ can be chosen such that
for any $i\in W$ the element ${\bf c}[i]$ is as-maximal in ${\rm pr}_iQ$.
We will assume it from now on. For $U=W-\{i\}$, $i\in W$, we
denote ${\bf c}_U$ by ${\bf c}_i$.
Suppose that for some $i\in W$ the unary projection
${\rm pr}_iQ\ne\Sg{{\bf c}[i],{\bf c}_i[i]}$. Assume $i=1$. Then set
$$
Q'=Q\cap\left(\Sg{{\bf c}[1],{\bf c}_1[1]}\tm
\prod_{i\in W-\{1\}}{\rm pr}_iQ\right).
$$
Note that in this case ${\bf c}$ is $Q'$-approximable, and the
result follows by the inductive hypothesis.
Let ${\bf c}_i$, $i\in W$, be chosen such that $\Sg{{\bf c}[i],{\bf c}_i[i]}$ are
minimal possible. It is also clear that $Q$ can be chosen to be
$\Sg{\vc{\bf c}\ell}$.
\smallskip
{\sc Claim 3.}
For any $i\in W$ there is ${\bf d}\inQ$ such that ${\bf c}[i]\sqq_{as}{\bf d}[i]$
and ${\rm pr}_U{\bf c}\sqq_{as}{\rm pr}_U{\bf d}$ in ${\rm pr}_UQ$ where $U=W-\{i\}$.
\smallskip
Without loss of generality assume $i=1$ and $U=W-\{i\}$. Consider
the relation
$$
Q'(x,y,z)=\exists x_4,\ldots, x_\ell (Q(x,y,z,x_4,\ldots,
x_\ell)\meet(x_4={\bf c}[4]) \meet\ldots\meet(x_\ell={\bf c}[\ell])).
$$
Obviously, ${\rm pr}_{\{1,2,3\}}{\bf c}_1,{\rm pr}_{\{1,2,3\}}{\bf c}_2,
{\rm pr}_{\{1,2,3\}}{\bf c}_3\inQ'$. We show that $Q'$ contains a tuple
${\bf d}$ such that ${\rm pr}_{12}{\bf c}\sqq_{as}{\rm pr}_{12}{\bf d}$,
${\rm pr}_{13}{\bf c}\sqq_{as}{\rm pr}_{13}{\bf d}$, ${\rm pr}_{23}{\bf c}\sqq_{as}{\rm pr}_{23}{\bf d}$.
This would imply the claim, because, ${\rm pr}_{23}{\bf c}\sqq_{as}{\rm pr}_{23}{\bf d}$
means ${\rm pr}_U{\bf c}\sqq_{as}{\rm pr}_U{\bf d}$, and any of the fist two connections
means that ${\bf c}[i]\sqq_{as}{\bf d}[i]$.
If, say $({\bf c}[1],{\bf c}[2])$ is not as-maximal in ${\rm pr}_{12}Q'$, choose
an as-path $({\bf c}[1],{\bf c}[2])={\bf e}_1,\ldots, {\bf e}_s$ in ${\rm pr}_{12}Q'$
such that ${\bf e}_s$ is as-maximal in ${\rm pr}_{12}Q'$. By
Corollary~\ref{cor:product-path}(1) this as-path can be extended
to an as-path ${\rm pr}_{\{1,2,3\}}{\bf c}_3={\bf e}'_1,\ldots,{\bf e}'_s$ in $Q'$.
Now, as in the proof of Claim~1 we construct a sequence
${\rm pr}_{\{1,2,3\}}{\bf c}={\bf e}''_1,\ldots,{\bf e}''_s$, that is not necessarily from
$Q'$, as follows. If ${\bf e}'_i\le{\bf e}'_{i+1}$, set
${\bf e}''_{i+1}={\bf e}''_i\cdot{\bf e}'_{i+1}$. If ${\bf e}'_i{\bf e}'_{i+1}$ is
a thin affine edge, then set ${\bf e}''_{i+1}$ to be any tuple in
$\Sg{{\bf e}''_i,{\bf e}'_{i+1}}$ such that ${\bf e}''_i{\bf e}''_{i+1}$ is a thin
affine edge and ${\rm pr}_{12}{\bf e}''_{i+1}={\rm pr}_{12}{\bf e}'_{i+1}$.
The resulting tuple ${\bf e}''_s$ satisfies the following conditions:
${\rm pr}_{12}{\bf e}''_s={\bf e}_s$
and
\[
{\rm pr}_{13}{\bf c}\sqq_{as}{\rm pr}_{13}{\bf e}''_s\in{\rm pr}_{13}Q',\qquad
{\rm pr}_{23}{\bf c}\sqq_{as}{\rm pr}_{23}{\bf e}''_s\in{\rm pr}_{23}Q'.
\]
Repeating the procedure above for projections on $\{1,3\}$ and
$\{2,3\}$ if necessary, we obtain a tuple ${\bf c}'$ such that ${\rm pr}_{ij}{\bf c}'$
is an as-maximal tuple in ${\rm pr}_{ij}Q'$ for $i,j\in[3]$. Relation
$Q'$ and the tuples ${\rm pr}_{ij}{\bf c}'$, $i,j\in[3]$, satisfy
the conditions of Lemma~\ref{lem:3-quasi}. Therefore, $Q'$
contains a tuple ${\bf d}$ such that ${\rm pr}_{ij}{\bf c}\sqq_{as}{\rm pr}_{ij}{\bf d}$
in ${\rm pr}_{ij}Q'$ for $i,j\in[3]$. The result follows.
\smallskip
To complete the proof let $U=[\ell-1]$ (recall that $W=[\ell]$) and
${\bf d}$ the tuple obtained in Claim~3 for $i=\ell$.
Then ${\rm pr}_U{\bf c}\sqq_{as}{\rm pr}_U{\bf d}$ in ${\rm pr}_UQ$.
By Claim~2 ${\bf c}$ can be amended so that the new tuple ${\bf c}'$
still supports $I$, but ${\rm pr}_U{\bf c}'={\rm pr}_U{\bf d}$. Note that ${\bf c}'[\ell]$ is
in the same as-component of ${\rm pr}_\ellQ$ as ${\bf d}[\ell]$, therefore,
${\bf c}'[\ell]\sqq_{as}{\bf d}[\ell]$ in ${\rm pr}_\ellQ$.
If $\Sgg{{\mathbb A}_\ell}{{\bf c}'[\ell],{\bf d}[\ell]}={\rm pr}_\ellQ$, then there is a as-path
from ${\rm pr}_W{\bf c}'$ to ${\bf d}$ in ${\rm pr}_W{\mathcal E}(I)$: this is because
${\rm pr}_U{\bf c}'={\rm pr}_U{\bf d}$ and $\{{\rm pr}_U{\bf d}\}\tm{\rm pr}_\ellQ\sse{\rm pr}_W{\mathcal E}(I)$
in this case. Extend this path to a path in ${\mathcal E}(I)$ as before, and
change ${\bf c}'$ using this path as in Claim~1. The resulting tuple
${\bf c}''$ supports $I$, and
${\rm pr}_W{\bf c}''={\bf d}\inQ$ as required.
If ${\mathbb B}=\Sgg{{\mathbb A}_\ell}{{\bf c}'[\ell],{\bf d}[\ell]}\ne{\rm pr}_\ellQ$, then set
$Q''=Q\cap({\rm pr}_{[\ell-1]}Q\tm{\mathbb B})$. Since ${\bf c}'$
is $Q''$-approximable, the result follows from the inductive
hypothesis.
To finish the proof of Theorem~\ref{the:quasi-2-decomp} it suffices to
take care of the requirement that the resulting tuple ${\bf b}$ is such that
${\rm pr}_X{\bf b}={\rm pr}_X{\bf a}$. Since $X\in I$ already in the base
case, the resulting tuple ${\bf b}$ is such that ${\rm pr}_X{\bf a}\sqq{\rm pr}_X{\bf b}$. By
Corollary~\ref{cor:product-path}(1) there is also a tuple ${\bf b}'$
satisfying the same requirements and such that ${\rm pr}_X{\bf b}'={\rm pr}_X{\bf a}$.
\end{proof}
\begin{theorem}\label{the:pseudo-majority}
Let ${\mathcal K}$ be a finite class of finite similar smooth algebras
omitting type~{\bf1}. There is a term operation $\mathrm{maj}$ of ${\mathcal K}$ such
that for any ${\mathbb A}\in{\mathcal K}$ and any
$a,b\in{\mathbb A}$, $\mathrm{maj}(a,a,b),\mathrm{maj}(a,b,a),\mathrm{maj}(b,a,a)\in\mathrm{Ft}_{\mathbb A}^{as}(a)$.
In particular, if $a$ is as-maximal, then $\mathrm{maj}(a,a,b),\mathrm{maj}(a,b,a),\mathrm{maj}(b,a,a)$
belong to the as-component of ${\mathbb A}$ containing $a$.
\end{theorem}
\begin{proof}
Let $\{a_1,b_1\},\ldots,\{a_n,b_n\}$ be a list of all pairs of elements from
algebras of ${\mathcal K}$,
let $a_i,b_i\in{\mathbb A}_i$. Define a relation $R$ to be a subdirect product of
${\mathbb A}_1^3\tm\dots\tm{\mathbb A}_n^3$ generated by ${\bf a}_1,{\bf a}_2,{\bf a}_3$, where for every
$i\in[n]$, ${\rm pr}_{3i-2,3i-1,3i}{\bf a}_1=(a_i,a_i,b_i)$,
${\rm pr}_{3i-2,3i-1,3i}{\bf a}_2=(a_i,b_i,a_i)$, ${\rm pr}_{3i-2,3i-1,3i}{\bf a}_3=(b_i,a_i,a_i)$.
In other words the triples $({\bf a}_1[3i-2],{\bf a}_2[3i-2],{\bf a}_3[3i-2])$,
$({\bf a}_1[3i-1],{\bf a}_2[3i-1],{\bf a}_3[3i-1])$, $({\bf a}_1[3i],{\bf a}_2[3i],{\bf a}_3[3i])$
have the form $(a_i,a_i,b_i),(a_i,b_i,a_i),(b_i,a_i,a_i)$, respectively. Therefore
it suffices to show that $R$ contains a tuple ${\bf b}$ such that
$a_i\sqq_{as}{\bf b}[j]$, where $j\in\{3i,3i-1,3i-2\}$. However, since
$(a_{i_1},a_{i_2})\in{\rm pr}_{j_1j_2}R$ for any $i_1,i_2\in[n]$ and
$j_1\in\{3i_1,3i_1-1,3i_1-2\}$, $j_2\in\{3i_2,3i_2-1,3i_2-2\}$, this
follows from the 2-Decomposition Theorem~\ref{the:quasi-2-decomp}.
\end{proof}
A function $\mathrm{maj}$ satisfying the properties from
Theorem~\ref{the:pseudo-majority} will be called a
\emph{quasi-majority function}.
\section{Rectangularity for maximal components}%
\label{sec:max-rectangularity}
In this section we show a stronger rectangularity property --- involving
multi-ary relations --- than that in Proposition~\ref{pro:max-gen},
but for maximal components, rather than as-components.
An algebra ${\mathbb A}$ is said to be \emph{maximal generated} if it is
generated by its maximal component.
\subsection{Simple maximal generated algebras}
We start with several auxiliary statements.
\begin{lemma}\label{lem:3-ary}
Let $R$ be a subdirect product of simple maximal generated algebras
${\mathbb A}_1,{\mathbb A}_2,{\mathbb A}_3\in{\mathcal K}$, generated by their maximal components
$C_1,C_2,C_3$, respectively. If ${\mathbb A}_i\tm {\mathbb A}_j\sse{\rm pr}_{ij}R$
for every $i,j\in[3]$ and $R\cap(C_1\tm C_2\tm C_3)\ne\eps$,
then $R={\mathbb A}_1\tm {\mathbb A}_2\tm {\mathbb A}_3$.
\end{lemma}
\begin{proof}
Suppose without loss of generality that $|{\mathbb A}_1|\le
|{\mathbb A}_2|\le |{\mathbb A}_3|$. Recall that for $a\in {\mathbb A}_1$ by $R[a]$ we
denote the set $R[a]=\{(b_2,b_3)\mid (a,b_2,b_3)\in R\}$.
Notice that, for every $a\in{\mathbb A}_1$, $R[a]$ is a subalgebra of
${\rm pr}_{23}R$, and, since ${\rm pr}_{12}R={\mathbb A}_1\tm{\mathbb A}_2$,
${\rm pr}_{13}R={\mathbb A}_1\tm{\mathbb A}_3$, the algebra $R[a]$ is a subdirect
product of ${\mathbb A}_2,{\mathbb A}_3$.
Since both ${\mathbb A}_2,{\mathbb A}_3$ are simple and generated by their
maximal components (and therefore as-components) by
Corollary~\ref{cor:linkage-rectangularity}, depending on
whether $R[a]$ is linked or not, it is either the
graph of a bijective mapping, or ${\mathbb A}_2\tm{\mathbb A}_3$.
Suppose first that $R[a]$ is not the graph of a mapping for some
$a\in{\mathbb A}_1$. For any $b\in{\mathbb A}_2$ we have
that $(a,b)\tm{\mathbb A}_3\sseR$. Applying
Corollary~\ref{cor:linkage-rectangularity} treating
$R$ as a subdirect product of ${\rm pr}_{12}R={\mathbb A}_1\tm{\mathbb A}_2$ and
${\mathbb A}_3$ we get $C_1\tm C_2\tm C_3\sseR$. This implies
$R={\mathbb A}_1\tm{\mathbb A}_2\tm{\mathbb A}_3$.
Now suppose that, for every $a\in {\mathbb A}_1$, the set $R[a]$ is the graph
of a bijective mapping $\pi_a\colon {\mathbb A}_2\to{\mathbb A}_3$. We repeat the
argument from the proof of Lemma~\ref{lem:3-quasi}.
First, it follows that ${\mathbb A}_2,{\mathbb A}_3$ are isomorphic and $|{\mathbb A}_2|=|{\mathbb A}_3|$.
Let $k=|{\mathbb A}_2|=|{\mathbb A}_3|$. As ${\rm pr}_{23}R={\mathbb A}_2\tm{\mathbb A}_3$, there are at
least $k$ different
relations of the form $R[a]$. Therefore, $|{\mathbb A}_1|=k$
and $|R[a]|=k$ for any $a\in {\mathbb A}_1$. Moreover, $|{\rm pr}_{23}R|=k^2$,
which means $R[a]\cap R[a']=\eps$ whenever $a\ne a'$, $a,a'\in
{\mathbb A}_1$. The sets of the form $R[a]$ form the link congruence ${\sf lk}_{23}$
of ${\rm pr}_{23}R={\mathbb A}_2\tm{\mathbb A}_3$, which is isomorphic to ${\mathbb A}_2^2$.
Therefore ${\sf lk}_{23}$ is a skew congruence of the square of a simple
idempotent algebra. Algebra ${\mathbb A}_2$ does not have an absorbing element,
because $|{\mathbb A}_2|>1$, while an absorbing element would be the only maximal
element of ${\mathbb A}_2$, and so ${\mathbb A}_2$ cannot be maximal generated.
Therefore by Theorem~\ref{the:simple-idempotent} ${\mathbb A}_2$ is a module,
which implies that $|C_1|=|C_2|=|C_3|=1$, and so
$|{\mathbb A}_1|=|{\mathbb A}_2|=|{\mathbb A}_3|=1$ and the claim is trivial.
\end{proof}
The next lemma is not really needed for our proof, but may be of independent
interest.
\begin{lemma}\label{lem:n-ary}
Let $R$ be a subdirect product of simple maximal generated
algebras ${\mathbb A}_1,\ldots,{\mathbb A}_n$, say, ${\mathbb A}_i$ is generated by an maximal
component $C_i$. If ${\mathbb A}_i\tm {\mathbb A}_j\sse{\rm pr}_{ij}R$ for
every $i,j\in[n]$ and $R\cap(\tms Cn)\ne\eps$, then
$R={\mathbb A}_1\tm\ldots\tm {\mathbb A}_n$.
\end{lemma}
\begin{proof}
We prove the lemma by induction. The base case of induction $n=3$
has been proved in Lemma~\ref{lem:3-ary}. Suppose that
the lemma holds for each number less than~$n$. Take $a\in
{\mathbb A}_1$ and recall that $R[a]=\{(b_2,\ldots, b_n)\mid
(a,b_2,\ldots, b_n) \in R\}$. By Lemma~\ref{lem:3-ary}, ${\mathbb A}_1\tm
{\mathbb A}_i\tm {\mathbb A}_j\sse {\rm pr}_{1,i,j}R$ for any $2\le i,j\le n$.
Then ${\mathbb A}_i\tm {\mathbb A}_j\sse{\rm pr}_{ij}R[a]$. Therefore by induction
hypothesis $R[a]= {\mathbb A}_2\tm\ldots\tm {\mathbb A}_n$.
\end{proof}
Lemma~\ref{lem:n-ary} allows one to describe the structure of
subdirect products of simple maximal generated algebras.
\begin{defin}
A relation $R\sse {\mathbb A}_1\tm\ldots\tm {\mathbb A}_n$ is said to be {\em
almost trivial} if there exists an equivalence relation $\th$ on the set
$[n]$ with classes $I_1,\ldots, I_k$, such that
$$
R={\rm pr}_{I_1}R\tm\ldots\tm{\rm pr}_{I_k}R
$$
where ${\rm pr}_{I_j}R=\{(a_{i_1},\pi_{i_2}(a_{i_1}),\ldots,
\pi_{i_l}(a_{i_1}))\mid a_{i_1}\in {\mathbb A}_{i_1}\}$, $I_j=\{i_1,\ldots, i_l\}$,
for certain bijective mappings $\pi_{i_2}\colon {\mathbb A}_{i_1}\to
{\mathbb A}_{i_2},\ldots, \pi_{i_l}\colon {\mathbb A}_{i_1}\to {\mathbb A}_{i_l}$.
\end{defin}
\begin{lemma}\label{lem:at-for-simple}
Let $R$ be a subdirect product of simple maximal generated
algebras $\vc{\mathbb A} n$, say, ${\mathbb A}_i$ is generated by an maximal component
$C_i$; and let $R\cap(C_1\tm\ldots\tm C_n)\ne\eps$. Then $R$
is an almost trivial relation.
\end{lemma}
\begin{proof}
We prove the lemma by induction on $n$. When $n=1$ the result
holds trivially.
We now prove the induction step. By Corollary~\ref{cor:linkage-rectangularity},
for any pair $i,j\in[n]$ the projection ${\rm pr}_{ij}R$ is either ${\mathbb A}_i\tm{\mathbb A}_j$,
or the graph of a bijective mapping. Assume that there exist $i,j$
such that ${\rm pr}_{ij}R$ is the graph of a mapping
$\pi\colon{\mathbb A}_i\to{\mathbb A}_j$. By the inductive hypothesis ${\rm pr}_{[n]-\{j\}}R$
is almost trivial, and therefore can be represented in the form
$$
{\rm pr}_{[n]-\{j\}}R={\rm pr}_{I_1}R\tm\ldots\tm{\rm pr}_{I_k}R
$$
where $I_1\cup\ldots\cup I_k=[n]-\{j\}$. Suppose, for simplicity,
that $i$ is the last coordinate position in $I_1$, that is,
\begin{eqnarray*}
{\rm pr}_{I_1}R &=& \{(a_{i_1},\ldots, a_{i_k},a_i)\mid a_{i_1}\in{\mathbb A}_{i_1}, \
a_{i_s}=\pi_{s1}(a_{i_1})\\
& & \hbox{for}\ s\in\{2,\ldots, k\},\ a_i=\pi_i(a_{i_1})\}.
\end{eqnarray*}
Then
\begin{eqnarray*}
{\rm pr}_{I_1\cup\{j\}}R &=& \{(a_{i_1},\ldots, a_{i_k},a_i,a_j)\mid a_{i_1}\in{\mathbb A}_{i_1}, \
a_{i_s}=\pi_{s1}(a_{i_1})\\
& & \hbox{for}\ s\in\{2,\ldots, k\},\ a_i=\pi_i(a_{i_1}),\ a_j=\pi\pi_i(a_{i_1})\},
\end{eqnarray*}
and we have $R={\rm pr}_{I_1\cup\{j\}}R\tm\ldots\tm{\rm pr}_{I_k}R$, as
required.
Finally, if ${\rm pr}_{ij}R={\mathbb A}_i\tm{\mathbb A}_j$ for all $i,j\in\un n$, then
the result follows by Lemma~\ref{lem:n-ary}.
\end{proof}
\subsection{General maximal generated algebras}
Here we consider the case when factors of a subdirect product are maximal
generated, but not necessarily simple.
\begin{lemma}\label{lem:n-simple}
Let $R$ be a subdirect product of maximal generated algebras
${\mathbb A}_1,\ldots,{\mathbb A}_n$, where ${\mathbb A}_1$ is simple. Let also ${\mathbb A}_1$
be generated by a maximal component $C_1$, ${\rm pr}_{2,\ldots, n}R$
is maximal generated, say, by a maximal component $Q$,
$R\cap(C_1\tmQ)\ne\eps$, and ${\rm pr}_{1i}R={\mathbb A}_1\tm {\mathbb A}_i$ for
$i\in\{2,\ldots, n\}$, Then $R={\mathbb A}_1\tm{\rm pr}_{2,\ldots, n}R$.
\end{lemma}
\begin{proof}
We prove the lemma by induction on $n$. The case $n=2$ is obvious.
Consider the case $n=3$. We use induction on
$|{\mathbb A}_1|+|{\mathbb A}_2|+|{\mathbb A}_3|$. The trivial case
$|{\mathbb A}_1|+|{\mathbb A}_2|+|{\mathbb A}_3|=3$ gives the base
case of induction. Let $Q$ be a maximal component of ${\rm pr}_{23}R$
generating it. If both ${\mathbb A}_2,{\mathbb A}_3$ are simple,
then the result follows from Lemma~\ref{lem:at-for-simple}. Otherwise,
suppose that ${\mathbb A}_3$ is not simple. Take a maximal congruence $\th$
of ${\mathbb A}_3$, fix a $\th$-class $D$ and consider
$R'\sse{\mathbb A}_1\tm{\mathbb A}_2\tm{\mathbb A}_3\fac\th$, $R''\sseR$ such that
\begin{eqnarray*}
R' &=& \{(a,b,c\fac\th)\mid (a,b,c)\inR\},\\
R''&=& \{(a,b,c)\mid (a,b,c)\inR, c\in D\},
\end{eqnarray*}
and $R'''\sseR$, the algebra generated by the maximal component
$Q'$ of $R''$ such that ${\rm pr}_1Q'\cap C_1\ne\eps$ and
${\rm pr}_{23}Q'\capQ\ne\eps$. Note that since
${\mathbb A}_1\tm{\mathbb A}_3\sse{\rm pr}_{13}R$, by Corollary~\ref{cor:product-maximal}(1)
this implies ${\rm pr}_1Q'\cap C_1=C_1$. Also, obviously,
${\rm pr}_{13}R''={\mathbb A}_1\tm D$. Moreover, ${\mathbb A}_1\tm
D''\sse{\rm pr}_{13}R'''$, where $D''$ is the algebra generated by a
certain maximal component $D'$ of $D$. By Proposition~\ref{pro:max-gen},
${\rm pr}_{23}R'$ is either the graph of a mapping, or
${\mathbb A}_2\tm{\mathbb A}_3\fac\th$.
\bigskip
\noindent
{\sc Case 1.}
${\rm pr}_{23}R'$ is the graph of a mapping
$\pi\colon{\mathbb A}_2\to{\mathbb A}_3\fac\th$.
\medskip
In this case $B''={\rm pr}_2R'''$ is the algebra generated by a maximal
component
$B'$ of $B=\pi^{-1}(D)$ and such that $B'\cap{\rm pr}_2Q'\ne\eps$.
Since for each
$(a,b)\in{\mathbb A}_1\tm B\sse{\rm pr}_{12}R$ there is $c\in D$ with
$(a,b,c)\inR$, we have ${\mathbb A}_1\tm B\sse{\rm pr}_{12}R''$. Furthermore,
${\mathbb A}_1\tm B''$ is the algebra generated by a maximal component of
${\mathbb A}_1\tm B$, hence, ${\rm pr}_{12}R'''={\mathbb A}_1\tm B''$.
Since $|{\mathbb A}_1|+|B''|+|D''|<|{\mathbb A}_1|+|{\mathbb A}_2|+|{\mathbb A}_3|$, and
${\rm pr}_{23}R'''$ is maximal generated, inductive hypothesis
implies ${\mathbb A}_1\tm{\rm pr}_{23}R'''\sseR'''$. In particular,
there is $(a,b)\in{\rm pr}_{23}R'''\capQ\sse{\rm pr}_{23}R$ such that
${\mathbb A}_1\tm\{(a,b)\}\sseR$. To finish the proof we just apply
Lemma~\ref{lem:buket}.
\bigskip
\noindent
{\sc Case 2.}
${\rm pr}_{23}R'={\mathbb A}_2\tm{\mathbb A}_3\fac\th$.
\medskip
Since $|{\mathbb A}_1|+|{\mathbb A}_2|+|{\mathbb A}_3\fac\th|<|{\mathbb A}_1|+|{\mathbb A}_2|+|{\mathbb A}_3|$,
${\mathbb A}_3\fac\th$ is simple, and ${\rm pr}_{12}R={\mathbb A}_1\tm{\mathbb A}_2$, by
inductive hypothesis, $R'={\mathbb A}_1\tm{\mathbb A}_2\tm{\mathbb A}_3\fac\th$. Therefore,
${\rm pr}_{12}R''={\mathbb A}_1\tm{\mathbb A}_2$. Then ${\rm pr}_{12}R'''={\mathbb A}_1\tm{\mathbb A}_2$.
Indeed, let $C_2={\rm pr}_2Q$, it is a maximal component of ${\mathbb A}_2$, and
${\mathbb A}_2$ is generated by $C_2$. Moreover, ${\mathbb A}_1\tm{\mathbb A}_2$ is generated
by $C_1\tm C_2$. By the choice of $R'''$, there is
$(a,b,c)\inR'''\cap(C_1\tm C_2\tm D')$. By Corollary~\ref{cor:product-path}(1)
for any $(a',b')\in C_1\tm C_2$ there is a path from $(a,b,c)$ to $(a',b',c')$ for
some $c'\in D'$.
Now we argue as in Case~1, except in this case $B''={\mathbb A}_2$.
\medskip
Let
us assume that the lemma is proved for $n-1$. Then
${\mathbb A}_1\tm{\rm pr}_{3,\ldots, n}R\sse{\rm pr}_{1,3,\ldots, n}R$. Denoting ${\rm pr}_{3,\ldots,
n}R$ by $R'$ we have $R\sse{\mathbb A}_1\tm{\mathbb A}_2\tmR'$, and the
conditions of the lemma hold for this subdirect product. Thus
$R={\mathbb A}_1\tm{\rm pr}_{2,\ldots, n}R$ as required.
\end{proof}
Lemma~\ref{lem:n-simple} serves as the base case for the following more
general statement.
\begin{lemma}\label{lem:relation-direct-product}
Let $R$ be a subdirect product of smooth algebras ${\mathbb A}_1,\ldots,{\mathbb A}_n$.
Let ${\mathbb A}_1$ be generated by a maximal component $C_1$, ${\rm pr}_{2,\ldots, n}R$
is maximal generated, say, by a maximal component $Q$,
$R\cap(C_1\tmQ)\ne\eps$, and ${\rm pr}_{,i}R={\mathbb A}_1\tm {\mathbb A}_i$ for
$i\in\{2,\ldots, n\}$, Then $R={\mathbb A}_1\tm{\rm pr}_{2,\ldots, n}R$.
\end{lemma}
\begin{proof}
For every $i\in\{2,\ldots, n\}$ the set $C_i={\rm pr}_iQ$ is a maximal component.
Moreover, ${\mathbb A}_i$ is generated by $C_i$, and therefore is also maximal
generated.
We show that for any subalgebra $S$ of ${\mathbb A}_1$ such that
(a) $S\cap C_1\ne\eps$, (b) $S$ is maximal generated by its
elements from $C_1$, (c) $\max(C_1\capS)\tm C_i\sse{\rm pr}_{1i}R$
for $i\in\{2,\ldots, n\}$, and
(d) $Q\sse{\rm pr}_{2,\ldots, n}(R\cap(S\tm C_2\tm\dots\tm C_n))$,
the following holds: $\{d\}\tmQ\sseR$ for any $d\in\max(C_1\capS)$.
We prove by induction on the size of $S$. If $|S|=1$, then its
only element belongs to $C_1$ by (a) and is maximal. Then (d) is
equivalent to the claim. Suppose that the result holds for all
subalgebras satisfying (a)--(d) smaller than $S$. If
$S$ is simple then the result follows from Lemma~\ref{lem:n-simple},
since conditions (a)--(d) imply the premices of
Lemma~\ref{lem:n-simple}. Otherwise let $\th$ be a maximal congruence of
$S$, let $R'=\{(c_1,c_2,\ldots, c_n)\inR\mid c_1\inS\}$, and let
$$
R^\th=\{(c_1\fac\th,c_2,\ldots, c_n)\mid (c_1,c_2,\ldots, c_n)\in R'\}.
$$
By Lemma~\ref{lem:n-simple}
$R^\th=S\fac\th\tm{\rm pr}_{2,\ldots, n}R$. Take a class $S'$ of
$\th$ containing elements from $C_1$. Observe that $S'$
satisfies condition (d). As is easily seen there is a maximal component $B$
of $S'$ containing elements from $C_1$. Indeed, take any
$d\in C_1\capS'$, then $\mathrm{Ft}_{S'}^s(d)\sse C_1$. Let $S''$
be a subalgebra of $S'$ generated by $B$, we show it satisfies
(a)--(d).
Conditions (a) and (b)
are true by the choice of $S''$, condition (c) holds since this
condition is true for $S$. For condition (d) observe first that
$Q\sse{\rm pr}_{2,\ldots, n}(R\cap(\max(S')\tm Q))$.
As for any $d\in C_1\cap S'$ there is $(a_2,\ldots, a_n)\inQ$
with $(d,a_2,\ldots, a_n)\inR$ (it follows from the condition
$R\cap(C_1\tmQ)\ne\eps$ of the lemma and
Corollary~\ref{cor:product-path}(1)), applying
Corollary~\ref{cor:product-path}(1) again
$Q\sse {\rm pr}_{2,\ldots, n}(R\cap(B\tmQ))$,
and (d) is also true for $S''$. By inductive hypothesis
$\{d\}\tmQ\sse R$ for $d\in B$. Applying
Proposition~\ref{pro:max-gen} we obtain the result.
Finally, the lemma follows from the fact that ${\mathbb A}_1$ contains
$C_1$ and satisfies conditions (a)--(d).
\end{proof}
\begin{corollary}\label{cor:max-comp-product}
Let $R$ be a subdirect product of smooth algebras
${\mathbb A}_1,\ldots,{\mathbb A}_n$ such that ${\rm pr}_{1i}R$ is linked for any $i\in\{2,\ldots, n\}$.
Let also ${\bf a}\inR$ be such that ${\bf a}[1]\in\max({\mathbb A}_1)$ and
${\rm pr}_{2\dots n}{\bf a}\in\max({\rm pr}_{2\dots n}R)$. Then
$\se{{\bf a}[1]}\tm\se{{\rm pr}_{2\dots n}{\bf a}}\sseR$.
\end{corollary}
\begin{proof}
Consider $R'$, the relation generated by
$R\cap(C\tm D)$, $C=\se({\bf a}[1])$, $D=\se({\rm pr}_{2\dots n}{\bf a})$.
By Corollary~\ref{cor:product-path} $\se({\bf a}[1])\sse{\rm pr}_1R'$ and
$\se({\rm pr}_{2\dots n}{\bf a})\sse{\rm pr}_{2\dots n}R'$. Moreover, $C$ and
$D$ are maximal components in ${\rm pr}_1R'$ and ${\rm pr}_{2\dots n}R'$,
respectively. Since ${\rm pr}_{1i}R$ is linked for $i\in\{2,\ldots, n\}$,
$C\tm{\rm pr}_i D\sse{\rm pr}_{1i}$. As ${\rm pr}_{1i}R'\cap(C\tm{\rm pr}_i D)\ne\eps$
and $C\tm{\rm pr}_i D$ is a maximal component in ${\rm pr}_{1i}R$, by
Corollary~\ref{cor:product-path} $C\tm{\rm pr}_i D\sse{\rm pr}_{1i}R'$.
Subalgebras ${\rm pr}_1R'$ and ${\rm pr}_iR'$ are generated by $C$ and
${\rm pr}_i D$, respectively, therefore, ${\rm pr}_{1i}R'={\rm pr}_1R'\tm{\rm pr}_iR'$.
Now by Lemma~\ref{lem:relation-direct-product} the result follows.
\end{proof}
\bibliographystyle{plain}
| {'timestamp': '2020-07-21T02:34:04', 'yymm': '2006', 'arxiv_id': '2006.10239', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10239'} | arxiv |
\section{Introduction}
\label{sec:intro}
Search clarification has recently been recognized as a useful feature for improving user experience in search engines, especially for ambiguous and faceted queries~\cite{Zamani:2020:WWW}. In addition, it has been identified as a necessary step towards developing mixed-initiative conversational search systems~\cite{Radlinski:2017,Zamani:2020:Macaw}. The reason is that limited bandwidth interfaces used in many conversational systems, such as speech-only and small-screen devices, make it difficult or even impossible for users to go through multiple documents in case of ambiguous or faceted queries. This has recently motivated researchers and practitioners to investigate possible approaches to \emph{clarify} user information needs by asking a question~\cite{Aliannejadi:2019,Zamani:2020:WWW}.
\begin{figure}[t]
\centering
\includegraphics[width=\linewidth]{img/bing3.jpg}
\caption{An example of clarification pane in Bing.}
\label{fig:bing}
\vspace{-0.5cm}
\end{figure}
Despite the recent progress in search clarification, e.g.,~\cite{Aliannejadi:2019,Zamani:2020:WWW,Zamani:2020:SIGIR,Hashemi:2020:SIGIR}, the community still feels the lack of a large-scale dataset for search clarification, which is necessary for speeding up the research progress in this domain.
To address this issue, we introduce MIMICS\xspace,\footnote{MIMICS\xspace stands for the \underline{Mi}crosoft's \underline{M}ixed-\underline{I}nitiative \underline{C}onversation \underline{S}earch Data.} a data collection consisting of multiple datasets for search clarification. Each clarification in MIMICS\xspace consists of a clarifying question and up to five candidate answers. \figurename~\ref{fig:bing} shows the interface used for clarification in Bing for constructing this data. The first dataset, called \dataset-Click\xspace, includes over 400k unique search queries sampled from the Bing's query logs, each associated with a single clarification pane. The dataset also includes aggregated user interaction signals, such as the overall user engagement level and conditional clickthrough rate on individual candidate answers. The second dataset, called \dataset-ClickExplore\xspace, contains over 64k queries, each with multiple clarification panes which are the result of multiple exploration and online randomization experiments. This dataset also includes the aggregated user interaction signals. The third dataset, on the other hand, is manually labeled by trained annotators. This dataset, which is called \dataset-Manual\xspace, includes graded quality labels for clarifying question, candidate answer set, and the landing result page for each individual answer.
The datasets created as part of MIMICS\xspace can be used for training and evaluating a variety of tasks related to search clarification, including generating/selecting clarifying questions and candidate answers, re-ranking candidate answers for clarification, click models for search clarification, user engagement prediction for search clarification, and analyzing user interactions with search clarification. This paper also suggests some evaluation methodologies and metrics for these tasks.
\section{Related Work}
\label{sec:rel}
Clarification has been explored in a number of applications, such as speech recognition~\cite{Stoyanchev:2014}, dialogue systems~\cite{DeBoni:2003,DeBoni:2005,Quintano:2008}, and community question answering~\cite{Braslavski:2017,Rao:2018,Rao:2019}. Recently, it attracted much attention in the information retrieval literature~\cite{Aliannejadi:2019,Zamani:2020:WWW,Zamani:2020:SIGIR,Hashemi:2020:SIGIR,Radlinski:2017}. For instance, \citet{Kiesel:2018} investigated the impact of voice query clarification on user satisfaction. Their study showed that users like to be prompted for clarification. Simple form of clarification, such as entity disambiguation, has been explored by \citet{Coden:2015}. They basically ask a ``did you mean A or B?'' question to resolve entity ambiguity. Even earlier, \citet{Allan:2004} organized the HARD Track at TREC 2004 which involved clarification from participants. In more detail, the participants could submit a form containing some human-generated clarifying questions in addition to their submission run. Recently, \citet{Aliannejadi:2019} proposed studying clarification in the context of conversational information seeking systems. This was later highlighted as an important aspect of conversational search in the Dagstuhl Seminar on Conversational Search~\cite{Anand:2020}. More recently, \citet{Zamani:2020:WWW} introduced clarification in the context of web search and proposed models for generating clarifying questions and candidate answers for open-domain search queries. In a follow-up study, \citet{Zamani:2020:SIGIR} analyzed user interactions with clarification panes in Bing and provided insights into user behaviors and click bias in the context of search clarification. Moreover, \citet{Hashemi:2020:SIGIR} proposed a representation learning model for utilizing user responses to clarification in conversational search systems.
\begin{table*}[t]
\centering
\caption{Statistics of the datasets constructed as part of MIMICS\xspace.}
\vspace{-0.3cm}
\renewcommand{\tabcolsep}{3pt}
\begin{tabular}{llll}\toprule
& \textbf{\dataset-Click\xspace} & \textbf{\dataset-ClickExplore\xspace} & \textbf{\dataset-Manual\xspace} \\\midrule
\# unique queries & 414,362 & 64,007 & 2464 \\
\# query-clarification pairs & 414,362 & 168,921 & 2832 \\
\# clarifications per query & 1 $\pm$ 0 & 2.64 $\pm$ 1.11 & 1.15 $\pm$ 0.36 \\
min \& max clarifications per query & 1 \& 1 & 2 \& 89 & 1 \& 3 \\
\# candidate answers & 2.81 $\pm$ 1.06 & 3.47 $\pm$ 1.20 & 3.06 $\pm$ 1.05 \\
min \& max \# candidate answers & 2 \& 5 & 2 \& 5 & 2 \& 5\\
\# query-clarification pairs with positive engagement & 71,188 & 89,441 & N/A \\
\# query-clarification pairs with low/medium/high impressions & 264,908 / 105,879 / 43,575 & 52,071 / 60,907 / 55,943 & N/A \\
\bottomrule
\end{tabular}
\label{tab:stats}
\end{table*}
Despite the recent progress reviewed above, there is no large-scale publicly available resource for search clarification. To the best of our knowledge, Qulac\footnote{\url{https://github.com/aliannejadi/qulac}}~\cite{Aliannejadi:2019} is the only public dataset that focuses on search clarification. However, it only contains 200 unique queries borrowed from the TREC Web Track 2009-2012. Therefore, it is not sufficient for training a large number of machine learning models with millions of parameters. In addition, it was constructed through crowdsourcing. Therefore, the clarifications are human generated and user responses to clarifications in real scenarios may differ from the ones in Qulac. There also exist a number of community question answering data and product catalogs with clarifications (e.g., see \cite{Rao:2019}), however, they are fundamentally different from search clarification. Therefore, this paper provides a unique resource in terms of realisticness, size, diversity, clarification types, user interaction signals, and coverage.
It is worth noting that a number of datasets related to conversational search has recently been created and released. They include CCPE-M~\cite{Radlinski:2019}, CoQA~\cite{Reddy:2019}, QuAC~\cite{Choi:2018}, MISC~\cite{Thomas:2017}, and the Conversation Assistance Track data created in TREC 2019~\cite{Dalton:2020:CAST}. Although these datasets do not particularly focus on clarification, there might be some connections between them and MIMICS\xspace that can be used in future research. In addition, the public query logs, such as the one released by AOL~\cite{Pass:2006}, can be used together with MIMICS\xspace for further investigations. This also holds for the datasets related to query suggestion and query auto-completion.
\section{Data Collection}
\label{sec:data}
Bing has recently added a clarification pane to its result pages for some ambiguous and faceted queries. It is located right below the search bar and above the result list. Each clarification pane includes a clarifying question and up to five candidate answers. The user interface for this feature is shown in \figurename~\ref{fig:bing}. The clarifying questions and candidate answers have been generated using a number of internal algorithms and machine learning models. They are mainly generated based on users' past interactions with the search engine (e.g., query reformulation and click), content analysis, and a taxonomy of entity types and relations. For more information on generating clarification panes, we refer the reader to~\cite{Zamani:2020:WWW} that introduces three rule-based and machine learning models for the task. All the datasets presented in this paper follow the same properties and only demonstrate the queries from the en-US market.
In the following subsections, we explain how we created and pre-processed each dataset introduced in the paper. In summary, MIMICS\xspace consists of two datasets (\dataset-Click\xspace and \dataset-ClickExplore\xspace) based on user interactions (i.e., clicks) in Bing and one dataset (\dataset-Manual\xspace) based on manual annotations of clarification panes by multiple trained annotators.
\subsection{\dataset-Click\xspace}
\label{sec:data:one}
We sub-sampled the queries submitted to Bing in September 2019. We only kept the queries for which a clarification pane was rendered in the search engine result page (SERP). We made efforts in our data sampling to cover a diverse set of query and clarification types in the dataset, therefore, the engagement levels released in the paper by no mean represent the overall clickthrough rates in Bing. For privacy reasons, we followed $k$-anonymity by only including the queries that have been submitted by at least 40 users in the past year. In addition, the clarification panes were solely generated based on the submitted queries, therefore they do not include session and personalized information. We performed additional filtering steps to preserve the privacy of users using proprietary algorithms. Sensitive and inappropriate contents have automatically been removed from the dataset.
To reduce the noise in the click data, we removed the query-clarification pairs with less than 10 impressions. In other words, all the query-clarification pairs released in the dataset have been presented at least 10 times to the Bing users in the mentioned time period (i.e., one month).
This resulted in 414,362 unique queries, each associated with exactly one clarification pane. Out of which 71,188 of clarifications have received positive clickthrough rates. The statistics of this dataset is presented in \tablename~\ref{tab:stats}.
The dataset is released in a tab-separated format (TSV). Each data point in \dataset-Click\xspace is a query-clarification pair, its impression level (low, medium, or high), its engagement level (between 0 and 10), and the conditional click probability for each individual candidate answer. The engagement level 0 means there was no click on the clarification pane. We used a equal-depth method to divide all the positive clickthrough rates into ten bins (from 1 to 10). The description of each column in the dataset is presented in \tablename~\ref{tab:clickdataformat}.
\begin{table*}[t]
\centering
\caption{The data format in \dataset-Click\xspace and \dataset-ClickExplore\xspace.}
\vspace{-0.3cm}
\begin{tabular}{llL{11.5cm}}\toprule
\textbf{Column(s)} & \textbf{Type} & \textbf{Description} \\\midrule
query & string & The query text \\
question & string & The clarifying question \\
option\_1, $\cdots$, option\_5 & string & The candidate answers from left to right. If there is less than five candidate answers, the rest would be empty strings. \\
impression\_level & string & A string associated with the impression level of the corresponding query-clarification pair. Its value is either 'low', 'medium', or 'high'. \\
engagement\_level & integer & An integer from 0 to 10 showing the level of total engagement received by the users in terms of clickthrough rate. \\
option\_cctr\_1, $\cdots$, option\_cctr\_5 & real & The conditional click probability on each candidate answer. They must sum to 1, unless the total\_ctr is zero. In that case, they all are zero. \\\bottomrule
\end{tabular}
\label{tab:clickdataformat}
\end{table*}
\subsection{\dataset-ClickExplore\xspace}
\label{sec:data:two}
Although \dataset-Click\xspace is a invaluable resource for learning to generate clarification and related research problems, it does not allow researchers to study some tasks, such as studying click bias in user interactions with clarification. Therefore, to foster research in these interesting and practical tasks, we created \dataset-ClickExplore\xspace using some exploration and randomization experiments in September 2019. In more detail, we used the top $m$ clarifications generated by our algorithms and presented them to different sets of users (similar to A/B testing). The user interactions with multiple clarification panes for the same query at the same time period enable comparison of these clarification panes. The difference between these clarification panes can be in the clarifying question, the candidate answer set, the order of candidate answers, or a combination of them.
We performed the same filtering approach to address privacy concerns as the one discussed above for \dataset-Click\xspace. Again, we only kept the query-clarification pairs with a minimum impression of 10. The resulted dataset contains 64,007 unique queries and 168,921 query-clarification pairs. Out of which, 89,441 query-clarification pairs received positive engagements.
The format of this dataset is the same as \dataset-Click\xspace (see \tablename~\ref{tab:clickdataformat}). Note that the sampling strategies for \dataset-Click\xspace and \dataset-ClickExplore\xspace are different which resulted in significantly more query-clarification pairs with low impressions in \dataset-Click\xspace.
\begin{table*}[t]
\centering
\caption{The data format in \dataset-Manual\xspace. All the labels in this dataset are either 2 (Good), 1 (Fair), or 0 (Bad).}
\vspace{-0.3cm}
\begin{tabular}{llL{11cm}}\toprule
\textbf{Column(s)} & \textbf{Type} & \textbf{Description} \\\midrule
query & string & The query text \\
question & string & The clarifying question \\
option\_1, $\cdots$, option\_5 & string & The candidate answers from left to right. If there is less than five candidate answers, the rest would be empty strings. \\
question\_label & integer & The label associated with the clarifying question independent of the candidate answers. \\
options\_overall\_label & integer & The overall label given to the candidate answer set. \\
option\_label\_1, $\cdots$, option\_label\_5 & integer & The label assigned to each individual candidate answer based on the quality of the landing search result page. \\\bottomrule
\end{tabular}
\label{tab:labeldataformat}
\end{table*}
\begin{table*}[t]
\centering
\caption{The statistics of the common clarifying question templates in MIMICS\xspace. We only present the templates with at least 100 occurrence in \dataset-Click\xspace and \dataset-ClickExplore\xspace individually. Note that there is no label associated with the first template in \dataset-Manual\xspace.}
\vspace{-0.3cm}
\renewcommand{\tabcolsep}{2pt}
\begin{tabular}{llllllll}\toprule
\multirow{2}{*}{\textbf{ID}} & \multirow{2}{*}{\textbf{Clarifying question template}} & \multicolumn{2}{c}{\textbf{\dataset-Click\xspace}} & \multicolumn{2}{c}{\textbf{\dataset-ClickExplore\xspace}} & \multicolumn{2}{c}{\textbf{\dataset-Manual\xspace}} \\
& & \textbf{Freq.} & \textbf{Engagement} & \textbf{Freq.} & \textbf{Engagement} & \textbf{Freq.} & \textbf{Question Quality} \\\midrule
T1 & select one to refine your search & 395134 & 0.9285 & 156870 & 2.8631 & 2490 & N/A \\
T2 & what (do you want|would you like) to know about (.+)? & 7136 & 0.5783 & 5624 & 2.9070 & 158 & 1.9367 \\
T3 & (which|what) (.+) do you mean? & 7483 & 0.6123 & 1905 & 2.6714 & 76 & 2.000 \\
T4 & (what|which) (.+) are you looking for? & 3436 & 1.7252 & 2055 & 5.1990 & 22 & 1.6818 \\
T5 & what (do you want|would you like) to do with (.+)? & 689 & 1.9637 & 1833 & 3.4043 & 60 & 2.000 \\
T6 & who are you shopping for? & 101 & 1.9604 & 350 & 4.3800 & 7 & 1.5714 \\
T7 & what are you trying to do? & 188 & 3.3777 & 116 & 5.8793 & 3 & 1.0\\
\bottomrule
\end{tabular}
\label{tab:templates}
\end{table*}
\begin{table}[t]
\centering
\caption{The average and standard deviation of user engagement levels with respect to different query-clarification impressions.}
\vspace{-0.3cm}
\renewcommand{\tabcolsep}{4pt}
\begin{tabular}{lll}\toprule
\textbf{Impression level} & \textbf{\dataset-Click\xspace} & \textbf{\dataset-ClickExplore\xspace} \\\midrule
Low & 0.9061 $\pm$ 2.5227 & 3.1712 $\pm$ 4.2735 \\
Medium & 0.9746 $\pm$ 2.1249 & 3.1247 $\pm$ 3.3622 \\
High & 0.9356 $\pm$ 1.6159 & 2.4119 $\pm$ 2.4559 \\\bottomrule
\end{tabular}
\label{tab:impression}
\end{table}
\subsection{\dataset-Manual\xspace}
\label{sec:data:three}
Although click provides a strong implicit feedback signal for estimating the quality of models in online services, including search clarification, it does not necessarily reflect all quality aspects. In addition, it can be biased for many reasons. Therefore, a comprehensive study of clarification must include evaluation based on manual human annotations. This has motivated us to create and release \dataset-Manual\xspace based on manual judgements performed by trained annotators.
Therefore, we randomly sampled queries from the query logs to collect manual annotations for a set of realistic user queries. The queries satisfy all the privacy concerns reviewed in Section~\ref{sec:data:one}. We further used the same algorithm to generate one or more clarification pairs for each query. Each query-clarification pair was assigned to at least three annotators. The annotators have been trained to judge clarification panes by attending online meetings, reading comprehensive guidelines, and practicing. In the following, we describe each step in the designed Human Intelligence Task (HIT) for annotating a query-clarification pair. This guideline has been previously used in \cite{Zamani:2020:WWW,Zamani:2020:SIGIR}.
\subsubsection{Step I: SERP Review}
Similar to \citet{Aliannejadi:2019}, we first asked the annotators to skim and review a few pages of the search results returned by Bing. Since search engines try to diversify the result lists, this would enable the annotators to better understand the scope of the topic and different potential intents behind the submitted query. When completed, the users can move to the next step.
\subsubsection{Step II: Annotating the Clarifying Question Quality}
In this step, the annotators were asked to assess the quality of the given clarifying question independent of the candidate answers. Therefore, the annotation interface does not show the candidate answers to the annotators at this stage. Each clarifying question is given a label 2 (Good), 1 (Fair), or 0 (Bad). The annotators were given detailed definitions, guidelines, and examples for each of the labels. In summary, the guideline indicates that a Good clarifying question should accurately address and clarify different intents of the query. It should be fluent and grammatically correct. If a question fails in satisfying any of these factors but still is an acceptable clarifying question, it should be given a Fair label. Otherwise, a Bad label should be assigned to the question. Note that if a question contains sensitive or inappropriate content, it would have been flagged by the annotators and removed from the dataset. Note that in case of having a generic template instead of clarifying questions (i.e., ``select one to refine your search''), we do not ask the annotators to provide a question quality labels.
\subsubsection{Step III: Annotating the Candidate Answer Set Quality}
Once the clarifying question is annotated, the candidate answers would appear on the HIT interface. In this step, the annotators were asked to judge the overall quality of the candidate answer set. In summary, the annotation guideline indicates that the candidate answer set should be evaluated based on its usefulness for clarification, comprehensiveness, coverage, understandability, grammar, diversity, and importance order. A clear definition of each of these constraints has been mentioned in the guideline.
Note that the annotators have reviewed multiple pages of the result list in Step I and have been expected to know different possible intents of the query. Again, the labels are either 2 (Good), 1 (Fair), or 0 (Bad), and the candidate answers with sensitive or inappropriate contents have been removed from the dataset. If a candidate answer set satisfies all the aforementioned constraints, it should be given a Good label. While, the Fair label should be given to an acceptable candidate answer set that does not satisfy at least one of the constraints. Otherwise, the Bad label should be chosen. Note that since all the defined properties are difficult to satisfy with up to 5 candidate answers, the label Good is rarely chosen for a candidate answer set.
\begin{table*}[t]
\centering
\caption{The average and standard deviation of engagement levels and manual annotation labels per query length.}
\vspace{-0.3cm}
\renewcommand{\tabcolsep}{3pt}
\begin{tabular}{lllllllll}\toprule
\textbf{Query} & \multicolumn{2}{c}{\textbf{\dataset-Click\xspace}} & \multicolumn{2}{c}{\textbf{\dataset-ClickExplore\xspace}} & \multicolumn{4}{c}{\textbf{\dataset-Manual\xspace}} \\
\textbf{length} & \textbf{Freq.} & \textbf{Engagement} & \textbf{Freq.} & \textbf{Engagement} & \textbf{Freq.} & \textbf{Question quality} & \textbf{Answer set quality} & \textbf{Landing page quality} \\\midrule
1 & 52213 & 0.5158 $\pm$ 1.6546 & 26926 & 1.9508 $\pm$ 2.7098 & 1028 & 1.7347 $\pm$ 0.4415 & 1.0418 $\pm$ 0.3075 & 1.9750 $\pm$ 0.1251\\
2 & 160161 & 0.7926 $\pm$ 2.1548 & 70621 & 2.7965 $\pm$ 3.3536 & 942 & 1.4694 $\pm$ 0.4991 & 1.0085 $\pm$ 0.3827 & 1.9178 $\pm$ 0.2881\\
3 & 120821 & 1.0152 $\pm$ 2.4573 & 46070 & 3.1677 $\pm$ 3.5811 & 555 & 1.4667 $\pm$ 0.4989 & 0.9333 $\pm$ 0.4463 & 1.8021 $\pm$ 0.4816\\
4 & 51503 & 1.2196 $\pm$ 2.6980 & 16798 & 3.5397 $\pm$ 3.7492 & 199 & 1.3333 $\pm$ 0.4714 & 0.9698 $\pm$ 0.5103 & 1.8313 $\pm$ 0.41986\\
5 & 19893 & 1.4473 $\pm$ 2.9078 & 5755 & 4.0188 $\pm$ 3.8921 & 75 & 1.3846 $\pm$ 0.4865 & 1.0267 $\pm$ 0.5157 & 1.7847 $\pm$ 0.5291\\
6 & 6299 & 1.5785 $\pm$ 3.0318 & 1806 & 4.1877 $\pm$ 3.9642 & 15 & 1.0 $\pm$ 0.0 & 0.8 $\pm$ 0.5416 & 1.7 $\pm$ 0.4800\\
7 & 2424 & 1.6634 $\pm$ 3.0815 & 621 & 4.6715 $\pm$ 3.9861 & 13 & 1.0 $\pm$ 0.0 & 0.7692 $\pm$ 0.4213 & 1.7692 $\pm$ 0.5756\\
8 & 823 & 1.7618 $\pm$ 3.1575 & 264 & 4.2008 $\pm$ 3.9082 & 3 & N/A & 1.0 $\pm$ 0.0 & 1.8333 $\pm$ 0.2357\\
9 & 184 & 1.9620 $\pm$ 3.2959 & 52 & 4.1731 $\pm$ 3.8467 & 1 & N/A & 0.0 $\pm$ 0.0 & 2.0 $\pm$ 0.0\\
10+ & 41 & 2.0732 $\pm$ 3.4244 & 8 & 4.8750 $\pm$ 3.4799 & 1 & N/A & 1.0 $\pm$ 0.0 & 2.0 $\pm$ 0.0\\
\bottomrule
\end{tabular}
\label{tab:qlen}
\end{table*}
\subsubsection{Step IV: Annotating the Landing SERP Quality for Each Individual Candidate Answer}
\citet{Zamani:2020:WWW} recently performed a number of user studies related to search clarification. In their interviews, the participants mentioned that the quality of the secondary result page (after clicking on a candidate answer) perceived the usefulness of the clarification pane. Based on this observation, we asked the annotators to evaluate the quality of the secondary result page (or the landing result page) for the individual candidate answers one by one. Therefore, the annotators could click on each individual answer and observe the secondary result page in Bing. Since a SERP may contain multiple direct answers, entity cards, query suggestion, etc. in addition to the list of webpages, adopting ranking metrics based on document relevance, such as mean reciprocal rank (MRR) or normalized discounted cumulative gain (NDCG)~\cite{Jarvelin:2002}, is not desired to evaluate the overall SERP quality. Therefore, we again asked the annotators to assign a label 2 (Good), 1 (Fair), or 0 (Bad) to each landing SERP. A label Good should be chosen, if the correct answer to all possible information needs behind the selected candidate answer can be easily found in a prominent location in the page (e.g., an answer box on top of the SERP or the top three retrieved webpages). If the result page is still useful and contain relevant information, but finding the answer is not easy or is not on top of the SERP, the Fair label should be selected. Otherwise, the landing SERP should be considered as Bad.
\subsubsection{A Summary of the Collected Data}
Each HIT was assigned to at least three annotators. For each labeling task, we used majority voting to aggregate the annotation. In case of disagreements, the HIT was assigned to more annotators. The overall Fleiss’ kappa inter-annotator agreement is 63.23\%, which is considered as good.
Our annotations resulted in over 2.4k unique queries and over 2.8k query-clarification pairs. The statistics of the dataset is reported in \tablename~\ref{tab:stats}.
The data has been released in a tab-separated file format (TSV). The description of each column in the data is provided in \tablename~\ref{tab:labeldataformat}.
\section{Data Analysis}
\label{sec:analysis}
In this section, we provide a comprehensive analysis of the created datasets.
\subsection{Question Template Analysis}
\citet{Zamani:2020:WWW} showed that most search clarifications can be resolved using a small number of question templates. In our first set of analysis, we study the question templates in MIMICS\xspace and their corresponding statistics. We only focus on the templates with a minimum frequency of 100 in both \dataset-Click\xspace and \dataset-ClickExplore\xspace. We compute the average engagement level per clarifying question template for \dataset-Click\xspace and \dataset-ClickExplore\xspace. In addition, we compute the average question quality label per template for \dataset-Manual\xspace that has manual annotations. Note that engagement levels are in the $[0, 10]$ interval, while the manual annotation labels are in $[0, 2]$. The results are reported in \tablename~\ref{tab:templates}. The first general template is excluded in our manual annotations. According to the results, the last four templates (T4 - T7) have led to higher engagements compared to T1, T2, and T3 in both \dataset-Click\xspace and \dataset-ClickExplore\xspace. They are also generally less frequent in the dataset and more specific. In general, the exploration dataset has higher average engagements compared to \dataset-Click\xspace. The reason is that the number of query-clarification pairs with zero engagements in \dataset-Click\xspace are higher than those in \dataset-ClickExplore\xspace (see \tablename~\ref{tab:stats}).
\subsection{Analyzing Engagement Based on Clarification Impression}
As mentioned in Section~\ref{sec:data}, \dataset-Click\xspace and \dataset-ClickExplore\xspace contain a three-level impression label per query-clarification pair. The impression level is computed based on the number of times the given query-clarification pair has been presented to users. The impression level should have a correlation with the query frequency. We compute the average and standard deviation of engagements per impression level whose results are reported in \tablename~\ref{tab:impression}. According to the results, there is a negligible difference between the average engagements across impression levels. Given the engagements range (i.e., $[0, 10]$), the query-clarification pairs with high impressions in \dataset-ClickExplore\xspace have led to slightly lower average engagements.
\subsection{Analysis Based on Query Length}
In our third analysis, we study user engagements and manual quality labels with respect to query length. To this aim, we compute the query length by simply splitting the query using whitespace characters as delimiters. The results are reported in \tablename~\ref{tab:qlen}. According to the results on \dataset-Click\xspace and \dataset-ClickExplore\xspace, the average engagement increases as the queries get longer. By looking at the data one can realize that longer queries are often natural language questions, while short queries are keyword queries. Surprisingly, this is inconsistent with the manual annotations suggesting that single word queries have higher question quality, answer set quality, and also landing page quality (excluding the rare queries with less than 10 frequency in the dataset). This observation suggests that user engagement with clarification is not necessarily aligned with the clarification quality. The behavior of users who submit longer queries may differ from those who search with keyword queries.
\begin{table*}[t]
\centering
\caption{The average and standard deviation of engagement levels and manual annotation labels per number of candidate answers.}
\vspace{-0.3cm}
\renewcommand{\tabcolsep}{2pt}
\begin{tabular}{lllllllll}\toprule
\multirow{2}{*}{\textbf{\# answers}} & \multicolumn{2}{c}{\textbf{\dataset-Click\xspace}} & \multicolumn{2}{c}{\textbf{\dataset-ClickExplore\xspace}} & \multicolumn{4}{c}{\textbf{\dataset-Manual\xspace}} \\
& \textbf{Freq.} & \textbf{Engagement} & \textbf{Freq.} & \textbf{Engagement} & \textbf{Freq.} & \textbf{Question quality} & \textbf{Answer set quality} & \textbf{Landing page quality} \\\midrule
2 & 226697 & 0.9047 $\pm$ 2.3160 & 50474 & 2.8430 $\pm$ 3.3921 & 1083 & 1.3164 $\pm$ 0.4651 & 0.9751 $\pm$ 0.3775 & 1.8915 $\pm$ 0.3665\\
3 & 91840 & 0.9904 $\pm$ 2.4175 & 38619 & 3.0592 $\pm$ 3.5111 & 892 & 1.7513 $\pm$ 0.4323 & 0.9507 $\pm$ 0.2954 & 1.9129 $\pm$ 0.3101\\
4 & 42752 & 0.9276 $\pm$ 2.3505 & 29678 & 2.9157 $\pm$ 3.4395 & 453 & 1.6292 $\pm$ 0.4830 & 1.0088 $\pm$ 0.3816 & 1.9073 $\pm$ 0.2862\\
5 & 53073 & 0.9099 $\pm$ 2.3323 & 50150 & 2.8354 $\pm$ 3.4236 & 404 & 1.4741 $\pm$ 0.4993 & 1.1733 $\pm$ 0.5401 & 1.9168 $\pm$ 0.2832\\
\bottomrule
\end{tabular}
\label{tab:num_answerset}
\end{table*}
\subsection{Analysis Based on the Number of Candidate Answers}
As pointed out earlier, the number of candidate answers in the data varies between two and five. To demonstrate the impact of the number of candidate answers, we report the average and standard deviation of engagement levels and manual quality labels per number of candidate answers in \tablename~\ref{tab:num_answerset}. According to the results, there is a small difference between average engagements in both \dataset-Click\xspace and \dataset-ClickExplore\xspace datasets. The clarifications with three candidate answers have led to a slightly higher engagement than the rest. It is again in contrary to the manual quality labels; the clarifications with three candidate answers have obtained the lowest answer set quality label. On the other hand, the question quality of clarifications with three candidate answers is higher than the others. This highlights that the question quality may play a key role in increasing user engagements.
\begin{figure*}
\begin{subfigure}{.25\textwidth}
\centering
\includegraphics[width=\linewidth]{img/hist_entropy_ctr_2options_single.pdf}
\caption{\# candidate answers = 2}
\label{fig:sfig1}
\end{subfigure}%
\begin{subfigure}{.25\textwidth}
\centering
\includegraphics[width=\linewidth]{img/hist_entropy_ctr_3options_single.pdf}
\caption{\# candidate answers = 3}
\label{fig:sfig1}
\end{subfigure}%
\begin{subfigure}{.25\textwidth}
\centering
\includegraphics[width=\linewidth]{img/hist_entropy_ctr_4options_single.pdf}
\caption{\# candidate answers = 4}
\label{fig:sfig2}
\end{subfigure}%
\begin{subfigure}{.25\textwidth}
\centering
\includegraphics[width=\linewidth]{img/hist_entropy_ctr_5options_single.pdf}
\caption{\# candidate answers = 5}
\label{fig:sfig1}
\end{subfigure}%
\caption{The distribution of normalized entropy for the conditional clickthrough rates on candidate answers for the \dataset-Click\xspace dataset. For the sake of clarity and visualization, we exclude the clarification with no click and those with zero entropy.}
\label{fig:entropy:one}
\end{figure*}
\begin{figure*}
\begin{subfigure}{.25\textwidth}
\centering
\includegraphics[width=\linewidth]{img/hist_entropy_ctr_2options_multiple.pdf}
\caption{\# candidate answers = 2}
\label{fig:sfig1}
\end{subfigure}%
\begin{subfigure}{.25\textwidth}
\centering
\includegraphics[width=\linewidth]{img/hist_entropy_ctr_3options_multiple.pdf}
\caption{\# candidate answers = 3}
\label{fig:sfig1}
\end{subfigure}%
\begin{subfigure}{.25\textwidth}
\centering
\includegraphics[width=\linewidth]{img/hist_entropy_ctr_4options_multiple.pdf}
\caption{\# candidate answers = 4}
\label{fig:sfig2}
\end{subfigure}%
\begin{subfigure}{.25\textwidth}
\centering
\includegraphics[width=\linewidth]{img/hist_entropy_ctr_5options_multiple.pdf}
\caption{\# candidate answers = 5}
\label{fig:sfig1}
\end{subfigure}%
\caption{The distribution of normalized entropy for the conditional clickthrough rates on candidate answers for the \dataset-ClickExplore\xspace dataset. For the sake of clarity and visualization, we exclude the clarification with no click and those with zero entropy.}
\label{fig:entropy:two}
\end{figure*}
\subsection{Analyzing Click Entropy Distribution on Candidate Answers}
\dataset-Click\xspace and \dataset-ClickExplore\xspace both contain conditional click probability on each individual answer, i.e., the probability of clicking on each candidate answer assuming that the user interacts with the clarification pane. The entropy of this probabilistic distribution demonstrates how clicks are distributed across candidate answers. The entropy range depends on the number of candidate answers, therefore, we normalized the entropy values by the maximum entropy per the candidate answer size. The distribution for \dataset-Click\xspace and \dataset-ClickExplore\xspace are reported in Figures~\ref{fig:entropy:one} and \ref{fig:entropy:two}, respectively. Note that for the sake of visualization, these plots do not include clarifications with no click (i.e., the engagement level zero) and those with zero entropy. According to the plots, the number of peaks in the entropy distribution is aligned with the number of candidate answers. The entropy values where the histogram peaks suggest that in many cases there is a uniform-like distribution for $m$ out of $n$ candidate answers (for all values of $m$). Comparing the plots in \figurename~\ref{fig:entropy:one} with those in \figurename~\ref{fig:entropy:two} shoes that this finding is consistent across datasets.
\section{Introducing Research Problems Related to Search Clarification}
MIMICS\xspace enables researchers to study a number of research problems. In this section, we introduce these tasks and provide high-level suggestions for evaluating the tasks using MIMICS\xspace.
\subsection{Clarification Generation}
Clarification generation (including both clarifying question and candidate answers) is a core task in search clarification. Generating clarification from a passage-level text has been studied in the context of community question answering posts~\cite{Rao:2019}. It has lately attracted much attention in information seeking systems, such as search engines (similar to this study)~\cite{Zamani:2020:WWW} and recommender systems~\cite{Zhang:2018}. Previous work has pointed out the lack of large-scale training data for generating search clarification~\cite{Zamani:2020:WWW,Aliannejadi:2019}. MIMICS\xspace, especially the click data, provides an excellent resource for training clarification generation models.
Evaluating clarification generation models, on the other hand, is difficult. One can use MIMICS\xspace for evaluating the generated clarification models using metrics such as BLEU~\cite{Papineni:2002} and ROUGE~\cite{Lin:2003}. However, we strongly discourage this evaluation methodologies, as they poorly correlate with user satisfaction and clarification quality. Here is our recommendation for evaluating clarification generation models:
\begin{itemize}[leftmargin=*]
\item In case of access to production systems with real users, conducting online experiments (e.g., A/B tests) would be a reliable evaluation methodology and the models can be compared using user engagement measures, such as clickthrough rate.
\item Manual annotation of the generated clarifications based on carefully-defined criteria would be an alternative for clarification generation evaluation. Previously, \citet{Zamani:2020:WWW} used this evaluation methodologies. Researchers may adopt the annotation guideline presented in Section~\ref{sec:data:three} for designing their crowdsourcing HITs.
\end{itemize}
\subsection{Clarification Selection}
Since automatic offline evaluation of clarification generation models is difficult, clarification selection (or clarification re-ranking) can be considered as an auxiliary task to evaluate the quality of learned representations for clarification. In addition, as pointed out by \citet{Aliannejadi:2019}, information seeking systems can adopt a two stage process for asking clarification, i.e., generating multiple clarifications and selecting one. Selecting clarification has been previously studied in \cite{Zamani:2020:SIGIR,Aliannejadi:2019,Hashemi:2020:SIGIR}.
Researchers can benefit from MIMICS\xspace for both training and evaluating clarification selection models. In more detail, \dataset-ClickExplore\xspace contains multiple clarifications per query and can be directly used for evaluating clarification selection (or re-ranking) models. The other two datasets can be also used by drawing some negative samples that can be obtained either randomly or using a baseline model.
Ranking metrics, such as NDCG, can be used to evaluate clarification selection models. In addition, since only one clarification is often shown to the users, the average engagement of the selected clarification can be also chosen as an evaluation metric. Refer to \cite{Zamani:2020:SIGIR} for more information.
\subsection{User Engagement Prediction for Clarification}
A major task in search clarification is deciding whether to ask clarification, especially in search systems with limited-bandwidth interfaces. This problem can be cast to query performance prediction~\cite{Cronen-Townsend:2002,Carmel:2010}. In other words, clarification can be asked when the predicted performance for the given query is below a threshold. An alternative to query performance prediction for this task would be user engagement prediction. In more detail, if users enjoy interacting with clarification and find it useful, the system can decide to ask the clarification. Predicting user engagement has been previously studied in various contexts, such as social media and web applications~\cite{Lalmas:2014,Zamani:2015}, however, user engagement prediction for clarification is fundamentally different. \dataset-Click\xspace and \dataset-ClickExplore\xspace contain engagement levels in the $[0, 10]$ interval. Therefore, they can be directly used for predicting user engagements.
For evaluating user engagements prediction models for clarification, we recommend computing correlation between the predicted engagements and the actual observed engagement released in the datasets. Correlation has been also used for evaluating query performance prediction models~\cite{Carmel:2010}. Since we only release engagement levels, we suggest using both linear (e.g., Pearson's $\rho$) and rank-based (e.g., Kendall's $\tau$) correlation metrics.
In addition, mean square error or mean absolute error can be used for evaluating user engagement prediction methods.
\subsection{Re-ranking Candidate Answers}
Previous work has shown that the order of candidate answers in clarification matters~\cite{Zamani:2020:SIGIR}. MIMICS\xspace enables researchers to study the task of re-ranking candidate answers for a given pair of query and clarifying question. Experiments on both click data (\dataset-Click\xspace and \dataset-ClickExplore\xspace) and manual annotations would provide complementary evaluation for the task.
For evaluating the candidate answers re-ranking task, the manual annotations per individual answers based on their landing SERP quality can be used as graded relevance judgement. NDCG would be adopted as the evaluation metric. For evaluation using the click data, researchers should be careful about presentation bias in the data. Refer to \cite{Zamani:2020:SIGIR} for more detail. In summary, the candidate answers with higher ranks and longer text are more likely to attract clicks. This point should be considered prior to using the \dataset-Click\xspace and \dataset-ClickExplore\xspace for re-ranking candidate answers. Once this issue is addressed, the conditional click probabilities can be mapped to ordinal relevance labels and typical ranking metrics can be adopted for evaluation. One can also use cross-entropy between the predicted probability distribution for candidate answers and the actual conditional click distribution. The impression level can be also considered in the metric to compute a gain per query-clarification pair with respect to their impression. In more detail, the clarifications that are presented more often should be assigned higher weights.
\subsection{Click Models for Clarification}
Related to the re-ranking candidate answers task, it is important to design user models for their click behavior while interacting with clarification panes. \citet{Zamani:2020:SIGIR} showed that the existing click models that have primarily been designed for web search do not perform as expected for search clarification. The reason is that the assumptions made in the web search click models do not hold for search clarification. The \dataset-ClickExplore\xspace dataset contains many clarification pairs for a given query whose only differences are in the order of candidate answers. This allows researchers to train and evaluate click models for search clarification using \dataset-ClickExplore\xspace. The evaluation methodology used in \cite{Zamani:2020:SIGIR} is suggested for evaluating the task. In summary, it is based on predicting the click probability of swapping adjacent candidate answers. This approach has originally been used for evaluating click models in web search by \citet{Craswell:2008}. The cross-entropy would be an appropriate metric in this evaluation setup.
\subsection{Analyzing User Behavior in Search Clarification}
Although this paper provides several analyses based on search clarification quality in terms of both manual judgements and engagement levels, future work can benefit from \dataset-Click\xspace and \dataset-ClickExplore\xspace to conduct more in depth analysis of user behaviors while interacting with search clarification in the context of web search.
\section{Conclusions}
\label{sec:conclusions}
In this paper, we introduced MIMICS\xspace, a data collection for studying search clarification, which is an interesting and emerging task in the context of web search and conversational search. MIMICS\xspace was constructed based on the queries and interactions of real users, collected from the search logs of a major commercial web search engine. MIMICS\xspace consists of three datasets: (1) \dataset-Click\xspace includes over 400k unique queries with the associated clarification panes. (2) \dataset-ClickExplore\xspace is an exploration data and contains multiple clarification panes per query. It includes over 60k unique queries. (3) \dataset-Manual\xspace is a smaller dataset with manual annotations for clarifying questions, candidate answer sets, and the landing result page after clicking on individual candidate answers. We publicly released these datasets for research purposes.
We also conducted a comprehensive analysis of the user interactions and manual annotations in our datasets and shed light on different aspects of search clarification. We finally introduced a number of key research problems for which researchers can benefit from MIMICS\xspace.
In the future, we intend to report benchmark results for a number of standard baselines for each individual task introduced in the paper. We will release the results to improve reproducibility and comparison.
There exist a number of limitations in the released datasets. For instance, they only focus on the en-US market and do not contain personalized and session-level information. These limitations can be resolved in the future.
| {'timestamp': '2020-06-19T02:05:00', 'yymm': '2006', 'arxiv_id': '2006.10174', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10174'} | arxiv |
\section{Discussion on the SAFFRON Algorithm} \label{sec:saffron}
While the SAFFRON algorithm \cite{Lee15a} is based on sparse-graph codes, we find it most instructive to compare against the simplified singleton-only version \cite[Sec.~5.4]{Ald19}, as the more sophisticated version does not attain better scaling laws (though it may attain better constant factors).
Singleton-only SAFFRON is briefly outlined as follows. One forms $O(k \log k)$ ``bundles'' of tests of size $2 \log_2 n$ each, and assigns each item to any given bundle with probability $O\big(\frac{1}{k}\big)$. If a given item is assigned to a given bundle, then its $(\log_2 n)$-bit description is encoded into the first $\log_2 n$ tests (i.e., the item is included in the test if and only if its bit description contains a $1$ at the corresponding location), and its bit-wise complement is encoded into the last $\log_2 n$ tests. The following decoding procedure ensures the identification of any defective item for which there exists a bundle in which it is included without any other defective items:
\begin{itemize}
\item For each bundle, check whether the first $\log_2 n$ test outcomes equal the bit-wise negation of the second $\log_2 n$ outcomes.
\item If so, add the item with bit representation given by the first $\log_2 n$ outcomes into the defective set estimate.
\end{itemize}
Due to the first step, the second step will never erroneously be performed on a bundle without defective items, nor on a bundle with multiple defective items.
In \cite{Lee15a}, a decoding time of $O(k \log k \cdot \log n)$ is stated under the assumption that reading the $2 \log_2 n$ bits takes $O(\log n)$ time. However, if the associated $2 \log_2 n$ tests are stored in memory as two ``words'' of length $\log_2 n$ each, then a word-RAM model of computation only incurs $O(1)$ time per bundle, or $O(k \log k)$ time overall.
We also note that SAFFRON only requires $O(k \log k \cdot \log n)$ bits of storage, amounting to negligible storage overhead beyond the test outcomes themselves. This is because the only item indices stored are those added to the estimate of the defective set, and there are at most $k$ such indices (or $k \log_2 n$ bits) due to the fact that SAFFRON makes no false positives.
\section{Proof of Lemma \ref{lem:var_bound} (Mean and Variance Bounds)} \label{app:var}
For ease of notation, we leave the subscripts $(\cdot)_{\ell}$ implicit throughout the proof, but the associated conditioning is understood to apply to all probabilities, expectations, variance terms, and so on.
We first prove \eqref{eq:E_sum}. The event $\Dc_u$ occurs if $u$ is hashed into the same bin as any of the $k' \le k$ defective nodes. Since we are hashing into $\{1,\dotsc,Ck\}$ and the hash family is (at least) pairwise independent, each collision occurs with probability $\frac{1}{Ck}$. Hence, by the union bound, $u$ is in a positive test with probability at most $\frac{1}{C}$, and \eqref{eq:E_sum} follows from the assumption that there are at most $4k$ PD nodes and $C \ge 8$.
As for \eqref{eq:var_sum}, we first characterize $\cov[D_u,D_v]$, writing
\begin{align}
\cov[D_u,D_v]
&= \EE[D_u D_v] - \EE[D_u] \EE[D_v] \\
&= \PP[\Dc_u \cap \Dc_v] - \PP[\Dc_u]\PP[\Dc_v] \\
&= \PP[\Dc_u] + \PP[\Dc_v] - \PP[\Dc_u \cup \Dc_v] - \PP[\Dc_u]\PP[\Dc_v]. \label{eq:p_diff}
\end{align}
We proceed by bounding $\PP[\Dc_u]$ (the same bound holds for $\PP[\Dc_v]$) and $\PP[\Dc_u \cup \Dc_v]$ separately.
\paragraph*{Probability of the individual event} Fix a non-defective node $u$. Let $h(\cdot)$ denote the random hash function with output values in $\{1,\dotsc,Ck\}$, and for each defective node indexed by $i \in \{1,\dotsc,k'\}$ (where $k'$ is the total number of defective nodes at the level under consideration), let $B_i$ be the ``bad'' event that $h(i) = h(u)$. We apply the inclusion-exclusion principle, which is written in terms of the following quantities for $j = 1,\dotsc,k'$:
\begin{equation}
T_j = \sum_{1 < i_1 < \dotsc < i_j < k'} \PP[B_{i_1} \cap \dotsc \cap B_{i_j}].
\end{equation}
If the hash function is $(j+1)$-wise independent, this simplifies to
\begin{equation}
T_j = {k' \choose j} \Big(\frac{1}{Ck}\Big)^j.
\end{equation}
Hence, if the hash function is $(j_{\max}+1)$-wise independent for some $j_{\max}$, then the inclusion-exclusion principle gives
\begin{align}
\PP[\Dc_u]
&= \PP\bigg[\bigcup_{i=1,\dotsc,k'} B_i \bigg] \\
&\le \sum_{j=1}^{j_{\max}} (-1)^{j+1} T_j \label{eq:inc_exc0} \\
&= \sum_{j=1}^{j_{\max}} {k' \choose j} (-1)^{j+1} \Big(\frac{1}{Ck}\Big)^j \label{eq:inc_exc}
\end{align}
for odd-valued $j_{\max}$, and the reverse inequality for even-valued $j_{\max}$. Using the fact that $\sum_{j=1}^{k'} {k' \choose j} (-1)^{j+1} \big(\frac{1}{Ck}\big)^j = 1 - \big(1-\frac{1}{Ck}\big)^{k'}$, we can write \eqref{eq:inc_exc} as
\begin{equation}
\PP[\Dc_u] \le 1 - \Big(1-\frac{1}{Ck}\Big)^{k'} - \sum_{j_{\max}+1}^{k'} {k' \choose j} (-1)^{j+1} \Big(\frac{1}{Ck}\Big)^j. \label{eq:inc_exc2}
\end{equation}
The final term can then be bounded as follows in absolute value:
\begin{align}
\bigg| \sum_{j_{\max}+1}^{k'} {k' \choose j} (-1)^{j+1} \Big(\frac{1}{Ck}\Big)^j \bigg|
&\le \sum_{j_{\max}+1}^{k'} {k' \choose j} \Big(\frac{1}{Ck}\Big)^j \\
&\le \sum_{j_{\max}+1}^{\infty} \Big(\frac{1}{C}\Big)^j \label{eq:abs_bound2} \\
&= \frac{(1/C)^{j_{\max}+1}}{1-1/C}, \label{eq:abs_bound3}
\end{align}
where \eqref{eq:abs_bound2} uses ${k' \choose j} \le (k')^j$ and $k' \le k$, and \eqref{eq:abs_bound3} applies the geometric series formula. Assuming $C \ge 2$, we can further upper bound the above expression by $(1/C)^{j_{\max}}$, and hence by any target value $\delta_0$ provided that $j_{\max} \ge \log_{C}\frac{1}{\delta_0}$. Recall also that \eqref{eq:inc_exc2} is reversed for even-valued $j_{\max}$, so loosening the preceding requirement to $j_{\max} \ge \lceil \log_{C}\frac{1}{\delta_0} \rceil + 1$ gives
\begin{equation}
1 - \Big(1-\frac{1}{Ck}\Big)^{k'} - \delta_0 \le \PP[\Dc_u] \le 1 - \Big(1-\frac{1}{Ck}\Big)^{k'} + \delta_0. \label{eq:d0_deviation}
\end{equation}
Since $u$ is arbitrary, the same bound also holds for $\PP[\Dc_v]$.
\paragraph*{Probability of the union of two events} We can decompose $\PP[\Dc_u \cup \Dc_v]$ as follows:
\begin{align}
\PP[\Dc_u \cup \Dc_v]
&= \Big(1 - \frac{1}{Ck}\Big) \PP[\Dc_u \cup \Dc_v \,|\, h(u) \ne h(v)] + \frac{1}{Ck} \PP[\Dc_u \cup \Dc_v \,|\, h(u) = h(v)] \\
&= \PP[\Dc_u \cup \Dc_v \,|\, h(u) \ne h(v)] + O\Big( \frac{1}{k} \Big).
\end{align}
Hence, we focus on the case $h(u) \ne h(v)$ in the following. Similar to the above, let $B'_i$ be the ``bad'' event that $h(i) \in \{ h(u), h(v) \}$, and define
\begin{equation}
T'_j = \sum_{1 < i_1 < \dotsc < i_j < k'} \PP[B'_{i_1} \cap \dotsc \cap B'_{i_j} \,|\, h(u) \ne h(v)].
\end{equation}
If the hash function is $(j+2)$-wise independent, this simplifies to
\begin{equation}
T'_j = {k' \choose j} \Big(\frac{2}{Ck}\Big)^j,
\end{equation}
where the factor of two comes from the possibility of colliding with either $u$ or $v$. Following the same argument as above, we find that if (i) $j_{\max} \ge \lceil \log_{C/2}\frac{1}{\delta_0} \rceil + 1$, (ii) $C \ge 4$, and (iii) the hash function is $(j_{\max} + 2)$-wise independent, then the following analog of \eqref{eq:d0_deviation} holds:
\begin{equation}
1 - \Big(1-\frac{2}{Ck}\Big)^{k'} - \delta_0 \le \PP[\Dc_u \cup \Dc_v \,|\, h(u) \ne h(v)] \le 1 - \Big(1-\frac{2}{Ck}\Big)^{k'} + \delta_0. \label{eq:d0_deviation2}
\end{equation}
\paragraph*{Combining and simplifying} Setting $\delta_0 = \frac{1}{k}$ and combining the above findings, we deduce that for a $\Theta(\log k)$-wise independent hash,
\begin{gather}
\PP[\Dc_u] = 1 - \Big(1-\frac{1}{Ck}\Big)^{k'} + O\Big( \frac{1}{k} \Big), \\
\PP[\Dc_u \cup \Dc_v] = 1 - \Big(1-\frac{2}{Ck}\Big)^{k'} + O\Big( \frac{1}{k} \Big).
\end{gather}
The idea in the following is to approximate $1 - \frac{\nu}{Ck} \approx e^{-\frac{1}{Ck}}$ for $\nu=1,2$, and substitute into \eqref{eq:p_diff}. To make this more precise, we use the fact that $k' \le k$ to write
\begin{align}
\Big(1 - \frac{1}{Ck}\Big)^{k'}
&= \bigg( e^{-\frac{1}{Ck} + O\big( \frac{1}{k^2} \big)} \bigg)^{k'} \\
&= e^{-\frac{k'}{Ck} + O\big( \frac{1}{k} \big)} \\
&= e^{-\frac{k'}{Ck}} + O\Big( \frac{1}{k} \Big).
\end{align}
Applying a similar argument to $\big(1 - \frac{2}{Ck}\big)^{k'}$ and substituting into \eqref{eq:p_diff}, we obtain
\begin{align}
\cov[D_u,D_v]
&= 2\Big(1 - e^{-\frac{k'}{Ck}}\Big) - \Big(1 - e^{-\frac{2k'}{Ck}}\Big) - \Big(1 - e^{-\frac{k'}{Ck}}\Big)^2 + O\Big( \frac{1}{k} \Big) \\
&= O\Big( \frac{1}{k} \Big),
\end{align}
since the first three terms cancel upon expanding the square. The proof is concluded by writing
\begin{align}
\var\bigg[ \sum_{u} D_u \bigg] = \sum_{u} \var[D_u] + \sum_{u \ne v} \cov[D_u, D_v] = O(k)
\end{align}
since $\var[D_u] \le \EE[D_u] \le \frac{1}{C}$, and there are at most $4 k$ values of $u$ by assumption.
\section{Introduction} \label{sec:intro}
Group testing is a classical statistical problem with a combinatorial flavor \cite{Dor43,Du93,Ald19}, and has recently regained significant attention following new applications \cite{Ant11,Cli10,Cor05}, connections with compressive sensing \cite{Gil08,Gil07}, and most recently, utility in testing for COVID-19 \cite{Yel20,Hog20,Ver20}. The goal is to identify a defective (or infected) subset of items (or individuals) based on a number of suitably-designed tests, with the binary test outcomes indicating whether or not the test includes at least one defective item.
In both classical studies and recent works, considerable effort has been put into the development of group testing algorithms achieving a given recovery criterion with a near-optimal number of tests \cite{Mal78,Mal80,Du93,Ati12,Ald14a,Cha14,Joh16,Sca15b,Ald15,Coj19,Coj19a}, and many solutions are known with decoding time linear or slower in the number of items. In contrast, works seeking to further reduce the decoding time have only arisen more recently \cite{Che09,Ind10,Ngo11,Cai13,Lee15a,Ina19,Bon19a}; see Section \ref{sec:related} for an overview.
In this paper, we present a non-adaptive group testing algorithm that guarantees high-probability recovery of the defective set with $O(k \log n)$ scaling in both the number of tests and the decoding time in the case of $n$ items and $k$ defectives. By comparison, the best previous decoding time alongside $O(k \log n)$ tests was $O(k^2 \log k \cdot \log n)$ \cite{Bon19a}, with faster algorithms incurring suboptimal $O(k \log k \cdot \log n)$ scaling in the number of tests \cite{Cai13,Lee15a}. By a standard information-theoretic lower bound \cite[Sec.~1.4]{Ald19}, the $O(k \log n)$ scaling in the number of tests is optimal whenever $k \le n^{1-\Omega(1)}$.
Before outlining the related work and contributions in more detail, we formally introduce the problem.
\subsection{Problem Setup} \label{sec:setup}
We consider a set of $n$ items indexed by $\{1,\dotsc,n\}$, and let $S \subset \{1,\dotsc,n\}$ be the set of defective items. The number of defectives is denoted by $k = |S|$; this is typically much smaller than $n$, so we assume that $k \le \frac{n}{2}$. For clarity of exposition, we will present our algorithm and analysis for the case that $k$ is known, but these will trivially extend to the case that only an upper bound $\kbar \ge k$ is known, and $\kbar$ replaces $k$ in the number of tests and decoding time.
A sequence of $t$ tests $X^{(1)},\dotsc,X^{(t)}$ is performed, with $X^{(i)} \in \{0,1\}^n$ indicating which items are in the $i$-th test, and the resulting outcomes are $Y^{(i)} = \bigvee_{j \in S} X_j^{(i)}$ (i.e., $1$ if there is any defective item in the test, $0$ otherwise). We focus on the non-adaptive setting, in which all tests $X^{(1)},\dotsc,X^{(t)}$ must be designed prior to observing any outcomes.
We consider a for-each style recovery guarantee, in which the goal is to develop a randomized algorithm that, for any fixed defective set $S$ of cardinality $k$, produces an estimate $\Shat$ satisfying $\PP[\Shat \ne S] \le \delta$ for some small $\delta > 0$ (typically $\delta \to 0$ as $n \to \infty$). In our algorithm, only the tests $\{X^{(i)}\}_{i=1}^t$ will be randomized, and the decoding algorithm producing $\Shat$ from the test outcomes will be deterministic.
\subsection{Related Work} \label{sec:related}
The existing works on group testing vary according to the following defining features \cite{Du93,Ald19}:
\begin{itemize}
\item {\bf For-each vs.~for-all guarantees.} In {\em combinatorial (for-all) group testing}, one seeks to construct a test design that guarantees the recovery of {\em all} defective sets up to a certain size. In contrast, in {\em probabilistic (for-each) group testing}, the test design may be randomized, and the algorithm is allowed some non-zero probability of error.
\item {\bf Adaptive vs.~non-adaptive.} In the {\em adaptive} setting, each test may be designed based on all previous outcomes, whereas in the {\em non-adaptive setting}, all tests must be chosen prior to observing any outcomes. The non-adaptive setting is often preferable in practice, as it permits the tests to be performed in parallel.
\item {\bf Noiseless vs.~noisy.} In the {\em noiseless} setting, the test outcomes are perfectly reliable, whereas in {\em noisy settings}, some tests may be flipped according to some probabilistic or adversarial noise model.
\end{itemize}
As outlined in the previous subsection, our focus is on the for-each guarantee, non-adaptive testing, and noiseless tests, but for comparison, we also discuss other variants in this section.
\begin{table}
\begin{center}
\begin{tabular}{|>{\centering}m{2.8cm}|>{\centering}m{2.9cm}|>{\centering}m{3.2cm}|>{\centering}m{2.6cm}|}
\hline
\textbf{Reference} & \textbf{Number of tests} & \textbf{Decoding time} & \textbf{Construction}\tabularnewline
\hline
\hline
SAFFRON \cite{Lee15a} & $O(k\cdot\log k\cdot\log n)$ & $O(k\log k)$\footnotemark & Randomized\tabularnewline
\hline
GROTESQUE~\cite{Cai13} & $O(k\cdot\log k\cdot\log n)$ & $O(k\cdot\log k\cdot\log n)$ & Randomized\tabularnewline
\hline
Inan \emph{et al.}~\cite{Ina19} & $O\big(k\cdot\log n\cdot\log\frac{\log n}{\log k}\big)$ & $\ensuremath{O\big(k^{3}\cdot\log n\cdot\log\frac{\log n}{\log k}\big)}$ & Explicit\tabularnewline
\hline
BMC \cite{Bon19a} & $O(k\log n)$ & $O(k^2 \cdot\log k\cdot\log n)$ & Randomized\tabularnewline
\hline
{\bf This Paper} & $O(k\log n)$ & $O(k \log n)$ & Randomized\tabularnewline
\hline
\end{tabular}
\par\end{center}
\caption{Overview of existing noiseless non-adaptive group testing results with ${\rm poly}(k \log n)$ decoding time under the for-each guarantee, with $n$ items and $k$ defectives. \label{tbl:sublinear}} \vspace*{-3ex}
\end{table}
\footnotetext{The decoding time of SAFFRON is typically stated as
$O(k \log k \cdot \log n)$, but can be $O(k \log k)$ in the word-RAM
model of computation, where the test outcomes are stored as
$O(k \log k)$ words of length $\log_2 n$ each; see Appendix
\ref{sec:saffron} for details. \label{foot:saffron}}
By a simple counting argument, even in the least stringent scenario of noiseless adaptive testing and the for-each guarantee, $\Omega\big(k \log \frac{n}{k}\big)$ tests are required for reliable recovery \cite{Mal78,Bal13}. In the noiseless adaptive setting, the classical generalized binary splitting algorithm of Hwang \cite{Hwa72} matches this bound with sharp constant factors, and attains the stronger for-all guarantee. More recently, $O(k \log n)$ adaptive tests and decoding time were shown to suffice under the for-each guarantee in the presence of random noise \cite{Cai13}.
In the non-adaptive setting with the for-each guarantee, a recent of result of \cite{Ald18} shows that $n$ tests are required to attain asymptotically vanishing error probability as $n \to \infty$ with $k = \lfloor \beta n \rfloor$, for arbitrarily small $\beta > 0$. Thus, $O(k \log \frac{n}{k})$ scaling (with a universal implied constant) is impossible; see also \cite{Coj19a}. On the other hand, $O(k \log n)$ tests do suffice, and this scaling is equivalent to $O(k \log \frac{n}{k})$ in the regime $k \le n^{1-\Omega(1)}$. Early works
achieved this for the scaling regime $k = O(1)$
\cite{Mal78,Mal80,Ati12}, and a variety of more recent works
considered more general $k$
\cite{Mal78,Mal80,Ati12,Sca15b,Ald15,Joh16,Coj19,Coj19a}, particularly
under ``unstructured'' random test designs such as i.i.d.~Bernoulli
\cite{Ati12,Ald14a,Sca15b} and near-constant tests-per-item
\cite{Joh16,Coj19}. In fact, following the recent work of Coja-Oghlan
{\em et al.} \cite{Coj19a}, the precise constants for non-adaptive
group testing have been nailed down in the regime
$k \le n^{1-\Omega(1)}$, with the algorithm for the upper bound
requiring $\Omega(n)$ decoding time
\addtocounter{footnote}{-1}
Since non-adaptive algorithms with ${\rm poly}(k \log n)$ decoding time under the for-each guarantee are particularly relevant to the present paper, we provide a summary of the existing works in Table \ref{tbl:sublinear}. We separate our discussion according to whether or not each algorithm attains $O(k \log n)$ scaling in the number of tests, as we believe this to be a particularly important desiderata in practice when tests are expensive:
\begin{itemize}
\item SAFFRON and GROTESQUE both use $O(k\log k \cdot \log n)$ tests, which is suboptimal by a $\log k$ factor. In particular, SAFFRON's decoding time is as low as $O(k \log k)$ in the word-RAM model.\footnotemark~While storage requirements were not a significant point of focus in the existing works, we also note (for later comparison) that SAFFRON only requires $O(k\log k \cdot \log n)$ bits of storage; see Appendix \ref{sec:saffron} for details.
\item In the regime $k = \Theta(n^{\alpha})$ with fixed $\alpha \in (0,1)$, Inan {\em et al.}~\cite{Ina19} attain $O(k^3 \log n)$ decoding time with $O(k \log n)$ tests, whereas the number of tests becomes suboptimal in sparser regimes such as $k = {\rm poly}(\log n)$. The best previous decoding time for an algorithm that only uses $O(k \log n)$ tests is $O(k^2 \log k \cdot \log n)$, via bit-mixing coding (BMC) \cite{Bon19a}. To our knowledge, all other existing algorithms succeeding with $O(k \log n)$ tests incur $\Omega(n)$ decoding time \cite{Mal78,Mal80,Ati12,Sca15b,Ald15,Joh16,Coj19,Coj19a}.
\end{itemize}
Our main theoretical contribution is to provide an algorithm that attains $O(k \log n)$ scaling in both the number of tests and decoding time, as well as using distinct algorithmic ideas from the existing works (see Section \ref{sec:description} for discussion). In particular, among the algorithms using $O(k \log n)$ tests, ours reduces the dependence on $k$ in the decoding time from quadratic to linear.
It is worth noting that the works \cite{Cai13,Lee15a,Ina19,Bon19a} also extend their guarantees to noisy settings, and the approach in \cite{Ina19} has the additional advantage of using an {\em explicit} test design, i.e., the test vectors $X^{(1)},\dotsc,X^{(t)}$ can be constructed deterministically in time polynomial in $n$ and $t$. Although noisy and/or de-randomized variants of our algorithm may be possible, this is deferred to future work.\footnote{Our analysis can easily be adapted to handle false positive tests, but handling false negative tests appears to require more significant changes and a slightly increased decoding time. \label{foot:noise}}
In addition, \cite{Lee15a} demonstrated that $O\big( k \log n \cdot \log\frac{1}{\epsilon} \big)$ tests suffice for SAFFRON in the case that one is only required to identify a fraction $1 - \epsilon$ of the defectives, as opposed to the entire defective set. Thus, $O(k \log n)$ scaling is maintained for approximate recovery with constant $\epsilon > 0$, but not for the more common requirement of exact recovery.
While we have focused our discussion on the for-each setting, the first ${\rm poly}(k \log n)$-time non-adaptive group testing algorithms were for the more stringent for-all setting \cite{Che09,Ind10,Ngo11}.
The strength of the for-all guarantee comes at the expense of requiring significantly more tests, e.g., see \cite{Dya82} for an $\Omega\big(\min\big\{k^2 \frac{\log n}{\log k},n\big\}\big)$ lower bound. An $O(k^2 \log n)$ upper bound on the number of tests was originally attained with $\Omega(n)$ decoding time, \cite{Dya83,Por11}, and more recently with ${\rm poly}(k \log n)$ decoding time \cite{Ind10,Ngo11}. The earlier work of \cite{Che09} attained ${\rm poly}(k \log n)$ decoding time under a list decoding recovery criterion, and also allowed for adversarial noise in the test outcomes.
\subsection{Summary of Results} \label{sec:contr}
Before summarizing our main results, we briefly highlight that our algorithmic techniques are distinct from the existing works summarized above (see Section \ref{sec:description} for further details), and are more closely related to the adaptive binary splitting approach of Hwang \cite{Hwa72}. We first test large groups of items together, placing each group into a single randomly-chosen test among a sequence of $O(k)$ tests. We then ``split'' these groups into smaller sub-groups, while using the $O(k)$ test outcomes to eliminate those known to be non-defective. This process is repeated (with the elimination step ensuring that the number of groups under consideration does not grow too large) until a superset of $S$ is found. This superset is shown to be of size $O(k)$ with high probability, and $S$ is deduced from this superset via a final sequence of $O(k \log k)$ tests (similar ideas to this final step have appeared in works such as \cite{Che09,Ngo11}). Despite the sequential nature of this procedure, the tests can be performed non-adaptively.
Our first main result is informally stated as follows; see Theorem \ref{thm:main1} for a formal statement.
\begin{mainresult} \label{mr1}
{\em (Algorithmic Guarantees -- Informal Version)} There exists a non-adaptive group testing algorithm that, for any constant $c > 0$, succeeds with probability $1 - O(k^{-c})$ using $O(k \log n)$ tests and $O(k \log n)$ decoding time, and requires $O(n \log^2 k)$ bits of storage.
\end{mainresult}
Main Result \ref{mr1} uses $\Omega(n)$ storage to record
the random choices of tests the items are included in. For our second main result, we consider a low-storage variant in which the tests are instead allocated using
hash functions. In this case, the precise decoding time and storage
guarantees depend on the properties of the hash family used. The
following theorem informally states the guarantee resulting from
$O(\log k)$-wise independent hashing using the classical hash family
of Wegman and Carter \cite{Weg81}; see Theorem \ref{thm:main2} for a
formal and more general statement.
\begin{mainresult} \label{mr2}
{\em (Algorithmic Guarantees with Reduced Storage -- Informal Version)} There exists a non-adaptive group testing algorithm that, for any constant $c > 0$, succeeds with probability $1 - O\big(\frac{\log n}{k^c}\big)$ using $O(k \log n)$ tests and $O(k \log k \cdot \log n)$ decoding time, and requires $O(k \log n + \log k \cdot \log^2 n)$ bits of storage.
\end{mainresult}
\section{Non-Adaptive Binary Splitting Algorithm} \label{sec:alg_result}
In this section, we introduce our algorithm, and state and prove our main result giving guarantees on its correctness, number of tests, decoding time, and storage. For simplicity of notation, we assume throughout the analysis that $k$ and $n$ are powers of two. Our algorithm only requires an upper bound on the number of defectives, and hence, any other value of $k$ can simply be rounded up to a power of two. In addition, the total number of items $n$ can be increased to a power of two by adding ``dummy'' non-defective items.
\subsection{Description of the Algorithm} \label{sec:description}
\begin{figure}
\begin{centering}
\includegraphics[width=0.8\columnwidth]{DefectiveTree}
\par
\end{centering}
\caption{Example structure of groups of items that are tested together when $n = 16$ and $k =3$ (Left), and the corresponding tree representation (Right). Leaves correspond to single items, and nodes at the higher levels correspond to groups of items. \label{fig:tree}} \vspace*{-1.5ex}
\end{figure}
We propose an algorithm that works with a tree structure, as illustrated in Figure \ref{fig:tree}. On the left of the figure, we have $1+\log_2 n$ levels, with the top level containing all items, the second level containing two groups with half the items each, and so on, with each level ``splitting'' the previous levels' groups in half until the final level containing individual items. The ordering of items is inconsequential for our analysis and results provided that the two children of a given node can be identified in constant time, so for convenience we assume the natural order.\footnote{Alternatively, one may use a dyadic splitting approach: Assign each item a unique $(\log_2 n)$-bit string, and first split according to the first bit, then the second bit, and so on.} For $\ell = 0,\dotsc,\log_2 n$, the $j$-th group at the $\ell$-th level is denoted by $G^{(\ell)}_j \subseteq \{1,\dotsc,n\}$, and we observe that for fixed $\ell$, there are $2^{\ell}$ groups $G^{(\ell)}_1,\dotsc,G^{(\ell)}_{2^{\ell}}$ of cardinality $\frac{n}{2^{\ell}}$ each.
We consider the binary tree representation in Figure \ref{fig:tree} (Right), in which each node corresponds to a group of items (e.g., the root corresponds to the set of all items, and the leaves correspond to individual items). The levels of the tree are indexed by $\ell = 0,\dotsc,\log_2 n$. Our algorithm works down the tree one level at a time, keeping a list of {\em possibly defective} (PD) nodes, and performing tests to obtain such a list at the next level, while ideally keeping the size of the list small (e.g., $O(k)$). When we perform tests at a given level, we treat each node as a ``super-item''; including a node in a test amounts to including all of the items in the corresponding group $G^{(\ell)}_j$.
While this may appear to naturally lead to an adaptive algorithm, we can in fact perform all of the tests non-adaptively.
If we were to test nodes at the root or the early levels, they would almost all return positive, and hence not convey significant information. We therefore let the algorithm start at the level $\ell_{\min} = \log_2 k$, and we consider the following test design:
\begin{itemize}
\item For each $\ell = \log_2 k, \dotsc, \log_2 n - 1$, form a sequence of $C k$ tests (for some $C > 0$ to be selected later), and for each $j=1,\dotsc,2^{\ell}$, choose a single such test uniformly at random, and place all items from $G^{(\ell)}_j$ into that test
\item For the final level $\ell = \log_2 n$, each $G^{(\ell)}_j = \{j\}$ is a singleton. In this case, we form $C' \log k$ sequences of $2k$ tests (for some $C' > 0$). For each item, and each of the $C' \log k$ sequences of tests, we place the item in one of the $2k$ corresponding tests, chosen uniformly at random.
\end{itemize}
This creates a total of $t = Ck \log_2\frac{n}{k} + 2 C' k \log k = O(k \log n)$ tests.
Upon observing the $t$ non-adaptive test outcomes, the decoder forms an estimate $\Shat$ of the defective set via the following procedure:
\begin{itemize}
\item Initialize $\Gc^{(\ell_{\min})} = \{ G^{(\ell_{\min})}_j \}_{j=1}^{k}$, where $\ell_{\min} = \log_2 k$;
\item Iterate the following for $\ell = \log_2 k,\dotsc,\log_2 n - 1$:
\begin{itemize}
\item For each group $G \in \Gc^{(\ell)}$, check whether the single test corresponding to that group is positive or negative. If positive, then add both children of $G$ (see Figure \ref{fig:tree}) to $\Gc^{(\ell+1)}$.
\end{itemize}
\item Let the estimate $\Shat$ of the defective set be the (singleton) elements of $\Gc^{(\log_2 n)}$ that are not included in any negative test among the $2C' k \log k$ tests at the final level.
\end{itemize}
\paragraph*{Comparisons with existing methods} Our algorithm is distinct from existing sublinear-time non-adaptive group testing algorithms, which are predominantly based on code concatenation \cite{Ind10,Ngo11} or related methods that encode item indices' binary representations directly into the test matrix \cite{Cai13,Lee15a,Bon19}. In fact, in the context of group testing, our approach is perhaps most reminiscent of the {\em adaptive} algorithm of Hwang \cite{Hwa72} (see also \cite{Du93,Ald19}), which identifies one defective at a time using binary splitting, removing each defective from consideration after it is identified. By keeping track of the multiple defective nodes simultaneously and allowing a small number of false positives up to the final level, we are able to exploit similar ideas without requiring adaptivity.
Beyond group testing and binary splitting, this recursive
tree-structured approach is also reminiscent of ideas used in
sketching algorithms, such as dyadic tree recovery for count-min
sketch~\cite{Cor05a}. Our particular approach---maintaining a
superset at each level, and relying on a lack of false negatives---is
most similar to the pyramidal reconstruction method for compressive
sensing under the earth mover's distance~\cite{Ind11}.
A nearly identical algorithm to ours was given independently in the concurrent work of \cite{Che20}, with similar theoretical guarantees. In addition, \cite{Che20} observes that since the total number of non-discarded nodes in the algorithm is $O\big(k \log \frac{n}{k}\big)$ with overwhelming probability (see Lemma \ref{lem:Ntotal_hp} below), one can take a union bound over the $n \choose k$ possible defective sets to attain \emph{list recovery} in the combinatorial (for-all) setting. This idea allows the authors of \cite{Che20} to attain a variety of other results, including in the related problems of heavy hitters and compressive sensing. In the context of probabilistic (for-each) group testing, some slight advantages of our analysis include (i) proving that the first batch of tests leads to $O(k)$-size list recovery rather than $O\big(k \log \frac{n}{k}\big)$-size, thus circumventing the need for a third batch of tests, and (ii) only requiring $O(\log k)$-wise independence in our low-storage variant based on hashing (see Section \ref{sec:storage}), rather than $O\big(k \log \frac{n}{k}\big)$-wise independence (albeit at the expense of a higher error probability).
\subsection{Algorithmic Guarantees} \label{sec:main_result}
In the following, we provide the formal version of Main Result \ref{mr1}. Here and subsequently, we assume a word-RAM model of computation; for instance, with $n$ items and $t$ tests, it takes constant time to read a single integer in $\{1,\dotsc,n\}$ from memory, perform arithmetic operations on such integers, fetch a single test outcome indexed by $\{1,\dotsc,t\}$, and so on.
\begin{theorem} \label{thm:main1}
{\em (Algorithmic Guarantees)} Let $S$ be a fixed (defective) subset of $\{1,\dotsc,n\}$ of cardinality $k$. For any constant $c > 0$, there exist choices of $C$ and $C'$ such that the group testing algorithm described in Section \ref{sec:description} satisfies the following with probability $1 - O(k^{-c})$:
\begin{itemize}
\item The returned estimate $\Shat$ equals $S$;
\item The algorithm runs in time $O(k \log n)$;
\item The algorithm uses $O(n (\log k)^2)$ bits of storage.
\end{itemize}
In addition, the number of tests scales as $O(k \log n)$.
\end{theorem}
We note that the success probability approaches one as $n \to \infty$ in any asymptotic regime satisfying $k = \omega(1)$, but not in the regime $k = O(1)$; the same is true in the existing works listed in Table \ref{tbl:sublinear}, with the exception of \cite{Bon19a}. In addition, it is straightforward to improve the success probability to $1 - e^{-\Omega(k)} - O(n^{-c})$ by using $O(\log n)$ (rather than $O(\log k)$) sequences of $2k$ tests at the final level.
Theorem \ref{thm:main1} is proved in the remainder of the section. We emphasize that our focus is on scaling laws, and we make no significant effort to optimize the underlying constant factors.
\subsection{Analysis} \label{sec:analysis}
Throughout the analysis, the defective set $S$ will be fixed but otherwise arbitrary, and we will condition on fixed placements of the defective items into tests (and hence, fixed test outcomes). The test placements of the non-defective items are independent of those of the defectives, and our analysis will hold regardless of which particular tests the defectives were placed in. We use $\PP[\cdot \,|\, \Tc_S]$ to represent this conditioning, and we refer to $\Tc_S$ as the defective test placements. In addition, for the tree illustrated in Figure \ref{fig:tree}, we refer to nodes containing defective items as defective nodes, to all other nodes as non-defective nodes, and to the set of defective nodes as the defective (sub-)tree.\footnote{Since we start at level $\ell_{\min} = \log_2 k$, this could more precisely be considered as a forest.}
We begin with the following simple lemma.
\begin{lemma} \label{lem:marking}
{\em (Probabilities of Non-Defectives Being in Positive Tests)} Under the test design described in Section \ref{sec:description}, the following holds at any given level $\ell = \log_2 k, \dotsc, \log_2 n - 1$: Conditioned on any defective test placements $\Tc_S$, any given non-defective node at level $\ell$ has probability at most $\frac{1}{C}$ of being placed in a positive test.
\end{lemma}
\begin{proof}
Since there are $k$ defective items, at most $k$ nodes at a given level can be defective, and since each node is placed in a single test, at most $k$ tests out of the $Ck$ tests at the given level can be positive. Since the test placements are independent and uniform, it follows that for any non-defective node, the probability of being in a positive test is at most $\frac{1}{C}$.
\end{proof}
In view of this lemma, when starting at any non-defective child of any given defective node (or alternatively, starting at a non-defective node at level $\ell_{\min}$), we can view any further branches down the non-defective sub-tree as ``continuing'' (i.e., the two children remain ``possibly defective'') with probability at most $\frac{1}{C}$. Hence, we have the following.
\begin{lemma} \label{lem:reach}
{\em (Probability of Reaching a Non-Defective Node)} Under the setup of Lemma \ref{lem:marking}, any given non-defective node having $\Delta$ non-defective ancestor nodes is reached (i.e., all of its ancestor nodes are placed in positive tests, so the node is considered possibly defective) with probability at most $\big( \frac{1}{C} \big)^{\Delta}$.
\end{lemma}
We will use the preceding lemmas to control the following two quantities:
\begin{itemize}
\item $N_{\rm total}$, the total number of non-defective nodes that are reached in the sense of Lemma \ref{lem:reach};
\item $N_{\rm leaf}$, the number of non-defective leaf nodes that are reached, and thus are still considered possibly defective by the final level.
\end{itemize}
It will be useful to upper bound $N_{\rm total}$ for the purpose of controlling the overall decoding time, and to upper bound $N_{\rm leaf}$ for the purpose of controlling the number of items considered at the final level.
\subsubsection{Bounding $N_{\rm total}$ and $N_{\rm leaf}$ on average} \label{sec:bound_avg}
We first present two lemmas bounding the averages of $N_{\rm total}$ and $N_{\rm leaf}$, and then establish high-probability bounds.
\begin{lemma} \label{lem:Ntotal_avg}
{\em (Bounding $N_{\rm total}$ on Average)} For any $C \ge 4$ and any defective test placements $\Tc_S$, we have
\begin{equation}
\EE[ N_{\rm total} \,|\, \Tc_S ] \le 6 k \log_2\frac{n}{k}.
\end{equation}
\end{lemma}
\begin{proof}
Since the tree is binary, each defective node can have at most $2^{i}$ non-defective descendants appearing exactly $i$ levels further down the tree; such descendants correspond to $\Delta = i-1$ in Lemma \ref{lem:reach}. Since there are at most $k \log_2\frac{n}{k}$ defective nodes, it follows that there are at most $\big( k \log_2\frac{n}{k} \big) 2^{\Delta+1}$ non-defective nodes with $\Delta$ non-defective ancestors and at least one defective ancestor. Similarly, there are at most $k$ non-defective nodes at level $\ell_{\min} = \log_2 k$, each of which has at most $2^\Delta$ non-defective nodes appearing $\Delta$ levels later.
Since Lemma \ref{lem:reach} demonstrates a probability $\big( \frac{1}{C} \big)^{\Delta}$ of being reached for a given number $\Delta$ of non-defective ancestors, it follows that
\begin{equation}
\EE[ N_{\rm total} \,|\, \Tc_S ] \le \Big( k \log_2\frac{n}{k}\Big) \sum_{\Delta = 0}^{\log_2\frac{n}{k}-1} 2^{\Delta+1} \Big( \frac{1}{C} \Big)^{\Delta} + k\sum_{\Delta = 0}^{\log_2\frac{n}{k}} 2^{\Delta} \Big( \frac{1}{C} \Big)^{\Delta}.
\end{equation}
Hence, the assumption $C \ge 4$ gives
\begin{equation}
\EE[ N_{\rm total} \,|\, \Tc_S ] \le \Big( 2 k \log_2\frac{n}{k}\Big) \sum_{\Delta = 0}^{\log_2\frac{n}{k}-1} 2^{- \Delta} + k\sum_{\Delta = 0}^{\log_2\frac{n}{k}} 2^{- \Delta} \le 6 k \log_2\frac{n}{k}, \label{eq:simplifications}
\end{equation}
where we used $\sum_{\Delta=0}^{\infty} 2^{-\Delta} = 2$ and $\log_2 \frac{n}{k} \ge 1$ (for $k \le \frac{n}{2}$).
\end{proof}
\begin{lemma} \label{lem:Nleaf_avg}
{\em (Bounding $N_{\rm leaf}$ on Average)}
For any $C \ge 4$ and any defective test placements $\Tc_S$, we have
\begin{equation}
\EE[ N_{\rm leaf} \,|\, \Tc_S ] \le 6 k.
\end{equation}
\end{lemma}
\begin{proof}
Again using the fact that each defective node can have at most $2^{i}$ descendants appearing $i$ levels further down the tree, we find that there are at most $k 2^{\Delta+1}$ leaf nodes with $\Delta$ non-defective ancestors and at least one defective ancestor. In addition, a leaf having only non-defective ancestors corresponds to $\Delta = \log_2\frac{n}{k}$ in Lemma \ref{lem:reach} (since $\ell_{\min} = \log_2 k$), and to handle this case, we trivially upper bound he number of leaves by $n$. Hence, for $C \ge 4$, we have similarly to \eqref{eq:simplifications} that
\begin{equation}
\EE[ N_{\rm leaf} \,|\,\Tc_S ] \le 2 k \sum_{\Delta = 0}^{\log_2\frac{n}{k} -1} 2^{\Delta} \Big( \frac{1}{C} \Big)^{\Delta } + n\Big( \frac{1}{C} \Big)^{\log_2\frac{n}{k}} \le 6k. \label{eq:avg_leaf}
\end{equation}
\end{proof}
\subsubsection{Bounding $N_{\rm total}$ with high probability} \label{sec:bound_Ntotal}
In this subsection, we prove the following.
\begin{lemma} \label{lem:Ntotal_hp}
{\em (High-Probability Bound on $N_{\rm total}$)} For any $C \ge 16$, conditioned on any defective test placements $\Tc_S$, we have $N_{\rm total} = O\big( k \log\frac{n}{k} \big)$ with probability $1-e^{-\Omega(k \log \frac{n}{k})}$.
\end{lemma}
To prove this result, we make use of Lemmas \ref{lem:marking} and \ref{lem:Ntotal_avg}, along with the following auxiliary result written in generic notation.
\begin{lemma} \label{lem:branching}
{\em (Sub-Exponential Behavior in a Branching Process)} Consider an infinite-depth binary tree in which each node is independently assigned a value $\{0,1\}$ with probability $q$ of being $1$, and let $N$ be the number of nodes whose ancestors are all marked as $1$. Then, when $q \le \frac{1}{16}$, we have all $n > 0$ that $\PP[N = n] \le 2^{-(n-1)}$.
\end{lemma}
\begin{proof}
We make use of branching process theory \cite[Ch.~XII]{Fel57}, in particular noting that $N$ equals the {\em total progeny} \cite{Dwa69} when the initial population size is $1$ (i.e., the root) and the distribution of the number of children per node is given by
\begin{equation}
P_X(0) = 1-q, \quad P_X(2) = q, \quad P_X(x) = 0,\, \forall x \notin \{0,2\}.
\end{equation}
The results we use from branching process theory are expressed in terms of the generative function $M_X(s) = \EE[s^X]$, which is given by
\begin{equation}
M_X(s) = (1-q) + qs^2. \label{eq:MX}
\end{equation}
It is evident in our case that $N < \infty$ with probability one provided that $q < \frac{1}{2}$, and one way to formally prove this is to utilize the general result that the {\em extinction probability} $\PP[N < \infty]$ equals one provided that the smallest root of $s = M_X(s)$ is $s=1$ \cite[Sec.~XII.4]{Fel57}.
We utilize an exact expression for the distribution of $N$ for general branching processes \cite{Dwa69} (specialized to the case that the initial population size is one):
\begin{equation}
\PP[N = n] = \frac{1}{n} m_{n-1}^{(n)}, \label{eq:p_branching}
\end{equation}
where $m_{n-1}^{(n)}$ is computed according to the expansion
\begin{equation}
\big( M_X(s) \big)^n = \sum_{j=0}^{\infty} m_j^{(n)} s^j. \label{eq:Mxn}
\end{equation}
Substituting our expression \eqref{eq:MX} for $M_X(s)$ on the left-hand side, we find that $(M_X(s))^n = \big( (1-q) + qs^2 \big)^n$, which equals $\sum_{i=0}^n {n \choose i} (1-q)^{n-i} (qs^2)^i$ by a binomial expansion. Hence, we obtain $m_{n-1}^{(n)} = 0$ for even-valued $n$, and for odd-valued $n$ we substitute $i = \frac{n-1}{2}$ to obtain
\begin{align}
m_{n-1}^{(n)}
&= {n \choose \frac{n-1}{2}} (1-q)^{\frac{n+1}{2}} q^{\frac{n-1}{2}} \\
&\le 2 (2 \sqrt{q})^{n-1}, \label{eq:mn3}
\end{align}
where we applied ${n \choose \frac{n-1}{2}} \le 2^n = 2 \cdot 2^{n-1}$ and $(1-q)^{\frac{n+1}{2}} \le 1$.
Substituting \eqref{eq:mn3} into \eqref{eq:p_branching}, we obtain
\begin{equation}
\PP[N = n] \le \frac{2}{n} \big( \sqrt{4q} \big)^{n-1} \openone\{n \text{ is odd}\}. \label{eq:pN}
\end{equation}
This implies $\PP[N = n] \le 2^{-(n-1)}$ when $q \le \frac{1}{16}$ and $n \ge 2$, and the same trivially holds when $n=1$.
\end{proof}
The condition $\PP[N = n] \le 2^{-(n-1)}$ in Lemma \ref{lem:branching} implies that $N$ is a sub-exponential random variable, and the same trivially follows for a branching process that only runs up to a certain depth (number of generations).
In the group testing setup of Lemma \ref{lem:Ntotal_hp}, we are adding together $O\big( k \log\frac{n}{k} \big)$ independent copies of such random variables (each corresponding to a different non-defective sub-tree) to get $N_{\rm total}$. As a result, we can apply a standard concentration bound for sums of independent sub-exponential random variables \cite[Prop.~5.16]{Ver10} to obtain
\begin{equation}
\PP[ N_{\rm total} \ge \EE[N_{\rm total}\,|\,\Tc_S] + t \,|\, \Tc_S] \le e^{-\Omega(\min\{ t^2/(k\log_2\frac{n}{k}), t \})}, \label{eq:total_conc}
\end{equation}
from which Lemma \ref{lem:Ntotal_hp} follows by setting $t = \Theta\big(k \log_2\frac{n}{k}\big)$ and using $\EE[N_{\rm total}\,|\,\Tc_S] = O\big(k \log_2\frac{n}{k}\big)$ (see Lemma \ref{lem:Ntotal_avg}). The condition $C \ge 16$ coincides with $q \le \frac{1}{16}$ in Lemma \ref{lem:branching}.
\subsubsection{Bounding $N_{\rm leaf}$ with high probability} \label{sec:bound_Nleaf}
In this subsection, we prove the following.
\begin{lemma} \label{lem:Nleaf_hp}
{\em (High-Probability Bound on $N_{\rm leaf}$)}
For any $C \ge 12$, conditioned on any defective test placements $\Tc_S$, we have $N_{\rm leaf} = O(k)$ with probability $1-e^{-\Omega(k)}$.
\end{lemma}
We again use Lemma \ref{lem:marking}, along with the following auxiliary results written in generic notation.
\begin{lemma} \label{lem:leaf_tail}
{\em (Tail Bound on Binary Tree Paths)}
Consider a binary tree of height $h$ in which each node is independently assigned a value $\{0,1\}$ with probability $q$ of being $1$, and let $N_h$ be the number of leaf nodes that have a path of $1$'s back to the root (including both endpoints). Then $\PP[N_h \ge t] \le 4^{-(h+t)}$ for any integer $t \ge 1$.
\end{lemma}
\begin{proof}
We use a proof by induction. The base case is $h=1$, in which case we have $\PP[N_h > 2] = 0$, $\PP[N_h = 2] = \frac{1}{q^3}$, and $\PP[N_h \ge 1] \le \frac{2}{q^2}$ by the union bound. These bounds satisfy the claim of the lemma due to the assumption $q \le \frac{1}{12}$.
Now fix $h \ge 2$ and suppose that the claim is true for height $h-1$. Let $L$ and $R$ be the number of leaf nodes reached in the left and right sub-trees of the root, and observe that
\begin{align}
\PP[N_h \ge t]
&\le \sum_{j=0}^t \PP[L \ge j \cap R \ge t-j] \\
&= \PP[L \ge t] + \PP[R \ge t] + \sum_{j=1}^{t-1} \PP[L \ge j \cap R \ge t-j]. \label{eq:splitLR}
\end{align}
Applying the induction hypothesis, we find that the first two terms are at most $q 4^{-(h-1+t)} = 4q \cdot 4^{-(h+t)}$, and for $1 \le j \le t-1$, we have $\PP[L \ge j \cap R \ge t-j] \le q \cdot 4^{-(h-1+j)} \cdot 4^{-(h-1+t-j)} = 16 q \cdot 4^{-(2h+t)}$, where the multiplications by $q$ correspond to the root node being marked as $1$. Substituting back into \eqref{eq:splitLR} gives
\begin{equation}
\PP[N_h \ge t] \le 8q 4^{-(h+t)} + 16 q t 4^{-(2h+t)}.
\end{equation}
We may assume that $t \le 2^{h}$, since for $t > 2^{h}$ we trivially have $\PP[N_h \ge t] = 0$. Hence, the above bound simplifies to
\begin{equation}
\PP[N_h \ge t] \le 8q 4^{-(h+t)} + 16 q 4^{-(h+t)} 2^{-h} \le 4^{-(h+t)},
\end{equation}
since $h \ge 2$ implies $2^{-h} \le \frac{1}{4}$, and we have assumed $q \le \frac{1}{12}$.
\end{proof}
\begin{lemma} \label{lem:leaf_subexp}
{\em (Sub-Exponential Behavior for Binary Tree Paths)}
Under the setup of Lemma \ref{lem:leaf_tail}, $N_h$ satisfies $\EE[e^{\lambda N_h}] \le 1 + 4^{-h}$ for $\lambda \le \log 2$. In addition, for any integer $h_{\max} \ge 1$, if $N_1,\dotsc,N_{h_{\max}}$ are independent random variables with the same distribution as $N_h$ for the specified height, then $N = \sum_{h=1}^{h_{\max}} N_h$ satisfies $\EE[e^{\lambda N}] \le 2$ for $\lambda \le \log 2$.
\end{lemma}
\begin{proof}
We seek to upper bound $\EE[e^{\lambda N_h}] = \sum_{t=0}^{\infty}\PP[N_h = t] e^{\lambda t}$. Separating out the $t=0$ term and applying Lemma \ref{lem:leaf_tail}, we obtain $\EE[e^{\lambda N_h}] \le 1 + \sum_{t=1}^{\infty}4^{-(h+t)}e^{\lambda t} = 1 + 4^{-h}\sum_{t=1}^{\infty}e^{(\lambda - \log 4)t} = 1 + 4^{-h} \cdot \frac{e^{\lambda}}{4 - e^{\lambda}}$ for $\lambda \in [0,\log4)$. In particular, if $\lambda \le \log 2$, then $\EE[e^{\lambda N_h}] \le 1 + 4^{-h}$.
For the second part, we again consider $\lambda \le \log 2$, and use the independence assumption to write $\EE[e^{\lambda N}] = \prod_{h=1}^{h_{\max}} \EE[e^{\lambda N_h}] \le \prod_{h=1}^{h_{\max}}\big( 1 + 4^{-h}\big) \le e^{\sum_{h=1}^{h_{\max}} 4^{-h} } \le e^{1/3} \le 2$.
\end{proof}
We now consider the following decomposition of $N_{\rm leaf}$:
\begin{equation}
N_{\rm leaf} = N'_{\rm leaf} + N''_{\rm leaf}, \label{eq:N_decomp}
\end{equation}
where $N'_{\rm leaf}$ counts the reached non-defective leaf nodes having at least one defective ancestor, and $N''_{\rm leaf}$ counts the reached non-defective leaf nodes having all non-defective ancestors.
In the case of a single defective item (i.e., $k=1$), we claim that $N'_{\rm leaf}$ has the same distribution as $2N$, with $N$ given in Lemma \ref{lem:leaf_subexp} for a suitably-chosen value of $h_{\max}$ and $q = \frac{1}{C}$. To see this, we identify the leaf nodes in Lemma \ref{lem:leaf_subexp} with nodes at the {\em second-last} level of the tree illustrated in Figure \ref{fig:tree}, and observe that the factor of $2$ arises since every such node produces two children at the final level (hence contributing to $N'_{\rm leaf}$) when placed in a positive test.
In the case of $k$ defective items, some care is needed, as the relevant sets of leaves associated with the $k$ defective paths may overlap, potentially creating complicated dependencies between the associated random variables. However, if we take the definition of $N$ in Lemma \ref{lem:leaf_subexp} and remove some leaves from the count, the quantity $\EE[e^{\lambda N}]$ can only decrease further, so the conclusion $\EE[e^{\lambda N}] \le 2$ remains valid.
Hence, by counting any overlapping leaves only once (in an otherwise arbitrary manner), we can form $k$ independent random variables $N^{(1)},\dotsc,N^{(k)}$ satisfying $2\sum_{i=1}^k N^{(i)} \stackrel{\rm d}{=} N'_{\rm leaf}$ and $\EE[e^{\lambda N^{(i)}}] \le 2$. In addition, since there are $k$ nodes at level $\ell_{\min} = \log_2 k$, we can similarly form $k' \le k$ independent random variables $N^{(k+1)},\dotsc,N^{(k+k')}$ satisfying $\sum_{i=k+1}^{k+k'} N^{(i)} \stackrel{\rm d}{=} N''_{\rm leaf}$ and $\EE[e^{\lambda N^{(i)}}] \le 2$.
Thus, by \eqref{eq:N_decomp}, $N_{\rm leaf}$ is the sum of at most $2k$ independent sub-exponential random variables. Again applying a standard concentration bound \cite[Prop.~5.16]{Ver10}, it follows that
\begin{equation}
\PP[ N_{\rm leaf} \ge \EE[N_{\rm leaf}\,|\,\Tc_S] + t \,|\, \Tc_S] \le e^{-\Omega(\min\{ t^2/k, t \})}, \label{eq:leaf_conc}
\end{equation}
from which Lemma \ref{lem:Nleaf_hp} follows upon setting $t = \Theta(k)$ and using the fact that $\EE[N_{\rm leaf}\,|\,\Tc_S] = O(k)$ (see Lemma \ref{lem:Nleaf_avg}).
\subsubsection{Analysis of the final level} \label{sec:final_level}
Recall that at the final level, we perform $C' \log k$ independent sequences of $2k$ tests, with each item being randomly placed in one test in each sequence. We study the error probability conditioned on the high-probability event that $N_{\rm leaf} = O(k)$ (see Lemma \ref{lem:Nleaf_hp})
For a given non-defective item and a given sequence of $2k$ tests, the probability of colliding with any defective item is at most $\frac{1}{2}$, similarly to Lemma \ref{lem:marking}. Due to the $C' \log k$ repetitions, for any fixed $c' > 0$, there exists a choice of $C'$ yielding $O(k^{-c'})$ probability of a given non-defective appearing only in positive tests. By a union bound over the $N_{\rm leaf} = O(k)$ non-defectives at the final level, we find that the estimate $\Shat$ equals $S$ with (conditional) probability $1 - O(k^{1-c'})$.
\subsubsection{Number of tests, error probability, decoding time, and storage} \label{sec:numbers}
The claims of Theorem \ref{thm:main1} are established as follows:
\begin{itemize}
\item {\em Number of tests:} As stated in Section \ref{sec:description}, the number of tests is $t = Ck \log_2\frac{n}{k} + 2 C' k \log k$, which behaves as $O\big( k \log \frac{n}{k} + k \log k \big) = O(k \log n)$.
\item {\em Error probability}: The concentration bounds on $N_{\rm leaf}$ and $N_{\rm total}$ (see Lemmas \ref{lem:Ntotal_hp} and \ref{lem:Nleaf_hp}) hold with probability $1-e^{-\Omega(k)}$ and $1-e^{-\Omega(k\log\frac{n}{k})}$ respectively, and we treat their complements as error events. These terms are dominated by the final stage, which incurs $O(k^{1-c'})$ failure probability; setting $c' = c+1$ gives the $O(k^{-c})$ behavior stated in Theorem \ref{thm:main1}.
\item {\em Decoding time}: We claim that conditioned on the the high-probability events $N_{\rm total} = O\big( k \log \frac{n}{k} \big)$ and $N_{\rm leaf} = O(k)$, the decoding time is $O\big(k \log \frac{n}{k} + k \log k\big) = O(k \log n)$. The first term comes from considering all levels except the last, since it takes $O(1)$ time to check whether each node associated with $N_{\rm total}$ is in a positive or negative test. While $N_{\rm total}$ only counts the non-defective nodes, the number of defective nodes also trivially behaves as $O\big(k \log \frac{n}{k}\big)$. At the last level, for each of the $k + N_{\rm leaf} = O(k)$ relevant leaf nodes, we perform $O(\log k)$ such checks for a total time of $O(k \log k)$.
\item {\em Storage}: At the $\ell$-th level, we need to store $2^{\ell}$ integers indicating the test associated with each of the $2^{\ell}$ nodes. Hence, excluding the last level, we need to store $\sum_{\ell=\log_2 k}^{\log_2 n - 1} 2^{\ell} = O(n)$ integers in $\{1,\dotsc,2k\}$, or $O(n \log k)$ bits. Similarly, the $O(\log k)$ independent sequences of tests at the final level amount to storing $O(n \log k)$ integers, or $O(n (\log k)^2 )$ bits. In addition, under the high-probability event $N_{\rm total} = O\big(k \log\frac{n}{k} \big) = O(k \log n)$, the storage of the possibly defective set requires $O(k \log n)$ integers, or $O(k \log^2 n)$ bits. Since $k \le n$, this is no higher than $O(n \log^2 k)$.
\end{itemize}
\section{Storage Reductions via Hashing} \label{sec:storage}
A notable weakness of Theorem \ref{thm:main1} is that the storage required at the decoder is higher than linear in the number of items. In this section, we present a variant of our algorithm with considerably lower storage that attains similar guarantees to Theorem \ref{thm:main1}.
The idea is to interpret the mappings $\big\{1,\dotsc,2^{\ell}\big\} \to \{1,\dotsc,Ck\}$ at each level as hash functions. Since the high storage in Theorem \ref{thm:main1} comes from explicitly storing the corresponding $2^{\ell} = O(n)$ values, the key to reducing the overall storage is to use lower-storage hash families. The reduced storage comes at the expense of reduced independence between different hash values (e.g., only $r$-wise independence for some $r \ll n$), and the proof of Theorem \ref{thm:main1} utilizes full independence. The modified algorithm in this section uses $\Theta(\log k)$-wise independent hash families, and we leave open the question of whether similar recovery guarantees can be attained with only $O(1)$-wise independence.
A second modification to the algorithm is that in order to attain the behavior $O(k^{-c})$ in the error probability similarly to Theorem \ref{thm:main1}, we consider the use of $\Ctil \ge 1$ independent repetitions at each level $\ell = \ell_{\min},\dotsc,\log_2 n -1$, in the same way that we already used repetitions at the final level. This means that at each level, there are $\Ctil$ sequences of $Ck$ tests (each with a different and independent hash function), and a node is only considered to be possibly defective at a given level if {\em all} of its associated $\Ctil$ tests are positive.
\begin{remark*}
This idea of using low-storage hash functions is reminiscent of the Bloom filter data structure \cite{Blo70}. A direct approach to transferring Bloom filters to group testing is to perform $L = O(\log n)$ hashes of each item into one of $t = O(k \log n)$ tests, and then estimate the defective set to be the set of items only included in positive tests \cite[Sec.~1.7]{Ald19}. By checking the $L$ test outcomes associated with each item, the defective set can be identified with low storage (depending on the hash family properties) under the preceding scaling laws. However, a drawback of this direct approach is that checking all items separately takes $\Omega(n)$ time. Our algorithm circumvents this via the binary splitting approach.
\end{remark*}
\subsection{Statement of Result} \label{sec:main_result2}
With the above-described modifications to the algorithm, we have the following counterpart to Theorem \ref{thm:main1}, which formalizes and generalizes Main Result \ref{mr2}.
\begin{theorem} \label{thm:main2}
{\em (Algorithmic Guarantees with Reduced Storage)} Let $S$ be a fixed (defective) subset of $\{1,\dotsc,n\}$ of cardinality $k$. For any constant $c > 0$, there exist choices of $C$, $\Ctil$, and $C'$ such that the above-described group testing algorithm adapted from Section \ref{sec:description}, with a $\Theta(\log k)$-wise independent hash family and $\Ctil$ independent repetitions per level, yields the following with probability at least $1 - O\big( \frac{\log n}{k^c} \big)$:
\begin{itemize}
\item The returned estimate $\Shat$ equals $S$;
\item The algorithm runs in time $O(\Tsf_{\rm hash} k \log n)$, where $\Tsf_{\rm hash}$ is the evaluation time for one hash value;
\item The algorithm uses $O(k \log n + \Ssf_{\rm hash} \log n)$ bits of storage, where $\Ssf_{\rm hash}$ is the number of bits of storage required for one hash function.
\end{itemize}
In addition, the number of tests scales as $O(k \log n)$.
\end{theorem}
We briefly discuss some explicit values that can be attained for $\Tsf_{\rm hash}$ and $\Ssf_{\rm hash}$. Supposing that $n$, $k$, and $C$ are powers of two, we can adopt the classical approach of Wegman and Carter \cite{Weg81} and consider a random polynomial over the finite field ${\rm GF}(2^{m})$, where $m \in \{ \log_2 k, \dotsc, \log_2 n\}$ (depending on the level). In this case, one attains $r$-wise independence while storing $r$ elements of ${\rm GF}(2^{m})$ (or $O(r \log n)$ bits), and performing $O(r)$ additions and multiplications in ${\rm GF}(2^{m})$ to evaluate the hash. As a result, with $r = \Theta(\log k)$, we get
\begin{equation}
\Tsf_{\rm hash} = O(\log k), \qquad \Ssf_{\rm hash} = O(\log k \cdot \log n)
\end{equation}
under the assumption that operations in ${\rm GF}(2^{m})$ can be performed in constant time. Hence, Theorem \ref{thm:main2} gives $O(k \log k \cdot \log n)$ decoding time and $O(k \log n + \log k \cdot \log^2 n)$ storage. Different trade-offs can also be attained using more recent hash families that can attain $r$-wise independence with an evaluation time significantly less than $r$ \cite{Sie89,Tho17}.
The error probability of $O\big( \frac{\log n}{k^c} \big)$ is slightly worse than the $O(k^{-c})$ scaling of Theorem \ref{thm:main1}; in particular, $o(1)$ error probability is only guaranteed when $k = (\log n)^{\Omega(1)}$. We expect that this requirement could be avoided via a refined analysis, e.g., by characterizing the behavior of the random variables $N_{\rm total}$ and $N_{\rm leaf}$ used in the proof of Theorem \ref{thm:main1}. In addition, the following variants of Theorem \ref{thm:main2} can already be attained with almost no additional effort:
\begin{itemize}
\item We can allow $c = \omega(1)$ in the statement of Theorem \ref{thm:main2}, but at the expense of the number of tests and decoding time increasing by a multiplicative $\Theta(c)$ factor.
\item It is straightforward to show that $\EE[N_{\rm total}] = O\big( k \log \frac{n}{k} \big)$ and $\EE[N_{\rm leaf}] = O(k)$, and one can use Markov's inequality to deduce that $N_{\rm total} = O\big(k^{1+c}\log \frac{n}{k}\big)$ and $N_{\rm leaf} = O(k^{1+c})$ with probability $1-O(k^{-c})$. For any constant $c > 0$, this approach leads to $O(k^{-c})$ error probability with $O(k \log n)$ tests, but the decoding time increases to $O(\Tsf_{\rm hash} k^{1+c} \log n)$, and the storage increases to $O(k^{1+c} \log^2 n + \Ssf_{\rm hash} \log n)$.
\end{itemize}
In the remainder of the section, we provide the proof of Theorem \ref{thm:main2}.
\subsection{Analysis} \label{sce:analysis2}
\subsubsection{Auxiliary variance calculation (case $\Ctil = 1$)} \label{sec:aux_var}
We first study the case $\Ctil = 1$ (i.e., no repetitions), as the case $\Ctil > 1$ will then follow easily.
Recall that the algorithm maintains an estimate of the possibly defective (PD) set at each level. We will give conditions under which the size of this set remains at $O(k)$ throughout the course of the algorithm. For $\ell = \ell_{\min} = \log_2 k$, we trivially have at most $k \le 4k$ PD items. We will use an induction argument to show that every level has at most $4k$ PD items, with high probability.
Consider two non-defective nodes indexed by $u,v$ at a given level $\ell$ having $k' \le k$ defective nodes, let $\Dc_u,\Dc_v$ denote the respective events of hashing into a test containing one or more defectives, and let $D_u,D_v$ be the corresponding indicator random variables. The dependence of these quantities on $\ell$ is left implicit. We condition on all of the test placements performed at the earlier levels, accordingly writing $\EE_{\ell}[\cdot]$ and $\var_{\ell}[\cdot]$ for the conditional expectation and conditional variance. In accordance with the above induction idea, we assume that there are at most $4k$ PD nodes at level $\ell$.
\begin{lemma} \label{lem:var_bound}
{\em (Mean and Variance Bounds)} Under the preceding setup and definitions, if there are at most $4k$ PD nodes at level $\ell$, then we have the following when $\Ctil = 1$ and $C \ge 8$:
\begin{gather}
\EE_{\ell}\bigg[ \sum_{u} D_u \bigg] \le \frac{k}{2} \label{eq:E_sum} \\
\var_{\ell}\bigg[ \sum_{u} D_u \bigg] = c_{\rm var} k, \label{eq:var_sum}
\end{gather}
where the sums are over all non-defective PD nodes at the $\ell$-th level, and $c_{\rm var} > 0$ is a universal constant.
\end{lemma}
The proof is given in Appendix \ref{app:var}. Given this result, we easily deduce the following.
\begin{lemma} \label{lem:induction}
For $\Ctil = 1$ and $C \ge 8$, conditioned on the $\ell$-th level having at most $4k$ possibly defective (PD) nodes, the same is true at the $(\ell+1)$-th level with probability $1 - O\big(\frac{1}{k}\big)$.
\end{lemma}
\begin{proof}
Among the PD nodes at the $\ell$-th level, at most $k$ are defective, amounting to at most $2k$ children at the next level. By Lemma \ref{lem:var_bound} and Chebyshev's inequality, with probability $1 - O\big(\frac{1}{k}\big)$, at most $k$ non-defective nodes are marked as PD, thus also amount to at most $2k$ additional children at the next level, for a total of $4k$.
\end{proof}
\subsubsection{Analysis of the error probability} \label{sec:pe}
At the first level $\ell = \log_2 k$, we trivially have $k \le 4k$ possibly defective (PD) nodes. For $\Ctil = 1$, using Lemma \ref{lem:induction} and an induction argument, the same follows for all levels simultaneously with probability at least $1 - O(k^{-1} \log n)$. For $\Ctil > 1$, we note that since we have $\Ctil$ repetitions at each level and only keep the nodes whose tests are {\em all} positive, the $1 - O(k^{-1})$ behavior becomes $1 - O(k^{-\Ctil})$ due to the independence of the repetitions. Hence, the expression $1 - O(k^{-1} \log n)$ for $\Ctil = 1$ generalizes to $1 - O\big(k^{-\Ctil} \log n\big)$.
The analysis of the final level in Section \ref{sec:final_level} did not rely on $h(\cdot)$ being a fully independent hash function, but rather, only relied on a collision probability of $\frac{1}{2k}$ between any two given items. Since this condition still holds for any pairwise (or higher) independent hash family, we immediately deduce the same conclusion: Conditioned on the final level having $O(k)$ nodes marked as possibly defective, and by choosing $C'$ appropriately in the algorithm description, we attain $O(k^{1-c'})$ error probability at this level for any fixed $c' > 0$.
Combining the above and setting $\Ctil = c$ and $c' = 1+c$, we attain the desired scaling $O(k^{-c} \log n)$ in the theorem statement.
\subsubsection{Number of tests, decoding time, and storage} \label{sec:numbers2}
The remaining claims of Theorem \ref{thm:main2} are established as follows:
\begin{itemize}
\item {\em Number of tests:} The number of tests is the same as in the fully independent case, possibly with a modified implied constant if $\Ctil > 1$ and/or a different choice of $C$ is used.
\item {\em Decoding time}: The analysis of the decoding time is similar to the fully independent case (see Section \ref{sec:numbers}), but each hash takes $\Tsf_{\rm hash}$ time to compute. Hence, the decoding time is $O\big(\Tsf_{\rm hash} k \log n\big)$.
\item {\em Storage}: We use $O(1)$ hash functions at each level except the last, and $O( \log k )$ hash functions at the final level, for a total of $O\big( \log\frac{n}{k} + \log k \big) = O(\log n)$, requiring $O(\Ssf_{\rm hash} \log n)$ storage. In addition, under the high-probability event that there are $O(k)$ possibly defective nodes at each level, their storage requires $O(k)$ integers, or $O(k \log n)$ bits. Hence, the total storage is $O(k \log n + \Ssf_{\rm hash} \log n)$.
\end{itemize}
\section{Conclusion} \label{sec:conclusion}
We have presented a novel non-adaptive group testing algorithm ensuring high-probability (for-each) recovery with $O(k \log n)$ scaling in both the number of tests and decoding time. In addition, we presented a low-storage variant with similar guarantees depending on the hash family used. An immediate open question for this variant is whether similar guarantees hold for $O(1)$-wise independent hash families. In addition, even for the fully independent version, it would be of significant interest to develop a variant that is robust to random noise in the test outcomes (see Footnote \ref{foot:noise} on Page \pageref{foot:noise}).
\section*{\huge Appendix}
\input{appendix.tex}
\bibliographystyle{myIEEEtran}
| {'timestamp': '2020-06-19T02:08:28', 'yymm': '2006', 'arxiv_id': '2006.10268', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10268'} | arxiv |
\section*{Acknowledgments and Disclosure of Funding}}
\NewEnviron{ack}{%
\section*{Acknowledgments and Disclosure of Funding}
\BODY
}
\sloppy
\author{Fran\c{c}ois-Xavier Vialard\thanks{LIGM, Univ Gustave Eiffel, CNRS, \texttt{[email protected]}}\;
\and Roland Kwitt\thanks{
Department of Computer Science
University of Salzburg;
\texttt{[email protected]}}\;
\and
Susan Wei\thanks{
School of Mathematics and Statistics
University of Melbourne;
\texttt{[email protected]}}\;
\and
Marc Niethammer\thanks{
Department of Computer Science
University of North Carolina at Chapel Hill;
\texttt{[email protected]}}
}
\title{A Shooting Formulation of Deep Learning}
\begin{document}
\maketitle
\begin{abstract}
A residual network may be regarded as a discretization of an ordinary differential equation (ODE) which, in the limit of time discretization, defines a continuous-depth network. Although important steps have been taken to realize the advantages of such continuous formulations, most current techniques assume \textit{identical} layers. Indeed, existing works throw into relief the myriad difficulties of learning an infinite-dimensional parameter in a continuous-depth neural network. To this end, we introduce a shooting formulation which shifts the perspective from parameterizing a network layer-by-layer to parameterizing over \textit{optimal} networks described only by a set of \textit{initial conditions}. For scalability, we propose a novel particle-ensemble parameterization which fully specifies the optimal weight trajectory of the continuous-depth neural network. Our experiments show that our particle-ensemble shooting formulation can achieve competitive performance.
Finally, though the current work is inspired by continuous-depth neural networks, the particle-ensemble shooting formulation also applies to discrete-time networks and may lead to a new fertile area of research in deep learning parameterization.
\end{abstract}
\section{Introduction}
Deep neural networks (DNNs) are closely related to optimal control (OC) where the sought-for control variable corresponds to the parameters of the DNN ~\cite{liu2019deep,li2017maximum,haber2017stable}. To be able to talk about an \emph{optimal} control requires the definition of a control cost, i.e., a norm on the control variable. We explore the ramifications of such a control cost in the context of DNN parameterization. For simplicity, we focus on continuous formulations in the spirit of neural ODEs~\cite{chen2018neural}. However, both discrete and continuous OC formulations exist~\cite{brysonapplied,athans2013optimal,troutman2012variational}; our approach could be developed for both.
\begin{figure}[h!]
\centering{
\includegraphics[width=\textwidth]{figs/paper_figures/intro_figure_refined.pdf}}
\caption{Optimization in the neural ODE (NODE) framework \cite{chen2018neural} (left) amounts to a forward pass with the gradient computed via \textcolor{backprop}{backpropagation} (\protect\tikz[baseline]{\protect\draw[line width=0.3mm,densely dashed,color=backprop] (0,.6ex)--++(0.3,0) ;}). Optimization under the shooting principle (middle) turns the forward-backward system into a forward \textit{second-order} system, where we essentially run the backpropagation equation forward. We use a Hamiltonian particle ensemble (right) consisting of $K$ (position, momentum) pairs $(\mathbf{q}_j, \mathbf{p}_j)$ to make shooting efficient. Note that we write $\theta = \theta(\{(\mathbf{q}_j,\mathbf{p}_j) \}_{j=1}^K)$ since $\theta$ satisfies a compatibility equation which involves all $K$ particles. In shooting $\theta$ is time-dependent, in standard NODE $\theta(t)=\theta~\forall t$.
\label{fig:shooting_principle}}
\vspace{-0.4cm}
\end{figure}
Initial work on continuous DNN formulations was motivated by the realization that a \texttt{ResNet}\ \cite{he2016deep,he2016identity} resembles Euler forward time-integration~\cite{haber2017stable,li2017maximum}. Specifically, the forward pass of some input vector $\tilde{\mathbf{x}} \in \mathbb R^d$ through a network with $L$ layers, specified as $\mathbf{x}(0) = \tilde{\mathbf{x}}$ and
$
\mathbf{x}(j+1) = \mathbf{x}(j) + f(\mathbf{x}(j),\theta(j)), \, j=0,1,\ldots,L,
$
closely relates to an explicit Euler~\cite{trefethen1996finite} discretization of the ODE
\begin{equation}
\dot \mathbf{x}(t) = f(t,\mathbf{x}(t),\theta(t)), \quad \mathbf{x}(0)=\tilde{\mathbf{x}}, \quad 0\le t \le T\enspace.
\label{ode_constraint}
\end{equation}
In the continuous DNN formulation, we seek an optimal $\theta$ such that the terminal prediction given by $\mathbf{x}(T)$, i.e., the solution to \eqref{ode_constraint} at time $T$, minimizes $\ell(\mathbf{x}(T))$ for a task-specific loss function $\ell$.
Although \eqref{ode_constraint} with time-varying parameter $\theta(t)$ can be considered as a neural network with an infinite number of layers, current implementations of ODE-inspired networks largely assume the parameters $\theta$ are fixed in time, i.e., $\forall t: \theta(t) = \theta$ ~\cite{chen2018neural,dupont2019augmented}, or follow some prescribed dynamics~\cite{zhang2019anodev2}. Instead, we explore time-varying $\theta(t)$ by employing regularization (i.e., a control cost) to render the estimation well-posed and to assure regularity of the resulting flow. Specifically, (for a single data point) we propose minimizing over $\theta$ the regularized loss
\begin{equation}
\mathcal E(\theta ) = \int_0^T R(\theta(t)) \,\,\mathrm{d} t + \gamma~ \ell(\mathbf{x}(T)), \quad \gamma \in \mathbb R^+,\quad \text{subject to \eqref{ode_constraint}}\enspace,
\label{complete_energy}
\end{equation}
where $R$ is a real-valued complexity measure of $\theta$ corresponding to the control cost. We will mostly work with the Frobenius norm but $R(\theta(t))$ can be more general (see Appendix \ref{appendix:Barron}).
Instead of \emph{directly} optimizing over the set of time-dependent $\theta(t)$ as in standard \texttt{ResNet}s, {\it we restrict the optimization set to those $\theta$ which are critical points of $\mathcal E(\theta)$, thereby dramatically reducing the number of parameters.}
In doing so, one can describe the optimization task as an \textit{initial value problem}. Namely, we show that
we can rewrite the loss in~\eqref{complete_energy} solely in terms of the input $\mathbf{x}(0)$ and a corresponding finite-dimensional momentum variable, $\mathbf{p}(0)$. Such an approach, just like optimizing the initial speed of a mass particle to reach a given point, is called a \textit{shooting method} in numerical analysis~\cite{press2007numerical} and control~\cite{bonnans2013shooting}, giving its name to our new formulation.
The first two panels of Fig.~\ref{fig:shooting_principle} illustrate the difference between the optimization of a neural ODE (NODE) via~\cite{chen2018neural} and our shooting formulation. Since in practice, we have multiple inputs $\tilde{\mathbf{x}}_i, i=1,\ldots,n$, there is an initial momentum vector $\mathbf{p}_i$ corresponding to each of them. If the shooting formulation is to scale up to a large sample size $n$, we must take care that the parameterization does not grow linearly with $n$. To this end, we propose what we call the \emph{Hamiltonian particle-ensemble parameterization}. It is a finite set of particles, where each particle is a (position, momentum) pair. The initial conditions of these particle pairs $\{(\mathbf{q}_j,\mathbf{p}_j)\}_{j=1}^K$ (where $K\ll n$) completely determine $\theta(t)$. This is illustrated in the rightmost panel of Fig.~\ref{fig:shooting_principle}. Once the optimized set of particles has been computed, the computational efficiency of the forward model, similarly to NODE~\cite{chen2018neural}, is retained for vector fields $f$ that are linear in their parameters $\theta(t)$.
Our \textbf{contributions} are as follows:
1) We introduce a shooting formulation for DNNs, amounting to an initial-value formulation for neural network parameterization. This allows for optimization over the original network parameter space via optimizing over the initial conditions of critical networks only;
2) We propose an efficient implementation of the shooting approach based on a novel particle-ensemble parameterization in which a set of initial particles (the (position, momentum) pairs) describe the space of putative optimal network parameters;
3) We propose the \texttt{UpDown}\ model which gives rise to explicit shooting equations;
4) We prove universality for the flows of the \texttt{UpDown}\ vector field and demonstrate in experiments its good performance on several prediction tasks.
\vspace{-0.2cm}
\section{Related work}
We draw inspiration from two separate branches of research: 1) continuous formulations of neural networks~\cite{chen2018neural} and 2) shooting approaches for deformable image registration~\cite{Vialard2012,Miller2006,Niethammer2011}.
\textbf{Continuous-depth neural networks.}
Continuous equivalents of \texttt{ResNet}s\ ~\cite{he2016deep,he2016identity} have been developed in~\cite{ruthotto2019deep,haber2017stable}, but na\"ive implementations are memory-demanding since backpropagation requires differentiating through the numerical integrator. Two approaches can address this unfavorable memory footprint. NODE~\cite{chen2018neural} does not store intermediate values in the forward pass, but recomputes them by integrating the forward model backward. This is easily possible only if the forward model is numerically invertible and the formulation is time-continuous~\cite{gholami2019anode}\footnote{In a discrete setting, resolving the forward model in the backward direction generally requires costly solving of implicit equations. This can be done (it is, e.g., done for invertible \texttt{ResNet}s\ ~\cite{behrmann2018invertible}). In general, an explicit numerical solution for forward time-integration becomes implicit in the backward direction and vice versa.}. Instead, checkpointing ~\cite{gholami2019anode} is a general approach to reduce memory requirements by selectively recomputing parts of the forward solution~\cite{griewank2008evaluating}. Our work can easily be combined with these numerical approaches.
\textbf{Solving implicit equations.}
A recent line of works, including deep equilibrium models~\cite{bai2019deep} and implicit residual networks~\cite{reshniak2019robust}, has shown that it may not always be necessary to freely parameterize all the layers in the network. Specifically, in~\cite{bai2019deep} and~\cite{reshniak2019robust}, the parameters of each layer are defined via an implicit equation motivated by \emph{weight tying} thus improving expressiveness and reducing the number of parameters while decreasing the memory footprint via implicit differentiation. Instead, our work increases expressiveness and reduces the number of parameters via particle-based shooting.
\textbf{Invertibility and expressiveness.}
Based on similarity with continuous time integration, constraining the norm of a layer in a \texttt{ResNet}\ will result in an invertible network such as in ~\cite{behrmann2018invertible,jacobsen2018revnet}. Invertibility is also explored in~\cite{younes2018diffeomorphic}, where it is enforced (as in our setting) via a penalty of the norm. These works show that standard learning tasks can be performed on top of a one-to-one transformation. Recent theoretical developments~\cite{zhang_approximation_2020} show that indeed capping a NODE or i-ResNet~\cite{behrmann2018invertible} with a single linear layer gives universal approximation for non-invertible continuous functions. Further, expressiveness can be increased by moving to more complex models, e.g., by introducing additional dimensions as explored in augmented NODE~\cite{dupont2019augmented}. In \cite{zhang2019anodev2} (\texttt{AnodeV2}), Zhang et al. treat time-dependent $\theta(t)$. Weights are evolved jointly with the state of the continuous DNN. While this weight evolution could, in principle, also be captured by a learned weight network, the authors argue that this would result in a large increase in parameters and therefore opt for explicitly parameterizing these evolutions (e.g., via a reaction diffusion equation). In contrast, our method does not rely on learning a separate weight-network or on explicitly specifying a weight evolution. Instead, our evolving weights are a direct consequence of the shooting equations which, in turn, are a direct consequence of penalizing network parameters (the control cost) over time; a large increase in parameters does not occur.
\textbf{Hamiltonian approaches.}
Toth et al.~\cite{toth2019hamiltonian} proposed Hamiltonian generative networks to learn the Hamiltonian governing the evolution of a physical system. Specifically, they learn Hamiltonian vector fields in the latent space of an image encoder-decoder architecture. S{\ae}mundsson et al.~\cite{saemundsson2019variational} also learn the underlying dynamics of a system from time-dependent data, starting from a discrete Lagrangian combined with a variational integrator. This motivates particular network structures; e.g., Newtonian networks where the potential energy is learned via a neural network. Although sharing common tools, our work completely differs from this line of research in the sense that we exploit Hamiltonian mechanics to parameterize \emph{general} continuous neural networks. In principle, our work applies to most network architectures and is not specific to physical data.
Finally, we mention that shooting approaches have been applied successfully in other areas such as diffeomorphic image matching \cite{Miller2006,Vialard2012,Niethammer2011}. However, the decisive difference here is in the dimensionality of the underlying space: in diffeomorphic image registration, the data are points in a 3D volume i.e., $d=3$; for DNNs applications, data points usually lie in a much higher-dimensional space, i.e., $d$ is very large.
\section{Shooting formulation of ODE-inspired neural networks}
\label{sec:general_framework}
We consider, for simplicity, a supervised learning task where the input and target spaces are $\mathcal X \subset \mathbb R^d$ and $\mathcal Y$, resp., and sampled data are denoted
by $\{(\tilde{\mathbf{x}}_i,\tilde{\mathbf{y}}_i)\}_{i=1}^n \subset \mathcal X \times \mathcal Y$. The goal is to learn the weight $\theta(t)$ in the following flow equation
\begin{equation}\label{EqFlow}
\dot{\mathbf{x}}_i(t) = f(\mathbf{x}_i(t),\theta(t)), \quad \mathbf{x}_i(0) = \tilde{\mathbf{x}}_i, \quad 0\le t \le T, \quad i=1,\ldots,n
\end{equation}
such that it minimizes the loss $\sum_{i = 1}^n \ell(\mathbf{x}_i(T),\tilde{\mathbf{y}}_i)$ for some loss function $\ell$. In existing works, the weight is chosen independent of time, i.e., $\theta(t) = \theta$ \cite{chen2018neural}, or specific evolution equations are postulated for it~\cite{massaroli_dissecting_2020,zhang2019anodev2}. Such strategies show the difficulty of addressing infinite dimensional parameterizations of time-dependent $\theta$ and the need for regularization for well-posedness~\cite{finlay_how_2020,massaroli_dissecting_2020,haber2017stable}. Instead of parameterizing $\theta(t)$ directly, we aim at penalizing $\theta(t)$ according to the regularity of $f(\cdot,\theta(t))$ to arrive at a well-posed problem. Specifically, we consider a regularization term $R(\theta(t))$ (discussed in \S\ref{SecChoiceOfReg}) and propose to minimize over $\theta$
\begin{equation}\label{EqVariationalFormulation}
\mathcal E_n(\theta) = \int_0^T R(\theta(t)) \,\,\mathrm{d} t + \gamma \sum_{i=1}^n \ell(\mathbf{x}_i(T),\tilde{\mathbf{y}}_i), \quad \gamma \in \mathbb R^+, \quad \text{subject to \eqref{EqFlow}}\enspace.
\end{equation}
Note that upon discretizing the time $t$ (i.e., having a number of parameters proportional to the number of timesteps) this is similar to a \texttt{ResNet}\ with weight decay.
For a \texttt{ResNet}\ or a NODE, optimization is based on computing the parameter gradient via a forward pass followed by backpropagation (see left panel of Fig.~\ref{fig:shooting_principle}).
\textbf{Optimality equations.}
The optimality conditions for~\eqref{EqVariationalFormulation} in continuous time are:
\begin{align}
\begin{cases}
\dot{\mathbf{x}}_i(t) - f(\mathbf{x}_i(t),\theta(t)) = 0,~\mathbf{x}_i(0) = \tilde{\mathbf{x}}_i, & \text{Data evolution} \\
\dot{\mathbf{p}}_i(t) + \partial_\mathbf{x} f(\mathbf{x}_i(t),\theta(t))^\top(\mathbf{p}_i) = 0,~\mathbf{p}_i(T) = -\gamma \nabla \ell(\mathbf{x}_i(T),\tilde{\mathbf{y}}_i),& \text{Adjoint evolution}\\
\partial_\theta R(\theta(t)) - \sum_{i = 1}^n\partial_\theta f(\mathbf{x}_i(t),\theta(t))^\top(\mathbf{p}_i(t)) = 0
\,. & \text{Compatibility}
\end{cases}
\label{EqOptimalityEquations}
\end{align}
The first equation describes evolution of the input data and the second equation is the adjoint equation solved backward in time in order to compute the gradient with respect to the parameters. At convergence, the third equation is also satisfied. This last equation encodes the optimality of the layer at timestep $t$, as it is the case for an \emph{argmin layer} or \emph{weight tying}~\cite{br2017optnet}. Its left hand side corresponds to the gradient with respect to the parameter $\theta$, but as we shall see it will allow us to compute $\theta$ directly via our (position, momentum) pairs in our particle shooting formulation. The shooting approach simply replaces the optimization set by the set of critical points of \eqref{EqVariationalFormulation} expressed in these optimality conditions. That is, we only optimize over solutions fulfilling~\eqref{EqOptimalityEquations}.
\textbf{Shooting principle.} The shooting method is standard in optimal control~\cite{bonnans2013shooting} and can be formulated as follows: since, at optimality, the system in \eqref{EqOptimalityEquations} is satisfied, one can \emph{turn this system into a forward model} defined only by its initial conditions $\{(\mathbf{x}_i(0),\mathbf{p}_i(0))\}_{i=1}^n$ which specify the \emph{entire trajectory} of optimal parameters. \mnrev{We evolve \emph{both} the data and adjoint evolution equations forward in time and compute at each time, $t$, $\theta(t)$ from the compatibility \eqref{EqOptimalityEquations} via the current values of $\{(\mathbf{x}_i(t),\mathbf{p}_i(t))\}_{i=1}^n$.} We refer to the forward model defined by \eqref{EqOptimalityEquations} as the \textit{shooting equations}.
Unfortunately, this initial-condition parameterization still requires \emph{all} initial conditions $\mathbf{x}_i(0)$ and their corresponding momenta $\mathbf{p}_i(0)$ for $i=1,\ldots,n$. Since this does not scale to very large datasets, we propose an approximation using a collection of particles, as described next.
\textbf{Hamiltonian particle ensemble.}
In the limit and ideal case where the data distribution is known, the optimality equations can be approximated using a collection of particles which follow the Hamiltonian system (see Appendix \ref{appendix:SecExpectationApproximation}).
We thus consider a collection of particles $\{(\mathbf{q}_j,\mathbf{p}_j)\}_{j = 1}^K \in {\mathbb R}^d \times {\mathbb R}^d$ that drive the evolution of the entire population $\{\mathbf{x}_i\}_{i = 1}^n \subset {\mathbb R}^d$ through the following forward model
\begin{align}\label{EqShootingForward}
\begin{cases}
\,\dot{\mathbf{x}}_i(t) - f(\mathbf{x}_i(t),\theta(t)) = 0,~\mathbf{x}_i(0)=\tilde{\mathbf{x}}_i & \text{Data evolution}\\
\left.\begin{aligned}
&\dot{\mathbf{q}}_j(t) - f(\mathbf{q}_j(t),\theta(t)) = 0, \\
&\dot{\mathbf{p}}_j(t) + \partial_\mathbf{q} f(\mathbf{q}_j(t),\theta(t))^\top(\mathbf{p}_j(t)) = 0, \\
&\partial_\theta R(\theta(t)) - \sum_{j = 1}^K \partial_\theta f(\mathbf{q}_j(t),\theta(t))^\top(\mathbf{p}_j(t)) = 0 \,,
\end{aligned}
\right\}
& \text{Hamiltonian equations}
\end{cases}
\end{align}
with initial conditions $\{(\mathbf{q}_j(0),\mathbf{p}_j(0))\}_{j = 1}^K$, where the gradient with respect to this new parameterization is computed via backpropagation\mnrev{, and typically $K\ll n$.} This set of (position, momentum) pairs is termed the \emph{Hamiltonian particle ensemble}. As the number of particles is reduced, so are the number of free parameters, see Appendix \ref{appendix:freeparams}. Indeed, varying the Hamiltonian particle ensemble allows for controlling the tradeoff between reconstruction and network complexity. \mnrev{Note that the main difference to the shooting formulation of \eqref{EqOptimalityEquations} is that the parameterization, $\theta(t)$, is now retrieved from the shooting equations as specified by the particle collection. The original data samples, $\tilde{\mathbf{x}}_i$, are simply propagated via these parameters.}
\subsection{Choices of regularization, parameterization and conserved quantities}\label{SecChoiceOfReg}
The main computational bottleneck in the forward model of \eqref{EqShootingForward} is the implicit parameterization of $\theta$ by the last equation. Making it explicit is key to render shooting computationally tractable.
\textbf{Linear in parameter\footnote{Obviously, an affine function of the parameters also works similarly.} - quadratic penalty.} In the simplest case, the space of functions $f$ is a linear space parameterized by $\theta(t)$. In this case, a quadratic penalty amounts to a kinetic penalty. Specifically, as a motivating example, consider the
forward model
\begin{equation}
f(\mathbf{x}(t),\theta(t)) = A(t) \sigma(\mathbf{x}(t)) + b(t),
\label{EqAffineVectorField}
\end{equation}
where $\sigma$ is a component-wise activation function,
$A \in L^2([0,1], \mathbb R^{d^2})$, $b \in L^2([0,1],\mathbb{R}^d)$ and
$\theta(t) = [A(t),b(t)]$. With the quadratic regularizer $R(\theta(t)) = \frac{1}{2} \Tr\left(A(t)^\top M_{A} A(t)\right) + \frac{1}{2} b(t)^\top M_{b} b(t)$,
where $M_{A}$, $M_{b}$ are positive definite matrices,
the particle shooting equations are
\begin{equation}
\begin{cases}
\dot \mathbf{q}_j(t) \!&= A(t) \sigma(\mathbf{q}_j(t)) + b(t), \\
\dot{\mathbf{p}}_j(t) \! &= - \,\mathrm{d} \sigma(\mathbf{q}_j(t))^\top A(t)^\top \mathbf{p}_j(t), \\
\end{cases}\quad
\begin{cases}
A(t) \! &= {M_{A}}^{-1}(-\sum_{j=1}^K \mathbf{p}_j(t) \sigma(\mathbf{q}_j(t))^\top)\\
b(t) \! &= {M_{b}}^{-1}(-\sum_{j=1}^K \mathbf{p}_j(t))\,,
\end{cases}
\label{EqShootingLinearParameterQuadraticPenalization}
\end{equation}
with given initial conditions $(\mathbf{p}_j(0),\mathbf{q}_j(0))$. We emphasize that $\theta(t)$ is \textit{explicitly defined} by $\{(\mathbf{p}_j(t),\mathbf{q}_j(t))\}_{j=1}^K$ and the computational cost is reduced to matrix multiplications.
\par
As is well-known \cite{Arnold1978MathematicalMO}, the Hamiltonian flow preserves the Hamiltonian function. In the ``linear in parameter - quadratic penalty'' case, this preserved quantity, denoted
$$H(\mathbf{p}(t),\mathbf{q}(t)) = R(\theta(t)),$$
corresponds to a (kinetic) energy of the system of particles. As a first consequence, the objective functional can be rewritten as
$$
H(\mathbf{p}(0),\mathbf{q}(0))) + \gamma \sum_{i=1}^n \ell(\mathbf{x}_i(T),\tilde{\mathbf{y}}_i)\,.
$$
This clearly allows for direct optimization on $(\mathbf{p}(0),\mathbf{q}(0))$, i.e., shooting.
As a second consequence, since the vector field has constant norm
(its squared norm is the Hamiltonian), it gives a quantitative bound on the regularity of the flow map at time $t=T$ explicit in terms of $H(\mathbf{p}(0),\mathbf{q}(0))$.
In addition (Appendix \ref{appendix:SecExpectationApproximation}), the Rademacher complexity of the generated flows with bounded $H(\mathbf{p}(0),\mathbf{q}(0)))$ can also be controlled.
\textbf{Nonlinear in parameter and non-quadratic penalty.}
A standard \texttt{ResNet}\ structure uses vector fields of the type (in convolutional form or not)
\begin{equation}\label{Eq:SingleHiddenLayer}
f(\mathbf{x}(t),\theta(t)) = \theta_1(t) \sigma(\theta_2(t) \mathbf{x}(t) + b_2(t)) + b_1(t)\enspace,
\end{equation}
where $\theta_1(t) \in L({\mathbb R}^{d'},{\mathbb R}^d)$ and $\theta_2(t) \in L({\mathbb R}^d,{\mathbb R}^{d'})$. We will refer to \eqref{Eq:SingleHiddenLayer} as the \textbf{single-hidden-layer} vector field.
This model can also be handled in our shooting approach since the shooting equations in \eqref{EqOptimalityEquations} are completely specified by the Hamiltonian
$$H(\mathbf{p},\mathbf{q},\theta) = R(\theta) - \mathbf{p}^\top f(\mathbf{q},\theta). $$ Automatic differentiation can be used (see Appendix~\ref{appendix:automatic_shooting}) to implement the forward model
\begin{equation}
\dot{\mathbf{q}}(t) = \frac{\partial H}{\partial \mathbf{p}} (\mathbf{p}(t),\mathbf{q}(t),\theta(t)),~
\dot{\mathbf{p}}(t) = -\frac{\partial H}{\partial \mathbf{q}}(\mathbf{p}(t),\mathbf{q}(t),\theta(t)),~
\theta(t) \in \argmin H(\mathbf{p}(t),\mathbf{q}(t),\theta(t))
\label{EqTrueHamiltonEquations}
\end{equation}
Note that a necessary condition for solving the third equation above is in fact the compatibility equation in \eqref{EqShootingForward}.
Important bottlenecks appear since the third equation is nonlinear and potentially associated with a non-convex optimization problem. This could be addressed by unrolling the optimization corresponding to the last equation, resulting in increased computational cost. In addition, in this nonlinear case, the Hamiltonian function is no longer (in general) equal to $R(\theta(t))$ even in the quadratic regularization setting. Therefore, results on the smoothness or Rademacher complexity would no longer be guaranteed as for the linear - quadratic penalty case. Last, quadratic regularization has no known theoretical results for the Rademacher complexity of functions generated by \eqref{Eq:SingleHiddenLayer} with bounded norm. Norms for which the Rademacher complexity of this class of functions is known~\cite{e2019barron} to be bounded are called Barron norms, which are non-smooth and non-convex, and which would add to the difficulty.
To circumvent these issues while retaining expressiveness and theoretical guarantees in the linear parameterization setting, we next introduce the \texttt{UpDown}\ model.
\subsection{The \texttt{UpDown}\ model}
\label{sec:updownNODE}
The key idea is to transform the vector field of \eqref{Eq:SingleHiddenLayer} into a model which is linear in parameters on which the quadratic regularization can be applied.
To this end, we introduce the additional state
$$\v(t) = \theta_2(t) \mathbf{x}(t) + b_2(t)$$
which we differentiate with respect to time to obtain $$\dot{\v}(t) = \dot{\theta}_2(t) \mathbf{x}(t) + \dot{b}_2(t) + \theta_2(t) \dot{\mathbf{x}}(t)\enspace.$$
Replacing $\dot{\mathbf{x}}(t)$ by its formula, we get
$$
\dot{\v}(t) = \dot{\theta}_2(t) \mathbf{x}(t) + \dot{b}_2(t) + \theta_2(t) (\theta_1(t) \sigma (\v(t)) + b_1(t))\enspace.
$$
Now overloading on notation slightly, we use the additional state variable $\v(t)$ to propose the following ODE system, denoted the \texttt{UpDown}\ model
\begin{equation}
\dot{\mathbf{x}}(t) = \theta_1(t) \sigma(\v(t)) + b_1(t),\quad
\dot{\v}(t) = \theta_2(t) \mathbf{x}(t) + b_2(t) + \theta_3(t) \sigma(\v(t))\,,
\label{updownODE}
\end{equation}
with $\mathbf{x}(t) \in {\mathbb R}^d$, $\v(t) \in {\mathbb R}^{\alpha d}$ and introducing the (integer-valued) \emph{inflation factor} $\alpha \geq 1$. For the data evolution, $\mathbf{x}_i(0)$ are given by the data $\{\tilde{\mathbf{x}}_i\}$. We parameterize the $\v_i(0)$ using an affine map $g_{\Theta}$, i.e.,
$$
\v_i(0) = g_{\Theta}(\mathbf{x}_i(0)) = \Theta_{12}(\mathbf{x}_i(0)) + b_{12},
$$
where $\Theta_{12} \in L({\mathbb R}^d,{\mathbb R}^{\alpha d})$ and $b_{12} \in L({\mathbb R}^{\alpha d})$.
In Appendix \ref{appendix:updown_universal}, we prove the following theorem:
\vskip2ex
\begin{theorem}
Given a time-dependent vector field defined on a compact domain $C$ of ${\mathbb R}^d$, which is time continuous and Lipschitz, we denote by $\varphi(T,\mathbf{x}(0))$ its flow at time $T$ from starting value $\mathbf{x}(0)$. Then, there exists a parameterization of the \emph{\texttt{UpDown}}\ model for which
its solution is $\varepsilon$-close to the flow,
$\sup_{\mathbf{x}(0) \in C}\| \varphi(T,\mathbf{x}(0)) - \mathbf{x}(T) \| \leq \varepsilon $.
\label{thm:universal}
\end{theorem}
Notably, in the proof, the dimension of the hidden state $\v$ is used twice: \emph{first}, for having a sufficient number of neurons in \eqref{Eq:SingleHiddenLayer} to approximate a stationary vector field (standard universality property of multilayer perceptron) and, \emph{second}, for approximating time-dependent vector fields. Therefore, at the cost of introducing a possibly large number of dimensions, the \texttt{UpDown}\ model is universal in the class of time-dependent NODEs.
As shown in Appendix \ref{appendix:updown_universal}, this universality result transfers to our shooting formulation. Due to its additional dimensions, it is also likely to be universal in the space of functions (i.e., not necessarily injective). We focus on the \texttt{UpDown}\ model in our experiments. Note also that while we derived our theory for vector-valued evolutions for simplicity, similar linear in parameter evolution equations can for example be derived for convolutional neural networks.
\section{Experiments}
\label{section:experiments}
Our goal is to demonstrate that it is possible to learn DNNs by optimizing only over the initial conditions of \textit{critical} networks. This is made possible via shooting and efficient via our particle parameterization. A key difference to prior work is that our approach allows to capture time-dependent (i.e., layer-dependent in the discrete setting) parameters {\it without} discretizing these parameters at every time-point. Comparisons to other NODE like methods are not straightforward due to hyper-parameters and different implementations. For consistency, we therefore provide four different formulations (based on the \texttt{UpDown}\ model of \S\ref{sec:updownNODE}).
\begin{itemize}
\item The \textbf{static direct} model forgoes the Hamiltonian particle ensemble, and instead directly optimizes over \emph{time-constant} parameters: $\theta(t)=\theta$ for all $t$. Everything else, including the \texttt{UpDown}\ model, stays unchanged. This model is most closely related to NODE~\cite{chen2018neural} and augmented NODE~\cite{dupont2019augmented}.
\item We call our proposed shooting model \textbf{dynamic with particles}. It is parameterized via a set of initial conditions of (position, momentum) pairs, which evolve over time and fully specify $\theta(t)$.
\item The \textbf{static with particles} model is similar to the {\it static direct} model. However, instead of directly optimizing over a \emph{time-constant} $\theta$, it uses a set of (position, momentum) pairs (i.e., particles, as in our {\it dynamic with particles} model above) to parameterize $\theta$ indirectly.
\item
Finally, we consider the \textbf{dynamic direct} model which uses a piece-wise time-constant $\theta(t)$. It essentially chains together multiple {\it static direct} models and is closely related to a discrete \texttt{ResNet}\ in the sense that multiple blocks (we use five) are used in succession. However, each block involves time-integrating the \texttt{UpDown}\ model. While the \textit{dynamic with particles} model captures $\theta(t)$ indirectly via particles and shooting, the \textit{dynamic direct} model requires many more parameters as it represents $\theta(t)$ directly. We show results for the \textit{dynamic direct} model for a subset of the experiments.
\end{itemize}
\begin{figure}[t!]
\includegraphics[width=0.99\textwidth]{paper_figures/quadratic_like_results.pdf}
\caption{Fit for quadratic-like $y = x^2 + 3/(1+x^2)$ for 10 random initializations. \emph{Left}: Test loss; \emph{Right}: time-integral of $\log_2$ of the Frobenius norm complexity. Lower is better for both measures. * indicates number of removed outliers (outside the interquartile range (IQR) by $\geq1.5\times$ IQR); $\alpha$ denotes the inflation factor. \label{fig:loss_and_complexity_quadratic}}
\end{figure}
All experiments use the \texttt{UpDown}\ model with quadratic penalty function $R$. Detailed experimental settings, including weights for the quadratic penalty function, can be found in Appendix \ref{appendix:experimental_settings}.
\textbf{Simple 1D function regression.}
We approximate a simple quadratic-like function $y= x^2 + 3/(1+x^2)$ which is non-invertible. We use 15 particles for our experiments. Fig.~\ref{fig:loss_and_complexity_quadratic} shows the test loss and the network complexity, as measured by the log Frobenius norm integrated over time~\cite{neyshabur_exploring_2017}, for the different models as a function of the inflation factor $\alpha$ (cf. \S\ref{sec:updownNODE}). On average, the \textit{dynamic with particles} model shows the best fits with the lowest complexity measures, indicating the simplest network parameterization. Note that the \textit{static with particles} approach results in the lowest complexity measures only because it cannot properly fit the function as indicated by the high test loss. Additional results for a cubic function $y=x^3$ are in Appendix \ref{appendix:figures_results}.
\textbf{Spiral.}
Next, we revisit the spiral ODE example of~\cite{chen2018neural} following the nonlinear dynamics $\dot \mathbf{x} = A\mathbf{x}^3$, $\mathbf{x} \in \mathbb R^2$ (where the power is component-wise). We fix $\mathbf{x}(0)=[2,0]^T$, use $A=[-0.1,2.0;-2,-0.1]$ and evolve the dynamics for time $T=10$. The training data consists of snippets from this trajectory, all of the same length. We use an $L^2$ norm loss (calculated on all intermediate time-points) and 25 particles. Our goal is to show that we can obtain the best fit to the training data due to our dynamic model. Fig.~\ref{fig:spiral_short_long_range} (\emph{top}) shows that we can indeed obtain similar or better fits (lower losses) for a similar number of parameters while achieving the lowest network complexity measures. Fig.~\ref{fig:spiral_short_long_range} (\emph{bottom}) shows the corresponding results for the validation data consisting of the original long trajectory starting from initial value $\mathbf{x}(0)$. Interestingly, by pasting together short-range solutions we are successful in predicting the long-range trajectory despite training on short-range trajectory snippets.
\begin{figure}[t!]
\includegraphics[width=0.99\textwidth]{paper_figures/spiral_results}
\caption{Fit for spiral (short- and long-range). Losses for the different models as well as the time-integral of $\log_2$ of the Frobenius norm complexity measure. Lower is better for both measures. The * symbol indicates how many outliers were removed and $\alpha$ denotes the inflation factor.
\label{fig:spiral_short_long_range}}
\end{figure}
\textbf{Concentric circles.}
To study the impact of the inflation factor $\alpha$ in a classification regime, we replicate the concentric circles setting of \cite{dupont2019augmented}.
The task is learning to separate points, sampled from two disjoint annuli in $\mathbb{R}^2$.
While we are less interested in the learned flow (as in \cite{dupont2019augmented}), we study how often the proposed \texttt{UpDown}\ (dynamic with particles) model perfectly fits the training data as a function of $\alpha$.
To the right, we show the success rate over 50 training runs for three choices
\begin{wrapfigure}{r}{4.4cm}
\vspace{-6pt}
\includegraphics[width=4.5cm]{paper_figures/cc_results.pdf}
\vspace{-10pt}
\end{wrapfigure}
of $\alpha$ and 20 particles. \emph{Notably, the effect of $\alpha$ is only visible if the classification loss is down-weighted so that the regularization, $R$, dominates}.
Otherwise, for the tested $\alpha$, the model always fits the data. The experiment is consistent with~\cite{dupont2019augmented}, where it is shown that increasing the space on which an ODE is solved allows for easy separation of the data and leads to less complex flows.
The latter is also observed for our model.
\textbf{Rotating MNIST.} Here, we are given sequences of a rotating MNIST digit (along 16 angles, linearly spaced in $[0,2\pi]$). The task is learning to synthesize the digit at any rotation angle, given only the \emph{first} image of a sequence. We replicate the setup of \cite{Yildiz19a} and consider rotated versions of the digit ``3''. We identify each rotation angle as a time point $t_i$ and randomly drop four time points of each sequence during training. One fixed time point is consistently left-out and later evaluated during testing. We use the same convolutional autoencoder of \cite{Yildiz19a} with the \texttt{UpDown}\ model operating in the internal representation space after the encoder.
\begin{wrapfigure}{r}{3.7cm}
\vspace{-8pt}
\includegraphics[width=3.7cm]{paper_figures/rot_mnist_pca_results.pdf}
\vspace{-8pt}
\end{wrapfigure}
During training, the encoder receives the first
image of a sequence (always at angle $0^\circ$), the \texttt{UpDown}\ model integrates forward to the desired time points, and the decoder decodes these representations. As loss, we measure the mean-squared-error (MSE) of the decoder outputs.
Fig.~\ref{fig:mnistresults} lists the MSE (at the left-out angle), averaged over all testing sequences and shows two example sequences with predictions for all time points (100 particles, $\alpha=10$).
While all \texttt{UpDown}\ variants substantially lower the MSE previously reported in the literature, they exhibit comparable performance. To better understand the differences, we visualize the internal representation space of the autoencoder by projecting all 16 internal representations (i.e., the output of the \texttt{UpDown}\ models after receiving the output of the encoder) of each testing image onto the two largest principal components, shown to the right (different colors indicate the different rotation angles). This qualitative result shows that allowing for a time-dependent parameterization leads to a more structured latent space of the autoencoder.
\begin{figure*}
\begin{center}
\includegraphics[width=0.99\textwidth]{paper_figures/rot_mnist_results.pdf}
\end{center}
\caption{\label{fig:mnistresults}\emph{Left}: Image (per-pixel) MSE (measured at the marked time point) averaged over all testing sequences of the rotated MNIST dataset. \emph{Right}: Two testing sequences and predictions (marked \textcolor{blue}{blue}) for all 16 time points when the image at $t=0$ is given as input (marked \textcolor{red}{red}). Results marked with $^\dagger$ are taken from \cite{Yildiz19a}.}
\vspace{-0.25cm}
\end{figure*}
\textbf{Bouncing balls.}
Finally, we replicate the ``bouncing balls'' experiment
of \cite{Yildiz19a}. This is similar to the rotating MNIST experiment, but the underlying dynamics are more complex. In particular, we are given 10,000 (training) image sequences of bouncing balls at 20 different time points \cite{Sutskever09a}. The task is learning to predict, after seeing the first three images of a sequence, future time points. We use the same convolutional autoencoder of \cite{Yildiz19a} and minimize image (per-pixel) MSE (using all 20 time points for training). Our
\texttt{UpDown}~model operates in the internal representation space of the encoder (50-dimensional in our experiments\footnote{We did not further experiment with this hyperparameter, so potentially better results can be obtained.}). In test mode, the network receives the first three image of a sequence and predicts 10 time points ahead. We measure the image (per-pixel) MSE and average the results (per time point) over all 500 testing sequences. For model selection, we rely on the provided validation set. Our \texttt{UpDown}~(dynamic with particles) model uses 100 particles. Fig.~\ref{fig:bballs_results} (\emph{left}) lists the averaged MSE per time point, plotted against the approaches listed in \cite{Yildiz19a}. Fig.~\ref{fig:bballs_results} (\emph{right}) shows two testing sequences with predictions (the three input time points are not shown). Results for the \texttt{UpDown}\ static and static with particles model are $\oslash~0.0154$ and $\oslash~0.0150$, respectively
\begin{figure*}
\begin{center}
\includegraphics[width=0.99\textwidth]{paper_figures/bballs_results.pdf}
\end{center}
\caption{\label{fig:bballs_results} \emph{Left}: Image (per-pixel) MSE for predicting 10 time points ahead (after receiving the first three inputs of a sequence), averaged over all testing sequences (numbers in parentheses indicate the MSE when additionally averaged over \emph{all} prediction time points). Results marked with $^\dagger$ are taken from \cite{Yildiz19a}. \emph{Right}: Two testing sequences with predictions (marked \textcolor{blue}{blue}).}
\end{figure*}
\textbf{Computational cost.}
The computational cost of the \texttt{UpDown}\ model consists in storing the particles and running forward the model for the collection of particles and the data. Hence, computational cost scales linearly in the number of particles. To get rid of this linear relationship (in case only a forward pass is needed), the ODE can be discretized in time and the \texttt{ResNet} with its weights is obtained.
\vspace{-0.2cm}
\section{Discussion and Conclusions}
We demonstrated that it is possible to parameterize DNNs via initial conditions of (position, momentum) pairs. While our experiments are admittedly still simple, results are encouraging as they show that 1) the particle-based approach can achieve competitive performance over direct parameterizations and that 2) time-dependent parameterizations are useful for obtaining simpler networks and can be realized with significantly fewer parameters using particle-based shooting.
Our work opens up many different follow-up questions and formulations. For example, we presented our approach for a model with continuous dynamics, but the particle and the shooting formalism can also be applied to discrete-time models. Further, we focused, for simplicity, on continuous variants of multi-layer perceptrons, but similar linear-in-parameter models can be formulated for convolutional neural networks.
Models that are nonlinear in their parameters hold the promise for connections with optimal mass transport theory and to theoretical complexity results, which we touched upon for our \texttt{UpDown}\ model. Indeed, this change of paradigm in the parameterization may result in new quantitative results on network generalization properties. Lastly, how well the approach generalizes to more complex problems, how many particles are needed to switch from a standard deep network to its shooting formulation, and how optimizing over critical points of the original optimization problem via shooting relates to network generalization will be fascinating to explore.
\textbf{Source code} is available at: \href{https://github.com/uncbiag/neuro_shooting}{\texttt{https://github.com/uncbiag/neuro\_shooting}}
\vspace{-0.2cm}
\section*{Broader Impact}
One goal of this work is to enrich the understanding of continuous depth neural networks and to open a different (or alternative) perspective on its parameterization.
Specifically, we shift the parameterization of deep neural networks from a layer-by-layer perspective to an initial-value perspective and Hamiltonian dynamics. At this point, our work is conceptual and theoretical in nature; broader impact emerges most likely as a consequence of better understanding the role of neural network parameterizations.
\vspace{-0.2cm}
\begin{ack}
This research project was initiated during a one-month invitation of M. Niethammer by the Labex Bézout, supported by the French National Research Agency ANR-10-LABX-58.
R. Kwitt is partially funded by the Austrian Science Fund (FWF): project FWF P31799-N38 and the Land Salzburg (WISS 2025) under project numbers 20102-F1901166-KZP and 20204-WISS/225/197-2019. S. Wei is the recipient of an Australian Research Council Discovery Early Career Award (project number DE200101253) funded by the Australian Government.
\end{ack}
\section*{Supplementary material}
The following sections discuss in more detail the theoretical guarantees of our approach. \S\ref{appendix:SecExpectationApproximation} presents the optimality conditions underlying our shooting formulation and it is shown how these optimality equations can be approximated via a collection of particles. \S\ref{appendix:Barron} proposes different regularizations, whose choice is key for practical and theoretical results. We show that, under some conditions, the Rademacher complexity of the set of flows can be bounded and apply our results in \S\ref{SecAppendixConsequencesUpDown} to the {\texttt{UpDown}} model. \S\ref{appendix:freeparams} discusses the number of free parameters of our shooting approach in relation to the number of free parameters for direct optimization. \S\ref{appendix:automatic_shooting} explains how the shooting equations can be automatically derived via automatic differentiation. \S\ref{appendix:updown_universal} shows the universality of our {\texttt{UpDown}} model. \S\ref{appendix:experimental_settings} provides details on our experimental setup. Lastly, \S\ref{appendix:figures_results} shows some additional experimental results.
\section{Expectation approximation of optimality equations}
\label{appendix:SecExpectationApproximation}
We first discuss a general variational setup of supervised learning including regularization.
\subsection{Variational setup}
Suppose the data consists of input $X \in {\mathbb R}^d$.
Let $f(\cdot,\theta(t))$ be a vector field on $\mathbb {\mathbb R}^d$, e.g. the single hidden layer of \eqref{Eq:SingleHiddenLayer} or a linear (in parameter) layer. Consider the flow $\varphi := \varphi(T,\cdot)$ generated by $f$ according to
\begin{equation}\label{EqDiffeomorphicFlows}
\begin{cases}
\frac{\,\mathrm{d}}{\,\mathrm{d} t} \varphi(t,\mathbf{x}) = f(\varphi(t,\mathbf{x}),\theta(t))\,,\\
\varphi(0,\mathbf{x}) = \mathbf{x}\,.
\end{cases}
\end{equation}
We consider the general task of minimizing,
\begin{equation}
\on{Reg}(\varphi) + \gamma \mathbb{E}[\ell(\varphi(X))]\,,
\label{eq:variational_task}
\end{equation}
where $\gamma$ is a positive regularization parameter.
\par
We now consider the particular case of a \texttt{ResNet}\ model where each layer is given by an \texttt{UpDown}\ model \eqref{updownODE} or even a single hidden layer \eqref{Eq:SingleHiddenLayer}.
\par
Without loss of generality, set the terminal time to $T=1$.
Letting $\rho_0$ denote the probability density of $X$, minimizing \eqref{eq:variational_task} is equivalent to minimizing
\[
\inf_{\varphi}\left[ \on{Reg}(\varphi) + \gamma \int_{{\mathbb R}^d} \ell(\varphi(\mathbf{x})) \rho_0(\mathbf{x}) \,\mathrm{d} \mathbf{x}\ \right]\enspace.
\]
This can be rewritten as
\[
\inf_{\varphi} \left[\on{Reg}(\varphi) + \gamma \int_{{\mathbb R}^d} \ell(\mathbf{x}') \rho_1(\mathbf{x}') \,\mathrm{d} \mathbf{x}'\right]\enspace,
\]
where $\rho_1(\mathbf{x}):=\rho(1,\mathbf{x})$ is the flow of the continuity equation
\[
\partial_t \rho(t,\mathbf{x}) + \on{div}(\rho(t,\mathbf{x}) f(\mathbf{x},\theta)) = 0\,,\rho(0,\mathbf{x})=\rho_0(\mathbf{x})\,,
\]
where $\on{div}$ is the divergence operator on vector fields. Note that $\rho_1$ can be regarded as the density representing the data at time $1$.
In the following, we deal with a general regularization term $\on{Reg}(\varphi) = \int_0^1 R(\theta(t),\rho(t)) \,\mathrm{d} t$, where the $R$ term can depend on the density of data at time $t$. A particular though important case is when the regularization $R$ does not depend on $\rho$,
$\int_0^1 R(\theta(t)) \,\mathrm{d} t$.
\subsection{Optimality equations and Hamiltonian ensemble approximation}
We detail the optimality equations when data points are represented by a probability measure.
As mentioned above, the regularity of the map is enforced via a penalty on the weights at each timepoint and is the integral $\int_0^1 R(\theta(t)) \,\mathrm{d} t$ or even more generally $\int_0^1 R(\theta(t),\rho(t)) \,\mathrm{d} t$.
Using Lagrange multipliers, this constraint can be enforced and minimizers of the energy should be saddlepoints of the energy
\begin{multline*}
\mathcal{L}(\rho,\theta,p) := \gamma \int_{{\mathbb R}^d} \ell(\mathbf{x}) \rho_1(\mathbf{x}) \,\mathrm{d} \mathbf{x}+ \int_{0}^1 R(\theta(t),\rho(t))\,\mathrm{d} t \\ + \int_0^1 \int_{{\mathbb R}^d} p(t,\mathbf{x}) (\partial_t \rho(t,\mathbf{x}) + \on{div}(\rho(t,\mathbf{x}) f(\mathbf{x},\theta(t)))) \,\mathrm{d} \mathbf{x} \,\mathrm{d} t\,,
\end{multline*}
where $p(t,\mathbf{x})$ is a time and space dependent function.
The optimality equations are then
\begin{equation}\label{EqOptimalityEquations_density}
\begin{cases}
\partial_t \rho(t,\mathbf{x}) + \on{div}(\rho(t,\mathbf{x}) f(t,\mathbf{x},\theta(t))) = 0\,,\\
\partial_t p(t,\mathbf{x}) + \nabla p(t,\mathbf{x}) \cdot f(t,\mathbf{x},\theta(t)) = \frac{\delta R}{\delta \rho}(\theta(t),\rho(t))\,,\\
\partial_{\theta}R
(\theta(t),\rho(t)) - \int_{{\mathbb R}^d}
\partial_{\theta}f(\mathbf{x},\theta(t))^\top(\nabla p(t,\mathbf{x}) \rho(t,\mathbf{x})) = 0\,,
\end{cases}
\end{equation}
where $\nabla p$ is the gradient w.r.t. $\mathbf{x}$ of $p(t,\mathbf{x})$ and $\delta$ denotes differentiation w.r.t. the indicated parameter. The notation $\frac{\delta R}{\delta \rho}$ means the Fréchet derivative of the penalty w.r.t. the density $\rho$. Note that in our current work, $R$ is independent of $\rho$. However, this more general setup encompasses optimal transport models, see Section \ref{SecNonlinearInParameters}.
In practice, one does not have access to the full distribution and the variational setup needs to be approximated. As proposed in the main text, we approximate it using a collection of particles that follow the optimality equations which are Hamiltonian evolution equations for this collection of particles. The collection of particles $\{(\mathbf{q}_j,\mathbf{p}_j)\}$ are defined by their state and costate. We estimate $\rho$ using the empirical measure $\frac{1}{K} \sum_{j = 1}^K \delta_{\mathbf{q}_j(t)}(\cdot)$. Writing the optimality equation for this particular empirical measure leads to the equation \eqref{EqShootingForward}.
When the number of particles tends to infinity, we can hope to recover the optimal trajectory.
However, we do not explore this question formally here. We simply remark that this question is directly connected to expressiveness and generalization properties of the constructed neural network and is also probably data dependent.
\section{Choice of regularization}
\label{appendix:Barron}
The simplest regularization on the flow $\varphi$ is given by
\begin{equation}
\on{Reg}(\varphi) = \int_0^1 R(\theta(t)) \,\mathrm{d} t\,,
\end{equation}
where $R$ does not depend on $\rho(t,\cdot)$.
The first possibility is a quadratic penalty for the single-hidden-layer vector field of \eqref{Eq:SingleHiddenLayer}, where $R(\theta(t)) = \frac 12 \| \theta(t) \|^2_2$ is the Frobenius norm of the parameter $\theta$.
Since the space of vector fields is a \emph{finite} dimensional linear space, it can be endowed with a scalar product, which turns this space into a Reproducing Kernel Hilbert Space (RKHS). Therefore, the linear in parameter - quadratic penalty setting of \S\ref{SecChoiceOfReg} is a particular case of vector fields encoded by $f(\cdot,\theta(t))\in H$, with $H$ a RKHS embedded in $W^{1,\infty}$ vector fields.
This setting
leverages strong analytical and geometrical foundations \cite{laurentbook,CompletenessDiffeomorphismGroup}:
1) When the activation function is smooth, the resulting vector field is smooth\footnote{I.e smoothness asks for Lipschitz regularity vector field, which ensures existence and uniqueness of the flow.}, and consequently the associated flow map $\varphi$ is guaranteed to be a one-to-one smooth map (i.e., a diffeomorphism). For instance, with the \texttt{UpDown}\ model, it is a homeomorphism in $(\mathbf{x},\v)$.
Moreover, the quadratic penalty induces a right-invariant distance on the set of flows generated by \eqref{EqDiffeomorphicFlows} and the distance to identity of the resulting flow can be bounded by $\on{Reg}(\varphi)$ (see~\cite{laurentbook,CompletenessDiffeomorphismGroup} for more details in a Sobolev setting). 2) When the activation function is of {\texttt{ReLU}} type, the resulting map is still a $W^{1,\infty}$ one-to-one map (i.e., a homeomorphism) and has Lipschitz regularity.
\par
Another type of regularization for the single-hidden-layer vector field of \eqref{Eq:SingleHiddenLayer} we discuss is based on the Barron norm \cite{e2019barron}:
\begin{equation*}
\| \theta \|_{\mathcal{B}}^2 := \frac 1{d'} \sum_{j = 1}^{d'}\| \theta_1^j \|_2^2 (\| [\theta_2]_j \|_1 + \| b_2^j \|_1)^2\enspace,
\end{equation*}
where $\theta_1^j$ denotes the $j^{\text{th}}$ column of $\theta_1$ and $[\theta_2]_j$ denotes the $j^{\text{th}}$ row of $\theta_2$.
As discussed in the main text, the reason we might consider a Barron norm penalty for the single-hidden-layer vector field in \eqref{Eq:SingleHiddenLayer} rather than the quadratic penalty is because of its theoretical results. Indeed, the Rademacher complexity is bounded
for the combination of a single-hidden-layer vector field with a Barron norm penalty, but not when combined with a quadratic penalty.
\subsection{Linear in parameters - quadratic energy}
\label{appendix:quadratic_energy}
Now let us examine in detail models that are \emph{linear} in parameters and have \emph{quadratic} energy on parameters: this case is the simplest to be studied, and computationally not as demanding as the nonlinear case. As mentioned above, the set of possible vector fields $f(\cdot,\theta(t))$ is a finite dimensional linear space, which is a reproducing kernel Hilbert space when endowed with an $L^2$ norm. Since all Hilbert norms in finite dimensions are equivalent, this choice of regularization is universal in this class of quadratic penalties.
\begin{enumerate}
\item The vector field is $f(\cdot,\theta(t)) = \theta \cdot \mathbf{\sigma}$, where $\mathbf{\sigma}$ is a vector of maps.
In this case, the optimality equation reads
\begin{equation*}
\partial_{\theta}f(\mathbf{x},\theta(t))^\top
(\nabla p(t,\mathbf{x}) \rho(t,\mathbf{x})) = \int_{{\mathbb R}^d} \mathbf{\sigma}(x)^\top(\nabla p(t,\mathbf{x}) \rho(t,\mathbf{x}))\,\mathrm{d} \mathbf{x} \,.
\end{equation*}
\item If the penalty $R$ only depends on $\theta$ and is quadratic: $R(\theta(t)) = \frac{1}{2}\int_0^1 \| \theta(t) \|^2 \,\mathrm{d} t$, then one has $\frac{\delta R}{\delta \theta}(\theta(t),\rho(t)) = \theta(t)$.
\end{enumerate}
Thus, under these two conditions, the parameters are \emph{explicit} in terms of $p$, $\rho$ and $\sigma$:
\begin{equation}\label{EqOptimalityEquationLinearInParameter}
\theta(t) = \int_{{\mathbb R}^d} \sigma(\mathbf{x})^\top(\nabla p(t,\mathbf{x}) \rho(t,\mathbf{x}))\,\mathrm{d} \mathbf{x}\,.
\end{equation}
Two observations are warranted. First, if, instead of quadratic regularization on the parameters, we were to choose a RKHS norm (in the infinite dimensional case) as penalty, it would result in the introduction of the kernel applied to the R.H.S. of \eqref{EqOptimalityEquationLinearInParameter}.
Second, from \eqref{EqOptimalityEquationLinearInParameter}, one could be tempted to derive an evolution equation for $\theta$. This equation is known as the EPDiff equation \cite{laurentbook} and is unfortunately not a closed equation on the set of parameters $\theta(t)$ themselves. Therefore, our approach is a possible way to approximate it.
An important property of this simple setting is that the norm of the vector field is preserved by the forward model defined by the collection of Hamiltonian particles and it also holds in the continuous setting. As stated in Section \ref{SecChoiceOfReg}, the Hamiltonian is given by $R(\theta(t)) = \frac{1}{2} \Tr\left(A(t)^\top M_{A} A(t)\right) + \frac{1}{2} b(t)^\top M_{b} b(t)$ where $A,b$ are the optimal parameters given by
\begin{equation}
\begin{cases}
A(t) \! &= {M_{A}}^{-1}(-\sum_{j=1}^K \mathbf{p}_j(t) \sigma(\mathbf{q}_j(t))^\top)\\
b(t) \! &= {M_{b}}^{-1}(-\sum_{j=1}^K \mathbf{p}_j(t))\,.
\end{cases}
\end{equation}
The Hamiltonian $R(\theta(t))$ being constant gives a constant norm vector field.
\subsection{Nonlinear in parameters - energy which depends on the distribution}\label{SecNonlinearInParameters}
For exposition purposes, we present two cases of interest which we have not well explored numerically.
\textbf{Example of the Barron norm.}
Obviously, the single-hidden-layer vector field in \eqref{Eq:SingleHiddenLayer} is not linear in parameters. We have already discussed that it is proper in this case to endow the space with norms such as the Barron norm \cite{e2019barron}.
For simplicity, consider the single-hidden-layer vector field in \eqref{Eq:SingleHiddenLayer} without $b_1$, i.e., $f(\mathbf{x}(t),\theta(t)) = \theta_1 \sigma(\theta_2(\mathbf{x}) + b_2)$. A simple upper bound for the Barron norm\footnote{The actual Barron norm is defined as the infimum of the r.h.s. in \eqref{EqBarronNormNotOptimized} on all the possible representations of the function $f(\cdot,\theta)$ as a single-hidden-layer.} is
\begin{equation}\label{EqBarronNormNotOptimized}
\| f(\cdot,\theta) \|_{\mathcal{B}}^2 := \frac 1{d'} \sum_{j = 1}^{d'}\| \theta_1^j \|_2^2 (\| [\theta_2]_j \|_1 + \|[b_2]_j\|_{1})^2\enspace.
\end{equation}
Again, $\theta_1^j$ denotes the $j^{\text{th}}$ column of $\theta_1$ and $[\theta_2]_j$ denotes the $j^{\text{th}}$ row of $\theta_2$.
Let us consider the case of $R(\theta(t)) = \frac 1 2 \| f(\cdot,\theta) \|_{\mathcal{B}}^2$.
In this case, one has the following optimality equations to solve
\begin{align*}
& \theta_1^j (\| [\theta_2]_j \|_1 + \| |[b_2]_j \|_1)^2 = \int_{{\mathbb R}^d} \sigma([\theta_2]_j\mathbf{x} + [b_2]_j)^\top(\nabla p(t,\mathbf{x}) \rho(t,\mathbf{x}))\,\mathrm{d} \mathbf{x}\,,\\
& \| \theta_1^j \|^2_2 (\| [\theta_2]_j \|_1 + \| [b_2]_j\|_1) \partial \| [\theta_2]_j^k \|_1 = \int_{{\mathbb R}^d}
[\,\mathrm{d} \sigma([\theta_2]_j\mathbf{x} + [b_2]_j)(\mathbf{x}_k)]^\top(\nabla p(t,x) \rho(t,\mathbf{x}))\,\mathrm{d} \mathbf{x} \,,\\
& \| \theta_1^j \|^2_2 (\| [\theta_2]_j \|_1 + \| [b_2]_j \|_1) \partial \| [b_2]_k^j \|_1 = \int_{{\mathbb R}^d}
[\,\mathrm{d} \sigma([\theta_2]_j\mathbf{x} + [b_2]_j)(\mathbf{x}_k)]^\top(\nabla p(t,\mathbf{x}) \rho(t,\mathbf{x}))\,\mathrm{d} \mathbf{x} \,.
\end{align*}
These equations involve the subdifferential of the $L^1$ norm, and optimization of this type of functions, which involves sparsity, is a well-explored field~\cite{MAL-015}.
We leave experiments with this norm for future work. Note that in this case the norm of the vector field is not equal to the Hamiltonian and it is not a constant of the flow.
\subsection{$L^2$ regularization, optimal transport}
Last, we briefly mention a model that is part of our framework which has the advantage of not specifying the penalty on the space of parameters encoding the vector field. In case there is no obvious norm to be used on the space of vector fields, it is possible to use an $L^2$ type of penalty on the vector fields themselves \mnrev{instead of on the parameters.}
Indeed, one way to be rather independent of the choice of the parameterization of the map consists in introducing a cost that represents the $L^2$ norm of the map. However, $L^2$ depends on the choice of a measure and this measure can be chosen as the density of the data, $\rho(t,\mathbf{x})$. More precisely, one can use
\begin{equation}\label{EqOTLike}
R(f,\rho(t)) = \frac 12 \int_{{\mathbb R}^d} \| f(\mathbf{x},\theta)\|^2 \rho(t,\mathbf{x}) \,\mathrm{d} \mathbf{x}\,.
\end{equation}
In such a case, this formulation resembles finding an optimal transport (OT) map between $\rho_0$ and $\rho_1$. Specifically,
optimal transport is an optimization problem which can be solved via a fluid dynamic formulation \cite{benamou2000computational} introducing the kinetic penalty above. However, the two models (OT and the one defined by the regularization \eqref{EqOTLike}) differ since the optimization set for optimal transport is the set of $L^2$ vector fields with respect to measure $\rho$ and the above formulation is a parameterized approximation of this set.
This parameterized approximation needs to retain generalization properties of the optimized map. Note however, that in the limit where the number of neurons goes to infinity, optimal transport will be well-approximated since the optimization is performed on a dense subset of all vector fields. Obviously, fixing the choice to a single-hidden-layer design implies a choice for $d'$ in $\theta_1(t) \in L({\mathbb R}^{d'},{\mathbb R}^d)$ and $\theta_2(t) \in L({\mathbb R}^d,{\mathbb R}^{d'})$ of ~\eqref{Eq:SingleHiddenLayer}, which thus gives a regularization of the computed approximation of the optimal transport map.
\textbf{Computational burden.}
In either case of the Barron norm or the optimal transport type of penalty, the implicit equation corresponding to the third equation in \eqref{EqOptimalityEquations_density} has to be solved at each layer of the discretization.
We experimented with a simple strategy of unrolling the related minimization scheme. An efficient approach to solve such implicit equations will be necessary for practical implementations.
\subsection{Rademacher complexity of bounded energy flows. }\label{SecRademacher}
In this section, given a set of vector fields with bounded Rademacher complexity, we show that the resulting flows also have bounded Rademacher complexity.
The flow of a vector field $f(\cdot,\theta(t))$ is a vector valued map denoted by $\varphi$.
Let us first treat the case of the Rademacher complexity of a component of the flow map $\varphi^k$.
\begin{theorem}\label{ThRademacher}
Let $\mathcal{F}$ be a space of vector fields defined on a compact space $C \subset {\mathbb R}^d$. Assume that the Rademacher complexity on $n$ points in $C$ of each component of the vector fields $f^k(t,\cdot)$ for $k = 1,\ldots,d$ is controlled by $M(n,t)$ which depends on $n$, then the Rademacher complexity of each component of the flows at time $1$ is bounded by $\int_0^1 M(n,t) \,\mathrm{d} t$.
\end{theorem}
\begin{proof}
Recall that Rademacher complexity, see \cite{wainwright2019high}, of a class of functions $\mathcal{F}$ is defined as, for $\mathbf{Z} = (\mathbf{z}_1,\ldots,\mathbf{z}_n) \in C$,
\begin{equation*}
\on{Rad}_{\mathbf{Z}}(\mathcal{F})\ensuremath{\stackrel{\mbox{\upshape\tiny def.}}{=}} \mathbb{E}\left[\sup_{g \in \mathcal{F}} \sum_{i = 1}^n \varepsilon_i g(\mathbf{z}_i)\right]\,,
\end{equation*}
where the $\{\varepsilon_i\}_{i = 1}^n$ are i.i.d. Rademacher random variables. Our hypothesis ensures
$\on{Rad}_{\mathbf{Z}}(\mathcal{F}) \leq M(n)$. Apply the definition of the flow to get
\begin{equation*}
\varphi(1,\mathbf{x}) = \mathbf{x} + \int_0^1 f(\varphi(t,\mathbf{x}),\theta(t)) \,\mathrm{d} t\,.
\end{equation*}
Therefore,
\begin{align*}
\mathbb{E}\left[\sup_{\varphi \in \mathcal{F}} \sum_{i = 1}^n \varepsilon_i \varphi^k(\mathbf{z}_i)\right] &\leq \on{Rad}_{\mathbf{Z}}(\{\on{Id}\}) + \int_0^1 \mathbb{E}\left[\sup_{f(\cdot,\theta(t))}\sum_{i = 1}^n \varepsilon_i f^k(\varphi(t,\mathbf{z}_i),\theta(t))\right] \,\mathrm{d} t\,,\\
&\leq 0 + \int_0^1 M(n,t) \,\mathrm{d} t \,.
\end{align*}
In the previous formula, we used the fact that the Rademacher complexity of a set comprised of a single map is zero.
\end{proof}
\begin{corollary}
Let $H$ be a RKHS of vector fields whose kernel $\mathsf{k}$ is bounded on the diagonal $\| \mathsf{k}(\mathbf{x},\mathbf{x})^k \|_\infty < \infty$ , then, the set of flows denoted by $\mathcal{F}$ at time $1$ of time-dependent vector fields in $\mathcal B(0,R)$, the ball of radius $R$ centered at the origin satisfies $\on{Rad}_{\mathbf{Z}}(\mathcal{F}) \leq \frac{2R \sqrt{\| \mathsf{k}(\mathbf{x},\mathbf{x})^k \|_\infty}}{\sqrt{n}}$, where $\on{Rad}_{\mathbf{Z}}(\mathcal{F})$ is the Rademacher complexity for $n$ points.
\end{corollary}
\begin{proof}
The Rademacher complexity of the ball of radius $R$ in the RKHS $H$ \cite[Lemma~22]{bartlett} is upper bounded: $\on{Rad}_{\mathbf{Z}}(\mathcal{B}(0,R)) \leq \frac{2R \sqrt{\| \mathsf{k}(\mathbf{x},\mathbf{x})^k \|_\infty}}{\sqrt{n}}$. We then directly apply Theorem \ref{ThRademacher}.
\end{proof}
A similar result also holds for vector fields generated by the single-hidden-layer vector field in \eqref{Eq:SingleHiddenLayer}, see \cite{e2019barron}.
Last, we note that the result and its proof also hold if one uses the following Rademacher complexity for vector valued functions \cite{RademacherVectorValued},
\begin{equation*}
\on{Rad}_{\mathbf{Z}}(\mathcal{F})\ensuremath{\stackrel{\mbox{\upshape\tiny def.}}{=}} \mathbb{E}\left[\sup_{g \in \mathcal{F}} \sum_{i = 1}^n\sum_{j =1}^d \varepsilon_j \varepsilon_i g_j(\mathbf{z}_i)\right]\,,
\end{equation*}
for $g = (g_j)_{j = 1,\ldots,d} \in \mathcal{F}$.
\subsection{Consequences for the \texttt{UpDown} model}\label{SecAppendixConsequencesUpDown}
We put together the previous results on the \texttt{UpDown} model. First, the space of vector fields endowed with the quadratic penalty on the parameters forms a RKHS.
The variational formulation implies that the norm of the velocity field generated by a given collection of Hamiltonian particles $\{(\mathbf{q}_j(0),\mathbf{p}_j(0))\}$ is preserved. In addition, this norm can be explicitly computed since the parameters at time $0$ can be computed in terms of $\{(\mathbf{q}_j(0),\mathbf{p}_j(0))\}$. Last, the generated space of maps has a Rademacher complexity which is linearly bounded by this norm. In order to be fully explicit on the constant for the Rademacher complexity, we need to compute $\sup_{x \in C} \| \mathsf{k}(x,x) \|$ where $\mathsf{k}$ is the kernel associated with the RKHS. Without making this quantity explicit here, we simply mention that the bound degrades (i.e. increases) with increasing inflation factor $\alpha$, as it can be expected.
\section{Analysis of the number of free parameters}
\label{appendix:freeparams}
It is instructive to understand the number of parameters for a shooting approach in comparison to the typical approach of optimizing a neural network (where the parameter-dependency at optimality is only considered implicitly at convergence of the numerical solution rather than explicitly during the shooting). We focus on the cases of affine and convolutional layers for illustration.
Consider a DNN with a depth of $L$ layers, where each hidden layer has $P$ parameters. The number of free parameters is then $LP$, compared to $2KS$ where $K$ is the number of active particles, each of them of size $2S$\footnote{For example, $S$ for our {\texttt{UpDown}} model simply corresponds to the dimension of its state space: $S=(\alpha+1)d$, where $\alpha$ is the inflation factor and $d$ the data dimension. Note that in our experiments with the {\texttt{UpDown}} model we also learned an affine map from the initial conditions $\mathbf{x}(0)$ to the initial conditions $\v(0)$. Such a map has $\alpha d(d+1)$ parameters. These parameters are included in the table of Fig.~\ref{fig:spiral_short_long_range} and in Tables~\ref{tab:number_of_parameters_simple_functions}/\ref{tab:number_of_parameters_spiral} summarizing the number of mode parameters. However, we will not consider parameters in our discussion here, as they would equally apply to both a shooting and a direct optimization approach and could also be avoided by simply initializing $\v(0)$ to zero. A similar initialization to zero approach is, for example, commonly taken in {\texttt{ResNet}s} when increasing the number of feature channels~\cite{he2016deep}.}. Hence, solutions with less than $LP/(2S)$ particles provide benefits in the number of free parameters. Therefore, as the number of particles is reduced, we may parameterize the DNN with a smaller number of parameters. \emph{Most remarkably, the number of free parameters is always $2KS$ regardless of the number of parameters of a particular layer as the layer parameters are obtained via the shooting equations based on the particle states.} This is a consequence of regularizing the parameters in our loss which couples them across time at optimality. We make this clearer in what follows.
\textbf{Affine layers.} Recall that in our simple example of \S\ref{SecChoiceOfReg} the parameters $\theta(t)=[A(t),b(t)]$ of our affine\footnote{In this section, we mean affine with respect to $(\sigma(\mathbf{q}_j(t)))_{j \in 1,\ldots,K}$.} model are given as
\begin{equation}
A(t) \! = {M_{A}}^{-1}\left(-\sum_{j=1}^K \mathbf{p}_j(t) \sigma(\mathbf{q}_j(t))^\top\right),\quad
b(t) \! = {M_{b}}^{-1}\left(-\sum_{j=1}^K \mathbf{p}_j(t)\right)\enspace.
\label{eq:parameters_for_affine_model}
\end{equation}
Here, $A(t)$ and $b(t)$ have $d^2$ and $d$ parameters, respectively; these parameters are indirectly given by the set of particles $\{(\mathbf{q}_j(t),\mathbf{p}_j(t))\}$ at any given time. Hence, for this model $S=d$ and $P=d(d+1)$. If we assume we have $K$ particles and compare to a discrete layer implementation of this model then the particle-based approach will have less free parameters if
\begin{equation*}
2Kd < L d(d+1)\enspace.
\end{equation*}
Importantly, the state-space dimension, $d$, only enters the number of free parameters linearly for the particle approach ($2Kd$), while there is a quadratic dependence for direct optimization ($Ld(d+1)$). This is a direct consequence of the optimality condition which couples the parameters $\theta(t)$ across time. One can see this phenomenon in action in~\eqref{eq:parameters_for_affine_model}, where the matrix $A$ is expressed as the sum of matrices $\mathbf{p}_j(t) \sigma(\mathbf{q}_j(t))^\top$ with rank $\leq 1$. Concretely, a particle-based shooting approach uses less parameters if the number of particles $K<L(d+1)/2$. Another interesting observation based on this example is that even if we would have only considered a linear model (i.e., without the bias term, $b(t)$) the number of parameters for the particles would have still remained at $2KS$. This is again a consequence of optimality and of our parameter regularization. Note that this also means that even though our {\texttt{UpDown}} model
\begin{equation*}
\dot{\mathbf{x}}(t) = \theta_1(t) \sigma(\v(t)) + b_1(t),\quad
\dot{\v}(t) = \theta_2(t) \mathbf{x}(t) + b_2(t) + \theta_3(t) \sigma(\v(t))\,,
\end{equation*}
has significantly more parameters $\theta(t)=[\theta_1(t),b_1(t),\theta_2(t),b_2(t),\theta_3(t)]$ when directly optimized, this has no direct impact on the number of free parameters of its particle-based parameterization. Only the state-space dimension matters. Concretely, if we were to instead consider a model of the form
\begin{equation*}
\dot{\mathbf{x}}(t) = \theta_1(t) \sigma(\v(t)),\quad
\dot{\v}(t) = \theta_2(t) \mathbf{x}(t)\,,
\end{equation*}
the particle-based parameterization would stay \emph{unchanged!} Only the way how one infers $\theta(t)$ from the particles changes.
\textbf{Convolutional layers.} Shooting approaches for convolutional models can also be derived. We did not experiment with such models in this work. However, we show here that the number of free parameters may also be decreased with a particle-based approach. This will be interesting to explore in future work. Specifically, for convolutional layers a particle-based parameterization could be particularly effective as one typically has quadratic complexity in the number of filters between convolutional layers (i.e., if a layer with $N$ feature channels is followed by a layer with $M$ feature channels, this will induce the estimation of $N\times M$ convolutional filters and hence will drastically influence the number of parameters for large $N$ or $M$). In contrast, a particle-based shooting approach does not increase the number of parameters as it ties them together via the optimality conditions expressed by the shooting equations. As a rough estimate for a standard convolutional \texttt{ResNet}\, for $L = 50$, $P = 100^2 \times 16$, $LP \approx 8.10^6$. Thus, if particles have size $40$, we end up with at most $10^5$ active particles.
\textbf{General remarks.} Nevertheless, all model parameters (e.g., $[A(t),b(t)]$ or all convolutional filters for a convolutional layer) are still instantiated during computation. It is important to note that regardless of the chosen number of particles, a shooting neural network solution is a possible optimal solution (for a given data set) at any given time, not only at convergence. One optimizes over the family of possible neural network models with the goal of finding the element within this family that best matches the observations.
\section{Automatic shooting}
\label{appendix:automatic_shooting}
The general shooting equations were presented in \eqref{EqOptimalityEquations}. We then proceeded to explicitly derive the shooting equations for a continuous DNN with linear-in-parameter layers and \texttt{UpDown}\ layers in \S\ref{SecChoiceOfReg} and \S\ref{sec:updownNODE}, respectively. While this was instructive, it is somewhat cumbersome, in particular, for more complex models or when moving to convolutional networks. Fortunately, in practice these shooting equations do not need to be derived by hand. Indeed, they are completely specified by the Hamiltonian
$$
H(\mathbf{p},\mathbf{x},\theta) = \mathbf{p}^\top (\dot{\mathbf{x}} - f(t,\mathbf{x},\theta)) + R(\theta)\enspace,
$$
in the sense that the shooting equations in \eqref{EqOptimalityEquations} are computed via differentiation of $H$. Specifically, the shooting equations in \eqref{EqOptimalityEquations} are equivalently given by
\begin{align*}
\begin{cases}
\dot{\mathbf{x}} = \frac{\partial H(\mathbf{p},\mathbf{x},\theta)}{\partial p}\,, \\
\dot{\mathbf{p}} = -\frac{\partial H(\mathbf{p},\mathbf{x},\theta)}{\partial x}\,,\\
\theta \in \argmin_{\theta} H(\mathbf{p},\mathbf{x},\theta)\,.
\end{cases}
\end{align*}
As discussed above, the last equation can be replaced by solving
$$
\partial_\theta R(\theta) - \sum_{i = 1}^N\partial_\theta f(t,\mathbf{x}_i,\theta)^T(\mathbf{p}_i) = 0\enspace.
$$
Automatic differentiation can be used to automatically obtain the shooting equations.
As fitting a shooting model requires differentiating the shooting equations, we in effect end up with differentiating twice. This can be done seamlessly using modern deep learning libraries, such as \texttt{PyTorch}.
\section{Universality of the \texttt{UpDown}\ model}
\label{appendix:updown_universal}
In this section, we set out to demonstrate that the \texttt{UpDown}\ model is universal in the sense that its associated flow can come $\varepsilon$-close to the flow of any well behaving time-dependent vector field.
Recall the single-hidden-layer vector field in \eqref{Eq:SingleHiddenLayer} with time-varying parameters $\theta(t)=(\theta_1(t),\theta_2(t),b_1(t), b_2(t))$.
While shooting with the single hidden layer vector field is theoretically appealing as it is universal \cite{Cybenko1989}, it would result in implicit shooting equations.
We first show that the \texttt{UpDown}\ model introduced in \ref{sec:updownNODE} can give the same flow as the single hidden layer (Lemma \ref{lem:updown_shl}) and then leverage this relationship to show that the \texttt{UpDown}\ model inherits the universality of the single hidden layer (Proposition \ref{prop:updown_universal}).
\begin{lemma}\label{ThLemma1}
Consider the single-hidden-layer vector field in \eqref{Eq:SingleHiddenLayer} with $\theta_2(t)$ and $b_2(t)$ being piecewise $C^1$ and $\theta_1(t),b_1(t)$ continuous. Then, there exists a parameterization of the {\texttt{UpDown}} model that gives the same flow at a fixed time, $T=1$.
\end{lemma}
\begin{proof}
We rewrite the differential equation
\begin{equation*}
\dot{\mathbf{q}}(t) = \theta_1(t) \sigma (\theta_2(t) \mathbf{q} + b_2(t)) + b_1(t)\,,
\end{equation*}
by introducing the additional state variable $\v(t) = \theta_2(t) \mathbf{q}(t) + b_2(t)$ which we differentiate w.r.t. time.
We obtain $\dot{\v}(t) = \dot{\theta}_2(t) \mathbf{q}(t) + \dot{b}_2(t) + \theta_2(t) \dot{\mathbf{q}}(t) \,.$ Replacing $\dot{\mathbf{q}}(t)$ by its formula, we get
\begin{equation*}
\dot{\v}(t) = \dot{\theta}_2(t) \mathbf{q}(t) + \dot{b}_2(t) + \theta_2(t) \theta_1(t)( \sigma (\v(t)) + b_1(t))\,.
\end{equation*}
The system can be rewritten as
\begin{equation}
\begin{cases}\label{EqSystemUpdown}
\dot{\mathbf{q}}(t) = \theta_1(t) \sigma (\v(t)) + b_1(t)\,,\\
\dot{\v}(t) = \theta_3(t) \mathbf{q}(t) + \theta_4(t)\sigma (\v(t)) + b_3(t)\,.
\end{cases}
\end{equation}
Therefore, with the initial condition $\v(0) = \theta_2(0)\mathbf{q}(0)$ and $\mathbf{q}(0) = \mathbf{q}_0$, the two systems of ordinary differential equations are equivalent.
\end{proof}
Note that the key point in Lemma \ref{ThLemma1} is the loss of regularity in the evolution of $\theta_2$ since we differentiated once in time. For that reason, we now show that adding more dimensions using the inflation factor $\alpha$ alleviate this issue.
It is likely possible that one could prove a universality result using only $\alpha = 1$ but we shall leave this question for future work\footnote{Note that the case $\alpha =1$ is similar in its formulation to a second-order model on $\mathbf{q}$.}. However, experimentally, the inflation factor has a crucial effect on the performance of the optimization, as discussed in \S\ref{section:experiments}. Lemma \ref{ThLemma1} helps us establish the next result.
\begin{lemma}\label{lem:updown_shl}
Consider the single-hidden-layer vector field in \eqref{Eq:SingleHiddenLayer} with $\theta(t)$ being piecewise continuous. Then, there exists a parameterization of the \texttt{UpDown}\ model that gives the same flow.
\end{lemma}
\begin{proof}
Without loss of generality, we only treat the case of one discontinuity in time of the parameterization; We thus assume that $\theta(t)$ is continuous on $[0,t_1[$ and $[t_1,1]$. We consider $\mathbf{q},\v_1,\v_2 \in {\mathbb R}^d$ such that $\mathbf{q},\v_1$ are defined as in Lemma~\ref{ThLemma1}.
We now define, up to time $t_1$, $\v_2(t) = \theta(t_1) \v_1(t) + \theta_2(t_1)$ which implies (differentiating w.r.t. time) that $\v_2$ follows an evolution equation similar to $\v_1$ and thus can be encoded in the general form of~\eqref{EqSystemUpdown}.
Now, $\mathbf{q}(t),\v_2(t)$ are defined on $[t_1,1]$ by the evolution \eqref{EqSystemUpdown} in order to coincide with the flow of single-hidden-layer vector field on $[t_1,1]$, $ \dot{\mathbf{q}}(t) = \theta_1(t) \sigma (\v_2(t)) + b_1(t)$ and $\dot{\v}_2(t) = \theta_3(t) \mathbf{q}(t) + \theta_4(t)\sigma (\v_2(t)) + b_3(t)$ for well chosen parameters as in Lemma~\ref{ThLemma1}. Since the value of $\v_1(t)$ is not used in the evolution equation of $\mathbf{q}(t) $, we can simply extend it by $\v_1(t) = \v_1(t_1)$ which is a valid evolution equation for~\eqref{EqSystemUpdown}.
\par
In the general case, we decompose the time interval $[0,1]$ into $k$ intervals $[t_i,t_{i + 1}[$ on which $\theta(t)$ is continuous and the proposed method can be directly extended using an inflation factor $\alpha = k$, introducing $\v_k \in {\mathbb R}^d$.
\end{proof}
Note that the result of this lemma gives an equality between the two flows defined on the \emph{whole} space ${\mathbb R}^d$.
The next result is an approximation result which holds on a compact domain $C \subset {\mathbb R}^d$. For a function $f: {\mathbb R}^d \to {\mathbb R}$, we denote $\| f \|_{C,\infty} = \sup_{x \in C} |f(x)|$.
\begin{proposition}\label{prop:updown_universal}
The \texttt{UpDown}\ model is universal in the class of time-dependent vector fields. Let $C \subset {\mathbb R}^d$ be a compact domain. For every time-dependent vector field (such that it is time continuous and is Lipschitz in space) $w: [0,1] \times {\mathbb R}^d \mapsto {\mathbb R}^d$ and its associated flow $\varphi(t,\mathbf{x})$ there exist time dependent parameters of the \texttt{UpDown}\ model such that
\begin{equation*}
\begin{cases}
\dot{\mathbf{q}}(t) = \theta_1(t) \sigma(\v(t)) + b_1(t) \,,\\
\dot{\v}(t) = \theta_2(t) (\mathbf{q}(t) ) + b_2 + \theta_3(t) \sigma(\v(t) )\,,
\end{cases}
\end{equation*}
is $\varepsilon$-close to the solution $\varphi(1,\mathbf{x})$, e.g. $\| \varphi(1,\mathbf{x}) - \mathbf{q}(1,\mathbf{x}) \|_{C,\infty} \leq \varepsilon$.
\end{proposition}
\begin{proof}
The proof is standard and we include it here for self-containedness. It is the consequence of \cite{Cybenko1989} and Lemma \ref{lem:updown_shl}. Let $B(0,r)$ a ball of radius $r$ in ${\mathbb R}^d$ which contains $\varphi(t,\mathbf{x})$ for all time $t \in [0,1]$. The flow associated with a given time-dependent vector field $v(t,\cdot)$ can be approximated by a vector field which is piecewise constant in time; i.e. let $\varepsilon >0$ be a positive real, (by continuity in time of $v(t,\cdot)$) there exists a decomposition of $[0,1]$ into $k$ intervals $[t_i,t_{i + 1}]$ and Lipschitz vector fields $v_i(\mathbf{x}) = f(\mathbf{x},\theta_i)$ where $f$ is the single hidden layer in \eqref{Eq:SingleHiddenLayer} such that
$\| v_i(\mathbf{x}) - v(t,\mathbf{x}) \|_{B(0,r),\infty} \leq \varepsilon$ for $t \in [t_i,t_{i + 1}]$. Denote by $w(t,\cdot)$ the time-dependent vector field defined by $w(t,\cdot) = v_i(\cdot)$ for all $t \in [t_i,t_{i + 1}]$. Thus, denoting the flow of $v(t,\cdot)$ by $\varphi^v$ and the flow of $w(t,\cdot)$ by $\varphi^w$, we get
\begin{align*}
&\|\varphi^v(1,\mathbf{x}) - \varphi^{w}(1,\mathbf{x}) \| \leq \int_0^1 \| v(t,\varphi^v(t,\mathbf{x})) - v(t,\varphi^{w}(t,\mathbf{x}))\| + \| v(t,\varphi^{w}(t,\mathbf{x})) - w(t,\varphi^{w}(t,\mathbf{x}))\| \,\mathrm{d} t \,\\
&\|\varphi^v(1,\mathbf{x}) - \varphi^{w}(1,\mathbf{x}) \|_{C,\infty} \leq \int_0^1 \on{Lip}(v) \|\varphi^v(t,\mathbf{x}) - \varphi^{w}(t,\mathbf{x}) \|_{C,\infty} + \| v(t,\cdot) - w(\cdot)\|_{B(0,r),\infty} \,\mathrm{d} t\\
& \phantom{\|\varphi^v(1,\mathbf{x}) - \varphi^{w}(1,\mathbf{x}) \|_{K,\infty} } \leq \int_0^1 \on{Lip}(v) \|\varphi^v(t,\mathbf{x}) - \varphi^{w}(t,\mathbf{x}) \|_{C,\infty} \,\mathrm{d} t + \varepsilon\,,
\end{align*}
where $\on{Lip}(v)$ denotes a bound on the Lipschitz constant of $v(t,\mathbf{x})$ w.r.t. $\mathbf{x} \in B(0,r)$ for all $t\in [0,1]$.
Then, the Gr\"onwall lemma \cite{laurentbook} gives
\begin{equation}
\|\varphi^v(1,\mathbf{x}) - \varphi^{w}(1,\mathbf{x}) \|_{C,\infty} \leq \varepsilon e^{\on{Lip}(v)}\,.
\end{equation}
By Lemma~\ref{lem:updown_shl}, $\varphi^{w}(1,\mathbf{x})$ can be approximated by the flow of the \texttt{UpDown}\ and the result is obtained via the triangle inequality.
\end{proof}
In this section, we focused on a universality result in the space of time-dependent vector fields. Interestingly, due to the additional dimensions, it is likely that the model is universal in the space of functions as well. This conjecture is supported by the quadratic 1D function regression example which shows that the \texttt{UpDown}\ model is able to capture some maps which are not homeomorphic.
We leave this question for future work.
\section{Experimental settings}
\label{appendix:experimental_settings}
This section describes our experimental settings. We use our {\texttt{UpDown}} model for all experiments and simply use a weighted Frobenius norm penalty for all parameters. Specifically, we weigh this penalty for all parameters with $1$ except for, $\theta_3$ which we penalize by 10. In our experiments, we have observed better convergence properties for higher penalties on $\theta_3$. This might be due to the special role that $\theta_3$ plays in the model as it subsumes a quadratic term in the original derivation of the {\texttt{UpDown}} model (see \S\ref{sec:updownNODE}). In all experiments, we also optimize over the affine map from $x(0)$ to $v(0)$ for the data evolution.
\textbf{Simple function regression.} We use 500 epochs for all experiments. For all particle-based experiments we freeze the positions of the particles for the first 50 epochs. We use a {\texttt{ReLU}} activation function and the MSE loss. We weigh the MSE loss by 100 and the parameter norm loss by 1. We use 500 training samples, 1,000 testing samples and 1,000 validation samples and a batch size of 50. Note that for these simple examples there is, in practice, no real difference between the training, testing, and validation data, as the number of samples is large and the domain is $[-1.5,1.5]$. We initialize the particle positions uniformly at random in $[-1.5,1.5]$ and draw the momenta from a Gaussian distribution with zero mean and standard deviation $0.1$. All time-integrations are done via a fourth-order Runge-Kutta integrator with time-step 0.1. For optimization, we use {\texttt{Adam}} with a learning rate of 0.01 and the \texttt{ReduceLROnPlateau} learning rate scheduler of {\texttt{PyTorch}} with a learning rate reduction factor of 0.5.
\textbf{Spiral.} The spiral data is generated between time $t=0$ and $t=10$ with 200 uniformly spaced timepoints. Training is only on small time snippets with an approximate length of $0.25$ time-units. Evaluation is on these short time snippets as well as on the entire trajectory by pasting together solutions for these short time snippets, i.e., an individual short solution starts where the previous one ends. Settings for the spiral are the same as for the simple function regression with the following exceptions. We use 1,500 epochs and the step-size for the fourth-order Runge-Kutta integrator is 0.05. The MSE loss is still weighted by 100, but the parameter norm loss only by 0.01. We randomly draw 100 new training samples during each epoch and use 100 evaluation samples and 1,000 short range samples and 1 long-range testing sample. All samples are randomly drawn from the trajectory. However, as the trajectory is traversed at highly nonuniform speed the samples are drawn from a uniform distribution across the trace of the spiral. As for the simple function regression experiment, there is little practical difference between the training, validation, and testing data as the problem is so simple. However, this is not of concern in these experiments as the prime objective is to study the fitting behavior of the different models. We use a batch size of 100.
\textbf{Rotating MNIST.} We use the data provided by the authors of \cite{Yildiz19a} and follow the same autoencoder architecture, except that our encoder maps into a 20-dimensional
representation space. The
number of particles is set to 100 and the inflation factor $\alpha$ is set to 10. For optimization, we use
{\texttt{Adam}} with a learning rate of 0.001 and the \texttt{CosineAnnealingLR} learning rate scheduler of {\texttt{PyTorch}}. We train for 500 epochs with a batch size of 25 and the parameter norm loss set to 0.1.
\textbf{Bouncing balls.} As in the rotating MNIST experiment, we rely on the data provided by the authors of \cite{Yildiz19a},
follow their autoencoder architecture and set the dimensionality
of the representation space of the encoder to 50. The first three images of each sequence are provided to the encoder by concatenating the images along the channel dimension. The inflation factor $\alpha$ is set to 20 and we use 100 particles.
We optimize over 100 epoch using {\texttt{Adam}} with the \texttt{CosineAnnealingLR} learning rate scheduler of {\texttt{PyTorch}}, the initial learning rate is set to 0.001 and the parameter norm loss is set to 0.0001.
\section{Additional results}
\label{appendix:figures_results}
\input{cubic_quadratic_and_spiral}
| {'timestamp': '2020-12-09T02:24:40', 'yymm': '2006', 'arxiv_id': '2006.10330', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10330'} | arxiv |
\section{Introduction}\label{sec:intro}
In recent years, generative adversarial networks (GANs) \cite{DBLP:journals/corr/GoodfellowPMXWOCB14} have been widely applied to numerous types of image generation tasks, such as single image super-resolution \cite{DBLP:conf/cvpr/LedigTHCCAATTWS17,DBLP:conf/eccv/WangYWGLDQL18}, image-to-image translation \cite{DBLP:conf/iccv/ZhuPIE17,DBLP:conf/cvpr/IsolaZZE17}, image inpainting \cite{DBLP:conf/cvpr/Yu0YSLH18,DBLP:conf/cvpr/Yeh0LSHD17} and image deblurring \cite{DBLP:conf/cvpr/KupynBMMM18,DBLP:conf/cvpr/LuCC19}. In a nutshell, GANs are a framework to produce a generated distribution to match a given target distribution. The architecture of GANs consists of a generator that produces the generated distribution and a discriminator that evaluates the discrepancy between the generated and real data distributions. The generator and the discriminator are trained alternatively with the adversarial loss. To improve the quality of the generated images, the perceptual loss \cite{DBLP:conf/eccv/JohnsonAF16} is usually used to measure the discrepancy of the high-level features on image generation tasks \cite{DBLP:conf/cvpr/LedigTHCCAATTWS17,DBLP:conf/eccv/WangYWGLDQL18,DBLP:journals/corr/ZhangSP17,DBLP:conf/cvpr/KupynBMMM18}. Nevertheless, the perceptual loss is measured by an external pre-trained convolutional neural network. It generally employs the VGGNet-16/19 \cite{DBLP:journals/corr/SimonyanZ14a} pre-trained on the ImageNet dataset \cite{DBLP:journals/ijcv/RussakovskyDSKS15}. In this case, the perceptual loss mainly focuses on the high-level features that contribute to the specific classification task, and therefore, may perform inferiorly on the other tasks. Moreover, utilizing an external network as the feature extractor ignores the fact that the discriminator in GANs can learn the representations of the images and measure the discrepancy between them.
In addition, there is a persisting challenge in the training of GANs \cite{DBLP:conf/nips/SalimansGZCRCC16,DBLP:conf/iclr/ArjovskyB17}. When the generated distribution and the real data distribution are perfectly distinguished by the discriminator, the training of the generator comes will be stopped, as the gradient produced by the discriminator is $0$. A typical cause of this issue is that the discriminator rapidly overpowers the generator. To address this problem, Sajjadi et al. \cite{DBLP:conf/icml/SajjadiPMS18} propose a module to degrade the real data before feeding them to the discriminator, which balances the training of the generator and discriminator. However, this method greatly slows down the learning speed of the discriminator and the whole network.
In this paper, we propose a general framework, named Progressively Unfreezing Perceptual GAN (PUPGAN), which can generate images with fine texture details. Particularly, we propose an adaptive perceptual discriminator architecture, which utilizes a pre-trained dense block~\cite{DBLP:conf/cvpr/HuangLMW17} as a perceptual feature extractor, and the capability encoded in the percetual feature extractor can be transferred to the current task. The last layer in the feature extractor obtains multi-level features from all preceding layers. Following the perceptual feature extractor, the discriminative learning layers are used to measure the discrepancy between the multi-level features of the generated and real images. In addition, we propose a progressively unfreezing scheme to stabilize the training of PUPGAN. Specifically, we unfreeze the parameters in the perceptual feature extractor layer-by-layer during the training process.
\begin{figure}[t]
\centering
\includegraphics[width=\textwidth]{firstfig.pdf}
\caption{The images generated by PUPGAN: ($left$) for single image super-resolution; ($center$) for paired image-to-image translation; ($right$) for unpaired image-to-image translation.}
\label{fig:first}
\end{figure}
In summary, we make the following contributions in this work:\vspace{-0.3cm}
\begin{itemize}
\item We propose a general framework, called PUPGAN, for image generation with fine texture details. It can be applied to various scenarios to improve the texture details of the images generated by GANs-based models.
\item We propose an adaptive perceptual discriminator to measure the discrepancy between multi-level features of the generated and real images. In contrast to traditional perceptual loss based on an external network, we fully exploit the capability of the discriminator for multi-level feature extraction.
\item We propose a progressively unfreezing scheme for PUPGAN, to smoothly transfer external knowledge learned on large scale applications to the current task.
\item We have demonstrated the effectiveness of PUPGAN on several tasks, as shown in Fig.~\ref{fig:first}. In particular, we have applied PUPGAN to unpaired image-to-image translation and obtained promising results. To our best, this is the first work to efficiently exploit the external knowledge and adapt it to the GANs-based unpaired image-to-image translation.
\end{itemize}
\section{Related Work}\label{sec:rw}
Since Goodfellow et al. \cite{DBLP:journals/corr/GoodfellowPMXWOCB14} introduced GANs, they have received more and more attention from the deep learning community. Radford et al. \cite{DBLP:journals/corr/RadfordMC15} modified the architecture of GANs with convolutional layers \cite{DBLP:conf/icml/IoffeS15} to improve their performance and stabilize their training. Following this methodology, Salimans et al. \cite{DBLP:conf/nips/SalimansGZCRCC16} proposed several techniques to encourage the convergence of GANs, such as feature matching and minibatch discrimination.
To further improve the learning capability of GANs, the researchers proposed to train GANs with additional loss functions, such as pixel-wise loss and perceptual loss \cite{DBLP:conf/eccv/JohnsonAF16}. The reason behind this is that additional measurement can help to better evaluate the discrepancy between the generated image distribution and the real one. Specifically, the perceptual loss encourages the generated images to have similar high-level features with the real image. Though integrating perceptual loss to GANs has produced impressive results, it depends on the external convolutional neural network (e.g., VGGNet-19 \cite{DBLP:journals/corr/SimonyanZ14a}) trained on a specific classification task. As a result, the perceptual loss mainly focuses on high-level features relevant to the original dataset, e.g., ImageNet~\cite{DBLP:journals/ijcv/RussakovskyDSKS15}. Recently, Li et al. \cite{DBLP:conf/cvpr/LiLWXFY17} proposed a perceptual GAN for small object detection. The discriminator of this perceptual GAN consists of a perception branch. In addition, Wang et al. \cite{DBLP:journals/tip/WangXWT18} proposed a perceptual adversarial loss to train an image-to-image transformation network. The VGGNet was adopted as an internal perception function in the discriminator. Moreover, Sungatullina et al. \cite{DBLP:conf/eccv/SungatullinaZUL18} proposed a perceputal discriminator, which embeded a pre-trained feature extractor (VGGNet) inside the discriminator. However, the parameters in the pre-trained feature extractor were fixed during training. These approaches have improved the quality of the generated image to some extent. Nevertheless, the high-level features contribute to the specific classsication task and may perform inferiorly on the other tasks. In this work, we embed a well-trained dense block into the discriminator of the proposed PUPGAN. With the fine-tuning of the adaptive perceptual discriminator, PUPGAN can sufficiently leverage the external knowledge and adapt to the current task.
In order to overcome the unstable training problem of GANs due to the discriminator overpowering the generator, some efforts have been made. Sajjadi et al. \cite{DBLP:conf/icml/SajjadiPMS18} introduced a convolutional model to balance the generator and discriminator by gradually revealing the details of the real data. This method encourages a smooth training procedure. However, it slows down the training speed of the entire network. Karras et al. \cite{DBLP:conf/iclr/KarrasALL18} proposed to grow the generator and discriminator progressively by adding new layers to both the generator and discriminator as the training progresses. In this work, we propose a progressively unfreezing scheme for PUPGAN, which is quite different from the previous approaches.
Similar to GANs, PUPGAN can be considered as a general framework for generating images with fine texture details. It can be used for various image generation tasks. Among others, in this work, we have applied PUPGAN to the unpaired image-to-image translation task, which is a very challenging image generation task. Recently, CycleGAN has been applied to this task~\cite{DBLP:conf/iccv/ZhuPIE17}. However, the generated images are generally lack of texture details. On the contrary, with the adaptive perceptual discriminator, PUPGAN can perform well on the unpaired image-to-image translation task.
\section{Progressively Unfreezing Perceptual GAN}
In this section, we introduce the proposed Progressively Unfreezing Perceptual GAN (PUPGAN) in detail. We first present an overview of the PUPGAN framework. Then, we describe the architecture of the adaptive perceptual discriminator in PUPGAN. Next, we introduce the progressively unfreezing scheme for the training of PUPGAN. Finally, we specify how to apply PUPGAN to the unpaired image-to-image translation task.
\subsection{The PUPGAN Framework}
PUPGAN consists of a generator $G$ and an adaptive perceptual discriminator $D^{ap}$. The generator $G$ is trained to learn a mapping from the input distribution $x\sim p_x$ to the real data distribution $p_{data}$. For the architecture of the generator $G$, we just take the generator of the baseline method. Namely, there are no modifications to the generator $G$. The adaptive perceptual discriminator $D^{ap}$, which consists of a perceptual feature extractor and the discriminative learning layers, is trained to measure the multi-level feature discrepancy between the real images $y \sim p_{data}$ and the generated images $G(x)$. The learning objective can be written as follows:
\begin{eqnarray}\label{eq:gan}
\begin{aligned}
\min \limits_{G}\max \limits_{D^{ap}}{V(D^{ap},G)}=&E_{y\sim p_{data}}[\log D^{ap}(y)]\\
&+E_{x\sim p_x}[\log(1-D^{ap}(G(x)))].
\end{aligned}
\end{eqnarray}
The generator $G$ and the adaptive perceptual discriminator $D^{ap}$ are trained adversarially to compete with each other. The generator is encouraged to simulate the real images $y$ fed with the input images $x$. The adaptive perceptual discriminator is trained to distinguish the generated images $\tilde{y}$~($G(x)$) from the real images $y$. Hence, the adversarial loss can be defined as:
\begin{eqnarray}\small\label{eq:rg}
L_{Adv}=-E_{x\sim p_G(x)}[\log(D^{ap}(G(x)))].
\end{eqnarray}
The adversarial loss encourages the generated distributions to reside on the manifold of the real images by penalizing the discrepancy between the generated and real images.
\subsection{The Adaptive Perceptual Discriminator}
Unlike previous GANs using an external classifier to compute the perceptual loss, we use the discriminator of PUPGAN to evaluate the feature discrepancy between the generated and real images.
\begin{figure}
\centering
\includegraphics[scale=0.14]{db.pdf}
\caption{The adaptive perceptual discriminator of PUPGAN.}
\label{denseblock}
\end{figure}
In this paper, we propose an adaptive perceptual discriminator, which is composed of a perceptual feature extractor and some discriminative learning layers (as shown in Fig. \ref{denseblock}). Specifically, the perceptual feature extractor employs the hidden layer of the discriminator to extract the perceptual features and the discriminative learning layers are used to measure the feature discrepancy. More importantly, the perceputal feature extractor in the adaptive perceptual discriminator can be learned along with the training of the PUPGAN.
The perceptual feature extractor consists of a $7 \times 7$ convolution, a $3 \times 3$ max pooling, and a 6-layer dense block where each layer consists of a sequence of $1 \times 1$ convolutions and a $3 \times 3$ convolutions. Before each convolution, a batch normalization and the ReLU activation are adopted. Specifically, the 6-layer dense block is taken from Dense-121~\cite{DBLP:conf/cvpr/HuangLMW17}, which is pre-trained on the ImageNet classification task~\cite{DBLP:journals/ijcv/RussakovskyDSKS15}. The dense skip connections guarantee the forwarding of multi-level features to the discriminative learning layers. Furthermore, for error back propagation, the skip connections ensure the gradients from the discriminative learning layers and unfreezed layers to pass on to the generator. Hence, the discriminative learning layers measure a multi-level discrepancy between the generated and real images.
The perceptual feature extractor in the discriminator performs a transfer learning for the current image generation task. As a result, the perceptual features extracted by the adaptive perceptual discriminator is more suitable for the current task than the traditional perceptual loss and models dirctly embeded the VGGNet into the discriminators. In addition, compared to the traditional perceptual loss with element-wise measuring methods, using the discriminative learning layers can better measure the discrepancy of the perceptual features.
\subsection{Progressively Unfreezing Scheme}\label{sec:pud}
\subsubsection{Three Ways for Employing the Feature Extractor}
The pre-trained perceptual feature extractor in the adaptive perceptual discriminator can be employed in three ways. The first way is to update all the parameters in the perceptual feature extractor with the entire model, which we called normal transformation. The second way is to freeze all the parameters in the perceptual feature extractor, which we called no transformation (same as \cite{DBLP:conf/eccv/SungatullinaZUL18}). The third way is a compromise between them, which progressively unfreezes the parameters in the perceptual feature extractor layer-by-layer. We call it progressive transformation.
For the first way, at the beginning of training, since the discriminator has strong discriminative capability, it is trial to find the split hyperplane between the generated images and the real images, whereas the generator with low generative capability cannot fool the discriminator (as mentioned in Section \ref{sec:intro}). As a result, the gradient produced by the discriminator may lead to the gradient vanishing or mode collapse problems.
For the second way, when the parameters of the pre-trained perceptual feature extractor are freezed, its learning capability is restricted. In other words, the provided perceptual feature extractor is pre-trained on the ImageNet classification task, its performance is limited on the current image perceptual feature extraction task.
Here, we choose the third way, i.e. progressive transformation, which progressively unfreezes the pre-trained perceptual feature extractor in the adaptive perceptual discriminator.
\vspace{-0.2cm}
\subsubsection{Progressively Unfreezing with the Unfreezing Factor $\varphi$}
To achieve the progressive transformation, we propose a progressively unfreezing scheme, which depends on an unfreezing factor $\varphi$.
The training process is shown in Algorithm \ref{alg:1}. At the beginning of training, the parameters of the perceptual extractor are all freezed. As the training advances, the parameters of the bottom layer in the perceptual feature extractor that connects to the discriminative part are first unfreezed. Next, we progressively unfreeze the front layers one-by-one depending on a randomly generated probability. If the probability larger than a threshold (we empirically set the threshold $\varphi = 0.66$, please refer to the supplementary material), we unfreeze the parameters of one convolutional layer in front of the unfreezed layer. Namely, the unfreezed layers in the perceptual feature extractor and the discriminative learning layers remain trainable, while the parameters of the other layers in the perceptual feature extractor are freezed. Hence, the perceputal feature extractor smoothly adapt to the current image generation task.
\begin{algorithm}
\caption{The progressively unfreezing scheme.}
\label{alg:1}
\begin{algorithmic}[1]
\REQUIRE $\theta_G$: $G$'s parameters; $\theta_p$: perceptual feature extractor's parameters: $\theta_d$: discriminative learning layers' parameters; $m$: batchsize; $\varphi$: unfreezing factor (empirically set to 0.66).
\REQUIRE Adam hyperparameters: $\alpha_p=1\times10^{-6}$, $\alpha_d=2\times10^{-4}$, $\beta_1=0.5$ and $\beta_1=0.999$.
\STATE Freeze all of the parameters $\theta_p$
\FOR {e=1, 2, ..., epoch}
\STATE $p=$ random($1$)
\IF {$p>\varphi$}
\STATE Unfreeze one layer in the perceptual feature extractor which is the nearest neighbor to the discriminative learning layers.
\ENDIF
\FOR {j=1, 2, ..., datasize$/m$}
\STATE Sample {$y_1$, \ldots, $y_m$} from the real data distribution
\STATE Sample {$x_1$, \ldots, $x_m$} from the input data distribution
\STATE $L_{D^{ap}}\leftarrow \frac {1}{m} \sum[log D^{ap}(y_i)+log(1-D^{ap}(G(x_i)))]$
\STATE $L_G\leftarrow \frac {1}{m} \sum[log D^{ap}(G(x_i))]$
\STATE $\theta_d, \theta_p = Adam(L_{D^{ap}}, \theta_d, \theta_p, \alpha_d, \alpha_p, \beta_1, \beta_2)$
\STATE $\theta_G = Adam(L_{D^{ap}}, \theta_G, \beta_1, \beta_2)$
\ENDFOR
\ENDFOR
\end{algorithmic}
\end{algorithm}
There are several benefits for our progressively unfreezing scheme. First, the generation at the beginning is stable, because the adaptive perceptual discriminator with most parameters freezed is easy to fool by the generator. As the training progresses, the generator is asked for a more complicated question than the previous one by unfreezing the parameters in the adaptive perceptual discriminator. In addition, it is a reliable progressively training scheme, which can successfully avoid the gradient vanishing and model collapse problems.
Another benefit is that unfreezing the parameters of the perceptual feature extractor layer-by-layer can reduce the training time. Unlike normal transformation, when progressively unfreeze the parameters of the perceptual feature extractor, most parameters of the convolutional layers are freezed without update. In other words, the pre-trained feature extractor is incrementally transformed to that for the current task. In contrast to normal transformation, which needs to update all the parameters in the perceptual feature extractor, the progressive transformation method is more efficient.
In addition, the dense block is extremely suitable to the progressively unfreezing scheme. The skip connections between layers make it possible for information flow between the layers. Moreover, compared with VGGNet, the dense block has fewer parameters and better feature extraction capability.
\subsection{PUPGAN for Unpaired Image-to-Image Translation}
In GANs' research field, paired examples are generally required to train the network, as the discriminator needs both the generated images and the real images. CycleGAN \cite{DBLP:conf/iccv/ZhuPIE17} made a breakthrough on the unpaired image-to-image translation task, which introduced a cycle consistency loss to measure the discrepancy between the inputs with the reversely generated images. Although it has achieved competitive results on image-to-image translation task, the generated images are usually lack of texture details. Besides, the traditional perceptual loss, which needs both real images and generated images to measure the feature discrepancy, cannot work on the tasks without the pair-wise images.
The adaptive perceptual discriminator in PUPGAN extracts the multi-level perceptual features and measures the discrepancy between them. It overcomes the shortcomings of the traditional perceptual loss that needs pair-wise images to measure the feature discrepancy. Furthermore, the adaptive perceptual discriminator in PUPGAN efficiently extract and measure the multi-level feature discrepancy between the generated images and the real images. Hence, it can lead to better texture details and perceptual characteristics than the images generated by CycleGAN.
\section{Experiments}
To verify the universal validity of PUPGAN, we evaluate the performance of PUPGAN on several image generation tasks. Specifically, we choose three representative image generation tasks, i.e. single image super-resolution, paired image-to-image translation and unpaired image-to-image translation, for each task, we choose the classical baseline methods for comparison. For any other state-of-the-art GANs-based model, we can replace its discriminator to the adaptive perceptual discriminator designed in this work, and easily compare with it on the learning tasks.
In this section, we show some representative experimental results. For more implementation details and experimental results, please refer to the supplementary materials.
\subsection{Datasets and Evaluation Metrics}
For the single image super-resolution, we evaluated PUPGAN on several widely used benchmark datasets, i. e. Set5~\cite{DBLP:conf/bmvc/BevilacquaRGA12}, Set14~\cite{DBLP:conf/cas/ZeydeEP10}, BSD100~\cite{DBLP:conf/iccv/MartinFTM01} and Urban100~\cite{DBLP:conf/cvpr/HuangSA15}. All experiments were performed with a scale factor of $4 \times$ between the low-resolution and high-resolution images. Meanwhile, for quantitative comparison, we evaluated the generated images in terms of peak signal to noise ratio (PSNR) and structural similarity idex (SSIM) \cite{DBLP:journals/tip/WangBSS04}.
For the paired image-to-image translation, we conducted experiments on several tasks, such as aerial$\rightarrow$map with training data scraped from Google Maps~\cite{DBLP:conf/cvpr/IsolaZZE17}, label$\rightarrow$facade with images from the CMP facade dataset \cite{DBLP:conf/dagm/TylecekS13}. Moreover, we evaluated the generated images by PUPGAN and the compared methods in terms of PSNR and SSIM.
For the unpaired image-to-image translation, we chose several tasks performed in CycleGAN \cite{DBLP:conf/iccv/ZhuPIE17}. The tasks included aerial$\leftrightarrow$map~\cite{DBLP:conf/cvpr/IsolaZZE17}, label$\leftrightarrow$facade~\cite{DBLP:conf/dagm/TylecekS13}, horse$\leftrightarrow$zebra and orange$\leftrightarrow$apple with images downloaded from ImageNet \cite{DBLP:journals/ijcv/RussakovskyDSKS15} and summer$\leftrightarrow$winter Yosemite photos from Flickr (\url{http://www.flickr.com}). In addition, for quantitative comparison, we use the perceptual quality index (PQI)~\cite{DBLP:conf/cvpr/BlauM18} to measure the quality of the generated images.
\subsection{Parameter Settings}
To demonstrate the effectiveness of PUPGAN, we conducted the ablation study. The adaptive perceptual discriminator in PUPGAN is represented as ``Dense\_D". For the perceptual feature extractor, we took a pre-trained VGGNet-19 as the variant, represented as ``VGG\_D". For the training scheme, we considered to progressively unfreeze the parameters in the perceptual extractor layer-by-layer or freeze all the parameters of the perceptual feature extractor, represented as ``UF" or ``F" respectively. While unfreezing all the parameters at the beginning of training may cause the gradient vanishing or mode collapse problems, it is not considered here. In addition, for the regularization mechanism, we conducted experiments that with or without spectral normalization \cite{DBLP:conf/iclr/MiyatoKKY18} after each convolutional layer in the discriminator. The spectral normalization is represented as ``SN".
The generators of PUPGAN for the applied tasks are the same as that of the baseline models. The adaptive perceptual discriminators of PUPGAN for different tasks are designed with their unique discriminative learning layers. The specific architectures are described in the following subsections and in the supplementray material.
\subsection{Single Image Super-Resolution}
For the single image super-resolution task, we take SRGAN~\cite{DBLP:conf/cvpr/LedigTHCCAATTWS17} as the baseline. SRGAN is a famous GANs-based model for single image super-resolution. It utilizes a VGGNet loss which is based on a pre-trained VGGNet-19 network, and measures the high-level discrepancy with the Euclidean distance.
\begin{figure}[h]
\centering
\includegraphics[scale=0.75]{srganmp.pdf}
\caption{The architecture of PUPGAN for single image super-resolution.}
\label{fig:sr}
\end{figure}
Fig. \ref{fig:sr} illustrates the architecture of PUPGAN for single image super-resolution. The discriminative learning layers consist of three $3\times3$ convolutions with stride $2$ followed by average pooling and two $1\times1$ convolutions with stride $1$. The convolutional layers except the last one are followed by a LeakyReLU activation ($\alpha = 0.2$) and spectral normalization.
Fig. \ref{srgan} demonstrates the $4\times$ upscaling super-resolved images generated by the baseline SRGAN, PUPGAN and the other compared approaches. It is obvious that the images generated by SRGAN are blurry and without enough texture details. In general, the images generated by the models with ``VGG\_D" is more blurry than those with ``Dense\_D". Furthermore, utilizing progressively unfreezing scheme further enhanced the generative capability of the networks. It is worth mentioning that PUPGAN achieved the best performance. It not only recovered the texture details of the images, but also kept the textures approximate to the real texture in the ground-truth images.
\begin{figure}[t]
\centering
\includegraphics[width=\textwidth]{sr.pdf}
\caption{From left to right: ground-truth, SRGAN~\cite{DBLP:conf/cvpr/LedigTHCCAATTWS17}, SRGAN + VGGNet-based discriminator with freezed parameters, SRGAN + VGGNet-based discriminator + SN with freezed parameters, SRGAN + VGGNet-based discriminator + SN with progressively unfreezing scheme, SRGAN + adaptive perceptual discriminator with freezed parameters, SRGAN + adaptive perceptual discriminator with unfreezed parameters, SRGAN + adaptive perceptual discriminator + SN with freezed parameters and PUPGAN.}
\label{srgan}
\end{figure}
\begin{table}[t]
\centering
\setlength{\abovecaptionskip}{0 pt}
\caption{Performance of the baseline SRGAN~\cite{DBLP:conf/cvpr/LedigTHCCAATTWS17}, PUPGAN and other variants for single image super-resolution in terms of PSNR/SSIM on the Set5, Set14, BSD100 and Uber100 datasets.}
\label{SRGAN}
\scalebox{0.8}[0.8]{
\begin{tabular}{c|cc|cc|cc|cc}
\hline
\thead{ \backslashbox{Methods}{Datasets}}
&\multicolumn{2}{c}\centering\thead{Set5~\cite{DBLP:conf/bmvc/BevilacquaRGA12}}&\multicolumn{2}{c}\centering\thead{Set14~\cite{DBLP:conf/cas/ZeydeEP10}}
&\multicolumn{2}{c}\centering\thead{BSD100~\cite{DBLP:conf/iccv/MartinFTM01}}&\multicolumn{2}{c}\centering\thead{Uber100~\cite{DBLP:conf/cvpr/HuangSA15}}\\
\hline
\thead{ }&\thead{ PSNR }&\thead{SSIM}&\thead{ PSNR }&\thead{SSIM}&\thead{ PSNR }&\thead{SSIM}&\thead{ PSNR }&\thead{SSIM}\\
\thead{SRGAN~\cite{DBLP:conf/cvpr/LedigTHCCAATTWS17} }&\thead{ 28.5694 }&\thead{ 0.8271 }&\thead{25.4943 }&\thead{ 0.7266 }&\thead{ 25.6282 }&\thead{0.6935 }&\thead{ 23.4113 }&\thead{ 0.7099 }\\
\thead{SRGAN~\cite{DBLP:conf/cvpr/LedigTHCCAATTWS17}+VGG\_D+F (\cite{DBLP:conf/eccv/SungatullinaZUL18})} &\thead{ 24.2069 } &\thead{0.6185 }&\thead{ 22.7773 } &\thead{ 0.5455 }&\thead{22.8579 } &\thead{ 0.5262 }&\thead{ 21.3465} &\thead{0.5761 }\\
\thead{SRGAN~\cite{DBLP:conf/cvpr/LedigTHCCAATTWS17}+VGG\_D+SN+F} &\thead{ 27.5899 } &\thead{ 0.7686 }&\thead{25.1665 } &\thead{0.7249 }&\thead{ 25.3625} &\thead{ 0.6769 }&\thead{23.0150 } &\thead{ 0.7020 }\\
\thead{SRGAN~\cite{DBLP:conf/cvpr/LedigTHCCAATTWS17}+VGG\_D+SN+UF } &\thead{ 24.5858 } &\thead{ 0.7386 }&\thead{22.1574 } &\thead{ 0.6247 }&\thead{ 22.8857 } &\thead{ 0.6134 }&\thead{ 20.5188 } &\thead{ 0.6169 }\\
\thead{SRGAN~\cite{DBLP:conf/cvpr/LedigTHCCAATTWS17}+Dense\_D+F} &\thead{ 23.3219 } &\thead{ 0.6699 }&\thead{ 21.4114 } &\thead{0.5920 }&\thead{ 21.8136} &\thead{ 0.5455 }&\thead{19.7500 } &\thead{ 0.5463 }\\
\thead{SRGAN~\cite{DBLP:conf/cvpr/LedigTHCCAATTWS17}+Dense\_D+SN+F} &\thead{ 27.6365 } &\thead{0.8092 }&\thead{25.0694 } &\thead{0.7184 }&\thead{ 25.1767 } &\thead{ 0.6832 }&\thead{22.9457 } &\thead{ 0.6892 }\\
\thead{SRGAN~\cite{DBLP:conf/cvpr/LedigTHCCAATTWS17}+Dense\_D+UF } &\thead{ 24.3997 } &\thead{ 0.6643 }&\thead{22.4456 } &\thead{ 0.5933 }&\thead{ 22.5424 } &\thead{ 0.5569 }&\thead{ 20.9289 } &\thead{ 0.6037 }\\
\hline
\thead{PUPGAN} &\thead{ $\boldsymbol{29.0598}$ } &\thead{ $\boldsymbol{0.8495}$ }&\thead{$\boldsymbol{25.7471}$ } &\thead{ $\boldsymbol{0.7454}$ }&\thead{$\boldsymbol{25.8316}$ } &\thead{ $\boldsymbol{0.7074}$ }&\thead{ $\boldsymbol{23.5533}$ } &\thead{ $\boldsymbol{0.7297}$ }\\
\hline
\end{tabular}}
\end{table}
Table \ref{SRGAN} illustrates the quantitative results on several benchmark datasets. PUPGAN obtained the highest score among the other compared approaches. Even though SRGAN received the second-highest score, the images generated by it is blurry (as shown in Fig. \ref{srgan}).
\subsection{Paired Image-to-Image Translation}\label{sec:pix}
For the paired image-to-image task, we take Pix2Pix~\cite{DBLP:conf/cvpr/IsolaZZE17} as the baseline. Pix2Pix is a generic tool for paired image-to-image translation tasks, which utilized a conditional GAN-based model to achieve the reasonable results. It optimizes the entire model with a generative adversarial loss and an MAE loss between the generated images and the real images.
\begin{figure}[h]
\centering
\includegraphics[scale=0.7]{pixmp.pdf}
\caption{The architecture of PUPGAN for paired image-to-image translation.}
\label{fig:pix}
\end{figure}
Fig. \ref{fig:pix} illustrates the structure of PUPGAN for paired image-to-image translation. Notice that in the Pix2Pix model, the generated image and the real image are concatenated as the input to the discriminator. While for the adaptive perceptual discriminator, the generated image and the real image first go through the perceptual feature extractor, and then the perceptual features are concatenated as the input to the discriminative learning layers. Here, the discriminative learning layers consist of four $3\times3$ convolutions with stride $2$ and a $4\times4$ convolution with stride $1$. The convolutional layers are followed by a LeakyReLU activation ($\alpha = 0.2$) and spectral normalization.
Fig. \ref{pixf} shows the images generated by the baseline Pix2Pix, PUPGAN and the other compared approaches on the label$\rightarrow$facade and aerial$\rightarrow$map tasks. The image details generated by PUPGAN is much better than the other compared approaches. It should be noted that the images generated by PUPGAN are the closest to the ground-truth image, no matter the color of the objects or the fine texture details.
\begin{figure}[t]
\centering
\includegraphics[width=\textwidth]{pix.pdf}
\caption{The comparison between different methods for the paired image translation task. Pix2Pix~\cite{DBLP:conf/cvpr/IsolaZZE17} is the baseline method.}
\label{pixf}
\end{figure}
\begin{table}[h]
\centering
\setlength{\abovecaptionskip}{0pt}
\caption{Performance of PUPGAN, the baseline Pix2Pix~\cite{DBLP:conf/cvpr/IsolaZZE17} and other variants for the paired image translation tasks in terms of PSNR and SSIM.}
\label{pix:tab}
\scalebox{0.8}[0.8]{
\begin{tabular}{c|cc|cc}
\hline
\thead{ \backslashbox{Methods}{Datasets}}
&\multicolumn{2}{c}\centering\thead{Label$\rightarrow$Facade}&\multicolumn{2}{c}\centering\thead{Aerial$\rightarrow$Map}\\
\hline
\thead{ }&\thead{ PSNR }&\thead{SSIM}&\thead{ PSNR }&\thead{SSIM}\\
\thead{Pix2Pix~\cite{DBLP:conf/cvpr/IsolaZZE17}}&\thead{ 18.8356 }&\thead{ 0.4955}&\thead{ 17.4289 }&\thead{ 0.3749 }\\
\thead{Pix2Pix~\cite{DBLP:conf/cvpr/IsolaZZE17}+VGG\_D+F (\cite{DBLP:conf/eccv/SungatullinaZUL18})} &\thead{17.4117}&\thead{0.3691}&\thead{18.2702}&\thead{0.3954}\\
\thead{Pix2Pix~\cite{DBLP:conf/cvpr/IsolaZZE17}+Dense\_D+F} &\thead{16.8993}&\thead{0.3560}&\thead{15.2598}&\thead{0.3554}\\
\thead{Pix2Pix~\cite{DBLP:conf/cvpr/IsolaZZE17}+VGG\_D+SN+F} &\thead{18.8696}&\thead{0.4794}&\thead{18.2852}&\thead{0.3971}\\
\thead{Pix2Pix~\cite{DBLP:conf/cvpr/IsolaZZE17}+Dense\_D+SN+F} &\thead{19.4678}&\thead{0.5234}&\thead{17.8319}&\thead{0.3980}\\
\thead{Pix2Pix~\cite{DBLP:conf/cvpr/IsolaZZE17}+VGG\_D+SN+UF } &\thead{18.6036}&\thead{0.4902}&\thead{17.3374}&\thead{0.3668}\\
\hline
\thead{PUPGAN} &\thead{ $\boldsymbol{21.3647}$ } &\thead{ $\boldsymbol{0.6335}$ }&\thead{$\boldsymbol{19.7952}$ } &\thead{ $\boldsymbol{0.48649}$ }\\
\hline
\end{tabular}}
\end{table}
Table \ref{pix:tab} illustrates the quantitative results for the paired image translation tasks. PUPGAN obtained the highest score among the other compared approaches. In addition, we can see that taking the dense block as the perceptual feature extractor performs better than that taking the VGGNet as the perceptual feature extractor (from the last two lines in Table \ref{pix:tab}). It demonstrates that the dense connections in the feature extractor is extremely suitable to the progressively unfreezing scheme.
\subsection{Unpaired Image-to-Image Translation}
For the unpaired image-to-image translation task, we take CycleGAN~\cite{DBLP:conf/iccv/ZhuPIE17} as the baseline. CycleGAN is a well-known tool for unpaired image-to-image translation task. It contains both forward and reverse mapping functions between the source domain and target domain. It is optimized with two adversarial losses and a cycle consistency loss. However, in this case, the traditional perceptual loss cannot work, as the target image corresponding to a generated image is unknown. Although Sungatullina et al.~\cite{DBLP:conf/eccv/SungatullinaZUL18} embeded a pre-trained VGGNet inside the discriminator to extract the high-level features, the parameters in the pre-trained network were fixed, whereas the adaptive perceptual discriminator can help to learn the suitable high-level perceptual features adapted to the current task and generate images with fine texture details.
\begin{figure}[h]
\centering
\includegraphics[scale=0.7]{cyclemp.pdf}
\caption{The architecture of PUPGAN for unpaired image-to-image translation.}
\label{fig:cycle}
\end{figure}
Fig. \ref{fig:cycle} illustrates the structure of PUPGAN for unpaired image-to-image translation. The structures of the discriminative learning layers are as same as we illustrated in Section \ref{sec:pix}.
We first test the performance of PUPGAN and the compared approaches for unpaired image-to-image translation on paired datasets, where ground-truth input-output pairs are available for evaluation. For training, we shuffled the images to made them unpaired. Fig. \ref{cyclef} shows the label$\rightarrow$facade results obtained by PUPGAN and the other compared approaches. It is easy to see that, the images generated by PUPGAN are much better than that generated by CycleGAN and the compared approaches, whether from the contour of the facades or the texture details in the generated images.
\begin{figure}
\centering
\includegraphics[width=\textwidth]{cyclef.pdf}
\caption{The comparison for the unpaired image-to-image translation on label$\rightarrow$facade task. We took CycleGAN~\cite{DBLP:conf/iccv/ZhuPIE17} as the baseline and conduct extensive experiments on the variants of PUPGAN.}
\label{cyclef}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=\textwidth]{cycleh.pdf}
\caption{The comparison for the unpaired image-to-image translation on horse$\leftrightarrow$zebra task, where paired data does not exist.}
\label{cycleh}
\end{figure}
In addition, we conducted experiments on the unpaired image-to-image translation task, horse$\leftrightarrow$zebra. As shown in Fig. \ref{cycleh}, images generated by PUPGAN have fine texture details and correct color. Specifically, even the zebra's mane was painted in white and black by PUPGAN, while the compared approaches did not have this property.
\begin{table}
\centering
\setlength{\abovecaptionskip}{0pt}
\caption{Performance of PUPGAN, the baseline CycleGAN~\cite{DBLP:conf/iccv/ZhuPIE17} and other variants for unpaired image translation tasks in terms of PQI.}
\label{cycle:tab}
\scalebox{0.68}[0.68]{
\begin{tabular}{c|c|c|c|c|c|c|c}
\hline
\thead{PQI}&\thead{CycleGAN~\cite{DBLP:conf/iccv/ZhuPIE17}} & \thead{VGG\_D+F~(\cite{DBLP:conf/eccv/SungatullinaZUL18})} & \thead{Dense\_D+F}& \thead{VGG\_D+SN+F} & \thead{VGG\_D+SN+UF} & \thead{Dense\_D+SN+F} & \thead{PUPGAN}\\
\hline
\thead{Label$\rightarrow$Facade} &\thead{5.0085}&\thead{4.8144}&\thead{5.8095}&\thead{4.4230}&\thead{4.1031}&\thead{5.2549}& \thead{\bf4.0308}\\
\hline
\thead{Facade$\rightarrow$Label} &\thead{6.6129}&\thead{4.9482}&\thead{5.2549}&\thead{4.6094}&\thead{4.4423}&\thead{4.4885}& \thead{\bf4.3692} \\
\hline
\thead{Horse$\rightarrow$Zebra} &\thead{3.3219}&\thead{3.2865}&\thead{3.2363}&\thead{3.4095}&\thead{3.5321}&\thead{3.2862}&\thead{\bf2.8842}\\
\hline
\thead{Zebra$\rightarrow$Horse} &\thead{3.3278}&\thead{3.2679}&\thead{3.2979}&\thead{3.525}&\thead{3.2938}&\thead{3.2862}&\thead{\bf3.2109}\\
\hline
\end{tabular}}
\end{table}
Table \ref{cycle:tab} shows the quantitative results for the label$\leftrightarrow$facade and horse$\rightarrow$zebra tasks in terms of PQI. The lower the PQI value, the higher the perceptual quality recovered by the method. It obvious that PUPGAN obtained the best result among the other compared methods. For more experimental results, please refer to the supplementary materials.
\section{Conclusion}
In this paper, we propose a new framework called PUPGAN, which can generate images with fine texture details. Its adaptive perceptual discriminator, which utilizes a pre-trained dense block as the perceptual feature extractor and transfers it to the current task, efficiently measures the multi-level discrepancy between the generated and real images. In addition, we propose a progressively unfreezing scheme to smoothly improve the generator's image generation capability. The qualitative and quantitative experiments demonstrate the effectiveness of PUPGAN for texture details generation on three representative image generation tasks, i.e. single image super-resolution, paired image-to-image translation and unpaired image-to-image translation. Last but not the least, PUPGAN can be considered as a general framework for image generation with fine texture details, it can be applied to more image generation tasks other than that we performed here.
\bibliographystyle{splncs04}
| {'timestamp': '2020-06-19T02:07:54', 'yymm': '2006', 'arxiv_id': '2006.10250', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10250'} | arxiv |
\section{Introduction \label{sec:intro}}
\noindent
The needs for pipe inspection are rapidly increasing in various plants, such as chemical refineries, gas distribution, and sewer maintenance.
Since the damage and clogging in the pipe are substantially related to disastrous failures of the whole system, periodic industrial inspection is necessary to keep its function.
An industrial endoscope, or an industrial videoscope, is commonly used to inspect the inside of a pipe, since it is impossible for people to directly access the inspection site such as gas network underground or inside the building structures.
When an operator inserts the probe inside the pipe and then visually inspects on a remote screen to reveal the deformations or defects, they need to guess the defect location and 3D structures around the camera only from the 2D image sequences.
Vision-based 3D reconstruction techniques such as Structure-from-Motion (SfM)~\cite{photo_tourism,building_roma,visualsfm,colmap,hierarchical,crandall2011discrete,wilson2014robust,sweeney2015optimizing,hsfm} and Visual Simultaneous Localization and Mapping (Visual SLAM)~\cite{orbslam,dso,lsdslam} can potentially help those situation, by reconstruting the 3D structure of the pipe from images, and localizing the probe trajectory during the operation.
However, because of extraordinarily repetitive and narrow structures as shown in Fig.~\ref{fig:difficulty}, existing methods, which are mostly tested on the urban situation, fail to reconstruct the scene or produce an erroneous structure.
\begin{figure}[t]
\centering
\includegraphics[width=\columnwidth]{fig1_ds.png}
\caption{{\bf Difficulties of pipe reconstruction.} Narrow and repetitive structures inside of a pipe make vision-based 3D reconstruction extremely difficult. The reconstruction from such difficult conditions leads to severe drift errors and failure of tracking. We make a SfM system tailored to the pipe structure.\label{fig:difficulty}}
\end{figure}
In this paper, we propose a incremental SfM system for a pipe network, with a monocular camera used for the inspection.
To address the error arisen from the challenging appearances and narrow geometries of the industrial parts, we use prior information of the pipe (assuming a constant inner diameter).
In contrast to relevant works~\cite{peter2015ijrr,el2011robio}, our system is carefully designed to incorporate the prior constraint into the iterative process of SfM, which enables the system to deal with large errors of the reconstruction and to be capable for the pipe network consisting of multiple straight pipes.
During the reconstruction, a temporary 3D model is incrementally updated regarding feature correspondences between the previous model and the current image frame from the camera.
Considering the potential errors induced by scale-drifting, we find multiple straight pipes in the temporary model as conic shapes of the structure.
Subsequently, our proposed cylindrical constrained BA incrementally refines each pipe to be in line with the given prior.
Experiments on practical pipe networks consisting of multiple different parts clearly show that our methods obtain more accurate reconstruction compared with the state-of-the-art vision-based methods.
\section{Related work \label{sec:related_work}}
\subsection{Vision-based 3D reconstruction \label{sec:vision_recon}}
\noindent
For a set of images input, SfM depicts the captured scene by 3D scene points, based on local feature matching~\cite{sift,dsp_sift} and multi-view triangulation~\cite{mvg,hartley1997triangulation,snavely2008scene}, while estimating the camera poses for the input images.
In the recent decade, a variety of SfM strategies, including incremental~\cite{photo_tourism, building_roma, visualsfm, colmap}, hierarchical~\cite{hierarchical}, global~\cite{crandall2011discrete, wilson2014robust, sweeney2015optimizing}, and hybrid approach of them~\cite{hsfm} have been studied.
For a sequential image series input, incremental SfM is the most popular strategy that can be extended to the real-time application~\cite{bronte2014real}.
On the other hand, SLAM-based methods have been developed in contexts of the real-time operation of estimating the camera trajectory while reconstructing the environment. ORB-SLAM~\cite{orbslam} speeds up the feature extraction process by using binarized ORB descriptor~\cite{orb}. Direct methods~\cite{dso,lsdslam} allow more efficient operation directly obtaining camera trajectory by minimizing a cost regarding the differences of image intensities.
One common issue of those vision-based reconstruction methods is the accumulated scale-drift problem that causes a camera trajectory and a 3D model inaccurate.
Several works address the issue via loop closure~\cite{konolige2008frameslam,mei2009constant,strasdat2010vi} that attempts to detect a camera path loop, {\it e.g}.} \def\Eg{{\it E.g}., using image appearance~\cite{filliat2007icra, galvez2012tor}, and hence detect the scale-drift during the reconstruction. The 3D points and camera poses of the model are then refined as the model keeps consistent scene geometries at the former and the latter of the camera path loop.
Another approach is to compensate scale information via pre-trained deep architectures that estimate an absolute scale depth~\cite{yang2018eccv, tateno2017cvpr} and/or relative motion between the frames~\cite{demon, cvpr2017oral, ba-net, deeptam}.
\subsection{Pipe reconstruction \label{sec:pipe_recon}}
\noindent
Pipe network for gas distribution or sewer is an active target of 3D reconstruction since they are often narrow or dangerous to walk in for inspection.
Instead, a robot vehicle~\cite{peter2015ijrr} or an industrial endoscope~\cite{pipe_robot, pipe_robot2} provides a safety inspection using its mounted camera(s).
3D reconstruction from a sequence of images from the camera could also help a detailed 3D structure inspection rather than the 2D visual inspection.
However, poor and dynamically changing lighting conditions and highly repetitive appearances due to standardized pipes make application of vision-based approaches difficult.
Several works, therefore, rely on the use of multi-domain sensors outputs, {\it e.g}.} \def\Eg{{\it E.g}., stereo camera~\cite{hansenstereo}, Inertial Measurement Unit (IMU)~\cite{esquivel2009jprs} or structured light~\cite{peter2015ijrr}, along with a fish-eye camera.
Although rich sensors and equipment can help reconstruction, they are sometimes infeasible for very narrow structures and limited conditions, {\it e.g}.} \def\Eg{{\it E.g}., inspection of gas plumbing inside the building using an endoscope. Some works build an accurate 3D pipe model using only a monocular camera, with assumptions of camera motion and prior knowledge peculiar to the pipe. Kahi {\it et al.}~\cite{el2011robio} refine the reconstructed 3D points by cylinder fitting after BA. Zhang {\it et al.}~\cite{zhang2011wscg} and Kunzel {\it et al.}~\cite{kunzel2018wacv} rectify the images to a cylinder projection plane to triangulate points easily and regularize image illumination.
Our system, designed for a 3D reconstruction using an industrial endoscope equipping only a monocular camera, is built based on the incremental SfM pipeline.
Assuming a prior knowledge of the constant inner diameter of the straight pipe, we provide an accurate 3D structure by fitting 3D points to the known pipe surface.
In contrast to the previous works limiting a camera movement to be in parallel with the pipe axis~\cite{zhang2011wscg,kunzel2018wacv}, we give no limitations about the camera path, which enables general endoscope motions during the inspection. The most relevant work of ours is \cite{el2011robio}, which detects a cylinder per reconstructed model
and aligns the 3D points to the known pipe property after registering the fixed number of frames.
On the other hand, we detect the pipe as a general conic shape, which takes the scale-drifting errors of 3D points into account. More importantly, we search multiple pipe instances assuming the pipe network that consists of multiple pipes directed to different axes. We then incrementally refine the temporary model using a known inner diameter when each of new pipes is appeared.
The next section describes our SfM system and its components in detail.
\begin{figure*}[ht]
\centering
\includegraphics[width=\textwidth]{fig2.png}
\caption{{\bf The overview of our SfM system for pipe reconstruction.} We design our system based on the incremental SfM pipeline for general purposes while extending it to address the particular situations of the inner pipes.
Our system detects multiple pipe instances as general conic shapes in the temporary model (conic shape detection) and refines the whole model as each of the detected pipes satisfies the known inner diameter (BA with cylinder constraint). }
\label{fig:overview}
\end{figure*}
\section{Cylinder constrained SfM for pipe reconstruction}
\noindent
In this section, we describe the proposed SfM system for reconstructing a pipe network composed of multiple straight pipes using an image sequence taken by an endoscope camera.
The main challenges in the situation are three-folded;
{\bf 1)} Pipe networks constructed for industrial purposes are dominated by very weakly-textured (or highly repetitive) appearance (cf. Fig.~\ref{fig:objects}), and often consists of narrow and specular reflective cylindrical parts.
In addition, pipe inspection using a endoscopic camera is often operated in a poor lighting condition, consequently suffers from local feature deprivation and inaccurate keypoints.
Vision-based system such as SfM and SLAM are critically affected by such unstable keypoint properties, resulting in an inconsistent 3D reconstruction.
{\bf 2)} Incremental SfM iteratively registers each image in the image sequence. Therefore, the error of the temporary 3D model in each iteration is increasingly accumulated to the whole model.
{\bf 3)} Loop closure is often infeasible during the practical visual inspection, because the camera path often has no loops due to the flexibility of the endoscope, {\it i.e}.} \def\Ie{{\it I.e}., the system cannot detect the scale-drift.
We construct our reconstruction system (illustrated in Fig.~\ref{fig:overview}) based on the incremental SfM pipeline for general purposes (Sec.~\ref{sec:inpre}), while integrating several configuration and new processes to achieve an accurate reconstruction for the pipe network:
Before starting reconstruction, we calibrate intrinsic parameters of the endoscope camera to mitigate the effect of lens distortion (Sec.~\ref{sec:calibration}).
Our system finds each pipe instance from the temporary reconstructed model considering its scale-drifting (Sec.~\ref{sec:tube_detection}).
Detected pipes are refined by our cylinder constrained BA that minimizes point distances from the cylinder surface using a known property of the tube diameter (Sec.~\ref{sec:ba_cc}).
\subsection{Incremental SfM \label{sec:inpre}}
\noindent
In what follows, we describe an general incremental SfM pipeline for a set of sequential images.
\para{2D feature matching. }
For each input image, SfM extracts the image local features, {\it e.g}.} \def\Eg{{\it E.g}., SIFT~\cite{sift} or improved one~\cite{dsp_sift}, to get 2D correspondences between images that are used to register the image to the model in a latter step. When the set of images are ordered by time-stamp, the matching target can be restricted within the current few frames. In our experiment, we match an image toward the current 50 frames of the sequential set. Feature correspondences are verified through an outlier rejection scheme, {\it e.g}.} \def\Eg{{\it E.g}., random sample consensus (RANSAC)~\cite{ransac,mvg}.
\para{3D model initialization. }
Incremental SfM firstly initializes the 3D model for a selected image pair~\cite{beder2006determining,colmap}.
We assume the input from a sequential image set, thus the selection can be easily done using time stamp, {\it i.e}.} \def\Ie{{\it I.e}., initializing the model with first two frames of the input.
Then the initial model, composed of the 3D scene points correspond to the local feature matches and relative camera poses of the image pair, is to be constructed via two-view triangulation~\cite{beder2006determining,snavely2008scene}.
\para{Tracking and mapping (temporary model construction). }
Once the model has been initialized, the SfM incrementally registers the input images to the model, while enriching the model by adding new 3D points correspond to 2D local feature tracks.
In each iteration, SfM obtains local feature correspondences for a new input image (next frame) to the existing model, resulting in the set of tracked 2D observations, {\it i.e}.} \def\Ie{{\it I.e}., the keypoints seen from more than two other frames.
Using the existing 3D points correspond to the feature tracks, SfM estimates the camera pose of the input image by solving a Perspective-n-Point (PnP) problem via P3P-RANSAC~\cite{p3p,ransac}.
After recovering the pose of the image, the model grows adding 3D points for the newly tracked features, through the triangulation among the current frames.
\para{Bundle adjustment. }
To stably develop the model through the incremental scheme, the system refines the temporary 3D model
after each input image registration (local bundle adjustment).
Regarding the 3D points and camera poses of the current frames, the standard bundle adjustment~\cite{triggs1999bundle} minimizes the error of the 3D points from the corresponding 2D observations (reprojection error), which is represented as:
\begin{equation}
E_{rep} ({\bf X, P, K}) = \sum_{i \in {\bf P}} \sum_{j \in {\bf X}} \rho ( \| q_{ij} - \pi ({\bf P}_i, {\bf K}_i, {\bf X}_j) \|)
\label{eq:generalba}
\end{equation}
where ${\bf X}_j$ is the $j$--th 3D scene point, $q_{ij}$ is the 2D observation of ${\bf X}_j$ from the $i$--th view ${\bf P}_i$, $\pi ({\bf P}_i, {\bf K}_i, {\bf X}_j)$ is a function that projects scene points to the image plane, and $\rho$ is the robust function, {\it e.g}.} \def\Eg{{\it E.g}., Cauchy function.
The system also runs another refinement process after several iterations (global bundle adjustment) that maintains the consistency of the whole model. In this time, bundle adjustment also minimizes Eq.~(\ref{eq:generalba}) but in regard to all 3D points and frames registered to the model.
\subsection{Endoscope camera calibration \label{sec:calibration}}
\noindent
An accurate intrinsic parameter of the camera, that makes a relation between an image point $[u, v]^{\mathrm{T}}$ and a 3D point (normalized image coordinate) $[x, y, z]^{\mathrm{T}}$, is required to achieve a solid 3D reconstruction, {\it e.g}.} \def\Eg{{\it E.g}., for an accurate conversion $\pi$ in Eq.~(\ref{eq:generalba}).
We focus on the use of a standard industrial endoscope (Fig.~\ref{fig:hardware}, Tab.~\ref{tab:spec}) which has a wide FoV camera for efficient visual inspection.
To deal with the image distortion comes from the wide FoV configuration, we
rectify the image coordinates of the keypoints assuming a fish-eye model~\cite{fisheye}.
By the camera model, the relation between the image coordinate and the 3D point is formulated as:
\begin{equation}
\centering
\left[
\begin{array}{r}
u \\
v
\end{array}
\right]
=
\left[
\begin{array}{r}
f_x(\theta + k_1 \theta^3 + k_2 \theta^5)cos\phi + u_0 \\
f_y(\theta + k_1 \theta^3 + k_2 \theta^5)sin\phi + v_0
\end{array}
\right]
\end{equation}
where $\theta$ is the 3D angle formed by the camera optical axis and the ray going from camera center to the 3D point,
and $\phi$ is the polar angle of normalized image coordinate, respectively.
\begin{equation}
\centering
\theta = \arctan\left(\sqrt{\frac{x^2+y^2}{z^2}}\right), \phi = \arctan\left(\frac{y}{x}\right)
\end{equation}
Camera intrinsic parameter consists of:
focal length with respect to horizontal and vertical axis $(f_x, f_y)$,
distortion parameters $(k_1, k_2)$,
and image principal point $(u_0, v_0)$.
Before starting the reconstruction, we initialize the parameters by an offline calibration. To achieve an accurate calibration, we use a checkerboard pattern with a 2mm size of each square (Fig.~\ref{fig:hardware}) and take pictures from multiple views. The parameters are found by minimizing the sum of squared reprojection errors of the grid points~\cite{opencv_library}.
We also update the parameters during the reconstruction via bundle adjustment (Sec.~\ref{sec:ba_cc}).
\begin{figure}[t]
\begin{minipage}{0.64\linewidth}
\centering
\includegraphics[width=\linewidth]{hardware3ds.png}
\end{minipage}%
\begin{minipage}{0.34\linewidth}
\centering
\includegraphics[width=\linewidth]{calib_target.pdf}
\par \medskip \vfill
\includegraphics[width=\linewidth]{calib_fisheye2.pdf}
\end{minipage}
\caption{{\bf Industrial endoscope.} Left: The appearance of the industrial endoscope. We use an Olympus IPLEX NX with the AT120D/NF-IV96N optical adapter and the IV9635N scope. Right: A sample image capturing checkerboard pattern (top) and rectified by fish-eye camera model (bottom). \label{fig:hardware}}
\end{figure}
{\tabcolsep=3pt
\begin{table}[t]
\centering
\caption{The detailed specification of the industrial endoscope \label{tab:spec}}
{\footnotesize
\begin{tabular}{ccccc}
Resolution & \specialcell{Field of \\ view} & \specialcell{Scope \\ diameter} & \specialcell{Depth of \\ field} & Illumination \\ \hline
\rule{0pt}{2ex} $1024 \times 768$[px] & $120^{\circ}$ & 6.0 mm & 7 to 300 mm & laser diode
\end{tabular}
}
\end{table}
}
\subsection{Incremental conic shapes detection \label{sec:tube_detection}}
\noindent
In spite of the effort of the precise camera calibration, general incremental SfM pipeline can often cause a significant 3D model distortion on a pipe inner situation.
We address the errors assuming the known properties of a pipe network, {\it i.e}.} \def\Ie{{\it I.e}., if we can detect the pipe instances that is a component of the pipe network, the model can be refined by fitting 3D points to the known properties.
Instead of detecting the cylinders for the whole 3D model, which would requires substantial conversion of the model because of accumulated model distortion, we search the pipe instance from the temporary 3D points during the incremental pipeline.
Also, we observed even a small intrinsic calibration error can cause a large scale-drifting of the temporary model (Fig.~\ref{fig:color_results}), which can limit the standard cylinder detection for the 3D point cloud.
Therefore, we search the pipe by fitting a general conic shape~\cite{Lopez2014automatic} to the 3D points.
In each temporary model constructed during the incremental SfM process, we assume a 3D point in the homogeneous coordinate system $\bm{X}=[x,y,z,1]^{\mathrm{T}}$ represents the surface of a cone if it satisfies:
\begin{equation}
\centering
\bm{X}^{\mathrm{T}} {\bf C}\bm{X} = 0
\label{eq:cone}
\end{equation}
${\bf C}$ is a symmetric matrix, which can be decomposed as:
\begin{equation}
{\bf C} =
\left[
\begin{array}{cc}
R^{\mathrm{T}}{\bf D}R & R^{\mathrm{T}}{\bf D}t \\
t^{\mathrm{T}}{\bf D}R & t^{\mathrm{T}}{\bf D}t
\end{array}
\right],
{\bf D} = {\mathop{\rm diag}\nolimits}(-c^2, -c^2, 1)
\label{eq:conedecomp}
\end{equation}
where $c$ is the constant parameter representing the slope of the cone, and $[R, t]$ is the 3D rotation and translation that represents a coordinate transformation which aligns z--axis to the major axis of the cone.
Eq.~(\ref{eq:cone}) can also be rewritten by:
\begin{equation}
vech^{\mathrm{T}} (\bm{X}\bm{X}^{\mathrm{T}}) vech({\bf C}) = 0
\label{eq:cone_vech}
\end{equation}
$vech()$ is the half vectorization transformation of a symmetric matrix that is obtained by vectorizing the lower triangular part of the matrix.
Minimal solution for Eq.~(\ref{eq:cone_vech}) is therefore given by nine points.
We incrementally find multiple pipe instances by fitting cone to the newly produced 3D points. In each iteration of the incremental SfM, we search a cone in the temporary 3D model via RANSAC~\cite{ransac}.
The registered images are then labeled as it belongs to the pipe or not, based on the number and the ratio of inliers that support the cone model.
Once a pipe instance is detected, the detector searches a new conic shape from the 3D points seen by current frames that do not belong to any existing instances.
All cone parameters are then refined by local hypotheses refinement~\cite{chum2003locally} using 3D points observed by the labeled images, which achieves optimal cone fitting for 3D points.
\subsection{Bundle adjustment with cylinder constraint \label{sec:ba_cc}}
\noindent
Bundle adjustment in the general incremental SfM pipeline refines the current model by minimizing reprojection error represented by Eq.~(\ref{eq:generalba}).
If the conic shape detector finds the straight pipes, we can also compute the error of the 3D points with respect to the prior knowledge of the pipe properties, which is formulated as:
\begin{equation}
E ({\bf X, P, K, C}) = E_{rep} ({\bf X, P, K}) + \alpha E_{cyl} ({\bf X, C})
\label{eq:cost_ba}
\end{equation}
where the first term $E_{rep} ({\bf X, P, K})$ is the reprojection error term which is equal to Eq.~(\ref{eq:generalba}), and the second term $E_{cyl} ({\bf X, C})$ is our new cylinder constraint term.
${\bf X, P, K,}$ and ${\bf C}$ are the variables that indicate the sets of 3D points, the camera poses of the registered images, the camera intrinsic parameters, and the detected cones parameters, respectively. $\alpha$ is a constant scalar which controls the weights of two competing error terms.
Our cylindrical constraint punishes the distance of the 3D points $\bm{X}_j$ from the cylinder surface around the major axis.
Assuming the uniformly distributed accumulated error, the axis of the cylinder can be approximated by detected axis of the cone $[R_i, t_i]$, which is given by the decomposition of cone parameters ${\bf C}_i$ according to Eq.~(\ref{eq:conedecomp}).
$E_{cyl}$ is therefore formulated by:
\begin{equation}
E_{cyl} ({\bf X, C};r) = \sum_{i} \sum_{j} \rho (\| r - d(\bm{X}_j,[R_i, t_i])\| )
\end{equation}
where $d(\bm{X}_j,[R_i, t_i])$ is the distance of the 3D point $\bm{X}_j$ from the major axis of the cylinder,
and $r$ is the known inner diameter of the pipe.
$\rho$ is the Cauchy function used as the robust function.
Our incremental SfM system includes two types of bundle adjustment, local BA and global BA.
After registering each input image, our system performs local BA that refines camera poses of current frames, intrinsic parameters, and 3D points, by minimizing Eq.~(\ref{eq:cost_ba}).
When the model grows by a certain percentage or a new pipe instance is detected, the system runs global BA that optimizes all model parameters including the straight pipe parameters.
For completeness and fastness, we refine cameras intrinsic only after detecting first straight pipe.
Please notice that our newly proposed error term does not give any constraint on camera motion, unlike the previous works~\cite{el2011robio,zhang2011wscg,kunzel2018wacv}. Also notice that our SfM system updates each temporary model, thus produces a substantial different results from the one constructed via standard SfM at the end. As shown in the next section, this property enables us to obtain further complete and accurate 3D model (cf. Fig.~\ref{fig:qualitative}).
{\tabcolsep=1pt
\begin{figure}[t]
\centering
\begin{tabular}{cccc}
\rot{\rlap{~ \footnotesize Network A}}
&
\includegraphics[width=0.3\linewidth]{sequenceA_appearance_ds.png}
&
\includegraphics[width=0.3\linewidth]{sample_sequence1_ds.png}
&
\includegraphics[width=0.3\linewidth]{sample_sequenceA_2_ds.png}
\\
\rot{\rlap{~ \footnotesize Network B}}
&
\includegraphics[width=0.3\linewidth]{sequenceB_appearance_ds.png}
&
\includegraphics[width=0.3\linewidth]{sample_sequence2_ds.png}
&
\includegraphics[width=0.3\linewidth]{sample_sequenceB_2_ds.png}
\\
\rot{\rlap{~ \footnotesize Network C}}
&
\includegraphics[width=0.3\linewidth]{sequenceC_appearance_ds.png}
&
\includegraphics[width=0.3\linewidth]{sample_sequence3_ds.png}
&
\includegraphics[width=0.3\linewidth]{sample_sequenceC_2_ds.png}
\\
\rot{\rlap{~ \footnotesize Network D}}
&
\includegraphics[height=0.225\linewidth]{sequenceD_appearanceds.png}
&
\includegraphics[width=0.3\linewidth]{sample_sequenceD_1.png}
&
\includegraphics[width=0.3\linewidth]{sample_sequenceD_2.png}
\end{tabular}
\caption{{\bf Datasets.} Left: the target pipe network and camera path (red arrow) of each sequence. Middle and right: sample images of each sequence (middle: at a straight pipe, right: at an elbow).\label{fig:objects}}
\end{figure}
}
{\tabcolsep=11pt
\begin{table}[t]
\centering
\caption{{\bf The properties of each dataset.} We setup four different types of pipe networks and capture videos using the standard industrial endoscope as shown in Fig.~\ref{fig:hardware}. Note that the material of all pipes is steel.\label{tab:properties}}
\begin{tabular}{l|cccc}
Properties & A & B & C & D \\ \hline
Inner diameter [mm] & 16.1 & 8.0 & 16.1 & 16.1 \\
Video times [sec] & 61 & 183 & 367 & 442 \\
Centering device & Yes & No & No & No \\ \hline
\# Straight pipe & 3 & 4 & 5 & 7 \\
\# Tee & 2 & 2 & 2 & 2 \\
\# Elbow & 1 & 2 & 2 & 4 \\
Elbows angle (max) & $0^{\circ}$ & $45^{\circ}$ & $90^{\circ}$ & $90^{\circ}$ \\
\end{tabular}
\end{table}
}
\section{Experiments}
\noindent
In this section, we describe the performance of our incremental SfM pipeline designed for a pipe network reconstruction. We evaluate our method on several image sequences capturing the inners of pipe networks, which consist of multiple industrial pipes and indicate the practical scenarios of industrial visual inspection.
We firstly demonstrate our new constrained BA in an incremental SfM system effectively deals with error accumulation during the reconstruction (Sec.~\ref{sec:ba_impact}). We next compare our method with several vision-based reconstruction systems on our dataset (Sec.~\ref{sec:comparison}).
\para{Environment. }
Fig.~\ref{fig:objects} shows the four types of pipe networks we set up for evaluation. Detailed properties are described in Tab.~\ref{tab:properties}. All scenes consist of 1$\sim$5 straight pipes, tees, and elbows, constructed by industrial steel parts.
We collect $60$fps image sequences of those networks using an industrial endoscope (Fig.~\ref{fig:hardware}). Detailed specifications of the endoscope are summarized in Tab.~\ref{tab:spec}. The camera moves backward inside the networks following the red arrows in Fig.~\ref{fig:objects}, which is the practical manner of the pipe inspection due to the physical limitation of the endoscope.
The network A consists of three straight pipes in the same direction.
In this simple structure, we optionally attach an guide head device for the endoscope that roughly forces the camera to be in center of the pipe.
Note that this setting fairly makes the camera path to be stable and makes the reconstruction easier, but is sometimes infeasible, because the guide head does not support significant direction changes, {\it e.g}.} \def\Eg{{\it E.g}., curved camera path at an elbow. We do not use this attachment for network B, C, and D, to depict more general situations of the pipe network inspection.
Network B has a narrower inner diameter (8.0mm) than others (16.1mm) which leads to a more severe appearance changes and occlusions at the elbow parts.
Network D consists of the maximum number of pipes and elbows according to the flexibility of the endoscope, connected three-dimensionally with independent orientation.
\para{Evaluation metric. }
To evaluate the accuracy of 3D models, we compute the reconstruction error as the difference from the prescribed inner diameter of each straight pipe.
RMSE of radius rate is determined as:
\begin{equation}
RMSE = \sqrt{\frac{1}{n} \sum^n_i \left(\frac{r_i - r}{r} \right)^2}
\label{eq:rmse}
\end{equation}
where $r_i$ is the radius of inlier points in the straight cylinders estimated by our SfM, and $r$ is the prescribed radius value.
For other methods that originally do not detect any pipe, we additionally detect cylindrical parts and scale the model for evaluation, after the whole reconstruction process.
Specifically, we fit the multiple cones to the reconstructed model via sequential RANSAC while giving the number of pipe parts. The model is then scaled as approximating the diameter of the pipe by the average of points distances from the cone axis.
\para{Implementation. }
We construct our system based on an incremental SfM system implemented by COLMAP~\cite{colmap}, a widely known reconstruction tool. After constructing temporary 3D model for each 30 frames of the input, the system searches and refines the pipe instances of the model as described in Sec.~\ref{sec:tube_detection}. Once a cylinder is detected, the system replace bundle adjustment process in each iteration by our cylinder constrained BA (Sec.~\ref{sec:ba_cc}). We assume the pipe inner diameter of each Network is constant and known (cf. Tab.~\ref{tab:properties}). We experimentally set the parameter $\alpha$ in Eq.~(\ref{eq:cost_ba}) by 10.
{\tabcolsep=7pt
\begin{table}[t]
\footnotesize
\centering
\caption{{\bf Quantitative results.} Evaluation of 3D reconstruction results by our datasets. The values are the radius error rate (RMSE) (Eq.~(\ref{eq:rmse})). \label{tab:performance}}
\begin{tabular}{l|cccc}
Method & A & B & C & D \\ \hline
ORB-SLAM & 0.1916 & 0.5428 & 0.3331 & ${\bf 0.0958}$ \\
COLMAP & 0.1615 & 0.3291 & 0.3055 & 0.2670 \\
{\bf Ours} & $\bf{0.1375}$ & $\bf{0.2719}$ & $\bf{0.1560}$ & 0.1034 \\
\end{tabular}
\end{table}
}
\renewcommand{\thiswidth}{0.19\linewidth}
{\tabcolsep=1pt
\begin{figure}[t]
\centering
\begin{tabular}{ccccc}
\includegraphics[height=0.40\linewidth]{image_colmap_0.png} &
\includegraphics[height=0.40\linewidth]{image_colmap_1.png} &
\includegraphics[height=0.40\linewidth]{image_colmap_2.png} &
\includegraphics[height=0.40\linewidth]{image_colmap_3.png} &
\\
\includegraphics[height=0.40\linewidth]{errormap_colmap_0.png} &
\includegraphics[height=0.40\linewidth]{errormap_colmap_1.png} &
\includegraphics[height=0.40\linewidth]{errormap_colmap_2.png} &
\includegraphics[height=0.40\linewidth]{errormap_colmap_3.png} &
\includegraphics[height=0.40\linewidth]{colorbar.pdf} \\[-5pt]
\multicolumn{5}{c}{{\footnotesize (a) 3D points obtained via COLMAP. }} \\[5pt]
\includegraphics[height=0.40\linewidth]{image_pipmap_0.png} &
\includegraphics[height=0.40\linewidth]{image_pipmap_1.png} &
\includegraphics[height=0.40\linewidth]{image_pipmap_2.png} &
\includegraphics[height=0.40\linewidth]{image_pipmap_3.png} &
\\
\includegraphics[height=0.40\linewidth]{errormap_pipmap_0.png} &
\includegraphics[height=0.40\linewidth]{errormap_pipmap_1.png} &
\includegraphics[height=0.40\linewidth]{errormap_pipmap_2.png} &
\includegraphics[height=0.40\linewidth]{errormap_pipmap_3.png} &
\includegraphics[height=0.40\linewidth]{colorbar.pdf} \\[-5pt]
\multicolumn{5}{c}{{\footnotesize (b) 3D points obtained via proposed method. }}
\end{tabular}
\caption{{\bf Progress of the temporary model during the incremental SfM reconstruction.}
3D points show how the temporary model obtained via (a) COLMAP and (b) our incremental SfM pipeline grow up when each of the new images is registered. From left to right, each column roughly associates the temporary model updated by the end of the first pipe, the middle of the second pipe, the end of the second pipe, and the end of the pipe network, respectively.
Color-coded 3D points indicate the distance of each 3D point from the major axis of the pipe, regarding the true diameter of the pipes as 16.1mm.
}
\label{fig:color_results}
\end{figure}
}
\subsection{Impact of cylinder constrained BA \label{sec:ba_impact}}
\noindent
To demonstrate the impact of our cylinder constrained BA using the known pipe property,
we evaluate our method on Network A, the simplest situation on which all pipes direct to a common axis. For a comparison, we also run an incremental SfM for general purposes (COLMAP)~\cite{colmap}, which refines the model by minimizing Eq.~(\ref{eq:generalba}), on the same sequence.
Fig.~\ref{fig:qualitative}~(c,d) shows the appearances of the models obtained by proposed SfM and COLMAP.
Both methods succeed to recover the whole pipe network but proposed provides more accurate model (cf. Tab.~\ref{tab:performance}).
Fig.~\ref{fig:color_results} shows the 3D points of the temporary models obtained during the reconstruction, via COLMAP (a) and proposed (b).
During the reconstruction, COLMAP increasingly produces large errors regarding the known inner diameter, due to the errors of intrinsic parameters and erroneous estimations of the camera motion.
On the other hand, proposed method iteratively detects and refines each of the pipe instances, resulting in more accurate 3D model regarding the constant inner diameter.
\subsection{Reconstruction of multiple pipes network \label{sec:comparison}}
\noindent
Next we compare our SfM system with several other reconstruction systems on the pipe networks consist of multiple straight pipes.
\para{Comparisons. }
We compare our method to the state-of-the-art methods in each of three approaches described in Sec.~\ref{sec:related_work}, COLMAP~\cite{colmap} for SfM, ORB-SLAM~\cite{orbslam} for feature-based SLAM, and DSO~\cite{dso} for direct SLAM, respectively. For each comparison, we use the implementation provided by the authors. For a fair comparison, we use a calibrated fish-eye camera model (Sec.~\ref{sec:calibration}) for all methods\footnote{Since the original ORB-SLAM implementation only accepts a perspective model, we extend it for the fish-eye model.}. Note that we use DSO without photometric calibration since it is difficult to collect calibration data for industrial endoscope because of a built-in light source. While we use input sequence as $60$ fps for real-time methods (ORB-SLAM and DSO), we use $5$ fps sequence for offline methods (ours and COLMAP). We do not compare our methods with several works designed for a single pipe~\cite{peter2015ijrr,el2011robio, zhang2011wscg, kunzel2018wacv} because they do not provide their original implementations. But we believe adapting these works for each reconstructed pipe as batch-like process does not much improve reconstruction since they highly depend on the quality of the initial model, which is often largely distorted as shown in Sec.~\ref{sec:ba_impact}.
Tab.~\ref{tab:performance} shows the quantitative evaluation of 3D reconstruction results of COLMAP~\cite{colmap}, ORB-SLAM~\cite{orbslam}, and ours. Our method outperforms the baseline COLMAP on all scenes, and the margin is remarkable in network C. For network D, ORB-SLAM gives the best RMSE score, but it reconstructs only two pipes in the scene.
Fig.~\ref{fig:qualitative} shows the qualitative results of each method in each scene.
While ORB-SLAM and DSO can reconstruct in real-time, their reconstruction results are not as accurate as offline methods like ours and COLMAP, especially in complex scenes as network C and D.
ORB-SLAM reconstructs all the images in A and B, but fail to track the image sequences in C and D. This failure of tracking occurs because the method assumes a constant velocity motion to track the camera that is often not functional for an endoscopic cameras motion, {\it e.g}.} \def\Eg{{\it E.g}., significant view changes in an elbow.
In contrast, the proposed method reconstructs the whole target for all sequences, while preserving a stable diameter.
\para{Limitation. }
To address the difficulties raised in the pipe inner situation, our system applies a prior knowledge ({\it i.e}.} \def\Ie{{\it I.e}. constant inner diameter) to the existing 3D points in the model, rather applying before or during the 3D mapping, {\it e.g}.} \def\Eg{{\it E.g}., feature matching guided by known properties, or 3D points triangulation constrained within the known pipe surface. This strategy,
however, could result in insufficient model reconstruction when the system cannot find sufficient matches. The problem is caused when the pipe network includes pipes which have especially severe properties, {\it e.g}.} \def\Eg{{\it E.g}., material which has a smooth nature. Potential approach to make the system robust to such severe conditions is that obtaining matches in dense manner~\cite{tola2009daisy,aji_sfm} attempting to get pixel-wise precise matches and offering outlier rejection scheme guided by pipe properties.
Another future work is to determine a proper parameter $\alpha$ in Eq.~\ref{eq:cost_ba}, which balances the temporal property and the prior information, also regarding the demand of the model quality.
\renewcommand{0.24\columnwidth}{0.37\columnwidth}
{\tabcolsep=3pt
\begin{figure*}[t]
\centering
\begin{tabular}{cc|cccc}
\rot{\rlap{~ \footnotesize \hspace{15pt} Network A}} &
\includegraphics[height=0.24\columnwidth]{sequenceA_appearance_ds.png}
&
\includegraphics[clip, height=0.24\columnwidth]
{scene1_dso.pdf}
&
\includegraphics[clip, height=0.24\columnwidth]
{scene1_orbslam.pdf}
&
\includegraphics[clip, height=0.24\columnwidth]
{scene1_colmap.pdf}
&
\includegraphics[clip, height=0.24\columnwidth]
{scene1_propose.pdf}
\\
\rot{\rlap{~ \footnotesize \hspace{15pt} Network B}} &
\includegraphics[height=0.24\columnwidth]{sequenceB_appearance_ds.png}
&
\includegraphics[clip, height=0.24\columnwidth]
{scene2_dso.pdf}
&
\includegraphics[clip, height=0.24\columnwidth]
{scene2_orbslam.pdf}
&
\includegraphics[clip, height=0.24\columnwidth]
{scene2_colmap.pdf}
&
\includegraphics[clip, height=0.24\columnwidth]
{scene2_propose.pdf}
\\
\rot{\rlap{~ \footnotesize \hspace{15pt} Network C}} &
\includegraphics[height=0.24\columnwidth]{sequenceC_appearance_ds.png}
&
\includegraphics[clip, height=0.24\columnwidth]
{scene3_dso.pdf}
&
\includegraphics[clip, height=0.24\columnwidth]
{scene3_orbslam.pdf}
&
\includegraphics[clip, height=0.24\columnwidth]
{scene3_colmap.pdf}
&
\includegraphics[clip, height=0.24\columnwidth]
{scene3_propose.pdf}
\\
\rot{\rlap{~ \footnotesize \hspace{15pt} Network D}} &
\includegraphics[height=0.24\columnwidth]{sequenceD_appearanceds.png}
&
\includegraphics[clip, height=0.24\columnwidth]
{scene4_dso.png}
&
\includegraphics[clip, height=0.24\columnwidth]
{scene4_orbslam.png}
&
\includegraphics[clip, height=0.24\columnwidth]
{sene4_colmap.png}
&
\includegraphics[clip, height=0.24\columnwidth]
{scene4_propose.png}
\\ \hline
&
{\footnotesize Appearances}&
{\footnotesize (a) DSO} &
{\footnotesize (b) ORB-SLAM} &
{\footnotesize (c) COLMAP} &
{\footnotesize (d) {\bf Ours}} \\
\end{tabular}
\caption{{\bf Qualitative comparisons.} Each row shows a visual comparison of the 3D models for each pipe network obtained via four relevant methods. Gray dots show the reconstructed scene points, whereas red dots show the estimated cameras. }
\label{fig:qualitative}
\end{figure*}
}
\section{Conclusion}
\noindent
In this paper, we have proposed a vision-based pipe reconstruction system that can provide an accurate 3D reconstruction for industrial endoscopic images. To deal with the accumulated model errors, our method incorporates the prior information of the pipe network without limiting the flexibility of camera motion. Proposed SfM pipeline consists of robust pipe detection and bundle adjustment constrained by the geometrical properties of a pipe system, which are carefully combined into an incremental image registration process, for stable camera tracking and 3D reconstruction. Throughout the experiments on realistic pipe network environments, it is demonstrated that our method can suppress scale drifting and reconstruct 3D pipe models more accurately and robustly than existing state-of-the-art methods. One of the future works is to develop a real-time application for giving instant feedback to the inspector.
\para{Acknowledgement.} This work was partly supported by JSPS KAKENHI Grant Number 17H00744.
{\small
\bibliographystyle{IEEEtran}
| {'timestamp': '2020-07-06T02:07:59', 'yymm': '2006', 'arxiv_id': '2006.10383', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10383'} | arxiv |
\section{Simulation analyses}
\subsection{Dataset}
We generated sequences of neuronal populations in areas \textit{X} (e.g. early sensory cortex) and \textit{Y} (e.g. prefrontal cortex). We set the number of time steps to 24, and the number of neurons in areas \textit{X} and \textit{Y} to 10 and 9, respectively. At each time step $t$, baseline activities for areas \textit{X} and \textit{Y} were drawn randomly from a Gaussian distribution $\mathcal{N}(0,1)$. Each trial was labelled with stimulus and decision. There were 5 possible stimuli and 3 possible decisions, thus $3 \times 5 = 15$ possible combinations of labels. For each combination, we generated 20 trials, resulting in 300 trials in total. Stimulus onset occurred at time step 6. Noises were added to each neuron for each trial independently from a Gaussian distribution $\mathcal{N}(0,\frac{1}{3.5})$.
Neurons in areas \textit{X} and \textit{Y} were affected by the stimulus and decision, and communicated with each other as follows. First, neurons in area \textit{X} were affected by the stimulus for three time steps from the time of stimulus onset. The magnitudes of the effects were randomly determined for each neuron, were linearly correlated with the level of the stimulus, and were linearly increased across time. Neurons in area \textit{X} passed the stimulus-related information to the neurons in area \textit{Y} via a random projection matrix after two time steps from the time when neurons in area \textit{X} started to process stimulus-related computation. After area \textit{Y} received the stimulus-related input from area \textit{X}, neurons in area \textit{Y} started to compute the decision. As with the stimulus-related computation in area \textit{X}, the magnitude of the effects were also randomly determined for each neuron, were linearly correlated with the level of the decision, and were linearly increased across time. Area \textit{Y} then passed decision-related information back to area \textit{X} via another random projection matrix after two time steps from the time when decision-related computation in \textit{Y} emerged.
\subsection{Analyses}
With the setting described above, we obtained a $10 neurons \times 300 trials \times 24 timesteps $ array for area \textit{X}, and $9 neurons \times 300 trials \times 24 timesteps $ array for area \textit{Y}. To investigate the relationship between areas \textit{X} and \textit{Y} in a time-resolved manner, we then constructed two matrices $\mathbf{X}$ and $\mathbf{Y}$, where $\mathbf{X}$ is the area \textit{X}’s data matrix of size $10 \times 300$ at time $t_X$, and $\mathbf{Y}$ is the area \textit{Y}’s data matrix of size $9 \times 300$ at time $t_Y$. We assume that whichever neuronal population is currently earlier in time is the ‘source’ matrix, and whichever population is later in time is the ‘target’ matrix . We ignored the cases where $t_X == t_Y$.
To separate the data into training and testing sets, for each label combination, we held out one random trial as test trial. Thus the number of test set trials is $3decisions \times 5stimuli = 15$. We then applied jPECC (with CCA/RRR) or jPESC (with dSCA) to training set as follows. We then applied obtained transformation matrices to test set. We repeated this procedure fifteen times for different train-test splits, and averaged the results.
jPECC with CCA/RRR was performed on the training set, L2 regularized using $\lambda = 0.05$. For CCA, the test set trials were projected onto a canonical dimension, and the Pearson correlation coefficient was computed between projected test set trials in the source and target areas. For RRR, we predicted values of the test set target matrix from the test set source matrix, using transformation matrices estimated by training set. We then computed explained variance between predicted and actual test set target matrix. We used the top low-dimensional component both for CCA and RRR.
As with the jPECC with CCA/RRR, jPESC with dSCA was performed on the training set, L2 regularized using $\lambda = 0.05$. However, here we applied marginalization to the target matrix. We used stimulus- and decision-marginalized target matrices for dSCA separately. We predicted values of the marginalized target matrix from the source matrix in the test set, using transformation matrices estimated by the training set. We then computed explained variance between predicted and actual target matrices. We used the top low-dimensional component.
\subsection{Statistical inference }
To test whether areas of high correlation/explained-variance between two brain regions were significantly larger than would be expected by chance, we used a cluster-based permutation test \citep{Hunt2018}. For jPECC with CCA, we identified clusters in the correlation map that were larger than a cluster-forming threshold (set at $r>0.4$). For jPECC with RRR and jPESC with dSCA, we identified clusters in the explained variance map that were larger than a cluster-forming threshold (set at $R>-0.99$). We then permuted trials in one brain area to recompute jPECC/jPESC, and we identified clusters that exceeded the cluster-forming threshold in the permuted data. Note that, we permuted trials but not distorted temporal structure across time steps. For each of the 100 permutations, we stored the size of the largest cluster. This procedure provided a null distribution of maximum cluster sizes that would be expected by chance. We used 95th percentile of this null distribution as a threshold for deeming whether the cluster sizes observed in the data were significant, at $P<0.05$ (corrected for multiple comparisons across all pairs of timepoints).
\section{Perceptual decision making task (Steinmetz et al., 2019)}
\subsection{Dataset}
The authors trained mice to perform visual discrimination task. During each recording session, the authors simultaneously recorded from hundreds of neurons in multiple regions using Neuropixels \citep{Steinmetz2018,Jun2017} probe ($n = 92$ probe insertions over 39 sessions in 10 mice). The details of data acquisition and preprocessing are described in \citep{Steinmetz2019}. Datasets is obtained from \url{https://figshare.com/articles/Dataset_from_Steinmetz_et_al_2019/9598406} and codes for preprocessing is obtained from \url{https://github.com/nsteinme/steinmetz-et-al-2019}, both were published by the authors.
In their original paper, they applied jPECC with CCA to neural activities that were recorded at relative to movement (-300 to 100 ms) between visual and frontal cortex (15 sessions), visual cortex and midbrain (10 sessions), and frontal cortex and midbrain (9 sessions) (see \citep{Steinmetz2019} for precise anatomical locations included in each of these subregions). For each combination, we analysed data from the three sessions with the largest number of completed trials; this is because there was a substantial variation in terms of the number of completed trials between sessions, and we found empirically that a certain amount of trials are necessary for reliable estimation by dSCA.
If two task parameters are orthogonalized by experimental design, we do not need to do any procedure before marginalization (as in economic decision making task). However, if two task parameters are correlated by design (as in this task), to focus on a task parameter, we need to regress the other task parameters out from neural data before marginalization. Therefore, we also prepared the neural data that were regressed out Stimulus or Decision information. These regressed-out matrices were also used for dSCA.
\subsection{Analyses}
We applied jPECC with CCA and jPESC with dSCA. All settings are the same as the simulation analyses except for the following:
\begin{itemize}
\item Before applying jPECC with CCA and jPESC with dSCA, we applied PCA to both source and target matrices as was done in \citep{Steinmetz2019}, across time points and trials to reduce population activity to ten dimensions.
\item For jPESC with dSCA, marginalization was performed two main task parameters: stimulus and decision (see main manuscript for the definition). We also applied dSCA to matrices after regressing out either stimulus or decision from these matrices. We confirmed that applying PCA before applying jPESC with dSCA did not substantially change the results (data not shown).
\item We repeated the cross-validation procedure ten times, averaging the results.
\end{itemize}
\subsection{Statistical inference }
We used the same cluster-based permutation test procedure as described above for the simulation analyses.
To quantify lead–lag relationships, we computed the asymmetry index by calculating the number of significant timepoints included in the identified cluster from the above permutation procedure. We calculated these numbers in right and left half of the obtained jPECC and jPESC matrices separately, and then subtracted right from left. This procedure provided a null distribution of the difference in the number of significant timepoints between left half and right half that would be expected by chance. We used the 95th percentile of this null distribution as a threshold for deeming whether the difference of number of significant timepoints between the left half and right half observed in the data were significant, at $P<0.05$.
\section{Economic decision making task (Hunt et al., 2018)}
\subsection{Dataset}
The authors recorded neuronal activity in the macaque OFC, ACC and DLPFC during sequential attention-guided information search and choice. During a typical recording session, 8–24 electrodes were lowered bilaterally into multiple target regions. We used the data from monkey coded ‘F’. The details of data acquisition and preprocessing are described in \citep{Hunt2018}. Dataset and codes for preprocessing are obtained from \url{http://crcns.org/data-sets/pfc/pfc-7} that was published by the authors.
In this experiment, neural recordings were obtained in multiple sessions, so most of the neurons were not recorded simultaneously. We therefore used `pseudopopulation' matrices by averaging averaged across task parameters to identify each neuron’s response to experimental variables. This allowed us to collapse data across sessions.
\subsection{Analyses}
We applied jPECC with CCA and jPESC with dSCA, as per the previous analyses. All procedures are the same as the simulation analyses except for the following settings:
\begin{itemize}
\item For jPECC with CCA and jPESC with dSCA, we applied PCA to both source and target matrices as was done in \citep{Steinmetz2019}, across time points and trials to reduce population activity to eight dimensions.
\item For jPESC with dSCA, marginalization was performed on two main task parameters in the task: space and attended-value (see main manuscript for the definition). We confirmed that applying PCA before applying jPESC with dSCA did not substantially change the results (data not shown).
\item For cross-validation in the pseudopopulation setting, to separate the data into training and testing sets, we followed the procedure proposed in \citep{Kobak2016}. We first held out one random trial for each neuron in each combination of task parameters, i.e. space and attended-value, as a set of test pseudopopulations $X_{test}$ and $Y_{test}$. Because there are 5 possible stimuli and 2 possible spaces, the dimensions of $X_{test}$ and $Y_{test}$ is $5 \times 2 = 10$. Remaining trials were averaged to form a training sets of $X_{train}$ and $Y_{train}$. Note that test and training sets ($X_{test}$ and $X_{train}$, or $Y_{test}$ and $Y_{train}$) have the same dimensions of 10. We repeated this cross-validation procedure 20 times and averaged the results.
\end{itemize}
\subsection{Statistical inference }
We used the same cluster-based permutation test procedure as described above for the simulation analyses. We also used the same permutation test procedure for determining lead–lag relationships as described above for the perceptual decision making task.
\section{Introduction}
Recent methodological advances make it possible to record thousands of neurons simultaneously \citep{Jun2017}. Although such high-dimensional recording yields insights that are not apparent from studying single neuron activity, analysing population data remains a non-trivial problem because of the heterogeneity of responses and ‘mixing’ of encoded variables observed in neural data \citep{Fusi2016}. While traditionally such heterogeneity was discarded by simply averaging across neurons, more recently several dimensionality reduction methods have been developed for neurophysiological data that isolate key features of the population response structure \citep{Cunningham2014}. One popular approach is demixed principal component analysis (dPCA; \citep{Brendel2011,Kobak2016}). dPCA identifies components that explain maximum population variance while also ‘demixed’ from non-interesting task parameters, in other words depending upon key task parameters. This allows experimenters to combine rich population recordings with equally rich task design, as dPCA isolates low-dimensional components that vary along axes defined by features of the experimental task.
Besides the number of neurons recorded, neuroscientists are also experiencing a revolution in the number of brain areas recorded. This is fascinating because the brain is a connected system comprised of functionally specialised areas that interact with each other to produce complex behaviors. Recently, researchers have started to investigate interactions between populations of neurons in distinct areas for motor control \citep{Kaufman2014}, visual processing \citep{Semedo2019} or perceptual decision making \citep{Steinmetz2019}. Similar to studies examining population responses in a single brain region, these studies have applied dimensionality reduction methods to examine information shared across regions - including principal component analysis (PCA; \citep{Kaufman2014}), reduced rank regression (RRR; \citep{Semedo2019}), or canonical correlation analysis (CCA; \citep{Steinmetz2019}).
However, while these approaches all yield important insights into cross-regional information sharing, they cannot identify when and what task parameters are shared across regions. This limits our understanding of how information is shared across regions during cognitive tasks. It is known that the task parameters are mixed at the level of single neuron \citep{Rigotti2013} or low-dimensional components obtained by standard dimensionality reduction methods \citep{Mante2013}. Thus, it is important to properly demix each of closely related but distinct task parameters, for example, those encoding decision input, choice formation and motor output during decision making tasks \citep{Gold2007,Hunt2015}. It is also important to identify precise timing of information sharing because relevant cross-areal information sharing may only occur at any specific timing during the entire task-related processing.
Here, inspired by the approach taken by dPCA, we propose a method for identifying shared components across two areas that is specific to a task parameter of interest in a time-resolved manner. The key idea is to `marginalize' neural population activity in a single area to demix a specific task parameter of interest, while maximizing the information shared by the two areas with a time lag. We call this procedure demixed shared component analysis (dSCA). \footnote{Codes are available on GitHub (https://github.com/yu-takagi/dSCA).}
Our contributions are summarized as follows:
\begin{enumerate}
\item We briefly review previous methods, emphasizing that they cannot identify what and when task parameters are shared across brain regions.
\item Motivated by this fact, we propose dSCA to isolate the contribution of a task parameter of interest to the shared information between different brain areas. Using a simulation analysis in Sect. 3 we show that dSCA finds shared components that are demixed into specific task parameters of interest in a time-resolved manner, while previous CCA or RRR fail.
\item We reanalyze two previously published decision making datasets \citep{Steinmetz2019,Hunt2018} and show that dSCA captures shared components among different brain areas that is specific to task parameters such as decision input, stimulus valuation, attentional reorienting and choice formation.
\end{enumerate}
\section{Related work}
\paragraph{Interaction of populations of neurons across different brain areas.}
Early studies investigated interactions of different brain areas in different scales: pairs of single neurons (e.g. \citep{Nowak1999}), populations of neurons in one area and a single neuron in another (e.g. \citep{Truccolo2010}), neurons in one area and the local field potential (LFP) in another (e.g. \citep{Gregoriou2009}), and LFPs in different areas (e.g. \citep{salazar2012content}). In recent years, some researchers have started to investigate interaction of neuronal populations between brain areas \citep{Kaufman2014,Semedo2019,Steinmetz2019}. They commonly applied linear dimensionality reduction methods to study the relationship between neural populations in different areas (Figure 1c, top). For example, Kaufman et al. (2014) \citep{Kaufman2014} applied PCA to each area separately, then regressed from one area to the other area (an approach sometimes referred to as principal component regression). However, the components obtained by PCA that explain maximal variance separately in each area will not necessarily align with those that would explain maximal shared information between the two areas.
More recent studies have used alternative techniques such as RRR \citep{Semedo2019} and CCA \citep{Steinmetz2019, rodu2018detecting} (Figure 1d, top) to directly find low-dimensional latent components from two populations of neurons (Figure 1e, top), optimized for identifying interaction between them. In particular, Steinmetz et al. (2019) \citep{Steinmetz2019} also proposed a time-resolved approach, by applying CCA exhaustively on all possible pairs of time points/windows between one area and the other area activities (Figure 1f, top). The method, called joint peri-event canonical correlation (jPECC) analysis, identifies when cross-regional interaction occurs from one region to another. However, none of the above approaches provide results that are demixed by experimental conditions. This means that none of these analyses could identify (\textit{‘what’}) information was being shared across regions.
\paragraph{Demixing task parameters.}
It is well known that neurons have mixed selectivity, where a neuron’s firing rate reflects more than one task parameter \citep{Rigotti2013}. This is still true for the component after applying standard dimensionality reduction method such as PCA or non-negative matrix factorization \citep{Mante2013}. It is a critical problem for researchers who are interested in cognitive processing during a complex experiment, because different types of computations run simultaneously in the brain, and it is important to be able to dissociate computations pertaining to one task parameter from the others. Several approaches have been proposed (e.g., \citep{Brendel2011,Kobak2016,Mante2013}). Among such approaches, dPCA \citep{Brendel2011,Kobak2016} is one of the most popular methods because of its simplicity. dPCA combines regression with dimensionality reduction to demix task parameters of interest. However, this demixing is performed on neurons from a single region at a time, rather than capturing shared information across regions.
\section{Demixed shared component analysis (dSCA)}
We begin with a typical neuroscience experiment that motivated us to develop dSCA. In the experiment, animals are trained on a set of stimuli to make decisions in order to maximize total rewards (Figure 1a, top). For example, animals earn rewards at the end of each task trial if they choose an appropriate action (\textit{Decision}) depending on the visual stimulus (\textit{Stimulus}) presented after a fixation period. Each trial is thus labelled with the two task parameters, Decision and Stimulus, both discrete-valued. Single neuron activities are measured during a series of task trials using an implanted electrode array or probe in the brain. In recent years, such multielectrode technologies have been used for recording populations of neurons simultaneously across multiple brain regions (Figure 1b). In some instances, however, data from different electrodes may be recorded in different sessions, and a ‘pseudopopulation’ is reconstructed by first averaging across task parameters and then concatenating neurons across recording sessions. We will describe this procedure in detail later.
\begin{figure}
\centering
\includegraphics[width=\linewidth]{fig1.pdf}
\caption{\textbf{dSCA can identify content and timing of task-related information sharing among multiple brain areas.} \textbf{a} Schematic of typical timeline of a trial in a decision making experiment in neuroscience. \textbf{b} The data are represented as sequences of populations of neurons matrices of area \textit{X} (e.g. early sensory cortex) and area \textit{Y} (e.g. prefrontal cortex). \textbf{c} area \textit{X} (top) and area \textit{Y} (bottom) communicate task-related information each other. \textbf{d} Schematic of the analysis for two populations of neurons from different brain areas, \textit{X} and \textit{Y}. Conventional approaches (CCA or RRR) estimate relationship between source and target populations of neurons without taking task parameters into account (top). In contrast, dSCA applies marginalization to the target matrix by averaging across specific task-parameter of interests (middle: marginalization for stimulus; bottom: marginalization for decision). In the marginalization procedure, for each neuron and each task parameter, trials having the same level of the task parameter have the same values (average across the same-level trials). Cells with the same colours indicate the same values. \textbf{e} Schematic of the obtained components from CCA/RRR (top) and dSCA (middle and bottom). Each circle indicates a neuron or a component, and the width of an arrow indicates estimated weights. The component obtained from CCA/RRR is mixed, whereas the components obtained via dSCA are demixed in terms of the task parameter. \textbf{f} Top: Schematic of joint peri-event canonical correlation (jPECC) analysis. Results obtained from CCA/RRR may not dissociate two task parameters from one another. Using dSCA yields joint peri-event shared component (jPESC) for stimulus (middle) and decision (bottom) are dissociated. Coloured areas indicate significant relationship between two areas at the pair of time-points.}
\end{figure}
Our goal is to investigate both the content (\textit{‘what’}) and timing (\textit{‘when’}) of task-related information sharing among multiple brain areas based upon the measured activities of neuronal populations. We first assume that the entire population was measured simultaneously from area ‘\textit{X}’ and area ‘\textit{Y}’ (but note that our approach generalises to non-simultaneous pseudopopulation recordings below). For each area, we thus observe $M \times T \times N$ arrays of firing rates, where $M$ denote numbers of neurons in the area, $T$ denotes the number of trials, and $N$ denotes the length of timeseries of a particular time window of interest (e.g. 0-500ms after the stimulus onset).
Although existing approaches for cross-areal interaction analysis (see Related Work) can detect low-dimensional representations of shared information between different brain areas, they cannot give insights into the type of information in relation to the task parameters of interest. This is because these approaches use only the data (firing rate) matrices without taking into account how task parameters cause changes in these matrices. As a result, obtained components from these approaches are in general mixed in terms of the task parameters (Figure 1e, top).
This is problematic if we want to study how task-relevant information is passed between brain regions as a cognitive process unfolds. Consider, for example, a decision task in which sensory information is passed in a bottom up sweep from lower to higher cortical areas, but the categorical choice emerges in a distributed fashion across multiple layers in the cortical hierarchy (e.g. \citep{Siegel2015, Murphy2020}; see Figure 1c for simple schematic). Applying standard methods to this data will not differentiate between sensory input causing covariation between brain regions’ activity on the one hand, and the emergence of the decision process on the other.
To overcome the problem of what information is shared between regions, we propose to combine the idea of demixing \citep{Kobak2016} with cross-areal interaction analysis using CCA/RRR. We use demixed Shared Component Analysis (dSCA) to refer to a family of methods that combine these two principles. We focus on RRR for ease of exposition, but note that RRR reduces to CCA if the target matrix is whitened \citep{Torre2012} and thus the framework can unify both techniques.
First, recall that standard least-squares RRR minimizes the following:
\begin{center}
$L_\mathrm{RRR} = \left \| \mathbf{Y} - \mathbf{WX} \right \|^{2}$
\end{center}
where $\mathbf{X}$ is the area \textit{X}’s data matrix of size $M_{X} \times T$, $\mathbf{Y}$ is the area \textit{Y}’s data matrix of size $M_{Y} \times T$, and $\mathbf{W}$ is coefficient matrix of size $M_{X} \times M_{Y}$, and the rank of $\mathbf{W}$ is constrained not to be greater than $K$ $(<min(M_X,M_Y))$; $M_{X}$ and $M_{Y}$ denote their respective numbers of neurons , and the number of columns in $\mathbf{X}$ and $\mathbf{Y}$ equals the number of trials $T$ in our time-resolved setting while it may vary depending on the context. The constrained minimization can be solved using the singular value decomposition:
\begin{center}
$\mathbf{W}_{RRR} = \mathbf{W}_{OLS}\mathbf{VV}^T $
\end{center}
where $\mathbf{W}_{OLS}$ is the ordinary least-squares solution and the columns of the $M_{X} \times K$ matrix $\mathbf{V}$ contain the top $K$ principal components of the optimal linear predictor $\mathbf{\hat{Y}}_{OLS} = \mathbf{XW}_{OLS}$.
To properly demix the effect of task parameters within CCA/RRR, we now make a key change to the above framework based on the so-called 'marginalization' procedure \citep{Kobak2016}. The idea is to replace every column of raw target matrix $\mathbf{Y}$ with its conditional expectation, estimated empirically, given the corresponding realization of a specific task parameter of interest (Figure 1d, middle and bottom). For example, in the running example above, there can be 3 possible stimuli and 2 possible decisions. Marginalization to demix ‘stimuli’ yields $\mathbf{Y}_{\it Stimulus}$ having identical columns (trials) if they correspond to the same type of stimulus irrespective to the type of decision (Figure 1d, middle). Similarly, marginalization for ‘decision’ yields $\mathbf{Y}_{\it Decision}$ with identical columns depending only on the type of decision for each trial (Figure 1d, bottom). We will generically write the marginalized matrix as $\mathbf{Y}_{m}$, where $m$ can be any task parameter of interest, such as stimulus or decision, containing $N_{m}$ possible levels. We can also consider marginalization for the interaction of multiple parameters, e.g. stimulus and decision.
We refer to the resultant analysis framework as dSCA. After solving the CCA/RRR, if $\mathbf{Y}_{m}$ can significantly be associated with the source activity via the low-rank representations, it indicates that areas $X$ and $Y$ share information that is relevant to the task parameter $m$ of interest. For example, if we are interested in the stimulus-related information sharing between areas $X$ and $Y$, we will marginalize the target matrix by stimulus, thus we use $\mathbf{Y}_{\it Stimulus}$ as a target matrix. Then, applying RRR as above, we can find an optimal low-rank representation of the source populations of neurons for predicting the target area's variance that is related to the stimulus information (Figure 1e, middle and bottom). Thus, dSCA explicitly takes task parameters into account, which is the crucial difference from related previous methods.
Note that in our framework, we only marginalize the target, with the ‘source’ matrix $\mathbf{X}$ being left intact. As discussed in \citep{Kobak2016}, the underlying idea is that while the marginalized target can eliminate task-irrelevant variability by marginalization, one can still employ full information in the source populations of neurons. In fact, one may apply marginalization to source matrix as well in addition to the target, which gives a simple variation of dSCA. If the effects of different task parameters on neural populations are independent, the results obtained from the original source matrix and marginalized source matrix are indifferent. However, this reduces the effective sample size rather drastically (as the column pairs in $\mathbf{X}_m$ and $\mathbf{Y}_m$ then contain many duplicates).Therefore, if their effects are not independent, marginalization by non-interesting task parameters may unintentionally diminish the information of the task parameter of interest. Indeed, we empirically found that marginalization of both matrices often leads to less accurate results (see Section 4.1 for simulation analysis).
So far, we have assumed that all the neurons are measured simultaneously, but this is not always the case. Fortunately, when we do not record all neurons simultaneously, we can still apply the same technique by making use of the concept of ‘pseudopopulations’, as discussed in \citep{Kobak2016}. For each neuron, we first compute summary statistics for all possible combinations of task parameters, called peri-stimulus time histogram or PSTH. To calculate PSTH, we will average each neuron’s firing rate over trials for each possible task parameter, in order to estimate the neuron’s time-dependent firing rate. For example, suppose that we have two task parameters, stimulus and decision. In this case, we will average over trials for each stimulus $s$ (out of $S$) and decision $d$ (out of $D$). Specifically, we will use two matrices of $\mathbf{X}$ $\in$ $\mathbb{R}^{M_{X} \times C}$ and $\mathbf{Y}$ $\in$ $\mathbb{R}^{M_{Y} \times C}$, where $C = S \times D$.
To address the question of when information is shared between the two regions, we follow the jPECC approach introduced in Steinmetz et al. (2019) \citep{Steinmetz2019}. We repeat the dSCA analysis at all possible combinations of time-bins between areas \textit{X} and \textit{Y}. This yields a $N$-by-$N$ peri-event matrix for each demixed shared component (Figure 1f), which we refer to as the joint peri-event shared components (jPESC). When performing this lagged analysis, we assume that whichever neuronal population is currently earlier in time is the ‘source’ matrix, and whichever population is later in time is the ‘target’ matrix.
\section{Results}
\paragraph{Synthetic data}
To illustrate that dSCA can detect shared components between two areas that is specific to a task parameter of interest, we generated two simulated neuronal population datasets.
Suppose that we simultaneously recorded from two brain areas, $X$ and $Y$, during the experiment in which two task parameters exist: stimulus ($S$) and decision ($D$). The neural population in $X$ is affected by variation in the stimulus, as shown in Figure 1c. Then, the population of neurons in $X$ passes stimulus information to another population of neurons in $Y$ with some time delay. A decision computation then arises in the population of neurons $Y$, such that it begins to encode the categorical choice of the animal, which is passed back to populations of neurons in $X$. We also added independent random noise to populations of neurons in $X$ and $Y$ (see Supplementary Material).
We first conducted jPECC on the simulated data, applying standard CCA and RRR to $X$ and $Y$ with different time point pairs (Figure 2a), as was done in Steinmetz et al. (2019) \citep{Steinmetz2019}. Each pixel in the resulting matrix represents the strength of cross-validated correlation between the first pair of canonical variables at a given latency for CCA, or explained variance, $ -(\mathbf{Y}_m - \hat{\mathbf{Y}}_m)^2/\textrm{Var}(\mathbf{Y}_m)$, for RRR. Although jPECC can reveal that these two areas share information (significant clusters are shown; $P < 0.05$, cluster-based permutation test, corrected for multiple comparisons; see Supplementary Material for details), it does not tell us what types of information is being shared (Figure 2b). Given that both CCA and RRR provide similar results in the simulation analyses, we will use CCA for the following analyses of real datasets. Note that, if we used explained variance as a metric for CCA, we obtained similar results to using correlation (see Supplementary Figure 1).
We next applied jPESC to $X$ and $Y$, to obtain a similar time-resolved matrix but using dSCA rather than CCA/RRR. We focus on two main task parameters: stimulus ($S$) and decision ($D$). In contrast to CCA, we used the marginalized matrix as the target, rather than the raw population matrix. Figure 2c shows that dSCA can clearly dissociate the shared information related to the distinct task parameters in populations of neurons in area $X$ and $Y$ ($P < 0.05$, cluster-based permutation test, corrected for multiple comparisons). Note that, although we used the raw matrix as the source matrix for dSCA, we could also use the marginalized source matrix (as described in section 2.2). We found that such a version of dSCA in which both $X$ and $Y$ are marginalized provides similar, but less accurate results than the results from using the raw source matrix (see Supplementary Figure 2). Therefore, we used the raw matrix as the source matrix for the following analyses of real datasets.
\begin{figure}
\centering
\includegraphics[width=\linewidth]{fig2.pdf}
\caption{\textbf{Simulation demonstrates that dSCA decomposes information sharing between different brain regions into different task-relevant parameters.} \textbf{a} Schematic of joint peri-event analysis. \textbf{b} Results obtained from CCA (left) and RRR (right) show similar results. \textbf{c} Results obtained from dSCA for stimulus (left) and decision (right).}
\end{figure}
\paragraph{Perceptual decision making}
Next, we reanalyzed a perceptual decision making dataset for validating the use of dSCA to demix task parameters of interest. We used the dataset that was published in Steinmetz et al. (2019) \citep{Steinmetz2019} . On each trial of the experiment (Figure 3a), visual stimuli of varying coherence could appear on the left side, right side, both sides or neither side. Mice earned a water reward by turning a wheel with their forepaws to indicate which side had the higher coherence. Here, we exclude NoGo trials, where neither stimulus was present and mice should not move.
In the original study, the authors analyzed interactions of neural populations using jPECC among three different subregions: visual cortex, frontal cortex, and midbrain (Figure 3b); see Steinmetz et al. (2019) for precise anatomical locations included in each of these subregions \citep{Steinmetz2019}. They applied jPECC to neural activities that were simultaneously recorded at relative to movement onset between visual and frontal cortex (Figure 3c, top), visual cortex and midbrain (Figure 3c, middle), and frontal cortex and midbrain (Figure 3c, bottom). Their results revealed the latency at how information is shared between these subregions, but not which task parameter was being shared. We preprocessed the dataset exactly as in the original study (see Supplementary Material for the details of preprocessing) and our results with standard jPECC replicated their previous findings (Figure 3c; significant clusters are shown; $P < 0.05$, cluster-based permutation test, corrected for multiple comparisons). Note that, for each combination, we analysed data from the three sessions with the largest number of completed trials; this is because there was a substantial variation in terms of the number of completed trials between sessions, and a certain amount of trials are necessary for reliable estimation by dSCA. Qualitatively similar (albeit weaker) results could be obtained from all sessions, including those with fewer trials (Supplementary Figure 4).
To obtain demixed results, we applied dSCA to the same dataset. Here, we focus on two main task parameters: stimulus and decision. Stimulus is defined as the strength of left coherence (1, 0.5, 0.25 or 0) minus strength of right coherence (1, 0.5, 0.25 or 0) for each trial. Decision is defined as the mouse’s choice for each trial (Left or Right). In addition to applying dSCA to raw population matrices, we also applied dSCA to matrices after regressing out either stimulus or decision from these matrices, because these two task parameters are correlated to some extent (see Supplementary Material). Figure 3d shows that for all combinations of brain regions, information sharing is clearly decomposed into stimulus- and decision-related components (significant jPESC clusters are shown; $P < 0.05$, cluster-based permutation test, corrected for multiple comparisons). We can also see different types of time lag. For example, between midbrain and frontal cortex (bottom row), the shared stimulus-related component is lagged (occurring earlier in midbrain than in frontal cortex); by contrast, the decision-related component emerged in parallel between them (directional arrows indicate significant time delay, whereas bidirectional arrows indicate non time delay; $P<0.05$; see Supplementary Material for details of the statistical inference). We confirmed that marginalizing both of the source and target regions provides similar results (see Supplementary Figure 3). This underscores the unique contribution of dSCA in allowing us to observe when and what types of information is shared across different brain areas.
\begin{figure}
\centering
\includegraphics[width=\linewidth]{fig3.pdf}
\caption{\textbf{DSCA reveals strong double-dissociation of information sharing between two task parameters that are not apparent by CCA.} \textbf{a} Schematic of mice turning a wheel to indicate which of two visual gratings had higher contrast. \textbf{b} Schematic of task sequence. We focus on the time-window of -300 – 100 ms after decision (movement onset). \textbf{c} Results obtained from CCA. Directional arrows indicate significant time lag, whereas bidirectional arrows indicate no significant time lag. \textbf{d} Results obtained from dSCA for sensory inputs (1st column), movement direction (2nd column), sensory inputs that controlled movement direction (3rd column), and movement direction that controlled sensory inputs (4th column). n.s. corresponds to no significant cluster.}
\end{figure}
\paragraph{Economic decision making}
Finally, we applied dSCA to recordings from a macaque monkey performing an attention-guided information search and economic choice task. The data used here were previously published in Hunt et al. (2018) \citep{Hunt2018}. On each trial, a monkey made an instructed saccade toward a highlighted location to reveal a picture cue. The cue indicated to the monkey either the probability or magnitude of reward that would be available from a subsequent choice towards that spatial location. After 300ms of uninterrupted fixation, cue 1 was covered, and another cue location was highlighted. Full details of the information search and choice structure of the task can be found in Hunt et al. (2018) \citep{Hunt2018}; here, we only focus on the time when cue 1 was first attended to.
The authors recorded from three prefrontal cortex (PFC) subregions (anterior cingulate cortex [ACC], orbitofrontal cortex [OFC], and dorsolateral prefrontal cortex [DLPFC]), and analyzed each area separately in their original paper. The authors previously analysed these data only within-region, and capitalized on neuronal heterogeneity to assessing population-level encoding of cue value and spatial location, amongst other variables. Although they found a strong dissociation between the three PFC subregions in the degree of population encoding, all subregions had some encoding of both value and space. We therefore sought to use dSCA to identify how value and space information was shared between the three subregions, timelocked to the presentation of the stimulus.
As with the previous analyses, we first applied CCA to the combinations of ACC, OFC and DLPFC. We preprocessed the dataset exactly the same way as the original study. Note that, unlike the dataset published in Steinmetz et al. (2019), we performed the analysis on ‘pseudopopulations’ because not all neurons were simultaneously recorded (see Supplementary Material). Figure 4c applies standard jPECC to the data, and shows that all pairs of PFC subregions shared information after cue 1 onset (significant clusters are shown; $P < 0.05$, cluster-based permutation test, corrected for multiple comparisons). However, again, these results cannot tell us what type of information is being shared.
To obtain demixed results, we next applied dSCA to these pairs of PFC subregions. We focused on two main task parameters in the task: space and attended-value. Space is defined as the direction of cue 1 (Left Option or Right Option). Attended-value is defined as the magnitude (value or probability) of cue 1 (1, 2, 3, 4 or 5). As spatial position and value are orthogonal by task design, there is no need to regress these out of the data prior to marginalisation as in Figure 3.
Figure 4d shows that, again, the jPESC with dSCA captures several characteristics that are not apparent from the jPECC with CCA. Between ACC and DLPFC, value- and space-related shared components was strongly dissociated after cue 1 onset ($P<0.05$, corrected for multiple comparisons, cluster-based permutation test, only significant clusters are shown; see Supplementary Material for details); between ACC and OFC, we can see the strongest value-related shared components among all combinations, whereas no space-related shared components emerged; space-related components in ACC/OFC just after stimulus onset were sustained in DLPFC, whereas value-related computation emerged relatively in parallel later ($P<0.05$; see Supplementary Material for details). We confirmed that marginalizing both of the source and target regions provides similar results (see Supplementary Figure 3).
\begin{figure}
\centering
\includegraphics[width=\linewidth]{fig4.pdf}
\caption{\textbf{dSCA reveals that value-related information is strongly shared between OFC-ACC, emerging simultaneously across both subregions, whereas space-related information is shared between DLPFC and the other regions with a time lag.} \textbf{a} Schematic of task. Monkey chose between a left and right option (dotted rectangles), after sequentially sampling cues that revealed reward probability and magnitude. Gray squares indicate locations available for sampling. \textbf{b} Schematic of task sequence. We focus on the time-window of -200 – 600 ms after cue 1 onset. \textbf{c} jPECC results obtained from CCA. Directional arrows indicate significant time lag, whereas bidirectional arrows indicate no significant time lag. \textbf{d} jPESC obtained from dSCA for value (left) and space (right). n.s. corresponds to a no significant cluster. }
\end{figure}
In summary, compared to previous methods, dSCA can provide us with insight into how information is shared in terms across brain regions, in terms of a specific task parameter of interest.
\section{Conclusion and discussion}
We proposed dSCA, a new technique for analysing populations of neurons obtained from different brain areas. Unlike previous methods, dSCA decomposes population activities into a few components to find a low-rank approximation that maximizes the information shared by multiple brain areas with a time lag, while also depending on a relevant task parameter. We demonstrated that dSCA can reveal task specific shared components that are overlooked by conventional approaches using simulation and two previously published neuroscience datasets. We believe dSCA will be useful for neuroscientists who will have a large amount of data from different brain areas during complex cognitive experiments.
Our method has several limitations. First, dSCA assumes that task-related communication is linearly represented. It makes dSCA simple and exactly solvable, and a linear method is popular in neuroscience because of its interpretability and less computational demand (see Supplementary Figure 5 for the interpretation of the shared component in the simulation and real datasets). We believe our method is a good starting point for practitioners and methodological exploration. Second, even if we find a significant relationship between two regions via dSCA, this does not guarantee that they are communicating directly because there is always the possibility of a third region sharing information with both source and target regions. Despite this limitation, our method is an important starting point for subsequent interventional studies that more explicitly test task-related communication in a causal manner.
Future research topics include: (i) extending dSCA to deal with more than two brain areas; (ii) investigating the characteristics of components obtained from dSCA at the level of single-trial, for example, what is the behavioural difference between trials in which value-related information is shared between ACC-OFC and trials in which value-related information is not shared between them; and (iii) applying dSCA to human neuroimaging data measured by magnetoencephalography, or electrical potentials measured by electrocorticography.
\section*{Broader Impact}
Although several studies have investigated communication between populations of neurons, task-related communication has been ignored. This is of fundamental importance in neuroscience, and we show that it can be achieved simply by extending the previous method. We believe our methods will be beneficial to the neuroscientists who will investigate interaction among multiple brain areas in terms of specific task parameter of interest.
\begin{ack}
YT was supported by Grants-in-Aid for Scientific Research on Innovative Areas from the JSPS (23118001, 23118002) and Uehara Memorial Foundation. JH was supported by JSPS KAKENHI (18KK0284). LH was supported by a Sir Henry Dale Fellowship from Wellcome and the Royal Society (208789/Z/17/Z).
\end{ack}
| {'timestamp': '2020-10-27T01:39:03', 'yymm': '2006', 'arxiv_id': '2006.10212', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10212'} | arxiv |
\section{Introduction}\label{sec:intro}
\begin{wrapfigure}{R}{.35\textwidth}
\vspace{-5pt}
\includegraphics[width=.35\textwidth]{imgs/fig1viz3.png}
\caption{A manifold ODE solution for a given vector field on the sphere.}
\label{fig:mode}
\vspace{-5pt}
\end{wrapfigure}
\let\thefootnote\relax\footnotetext{* indicates equal contribution}
Deep generative models are a powerful class of neural networks which fit a probability distribution to produce new, unique samples. While latent variable models such as Generative Adversarial Networks (GANs) \cite{Goodfellow2014GenerativeAN} and Variational Autoencoders (VAEs) \cite{Kingma2014AutoEncodingVB} are capable of producing reasonable samples, computing the exact modeled data posterior is fundamentally intractable. By comparison, normalizing flows \cite{Rezende2015VariationalIW} are capable of learning rich and tractable posteriors by transforming a simple probability distribution through a sequence of invertible mappings. Formally, in a normalizing flow, a complex distribution $p(x)$ is transformed to a simple distribution $\pi(z)$ via a diffeomorphism $f$ (i.e. a differentiable bijective map with a differentiable inverse) with probability values given by the change of variables:
\begin{equation*}\label{eqn:logProbUpdate}
\log p(x) = \log \pi(z) - \log \det \abs{\parderiv{f^{-1}}{z}}, \qquad z = f(x).
\end{equation*}
To compute this update efficiently, $f$ must be constrained to allow for fast evaluation of the determinant, which in the absence of additional constraints takes $\mathcal{O}(D^3)$ time (where $D$ is the dimension of $z$). Furthermore, to efficiently generate samples, $f$ must have a computationally cheap inverse. Existing literature increases the expressiveness of such models under these computational constraints and oftentimes parameterizes $f$ with deep neural networks \cite{Germain2015MADEMA, Dinh2017DensityEU, Kingma2018GlowGF, Durkan2019NeuralSF}. An important recent advancement, dubbed the Continuous Normalizing Flow (CNF), constructs $f$ using a Neural Ordinary Differential Equation (ODE) with dynamics $g$ and invokes a continuous change of variables which requires only the trace of the Jacobian of $g$ \cite{Chen2018NeuralOD, Grathwohl2019FFJORDFC}.
Since $f$ is a diffeomorphism, the topologies of the distributions $p$ and $\pi$ must be equivalent. Furthermore, this topology must conform with the underlying latent space, which previous work mostly assumes to be Euclidean. However, topologically nontrivial data often arise in real world examples such as in quantum field theory \cite{Wirnsberger2020TargetedFE}, motion estimation \cite{Feiten2013RigidME}, and protein structure prediction~\cite{Hamelryck2006SamplingRP}.
In order to go beyond topologically trivial Euclidean space, one can model the latent space with a \textit{smooth manifold}. An $n$-dimensional manifold\footnote{All of our manifolds are assumed to be smooth, so we refer to them simply as manifolds.} $\mathcal{M}$ can be thought of as an $n$-dimensional analogue of a surface. Concretely, this is formalized with \textit{charts}, which are smooth bijections $\varphi_x : U_x \to V_x$, where $U_x \subseteq \mathbb{R}^n, x \in V_x \subseteq \mathcal{M}$, that also satisfy a smoothness condition when passing between charts. For charts $\varphi_{x_1}$, $\varphi_{x_2}$ with corresponding $U_{x_1}, V_{x_1}, U_{x_2}, V_{x_2}$, the composed map $\varphi_{x_2}^{-1} \circ \varphi_{x_1} : \varphi_{x_1}^{-1}(V_{x_1} \cap V_{x_2}) \to \varphi_{x_2}^{-1}(V_{x_1} \cap V_{x_2})$ is a diffeomorphism.
Preexisting manifold normalizing flow works (which we present a complete history of in Section \ref{sec:related}) do not generalize to arbitrary manifolds. Furthermore, many examples present constructions extrinsic to the manifold. In this work, we solve these issues by introducing Manifold Continuous Normalizing Flows (MCNFs), a manifold analogue of Continuous Normalizing Flows. Concretely, we:
\begin{enumerate}[label=(\roman*)]
\item introduce Neural Manifold ODEs as a generalization of Neural ODEs (seen in Figure \ref{fig:mode}). We leverage existing literature to provide methods for forward mode integration, and we derive a manifold analogue of the adjoint method \cite{pontryagin1962mathematical} for backward mode gradient computation.
\item develop a dynamic chart method to realize Neural Manifold ODEs in practice. This approach integrates local dynamics in Euclidean space and passes between domains using smooth chart transitions. Because of this, we perform computations efficiently and can accurately compute gradients. Additionally, this allows us to access advanced ODE solvers (without manifold equivalents) and augment the Neural Manifold ODE with existing Neural ODE improvements \cite{Dupont2019AugmentedNO, Grathwohl2019FFJORDFC}.
\item construct Manifold Continuous Normalizing Flows. These flows are constructed by integrating local dynamics to construct diffeomorphisms, meaning that they are theoretically complete over general manifolds. Empirically, we find that our method outperforms existing manifold normalizing flows on their specific domain.
\end{enumerate}
\section{Related Work}\label{sec:related}
In this section we analyze all major preexisting manifold normalizing flows. Previous methods are, in general, hampered by a lack of generality and are burdensomely constructive.
\textbf{Normalizing Flows on Riemannian Manifolds \cite{Gemici2016NormalizingFO}.} The first manifold normalizing flow work constructs examples on Riemannian manifolds by first projecting onto Euclidean space, applying a predefined Euclidean normalizing flow, and projecting back. Although simple, this construction is theoretically flawed since the initial manifold projection requires the manifold to be diffeomorphic to Euclidean space. This is not always the case, since, for example, the existence of antipodal points on a sphere necessarily implies that the sphere is not diffeomorphic to Euclidean space\footnote{This example is generalized by the notion of conjugate points. Most manifolds have conjugate points and those without are topologically equivalent to Euclidean space.}. As a result, the construction only works on a relatively small and topologically trivial subset of manifolds.
Our work overcomes this problem by integrating local dynamics to construct a global diffeomorphism. By doing so, we do not have to relate our entire manifold with some Euclidean space, but rather only well-behaved local neighborhoods. We test against \cite{Gemici2016NormalizingFO} on hyperbolic space, and our results produce a significant improvement.
\textbf{Latent Variable Modeling with Hyperbolic Normalizing Flows \cite{Bose2020LatentVM}.} In a recent manifold normalizing flow paper, the authors propose two normalizing flows on hyperbolic space---a specific Riemannian manifold. These models, which they name the Tangent Coupling (TC) and Wrapped Hyperboloid Coupling (WHC), are not affected by the aforementioned problem since hyperbolic space is diffeomorphic to Euclidean space. However, various shortcomings exist. First, in our experiments we find that the methods do not seem to conclusively outperform \cite{Gemici2016NormalizingFO}. Second, these methods do not generalize to topologically nontrivial manifolds. This means that these flows produce no additional topological complexity and thus the main benefit of manifold normalizing flows is not realized. Third, the WHC construction is not intrinsic to hyperbolic space since it relies on the hyperboloid equation.
Our method, by contrast, is derived from vector fields, which are natural manifold constructs. This not only allows for generality, but also means that our construction respects the manifold geometry. We compare against \cite{Bose2020LatentVM} on hyperbolic space and find that our results produce a substantial improvement.
\textbf{Normalizing Flows on Tori and Spheres \cite{Rezende2020NormalizingFO}.} In another paper, the authors introduce a variety of normalizing flows for tori and spheres. These manifolds are not diffeomorphic to Euclidean space, hence the authors construct explicit global diffeomorphisms. However, their constructions do not generalize and must be intricately designed with manifold topology in mind. In addition, the primary recursive $\mathbb{S}^n$ flow makes use of non-global diffeomorphisms to the cylinder, so densities are not defined everywhere. The secondary exponential map-based $\mathbb{S}^n$ flow is globally defined but is not computationally tractable for higher dimensions.
In comparison, our work is general, requires only local diffeomorphisms, produces globally defined densities, and is tractable for higher dimensions. We test against \cite{Rezende2020NormalizingFO} on the sphere and attain markedly better results.
\textbf{Other Related Work.} In \cite{Falorsi2019ReparameterizingDO}, the authors define a probability distribution on Lie Groups, a special type of manifold, and as a by-product construct a normalizing flow. The constructed flow is very similar to that found in \cite{Gemici2016NormalizingFO}, but the authors include a $\tanh$ nonlinearity at the end of the Euclidean flow to constrain the input space and guarantee that the map back to the manifold is injective. We do not compare directly against this work since Lie Groups are not general (the $2$-dimensional sphere is not a Lie Group \cite{Stillwell2008NaiveLT}) while Riemannian manifolds are.
There are some related works such as \cite{Wirnsberger2020TargetedFE, Wang2019RiemannianNF, Brehmer2020FlowsFS} that are orthogonal to our considerations as they either (i) develop applications as opposed to theory or (ii) utilize normalizing flows as a tool to study Riemannian metrics.
Concurrent work \cite{mathieu2020Riemannian,Falorsi2020NeuralOD} also investigates the extension of neural ODEs to smoooth manifolds.
\section{Background}
In this section, we present background knowledge to establish naming conventions and intuitively illustrate the constructions used for our work. For a more detailed overview, we recommend consulting a text such as \cite{lee1997riemannian, lee2003introduction, do1992riemannian}.
\subsection{Differential Geometry}
\textbf{Tangent space.} For an $n$-dimensional manifold $\mathcal{M}$, the \textit{tangent space} $T_x\mathcal{M}$ at a point $x \in \mathcal{M}$ is a higher-dimensional analogue of a tangent plane at a point on a surface. It is an $n$-dimensional real vector space for all points $x \in \mathcal{M}$.
For our purposes, tangent spaces will play two roles. First, they provide a notion of derivation which is crucial in defining manifold ODEs. Second, they will oftentimes be used in place of $\mathbb{R}^n$ for our charts (as we map $U_x$ to some open subset of $T_x\mathcal{M}$ through a change of basis from $\mathbb{R}^n \to T_x\mathcal{M}$).
\textbf{Pushforward/Differential.} A derivative (or a \textit{pushforward}) of a function $f : \mathcal{M} \to \mathcal{N}$ between two manifolds is denoted by $D_xf : T_x\mathcal{M} \to T_x\mathcal{N}$. This is a generalization of the classical Euclidean Jacobian (as $\mathbb{R}^n$ is a manifold), and provides a way to relate tangent spaces at different points.
As one might expect, the pushforward is central in the definition of manifold ODEs (analogous to the importance of the common derivative in Euclidean ODEs). We also use it in our dynamic chart method to map tangent vectors of the manifold to tangent vectors of Euclidean space.
\subsection{Riemannian Geometry}
While the above theory is general, to concretize some computational aspects (e.g. how to pick charts) and give background on related manifold normalizing flow work, we define relevant concepts from Riemannian geometry.
\textbf{Riemannian Manifold.} The fundamental object of study in Riemannian geometry is the \textit{Riemannian manifold}. This is a manifold with an additional structure called the \textit{Riemannian metric}, which is a smooth metric $\rho_x : T_x\mathcal{M} \times T_x\mathcal{M} \to \mathbb{R}$ (often denoted as $\inn{\cdot, \cdot}_\rho$). This Riemannian metric allows us to construct a distance on the manifold $d_{\rho} : \mathcal{M} \times \mathcal{M} \to \mathbb{R}$. Furthermore, any manifold can be given a Riemannian metric.
\textbf{Exponential Map.} The \textit{exponential map} $\exp_x : T_x\mathcal{M} \to \mathcal{M}$ can be thought of as taking a vector $v \in T_x\mathcal{M}$ and following the general direction (on the manifold) such that the distance traveled is the length of the tangent vector. Specifically, the distance on the manifold matches the induced tangent space norm $d_\rho(x, \exp_x(v)) = \norm{v}_\rho := \sqrt{\inn{v, v}_\rho}$. Note that $\exp_x(0) = x$.
The exponential map is crucial in our construction since it acts as a chart. Specifically, if we identify the chart domain with $T_x\mathcal{M}$ then $\exp_x$ is a diffeomorphism when restricted to some local set around~$0$.
\textbf{Special Cases.} Some special cases of Riemannian manifolds include hyperbolic spaces $\mathbb{H}^n = \{x \in \mathbb{R}^{n+1} : -x_1^2 + \sum_{i=2}^{n+1} x_i^2 = -1, \; x_1 > 0\}$, spheres ${\mathbb{S}^n = \{x \in \mathbb{R}^{n+1} : \sum^{n+1}_{i=1} x_i^2 = 1\}}$, and tori $\mathbb{T}^n = (\mathbb{S}^1)^n$. Specific formulas for Riemannian computations are given in Appendix~\ref{appendix:normalizingFlows}. Hyperbolic space is diffeomorphic to Euclidean space, but spheres and tori are not.
\subsection{Manifold Ordinary Differential Equations}
\textbf{Manifold ODE.} Finally, we introduce the key objects of study: manifold ordinary differential equations. A manifold ODE is an equation which relates a curve $\mathbf{z} : [t_s, t_e] \to \mathcal{M}$ to a vector field $f$ and takes the form
\begin{equation}\label{eqn:manifoldOde}
\frac{d\mathbf{z}(t)}{dt} = f(\mathbf{z}(t), t) \in T_{\mathbf{z}(t)} \mathcal{M} \qquad \mathbf{z}(t_s) = z_s
\end{equation}
$\mathbf{z}$ is a \textit{solution} to the ODE if it satisfies Equation \ref{eqn:manifoldOde} with initial condition $z_s$. Similarly to the case of classical ODEs, local solutions are guaranteed to exist under sufficient conditions on $f$ \cite{Hairer2011manifold}.
\section{Neural Manifold Ordinary Differential Equations}
To leverage manifold ODEs in a deep learning framework similar to Neural ODEs \cite{Chen2018NeuralOD}, we parameterize the dynamics $f$ by a neural network with parameters $\theta$. We define both forward pass and backward pass gradient computation strategies in this framework. Unlike Neural ODEs, forward and backward computations do not perfectly mirror each other since forward mode computation requires explicit manifold methods, while the backward can be defined solely through an ODE in Euclidean space.
\subsection{Forward Mode Integration}\label{sec:forward}
The first step in defining our Neural Manifold ODE block is the forward mode integration. We review and select appropriate solvers from the literature; for a more thorough introduction we recommend consulting a text such as \cite{Crouch1993NumericalMODE, Hairer2011manifold}. Broadly speaking, these solvers can be classified into two groups:
\begin{enumerate}[label=(\roman*)]
\item \textit{projection methods} that embed the manifold into Euclidean space $\mathbb{R}^d$, integrate with some base Euclidean solver, and project to the manifold after each step. Projection methods require additional manifold structure; in particular, $\mathcal{M}$ must be the level set of some smooth function $g: \mathbb{R}^d \to \mathbb{R}$.
\item \textit{implicit methods} that solve the manifold ODE locally using charts. These methods only require manifold-implicit constructions.
\end{enumerate}
Projection methods are conceptually simple, but ultimately suffer from generality issues. In particular, for manifolds such as the open ball or the upper half-space, there is no principled way to project off-manifold points back on. Furthermore, even in nominally well-defined cases such as the sphere, there may still exist points such as the origin for which the projection is not well-defined.
Implicit methods, by contrast, can be applied to any manifold and do not require a level set representation. Thus, this approach is more amenable to our generality concerns (especially since we wish to work with, for example, hyperbolic space). However, difficulty in defining charts restricts applicability. Due to this reason, implicit schemes often employ additional structure to define manifold variations of step-based solvers \cite{BieleckiRiemannianNormal, Crouch1993NumericalMODE}. For example, on a Riemannian manifold one can define a variant of an Euler Method solver with update step $z_{t + \epsilon} = \exp_{z_t}(\epsilon f(z_t, t))$ using the Riemannian exponential map. On a Lie group, there are more advanced Runge-Kutta solvers that use the Lie Exponential map and coordinate frames \cite{Crouch1993NumericalMODE, Hairer2011manifold}.
\subsection{Backward Mode Adjoint Gradient Computation}\label{sec:backward}
In order to fully incorporate manifold ODEs into the deep learning framework, we must also efficiently compute gradients. Similar to \cite{Chen2018NeuralOD}, we develop an adjoint method to analytically calculate the derivative of a manifold ODE instead of directly differentiating through the solver. Similar to manifold adjoint methods for partial differential equations, we use an ambient space \cite{Zahr2016AFD}.
\begin{thm}\label{thm:manifoldAdjoint}
Suppose we have some manifold ODE as given in Equation \ref{eqn:manifoldOde} and we define some loss function $L: \mathcal{M} \to \mathbb{R}$. Suppose that there is an embedding of $\mathcal{M}$ in some Euclidean space $\mathbb{R}^d$ and we identify $T_x\mathcal{M}$ with an $n$-dimensional subspace of $\mathbb{R}^d$. If we define the adjoint state to be $\mathbf{a}(t) = D_{\mathbf{z}(t)} L$, then the adjoint satisfies
\begin{equation}\label{eqn:manifoldAdjoint}
\frac{d\mathbf{a}(t)}{dt} = - \mathbf{a}(t) D_{\mathbf{z}(t)}f(\mathbf{z}(t), t)
\end{equation}
\end{thm}
\begin{remark}
This theorem resembles the adjoint method in \cite{Chen2018NeuralOD} precisely because of our ambient space condition. In particular, our curve $\mathbf{z}: [t_s, t_e] \to \mathcal{M}$ can be considered as a curve in the ambient space. Furthermore, we do not lose any generality since such an embedding always exists by the Whitney Embedding Theorem \cite{Whitney1935Differentiable}, if we simply set $d = 2n$.
\end{remark}
The full proof of Theorem \ref{thm:manifoldAdjoint} can be found in Appendix \ref{thm:manifoldAdjointAppendix}. Through this adjoint state, gradients can be derived for other parameters in the equation such as $t_s, t_e$, initial condition $z_s$, and weights $\theta$.
\begin{figure}[htb!]
\centering
\includegraphics[width=0.8\textwidth]{imgs/chart3.pdf}
\caption{Solving a manifold ODE with our dynamic chart method. We use $3$ charts.}
\label{fig:dynamicChart}
\end{figure}
\section{Dynamic Chart Method}\label{sec:trivialization}
While our above theory is fully expressive and general, in this section we address certain computational issues and augment applicability with our \textit{dynamic chart method}.
\begin{algorithm}[t]
\SetAlgoLined
Given $f$, local charts $\varphi_x$, starting condition $z_s$ and starting/ending times of $t_s, t_e$.\\
Initialize $z \leftarrow z_s$, $\tau \leftarrow t_s$\\
\While{$\tau < t_e$}{
Construct an equivalent differential equation $\frac{d\mathbf{y}(t)}{dt} = D_{\varphi_z(\mathbf{y}(t))} \varphi_z^{-1} \circ f(\varphi_z(\mathbf{y}(t)), t)$ with initial condition $\mathbf{y}(\tau) = \varphi_z^{-1}(z)$\\
Solve $\mathbf{y}$ locally using some numerical integration technique in Euclidean space. Specifically, solve in some interval $[\tau, \tau + \epsilon]$ for which $\mathbf{z}([\tau, \tau + \epsilon]) \subseteq \mathrm{im} \varphi_z$.\\
$z \leftarrow \varphi_z(\mathbf{y}(\tau + \epsilon)), \tau \leftarrow \tau + \epsilon$
}
\caption{Dynamic Chart Forward Pass}
\label{alg:implicitNumerical}
\end{algorithm}
The motivation for our dynamic chart method comes from \cite{LezcanoCasado2019TrivializationsFG}, where the author introduces a \textit{dynamic manifold trivialization} technique for Riemannian gradient descent. Here, instead of applying the traditional Riemannian gradient update $z_{t + 1} = \exp_{z_t}(-\eta\nabla_{z_t} f)$ for $N$ time steps, the author repeatedly applies $n \ll N$ local updates. Each update consists of a local diffeomorphism to Euclidean space, $n$~equivalent Euclidean gradient updates, and a map back to the manifold. This allows us to lower the number of expensive exponential map calls and invoke existing Euclidean gradient optimizers such as Adam \cite{Kingma2014adam}. This is similar in spirit to \cite{Gemici2016NormalizingFO}, but crucially only relies on local diffeomorphisms rather than a global diffeomorphism.
We can adopt this strategy in our Neural Manifold ODE. Specifically, we develop a generalization of the dynamic manifold trivialization for the manifold ODE forward pass. In a similar spirit, we use a local chart to map to Euclidean space, solve an equivalent Euclidean ODE locally, and project back to the manifold using the chart. The full forward pass is given by Algorithm \ref{alg:implicitNumerical} and is visualized Figure~\ref{fig:dynamicChart}.
We present two propositions which highlight that this algorithm is guaranteed to converge to the manifold ODE solution. The first shows that $\varphi_z(\mathbf{y})$ solves the manifold differential equation locally and the second shows that we can pick a finite collection of charts such that we can integrate to time~$t_e$.
\begin{prop}[Correctness]
If $\mathbf{y}(t) : [\tau,\tau+\epsilon] \to \mathbb{R}^n$ is a solution to $\frac{d\mathbf{y}(t)}{dt} = D_{\varphi_{z}(\mathbf{y}(t))} \varphi_{z}^{-1} \circ f(\varphi_{z}(\mathbf{y}(t)), t)$ with initial condition $\mathbf{y}(\tau) = \varphi_{z}^{-1}(z)$, then $\mathbf{z}(t) = \varphi_{z}(\mathbf{y}(t))$ is a valid solution to Equation \ref{eqn:manifoldOde} on $[\tau,\tau+\epsilon]$.
\end{prop}
\begin{prop}[Convergence]
There exists a finite collection of charts $\{\varphi_i\}_{i = 1}^k$ s.t. $\mathbf{z}([t_s, t_e]) \subseteq \displaystyle\bigcup_{i = 1}^k \mathrm{im} \varphi_i$.
\end{prop}
Proofs of these propositions are given in Appendix~\ref{appendix:trivialization}. Note that this forward integration is implicit, indicating the connections between \cite{hairer2010solving, Hairer2011manifold} and \cite{LezcanoCasado2019TrivializationsFG}. We realize this construction by finding a principled way to pick charts and incorporate this method into neural networks by developing a backward gradient computation.
We can intuitively visualize this dynamic chart forward pass as a sequence of $k$ Neural ODE solvers $\{\mathrm{ODE}_i\}_{i \in [k]}$ with chart transitions $\varphi_{i_2}^{-1} \circ \varphi_{i_1}$ connecting them. Here, we see how the smooth chart transition property comes into play, as passing between charts is the necessary step in constructing a global solution. In addition, this construction provides a \textit{chart-based backpropagation}. Under this dynamic chart forward pass, we can view a Neural Manifold ODE block as the following composition of Neural ODE blocks and chart transitions:
\begin{equation}\label{eqn:MODEComposition}
\mathrm{MODE} = \varphi_k \circ \mathrm{ODE}_k \circ (\varphi_k^{-1} \circ \varphi_{k - 1}) \circ \dots \circ (\varphi_2^{-1} \circ \varphi_1) \circ \mathrm{ODE}_1 \circ \varphi_1^{-1}
\end{equation}
This allows for gradient computation through backpropagation. We may differentiate through the Neural ODE blocks by the Euclidean adjoint method \cite{pontryagin1962mathematical,Chen2018NeuralOD}.
To finalize this method, we give a strategy for picking these charts for Riemannian manifolds\footnote{Note that we do not lose generality since all manifolds can be given a Riemannian metric.}. As previously mentioned, the exponential map serves as a local diffeomorphism from the tangent space (which can be identified with $\mathbb{R}^n$) and the manifold, so it acts as a chart. Similar to \cite{Falorsi2019ReparameterizingDO}, at each point there exists a radius $r_x$ such that $\exp_x$ is a diffeomorphism when restricted to $B_{r_x} := \{v \in T_x\mathcal{M} : \norm{v}_\rho < r_x\}$. With this information, we can solve the equivalent ODE with solution $\mathbf{y}$ until we reach a point $y > (1 - \epsilon) \norm{r_x}_\rho$, at which point we switch to the exponential map chart defined around $\exp_x(y)$. Complete details are provided in Appendix~\ref{appendix:dynamicChart}.
Our dynamic chart method is a significant advancement over previous implicit methods since we can easily construct charts as we integrate. Furthermore, it provides many practical improvements over vanilla Neural Manifold ODEs. Specifically, we
\begin{enumerate}[label=(\roman*)]
\item \textit{can perform faster evaluations.} The aforementioned single step algorithms rely on repeated use of the Lie and Riemannian exponential maps. These are expensive to compute and our method can sidestep this expensive evaluation. In particular, the cost is shifted to the derivative of the chart, but by defining dynamics $g$ on the tangent space directly, we can avoid this computation. We use this for our hyperbolic space construction, where we simply solve $\frac{d\mathbf{y}(t)}{dt} = g(\mathbf{y}(t), t)$.
\item \textit{avoid catastrophic gradient instability.} If the dimension of $\mathcal{M}$ is less than the dimension of the ambient space, then the tangent spaces are of measure $0$. This means that the induced error from the ODE solver will cause our gradients to leave their domain, resulting in a catastrophic failure. However, since the errors in Neural ODE blocks do not cause the gradient to leave their domain and as our charts induce only a precision error, our dynamic chart method avoids this trap.
\item \textit{access a wider array of ODE advancements.} While substantial work has been done for manifold ODE solvers, the vast majority of cutting edge ODE solvers are still restricted to Euclidean space. Our dynamic chart method can make full use of these advanced solvers in the Neural ODE blocks. Additionally, Neural ODE improvements such as \cite{Dupont2019AugmentedNO, Jia2019Neural} can be directly integrated without additional manifold constructions.
\end{enumerate}
\section{Manifold Continuous Normalizing Flows}
With our dynamic chart Neural Manifold ODE, we can construct a Manifold Continuous Normalizing Flow (MCNF). The value can be integrated directly through the ODE, so all that needs to be given is the change in log probability. Here, we can invoke continuous change of variables \cite{Chen2018NeuralOD} on the Neural ODE block and can use the smooth chart transition property (which guarantees that the charts are diffeomorphisms) to calculate the final change in probability as:
\begin{align}\label{eqn:mcnflog}
\log p(\mathrm{MODE}) = \log \pi &-\sum_{i = 1}^k \paren{\log\det |D \varphi_i| + \log \det |D \varphi_i^{-1}| + \int \mathrm{tr}(D \varphi_i^{-1} \circ f)}
\end{align}
Note that we drop derivative and integration arguments for brevity. A full expression is given in Appendix~\ref{appendix:normalizingFlows}.
For our purposes, the last required computation is the determinant of the $D_v\exp_x$. We find that these can be evaluated analytically, as shown in the cases of the hyperboloid and sphere \cite{Nagano2019AWN, Skopek2019MixedcurvatureVA}.
Since the MCNF requires only the local dynamics (which are in practice parameterized by the exponential map), this means that the construction \textit{generalizes to arbitrary manifolds}. Furthermore, we \textit{avoid diffeomorphism issues}, such as in the case of two antipodal points on the sphere, simply by restricting our chart domains to never include these conjugate points.
\begin{wrapfigure}{R}{0.6\textwidth}
\vspace{-20pt}
\newcommand{\scriptsize}{\scriptsize}
\centering
\begin{tabular}{cccc}
\scriptsize{Target} & \scriptsize{WHC \cite{Bose2020LatentVM}} & \scriptsize{PRNVP \cite{Gemici2016NormalizingFO}} & \scriptsize{MCNF (Ours)}\\
\midrule[1pt]
\includegraphics[width=0.09\textwidth]{imgs/true_1wrapped.png} &
\includegraphics[width=0.09\textwidth]{imgs/density_WrappedRealNVP_1wrapped.png} &
\includegraphics[width=0.09\textwidth]{imgs/density_AllTangentRealNVP_1wrapped.png} &
\includegraphics[width=0.09\textwidth]{imgs/1wrapped.png}\\
\includegraphics[width=0.09\textwidth]{imgs/true_5gaussians.png} &
\includegraphics[width=0.09\textwidth]{imgs/density_WrappedRealNVP_5gaussians.png} &
\includegraphics[width=0.09\textwidth]{imgs/fixed_AllTangentRealNVP_5gaussians.png} &
\includegraphics[width=0.09\textwidth]{imgs/5gaussians.png} \\
\includegraphics[width=0.09\textwidth]{imgs/true_bigcheckerboard.png} &
\includegraphics[width=0.09\textwidth]{imgs/density_WrappedRealNVP_bigcheckerboard.png} &
\includegraphics[width=0.09\textwidth]{imgs/fixed_AllTangentRealNVP_bigcheckerboard.png} &
\includegraphics[width=0.09\textwidth]{imgs/bigcheckerboard.png} \\
\includegraphics[width=0.09\textwidth]{imgs/true_mult_wrapped.png} &
\includegraphics[width=0.09\textwidth]{imgs/density_WrappedRealNVP_mult_wrapped.png} &
\includegraphics[width=0.09\textwidth]{imgs/density_AllTangentRealNVP_mult_wrapped.png} &
\includegraphics[width=0.09\textwidth]{imgs/mult_wrapped.png}
\end{tabular}
\caption{Density estimation on the hyperboloid $\mathbb{H}^2$, which is projected to the Poincar\'e Ball for visualization.}
\label{fig:hyperbolicDensity}
\begin{tabular}{ccc}
\scriptsize{Target} & \scriptsize{NCPS \cite{Rezende2020NormalizingFO}} & \scriptsize{MCNF (Ours)} \\
\midrule[1pt]
\includegraphics[width=0.14\textwidth]{imgs/true_sphere_1wrapped.png} &
\includegraphics[width=0.14\textwidth]{imgs/rezende_1wrapped.png} &
\includegraphics[width=0.14\textwidth]{imgs/sphere_1wrapped.png} \\
\includegraphics[width=0.14\textwidth]{imgs/true_mult_wrapped5.png} &
\includegraphics[width=0.14\textwidth]{imgs/rezende_mult_wrapped5.png} &
\includegraphics[width=0.14\textwidth]{imgs/good_mult_wrapped5.png} \\
\includegraphics[width=0.14\textwidth]{imgs/true_sphere_bigcheckerboard.png} &
\includegraphics[width=0.14\textwidth]{imgs/rezende_bigcheckerboard.png} &
\includegraphics[width=0.14\textwidth]{imgs/sphere_bigcheckerboard.png} \\
\end{tabular}
\caption{Density estimation on the sphere $\mathbb{S}^2$, which is projected to two dimensions by the Mollweide projection.}
\label{fig:sphereDensity}
\vspace{-25pt}
\end{wrapfigure}
\section{Experiments}
To test our MCNF models, we run density estimation and variational inference experiments. Though our method is general, we take $\mathcal{M}$ to be two spaces of particular interest: hyperbolic space $\mathbb H^n$ and the sphere $\mathbb S^n$. Appendix~\ref{appendix:normalizingFlows} concretely details the computation of MCNF in these spaces. Full experimental details can be found in Appendix~\ref{appendix:trainingDetails}.
\subsection{Density Estimation}\label{subsec:DensityEstimation}
We train normalizing flows for estimation of densities in the hyperbolic space $\mathbb H^2$ and the sphere $\mathbb S^2$, as these spaces induce efficient computations and are easy to visualize. For hyperbolic space, the baselines are Wrapped Hyperboloid Coupling (WHC) \cite{Bose2020LatentVM} and Projected NVP (PRNVP), which learns RealNVP over the projection of the hyperboloid to Euclidean space \cite{Gemici2016NormalizingFO,Dinh2017DensityEU}. On the sphere, we compare with the recursive construction of \cite{Rezende2020NormalizingFO}, with non-compact projection used for the $\mathbb S^1$ flow (NCPS). As visualized in Figures~\ref{fig:hyperbolicDensity} and \ref{fig:sphereDensity}, our normalizing flows are able to match complex target densities with significant improvement over the baselines. MCNF is even able to fit discontinuous and multi-modal target densities; baseline methods cannot fit these cases as they struggle with reducing probability mass in areas of low target density.
\subsection{Variational Inference}
We train a hyperbolic VAE \cite{Mathieu2019HierarchicalRW} and Euclidean VAE \cite{Kingma2014AutoEncodingVB} for variational inference on Binarized Omniglot \cite{Lake2015Human} and Binarized MNIST \cite{Lecun98gradient-basedlearning}. Both of these datasets have been found to empirically benefit from hyperbolic embeddings in prior work \cite{Nagano2019AWN,Mathieu2019HierarchicalRW,Bose2020LatentVM,Khrulkov2019HyperbolicIE,Skopek2019MixedcurvatureVA}. We compare different flow layers in the latent space of the VAEs. For the Euclidean VAE, we compare with RealNVP \cite{Dinh2017DensityEU} and CNF \cite{Chen2018NeuralOD,Grathwohl2019FFJORDFC}. Along with the two hyperbolic baselines used for density estimation, we also compare against the Tangent Coupling (TC) model in \cite{Bose2020LatentVM}. As shown in Table~\ref{tbl:TestLL}, our continuous flow regime is more expressive and learns better than all hyperbolic baselines. In low dimensions, along with the other hyperbolic models, our approach tends to outperform Euclidean models on Omniglot and MNIST. However, in high dimension the hyperbolic models do not reap as much benefit; even the baseline HVAE does not consistently outperform the Euclidean VAE.
\begin{table}[t]
\caption{MNIST and Omniglot average negative test log likelihood (lower is better) and standard deviation over five trials for varying dimensions.}
\label{tbl:TestLL}
\centering
\scriptsize
\begin{tabular}{clllllll}
\cmidrule[\heavyrulewidth]{2-8}
& & \multicolumn{3}{c}{MNIST} & \multicolumn{3}{c}{Omniglot} \\
\cmidrule(lr){3-5} \cmidrule(lr){6-8}
& & \multicolumn{1}{c}{2} & \multicolumn{1}{c}{4} & \multicolumn{1}{c} {6} & \multicolumn{1}{c}{2} & \multicolumn{1}{c}{4} & \multicolumn{1}{c}{6} \\
\cmidrule[\heavyrulewidth]{2-8}
\addlinespace[3pt]
\multirow{3}{*}{\rotatebox[origin=c]{90}{Euclidean}} & VAE\cite{Kingma2014AutoEncodingVB} & $143.06\pm .3$ & $117.57 \pm .5$ & $102.13 \pm .2$ & $154.31 \pm .5$ & $143.37 \pm .2$ & $138.65 \pm .1$ \\
& RealNVP \cite{Dinh2017DensityEU} & $142.09 \pm .7$ & $116.32 \pm .7$ & $100.95 \pm .1$ & $153.93\pm .5$ & $142.98 \pm .3$ & $\mathbf{137.21} \pm .1$ \\
& CNF \cite{Grathwohl2019FFJORDFC} & $141.16 \pm .4$ & $116.28 \pm .5$& $100.64 \pm .1$ & $154.05 \pm .2$ & $143.11 \pm .4$ & $137.32 \pm .7$ \\
\addlinespace[3pt]
\cmidrule[.3pt]{2-8}
\addlinespace[3pt]
\multirow{4}{*}{\rotatebox[origin=c]{90}{Hyperbolic}} & HVAE\cite{Mathieu2019HierarchicalRW} & $140.04\pm .9$ & $114.81 \pm .8$ & $100.45 \pm .2$ & $153.97 \pm .3$ & $144.10 \pm .8$ & $138.02 \pm .3$ \\
& TC \cite{Bose2020LatentVM} & $139.58 \pm .4$ & $114.16 \pm .6$ & $100.45 \pm .2$ & $157.11 \pm 2.7$ & $143.05 \pm .5$ & $137.49 \pm .1$ \\
& WHC \cite{Bose2020LatentVM} & $140.46 \pm 1.3$ & $113.78 \pm .3$ & $100.23 \pm .1$ & $158.08 \pm 1.0$ & $143.23 \pm .6$ & $137.64 \pm .1$ \\
& PRNVP \cite{Gemici2016NormalizingFO} & $140.43 \pm 1.8$ & $113.93 \pm .3$ & $100.06 \pm .1$ & $156.71 \pm 1.7$ & $143.00 \pm .3$ & $137.57 \pm .1$ \\
& MCNF (ours) & $\mathbf{138.14} \pm .5$ & $\mathbf{113.47} \tiny{\pm .3}$ & $\mathbf{99.89} \pm .1$ & $\mathbf{152.98}\pm .1$ & $142.99 \pm .3$ & $137.29 \pm .1$ \\
\addlinespace[3pt]
\cmidrule[\heavyrulewidth]{2-8}
\end{tabular}
\end{table}
\vspace{-5pt}
\section{Conclusion}
\vspace{-5pt}
We have presented Neural Manifold ODEs, which allow for the construction of continuous time manifold neural networks. In particular, we introduce the relevant theory for defining ``pure'' Neural Manifold ODEs and augment it with our dynamic chart method. This resolves numerical and computational cost issues while allowing for better integration with modern Neural ODE theory. With this framework of continuous manifold dynamics, we develop Manifold Continuous Normalizing Flows. Empirical evaluation of our flows shows that they outperform existing manifold normalizing flow baselines on density estimation and variational inference tasks. Most importantly, our method is completely general as it does not require anything beyond local manifold structure.
We hope that our work paves the way for future development of manifold-based deep learning. In particular, we anticipate that our general framework will lead to other continuous generalizations of manifold neural networks. Furthermore, we expect to see application of our Manifold Continuous Normalizing Flows for topologically nontrivial data in lattice quantum field theory, motion estimation, and protein structure prediction.
\section{Broader Impact}
As mentioned in the introduction, our method has applications to physics, robotics, and biology. While there are ethical and social concerns with parts of these fields, our work is too theoretical for us to say for sure what the final impact will be. For deep generative models, there are overarching concerns with generating fake data for malicious use (e.g. deepfake impersonations). However, our work is more concerned with accurately modelling data topology rather than generating hyper-realistic vision or audio samples, so we do not expect there to be any negative consequence in this area.
\section{Acknowledgements}
We would like to acknowledge Prof. Austin Benson and Junteng Jia for their insightful comments and suggestions. In addition, we would like to thank Facebook AI for funding equipment that made this work possible. We would also like to thank Joey Bose for providing access to his prerelease code.
| {'timestamp': '2020-06-19T02:08:02', 'yymm': '2006', 'arxiv_id': '2006.10254', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10254'} | arxiv |
\section{Introduction}
\IEEEPARstart{N}{owadays}, modern network attacks are accomplished with advanced automatic tools. One of them used in the post-penetration procedure is the RAT. RAT is essentially a type of software providing convenience for adversaries to complete post-penetration. Typical functions of RAT include process monitor, command execute, keyboard logger, file transfer and others. After break into the victim machine, adversies rely on the sophisticated tool for further steps. Hence, there is a need to specify the malicious activities of RAT to cut off the whole kill chain and prevent potential losses. In the early stage of the RAT development, signature-based methods can accurately detect malicious network activities with distinctive string patterns.
However, since traffic encryption is widely used in different malware including RAT to acquire longer life cycles, the traditional network detection method is greatly challenged.
To tackle the problem brought by encryption technology, novel detection approaches are proposed. Generally, the art methods can be distributed into two main categories according to the detection technology.
1) Statistical-based \cite{xie2019method, gezer2019flow, wu2019session, li2019method, stergiopoulos2019using, lashkari2017towards, wang2019mobile,kim2019intrusion, huang2018scalable}, which relies on the machine learning or deep learning to learn the classification boundary among different traffic types. It follows the procedure that first produces traffic features like bytes count or interval gap means of packets, and then applies models to train and predict based on the distilled information.
2) Signature-based \cite{papadogiannaki2018otter, trimananda2019pingpong}, which relies on abstract behaviors of the encrypted traffic used as identification signatures. It first formulates distinctive elements of the traffic as the signature set, and then check if the monitored traffic implies any appointed signature.
In recent years, the computer security community mainly follows the first technical route to utilize the powerful learning ability of machine learning models to tackle the problem. However, this approach is not perfect.
First and most important, statistical models perform unstable in different environments. The learning strategy of most machine learning models requires not only malicious traffic but also benign traffic in training procedure \cite{li2018machine}. Since the benign applications vary in different environments, the model will be confused by the unknown application network traces not appeared in the training procedure; thus the trained model will perform unstable when transferred into a different environment.
Second, the method also requires sufficient labeled instances in the training procedure. To meet this requirement, a large amount of data should be collected in advance, which dramatically increases the inconvenience of applying the method in a real environment. Considering the shortage of statistical-based approaches, hence, we focus on signature-based routine. Compared to the former technic, the signature-based approaches can achieve robust performance through different environments and thus more reliable in a real application. Besides, the signature-based approach requires only a few malicious network traces, which can release the tedious work of data gathering.
\subsection{Problems}
Traditional signatures, like string patterns, can hardly adapt to encryption context because the payload is unknown during data transmission. Motivated by the observation that applications usually follow a fixed-code procedure to initiate or respond to requests, the snippets of \emph{directed packet payload size (DirPiz)} sequence of a flow in arbitary position is used by several arts as fingerprints to identify encrypted behaviors \cite{trimananda2019pingpong, papadogiannaki2018otter}.
However, these proposed methods are not able to detect RAT in an accurate manner.
On one hand, false positives can occur due to the Dirpiz conflicts. Potentially, the snippets of flow-level DirPiz sequences generated from a benign application can be the same as that from RATs, thereby causing false alarms. In another word, only flow-level DirPiz snippets are not precise enough as malicious signatures.
On the other hand, false negatives can occur because the DirPiz varies slightly from different environments due to \emph{dynamically generated packets}. Generally, the size of packets carrying the instruction which asks the trapped machine to report the base information is the same, yet the size of corresponding callback packets is different. Unfortunately, existing arts can not properly handle the dynamic packets because all of them rely on the exact matching mechanism of the regex engine.
\subsection{Our Work}
In this paper, we present \emph{Malicious traces Behavior Tree (MBTree)}, a novel signature-based approach for robust and accurate encrypted C\&C identification based on network behavior.
First, MBTree creates signatures to depict malicious behaviors by integrating flow-level DirPiz sequences as a synthesis of host-level \emph{Multi-Level Tree (MLTree)} to improve the unique degree of malicious descriptions. In such a way, approximately 94\% false alarms triggered by only a few coincidences DirPiz can be reduced.
Second, MBTree relies on a flexible similarity-based matching mechanism expanding the coverage of each signature to facilitate robust detection. The proposed mechanism can cover reasonable deviations from the generated signatures. Besides, the alarm level of the detection can be adjusted by a predefined threshold.
To demonstrate the effectiveness of our approach, we conduct solid experiments on several datasets. These datasets are reorganized in a sophisticated manner to simulate the situation that the test set contains \emph{unknown applications} in a real environment. To acquire stable results, we also integrate the 5-fold cross-validation strategy. The experiment results show that MBTree yields a more accurate performance than machine learning state-of-the-arts on the test sets. Individually, MBTree can achieve approximately 94\% F1-score on validation set, and 91\% F1-score on test set. Moreover, we also analyze the influence of different hyperparameters of them by tuning them and inspect the malicious behaviors by reviewing generated MLTree signatures.
\subsection{Contributions}
In summary, this paper makes the following contributions:
\begin{itemize}
\item First, a sharp network behavior representation method, MLTree, is proposed as the
enhancement signature. It helps to reduce the probability of DirPiz conflicts by integrating multiple related flow-level DirPiz sequences; thus, it can depict encrypted malicious network traces in a more accurate and robust manner.
\item Second, a corresponding detection mechanism based on the similarity comparison of MLTree is proposed. This strategy enhances the flexibility of detection by covering deviations slightly different from generated signatures. Compared to the exact matching strategy, it can handle the dynamic packets properly; thus, more robust detection can be achieved.
\item Third, we demonstrate the effectiveness of our approach from both theoretical and experimental aspects. From theoretical perspective, we illustrate that it is in an extremely low probability that MBTree would misclassify different applications. From experimental perspective, persuasive experiments are conducted on different datasets to evaluate the real performance.
\end{itemize}
The remainder of this paper is structured as follows. Section II summarizes related works and their limitations. Section III gives an overview of the design of MBTree. Section IV elaborates the details of MLTree. Section V describes the similarity matching mechanism. Section VI provides the theoretical analysis of MBTree.
Section VII covers the experiment setup description. Section VIII reports the experiment evaluation results and analysis. Section IX discusses potential evading strategies to attack MBTree. And section X provides the conclusion.
\begin{table*}
\centering
\footnotesize
\caption{Comparison of different signature-based methods.}
\label{tab_sig_compare}
\begin{tabular}{c|ccccccc}
\hline
\textbf{Method} & \begin{tabular}[c]{@{}c@{}}\textbf{ Signature}\\\textbf{~Generation} \end{tabular} & \begin{tabular}[c]{@{}c@{}}\textbf{Main Element }\\\textbf{of Signature} \end{tabular} & \textbf{Level} & \textbf{Type} & \textbf{Scene} & \begin{tabular}[c]{@{}c@{}}\textbf{Encrypted }\\\textbf{Detection} \end{tabular} & \begin{tabular}[c]{@{}c@{}}\textbf{Detection }\\\textbf{Engine} \end{tabular} \\
\hline
Snort & Manual & String Pattern & packet/flow & Exact & IDS & No & Self \\
Suricata & Manual & String Pattern & packet/flow & Exact & IDS & No & Self \\
Zeek(Bro) & Manual & String Pattern & packet/flow & Exact & IDS & No & Self \\
& Automatic & String Pattern & packet/flow & Exact & Malware & No & Snort \\
& Semi-Automatic & String Pattern & flow & Exact & Malware & No & Snort \\
OTTer & Automatic & Packet Length & flow & Exact & Application & Yes & Self \\
PingPong & Automatic & Packet Length & packet pair & Exact & IOT Application & Yes & Self \\
\emph{\underline{MBTree}} & \emph{\underline{Automatic}} & \emph{\underline{Packet Length}} & \emph{\underline{host}} & \emph{\underline{Similarity}} & \emph{\underline{Malware}} & \emph{\underline{Yes}} & \emph{\underline{Self}} \\
\hline
\end{tabular}
\end{table*}
\begin{figure*}[htb]
\centering
\centerline{\includegraphics[width = 0.83\linewidth]{Fig_overview_usenix.pdf}}
\caption{High-level overview of MBTree}
\label{fig_overview}
\end{figure*}
\section{Related Work} \label{sec:relatedwork}
MBTree makes contributions to the problem of encryption RAT C\&C traffic detection. A central idea behind MBTree is adopting the MLTree as signatures. Below, we discuss related works in the above areas from two perspectives.
\subsection{Statistical-based}
In recent decades, statistical-based methods for RAT traffic detection have been widely studied \cite{xie2019method, gezer2019flow, wu2019session, li2019method, stergiopoulos2019using, lashkari2017towards, wang2019mobile,kim2019intrusion, huang2018scalable, alshammari2011can, sun2010novel, draper2016characterization, casino2019hedge, shen2017classification, kwon2016catching}. Generally, most of these methods follow such procedures that first extract features from the traffic, and then using statistical models to fit the data.
Recently, \cite{gezer2019flow, stergiopoulos2018automatic, stergiopoulos2019using, kim2019intrusion} use side-channel information with Random Forest (RF) for encrypted malicious traffic detection. Specifically, these side-channel features range from packet length, packet interval time to payload ratio. The experiment results have shown the effectiveness of this combination of side-channel features and machine learning models.
Besides, advanced deep learning models are also adopted in this area \cite{li2019method, xie2019method, aceto2019mimetic, lotfollahi2020deep, aceto2019mobile, dong2020cetanalytics}. Compared with traditional machine learning models, these models do not require the feature extraction procedure. The sophisticated models can automatically extract related features, and achieve end-to-end classification. For example,
\cite{li2019method} proposes a deep learning method to detect HTTP malicious traffic on mobile networks.
\cite{xie2019method} proposes a sophisticated deep learning architecture to detect trojans with hierarchy spatiotemporal features.
Generally, these traditional machine learning methods and advanced deep learning methods can achieve high performance in their experiments. However, they can hardly adapt to the situation of unseen applications beyond the training set due to the inconsistent statistical distribution. Moreover, they both lack the interpretability to trace back the cause of alarms for further response.
\subsection{Signature-based}
Different from statistical-based methods, signature-based methods rely on previously defined elements of the traffic, mainly on specific content string patterns. Generally, most of them first create a signature set and then determine if the testing instances match one or more signatures in the set.
Compared with machine learning methods, signature-based methods are more robust among different environments; thus, it is still applied in multiple security products, ranging from intrusion detection systems (IDS) to firewalls \cite{d2019survey}.
Despite the advance, there exist two apparent limitations of traditional signature methods. First, most methods require manual work to produce high-quality signatures even though given the cleaned malicious traffic. This manual work is tedious for security analysts. Second, traditional signatures like specific strings are seriously challenged by encrypted traffic \cite{roesch1999snort,paxson1999bro,suricata}. Because the string patterns are invalid to ciphertext.
Several studies focus on the automatic generation of network signatures to tackle the first problem \cite{newsome2005polygraph, perdisci2010behavioral, tegeler2012botfinder, shim2017sigbox}. For example,
\cite{newsome2005polygraph} propose three automatically generated signatures ranging from conjunction signatures, token-subsequence signatures to Bayes signatures for polymorphic worm detection with traffic payload.
\cite{perdisci2010behavioral} uses clustered malicious traces to produce network-level signatures from HTTP fields automatically. These network-level signatures are translated in a format compatible with Snort rules and can be used for detection.
Apart from only focusing on the first problem, recent studies focus on tackling both problems by introducing novel behavior patterns. Instead of using specific strings as signatures, these novel methods use other aspect information to identify specific behaviors, like packet size sequence. For example, \cite{papadogiannaki2018otter} propose an encrypted traffic pattern language based on \emph{packet payload size sequence} for scalable Over-The-Top (OTT) applications identification. They show that this signature is unique to identify applications or even application events.
Similarly, \cite{trimananda2019pingpong} proposes a method based on packet length pairs to identify specific events of home IoT devices. To achieve the fine-grained event-level traffic detection, \cite{trimananda2019pingpong} adopt the DBSCAN algorithm to search frequent conversation pairs, and then concatenate the pairs into sequences as signatures.
Even though previous studies present the effectiveness of novel network signatures, they still lack the ability to detect encrypted RAT in an accurate and robust manner. This can be attributed to the inaccurate signature building and inflexible matching mechanism. Since several RATs can establish different connections to evade the detection \cite{antonakakis2017understanding, lever2017lustrum}, only flow-level fingerprints can hardly cover the whole picture of the encryption RAT behaviors. Besides, although the exact matching strategy can cooperate with the finite state machine to improve efficiency, it lacks the flexibility to capture similar behaviors among different environments. To clearly show the path of research in this direction, we summarize the differences of each method in \autoref{tab_sig_compare}.
\section{MBTree Overview}
\begin{figure*}[htb]
\centerline{\includegraphics[width=0.73\linewidth]{Fig_total_MLTree.pdf}}
\caption{A brief example shows the simplified DirPiz sequences of each session with setting $L$ as 4. The training set contains the malicious traffic generated from Quasar. The testing set contains the mixed traffic generated from Quasar and WhatsApp. Positive numbers denote the packet sent from the client, while negative numbers denote the packet sent from the server.
}
\label{Fig_total_MLTree}
\end{figure*}
In this section, we provide an overview of the proposed MBTree system. As shown in \autoref{fig_overview}, our approach consists of two main procedures, \emph{host behavior formulation} and \emph{detection}. First, the raw traffic is formulated to MLTree representing host-level behaviors in three steps. 1). The preprocessing achieves traffic cleaning and session reassembling. 2). The DirPiz sequences from each session as multiple independent fingerprints. 3). The sequences are correlated based on common hosts to construct MLTree as the host behavior. It is worth mentioning that malicious signatures and testing instances are produced following the same steps in this procedure.
Second, the converted testing instances are compared to each signature to decide if they match any malicious behaviors in two steps. 1). The similarity between the testing instance and each signature is calculated to produce a similarity vector. 2) whether the instance belongs to malicious is predicted based on the similarity vector.
To show the workflow clearly, we also provide a simplified example throughout the following sections to describe the key design of MBTree. The example uses a part of pure Quasar traffic as malicious traffic, and a part of mixed Quasar traffic and WhatsApp traffic as testing traffic, as shown in \autoref{Fig_total_MLTree}.
\section{Host Behavior Formulation}
In this section, we describe the details of the formulation procedure from raw traffic to the host-level signature MLTree. \autoref{sec:preprocessing} introduces the cleaning and session reassemble strategy, \autoref{sec:dirpizextraction} shows our consideration of DirPiz extraction, and \autoref{sec:mltreeconstruction} provides the definition of MLTree and corresponding construction process.
\subsection{Preprocessing} \label{sec:preprocessing}
Raw traffic is usually captured in pcap or pcapng format recording a lot of communication details. Extra meta information should be removed before building the signature. Hence, we first apply traffic cleaning to discard invalid packets, then we apply session reassembling to recover the whole communication.
\textbf{Cleaning;}
Traffic cleaning aims at filtering out redundant information in raw traffic. As the requirements of cleaned traffic for signature and testing instance formulation are different, we apply different strategies for the two sets. For the training set, we apply a `whitelist' strategy to only reserve the packets containing C\&C IPs. For other traffic in the malicious communication, we just discard them. Thus, only ensured communications between the victim and C\&C are selected to produce valid signatures. For the testing set, we apply a `blacklist' strategy to only discard packets that meet the following conditions, repeated packets, loop packets, non-transmission packets. With this strategy, we can reserve the main information of testing traffic and avoid potential malicious packets bypassing.
\textbf{Session reassembling;} After cleaned, the traffic is reassembled into sessions to recover all end-to-end communication. In this procedure, we mainly identify a transmission session based on 5-tuple. The 5-tuple includes source IP, destination IP, source port, destination port, and protocol. Besides, for TCP protocol, the flag fields representing the communication status are also used to identify different sessions using the same 5-tuple.
\subsection{DirPiz Sequence Extraction}\label{sec:dirpizextraction}
Given a reassembled session, we extract the DirPiz sequence of the session to fingerprint the automated procedure.
As a matter of fact, multiple types of meta-information of the packet can be extracted as fingerprints, such as packet gap intervals, and packet payload hash. However, they either lack stable performance in different network environments or do not adapt to variable encrypted content because of the dynamic encryption key negotiation mechanism. As a result, we choose the DirPiz as the meta information for its robust performance.
Typically, a DirPiz sequence consists of the payload size of each packet with the direction in a connection. The direction means that the packet is either request from the client to the server or a response from the server to the client. Here we provide an example of extracted DirPiz sequences in Fig. 2(a). The Quasar traffic is used as a training set. While the mixed traffic of Quasar and WhatsApp is used as a testing set.
Then we provide the specific procedures to produce a DirPiz sequence.
First, different IP packets are reassembled if the packet is fragmented. Since the communication content can be scattered in multiple IP packets due to the limitation of MTU or potential IP fragment attack, reassembling these fragmented IP packets can restore the real payload in a communication.
Second, based on these reassembled IP packets, the payload sizes are counted according to the upper-level protocols to form a sequence. In this step, the influence of low-level protocol details can be reduced, e.g., TCP handshake or SSL/TLS negotiation. Different strategies are applied according to different protocols. For UDP protocol, the length of the transport payload is used directly. For TCP protocol, only the length of the transport payload after the connection is established is used. For SSL/TLS protocol, only the length of the payload in the 'Application Data' packet is used.
Third, we append the direction sign to the elements of payload size sequences. The request information from a client to the server is formulated as a positive number, and the response information from a server to the client is formulated as a negative number.
Fourth, all sequences are aligned to the same length to keep consistent.
Only \emph{$L$ DirPiz} are reserved in the sequence. Besides, for sequences less than $L$ in length, 0 is used as padding value. For example, Fig.~2(a) shows the extracted DirPiz sequences with setting $L$ as four.
\subsection{MLTree Construction}\label{sec:mltreeconstruction}
\begin{algorithm}[h]
\caption{MLTree Initialization}
\label{alg_mltree_construct}
\begin{algorithmic}[1]
\REQUIRE DirPiz Sequence Set $P$, Max Level $L$
\ENSURE MLTree $T$
\STATE Let $T = (N, E, C_N, C_E)$
\STATE Let $N=\varnothing, E=\varnothing,C_N=\varnothing,C_E=\varnothing$
\FORALL{level ${l} \in L$}
\STATE $N^l = \varnothing, C_N^l=\varnothing, E^l=\varnothing, E_N^l=\varnothing$
\FORALL{DirPiz sequence ${p} \in P$}
\STATE $N^l = N^l \cup \{p[l]\}$, $C_N^l[p[l]] +=1$
\IF {$l$ eq 0}
\STATE $e=(0, p[l]), E^l = E^l \cup \{e\}$, $C_E^l[e]+=1$
\ELSE
\STATE $e=(p[l-1], p[l]), E^l = E^l \cup \{e\}, C_E^l[e]+=1$
\ENDIF
\ENDFOR
\STATE Append $N^l, C_N^l, E^l, C_E^l$ to $N,C,C_N,C_E$
\ENDFOR
\RETURN T
\end{algorithmic}
\end{algorithm}
In this section, we integrate multiple diverse DirPiz sequences into MLTree as the host signature.
Corresponde to head sequences and tail sequences, two MLTrees are used to represent the host signature, specifically, a head MLTree and a tail MLTree.
As a central structure of our approach, MLTree is defined as follows,
\begin{definition}
\textbf{MLTree} MLTree $T$ is a Weighted Directed Acyclic Graph (WDAG), $T = (N, E, C_N, C_E)$, where $N, E, C_N, C_E$ represent the node set, edge set, node weight set, edge weight set respectively. The node set $N$ is used to represent unique DirPiz grouped by level. The statistical set $C_N$ is used to record the aggregated occurrence of each unique DirPiz organized in level. The edge set $E$ is used to represent two co-occurrence DirPiz grouped by two adjacent levels. The statistical set $C_E$ is used to record the co-occurrences of each two adjacent DirPiz.
With different to normal WDAG, MLTree is organized in hierarchy structure, every weighted node $n_i^l$ and weighted edge $e_i^l$ belongs to a specific level sub-set, $n_i^l \in N^l, e_i^l \in E^l$. And all these level sub-sets $N^l, E^l, C_N^l, C_E^l$ consist of the corresponding elements, $N=\{N^l\}_{l=0..L},E=\{E^l\}_{l=0..L},C_N=\{C_N^l\}_{l=0..L},C_E=\{C_E^l\}_{l=0..L}$.
\end{definition}
\begin{algorithm}[h]
\caption{MLTree Merging}
\label{alg_mltree_merge}
\begin{algorithmic}[1]
\REQUIRE MLTree Set $M$
\ENSURE Merged MLTree $T$
\STATE Let $T = (N, E, C_N, C_E)$
\STATE Let $N=\varnothing, E=\varnothing,C_N=\varnothing,C_E=\varnothing$
\FORALL{level ${l} \in L$}
\STATE $N^l = \varnothing, C_N^l=\varnothing, E^l=\varnothing, E_N^l=\varnothing$
\FORALL{MLTree ${m} \in M$}
\STATE $N^l = N^l \cup m.N^l, E^l= E^l \cup m.E^l$
\FORALL{node $n \in N^l$, edge $e \in E^l$}
\STATE $C_N^l[n] += m.C_N^l[n]$, $C_E^l[e] += m.C_E^l[e]$
\ENDFOR
\ENDFOR
\STATE Append $N^l, C_N^l, E^l, C_E^l$ to $N,C,C_N,C_E$
\ENDFOR
\RETURN T
\end{algorithmic}
\end{algorithm}
The specific MLTree construction process is as follows.
First, the DirPiz sequences are processed level by level as the initial MLTree. In each level of processing, the unique nodes, edges, and their corresponding statistics are specified. The specific initialization schema is shown in \autoref{alg_mltree_construct}.
Second, merging operations are taken to enhance the coverage as well as reduce the storage cost of repeated patterns. The specific merging algorithm is shown in \autoref{alg_mltree_merge}. Intuitively, it contains \emph{polluting risk} when integrating a large number of individual MLTrees into a huge MLTree. Because the DirPiz coverage of the large tree will increase dramatically resulting in high-level false alarms. We divide this kind of situation into two categories for discussion. 1) All initial MLTrees are from the same RAT. In this situation, all these individual MLTrees denote similar DirPiz coverage, thus they can be merged without worrying about polluting risk. 2) Initial MLTrees are from different RAT. In this situation, there is a high polluting risk in merging these individual MLTrees because their DirPiz coverage is different.
To avoid this, we limit the merging operation to integrate the DirPiz sequences generated from the same malicious sample. Thus, similar behaviors can be merged regardless of the number of DirPiz sequences, and the scale of the tree can be limited to a proper extent.
Example MLTrees built from Fig.~2(a). is shown in Fig~2(b). It is apparent that MLTree is hierarchically organized.
Briefly, MLTree provides several advantages to depict malicious behaviors.
First, MLTree ensures flexible merging to represent signatures efficiently. In our design, different MLTrees derived from the same malicious sample can be merged into a single MLTree. This feature can enhance the signature update ability as well as reduce the cost of storing repeated signatures.
Second, the hierarchy design can represent the host behavior in an intuitive and reasonable manner. Since the frequent DirPiz is with a higher probability of being generated automatically, the automated handshake behavior can be quantified by differentiating between frequent DirPizs and infrequent DirPizs hierarchically.
Third, MLTree can be automatically constructed given the cleaned malicious traffic. Both the MLTree construction and merging can be completed with a systematic script. In such a manner, the construction requires no interactions with security experts and prior knowledge. Hence the labor costs can be reduced.
\section {Detection}
Unlike traditional signature-based detection, our detection relies on similarity matching strategy instead of exact matching strategy to decide if the testing instance should be regarded as malicious.
Brief steps of detection are as follows. First, the similarity vector of the testing instance and each signature is calculated as $v_{m} = [s_0, s_1, ..., s_n]$. The element in the vector represents the similarity score of the testing instance and the corresponding signature. The specific similarity score calculation method is elaborated in \autoref{sec:similaritycalculation}. Second, we make a prediction based on the similarity vector to decide if the testing instance contains malicious behavior. The details of this step are shown in \autoref{sec:prediction}.
\begin{figure*}[h]
\centerline{\includegraphics[width=0.65\linewidth]{Fig_total_similarity.pdf}}
\caption{ CWP and Common Nodes of corresponding MLTrees in Fig.~2(b).}
\label{Fig_total_similarity}
\end{figure*}
\subsection{Similarity Calculation} \label{sec:similaritycalculation}
The first step towards malicious prediction is to produce the similarity vector of the testing instance with pre-produced MLTree signatures. In this step, the core is to calculate the similarity of two MLTrees. Roughly, the MLTree similarity is measured from two aspects, \emph{path similarity} and \emph{node similarity}. The path similarity measures the similarity of continuous edges in corresponding hierarchies, while the node similarity measures the similarity of nodes in corresponding hierarchies.
Specifically, a similarity score $S$ of the testing instance and a signature is formulated as
\begin{equation}
\label{eq1}
S = \beta [\alpha S_{fp} + (1-\alpha) S_{fn}] + (1-\beta)[\alpha S_{lp} + (1-\alpha) S_{ln}]
\end{equation}
where $S_{fp}$ and $S_{fn}$ represent the path similarity and the node similarity of corresponding head MLTree respectively, $S_{lp}$ and $S_{ln}$ represent the path similarity and the node similarity of corresponding tail MLTree respectively, $\alpha$ represents the path score ratio parameter that determines the balance of the path score and node score, and $\beta$ represents the head ratio parameter that determines the balance of the head score and tail score. In addition, special DirPiz that appear frequently in both benign and malicious MLTrees can be removed in calculating the similarity score. Thus, identical DirPizs can have a more important influence in similarity calculation.
\subsubsection{Path Similarity}
Path similarity is used to measure the common continuous paths of two MLTrees. Towards achieving this measurement, we first define \emph{common weighted path (CWP)} as follows,
\begin{definition}
\textbf{Common Weighted Path}
Given two MLTrees $bt = \{N_{t}, E_{t}, C_{Nt}, C_{Et}\}$, $bm = \{N_{m}, E_{m}, C_{Nm}, C_{Em}\}$, a CWP $P_C$ is defined as the intersection of continuous weighted edges of two MBTrees. Specifically, $P_C = \{E_C, C_{Ec}\}$, the edge set $E_I$ is the continuous intersection of the two edge sets $E_t$ and $E_m$. This means $ \forall 1 < l < L$, if $(n_i^l, n_j^{l+1}) \in E_I^l$, then $(n_i^l, n_j^{l+1}) \in (E_{t} \cap E_{m})$, and there exists at least one edge $(n_p^{l-1}, n_i^l)$ that $(n_p^{l-1}, n_i^l) \in E_I^{l-1}$. Besides, the statistics set $C_{Ec}$ based on $E_C$ is also the intersection of the two statistics sets according to different levels.
\end{definition}
Generally, CWP aims at capturing the common successive sequential information of two MLTrees. Thus, it is used as the middleware to measure the continuous similarity.
The algorithm to generate CWP of two MLTrees is shown in ~\autoref{alg_mbtree_merge}.
\begin{algorithm}[h]
\caption{CWP Generation}
\label{alg_mbtree_merge}
\begin{algorithmic}[1]
\REQUIRE Testing MLTree $bt = \{N_t, E_t, C_{Nt}, C_{Et}\}$, and signature MLTree $bm = \{N_m, E_m, C_{Nm}, C_{Em}\}$, Max Level $L$.
\ENSURE Common weighted path $P_C$
\STATE Let $P_c = \{E_c=\varnothing, C_{Ec}=\varnothing\}$
\FORALL{level ${l} \in L$}
\IF{$l$ is not 0 and $E_c^{l-1}$ is $\varnothing$}
\RETURN $P_c$
\ENDIF
\STATE Let $E_c^l=\varnothing, C_{Ec}^l=\varnothing, N_{tmp}^l =N_t^l \cap N_m^l$
\IF {$l$ is not 0}
\STATE $E_c^l$ = $E_t^l \cap E_m^l \cap (N_{tmp}^l \times N_{tmp}^{l-1})$
\ELSE
\STATE $E_c^l$ = $E_t^l \cap E_m^l$
\ENDIF
\FORALL{edge ${e} \in E_c^l$}
\STATE $C_{Ec}^l = C_{Em}^l[e] $
\ENDFOR
\ENDFOR
\RETURN $P_c$
\end{algorithmic}
\end{algorithm}
Then we provide several observations of CWP.
1) Edge statistics of CWP can reflect the similar level of two MLTrees.
2) Range of edge statistics at the same level in different CWP is inconsistent, because the testing instance may contain the traffic generated from a different period than signature traffic.
3) Range of edge statistics at different levels in CWP is inconsistent because the edge statistics are generated independently.
4) It is of low probability to produce a long CWP between two unrelated MLTree. As a matter of fact, two unrelated MLTree may contain the same DirPiz at a level; however, they can hardly contain the same edges or even continuous edges through different levels. Thus, a long CWP can indicate a higher level of similarity than a short CWP.
Next, we synthesize the observations of CWP and provide several considerations to design the formula for path similarity.
1) A higher similarity score should indicate more similar the two MLTrees are. To achieve this, we design a weighted product mechanism to ensure that the score increases monotonically with the increase of the number of edges and levels.
2) Edge statistics should be normalized to be used as a base factor of the score. Specifically, we use the edge statistics of signatures at the corresponding level to normalize that of testing instance; thus, the impact of the difference among levels can be eliminated. Besides, we also introduce a time ratio to balance the period difference between the testing instance and the signature.
3) Hierarchy level can be used as a weight factor for edge statistics. To leverage the continuous property of CWP, we assign different weights to statistics at different levels. Thus a longer CWP can correspond to higher similarity.
4) the statistics should be normalized to reduce the influence of different time lengths. %
Based on these considerations, we tried several schemes and performed experiments on a small training set. Finally, we found the best result is achieved by the formula as follows,
\begin{equation}
\label{eq_path_simi}
{{\rm{S}}_p} = {{\rm{2}}^{L' + \sum\limits_{l = 1}^{L'} {[\frac{{F(E_C^l,C_{Em}^l)}}{{F(E_m^l,C_{Em}^l)}} \times \frac{{{l^2}}}{{L'}} \times {R_t}]} }}
\end{equation}
where $L'$ denotes the max level of CWP, ${l^2 \over L'}$ denotes the \emph{level important factor}, the ${\frac{{F(E_C^l,C_{Ec}^l)}}{{F(E_m^l,C_{Em}^l)}}}$ denotes the \emph{normalized level path similarity factor}, $F(a,b)$ represents \emph{counting the total occurrence of all elements of $a$ in set $b$}, $R_t={\frac{{T_m}}{{T_t}}}$ denotes \emph{the time ratio for normalization}, the $T_m$ represents the capturing time of the signature traffic and the $T_t$ represents the capturing time of the testing traffic. It is worth to mention that we add level $L'$ in exponential part as an score normalization factor to differentiate the minum value with different max level $L$.
\subsubsection{Node Similarity}
Node similarity is used to measure the common nodes of two MLTrees in corresponding hierarchies. As preliminary, we define the \emph{Common Nodes} as follows,
\begin{definition}
\textbf{Common Nodes}
The common nodes $N_I$ are defined as the intersection nodes and their corresponding minimal occurrence at each level, formally, $ I_N = \{N_I, C_{NI}\}, \forall l < L \to N_I^l \subseteq (N_t^l \cap N_m^l), C_{NI}^l \subseteq (C_{Nt}^l \cap C_{Nm}^l)$.
\end{definition}
Totally, the node similarity is calculated based on the \emph{common nodes}.
Unlike CWP, common nodes are generated independently through different levels.
Thus, the nodes are treated equally to contribute to the diverse similarity of two MLTrees.
Specifically, correspond to produce path similarity, the formula to calculate node similarity is as follows,
\begin{equation}
\label{eq_node_simi}
{S_n} = {2^{L + \sum\limits_{l = 1}^L {[\frac{{F({N^l},C_N^l)}}{{F(N_m^l,C_{Nm}^l)}} \times {R_t}]} }}
\end{equation}
where $L$ denotes the max level of Common Nodes, ${\frac{{F({N^l},C_N^l)}}{{F(N_m^l,C_{Nm}^l)}}}$ denotes the \emph{normalized level node similarity factor}.
Here we provide the consideration to introduce the node similarity. Unlike the path similarity measurement used to accurately depict the malicious behavior, the node similarity is considered to facilitate robust detection ability.
Although the path similarity can precisely measure a similar path, it is not flexible enough to capture rough similar patterns, especially the dynamic packets. Generally, dynamic packets also exist in the handshake procedure with automated packets, like the inspection results of the victim machine transferred by the RAT client to the server. These dynamic packets can truncate the CWP for their random DirPiz. Hence, we propose the node similarity as a supplementary to path similarity to handle the dynamic packets problem.
Following the example in previous section, we provide CWP and Common Nodes of former MLTree instances in \autoref{Fig_total_similarity}. Based on these, the similarity score of the example can be calculated, $S_{fp} = 69.13$, $S_{fn} = 80.63$, $S_{tp} = 34.56$, $S_{tn} = 69.12$, when setting $\alpha = 0.3$, and $\beta = 0.7$, $S = 71.65$.
\subsection{Prediction} \label{sec:prediction}
\begin{figure}
\centerline{\includegraphics[width=1\columnwidth]{Fig_maxlogic.pdf}}
\caption{Prediction logic. $\theta$ is set as 32.}
\label{Fig_maxlogic}
\end{figure}
After similarity calculation, we acquire the similarity vector $v_m$ denoting the similarity of the testing instance with each signature.
Hence, we can further predict if the testing instance is malicious based on the max value $S_m$ of the vector $v_m$. First, the $S_{m}$ is specified. Then, if $S_m$ exceeds a predefined threshold $\theta$, the testing instance is regarded as containing malicious behaviors. Otherwise, the testing instance is regarded as benign. \autoref{Fig_maxlogic} shows the prediction logic with setting $\theta$ as 32.
In addition, in the situation that the testing instance is regarded as malicious, the specific type of malicious behavior can also be predicted based on the index of the malicious value $I_m$.
It is worth to mention that the specific encryption RAT type will only be decided when $S_m$ exceeds the threshold $\theta$. Otherwise, it is meaningless to predict the specific RAT type since the traffic is regarded as benign.
\section{Theoretical Analysis}
To demonstrate the effectiveness of our proposed methods, we provide theoretical analysis in this section. First, since the principle of MBTree is based on the uniqueness of the DirPiz sequence, we demonstrate the extremely low probability that two different applications would produce the same DirPiz sequences. Assume that the DirPiz $X$ at a level are random variables, $P(X)$ represent the probability dense function of $X$, and a DirPiz sequence $S$ is consists of several random variable $S^{m} = [X_0, X_1, ..., X_m]$, where $X_0, X_1, ..., X_m$ are independent. Due to the limit of MTU on the Internet, X can be only chosen from [-1500, 1500] in most cases.
According to \cite{castro2013probability} and \cite{mccreary2000trends}, $X$ on the Internet generally obey to the $\beta$ distribution. However, after a small amount of frequent DirPiz are removed, $X$ roughly obey to the uniform distribution. That is \[X \sim U( - 1500,1500).\]
Hence, when give two independent DirPiz sequences $S^{m}$ and $S'^{m}$, the probability of their collision in $n$ levels $P(S_n^{m})$ is $C(m, n) * (3*10^{-3})^n$. Suppose that we take $m$ as 10, the corresponding $P(S_n^{10})$ shown in \autoref{tab_probability}. As can be seen from the table, the probability of $S^{10}$ and $S'^{10}$ being completely the same is only $10^{-26}$ in the case of $m=10$, which is extremely low.
It is worth to mention that, previous studies uses DirPiz snippets at arbitary position rather than corresponding hierarchy to identify application behavior, which increases the collision probability.
\begin{table}[h]
\centering
\caption{The probability of different $n$ collision in two DirPiz sequences.}
\label{tab_probability}
\begin{tabular}{cc|cc}
\hline
$n$ & $P(S_n^{10})$ & $n$ & $P(S_n^{10})$ \\ \hline
1 & $3\times 10 ^ {-2}$ & 6 & $1\times 10 ^ {-13}$ \\
2 & $4\times 10 ^ {-4}$ & 7 & $2\times 10 ^ {-16}$ \\
3 & $3\times 10 ^ {-6}$ & 8 & $3\times 10 ^ {-19}$ \\
4 & $1\times 10 ^ {-8}$ & 9 & $2\times 10 ^ {-22}$ \\
5 & $6\times 10 ^ {-11}$ & 10 & $6\times 10 ^ {-26}$ \\ \hline
\end{tabular}
\end{table}
Second, based on the collision probability, we discuss the theoretical best threshold interval. Generally, the interval is decide based on number of unique applications $N_A$. When $N_A$ is ensured, the tolerable level of collisions should determined to calculate the max threshold $\theta$. Specifically, $\theta = 2^{L+n}$, where n should satisfy the following conditions \[\left\{ \begin{array}{l}
{N_A} \times P(S_n^m) \le {\rm{1}}\\
{\rm{max(n)}}
\end{array}. \right.\] For example, when $N_A =100$, the optimal value of $n$ is 1, and the corresponding threshold should be $2^{L+1}$.
\begin{table*}[]
\centering
\footnotesize
\caption{This table shows the partitioning details in each dataset. The $\bullet$ and $\star$ denotes the OSER traffic generated from Debian and CentOS respectively; $\triangleright$ denotes the WT traffic; $\otimes$ denotes the CTU-13 traffic; $\square$ and $\circ$ denote different applications traffic from the combined set of ISCX VPN2016 and USTC-TFC2016. }
\label{tab_data_partition}
\begin{tabular}{c|c|c|c|c|c|c|c|c|c}
\hline
& \multicolumn{3}{c|}{Dataset I} & \multicolumn{3}{c|}{Dataset II} & \multicolumn{3}{c}{Dataset III} \\ \hline
& Train & Validation & Test & Train & Validation & Test & Train & Validation & Test \\ \hline
Malicious & $\bullet$ & $\bullet$ & $\star$ & $\triangleright$ & $\triangleright$ & $\triangleright$ & $\otimes$ & $\otimes$ & $\otimes$ \\ \hline
Benign & $\square$ & $\square$ & $\circ$ & $\square$ & $\square$ & $\circ$ & $\square$ & $\square$ & $\circ$ \\ \hline
\end{tabular}
\end{table*}
\section{Evaluation Framework}
\subsection{Evaluation Data}
In our experiment, three malicious parts and two benign parts of traffic are used for evaluation. The first malicious part is the open-source RATs traffic collected by ourselves, the second part is the wild Trojan traffic selected from the Stratosphere project \cite{Stratosphere}, and the last part is a public open-source dataset CTU-13 \cite{garcia2014empirical}. While the two parts benign applications traffic used are from two open datasets, ISCX VPN2016 \cite{draper2016characterization} and USTC-TFC2016 \cite{wang2017malware}.
Each part is described below.
\textbf{Open Source Encryption RAT (OSER);} In order to hide the real identity, adopting customized OSER for attack is popular in recent years \cite{fuelRAT, wueest2016increased}. Thus, the open-version RAT traffic is studied in this paper. Based on popularity, stability, and maintenance on Github, 7 OSERs are selected to generate this part of the traffic.
Specifically, in the traffic generation procedure, to evaluate whether a RAT follows the same procedure for communication in different environments, we collect the traffic of two hosts, which install different systems but are infected by the same sample.
The traffic generation mechanism is shown in \autoref{Fig_rat_collect}. Besides, to simulate the practice usage of samples, 5 randomly chosen commands are executed on the comprised machine for each malicious session.
The details of the collected traffic are shown in \autoref{tab_rats} in Appendix.
\textbf{Wild Trojan (WT);} Apart from the OSER traffic, wild trojans (from 2015 to 2018) are also selected from \cite{Stratosphere}. Compared to OSER traffic, the WT traffic contains more number sessions. However, since the communications between the victim and Trojan C\&C are not controlled as detailed as OSER, it may also contain noise traffic generated by the machine automatically. Nevertheless, this part of the traffic is also a fair test to evaluate the WT detection ability of MBTree. More details of this part of the traffic are shown in \autoref{tab_trojans} in Appendix.
\textbf{CTU-13;} The public open-source dataset is widely used in malware traffic detection research \cite{wang2016botnet, ring2019survey}. It contains malicious traffic from 7 different types of Trojans. Apart from C\&C traffic, it also collects attack traffic in other procedures, like distributed denial of service (DDoS) traffic and spam traffic. Hence, this traffic is cleaned to only reserve C\&C traffic according to the dataset description. Due to the lack of valid traces for 5-fold validation, two types of Trojan (Rbot, NSIS.ay) are not used in our experiment. More details of cleaned traffic are shown in \autoref{tab_ctu13} in Appendix.
\textbf{ISCX VPN 2016;} In recent studies, the ISCX VPN2016 is widely used for encrypted traffic classification. In this paper, we also adopt this set as a part of benign traffic to evaluate the false alarm levels.
Totally, the set organizes the 27G raw traffic generated from 17 typical applications in 150 pcap or pcapng files. Compared to former malicious parts, this benign application set is larger.
\textbf{USTC-TFC 2016;} Apart from ISCX VPN2016, we also use the benign part of USTC-TFC2016 as another part of benign traffic, because it contains different applications traffic from the ISCX VPN2016. Actually, this part of traffic consists of both benign and malicious traffic. Since the traffic contained in the malicious part of USTC-TFC2016 is covered by former datasets, they are not taken as malicious parts. Thus, only the benign part of the set is used for evaluation. Totally, the benign part of the USTC-TFC2016 organizes the 3.71GB traffic generated from 10 applications in 14 pcap files.
\begin{figure}
\centerline{\includegraphics[width=0.7\columnwidth]{Fig_traffic_collect.pdf}}
\caption{Traffic collection mechanism.}
\label{Fig_rat_collect}
\end{figure}
\subsection{Data Organization}
We organize the five parts of the collected traffic into three datasets for evaluation. Each dataset consists of malicious traffic and benign traffic. The OSER is used as malicious traffic in dataset I, the WT is used in dataset II, and CTU-13 is used in dataset III. The benign traffic shared by two datasets is the combination of ISCX VPN 2016 and USTC-TFC 2016. Total $N_A$ of these two datasets is around 100.
For persuasive evaluation, we use the 5-fold cross-evaluation strategy to acquire a stable performance. Moreover, in each fold, the dataset is divided into three parts, train, validation, and test. Basically, the three parts in a fold are divided following the ratio of 0.49:0.21:0.3. It is noteworthy that since OSER is generated from two machines, we use the traffic generated from one machine as the train and validation sets respectively, and from the other machine as the test set. Besides, the benign applications that appeared in the train set do not appear in the test set. This partitioning strategy aims at simulating the situation that unknown applications that emerged in the test environment, which scenario is common in reality. The details of partition are shown in \autoref{tab_data_partition}.
\begin{table*}
\centering
\caption{Experiment results. Highlighted values: \textbf{overall best method}, second best method ($\dagger$), third best method ($\ddagger$).}
\label{tab_re}
\begin{tabular}{c|c|cccc|cccc}
\hline
Dataset & Methods & \multicolumn{4}{c|}{Validation} & \multicolumn{4}{c}{Test} \\
\hline
& & FPR & FNR & Acc & F1 & FPR & FNR & Acc & F1 \\
\hline
\multirow{7}{*}{I} & \underline{MBTree} & \underline{0.21±0.21} $\dagger$ & \underline{0.23±0.35} & \underline{99.82±0.23} $\ddagger$ & \underline{99.27±0.12} $\dagger$ & \textbf{\underline{0.1±0.09}} & \underline{1.41±1.55} $\dagger$ & \textbf{\underline{99.59±0.25}} & \textbf{\underline{99.42±0.15}} \\
& CART & 2.49±5.05 & 0.03±0.07 $\dagger$ & 99.56±2.68 & 95.71±11.54 & 26.77±6.99 $\ddagger$ & 1.73±2.1 $\ddagger$ & 74.2±31.43 $\ddagger$ & 66.17±8.43 $\ddagger$ \\
& RF & 24.79±19.45 & 0.08±0.07 $\ddagger$ & 99.36±0.93 & 74.59±20.34 & 33.06±16.54 & 3.2±1.28 & 57.44±21.63 & 57.72±21.94 \\
& GBDT-CIC & 49.25±22.02 & 1.59±3.11 & 79.2±44.25 & 47.37±25.22 & 67.16±13.82 & 3.85±2.2 & 54.02±21.56 & 25.39±11.93 \\
& CNN & \textbf{0.03±0} & \textbf{0.01±0} & \textbf{99.98±0} & \textbf{99.95±0.06} & 70.6±1.14 & 2.4±0.43 & 65.93±7.53 & 30.77±0.79 \\
& SAE & 1.37±2.98 $\ddagger$ & \textbf{0.01±0} & 99.97±0.03 $\dagger$ & 98.57±3.16 $\ddagger$ & 67.85±3.08 & 2.32±0.55 & 68.94±9.44 & 33.65±3.86 \\
& DirPiz-Seq & 18.49±2.29 & 1.45±0.66 & 80.28±9.77 & 83.14±1.95 & 18.1±2.42 $\dagger$ & \textbf{0.99±0.2} & 84.52±3.09 $\dagger$ & 80.66±1.83 $\dagger$ \\
\hline
\multirow{7}{*}{II} & \underline{MBTree} & \underline{\textbf{0.57±1.14}} & \underline{\textbf{0.03±0.05}} & \textbf{\underline{99.96±0.06}} & \underline{92.43±1.33} $\ddagger$ & \underline{\textbf{0.62±1.25}} & \underline{0.84±0.91} $\ddagger$ & \underline{\textbf{99.08±0.94}} & \underline{\textbf{87.71±1.71}} \\
& CART & 6.05±2.18 $\ddagger$ & 0.81±0.26 & 95.72±1.05 & 93.14±1.51 $\dagger$ & 52.66±13.2 & 5.43±2.23 & 68.06±17.96 & 44.17±16.88 \\
& RF & 10.32±13.01 & 1.4±1.5 & 91.62±10.19 & 88.01±17.97 & 38.67±9.98 & 11.77±12.91 & 67.68±13.00 & 51.93±10.99 \\
& GBDT-CIC & 3.56±1.63 $\dagger$ & 0.57±0.51 $\dagger$ & 96.94±0.74 $\dagger$ & \textbf{96.33±1.32} & 38.78±11.82 & 6.49±3.21 & 65.00±15.69 & 52.54±9.44 \\
& CNN & 15.67±1.99 & 0.66±0.33 $\ddagger$ & 95.75±2.16 $\dagger$ & 83.43±2.28 & 19.79±7.08 $\ddagger$ & \textbf{0.58±0.25} & 95.56±1.88 $\dagger$ & 74.4±7.20 $\ddagger$ \\
& SAE & 15.74±2.6 & 0.78±0.51 & 95.16±3.28 & 83.05±3.14 & 19.13±6.78 $\dagger$ & 0.59±0.41 $\dagger$ & 95.46±3.1 $\ddagger$ & 75.71±9.35 $\dagger$ \\
& DirPiz-Seq & 40.27±4.77 & 7.55±1.69 & 58.20±9.39 & 56.33±3.70 & 41.96±5.65 & 7.59±0.41 & 52.84±2.15 & 52.00±2.28 \\
\hline
\multirow{7}{*}{III} & \underline{MBTree} & \textbf{\underline{0.0±0.0}} & \textbf{\underline{0.0±0.0}} & \underline{99.99±0.01} $\dagger$ & \underline{91.11±0.0} & \textbf{\underline{0.0±0.0}} & \underline{0.12±0.13} $\ddagger$ & \underline{\textbf{99.88±0.13}} & \underline{\textbf{86.66±6.67}} \\
& CART & 0.17±0.24 $\dagger$ & 0.22±0.35 $\dagger$ & 99.61±0.27 & 93.59±4.11 & 0.03±0.05 $\dagger$ & 12.29±14.53 & 88.95±13.39 $\dagger$ & 79.58±11.73 $\dagger$ \\
& RF & \textbf{0.0±0.0} & \textbf{0.0±0.0} & 99.92±0.06 & 97.6±0.67 $\ddagger$ & \textbf{0.0±0.0} & 79.42±13.2 & 21.65±12.9 & 65.4±8.2 \\
& GBDT-CIC & \textbf{0.0±0.0} & \textbf{0.0±0.0} & 99.93±0.05 $\ddagger$ & 98.35±1.1 $\dagger$ & 0.03±0.07 $\ddagger$ & 75.82±20.42 & 25.17±20.07 & 66.49±9.1 \\
& CNN & 1.36±2.71 $\ddagger$ & \textbf{0.0±0.0} & 99.2±1.5 & 93.5±7.97 & 82.84±15.09 & 0.01±0.02 $\dagger$ & 81.12±15.04 $\ddagger$ & 70.95±8.02 $\ddagger$ \\
& SAE & \textbf{0.0±0.0} & \textbf{0.0±0.0} & \textbf{100.00±0.0} & \textbf{100.00±0.0} & 87.96±8.12 & \textbf{0.0±0.0} & 72.11±21.1 & 64.46±15.05 \\
& DirPiz-Seq & 20.85±2.27 & 21.6±38.72 $\ddagger$ & 66.69±17.73 & 52.63±8.78 & 14.92±0.31 & 49.0±31.39 & 61.32±5.18 & 54.04±5.8 \\
\hline
\end{tabular}
\end{table*}
\begin{figure*}[h]
\centering
\subfigure[Confusion matrix on Dataset I. ]{
\label{Fig_cnf_rats}
\includegraphics[width=0.25\linewidth]{Fig_cnf_rat.pdf}
}
\subfigure[Confusion matrix on Dataset II.]{
\label{Fig_cnf_malware}
\includegraphics[width=0.27\linewidth]{Fig_cnf_malware.pdf}
}
\subfigure[Confusion matrix on Dataset III. ]{
\label{Fig_cnf_ctu}
\includegraphics[width=0.27\linewidth]{Fig_cnf_ctu.pdf}
}
\caption{Confusion matrices of MBTree test predictions on different datasets. }
\label{Fig_cfx}
\end{figure*}
\subsection{Baselines}
In correspondence to the related studies in \autoref{sec:relatedwork}, six baselines are covered in this paper as comparisons.
The first baseline is a machine learning state-of-the-art \cite{stergiopoulos2018automatic} using side-channel features and CART represented as \emph{CART}.
The second baseline is another machine learning-based state-of-the-art \cite{gezer2019flow} using different features from \cite{stergiopoulos2018automatic} with random forest for Trickbot Trojan detection as \emph{RF}.
The third baseline is the extended features generated by CICFlowmeter \cite{CICFlowmeter} with GradientBoosting implemented by ourselves as \emph{GBDT-CIC}.
The fourth baseline is a deep learning method using one dimensional CNN from \cite{lotfollahi2020deep} as \emph{CNN}.
The fifth baseline is another deep learning method using a stacked autoencoder mechanism as \emph{SAE} \cite{lotfollahi2020deep}.
Besides, we also implement the flow-level similar matching method using the cosine distance and threshold of 0.99 represented as \emph{DirPiz-Seq} to illustrate the advantage of the host-level signatures.
Moreover, we try to compare our method with ping-pong \cite{trimananda2019pingpong}, which is a signature-based state-of-the-art for encrypted IOT traffic event identification. However, we find that ping-pong can hardly extract packet-level signatures of malicious traffic. Because the conversation pairs of packet-level signatures are too diverse to be clustered by the DBSCAN algorithm even though we try to tune corresponding parameters.
\subsection{Tasks \& Metrics}
Based on the aforementioned data, we propose the detection task for experiments. The goal of the task is to distinguish whether the traffic is benign or malicious. Specifically, the malicious traffic is labeled as the specific type when is predicted. While for benign traffic, they are all regarded equally as general benign without further classifying the specific application type.
In addition, we also record the prediction time of each method.
As evaluation, four well-known metrics are adopted: \emph{False Positive Ratio (also known as False Alarms Ration, FPR)}, \emph{False Negative Ratio (FNR)} \cite{shah2018performance}, \emph{Accuracy (Acc)}, and \emph{Macro F1 (F1)}. It should be noted that when calculating FPR and FNR, the multi-class labels are masked to binary labels as only simple malicious or benign. While calculating Acc and F1, the multi-class labels are directly taken into consideration. We believe this mechanism can measure the performance of different models more comprehensively.
\section{Experiments}
In this section, we provide a thorough evaluation of MBTree from five perspectives based on the aforementioned dataset. First, we perform the evaluation on the detection task to show the effectiveness of the proposed MBTree by comparing it to several machine learning-based state-of-the-arts. Second, we provide a case study to clearly show the significance of MBTree. Third, we compare the efficiency of each method. Fourth, we conduct experiments to analyze the influence of the hyperparameters and their corresponding optimal choice. Further, we show the analysis of the generated signatures to reveal the network behavior differences among different samples.
Except for the fourth experiment, the hyperparameters of MBTree are set preliminary as \emph{max level} $L$ of 10, \emph{path similarity ratio} $\alpha$ of 0.3, \emph{head signature ratio} $\beta$ of 0.7, and \emph{threshold} $\theta$ as 2048.
\subsection{Malicious Detection}
In this section, we focus on presenting the overall effectiveness of MBTree. \autoref{tab_re} shows the performance of different approaches on each dataset. And \autoref{Fig_cfx} shows the classification results of MBTree on the test part of different datasets.
First, as a high-level performance comparison, although MBTree is not achieving the best performance on the validation set, it outperforms all the considered elements of contrast in the test set in most metrics. This indicates the robust ability of our proposed signature-based approach. Besides, considering differences in performance on validation and test set, it can be concluded that the signature-based methods perform more stable on different sets, including both MBTree and DirPiz-Seq. From another view, although the statistical distribution of malicious part is consistent in validation and test of dataset II and III, the statistical-based methods also perform quite differently. This illustrates that these statistical-based methods are more susceptible to the change of the environment. Hence, the robust detection ability of signature-based methods through different environments is demonstrated.
Second, It should be noted that the F1 of MBTree on dataset II and III is not reaching the level that on the dataset I. According to \autoref{Fig_cnf_malware} and \autoref{Fig_cnf_ctu}, it can be observed that most of the misclassified instances are false negatives. With a detailed analysis of these instances, we found that they consist of shorter communication sequences, which means there are only one or two valid payloads exchanged between the client and C\&C. Thus, without sufficient evidence, MBTree tends to classify them as benign. An interesting phenomenon is that other metrics are consistent in all datasets, which indicates that though there exist misclassified instances, the number of them is still at a low level. This can be attributed to that the host-level detection reduces the number of instances. Hence, even only a few misclassified instances will lead to a significant change in F1.
Third, it can be noticed that the flow-level DirPiz-Seq performs worse than MBTree. This phenomenon indicates that only utilizing the flow-level communication sequences as signatures is not precise enough. Integrating flow fingerprints to host signatures can improve the performance dramatically.
\begin{figure*}[h]
\centering
\subfigure[Path Score Ratio $\alpha$]{
\label{Fig_alpha}
\includegraphics[width=0.23\linewidth]{Fig_alpha.pdf}
}
\subfigure[Head Score Ratio $\beta$ ]{
\label{Fig_beta}
\includegraphics[width=0.23\linewidth]{Fig_beta.pdf}
}
\subfigure[Max Level $L$ ]{
\label{Fig_maxlevel}
\includegraphics[width=0.33\linewidth]{Fig_maxlevel.pdf}
}
\caption{Different parameter tuning results.}
\label{Fig_tunning}
\end{figure*}
\begin{figure*}[ht!]
\centering
\subfigure[Max Level $L$ = 5]{
\label{Fig_thresholds_5}
\includegraphics[width=0.2\linewidth]{Fig_thresholds_5.pdf}
}
\subfigure[Max Level $L$ = 10 ]{
\label{Fig_thresholds_10}
\includegraphics[width=0.2\linewidth]{Fig_thresholds_10.pdf}
}
\subfigure[Max Level $L$ = 15 ]{
\label{Fig_thresholds_15}
\includegraphics[width=0.2\linewidth]{Fig_thresholds_15.pdf}
}
\subfigure[Max Level $L$ = 20]{
\label{Fig_thresholds_20}
\includegraphics[width=0.2\linewidth]{Fig_thresholds_20.pdf}
}
\caption{The tuning results of threshold $\theta$ with different Max Level $L$. For each $L$, 10 points of $\theta$ are sampled between $[2^{L}, 2^{L+2}]$}.
\label{Fig_tunning_threshold}
\end{figure*}
\begin{figure*}[ht!]
\centering
\subfigure[Max Level $L$ = 5]{
\label{Fig_det_5}
\includegraphics[width=0.2\linewidth]{Fig_det_5.pdf}
}
\subfigure[Max Level $L$ = 10 ]{
\label{Fig_det_10}
\includegraphics[width=0.2\linewidth]{Fig_det_10.pdf}
}
\subfigure[Max Level $L$ = 15 ]{
\label{Fig_det_15}
\includegraphics[width=0.2\linewidth]{Fig_det_15.pdf}
}
\subfigure[Max Level $L$ = 20]{
\label{Fig_det_20}
\includegraphics[width=0.2\linewidth]{Fig_det_20.pdf}
}
\caption{DET curves with different Max Level $L$ and threshold $\theta$.}
\label{Fig_det_threshold}
\end{figure*}
\subsection{Case Study}
To illustrate the advantage of MBTree, we provide a case study of \emph{koadic} RAT.
The most interesting behavior of koadic is that it simulates the browser traffic by changing source port to disguise the C\&C traffic. Hence, session-based detection including most of the statistical-based methods and DirPiz-Seq can hardly capture the malicious patterns of koadic since the content is transferred separately. However, MBTree can well handle the disguised traffic by regarding all session traffic of a host as a whole part.
And the similarity-based matching strategy can accurately identify the infected hosts by synthesizing the path similarity and node similarity.
\subsection{Efficiency Evaluation}
\begin{table}[h]
\centering
\footnotesize
\caption{Prediction time of different methods for per instance.}
\label{tab_time}
\begin{tabular}{c|c|c|c|c}
\hline
Methods & MBTree & CART & RF & GBDT-CIC \\ \hline
Time (s) & $10^{-5}$ & $10^{-7}$ & $10^{-5}$ & $10^{-3}$ \\ \hline
Methods & CNN & SAE & DirPiz-Seq & \\ \hline
Time (s) & $10^{-2}$ & $10^{-3}$ & $10^{-1}$ & \\ \hline
\end{tabular}
\end{table}
As a comprehensive evaluation, we also record the prediction time of each method as an efficiency comparison. By analyzing the workflow of the matching mechanism, we find that the main cost of our approach comes from the intersection operation in calculating the similarity score. Hence, we design a mechanism to realize parallel computing of similarity scores in our implementation. Specifically, for each signature, we start a process to calculate the corresponding similarity score and then collect all similarity scores for further steps. With this mechanism, the detection time is two order of magnitudes lower than that of the ordinary. The optimized results are shown in \autoref{tab_time}.
Apparently, MBTree has the same or even better performance than most statistical-based methods.
\subsection{Parameter Tuning}
In this section, we take experiments on the hyperparameters of MBTree to analyze their influences. Totally, there are four parameters, Max Level $L$, Scores Ratio $\alpha, \beta$, and the Threshold $\theta$. As adopted in previous experiments, we continue to use the default settings as start, L = 10, alpha = 0.3, beta = 0.7 and threshold = 2048. Results are shown in Fig. 7-9.
\begin{figure*}[h!]
\centering
\subfigure[Unique degree of head nodes in signatures of dataset I]{
\label{fig_sig_rat_head_nodes}
\includegraphics[width=0.25\linewidth]{Fig_signature_rats_head_nodes.pdf}
}
\centering
\subfigure[Unique degree of tail nodes in signatures of dataset I]{
\label{fig_sig_rat_tail_nodes}
\includegraphics[width=0.25\linewidth]{Fig_signature_rats_tail_nodes.pdf}
}
\centering
\subfigure[Unique degree of head nodes in signatures of dataset II]{
\label{fig_sig_malware_head_nodes}
\includegraphics[width=0.2\linewidth]{Fig_signature_malware_head_nodes.pdf}
}
\centering
\subfigure[Unique degree of tail nodes in signatures of dataset II]{
\label{fig_sig_malware_tail_nodes}
\includegraphics[width=0.2\linewidth]{Fig_signature_malware_tail_nodes.pdf}
}
\centering
\subfigure[Unique degree of head nodes in signatures of dataset III]{
\label{fig_sig_malware_head_nodes}
\includegraphics[width=0.2\linewidth]{Fig_signature_ctu_head_nodes.pdf}
}
\centering
\subfigure[Unique degree of tail nodes in signatures of dataset III]{
\label{fig_sig_malware_tail_nodes}
\includegraphics[width=0.2\linewidth]{Fig_signature_ctu_tail_nodes.pdf}
}
\caption{Number of unique values of nodes and edges organized hierarchically in the generated MLTree signatures.
}
\label{Fig_sigs}
\end{figure*}
\textbf{Path Score Ratio $\alpha$;}
The score ratio $\alpha$ determines the balance of the path score and node score. Specifically, $\alpha$ represents the ratio of the node score.
The results are shown in \autoref{Fig_alpha}. It can be noticed that the performance rise with $\alpha$ increasing at the initial on all datasets.
This can be mainly attributed to the existence of the dynamic DirPiz in the communication sequence, which truncates the CWP.
Hence, we suggest that the $\alpha$ should be set lower than 0.75 under normal conditions to facilitate robust detection.
\textbf{Head Score Ratio $\beta$;}
The parameter $\beta$ determines the balance of the head score and tail score. Specifically, $\beta$ represents the ratio of the head score.
The results are shown in \autoref{Fig_beta}. Slightly, the performances rise with $\beta$ increasing. This can be attributed to that the patterns of the handshake process are rather obvious. With the analysis of their traffic, it is obvious that the handshake process is sophisticated. The C\&C server sends fixed instructions (e.g., initialization) to the client after establishing the TCP connection.
While in the handwave process, it is rather simple. The server only sends one or two packets to notify the victim that the connection is closing, and then the rest work is handed over to the TCP level.
Hence, we suggest that the $\beta$ should be set greater than 0.5 without extra prior knowledge about samples.
\textbf{Max Level $\theta$;} The max level $\theta$ determines how deep should two MLTree be compared. Ideally, $L$ is supposed to be set as exactly the length of the automated handshake procedure. However, since the handshake process implementation varies from each other, it requires experiments on $L$ to determine the most appropriate value. Besides, for each $L$, we choose the corresponding theoretical best $\theta$. The results are shown in \autoref{Fig_maxlevel}. Obviously, based on the trend of the curves, the most appropriate value of $L$ should be lower than 15 to properly capture the automated behavior in most cases.
\textbf{Threshold $\theta$;}
The parameter $\theta$ determines the alarm level.
In this experiment, we observe the performance of different $\theta$ by setting different max levels $L$. Recall that $N_A$ is around 100. For each $L$, we sample 10 threshold points in the interval $[2^{L}, 2^{L+2}]$.
The \autoref{Fig_tunning_threshold} shows the F1 curve, and \autoref{Fig_det_threshold} shows the Detection Error Tradeoff (DET) curve.
It can be observed from \autoref{Fig_tunning_threshold} that the best performance is achieved around the points at [1,5], which covers the theoretical best threshold; thus this demonstrates the correctness of our theoretical analysis.
\subsection{Generated Signatures}
In this section, we analyze the generated signatures to inspect the behavior differences among different samples by counting the number of unique values at each level. The statistics are shown in \autoref{Fig_sigs}.
In this experiment, the max level $L$ is set as 30, which is a relatively deeper value for the handshake procedure.
First, it is apparent that the unique number of most signatures is less than 50 through different levels.
However, pupy-obfs3 shows a different trend from most of the others. The DirPizs unique degree of this RAT is relatively high at the start of the communication because obfs3 achieves the traffic obfuscation in the handshake procedure by changing the packet size distribution \cite{obfs3}. However, even though obfuscation technology is adopted to randomize the packet size, MBTree can also effectively identify the traffic. This can be attributed to the limited range of DirPiz after randomization. Since the randomize strategy of obfs3 is applied as \emph{using random length of bytes to pad the rest of the packet}, the length of the padded DirPiz can be only in the interval $[raw\_content\_length, MTU]$ according to \cite{wang2015seeing, bitansky2018indistinguishability}.
Thus our designed node similarity can still cover the padded DirPiz sequences.
Second, comparing the head nodes with tail nodes,
it is apparent that most samples use the same packets to complete the handshake process. Thus, it can be deduced that the head patterns are more identical. This conclusion is also in accord with what we acquired in the experiment of $\beta$.
Third, rough automatic handshake length can be deduced based on the change points of the curves. For example, pupy-obfs3, msf-1, Dridex, TrickBot, and neris accomplish the handshake process through 5 message exchanges.
\section{Discussion}
In the previous section, the experiment results illustrate that even though the content is transferred through encrypted transport, MBTree still identifies malicious C\&C traffic. However, sophisticated attack strategies can still be taken by adversaries to paralyze MBTree. Here we discuss the strategies that can be used against MBTree.
\emph{Disguising Attack;} A potential attack strategy for MBTree is disguising malicious traffic as benign applications. When adopting this strategy, though the malicious traces can still be identified, it will \emph{pollute} MLTree signatures and result in a large number of false alarms to cripple the MBTree. However, in order to implement such a strategy, it requires the adversaries (i) to acquire which benign application is running on the victim machine; (ii) to keep on the update of the benign applications' behaviors, which is hard to achieve in practice.
\emph{Malformed Packet;}
Since MBTree relies on successful payload identification, the evading techniques exploiting the protocol stack parsing procedure can be used to evade MBTree\cite{wang2020symtcp, moon2019alembic}. For example, transfer content through RST packets. When adopting such a technique, the payload can be incorrectly reassembled by the man-in-the-middle MBTree, and the malicious patterns cannot be identified. However, implementing this strategy also requires extra protocol stack control to deal with the malformed packets correctly. Besides, traditional firewall or IDS can identified these malformed packets easily.
\emph{Obfuscation Attack;}
Although our experiment proves that MBTree can resist the obfuscation strategy to some extent, it will still lead to the invalidity of MBTree in the face of a highly targeted attack strategy.
A potential valid evading strategy is radically splitting the padded content into several packets with random packet size. In the case of such a strategy, not only will MBTree be polluted, resulting in high-level false alarms, but the sample can also evade the detection of MBTree with unseen DirPiz sequences. However, current RATs rarely attempt to hide their DirPiz identifications to our best known. Besides, to against this radical strategy, we suggest that the entropy analysis of the DirPiz sequences can be used. Since benign applications usually follow a specific procedure to complete the handshake, the entropy of their DirPiz sequences are relatively low; thus, it is abnormal if the entropy is exceedingly high in the case of only running a few applications on the machine.
\section{Conclusion}
In this paper, we present the MBTree, a novel signature-based approach that integrates DirPiz sequences as MLTree signatures with the similarity matching mechanism to detect encrypted RAT traffic. We evaluate MBTree against several C\&C traffic with comprehensive benign applications' traffic as background. The results show that MBTree can detect different malicious traffic in different environments with high-level accuracy.
Briefly, there are two directions in our future work to improve MBTree. First, we plan to improve the similarity score calculation, so as to detect malicious behaviors through different hierarchies. Second, inspired by \cite{bovenzi2020big}, we plan to improve the parallel computing ability by integrating the famous MapReduce framework \cite{dean2008mapreduce}.
| {'timestamp': '2021-04-07T02:12:49', 'yymm': '2006', 'arxiv_id': '2006.10196', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10196'} | arxiv |
\section{Introduction}\label{s:intro}
\acused{ac}
The pursuit of developing systems with increasingly autonomous
capabilities is amongst the main reasons for the emergence of
\emph{\aclp{les}} (\acsp{les}), i.e.,\xspace systems embedding \acf{ml}
based software components.
There is a growing consensus in autonomy standardization efforts~\cite{ul4600std}
on the value of using \emph{\aclp{ac}} (\acsp{ac}) as the mechanism by which to convince various stakeholders that an \ac{les} can be relied upon. \acp{ac} have
been successfully used for safety assurance of novel aviation applications
where---like \acp{les}---regulations and standards continue to be under
development~\cite{cdp-atio-2017}.
However, \acp{les} pose particular assurance challenges~\cite{mcdermid2019}
and existing \ac{ac} technologies may not be sufficient, requiring
a framework where the system and its \ac{ac} evolve in tandem~\cite{dhp-icse2015}.
Here too, there are specific additional challenges:
first, structured arguments\footnote{The systematic reasoning that captures
the rationale why specific conclusions, e.g.,\xspace of system safety, can be drawn
from the evidence supplied.} in many \acp{ac} are effectively \emph{static},
i.e.,\xspace they are usually developed prior to system deployment under assumptions
about the environment and intended system behavior.
Evolution of the system or its \ac{ml} components (e.g.,\xspace via online learning,
or by adaptation in operation) can render invalid a previously accepted
\ac{ac}.
In principle, although it is possible to dynamically evolve structured
arguments~\cite{dhp-icse2015}, since their role is primarily to convince
human stakeholders, it makes more sense for such updates to happen between
missions at well-defined points.
Second, an operational evaluation of the extent of assurance in an \ac{les}
(or its \ac{ml} components, where appropriate) is a valuable system-level
indicator of continued fitness for purpose. That, in turn, can facilitate
potential intervention and counter-measures when assurance drops below
an acceptable level during a mission. Indeed, \emph{online assurance updates}
that are aimed at machine consumption must necessarily be in a computable
form, e.g.,\xspace using a formal language, such as a logic, or as a quantification. So
far as we are aware, prevailing notions of \acp{ac} do not yet admit such
evaluation.
Prior efforts at \ac{ac} confidence assessment~\cite{dhp-esem-11, guiochet2019}
have focused on the argument structure rather than the system itself, and face
challenges in repeatable, objective validation due to their reliance on
subjective data. They have also not been applied to \acp{les}.
Thus, there is a general need to capture a computable form of assurance
to bolster an otherwise qualitative \ac{ac}. Note that although a qualitative
\ac{ac} may well refer to quantitative evidence items, here we are identifying
the necessity to have quantified assurance as a core facet of \ac{les} \acp{ac}.
This paper focuses on the problem of assurance quantification, deferring its
use in dynamic updates to future work. The main contribution is an
approach to characterize assurance in an \ac{les} through \ac{uq} of
system-level dependability attributes, demonstrated by application to an
aviation domain \ac{les}.
\acused{cte}
\section{Methodology}\label{s:approach}
Previously~\cite{adp-edcc2019}, we have described how assurance of \ac{ml}
\emph{components} in an \ac{les} can be characterized through \ac{uq} of
component-level properties associated with the corresponding (component-level)
dependability attributes. Here, we extend our methodology to the system-level,
relying on the following concepts:
\emph{assurance} is the provision of (justified) confidence that an
\emph{item}---i.e.,\xspace a (learning-enabled) component, system, or service---possesses
the relevant assurance properties. An \emph{assurance property} is a logical,
possibly probabilistic characteristic associated with \emph{dependability
attributes}~\cite{dependability-taxonomy} and functional capabilities. One or
more assurance properties applied to a particular item give an \emph{assurance
claim}\footnote{Henceforth, we do not distinguish assurance properties from
assurance claims.}.
An \emph{assurance measure} characterizes the extent of confidence
that an assurance property holds for an item through a probabilistic
quantification of uncertainty. It can be seen as implementing a \ac{uq} model
on which to query the confidence in an assurance property.\footnote{When the
assurance property is itself probabilistic, the corresponding assurance measure
is deterministic, i.e.,\xspace either 0 or 1.}
In general, we can define multiple assurance properties (and assurance measures), based on the \ac{les} functionality and dependability attributes for which
assurance is sought. For example, the proposition ``\emph{the aircraft location
does not exceed a specified lateral offset from the runway centerline during taxiing}'' is a system-level assurance claim associated with the attribute
of \emph{reliability}.
Similarly, the assurance property ``\emph{the aircraft does not veer off
the sides of the runway during taxiing}'' is associated with the attribute
of \emph{system safety}. Such assurance properties directly map to the claims
made in the structured arguments of an \ac{les} \acl{ac}. Thus, we can leverage
the methodology for creating structured arguments~\cite{dp-jase2018} to also
specify assurance properties.
For quantification, we mainly consider assurance measures for those
system-level properties that can be reasonably and feasibly quantified.
For example, assurance measures for the preceding example quantify the
uncertainty that the aircraft location does not exceed, respectively, the
specified lateral offset from the runway centerline (reliability), and half
the width of the runway pavement (safety), over the duration of taxiing.
\acp{les} used in safety-critical applications, especially aviation, are
effectively stochastic dynamical systems. The insights from this
observation are that we can:
\begin{inparaenum}[\itshape i\upshape)]
\item capture \ac{les} behavior through model-based representations
of the underlying stochastic process;
\item view system-level assurance properties as specific realizations of
particular \acp{rv} of that process; and
\item express confidence in the assurance properties---i.e.,\xspace the assurance
measures---by propagating uncertainty through the model to determine
the distributions over the corresponding \acp{rv}.
\end{inparaenum}
One challenge is selecting an appropriate model and representation of the
stochastic process to be used to model \acp{les}. Although there is not a
generic answer for this, such a model could be built, for example,
by eliciting the expected system behavior from domain experts, by transforming
a formal system description, using model fitting and statistical optimization
techniques applied to (pre-deployment) system simulation and execution traces,
or through a combination of the three. For \acp{les}, a formal system description
may be often unavailable.
As such, we rely on elicitation and statistical techniques, using Bayesian
models where possible, making allowance to admit and use other well-known,
related stochastic process models---such as Markov chains---and leveraging
data from analytical representations of system dynamics, simulations, and
execution.
The Bayesian concepts of \emph{credible} intervals and regions---determined
on the posterior distribution of the \acp{rv} for assurance properties---give
a formal footing to the intuitive, subjective notion of confidence that
usually accompanies claims in assurance arguments, and \acp{ac} in
general~\cite{Hawkins2011}.
\section{Illustrative Example -- Runway Centerline Tracking}\label{s:example}
\acused{cte}
\acused{he}
\subsection{System Description}
To show our methodology is feasible, we now apply it to quantify
assurance in an aviation domain \ac{les} supplied by our industrial
collaborators: a \ac{uas} embedding an \ac{ml} component, trained offline
using supervised learning, to support an autonomous taxiing capability. The
broader goal is to enable safe aircraft movement on a runway without human pilot input.
Fig.~\ref{f:uas-example} shows a simplified \emph{pipeline architecture} used
to realize this capability. A deep \ac{cnn} implements a perception function
that ingests video images from a wing-mounted camera pointed to the nose of
the aircraft.
The input layer is $(360 \times 200)$ pixels $\times~3$ channels wide; the
network size and complexity is of the order of $100$ layers with greater than
two million tunable parameters. Effectively, this \ac{ml} component performs
regression under supervised learning producing estimates of \emph{\acl{cte}}
(\acs{cte})\footnote{The horizontal distance between the aircraft nose wheel
and the runway centerline.} and \emph{\acl{he}} (\acs{he})\footnote{\emph{Heading}
refers to the compass direction in which an object is pointed; \acf{he} here,
is thus the angular distance between the aircraft heading and the runway
heading.} as output. These estimates are input to a classical \ac{pid}
controller that generates the appropriate steering and actuation signals.
\begin{figure}[t]
\centering
\includegraphics[width=0.6\textwidth]{uas-example}
\caption{Pipeline architecture to implement an autonomous taxiing
capability in a \ac{uas}.}
\label{f:uas-example}
\end{figure}
\subsection{Assurance Properties}\label{sss:uas-assurance-properties}
The main objective during taxiing (autonomously, or under pilot control) is
to safely follow the runway (or taxiway) centerline. Safety during taxiing
entails avoiding \emph{lateral runway overrun}, i.e.,\xspace not veering off the sides
of the runway pavement. Although avoiding obstacles on the runway is also a
safety concern, it is a separate assurance property that we do not consider
in this paper.
Thus, safety can be achieved here, in part, by meeting a performance objective
of maintaining an acceptable lateral offset (ideally zero) on either side of
the runway centerline during a taxi \emph{mission} from starting taxi to
stopping (or taking off).\footnote{Our industry collaborators elicited the
exact performance objectives from current and proficient professional pilots.}
In other words, the closer the aircraft is to the runway centerline
during taxiing, the less likely it is to veer off the sides of the runway.
This performance objective relates to the attribute of reliability, where
\emph{taxi failure} is considered to be the violation of the specified
lateral offset.
Here, we focus on the corresponding assurance property,
$\mathtt{Assured Taxi}: \abs{\mathrm{CTE}_a} < \mathtt{offset}$, where $\mathtt{offset}=2\meter$ is the
maximum acceptable lateral offset on either side of the runway centerline for
this application and aircraft type. $\mathrm{CTE}_a$, which is the true (or actual)
\ac{cte} for the \ac{uas}, is a signed, real valued scalar; the absolute value
gives the magnitude of the offset, and the sign indicates where the \ac{uas} is
located relative to the centerline, i.e.,\xspace to its left or its right.
\subsection{Assurance Quantification}\label{sss:uas-uq}
\acused{dbn}
\subsubsection{Model Choice}
The assurance measure corresponding to $\mathtt{Assured Taxi}$, establishes
$\mathrm{Pr}\left(\abs{\mathrm{CTE}_a} < 2\meter\right)$, which characterizes the
uncertainty (or conversely, confidence) in the true (or actual) \ac{cte}
($\mathrm{CTE}_a$) relative to the specified offset. $\mathrm{CTE}_a$ evolves in
time as the \ac{pid} controller responds to \emph{estimates} of \ac{cte}
and \ac{he}, themselves the responses of the deep \ac{cnn} component, to
runway images captured by the wing mounted camera (see Fig.~\ref{f:uas-example}).
$\mathrm{CTE}_a$ is thus uncertain and depends on other variables, of which those that
can be observed are the estimated \ac{cte} ($\mathrm{CTE}_e$), estimated \ac{he}
($\mathrm{HE}_e$), and a sequence of images.
We can also model the controller behavior in terms of a time series evolution of
$\mathrm{CTE}_a$ since, during taxiing, the true \ac{cte} at a given time is
affected by the controller actuation signals at prior times.
An abstracted model of \ac{les} behavior is reflected in the joint
distribution of the relevant observed and uncertain variables.
In fact, a \emph{\acl{dbn}} (\acs{dbn})~\cite{ml-book} is a convenient and
compact representation of this joint distribution, as we will see subsequently in this section. It takes into account the temporal evolution of the variables
and their (known or assumed) conditional independence relations.
Thus, to determine the assurance measure, we effectively seek to quantify the
(posterior) distribution over $\mathrm{CTE}_a$, given a sequence of runway
images, the estimates of \ac{cte} and \ac{he} produced by the \ac{ml} component,
and the controller behavior, as a query over the corresponding \ac{dbn} model.
\begin{table}[t]
\centering
\caption{\ac{dbn} model variables.}
\label{t:uas-model-vars}
\includegraphics[width=\columnwidth]{uas-model-variables}
\end{table}
\subsubsection{Model Variables}
Model variables can be discrete or continuous, and there are tradeoffs
between information loss and computational cost involved in the choice.
Table~\ref{t:uas-model-vars} lists the discrete variables we have chosen,
giving the interval boundaries for their states. The choice of the intervals
that constitute the states of the variables has been based, in part, on:
\begin{inparaenum}[\itshape i\upshape)]
\item domain knowledge,
\item an assessment of the data sampled from the environments
used for training and testing the \ac{cnn}, and
\item the need to develop an executable model that was modest in
its computational needs.
\end{inparaenum}
Here, $w$ is the width of the runway in meters, and negative values
represent \ac{cte} measured on the left of the runway centerline. The \ac{he}
is given in degrees, while $D$ is dimensionless. An additional variable ($I$,
not shown in Table~\ref{t:uas-model-vars}) models the runway image captured
from the camera video feed as a vector of values in the range $[0\dots1]$ representing normalized pixel values.
The Boolean variable $D$ represents the detection of outliers in camera
image data. Such outliers may manifest due to various causes, including
camera errors and \emph{covariate shift}, i.e.,\xspace when the data input to
the \ac{cnn} has a distribution different from that of its training data.
Note that the \ac{les} shown in Fig.~\ref{f:uas-example} does not
indicate whether or not it includes a mechanism to detect outliers or
covariate shift. However, we include this variable here, motivated by
our earlier work on component-level assurance quantification of the
\ac{cnn}~\cite{adp-edcc2019}, which revealed its susceptibility to outlier
images. In fact, $D$ models a runtime monitor for detecting \ac{ood} inputs to
the \ac{cnn}.
\begin{figure}[t]
\centering
\includegraphics[width=0.65\columnwidth]{uas-dbn}
\caption{\ac{dbn} structure for assurance quantification, showing
two adjacent slices at times $t-1$, and $t$; shaded nodes represent
observed variables, clear nodes are the uncertain, latent variables.}
\label{f:uas-dbn}
\end{figure}
\subsubsection{Model Structure}
Each variable in Table~\ref{t:uas-model-vars} is indexed over time: we will
denote a variable $X$ at time $t$ as $X^{(t)}$. The causal ordering of the
model variables (Fig.~\ref{f:uas-dbn}) informs the structure of the \ac{dbn}:
the estimated \ac{cte} and \ac{he} at time $t$ are inputs to the controller
which, in turn, impacts the future location of the aircraft at time
$t+\varepsilon$. The directed links between the corresponding variables
in adjacent time slices capture this dependency. For example, in
Fig.~\ref{f:uas-dbn}, these are the directed links
$\mathrm{CTE}_e^{(t-1)} \to \mathrm{CTE}_a^{(t)}$, and
$\mathrm{HE}_e^{(t-1)} \to \mathrm{CTE}_a^{(t)}$ (and likewise for the
preceding and subsequent time slices).
The directed links $\mathrm{CTE}_a^{(t-1)} \to \mathrm{CTE}_a^{(t)}$ model the
correlation between actual vehicle position over time, also capturing vehicle
inertia.
At time $t$, the runway image $I^{(t)}$ influences the belief about the true
aircraft location, i.e.,\xspace the states of $\mathrm{CTE}_a^{(t)}$, with the node $D$
modeling the associated structural uncertainty. This reflects the intuition
that upon detecting an outlier image (more generally an \ac{ood} input), we are
no longer confident that the image seen is an indicator of the actual aircraft
location. Fig.~\ref{f:uas-dbn} reflects these dependencies by the directed edges
$\mathrm{CTE}_a^{(t)} \gets I^{(t)}$, and $\mathrm{CTE}_a^{(t)} \gets D^{(t)}$, respectively.
Fig.~\ref{f:uas-dbn} shows two adjacent time slices of the \ac{dbn} structure,
although the actual structure is unrolled for $T$ time steps, the duration of
taxiing, to compute the assurance measure over the taxi phase. At time $t$, this
is, in fact, the sum of the probability mass over the seven states of
$\mathrm{CTE}_a^{(t)}$ that lie within the interval $[-2, 2]$ (see
Table~\ref{t:uas-model-vars}).
By unrolling the \ac{dbn} for an additional $\varepsilon$ time steps
and propagating the uncertainty through the model from the time of the
last observations, the model can provide an assurance forecast.
\subsubsection{Probability Distributions}
To complete the \ac{dbn} model specification, we need to specify the
\acp{cpd} over the model variables, as encoded by its structure. One way to
identify the \acp{cpd} is through \acl{uq} of the physical system
model~\cite{najm2009uncertainty}. Practically, the latter may not be
available, especially for \acp{les}.
Another alternative---the approach we take here---is to assume a functional form
for the \acp{cpd} that is then tuned based on execution and simulation data.
Specifically, to construct the \ac{cpd} represented by the transition edge
between the time slices, i.e.,\xspace $\mathrm{Pr}(\mathrm{CTE}_a^{(t)}\,|\, \mathrm{CTE}_a^{(t-1)}, \mathrm{CTE}_e^{(t-1)}, \mathrm{HE}_e^{(t-1)})$, we chose a multinomial
distribution with a uniform prior, tuned using the \ac{map} estimate
on simulation data. This choice was advantageous in the sense that the
\ac{dbn} produces a uniform posterior distribution over $\mathrm{CTE}_a$
when the observed variables take on values from a distribution different from
that of the data used to build the \acp{cpd}.
For this example, the simulation data comprised sequences of runway
images, estimated \ac{cte} and \ac{he} as produced by the \ac{cnn}, and
true \ac{cte}. Section~\ref{s:uas-experimental-results} gives more details
on the simulation platform and data gathered.
To determine the emission probability $\mathrm{Pr}(\mathrm{CTE}_a^{(t)}\,|\,I^{(t)})$,
first we used the \ac{gp} model underpinning our prior work on component-level
assurance quantification~\cite{adp-edcc2019}. In brief, the idea is to use
a \ac{gp} to model the error performance of the \ac{cnn} (i.e.,\xspace its accuracy)
on its input (i.e.,\xspace runway images). Then, adding the error distribution to the
estimate of \ac{cte} gives the distribution over the true \ac{cte}. However,
for high dimensional data (such as images), this is computationally expensive.
Instead, in this paper we used an ensemble of decision
trees~\cite{criminisi2012decision} as a classifier that ascribes a
probability distribution over the states of $\mathrm{CTE}_a$, given a runway
image, $I$. This approach builds uncorrelated decision trees such that
their combined estimate is more accurate than that of any single decision tree.
To identify the decision rules, we used supervised learning over the
collection of runway images and corresponding true \ac{cte}, sampled from
the same environments used to train and test the \ac{cnn} (see
Section~\ref{s:uas-experimental-results}). For this example, we built $280$
decision trees with terminal node size of at least $10$, by randomly sampling
$100$ data points using the \emph{Gini index} as a performance metric,
selecting the model parameters to balance classification accuracy and
computational resources.
\section{Experimental Results}\label{s:uas-experimental-results}
We now present some results of our experiments in quantifying \ac{les}
assurance in terms of the assurance measure, $\mathrm{Pr}\left(|\mathrm{CTE}_a| <
2\meter\right)$, based upon simulations of constant speed taxiing missions.
\subsection{Simulation Setup}\label{ss:uas-simulation-setup}
We use a commercial-off-the-shelf flight simulator instrumented to reflect
the pipeline architecture of Fig.~\ref{f:uas-example}. The simulation
environment includes various airports and runways with centerlines of
varying quality, e.g.,\xspace portions of the centerline may be obscured at
various locations (see Fig.~\ref{f:uas-example}).
We can create different training and test environments by changing various
simulation settings, among which two that we have selected are:
\begin{inparaenum}[\itshape i\upshape)]
\item weather induced visibility (\emph{clear} and \emph{overcast}),
and
\item the time of day (\emph{07:30am} to \emph{2:00pm}).
\end{inparaenum}
Two such environments are, for example, ``\emph{Clear at 07:30am}'',
and ``\emph{Overcast at 12:15pm}''. More generally, we can construct
environments such as ``\emph{Clear Morning}'', ``\emph{Overcast Afternoon}'',
and so on. The former refers to the collection of data sampled from the
environment having clear weather, and the time of day incremented in steps
of $15$ and $30$ minutes from \emph{07:30am} until \emph{noon}. A similar
interpretation applies to other such environments.
From these environments, we gathered images via automated screen capture
(simulating the camera output) whilst taxiing the aircraft on the airport
runway, using different software controllers, as well as different \acp{cnn}
for perception: i.e.,\xspace the same \ac{cnn} architecture described in
Section~\ref{s:example}, but trained by our industrial collaborators with
data drawn from the various environments identified earlier. In tandem, for
each image, we collected true \ac{cte} (from internal simulation variables),
along with estimates of \ac{cte} and \ac{he}.
We used several such data sets, one for each of the different
environments identified above, from which data samples were drawn to build
the \acp{cpd} of the \ac{dbn} model. Here, note that these data samples
were \emph{not} identical to those used to train and test the \ac{cnn},
even though the samples were drawn from the collection of environments
common to both the \ac{les} and the \ac{dbn}.
\begin{figure}[t]
\centering
\includegraphics[width=0.75\columnwidth]{uas-uncertainty}
\caption{Visualization of predicted uncertainty in true \acl{cte},
$\mathrm{CTE}_a^{(t)}$, to quantify assurance in runway centerline tracking
as the assurance measure, $\mathrm{Pr}(\mathtt{Assured Taxi})$.}
\label{f:uas-uncertainty}{}
\vspace{\baselineskip}
\includegraphics[width=0.725\columnwidth]{uas-assurancemeasure}
\caption{$\mathrm{Pr}(\mathtt{Assured Taxi})$ for $\mathtt{offset}=2\meter$
and $\mathtt{offset} = 1.43\meter$.}
\label{f:uas-assurancemeasure}
\end{figure}
\subsection{Uncertainty Quantification}
Fig.~\ref{f:uas-uncertainty} shows the results of assurance quantification for
one test scenario, visualized as a probability surface overlaid on a stretch
of the runway, itself shown as a grid. The horizontal axis---discretized using
the interval boundaries for the states of $\mathrm{CTE}_a$ (see
Table~\ref{t:uas-model-vars})---gives the true aircraft location, which is
uncertain during taxiing. Thus, moving from left to right (or vice versa)
constitutes lateral aircraft movement.
The vertical axis (discretized into $6$ steps, each of duration
$0.33\second$) represents the number of time slices for which the \ac{dbn}
model is unrolled. We selected this based on the time taken for the \ac{uas}
to laterally depart the runway after violating the $2\meter$ bound, given:
runway dimensions, maximum allowed taxiing speed, and other constraints on
the \ac{uas} dynamics, e.g.,\xspace non-accelerating taxiing.
At $t=0$, the horizontal axis gives the aircraft location at the current time.
The time steps $t=1,\ldots, 6$ are \emph{lookahead times} for which the
horizontal axis gives the \emph{predicted} location of the aircraft relative
to the centerline, given the \ac{cnn} estimates of \ac{cte} and \ac{he} at $t=0$.
Thus, moving from the bottom to the top of Fig.~\ref{f:uas-uncertainty}
represents forward taxiing, i.e.,\xspace the temporal evolution of aircraft position
over the runway.
Each cell of the grid formed by discretizing the two axes is, therefore,
a state of $\mathrm{CTE}_a$ at a given time, shaded such that darker shades
indicate lower uncertainty (or higher confidence) and lighter shades
indicate higher uncertainty (or lower confidence).
Thus, the row at $t=0$ shows the \ac{dbn} estimate of uncertainty over
$\mathrm{CTE}_a$ at the current time. Similarly, each row for $t=1, \ldots, 5$
shows the \emph{predicted} uncertainty over $\mathrm{CTE}_a$ for those
lookahead times, given that the last known values for the observed
variables are at $t=0$.
The solid white line in Fig.~\ref{f:uas-uncertainty} at $t=0$ is
\emph{ground truth}, i.e.,\xspace the true \ac{cte} at the current time based on
internal simulation variables. Although this may not be otherwise
available during taxiing, we show it here primarily for model validation,
i.e.,\xspace to show that the interval (state of $\mathrm{CTE}_a$) estimated
by the \ac{dbn} to be the least uncertain is also the one that includes the
ground truth.
The solid black line is \ac{cte} as estimated by the \ac{cnn}
(i.e.,\xspace $\mathrm{CTE}_e$) at the current time.
Recall that assured taxiing involves maintaining $\mathrm{CTE}_a$ between
a $2\meter$ lateral offset on either side of the centerline. To quantify
assurance in this property, we sum up the probability mass in each cell
between the two offsets. Fig.~\ref{f:uas-assurancemeasure}
shows the assurance measure, $\mathrm{Pr}(|\mathrm{CTE}_a^{(t=0)}| < \mathtt{offset})$ computed
for two different offset values: $2\meter$ and $1.43\meter$.\footnote{The
introduction of a second offset was motivated by our industry collaborators
to integrate the assurance measure on the \ac{les} platform.}
The interval $[-2, 2]$ is a Bayesian \emph{credible interval}
within which the true \ac{cte} lies with probability $\approx 95\%$,
based on Fig.~\ref{f:uas-assurancemeasure}. In other words, \emph{the
\ac{dbn} model is $\approx 95\%$ confident that the aircraft is truly
located within $2\meter$ of the runway centerline}.
In general, the expected (and desired) \ac{dbn} behavior is to be more
uncertain over longer term assurance forecasts, when there are no
additional observations with which to update the posterior distributions
on the assurance measures.
\subsection{Sufficient Assurance}
We must select a threshold on the assurance measure to establish what
sufficient assurance constitutes, based on which we can assert whether or
not the assurance claim holds. The criterion we have selected here is: when
the \ac{dbn} is $\geq 30\%$ confident that the true \ac{uas} location exceeds
the allowed lateral offset, the assurance claim does not hold, i.e.,\xspace
$\Pr(|\mathrm{CTE}_a^{(t)}| \geq 2\meter) \geq 0.3 \Rightarrow \neg(\mathtt{Assured Taxi})$.
We determined this threshold under conservative assumptions about vehicle
behavior, leveraging the engineering judgment of our industry collaborators,
to balance the tradeoff between safety (avoiding runway overrun) and mission
effectiveness (not stopping too often).
\section{Discussion}\label{s:discussion}
We now evaluate how the \ac{dbn} performs relative to the \ac{les}, in
the context of ground truth.
The intent is to show that it is a reasonable (i.e.,\xspace valid) \emph{reference model}
of the system suitable for runtime use (i.e.,\xspace simple and abstract), based on which
to make certain decisions, e.g.,\xspace whether or not to stop taxiing. Moreover, we
must also show that the software implementation of the \ac{dbn} can be
relied upon. In this paper, we primarily address the former, leaving the latter
for future work.
\subsection{Validity}
We compare how well the \ac{dbn} and the \ac{les} can discriminate
between \emph{true positive} and \emph{true negative} situations when their
respective outputs are transformed into a classification on a plurality of
image data drawn from multiple simulated taxiing scenarios for different test
environments unseen by both the \ac{dbn} and the \ac{les}.
A true positive (negative) situation for the \ac{dbn} is one where it indicates
that the assurance property is satisfied (not satisfied) based on the criterion
for sufficient assurance (see Section~\ref{s:uas-experimental-results}),
and ground truth data also indicates that it is truly the case that the \ac{uas}
location is within (exceeds) the allowed lateral offset from the runway
centerline.
Likewise for the \ac{les}, a true negative (positive) situation is one where
the \ac{cnn} estimate of \ac{cte} indicates (does not indicate) an offset
violation i.e.,\xspace $\mathrm{CTE}_e \geq 2\meter$ (equivalently, $\mathrm{CTE}_e <
2\meter$), and so does ground truth data.
\begin{table}[ht]
\centering
\caption{\ac{dbn} Performance evaluation for runway centerline tracking.}
\label{t:uas-model-validation}
\includegraphics[width=0.9\columnwidth]{uas-model-validation}
\end{table}
Table~\ref{t:uas-model-validation} shows our evaluation results in terms of
\emph{sensitivity} (true positive rate) and the \emph{specificity} (true
negative rate) of both the \ac{dbn} model and the \ac{les}, varying the
embedded \ac{cnn} used for perception. The variability arises from using
\acp{cnn} trained under two different training environments. We also used
these training environments to build the \ac{dbn} for both \ac{les} variants
using $\approx 37000$ image samples. These samples were not the same as those
that were used to train the \ac{cnn} variants: indeed, we did not have access
to the actual training data for the different \acp{cnn}.
Also, the test environments listed in the table (and, therefore, the resulting
test data), are unseen during the development of both \ac{les} variants,
and the \ac{dbn} models of the same.
Based on Table~\ref{t:uas-model-validation}, in the context of the sensitivity
and specificity metrics shown, as well as the criterion for sufficient
assurance, we are cautiously optimistic in claiming that the \ac{dbn}
models the \ac{les} reasonably well.
For the test environments ``\emph{Clear at 11:45am}'', and ``\emph{Overcast at
12:15pm}'', the \ac{dbn} has a lower sensitivity than the \ac{les}, however its
specificity is substantially better. This suggests that the \ac{les} may be
biased in its estimates of \ac{cte} for those operating conditions.
\subsection{Suitability}
The \ac{dbn} model structure---in particular, the conditional independence
relations encoded by the structure---is informed by (our knowledge of) the
causal impacts of the identified variables and the system dynamics, and the
resulting assumptions.
We note that it is always possible to relax these assumptions and learn the
\ac{dbn} structure as well as its parameters. However, in most cases,
especially when there is limited data available, structure learning can be
an unidentifiable problem, or can produce a non-unique solution.
In our case, the conditional independence assumptions used have turned out
to be neither too strong to affect model performance nor too conservative to
impose a problem in identifying the \acp{cpd} given limited data.
Our assessment in Table~\ref{t:uas-model-validation} does \emph{not}
compare the \ac{dbn} and the \ac{cnn} that estimates \ac{cte}.
Indeed, the latter is a learned, static regression function for a
\emph{component}, that associates a vector of real values with a real-valued
scalar, whereas here we are assessing a stochastic process model of a
(learning-eabled) \emph{system} (i.e.,\xspace the \ac{dbn}) against the system itself.
When we use the \ac{dbn} for runtime assurance, we implement it as a software
component integrated into the \ac{les}. This can be viewed as an item to which
we can apply our own assurance methodology, i.e.,\xspace as in Section~\ref{s:approach},
and~\cite{adp-edcc2019}. Thus, although we have not formulated assurance
properties for the \ac{dbn}, sensitivity and specificity are probabilistic
performance metrics (albeit in a frequentist sense) that we can view as
assurance measures in their own right, that we have now applied to our model.
The validation above is admittedly not exhaustive although the following
observations are worth noting: the \ac{dbn} is a relatively simple and
abstract model of the time-series evolution of the \emph{system}, whose
estimates can be updated through Bayesian inference given observed data.
Thus, it is amenable to applying other verification techniques including
inspection, and formal verification.
Moreover, the \ac{dbn} \emph{does not} produce point estimates of \ac{cte};
rather, in quantifying confidence in a system-level assurance property, a
by-product is the uncertainty in true \ac{cte} given as a probability
distribution over the range of admissible values of $\mathrm{CTE}_a$.
Thus, in unseen situations where the \ac{cnn} can produce an inaccurate
estimate of \ac{cte} (see Fig.~\ref{f:uas-uncertainty}), the \ac{dbn}
gives a distribution over possible values of true \ac{cte}. As sucsh, it is
more conservative in potentially unsafe scenarios. Based on this assessment,
we submit that the \ac{dbn} is a reasonable and suitable runtime reference
model of the \ac{les} for the autonomous taxiing application, when used for
centerline tracking.
\acused{cms}
\subsection{Utility}
A key advantage of an abstract assurance quantification model is a small
implementation footprint for runtime integration into the \ac{les}.
As indicated in Section~\ref{s:intro}, one of the primary motivations for
quantified assurance measures is to provide feedback signals
(in a computable form) to the \ac{les}, that can be acted on, e.g.,\xspace by a \emph{\acl{cms}} (\acs{cms}), in operation.
In this work, the assurance measure values were translated into commands
to either \emph{stop}, \emph{slow down}, or \emph{continue} based on
\begin{inparaenum}[\itshape i\upshape)]
\item the chosen decision thresholds
(Section~\ref{s:uas-experimental-results}), and
\item a simple model of the system-level effect (i.e.,\xspace likelihood of lateral
runway overrun) given the assurance measure and current system state
\footnote{Although the content of integrating assurance measures with
a \ac{cms} is very closely related to the work here, it is not in
scope for this paper, and will be the topic of a forthcoming article.}
\end{inparaenum}
In general, deciding between a series of options in the presence of
conflicting and uncertain outcomes is a special case of \emph{decision
making under uncertainty}~\cite{Kochenderfer2015}. We plan to
investigate such techniques as future work to develop a principled approach
to contingency management using assurance measures.
The aim of \emph{run-time assurance}, also known as \emph{run-time
verification}, is to provide updates as to whether a system satisfies
specified properties as it executes \cite{R2U2}. This is done using a run-time
\emph{monitor}, which evaluates the property using values extracted from the
state of the system and its environment. In a sense, therefore, the notion of
assurance measure we have described here is a kind of monitor. However, it is
worth making several distinctions. A monitor relates directly to properties of
the system, whereas an assurance measure characterizes \emph{confidence} in
our knowledge of such properties. Second, an assurance measure seeks to
aggregate a range of sources of information, including monitors. Thus it can
be seen as a form of \emph{data fusion}. Third, monitors typically provide
values that relate to the current state of the system, whereas the assurance
measures we have defined are predictive, intended to give a probabilistic
quantification on dependability attributes.
In general, our approach to assurance quantification admits other models
including runtime monitors: recall that the node $D^{(t)}$ in
Fig.~\ref{f:uas-dbn} is a runtime monitor detecting data distribution
shift in the input image at time $t$.
Indeed, our framework is not intended to replace runtime verification,
and the assurance measures generated show the assurance contribution of the
runtime monitors, additionally providing an assurance/uncertainty forecast. We
are not aware of existing runtime verification techniques that do this.
\section{Related Work}\label{s:related-work}
The work in this paper is closely related to our earlier research on
assurance case confidence quantification~\cite{dhp-esem-11}. There,
although confidence estimation in an assurance claim also uses Bayesian
techniques, it relies primarily on the argument structure to build the
model. Similarly, based on the structure of an argument, the use of an
evidential theory basis has been explored for confidence quantification
in assurance claims~\cite{guiochet2019}. However, neither work has been
applied to \ac{les} assurance quantification. Moreover, in this paper
the focus is on those properties where quantification is possible, relying
upon models of the system that can be assessed against objective, measured
data.
This paper is a natural extension of our prior work on quantifying assurance
in \ac{ml} components~\cite{adp-edcc2019}: the assurance property we consider
there is $\mathrm{CTE}_e$ \emph{accuracy}. Assurance quantification then entails
using \acfp{gp} to determine the uncertainty in the error of $\mathrm{CTE}_e$,
which is inversely proportional to accuracy. However, the data used are not
(and need not be) time dependent and the model used applies regardless of
whether or not the aircraft position has violated $\mathtt{Assured Taxi}$. Indeed,
despite a high assurance \ac{cnn} that accurately estimates \ac{cte}, it is
nevertheless possible to violate $\mathtt{Assured Taxi}$. However, in this paper we
model the \ac{les} as a stochastic process, including any runtime
mitigations, e.g.,\xspace a monitor for detection \ac{ood} images. As such, the
models used for \ac{uq} are a generalization of that in~\cite{adp-edcc2019}
to time-series behavior.
As previously indicated (Section~\ref{s:intro}), one of the motivations is to
support dynamic \acfp{ac}. Our prior work~\cite{dhp-icse2015} first explored
this concept, which has subsequently been tailored for so-called
\emph{self-adaptive software}~\cite{calinescu2017}. Again, neither work has
considered \acp{les}, although self-adaptation is one of the properties that
\acp{les} can exhibit.
In~\cite{dhp-icse2015}, confidence quantification has been situated as a
core principle of dynamic assurance which has also motivated this paper to
an appreciable degree. However, that work relies on the quantification
methodology in~\cite{dhp-esem-11}.
In \cite{calinescu2017}, assurance quantification employs probabilistic
model checking, which can be leveraged for \acp{les} if they can be represented
using state-space models, e.g.,\xspace as in~\cite{verisig} which uses hybrid model
checking instead. Neither technique is incompatible with the stochastic
processes-based modeling approach that we have adopted. As such, they may be
a candidate means to check properties of the stochastic models that we build
as a means of (meta-)assurance.
\emph{Dynamic safety management} as an assurance concept has also been proposed
as a run-time assurance method~\cite{trapp2018}, but it is largely speculative
about applicability for \acp{les}.
The idea of \emph{requirements-aware} runtime models~\cite{bencomo2019} is
very closely related to our notion of building a reference model. Quantified
and probabilistic guarantees in reinforcement learning have been explored in
developing assured \ac{ml} components in~\cite{kochenderfer2019-rl}. That
work is also closely related to what we have presented here, though its focus
is mainly on assurance of correctness properties that have a safety impact.
Additionally, the assurance approach there is \emph{intrusive} in the sense
that the \ac{ml} component being built is modified. In our case, assurance
quantification does not modify the \ac{ml} components.
\emph{Benchmarking} of uncertainty estimation
techniques~\cite{weiss-uncertainty-benchmarking} has also been investigated,
although mainly in the context of image classification. It is unclear if the
reported results translate to assurance quantification as applied in this paper.
However, the benchmarking principles and metrics used could be candidates for
evaluating various system models built using our approach.
Kalman filters have long been used to address uncertainty during state
estimation, and have some similarities to our approach. A Kalman filters is a
special case of a \ac{dbn} where amongst the main assumptions are that sensor
errors are distributed as zero mean Gaussians, and that the uncertainty does
not vary between sensing outputs. In contrast, our model uses discrete
distributions, admitting varying sensor uncertainty for each image input, in a
more general graphical model that has a different structure, whilst including
detections of \ac{ood} inputs.
\section{Conclusion and Future Work}\label{s:conclusions}
We have described our approach to quantifiable assurance using assurance
measures, run-time computations of uncertainty (conversely, confidence)
in specified assurance properties, and their application to \acfp{les}.
Assurance measures complement design-time assurance activities, each of which
forms part of an overall \acf{dac}.
In collaboration with system integrators from industry, we have applied
our framework to an aviation platform that employed supervised learning
using a deep \ac{cnn}. Collaboration was crucial to develop the
contingency management capability, which relied on engineering judgment
to tradeoff safety risk reduction and achieving performance objectives.
Feedback from the end-users (i.e.,\xspace our industry collaborators) was also essential
in refining the final visualizations of the assurance measure that we
ultimately deployed in the system (based on Fig.~\ref{f:uas-assurancemeasure}).
Those are intended to provide insight into the system assurance state
for safety observer crew.
We have shown that our methodology can feasibly quantify assurance in
system-level properties of an aviation domain \ac{les}, though we have
used classical \ac{uq} techniques.
Our work in quantifying assurance in \acp{les} is ongoing, and we will be
developing assurance measures for other autonomous platforms in the context of
more complex mission objectives that require additional \ac{ml} components and
learning schemes.
The work in this paper is one strand of our overall approach to assurance through \acp{dac}. The diverse components of an assurance case, including structured
arguments, safety architecture~\cite{dpw-ress2019}, as well as the assurance
measures described here, each represent one facet of an integrated \ac{dac}.
There are close connections between the probabilistic models underlying
assurance measures and the safety architecture, as well as between assurance
properties and claims in an assurance arguments. Our future work will
place these connections on a rigorous basis. In part, this can be achieved
through use of a high-level \emph{\acl{dsl}} (\acs{dsl}) that will let us
\begin{inparaenum}[\itshape i\upshape)]
\item abstract from the details of the individual probabilistic models, and
\item conversely, allow compilation into a range of different models,
whilst making more explicit the connections to domain concepts used
elsewhere in the assurance case.
\end{inparaenum}
A related avenue of future work is providing comprehensive assurance
for our approach itself, and in turn, the assurance measures produced. From a
verification standpoint, we can consider \emph{correctness} properties
entailing
\begin{inparaenum}[\itshape i\upshape)]
\item consistency between the quantification model and the other \ac{dac}
components, e.g.,\xspace the risk scenarios captured by a safety architecture, and
\item correctness of the low-level implementation against the higher level
specification embodied by the quantification model.
\end{inparaenum}
Additionally, assurance measure validity is related, in part, to the limits
of the statistical techniques used to infer the underpinning stochastic models,
and the data used to build them.
Indeed, one of the challenges we faced in this work was obtaining sufficient
useful data. Moreover, the quality of the data gathered also plays a key role
in corroborating that the assurance quantification models sufficiently represent
the system behavior across its intended operational profile. We believe that a
more principled approach to specifying a variety of training data should be
possible (e.g.,\xspace to include various types of perturbed and adversarial inputs),
and that such specifications could be derived from the \acs{dsl} used to specify
the assurance measures themselves.
The dynamic nature of \acfp{ac} will also bear further investigation,
to see how real-time updates provided by assurance measures during a mission
can inform updates between missions, to the qualitative arguments of \acp{ac}.
\bibliographystyle{ieee}
| {'timestamp': '2020-06-19T02:11:05', 'yymm': '2006', 'arxiv_id': '2006.10345', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10345'} | arxiv |
\section{Introduction}
Concept taxonomies play a central role in a
wide spectrum of applications. On a daily basis, e-commerce websites like
Amazon heavily rely on their product taxonomies to support billions of product
navigations, searches, and recommendations \cite{zhang2014taxonomy}; scientific taxonomies (\eg, MeSH\footnote{https://www.nlm.nih.gov/mesh/meshhome.html}) make it much faster to
identify relevant information from massive scientific papers, and concept
taxonomies in knowledge bases (\eg, Freebase \cite{bollacker2008freebase}) underpin many question answering systems
\cite{harabagiu2003open}.
Due to such importance, many taxonomies have been curated in general and specific domains, \eg,
WordNet \cite{miller1995wordnet}, Wikidata \cite{vrandevcic2012wikidata}, MeSH~\cite{lipscomb2000medical}, Amazon Product Taxonomy~\cite{karamanolakis2020txtract}.
One bottleneck of many existing taxonomies is the {\it low coverage problem}. This problem arises mainly due to two reasons. First, many existing taxonomies are curated by domain experts. As the curation process is expensive and time-consuming, the result taxonomies often include only frequent and coarse-grained terms. Consequently, the curated taxonomies have high precision, but limited coverage. Second, domain-specific knowledge is constantly growing in most applications.
New concepts arise continuously, but it is too tedious to rely on human
curation to maintain and update the existing taxonomies. The low
coverage issue can largely hurt the performance of downstream tasks, and
automated taxonomy expansion methods are in urgent need.
\begin{figure*}[t]
\centering
\includegraphics[width=0.95\textwidth]{figures/TEMP-overall.pdf}
\caption{Illustration of the taxonomy expansion problem. Given an existing
taxonomy, the task is to insert new concept terms (\eg, \textit{EMI}, \textit{stratospheric pollutant}, \textit{economic noise}, \textit{carcinogenic substance}) into the correct positions in the existing taxonomy.
}
\label{fig:temp_overall}
\end{figure*}
Existing taxonomy construction methods follow two lines. One line is to
construct taxonomies in an unsupervised way
\cite{zhang2018taxogen,panchenko2016taxi,liu2012automatic, wang2013phrase}. This
is achieved by hierarchical clustering \cite{zhang2018taxogen}, hierarchical topic
modeling \cite{liu2012automatic,wang2013phrase}, or syntactic patterns (\eg, the Hearst
pattern~\cite{hearst1992automatic}). The other line adopts supervised approaches
\cite{mao2018end,gupta2017taxonomy, kozareva2010semi}, which first detect
hypernymy pairs (\emph{i.e.}\xspace, term pairs with the ``\textit{is-a}'' relation) and then
organize these pairs into a tree structure. However, applying these methods for
taxonomy \emph{expansion} suffers from two limitations. First, most of them
attempt to construct taxonomies \emph{from scratch}. Their output taxonomies can
rarely preserve the initial taxonomy structures curated by domain experts.
Second, the performance of many methods relies on large amounts of annotated
hypernymy pairs, which can be expensive to obtain in practice.
We propose a self-supervised taxonomy expansion model named {\sf STEAM}\xspace\footnote{Short
for \textbf{S}elf-supervised \textbf{T}axonomy \textbf{E}xp\textbf{A}nsion with
\textbf{M}ini-Paths.}, which leverages natural supervision in the existing
taxonomy for expansion. To generate natural self-supervision signals, {\sf STEAM}\xspace
samples \emph{mini-paths} from the existing taxonomy, and formulates a node
attachment prediction task between mini-paths and query terms.
The
\emph{mini-paths}, which contain terms
in different layers (\eg ``\emph{Pollutant}''--``\emph{Atmospheric
Pollutant}''--``\emph{Dust}'' in Figure \ref{fig:temp_overall}), serve as
candidate \textit{anchors} for query terms and yield
many training \textit{query-anchor} pairs from the existing taxonomy. With these query-anchor pairs, we learn a model (Section
\ref{sect:minipath}) to
pinpoint the correct position for a query term in the mini-path.
Compared with previous
methods~\cite{shwartz2016improving,vedula2018enriching,shen2020taxoexpan}
using single anchor terms, {\sf STEAM}\xspace
better leverages the existing taxonomy since the mini-paths contain richer
structural information from different levels.
In cooperation with mini-path-based node attachment, {\sf STEAM}\xspace extracts features for
query-anchor pairs from multiple views, including: (1) \emph{distributed features} that capture the similarity between terms' distributed representations; (2) \emph{contextual features}, \emph{i.e.}\xspace information from two terms' co-occurring sentences; (3) \emph{lexico-syntactic features} extracted from the similarity of surface string names between terms.
We find that different views can provide
complementary information that is vital to taxonomy expansion.
To fuse the three views more effectively, we propose a multi-view
co-training procedure (Section \ref{sect:cotrain}). In this procedure, the three views lead to different
branches for predicting the positions of the query term, and the predictions
from these three views are encouraged to agree with each other.
We have conducted extensive experiments on three taxonomy construction benchmarks in different domains. The results show that {\sf STEAM}\xspace outperforms
state-of-the-art methods for taxonomy expansion by $11.6\%$ in accuracy and
$7.0\%$ in mean reciprocal rank. Moreover, ablation studies demonstrate the effect of mini-path for capturing structural information from the taxonomy, as well as the multi-view co-training for harnessing the complementary signals from all views.
Our main contributions are: 1) a self-supervised framework that performs
taxonomy expansion with natural supervision signals from existing taxonomies
and text corpora; 2) a mini-path-based anchor format that better captures
structural information in taxonomies for expansion; 3) a multi-view co-training
procedure that integrates multiple sources of information in an end-to-end
model; and 4) extensive experiments on several benchmarks verifying the efficacy of our method.
\section{Problem Description}
We focus on the taxonomy expansion task for \emph{term-level} taxonomies, which is formally defined as follows.
\begin{definition}[Taxonomy] { A taxonomy $\mathcal{T} = (\mathcal{V}, \mathcal{E})$ is a tree structure
where 1) $\mathcal{V}$ is a set of terms (words or phrases); and 2)
$\mathcal{E}$ is a set of edges representing \emph{is-a} relations between
terms. Each directed edge $\langle v_i, v_j\rangle \in \mathcal{E}$ represents a hypernymy
relation between term $v_i$ and term $v_j$, where $v_i$ is the hyponym (child)
and $v_j$ is the hypernym (parent).}
\end{definition}
The problem of taxonomy expansion (Figure \ref{fig:temp_overall}) is to enrich an initial taxonomy by inserting
new terms into it. These new terms are often automatically extracted and
filtered from a text corpus. Formally, we define the problem as below:
\begin{definition}[Taxonomy Expansion] Given 1) an existing taxonomy
$\mathcal{T}_{0} = (\mathcal{V}_0, \mathcal{E}_0)$, 2) a text corpus
$\mathcal{D}$, and 3) a set of candidate terms $\mathcal{C}$, the goal of
taxonomy expansion is to insert the term $q\in \mathcal{C}$ into the existing
taxonomy $\mathcal{T}_{0}$ and expand it into a more complete
taxonomy $\mathcal{T} = (\mathcal{V}, \mathcal{E} )$ where $\mathcal{V} = \mathcal{V}_{0}\cup \mathcal{C}, \mathcal{E} =\mathcal{E}_0 \cup \mathcal{R}$
with $\mathcal{R}$ being the newly discovered relations between terms in
$\mathcal{C}$ and $\mathcal{V}_0$. \end{definition}
\subsection{Self-Supervised Learning by Mini-Path Attachment}
\label{sect:minipath}
The central task of taxonomy expansion is to attach a query term $q \in \mathcal{C}$ into the
correct position in the existing taxonomy $\mathcal{T}_0$. {\sf STEAM}\xspace learns to attach query terms using \emph{natural} supervision signals from the seed taxonomy. Its self-supervised learning procedure aims to preserve the structure of the seed taxonomy by creating a learning task that pinpoints the anchor positions for the terms already seen in the seed taxonomy. The training data for this self-supervised learning task can be easily obtained from the seed taxonomy, thereby facilitating learning a model that performs query attaching at inference time.
\subsubsection{Query-Anchor Matching with Mini-Paths}
To instantiate the self-supervised learning paradigm~\cite{liang2020beyond,shen2020taxoexpan,tung2017self}, an intuitive idea is to
find the best hypernym for the query term $q$. Most existing works
~\cite{shen2020taxoexpan,vedula2018enriching,mao2018end} follow this idea and
model the taxonomy expansion problem as finding the optimal hypernym pairs for
test terms. They usually design a binary classifier trained by determining whether
$\langle p_i, p_j \rangle$ ($p_i, p_j
\in \mathcal{V}_0$) is a hypernymy pair.
Unlike the binary classification formulation, {\sf STEAM}\xspace learns to match query terms
with anchors with richer structural information. The core of {\sf STEAM}\xspace's
self-supervised learning procedure is \emph{mini-paths}, which are snippets
sampled from the seed taxonomy. These mini-paths, containing the term pairs
from different layers of taxonomy, can preserve the hierarchical relations
among different terms. Below, we introduce the notion of \emph{mini-path} and
formulate the self-supervised learning task based on mini-paths.
\begin{definition}[Mini-path]
A mini-path $P = [p_1, p_2, \ldots, p_{L} ]$ consists of several terms $\{p_1, p_2, \ldots, p_{L} \} \subset \mathcal{V}_{0}$, where $L$ is the length of $P$. Each term pair $\langle p_i, p_{i+1}\rangle \ (1\leq i \leq L-1)$ corresponds to an edge in $\mathcal{E}_{0}$.
\end{definition}
\begin{figure}[h]
\centering {\
\subfigure[An illustration of mini-paths.] {
\label{subfig:temp_train_a}
\includegraphics[width=0.45\textwidth]{figures/TEMP-process-A.pdf}
}
\subfigure[The classification target.] {
\label{subfig:temp_train_b}
\includegraphics[width=0.45\textwidth]{figures/TEMP-process-B.pdf}
}
}
\caption{An illustration of the proposed self-supervised data structure, including the construction of mini-paths and the learning target during the term-insertion process.}
\vspace{-3mm}
\label{fig:temp_train}
\end{figure}
The mini-paths are fixed-length branchless sub-graphs of the existing taxonomy $\mathcal{T}_0$, as shown in Figure~\ref{subfig:temp_train_a}, which maintain part of the parent-child relationships between terms.
To keep the hierarchical information in the taxonomy with the self-supervised training
set, we design the training task as a multi-class classification problem.
As shown in Figure \ref{subfig:temp_train_b}, given a 3-terms mini-path as \emph{anchor} and a new term as \emph{query}, {\sf STEAM}\xspace predicts the probabilities of the \emph{query} being attached to the three terms or none of them.
Compared with the simple task of binary hypernymy classification, matching
query terms with mini-paths has two major advantages: 1) When attaching a query
term $q$ into an anchor mini-path $P$, we consider the collection of all terms $p_i\inP$ as a whole, rather than attend to them separately.
This not only provides richer information for query attachment but also
results in larger training data for self-supervised learning.
2) Compared with
the binary classification, this task is more challenging---the matching module
needs to judge not only whether $q$ should be matched to $P$ but also which specific position to attach.
Learning from this more challenging self-supervised task allows {\sf STEAM}\xspace to better leverage the structural
information of the existing taxonomy and perform better for anchor term deduction and taxonomy expansion.
\subsubsection{Sampling Mini-Paths from the Seed Taxonomy}
To facilitate the learning problem, we need to sample mini-paths from the existing
taxonomies as anchors, as well as the query terms that should be attached
to different positions in anchor mini-paths. This can be achieved by randomly
sampling mini-paths in the seed taxonomy, along with positive and
negative query terms for each mini-path.
The detailed procedure for training data creation is described as follows.
Given one mini-path $P \in \mathcal{P}$ where $\mathcal{P}$ is the collection of all mini-paths in the existing taxonomy,
we first generate positive training set $\mathcal{X}^{\rm pos}$ by sampling all the child terms
$a_{i,l}\inA$ of $P \in \mathcal{P}$, where $a_{i,l}$ is the $i$-${\rm th}$ child of the $l$-${\rm th}$ anchor term $p_l\inP$ and $A$ contains all child terms attached to the mini-path, and a positive pair is represented as $X^{\rm pos}_{i,l} = \langle a_{i,l}, p_j, l \rangle$.
Once $\mathcal{X}^{\rm pos}$ is obtained, we augment the training set by adopting the negative sampling strategy to generate negative set $\mathcal{X}^{\rm neg}$ by randomly selecting $|\mathcal{X}^{\rm neg}| = r\times|\mathcal{X}^{\rm pos}|$ terms $\{n_i\}_{i=1}^{|\mathcal{X}^{\rm neg}|} $ with sampling ratio $r$, each constituting a negative pair with one term that is not its parent in a anchor.
Since these negative terms do not directly associate with the mini-path $P$, we assign a relative position $L+1$ for them to indicate no connection exists.
Combining $\mathcal{X}^{\rm pos}$ and $\mathcal{X}^{\rm neg}$ together we obtain the final training set $\mathcal{X}$.
After obtaining query-anchor pairs, we
need to learn a model using such data. Given the set of training
pairs $\mathcal{X}$, we denote each pair as $X = \langle q, P, l
\rangle \in \mathcal{X}$ where $q$ is the query term, $P$ is the
mini-path, and $y$ is the relative position and aim to learn a
model $f(q, P|\Theta)$ to identify the correct position
(represented by the true label $y$).
The training objective is to optimize the negative log likelihood
$
\ell = -\sum_X \sum_{i=1}^{L+1} y_i \log \hat{y_i}
$
where $\hat{y}$ is the predicted position.
\subsection{Multi-View Co-Training with Mini-Paths}
\label{sect:cotrain}
Now the question is how to obtain feature representations for each query-anchor
pair $(q, P)$. In {\sf STEAM}\xspace, we learn feature representations for query-anchor
pairs from three different views and integrate them with a multi-view
co-training procedure.
\subsubsection{Multi-View Feature Extraction}
{\sf STEAM}\xspace learns representations of query-anchor pairs from three views: (1)
\emph{the distributed representation view}, which captures their correlation
from pre-trained word embeddings; (2) \emph{the contextual relation view}, which
captures their correlation from the sentences where the query term and anchor
terms co-occur; and (3) \emph{the lexico-syntactic view}, which captures their
correlation from the linguistic similarities between the query and the anchor.
Each of the three views has its own advantages and disadvantages: (1)
\emph{Distributed features} have a high coverage over the term vocabulary, but
they do not explicitly model pair-wise relations between a query term and an
anchor term; (2) \emph{Contextual features} can capture the relation between two
terms from their co-occurred sentences, but have limited coverage over term
pairs. For example, only less than 15\% of hypernym pairs have co-occurred in
the scientific corpus of the SemEval dataset; (3) \emph{Lexico-Syntactic
features} encode linguistic information between terms and can work well for
matched term pairs, but these features are too rigid to cover all the linguistic
patterns, and may also have limited coverage.
Given a query term $q$ and an anchor mini-path $P = [p_1, p_2, \cdots, p_L]$,
we describe the details of how we learn representations for the query-anchor
pair $(q, P)$ from the three different views.
\para{(1) Distributed Features.}
The first view extracts distributed features
for both the query $q$ and the anchor mini-path $P$. For the query term $q$ and the anchor terms in the mini-path $P$, we
use pre-trained BERT embeddings~\cite{devlin2019bert} to initialize their
distributed representations due to its superior expressive power~\cite{jiang2019smart,liang2020bond}. While it is feasible to directly use such initial
embeddings for similarity computation, recent work \cite{shen2020taxoexpan}
shows that the neighboring terms of an anchor term are also useful for taxonomy
expansion. We follow \cite{shen2020taxoexpan} to use a position-enhanced graph attention
network (PGAT) to propagate the embeddings for the terms in the seed taxonomy by
considering the taxonomy as a directed graph---this
will lead to updated embeddings for the anchor terms in the mini-path $P$. For each anchor term $p_l \in P$, we use $\w(p_l)$ to denote
its PGAT-propagated embedding and use $\w(q)$ to denote the embedding of
the query term $q$, then we concatenate these embeddings and obtain the
distributed representation for the query-anchor pair $(q, P)$:
\begin{equation}
\h_{d}(q, P) = [ \w(q) \oplus \w(p_1) \oplus \cdots \oplus \w(p_L)].
\label{eq1}
\end{equation}
\para{(2) Contextual Features.} When two terms co-occur in the same sentence, the contexts of their co-occurrence can often indicate the relation of the two terms. Our second view thus harvests the sentences from the given corpus $D$ to extract features for the query term $q$ and the mini-path $P$.
Given the query term $q$ and any anchor term $p_l \in P$, we fetch all the sentences where $q$ and $p_l$ have co-occurred from corpus $D$. Similar to
\cite{shwartz2016improving}, we process these sentences to extract the
dependency paths between $q$ and $p_l$ in these sentences, denoted as $\mathcal{D}_{q,
p_l}$. For each dependency path ${d}_{q, p_l} \in \mathcal{D}_{q, p_l}$, it is a
sequence of context words that lead $q$ to $p_l$ in the dependency tree:
\begin{equation}
d_{q, p_l} = \{v_{e_1}, v_{e_2}, \cdots, v_{e_k} \},
\end{equation}
where $k$ is the length of the dependency path.
Each edge $v_e$ in the
dependency path contains 1) the connecting term $v_l$, 2) the part-of-speech tag of
the connecting term $v_{pos}$, 3) the dependency label $v_{dep}$, and 4) the edge
direction between two subsequent terms $v_{dir}$. Formally, each edge $v_e$ is
represented as: $v_e = [v_l, v_{pos}, v_{dep}, v_{dir}]$.
Now in order to encode each extracted dependency path $d_{q, p_l}$, we feed the
multi-variate sequence $d_{q, p_l}$ into an LSTM encoder. The representation
of the LSTM's last hidden layer, denoted as $\text{LSTM}(d_{q, p_l})$, is then used as the
representation the path $d_{q, p_l}$. As the set $\mathcal{D}(q, p_l)$ contains multiple
dependency paths between $q$ and $p_l$, we aggregate them with the attention
mechanism to compute the weighted average of these path representations:
\begin{equation}
\begin{aligned}
\hat{\alpha}_{d}& = \mathbf{u}^{T} \tanh \left(\mathbf{W} \cdot \text{LSTM}(d_{q, p_l})\right), \\
\alpha_d &=\frac{\exp \left( \hat\alpha_d\right)}{\sum_{d' \in \mathcal{D}_{q, p_l}} \exp \left(\hat\alpha_{d'}\right)},\\
\mathbf{d}(q, p_l)&= \sum_{d \in \mathcal{D}(q, p_l)} \alpha_{d} \cdot \text{LSTM}(d_{q, p_l}),\\
\end{aligned}
\end{equation}
where $\alpha_d$ denotes attention weight for the dependency path $d_{q, p_l}$; $\mathbf{W}, \mathbf{u}$ are
trainable weights for the attention network.
The final
contextual features between $q$ and $P$ is thus given by
\begin{equation}
\h_{c}(q, P) = [ \mathbf{d}(q, p_1) \oplus \cdots \oplus \mathbf{d}(q, p_L)].
\label{eq2}
\end{equation}
\para{(3) Lexical-Syntactic Features.} Our third view extracts
lexical-syntactic features between terms. Such features encode the correlations
between terms based on their surface string names and syntactic information
\cite{mao2018end,panchenko2016taxi,zhang2016learning}.
Given a term pair $(x,y)$, we extract the following lexical-syntactic features
between them:
\begin{itemize}[leftmargin=*]
\item \textbf{Ends with}: Identifies whether $y$ ends with $x$ or not.
\item \textbf{Contains}: Identifies whether $y$ contains $x$ or not.
\item \textbf{Suffix match}: Identifies whether the $k$-length suffixes of $x$ and $y$ match or not.
\item \textbf{LCS}: The length of longest common substring of term $x$ and $y$.
\item \textbf{Length Difference}: The normalized length difference between $x$ and $y$. Let the length of term $x$ and $y$ be $L(x)$ and $L(y)$, then the normalized length difference is calculated as $\frac{|L(x)-L(y)|}{\max \left(L(x), L(y)\right)}$.
\item \textbf{Normalized Frequency Difference}: The normalized frequency of $(x, y)$ in corpus $D$ with min-max normalization. Specifically, follow~\cite{gupta2017taxonomy}, we consider \textbf{two types of} normalized frequency based on the noisy hypernym pairs obtained in ~\cite{panchenko2016taxi}: (1) \emph{the normalized frequency difference}. Given a term pair $(x,y)$, their normalized frequency is defined as $nf(x,y) = \frac{freq(x, y)}{\max_{z \in \mathcal{V}}freq(x,z)}$ where $freq(x,y)$ defines the occurrence frequency between term $(x,y)$ in the hypernym pairs given by \cite{panchenko2016taxi} and $\mathcal{V} = \mathcal{V}_0 \cup \mathcal{C}$ which is all terms in the existing taxonomy and test set. Then the first normalize frequence difference is defined as $f(x,y) = nf(x,y)-nf(y,x)$. (2) \emph{the generality difference}. For term $x$, the normalized generality score $ng(x)= log(1+h)$, where $h$
is defined as the logarithm of the number of its distinct hyponyms. Then the generality difference of term pair $g(x,y)$ is defined as the difference in generality between $(x,y)$ as $g(x,y)=ng(x) - ng(y)$.
\end{itemize}
Given the query term $q$ and the mini-path $P = [p_1, p_2, \cdots, p_L]$, we
compute the lexico-syntactic features for each pair $(q,p_l)~(1 \le l \le
L)$, denoted as $\s(q, p_l)$ and concatenate the features derived from all
the term pairs as the lexical-syntactic features for $(q, P)$:
\begin{equation}
\h_{s}(q, P) = [ \s(q, p_1) \oplus \cdots \oplus \s(q, p_L)].
\label{eq3}
\end{equation}
\begin{figure*}
\centering
\includegraphics[width=0.95\textwidth]{figures/TEMP_model.pdf}
\caption{Illustration of the proposed co-training model architecture.
The grey terms in the existing taxonomy on the left is an anchor path to attach the new term to.
$L_1$, $L_2$ and $L_3$ corresponds to the log-likelihood loss and Euclidean loss calculated in Equation \eqref{eq:l1}, \eqref{eq:l2} and \eqref{eq:l3} respectively.
}
\vspace{-2mm}
\label{fig:temp}
\end{figure*}
\subsubsection{The Multi-View Co-Training Objective}
As the three views provide complementary information to each other, it is
important to aggregate the three views for the query-anchor matching.
To this end, one may simply stack three different sets of features and train one unified classifier~\cite{mao2018end}. However, such feature-level integration can lead to suboptimal results due to two reasons: (1) one view can provide dominant signals over the other two, making it hard to fully unleash the discriminative power of each view; (2) the three views can have different dimensionality and distributions, making learning a unified classifier from concatenated features difficult.
To more effectively harvest the information from the three different views, we propose a multi-view co-training procedure. This co-training procedure (see Figure \ref{fig:temp}) uses the three views to learn three different classifiers and then derives an aggregated classifier from the three classifiers and also encourages their predictions to be consistent.
The entire model can be trained in an end-to-end manner. Below, we first describe the base classifiers designed for the three different views, and then present the co-training objective.
\para{Base Classifiers from Multiple Views.} Based on three sets of feature
$\h_{d}, \h_{c}, \h_{s}$ derived from different views, we design three neural
classifiers for the query-anchor matching task, \emph{i.e.}\xspace, the multi-class
classification problem formulated in Section
\ref{sect:minipath}.
For each of the three views, we use a multi-layer perceptron (MLP) with one hidden layer
for this prediction task, denoted as $f_d$, $f_s$, and $f_r$.
Then the predictions from the three views are given by:\\
\begin{equation}
\begin{aligned}
\y^d &= f_d(\h_{d}) = \mathbf{W}_2^d (\sigma(\mathbf{W}_1^d\h_{d}+\mathbf{b}_1^d) + \mathbf{b}_2^d ), \\
\y^c &= f_c(\h_{c}) = \mathbf{W}_2^c (\sigma(\mathbf{W}_1^c\h_{c}+\mathbf{b}_1^c) + \mathbf{b}_2^c ),\\
\y^s &= f_c(\h_{s}) = \mathbf{W}_2^s (\sigma(\mathbf{W}_1^s\h_{s}+\mathbf{b}_1^s) + \mathbf{b}_2^s ),
\\
\end{aligned}
\label{eq:4}
\end{equation}
where $\{{\mathbf{W}}_{1}^{k}, {\mathbf{W}}_{2}^k, \mathbf{b}_1^k, {\mathbf{b}}_{2}^k \}$ $k \in \{d,s,c\}$ are
trainable parameters for the three MLP classifiers, and $\sigma(\cdot)$ is the
activation function for which we use ReLU in our experiments.
\para{The Co-Training Objective.} Figure~\ref{fig:temp} shows the co-training
model that integrates the three base classifiers. From the three base
classifiers $f_d$, $f_s$, and $f_r$, we design an aggregated
classifier for the final output. This aggregated classifier, which we denote as
$f_\text{agg}$, integrates the three base classifiers by averaging over their
predictions\footnote{We have also tried to use attention mechanism to aggregate the score but didn't see an obvious performance gain.}:
\begin{equation}
\y^\text{agg} = f_\text{agg} \left(\y^d, \y^c, \y^s \right)
= \text{softmax} \left(\frac{1}{3} \left(\y^d + \y^s + \y^r \right) \right).
\label{ref:agg}
\end{equation}
To jointly optimize the base classifiers as well as the aggregated classifier, we develop a co-training procedure that not only learns the classifiers to fit the self-supervised signals but also promotes consistency among these classifiers. The co-training objective involves three types of supervision, as detailed below.
The first loss $\ell_1$ is defines for the aggregated
classifier $f^\text{agg}$, which produces the final output. Let $\{(\x_i, {\y}_i\}_{i=1}^N$ be
the training dataset, where $\x_i$ is a query-anchor pair and ${\y}_i$ is
the label indicating the correct position of the query term in the anchor
mini-path. Then $\ell_1$ is defined as the negative log-likelihood loss:
\begin{equation}
\label{eq:l1}
\ell_{1}=-\sum_{i=1}^N \sum_{j=1}^C {\y}_{ij} \log \y_{ij}^\text{agg},
\end{equation}
where $C=L+1$ is the number of labels for query-anchor matching.
The second loss $\ell_2$ is defined for three base classifiers corresponding to
the three views:
\begin{equation}
\label{eq:l2}
\ell_{2}=-\sum_{u \in \{d,c,s\}} \sum_{i=1}^N \sum_{j=1}^C {\y}_{ij} \log \y_{ij}^u.
\end{equation}
The third loss $\ell_3$ is a
\emph{ consistency loss } that encourages the prediction results from different views to
agree with each other. We use L2-distance to measure the difference between the classifiers and define $\ell_3$ as:
\begin{equation}
\label{eq:l3}
\ell_{3}= \sum_{u, v \in \{d,s,r\}} \sum_{i=1}^N \left\|{\y}_i^u-{\y}_i^v\right\|^{2}.
\end{equation}
The overall objective of our model is then:
\begin{equation}
\ell = \ell_1 + \lambda \ell_2 + \mu \ell_3,
\label{eq:14}
\end{equation}
where $\lambda>0, \mu>0$ are two pre-defined balancing hyper-parameters.
\section{The {\sf STEAM}\xspace Method}
In this section, we describe our proposed method {\sf STEAM}\xspace. We first give an
overview of our method, and then detail the two key modules: mini-path-based
prediction and multi-view co-training. Finally, we discuss the model learning
and inference procedures.
\input{3.1minipath}
\input{3.2cotrain}
\subsection{Model Learning and Inference}
During training, we learn the model parameter $\Theta$ by
minimizing the total
loss $\ell$ using stochastic gradient optimizers such as Adam \cite{kingma2014adam}.
During inference, given a new query term $q \in \mathcal{C}$, we
traverse all the mini-paths $P \in \mathcal{P}$ and calculate the
scores for all anchor terms $p \in P$ based on the aggregated final
prediction score $y_{q, p}^{P}$ in Eq.~\eqref{ref:agg}.
Specifically, for any anchor term $\hat{p}$, we calculate its score of being the parent of query $q$ as
\begin{equation}
y_{\hat{p}}= \frac{1}{|\hat{\mathcal{P}}|}\sum_{P \in \hat{\mathcal{P}}}{y_{q, \hat{p}}^{P}},
\end{equation}
where $\hat{\mathcal{P}}$ is the set of mini-paths which contain term $\hat{p}$. Then, we
rank all anchor terms and select the term $p^*$ with the highest score as the predicted parent of the query $q$:
\begin{equation}
p^* = \arg\max_{p \in \mathcal{V}_0} y_{p}.
\end{equation}
\subsection{Complexity Analysis}
At the training stage, our model uses $|\mathcal{P}|$ training instances every epoch and thus scales linearly to the number of mini-paths in the existing taxonomy. From above we have listed the number of mini-paths in our training, and the number of such mini-paths is linear to $O(|\mathcal{V}_0|)$ (\emph{i.e.}\xspace the number of terms in the existing taxonomy). At the inference stage, for each query term, we calculate $L|\mathcal{P}|$ matching scores, where $L$ is the length of the mini-path. To accelerate the computation, we use GPU for matrix multiplication and pre-calculate distributional and lexico-syntactic features and store the dependency paths for faster evaluation.
\subsection{Experiment Setup}
\subsubsection{Datasets}
We evaluate the performance of our taxonomy construction method using three
public benchmarks. These datasets come from the shared task of taxonomy
construction in SemEval 2016 \cite{bordea2016semeval}. We use all the three
English datasets in SemEval 2016, which correspond to three human-curated
concept taxonomies from different domains: environment (EN), science (SCI), and
food (Food). The statistics of these three benchmarks are presented in table~\ref{tb:dataset}. For each taxonomy, we start from the root term and randomly grow in a
top-down manner until 80\% terms are covered. We use the randomly-growed
taxonomies as seed taxonomies for self-supervised learning, and the rest 20\%
terms as our test data.
Our {\sf STEAM}\xspace method and several baselines also require external text corpora to
model the semantic relations between concept terms.
\begin{table}[t]
\vspace{-2mm}
\centering
\caption{The statistics of the three datasets for evaluation.}
\renewcommand\tabcolsep{3.2pt}
\begin{tabular}{cccc}
\toprule
Dataset & Environment & Science & Food \\ \midrule
\# of Terms & 261 & 429 & 1486 \\
\# of Edges & 261 & 452 & 1576 \\
\# of Layers & 6 & 8 & 8 \\ \bottomrule
\end{tabular}
\label{tb:dataset}
\vspace{-2mm}
\end{table}
\subsubsection{Baselines}
We compare with the following baselines:
\begin{itemize}[leftmargin=*]
\item \textbf{TAXI}\footnote{\url{https://github.com/uhh-lt/taxi}} \cite{panchenko2016taxi} is a taxonomy induction method that reached the first place in the SemEval 2016 task. It first extracts hypernym pairs based on substrings and lexico-syntactic patterns with domain-specific corpora and then organizes these terms into a taxonomy.
\item \textbf{HypeNet}\footnote{\url{https://github.com/vered1986/HypeNET}} \cite{shwartz2016improving} is a strong hypernym extraction method, which uses an LSTM-CNN model to jointly model the distributional and relational information between term pairs.
\item \textbf{BERT+MLP} is a distributional method for hypernym detection based on pre-trained BERT embeddings. For each term pair, it first obtains term embeddings from a pre-trained BERT model, and then feeds them into a Multi-layer Perceptron to predict whether they have the hypernymy relationship\footnote{For combining term embeddings, we experimented with \textsc{Concat}, \textsc{Difference}, and \textsc{Sum} as different fusing functions and report the best performance.}.
\item \textbf{TaxoExpan}\footnote{\url{https://github.com/mickeystroller/TaxoExpan}} \cite{shen2020taxoexpan} is state-of-the-art
self-supervised method for taxonomy expansion. It adopts graph
neural networks to encode the positional information and
uses a linear layer to identify whether the candidate term is the parent of the query term. For a fair comparison, we also use BERT embeddings for TaxoExpan instead of the word embeddings as in the original paper.
\end{itemize}
\subsubsection{Variants of ~{{\sf STEAM}\xspace}}
We also compare with several variants of {\sf STEAM}\xspace to
evaluate the effectiveness of its different modules:
\textsc{Concat} directly concatenates the three features and feeds it into an MLP for prediction; \textsc{Concat-D} concatenates only the context and lexico-syntactic views; \textsc{Concat-C} concatenates the distributed and the lexico-syntactic features; \textsc{Concat-L} concatenates the distributed and the context features; \textbf{{\sf \textsc{STEAM-Co}}\xspace} directly uses the aggregated classifier for prediction instead of the co-training objective (\emph{i.e.}\xspace, $\lambda=\mu=0$); \textbf{{\sf \textsc{STEAM-D}}\xspace} co-trains without the distributed view; \textbf{{\sf \textsc{STEAM-C}}\xspace} co-trains without the contextual view and \textbf{{\sf \textsc{STEAM-L}}\xspace} co-trains without the lexico-syntactic view.
\subsubsection{Implementation Details}
All the baseline methods, except for BERT-MLP, are obtained from the code
published by the original authors. The others (BERT-MLP, our model, and its
variants) are all implemented in PyTorch.
When learning our model, we use the ADAM optimizer ~\cite{kingma2014adam} with
a learning rate of 1e-3. On all the three datasets, we train the model for 40
epochs as we observe the model has converged after 40 epochs. To prevent
overfitting, we used a dropout rate of 0.4 and a weight decay of 5e-4. For
encoding context features, we follow \cite{shwartz2016improving} and set the
dimensions for the POS-tag vector, dependency label vector, and edge direction
vector, to 4, 5, and 1, respectively; and set the dimension for hidden units in
the LSTM encoder to 200. For the three base MLP classifiers, we set the
dimensions of the hidden layers to 50. For sampling negative mini-paths, we set the size of negative samples $r=4$.
In the co-training module, there are
two key hyper-parameters: $\lambda$ and $\mu$ for controlling the strength for
training base classifiers and the consistency among classifiers. By default, we
set $\lambda=0.1, \mu=0.1$. We will study how these parameters affect the
performance of our model later.
\subsubsection{Evaluation Protocol}
At test time, pinpointing the correct parent for a query term is a ranking problem.
Specifically, given $n$ test samples, let us use $\{\hat{y}_1, \hat{y}_2, \cdots,
\hat{y}_n\}$ to denote their ground truth positions, $\{y_1, y_2, \cdots,
y_n\}$ to denote model predictions. Follow existing works~\cite{Manzoor2020expand,shen2020taxoexpan,vedula2018enriching}, we use multiple metrics as follows:\\
(1) \textbf{Accuracy (Acc)} measures the exact match accuracy for terms in the test set. It only counts the cases when the prediction equals to the ground truth, calculated as
$$\text{Acc} = \frac{1}{n}\sum_{i=1}^{n}\mathbb{I}(y_i=\hat{y}_i).$$ \\
(2) \textbf{Mean reciprocal rank (MRR)} is the average of reciprocal ranks of a query concept's true parent among all candidate terms. Specifically, it is calculated as
$$ \text{MRR} = \frac{1}{n}\sum_{i=1}^n \frac{1}{{rank}(y_{i})}.$$\\
(3) \textbf{Wu \& Palmer similarity (Wu\&P)} calculates the semantic similarity between the predicted parent term $y$ and the ground truth parent term $\hat{y}$ as
$$
\omega\left( \hat{y}, y \right) = \frac{2\times \text{depth}(\text{LCA}(\hat{y}, y))}{\text{depth}(\hat{y}) + \text{depth}(y)}
$$
where ``$\text{depth}(\cdot)$'' is the depth of a term in the taxonomy and ``$\text{LCA}(\cdot, \cdot)$'' is the least common ancestor of the input terms in the taxonomy. Then, the overall Wu\&P score is the mean Wu \& Palmer similarity for all terms in the test set written as $\text{Wu\&P} = \frac{1}{n}\sum_{i=1}^{n}\omega(y_i, \hat{y}_i)$.
\subsubsection{Comparison with baselines.}
\begin{small}
\begin{table}[t
\centering
\caption{Comparision of {\sf STEAM}\xspace against the baseline methods on the three datasets (in \%). To reduce the randomness, we ran all methods for three times and report the average performance. TAXI outputs an entire taxonomy instead of ranking lists, so we are unable to obtain the MRRs for it.
}
\renewcommand\tabcolsep{2.2pt}
\begin{tabular}{c| ccc| ccc| c c c}
\toprule
Dataset & \multicolumn{3}{c|}{\textbf{Environment}} &\multicolumn{3}{c|}{\textbf{Science}} & \multicolumn{3}{c}{\textbf{Food}}\\
\midrule
Metric & Acc & MRR & Wu\&P & Acc & MRR & Wu\&P & Acc & MRR & Wu\&P \\
\midrule
BERT+MLP & 11.1 & 21.5 & 47.9 & 11.5 & 15.7 & 43.6& 10.5 & 14.9&47.0 \\
TAXI & 16.7& -- & 44.7 & 13.0 & -- & 32.9 & 18.2 & -- & 39.2 \\
HypeNet & 16.7 & 23.7 & 55.8 & 15.4 & 22.6 & 50.7 & 20.5 & 27.3& 63.2 \\
TaxoExpan & 11.1 & 32.3 & 54.8 & 27.8 & 44.8 & 57.6 & 27.6 & 40.5 & 54.2 \\
{\sf STEAM}\xspace & \textbf{36.1} &\textbf{46.9} & \textbf{69.6} & \textbf{36.5} & \textbf{48.3} & \textbf{68.2} &\textbf{34.2} & \textbf{43.4} & \textbf{67.0}\\
\bottomrule
\end{tabular}
\label{tb:full_guidance_results}
\end{table}
\end{small}
Table \ref{tb:full_guidance_results} reports the performance of {\sf STEAM}\xspace and the
baseline methods on the three benchmarks. From the results, we have the
following observations:
\noindent $\bullet$ {\sf STEAM}\xspace consistently outperforms all the baselines by large
margins on the three datasets. In particular, {\sf STEAM}\xspace improves the performance of
the state-of-the-art TaxoExpan model by 11.6\%, 7.0\% and 9.4\% for Acc, MRR and
Wu\&P on average. Such improvements are mainly due to the mini-path-based
prediction and the multi-view co-training designs in {\sf STEAM}\xspace.
\noindent $\bullet$
Among the baselines, TaxoExpan achieves the strongest overall performance.
The key advantage of TaxoExpan compared with other baselines is that it
propagates the embeddings among neighbors in the taxonomy via graph neural
networks. From the results, we can see that embedding propagation is
effective in improving the MRR, making it achieve close MRRs with {\sf STEAM}\xspace.
However, TaxoExpan is largely outperformed by {\sf STEAM}\xspace in accuracy. This
phenomenon shows that while distributed features are useful for finding
relevant concepts, contextual and lexico-syntactic features are important
for pinpointing the exact hypernymy relationships.
\noindent $\bullet$
Pre-trained BERT embeddings have remarkable expressive power. However, BERT embeddings alone can yield limited
performance in the taxonomy expansion task since BERT does not well capture the contextual relations and between
terms. {\sf STEAM}\xspace is based on BERT embedding, but it integrates contextual and
pattern information, which are highly useful for improving the performance.
\noindent $\bullet$
TAXI underperforms other methods on all three datasets. The major
drawback of TAXI and other taxonomy construction methods is that they
fail to use self-supervision signals in the existing taxonomy. This
hinders them from learning the hierarchical and semantic information. Moreover, they simply use lexico-syntactic patterns and
neglect other distributional features, which is important for taxonomy
expansion.
\noindent $\bullet$
HypeNet outperforms BERT and TAXI since it combines the contextual and
distributed features. However, it neglects the structural information during
training and does not consider lexico-syntactic features, rendering it less
effective than {\sf STEAM}\xspace.
\subsubsection{Ablations Studies}
\begin{small}
\begin{table}[t
\centering
\caption{Overall results of all variants of our methods on three datasets (in \%).
}
\renewcommand\tabcolsep{2.2pt}
\begin{tabular}{c| ccc| ccc| c c c}
\toprule
Dataset & \multicolumn{3}{c|}{\textbf{Environment}} &\multicolumn{3}{c|}{\textbf{Science}} & \multicolumn{3}{c}{\textbf{Food}}\\
\midrule
Metric & Acc & MRR & Wu\&P & Acc & MRR & Wu\&P & Acc & MRR & Wu\&P \\
\midrule
\textsc{Concat}& 25.0 & 40.3 & 64.2 & 20.4 & 25.8 &51.1 & 15.5 & 23.8 &49.6\\
\textsc{Concat-D}& 30.6 & 38.6 & 63.7 & 11.1 & 20.1 & 48.1 & 23.1 & 28.9 &55.4\\
\textsc{Concat-C}& 27.7 & 37.4 & 57.8 & 13.5 & 25.7 & 53.3 & 25.3 & 31.2 &58.3\\
\textsc{Concat-L}& 11.1 & 31.4 & 57.7 & 13.5 & 23.7 & 39.1 & 8.30 & 13.4 &40.1\\
{\sf \textsc{STEAM-Co}}\xspace & 25.0 & 41.0 & 66.3 & 32.7 & 45.3 & 64.4 & 31.1 & 40.7 & 65.1 \\
{\sf \textsc{STEAM-D}}\xspace & 13.8& 32.0& 54.3 & 23.1&32.9& 60.0& 20.1 & 31.5 & 60.8 \\
{\sf \textsc{STEAM-C}}\xspace & 11.1 &26.8& 49.2 &32.7& 44.5& 67.2 & 19.3 & 29.7 & 59.3\\
{\sf \textsc{STEAM-L}}\xspace & 11.1& 27.5 & 51.6& 23.1& 36.5& 62.1 & 12.7 & 22.6 & 56.7\\
{\sf STEAM}\xspace & \textbf{36.1} &\textbf{46.9} & \textbf{69.6} & \textbf{36.5} & \textbf{48.3} & \textbf{68.2} &\textbf{34.2} & \textbf{43.4} & \textbf{67.0}\\
\bottomrule
\end{tabular}
\label{tb:full_guidance_result}
\end{table}
\end{small}
We perform ablation studies to study the effectiveness of the
different components in {\sf STEAM}\xspace: 1) mini-path-based self-supervised learning; 2)
the multi-view information; and 3) the co-training procedure.
\noindent \textbf{The Effect of Mini-Paths.} To study the effectiveness of
mini-path-based self-supervised expansion, we vary the length $L$ of mini-paths.
Note that, when $L=1$, the model is reduced to performing hypernymy prediction.
Figure \ref{fig:data} shows the performance of {\sf STEAM}\xspace on the three datasets when
$L$ varies. Generally, when $L$ is small, the performance of {\sf STEAM}\xspace stably
increases with $L$. Such results show that mini-paths can effectively capture
the structural information in the seed taxonomy---apart from the `parent' of the
query term, the grandparents and siblings contain additional information to
improve expansion performance. The mini-paths connect terms from different
layers of the taxonomy and carry such information to make the model pinpoint the
correct position. However, when $L$ increases from 3 to 4, we observe slight performance drops. This is because the size of the training data shrinks
for smaller taxonomies when $L$ becomes larger. Take the environment dataset as
an example: It contains 185 training samples when $L=3$ while 83 when $L=4$. As
a result, the final performance decreases by $3.2\%$ for accuracy.
\begin{figure}[t]
\centering
\subfigure[Environment]{
\includegraphics[width=0.146\textwidth]{figures/length/env_env-eps-converted-to.pdf}
\label{fig:App_usage}
}
\subfigure[Science]{
\includegraphics[width=0.146\textwidth]{figures/length/env_sci2-eps-converted-to.pdf}
\label{fig:App_loc}
}
\subfigure[Food]{
\includegraphics[width=0.146\textwidth]{figures/length/env_food2-eps-converted-to.pdf}
\label{fig:App_day}
}
\caption{The result for different length of mini-paths $L$ over three datasets.}\label{fig:data}
\end{figure}
\noindent \textbf{The Effect of Multi-view Information.} We study the
contributions of different views by comparing {\sf STEAM}\xspace with its variants ({\sf \textsc{STEAM-D}}\xspace,
{\sf \textsc{STEAM-C}}\xspace, {\sf \textsc{STEAM-L}}\xspace). Table \ref{tb:full_guidance_result} shows the results on the
three datasets. As shown, it is clear that all three types of features
contribute significantly to the overall performance. When eliminating one of the
three views, the average performance drops by 6.07\%, 8.10\% and 4.67\% for the
three metrics.
\noindent \textbf{The Effect of Co-training.} Now we proceed to study the
effectiveness of the co-training procedure. While integrating multiple views is
important, \emph{how} to integrate multi-view information is equally important.
From the results in Table \ref{tb:full_guidance_results}, one can see {\sf STEAM}\xspace
outperforms \textsc{Concat} by $15.3\%$, $16.2\%$ and $13.3\%$ for three
metrics on average. This verifies the effectiveness of co-training
compared with concatenation: the simple concatenation strategy cannot fully
harvest the information from each view and could make the learning problem more
difficult. Interestingly, the performance for \textsc{Concat} is even worse
than \textsc{Concat-D} and \textsc{Concat-C} in accuracy on Food and
Environment, which implies that simple concatenation can even hurt the
performance with more views.
The co-training objective in {\sf STEAM}\xspace involves two loss terms that encourage better learning of the base classifiers and the consistency among them. From
Table \ref{tb:full_guidance_results}, the performance gap between {\sf STEAM}\xspace and {\sf \textsc{STEAM-Co}}\xspace shows the effectiveness of these two terms. {\sf \textsc{STEAM-Co}}\xspace only uses the aggregated classifier for prediction and underperforms {\sf STEAM}\xspace by large margins.
The reason is that these terms explicitly require \emph{every} base classifier is sufficiently trained and mutually enhances each other; without them, certain views may not be fully leveraged, which limit the effectiveness in leveraging multi-view information for training.
\subsubsection{Parameter Studies}
In this subsection, we study the effects of different parameters on the
performance of {\sf STEAM}\xspace. We have already studied the effect of the path length in
the ablation study, now we study the effects of two key parameters in the
co-training procedure: 1) the weight of the prediction loss of the three base
classifiers $\lambda$, and 2) the weight of the consistency loss $\mu$. When
evaluating one parameter, we fix other parameters to their default values and
report the results. Due to the space limit, we only report the results on
parameters on Science dataset as the tends and findings are similar for the
three datasets.
\noindent \textbf{Effect of $\lambda$.} Figure \ref{fig:lambda} shows the
effect of $\lambda$ on the Science dataset. We can observe that as $\lambda$
increases, the performance improves for all three metrics. This is because
larger $\lambda$ will add more weight to learning base classifiers and enforce
each base classifier to achieve good prediction performance. As the base
classifiers become stronger, the derived aggregated classifier can also become
stronger. However, when $\lambda \geq 0.15$, the performance decreases with
$\lambda$. We suspect the reason is each single view can be one-sided and noisy
to yield biased predictions, when $\lambda$ is too large, the biased
information from each single view can no longer be effectively eliminated
during integration, which can hurt the overall performance.
\noindent \textbf{Effect of $\mu$.} Figure \ref{fig:mu} shows the effect of
$\mu$. Similarly, as $\mu$ increases, the performance of {\sf STEAM}\xspace first increases
and then decreases when $\mu$ is too large. The reason for this phenomenon is
that: 1) when $\mu$ is too small, the three models cannot regularize each other
well, which hinders them from sharing the result with others; 2) when the $\mu$ is too large, then the output will be close to optimizing Equation \ref{eq:14}.
When one model does not perform well, it will negatively affect the other two models, which will deteriorate the performance of the overall model.
\begin{figure}[t]
\vspace{-2mm}
\centering
\subfigure[$\lambda$]{
\includegraphics[width=0.222\textwidth]{figures/lambda2.pdf}
\label{fig:lambda}
}
\subfigure[$\mu$]{
\includegraphics[width=0.222\textwidth]{figures/mu2.pdf}
\label{fig:mu}
}
\vspace{-1ex}
\caption{The performance of our model when varying different parameters.}\label{fig:param}
\end{figure}
\section{Experiments}
\vspace{-1mm}
In this section, we evaluate the empirical performance of our proposed {\sf STEAM}\xspace
method. Our experiments are designed to answer the following three research
questions:
\begin{itemize}[leftmargin=*]
\item \textbf{RQ1}: How well does {\sf STEAM}\xspace perform for the taxonomy expansion
task compared with state-of-the-art methods?
\item \textbf{RQ2}: How effective are the two key components in {\sf STEAM}\xspace:
mini-path-based prediction and multi-view co-training?
\item \textbf{RQ3}: What are the effects of different parameters on the performance of {\sf STEAM}\xspace?
\end{itemize}
\input{4.1setup}
\subsection{Experimental Results}
\input{4.2expcomp}
\input{4.3ablation}
\input{4.4parameter}
\subsection{Case Studies and Error Analysis}
\begin{figure}[t]
\centering
\includegraphics[width=0.48\textwidth]{figures/taxo.pdf}
\vspace{-0.1in}
\caption{Prediction result for several test terms from different datasets.}
\vspace{-0.1in}
\label{fig:case}
\end{figure}
Figure \ref{fig:case} shows multiple cases to illustrate the efficacy of {\sf STEAM}\xspace.
It reports the final prediction score of {\sf STEAM}\xspace for the ground-truth parent, as
well as the prediction scores from the three base classifiers. Based on the
scores, we calculate the rank of the ground truth parent. From
Figure~\ref{fig:case}(a), (b), we can find that there are cases when the
predictions from all the three views are inadequate, but the final prediction
can integrate the weak signals to rank the ground-truth to the top. Such cases
verify the power of multi-view co-training in {\sf STEAM}\xspace, which can utilize the
complementary signals from all views and improve the final performance. Besides, Figure~\ref{fig:case}(c), (d) shows two cases when the predictions
of one specific view are poor (\eg Distributed view for term \texttt{Whale
Marine}), yet {\sf STEAM}\xspace can rectify the mistakes by leveraging the information from
the other two views.
Figure~\ref{fig:case}(e) and (f) show two random examples on which our model
fails to provide the correct predictions. Through in-depth analysis, we found
that one common case when our model cannot perform well is that all views
cannot make accurate predictions. In such cases, the information from the three
views is insufficient to capture the hypernymy relationships between the test
term and its parent.
\section{Related Work}
\vspace{0.5ex}
\noindent
\textbf{Taxonomy Construction.}
There have been many studies on automatic taxonomy construction. One line of
works constructs taxonomies using cluster-based methods. They group terms into a
hierarchy based on hierarchical clustering \cite{alfarone2015unsupervised, zhang2018taxogen,shang2020nettaxo} or topic models \cite{liu2012automatic, downey2015efficient}.
These methods can work in an unsupervised way. However, they cannot be applied
to our taxonomy expansion problem, because they construct \emph{topic-level}
taxonomies where each node is a collection of topic-indicative terms instead of
single terms. More relevant to our work are the methods developed for
constructing \emph{term-level} taxonomies. Focused on taxonomy induction,
these methods organize hypernymy pairs into taxonomies. Graph optimization
techniques \cite{kozareva2010semi,gupta2017taxonomy,bansal2014structured,cocos2018comparing} have
been proposed to organize the hypernymy graph into a hierarchical structure,
and~\citeauthor{mao2018end}~\cite{mao2018end} utilize reinforcement learning
to organize term pairs by optimizing a holistic tree metric over the training
taxonomies. Very recently, \citeauthor{chao2020-g2t}~\cite{chao2020-g2t}~design a transfer framework to use the knowledge from existing domains for generating taxonomy for a new domain.
However, all these methods attempt to construct taxonomies
\emph{from scratch} and cannot preserve the structure of the seed
taxonomy.
\vspace{0.5ex}
\noindent
\textbf{Hypernymy Detection.}
Hypernym detection aims at identifying hypernym-hyponym pairs,
which is essential to taxonomy construction.
Existing methods for hypernymy detection mainly fall into two
categories: \emph{pattern-based} methods and \emph{distributed} methods.
\emph{Pattern-based} methods extract hypernymy pairs via
pre-defined lexico-syntactic patterns \cite{hearst1992automatic, panchenko2016taxi,roller2018hearst}. One prominent work in this branch is the
Hearst patterns~\cite{hearst1992automatic}, which extract hypernymy pairs based
on a set of hand-crafted \textit{is-a} patterns (\eg, ``X is a Y'').
Pattern-based methods achieve good
precision, but they suffer from low recall \cite{wu2012probase} and are prone to
idiomatic expressions and parsing errors \cite{kozareva2008semantic}.
\emph{Distributed} methods detect hypernymy pairs based on the
distributed representations (\eg word embeddings \cite{mikolov2013distributed,pennington2014glove,devlin2019bert}) of terms.
For a term pair \emph{$\langle
x,y\rangle$}, their embeddings are used for learning a binary classifier to predict whether it has the hypernymy relation
\cite{baroni2012entailment,fu2014learning,chang2018distributional,shi2019discovering}. As embeddings are directly learned from the corpora, distributed methods eliminate
the needs of designing hand-crafted patterns and have shown strong performance.
However, their performance relies on a sufficient amount of labeled term pairs,
which can be expensive to obtain.
\vspace{0.5ex} \noindent \textbf{Taxonomy Expansion.} Taxonomy expansion is less
studied than taxonomy construction. Most existing works on taxonomy expansion
aims to find new \emph{is-a} relations and insert new terms to their hypernyms.
For example, \citeauthor{aly2019every}~\cite{aly2019every} refine existing taxonomy by
adopting hyperbolic embeddings \cite{nickel2017poincare} to better capture
hierarchical lexical-semantic relationships,~\cite{vedula2018enriching,shen2018hiexpan} design various semantic patterns to determine the position to attach new concepts for expanding taxonomies, and \citeauthor{fauceglia2019automatic}~\cite{fauceglia2019automatic} use a hybrid method to take advantage of linguistic patterns, semantic web and neural
networks for taxonomy expansion. However, the above methods only model the `parent-child' relations and fail to capture the global structure of the existing taxonomy.
To better exploit self-supervision signals, \citeauthor{Manzoor2020expand}~\cite{Manzoor2020expand} study expanding
taxonomies by jointly learning latent representations for edge semantics and
taxonomy concepts. Recently,
\citeauthor{shen2020taxoexpan}~\cite{shen2020taxoexpan} propose position-enhanced graph neural networks to encode the relative position of terms
and improve the overall quality of taxonomy.
However, the above two approaches only consider distributional features such as word embeddings but neglect other types of relationships among terms.
Compared with these methods, {\sf STEAM}\xspace is novel in two aspects. \emph{First}, it inserts new terms with mini-path-based classification instead of simple hypernym attachment, which models different layers to better preserve the holistic structure. \emph{Second}, it considers multiple
sources of features for expansion and integrates them with a multi-view co-training procedure.
\section{Conclusion}
We proposed {\sf STEAM}\xspace, a self-supervised learning framework with novel
mini-path-based prediction and a multi-view co-training objective. The
self-supervised learning nature enables our model to optimize the utilization
of the knowledge in the existing taxonomy without labeling efforts. Compared
with the traditional node-to-node \textit{query-anchor} pairs, the adoption of
mini-paths captures more structural information thus facilitates the inference
of a query's attachment position. The multi-view co-training objective
effectively integrates information from multiple input sources, including
PGAT-propagated word embeddings, LSTM-embedded dependency paths and
lexico-syntactic patterns. Comprehensive experiments on three benchmarks show
that {\sf STEAM}\xspace consistently outperforms all baseline models by large margins, which
demonstrates its superiority for taxonomy expansion.
\section*{Appendix}
\clearpage
\begin{appendix}
\section*{Acknowledgement}
This work was in part supported by the National Science Foundation award IIS-1418511, CCF-1533768 and IIS-1838042, the National Institute of Health award 1R01MD011682-01 and R56HL138415.
\section*{Appendix--External Sources of Corpus}
{\sf STEAM}\xspace (our method) and several baselines require external text corpora to
model the semantic relations between concept terms.
For all the three
benchmarks, we collect the following public corpora: 1) the Wikipedia
dump\footnote{We use the 20190801 version of wikidump during our experiments.},
2) the UMBC web-based
corpus\footnote{https://ebiquity.umbc.edu/resource/html/id/351}; 3) the One
Billion Word Language Modeling
Benchmark\footnote{https://www.statmt.org/lm-benchmark/}.
We directly match the terms with the corpus with tools available online (\emph{i.e.}\xspace WikiExtractor\footnote{https://github.com/attardi/wikiextractor}) and only preserve the sentences that term pairs co-occur. In this way, for each dataset, we obtain a tailored corpus which preserves the co-occurrence between terms. The information for these corpora are summarized as:
\noindent $\bullet$ \textbf{Environment}: The corpus size is 824MB with 1.51M sentences.
\noindent $\bullet$ \textbf{Science}: The corpus size is 1.36GB with 2.07M sentences.
\noindent $\bullet$ \textbf{Food}: The corpus size is 2.00GB with 3.42M sentences.
\bibliographystyle{ACM-Reference-Format}
| {'timestamp': '2020-06-19T02:06:34', 'yymm': '2006', 'arxiv_id': '2006.10217', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10217'} | arxiv |
\section{Introduction}
As one of the largest B2C e-commerce platforms in China,
JD.com also powers a leading advertising system,
serving millions of advertisers with
fingertip connection to hundreds of millions of customers.
Every day, customers visit JD,
click ads and leave billions of interaction logs.
These data not only feed the learning system, but also boost technique revolutions that keep lifting both user experience and advertisers' profits on JD.com.
In the commonly used cost-per-click (CPC) advertising system, ads are ranked by effective cost per mile (eCPM),
the product of bid price given by advertisers and the CTR predicted by the ad system.
Accurate CTR prediction benefits both business effectiveness and user experience. Thus, this topic has attracted widespread interest in both machine learning academia and e-commerce industry.
\if 0
Click through rate(CTR) prediction is a wildly used technique in e-commerce advertising systems.
In the most common case of cost-per-click(CPC) billing, advertisements are ranked by effective cost per mile(eCPM), which is the product of bid price given by advertisers and CTR given by the system.
Since accurate CTR prediction benefits both business effectiveness and user experience, this topic has attracted widespread interest in both machine learning academia and e-commerce industry.
\fi
Nowadays, most of the ads on e-commerce platforms are displayed with images, since they are more visually appealing and convey more details compared to textual descriptions.
An interesting observation is that many ads get significantly higher CTR by only switching to more attractive images.
This motivates a variety of emerging studies on extracting expressive visual features for CTR prediction \cite{chen2016deep,mo2015image}.
These algorithms adopt various \textit{off-the-shelf} CNNs to extract visual features and fuse them with non-visual features (e.g. \textbf{Category}, user) for the final CTR prediction.
With the additional visual features, these algorithms significantly outperform their non-visual counterparts in \textit{offline}-experiments and generalize well to
\textit{cold} and \textit{long-tailed} ads.
Although encouraging progress has been made in offline studies, applying CNN in real online advertising systems remains non-trival.
The offline end-to-end training with CNN must be efficient enough to follow the time-varying online distribution, and the online serving needs to meet the low latency requirements of advertising system.
Furthermore, we notice that visual feature extraction in e-commerce is significantly different from the image classification setting where off-the-shelf CNNs were originally proposed.
In classification, categories are regarded as the target to predict. While in e-commerce,
categories of ads are clearly labeled,
which contain abundant visual priors and will intuitively help visual modeling.
Some academic studies have integrated the categorical information by building category-specific projecting matrix on top of the CNN embeddings \cite{he2016sherlock} and by
explicitly decomposing visual features into styles and categories \cite{liu2017deepstyle}.
These studies share a common architecture: the \textbf{late fusion} of visual and categorical knowledge, which however, is sub-optimal for CTR prediction.
Namely, the image embedding modules seldom take advantage of the categorical knowledge.
Unaware of the ad category, the embedding extracted by these CNNs may contain unnecessary features not related to this category, wasting CNN's limited expression ability.
In contrast, if the ad category is integrated, CNN only needs to focus on the category-specific patterns, which will ease the training process.
To overcome the industrial challenges, we build optimized infrastructure for both
efficient end-to-end CNN training and low
latency online servicing.
Base on this efficient infrastructure, we propose \textbf{Category-specific CNN} (CSCNN) specially for the CTR prediction task, to fully utilize the labeled categories in e-commerce.
Our key idea is to incorporate the ad category knowledge into the CNN in an \textbf{early-fusion} manner.
Inspired by the SE-net \cite{hu2018squeeze} and CBAM \cite{woo2018cbam} which model the inter-dependencies between convolutional features with a light-weighted self-attention module, CSCNN further incorporates the ad category knowledge and performs a category-specific feature recalibration, as shown in Fig. \ref{frame}.
More clearly, we sequentially apply category-specific channel and spatial attention modules to emphasize features that are both important and category related. These expressive visual features contribute to significant performance gain in the CTR prediction problem.
In summary, we make the following contributions:
\begin{itemize}
\item To the best of our knowledge, we are the first to high-light the negative impact of \textbf{late fusion} of visual and non-visual features in visual-aware CTR prediction.
\item We propose CSCNN, a novel visual embedding module specially for CTR prediction. The key idea is to conduct category-specific channel and spatial self-attention to emphasize features that are both important and category related.
\item We validate the effectiveness of CSCNN through extensive offline experiments and Online A/B test. We verify that the performance of various self-attention mechanisms and network backbones are consistently improved by plugging CSCNN.
\item We build highly efficient
infrastructure to apply CNN in the real online e-commerce advertising system.
Effective acceleration
methods are introduced to
accomplish
the end-to-end training with CNN on the
10 billion scale
real production dataset within 24 hours,
and meet the low latency requirements of online system (20ms on CPU).
CSCNN has now been deployed in the search advertising system of JD.com, one of the largest B2C e-commerce platform in China, serving the main traffic of hundreds of millions of active users.
\end{itemize}
\if 0
However, image modeling in search advertising CTR prediction remains challenging and non-trivial. In this problem, the core task is to rank search results from the same query. Due to the relevance control of the search engine, these results often belong to the same category and are visually similar.
Visual feature extractors need to model the subtle \textit{intra-category} variations to help the \textit{intra-query} ranking.
Most of the aforementioned approaches share a \textbf{late-fusion} architecture: the visual and non-visual features are extracted independently.
Unaware of the product category, these visual feature extractors need to have the ability to extract patterns for distinguishing \textit{intra-category} variations of this category, \textit{intra-category} variations of other categories and \textit{inter-category} variations, see Fig. \ref{new}.
On one hand, these approaches waste the limited expression ability of the model and are likely to be inferior in \textit{intra-category} discrimination.
On the other hand, through additionally modeling the two variations, these \textit{late-fusion} architectures increase the complexity, making the visual feature extractor more difficult to learn.
We thus conjecture that state-of-the-art CTR predictors could be further improved if non-visual features, at least the category, are used in the image embedding module.
\fi
\if 0
Despite being extensively studied, most of the existing CTR prediction models share a common architecture: the \textit{late fusion} of visual and non-visual features, which however, is not suitable for search advertising.
On one hand, the core task of search advertising is to rank search results from the same search query. Naturally, it is the subtle \textit{intra-category} variance between search results under the same query that actually affects the click through.
On the other hand, with late fusion architectures, existing image embedding modules seldom take advantage of the knowledge in non-visual features, e.g. product \textit{Category}. Unaware of the product category, these image embedding modules may not catch the intra-category variance needed for the CTR prediction in search advertising. Furthermore,
the intra-category variance we wish to catch largely depends on the category itself. Or in other words,
the factors that determine the click through in each specific category may differ a lot.
We thus conjecture that state-of-the-art CTR predictors for search advertising could be further improved if non-visual features, at least the category, are incorporated in the embedding module.
\fi
\if 0
Despite being extensively studied, most of the existing CTR prediction models
adopt a \textit{late fusion} of visual and non-visual features, which however, is suboptimal for search advertising.
Specifically, the image embedding modules seldom take advantage of the knowledge in non-visual features, e.g. product \textit{Category}.
This is because these embedding modules are mostly borrowed from classification models, where category is regarded as the label to predict rather than a feature.
While embedding modules from classification promote \textit{inter-category} variance,
the search results to rank in a search advertising system are all drawn from the same query and thus all in the same category.
It is the subtle \textit{intra-category} variance that actually affect the click through.
Unfortunately, this intra-category variance may not be caught by the improperly borrowed embedding modules, since they are unaware of the product category.
Actually, the intra-category variance we wish to catch largely depends on the category itself.
In each category, there are specific factors that determine the click through.
We thus conjecture that state-of-the-art CTR predictors could be further improved if non-visual features, at least the category, are used in the embedding module.
\fi
\if 0
We proposed \textit{Category-specific CNN} (CSCNN), specially designed to solve the \textit{intra-query} ranking problem for search advertising.
Our key idea is to early incorporate the product category knowledge into the ad image embedding module through a simple yet effective attention mechanism.
Inspired by the SE-Net \cite{hu2018squeeze} and CBAM \cite{woo2018cbam} which explicitly models the inter-dependencies between between convolutional features, our CSCNN further incorporates the product category knowledge into the ad image embedding module and perform a category-specific feature recalibration.
Compared to conventional CTR predictors with late fusion of visual and non-visual features, our CSCNN enjoys several advantages. First, our image embedding module focuses on the key visual features that affect the CTR of ads from the category specified by the search query. Second, we released the expression ability and enhance intra-category variance within search results under the same query.
Third, as the problem reduced to a specific category, the embedding module is easier to learn and converges much faster.
\fi
\if 0
In summary, we make the following contributions:
\begin{itemize}
\item To the best of our knowledge, we are the first to high-light the negative impact of late fusion of visual and non-visual features in visual personalized ranking
\item We propose CSCNN, a novel visual embedding module that apply category-specific channel and spatial self-attention modules to emphasize features that are both important and category related.
\item We validate the effectiveness of CSCNN through extensive offline and online experiments. We verify that the performance of various self-attention mechanisms and network backbones are consistently improved by plugging our \textit{Category-specific} module.
\item Efficient methods are introduced to accelerate training on the industrial dataset(10 billion instances within 24 hours) and meet the low latency requirements of online system(20ms on CPU). CSCNN is deployed in a leading e-commerce website, serving the main traffic of hundreds of millions of active users.
\end{itemize}
\fi
\begin{figure}[t]\begin{center}
\includegraphics[width=7.3 cm]{arch.pdf}\end{center}
\caption{
The Architecture of our CTR Prediction System.
Bottom left: the proposed CSCNN, which embeds an ad image together with its category, to a visual feature vector $\mathbf x_{v}\in \mathbb R^{150}$. Note that CSCNN only runs offline. While in the online serving system, to meet the low latency requirement, we use an efficient lookup table instead.
Bottom right: non-visual feature embedding, from (ad, user, contexts) to a non-visual feature vector $\mathbf x_{nv}\in \mathbb R^{380}$.
Top: The main architecture, a modified DCN, which takes both the visual feature $\mathbf x_{v}$ and the non-visual feature $\mathbf x_{nv}$ as inputs.
}\label{arch}
\end{figure}
\section{Related Work}
Our work is closely related to two active research areas: CTR prediction and attention mechanism in CNN.
\subsection{CTR Prediction}
The aim of CTR prediction is to predict the probability that
a user clicks an ad given certain contexts. Accurate CTR prediction benefits both user experience and advertiser's profits thus is of crucial importance to the e-commerce industry.
Pioneer works in CTR or user preference prediction are based on linear regression (LR) \cite{mcmahan2013ad},
matrix factorization (MF) \cite{wang2013online} and decision trees \cite{he2014practical}.
Recent years have witnessed many successful applications of deep learning in CTR prediction
\cite{cheng2016wide,wang2017deep}.
Early works usually only make use of non-visual features, which however, is insufficient nowadays.
Currently, most ads are displayed with images which contain plentiful visual details and largely affect users' preference. This motivates many emerging studies on visual aware CTR prediction \cite{chen2016deep,he2016vbpr,kang2017visually,he2016sherlock,liu2017deepstyle,yang2019learning,zhao2019you}.
They first extract visual features using various off-the-shelf CNNs, and then
fuse the visual features with non-visual features including categories, to build the preference predictor. Unfortunately,
this late fusion is actually sub-optimal or even a waste in e-commerce scenario, where categories are clearly labeled and contain abundant visual priors that may somehow help visual feature extraction.
In contrast to existing works with late fusion, CSCNN differs fundamentally in early incorporating categorical knowledge into the convolutional layers,
allowing easy category-specific inter-channel and inter-spatial dependency learning.
\if 0
Our work is closely related to two active research areas:
personalized ranking and attention mechanism in CNN.
\subsection{Personalized Ranking}
Personalized Ranking \cite{zhang2019deep} aims to predict the preference of a \textit{user} to a set of \textit{items}, under given \textit{contexts}, based on historical user-item interaction records such as clicking, purchase and rating. Accurate personalized ranking benefits both user experience and business revenue and thus is of crucial importance to many applications in e-commerce industry, such as recommendation system, ad displaying and personalized search ranking.
Matrix Factorization (MF) based algorithms have achieved remarkable success in personalized ranking \cite{koren2009matrix,wang2013online}.
Early works usually only make use of non-visual features \cite{rendle2009bpr}, which however, is insufficient nowadays.
Currently, most items are displayed with images, which contain plentiful visual details and largely affect users' preference. This motivates many emerging studies on visual aware personalized ranking \cite{he2016vbpr,kang2017visually,he2016sherlock,liu2017deepstyle}.
They first extract visual features using various off-the-shelf CNNs, and then
fuse the visual features with non-visual features including categories, to build the preference predictor. Unfortunately,
this late fusion is actually sub-optimal or even a waste in e-commerce scenario, where categories are clearly labeled and contain abundant visual priors that may somehow help visual feature extraction.
In contrast to existing works with late fusion, our CSCNN differs fundamentally in early incorporating categorical knowledge into the convolutional layers. Specifically, categorical knowledge is integrated to
the self-attention modules after convolution, allowing easy category-specific inter-channel and inter-spatial dependency learning.
\fi
\begin{table}
\caption{Important Notations Used in Section 3}\label{notations}
\begin{center}
\begin{tabular}{ll|ll|ll}
\hline
$y$&class label & $\sigma$ &sigmoid &$\hat y$ & predicted CTR \\
$\mathcal D$&dateset & $\mathbb R$ & real number set &$d$& feature dimension\\
$\ell$&loss&$\mathbf x$&feature vector & $f$ & prediction function\\
\hline
\end{tabular}
\begin{tabular}{ll|ll}
$l$&layer index& $\mathbf x_{nv}$& non-visual features\\
$\mathbf h$&hidden layer & $\mathbf x_{v}$& visual features\\
$\mathbf z$ & cross layer & $\mathbf w, \mathbf b$& cross layer parameter \\
$[]$&concatenation &$d_e$ & embedding dimension\\
$\mathbf x_\text{emb}$ &embedded feature & $E$ & embedding dictionary\\
$v$& vocabulary size &$\mathbf x_\text{hot}$& one/multi hot coding\\
\hline
$m$&ad image& $k$& ad category \\
$L$ &\# layers & $\mathbf A_s,\mathbf A_s'$ & spatial category prior\\
$C$ & \# channels & $\mathbf A_c$ & channel category prior \\
$W$ &width &$\mathcal K$ & category set\\
$H$& height & $\mathbf F$ & original feature map \\
$\mathbf M_s, \mathbf M_c$&attention map & $\mathbf F',\mathbf F''$ & refined feature map\\
$H',W',C'$ & size of $\mathbf A_s',\mathbf A_c$& $\odot $ &element-wise product\\
\hline
\end{tabular}\end{center}
\end{table}
\subsection{Attention Mechanism in CNN}
Attention mechanism is an important feature selection approach that
helps CNN to emphasize important parts of feature maps and suppress unimportant ones.
Spatial attention tells \textit{where} \cite{woo2018cbam} and channel-wise attention tells \textit{what} to focus on \cite{hu2018squeeze}.
In literature, many works have attempted to learn the attention weights from the feature map, termed \textit{self-attention}.
State-of-the-art algorithms include CBAM \cite{woo2018cbam}, SE \cite{hu2018squeeze} among others \cite{hu2018gather,gao2019global}.
Besides self attention, the attention weights can also be conditioned on external information, for example nature language.
Successful application fields include
search by language \cite{li2017person},
image captioning \cite{xu2015show,chen2017sca}
and visual question answering \cite{yang2016stacked}.
Our work is motivated by the attention mechanism. Rather than vision \& language, we design novel architectures to adapt attention mechanism to
address an important but long overlooked issue, the sub-optimal late fusion of vision and non-vision features in CTR prediction.
We combine the advantages of both self-attention and attention conditioned on external information, namely the ad category.
As a result, our image embedding is able to emphasize features that are both important and category related.
\if 0
In contrast to existing works with late fusion, our CSCNN differs fundamentally in early incorporating categorical knowledge into the convolutional layers. Specifically, categorical knowledge is integrated to
attention modules of convolutional layers, allowing easy category-specific inter-channel and inter-spatial dependency learning.
\subsection{Attention Mechanism}
Attention mechanism is an important feature selection approach that
helps CNN to emphasize important parts of feature maps and suppress unimportant ones.
Spatial attention tells \textit{where} \cite{woo2018cbam} and channel-wise attention tells \textit{what} to focus on \cite{hu2018squeeze}.
In literature, many works have attempted to learn the attention weights from the feature map, termed \textit{self-attention}.
State-of-the-art algorithms include CBAM \cite{woo2018cbam}, SE \cite{hu2018squeeze} among others \cite{hu2018gather,zhang2019relation,gao2019global}.
Besides self attention, the attention weights can also be conditioned on external information, for example nature language
Successful application fields include
search by language \cite{li2017person},
image captioning \cite{xu2015show,chen2017sca}
and visual question answering \cite{chen2015abc,yang2016stacked}.
Our work is motivated by the research in conditional attention mechanism. Rather than vision \& language, we design novel architectures to adapt the conditional attention mechanism to
address an important but long overlooked issue, the sub-optimal late fusion of vision and non-vision features in personalized ranking.
Conditioned on the additional category information, our image embedding is able to emphasize features that are both important and category related.
\fi
\section{The CTR Prediction System in JD.com}
We first review the background of the CTR prediction in Section \ref{pre}. Then we describe the architecture of our CTR prediction system in Section \ref{architecture}.
We further dig into details of our novel visual modeling module, the Category-Specific CNN in Section \ref{CSCNN}. Finally, we introduce essential accelerating strategies for online deployment in Section \ref{online}. The notations are summarized in Table \ref{notations}.
\subsection{Preliminaries}\label{pre}
In the online advertising industry, when an \textit{ad} is shown to a \textit{user} under some \textit{contexts}, this scenario is counted as an \textit{impression}. The aim of CTR prediction is to predict the probability that a positive feedback, i.e. \textit{click}, takes place in an impression (\textit{ad, user, contexts}).
Accurate CTR prediction directly benefits both the user experience and business effectiveness, which makes this task of crucial importance to the whole advertising industry.
CTR prediction is usually formulated as binary classification. Specifically, the goal is to learn a prediction function $f: \mathbb R^d \to \mathbb R$ from a training set $\mathcal D=\{(\mathbf x_1, y_1),...,(\mathbf x_{|\mathcal D|}, y_{|\mathcal D|})\}$, where $\mathbf x_i \in \mathbb R^d$ is the feature vector of the $i$-th impression and $y_i \in \{0,1\}$ is the class label that denotes whether a click takes place.
The objective function is defined as the negative log-likelihood:
\begin{equation}
\ell(\mathcal D) = -\frac{1}{|\mathcal D|} \sum_{i=1}^{|\mathcal D|} y_i \log( \hat y_i)+(1-y_i) \log (1-\hat y_i),
\end{equation}
where $\hat y_i$ is the predicted CTR, scaled to $(0,1)$ by sigmoid $\sigma$:
\begin{equation}
\hat y_i=\sigma\left(f(\mathbf x_i)\right).
\end{equation}
\subsection{The Architecture of CTR Prediction System}\label{architecture}
We now describe the architecture of our CTR prediction system that is serving on JD.com. Details are shown in Fig \ref{arch}.
\begin{figure*}[t]\begin{center}
\includegraphics[width=15.6 cm]{frame.pdf}\end{center}
\caption{
Our proposed Category-Specific CNN framework. Note that CSCNN can be added to any single convolutional layer, but for easy illustration, we only show details on single layer.
\textbf{Top}: A map from the category to category prior knowledge that affects channel-wise and spatial attentions.
\textbf{Bottom}: $\mathbf F$ is the output feature map of the current convolutional layer. Refined by channel-wise and spatial attention sequentially, the new feature map $\mathbf F''$ is used as the input to the next layer.
}\label{frame}
\end{figure*}
\subsubsection{Deep \& Cross Network}
Deep \& Cross network (DCN) \cite{wang2017deep}
has achieved promising performance thanks to the ability to learn effective feature interactions.
Here, we properly modify the DCN to take
two inputs,
a non-visual feature vector $\mathbf x_{nv}\in \mathbb R^{380}$
and
a visual feature vector $\mathbf x_{v}\in \mathbb R^{150}$.
The visual feature is incorporated to the
\textit{deep} net.
In layer 1, we
transform the non-visual feature to 1024 dimension and concatenate it with the visual feature,
\begin{equation}
\mathbf h_{1}=[\mathbf x_{v},\text{ReLU-MLP}(\mathbf x_{nv})] \in \mathbb R^{150+1024}
\end{equation}
Two deep layers follows,
\begin{equation}
\mathbf h_{l+1}=\text{ReLU-MLP}(\mathbf h_l), l\in\{1,2\},\mathbf h_2 \in \mathbb R^{512}, \mathbf h_3 \in \mathbb R^{256}
\end{equation}
The \textit{cross} net is used to process non-visual feature,
\begin{equation}
\mathbf z_{l+1}=\mathbf z_0 \mathbf z_l ^\top \mathbf w_l+\mathbf b_l +\mathbf z_l,
\end{equation}
where the input $\mathbf z_0=\mathbf x_{nv}$,
$\mathbf z_l, \mathbf w_l, \mathbf b_l \in \mathbb R^{380}$ for layer $l\in \{0,1,2\}$.
Finally, we combine the outputs for the predicted CTR,
\begin{equation}
\hat y = \sigma (\text{ReLU-MLP}[\mathbf h_3, \mathbf z_3])
\end{equation}
\subsubsection{Non-visual Feature Embedding}
We now describe the embedding layer that transforms raw non-visual features of an impression, namely \textit{(ad, user, contexts)}, to the vector $\mathbf x_{nv}$.
We assume that all features come in the categorical form (after preprocessings e.g. binning).
Usually, a categorical feature is encoded in a one-hot / multi-hot vector $\mathbf x_\text{hot} \in \{0,1\}^v$, where $v$ is the vocabulary size of this feature.
We show two examples below:
\textsf{WeekDay=Wed} ~~ ~~~~~$\Longrightarrow$ \textsf{[0,0,0,1,0,0,0]}
\textsf{TitleWords=[Summer, Dress]}~~~~~~~$\Longrightarrow$\textsf{[...,0,1,0,...,0,1,0...]}
\noindent Unfortunately, this one/multi-hot coding is not applicable to industrial systems due to the extreme high dimensionality and sparsity. We thus adopt a low dimensional embedding strategy in our system,
\begin{equation}
\mathbf x_\text{emb} = E \mathbf x_\text{hot}
\end{equation}
where $E\in \mathbb R^{d_e\times v}$ is the embedding dictionary for this specific feature and $d_e$ is
the embedding size.
We then concatenate the $\mathbf x_\text{emb}$'s of all features
to build $\mathbf x_{nv}$.
In practice, our system makes use of 95 non-visual features from users (historical clicks /purchases, location etc.), ads (category, title, \# reviews etc.) and rich contexts (query words, visit time etc.) with 7 billion vocabularies in total.
Setting $d_e=4$, the total dimension is $95\times4=380$. We will further introduce the features and their statistics in Table \ref{experiment5} Appendix \ref{app_data}.
\if 0
To encode the categorical features into vectors,
a classical tool is one-hot or multi-hot coding, which however, is not applicable to our industrial system due to the extreme sparsity.
For example, the feature ``\textsf{UserPin=Richard}" would be encoded as a one-hot vector of length over 100 million (\# active users).
To reduce the dimensionality, a commonly used method is to learn a low dimensional embedding vector for each value in vocabulary \cite{}. But this is still impractical in our huge industrial system since
the total vocabulary size is over 7 billion.
To address this issue, we propose an economical Hash \& Embedding method.
In contrast to trivial embedding methods that learn one embedding for every feature value , our embedding look up is guided by a hash function $\mathcal H$.
Specifically, $\mathcal H$ is designed to map
each feature value $v$ (such as \textsf{``WeekDay =Wed", ``TitleWords=Summer"})
to an integer $\mathcal H (v)\in \{1,...,d_h\}$.
Then we look up
an embedding dictionary of size ${d_h \times d_e}$ for its $\mathcal H(v)$-th row, as the $d_e$ dimensional embedding of feature value $v$.
Considering our system capacity,
we set the hash size $d_h=2^{28}$, which is only $\frac{1}{26}$ of the total vocabulary size.
To our surprise, this high hash collision rate actually benefits the performance in practice. We conjecture that sharing embedding vectors alleviates the overfit problem caused by the low frequency id features.
Given an impression with categorical features, we first look up the embeddings of all feature values.
For a multi-valued name space, we conduct an average pooling to aggregate the embeddings of multiple values inside this name space.
Consequently, the embedding length of
all name spaces, both single-valued or multi-valued, are all unified to $d_e$.
We finally concatenate the embeddings to build the feature vector, $\mathbf x \in \mathbb R^d $, where $d= d_e \times \# \text{name spaces}$.
\fi
\begin{figure*}[t]\begin{center}
\includegraphics[width=12.6 cm]{attention.pdf}\end{center}
\caption{Modules of our proposed Category-Specific CNN: Channel-wise Attention (top) and Spatial Attention (bottom). }\label{attention2}
\end{figure*}
\subsection{Category-Specific CNN}\label{CSCNN}
Conventional CTR prediction systems mostly
embed ad images using
\textit{off-the-shelf} CNNs.
We say off-the-shelf since they were
originally designed for classification, not for CTR prediction.
They regard the image category as the target to predict, not as inputs.
This is actually a huge waste on e-commerce platforms, where categories are precisely labeled and contain plentiful visual prior knowledge that would help visual modeling.
We address this issue by proposing a novel CNN specifically for CTR prediction,
Category-Specific CNN, that embeds an ad image $m$, together with the ad category $k \in \mathcal K$, to the visual feature $\mathbf x_v$.
Specifically, the category prior knowledge is encoded as category embeddings (trained jointly with the CTR model) and incorporated to the CNN using a conditional attention mechanism.
Theoretically, CSCNN can be adopted to any convoluation layer in any network. In our systems, we plug CSCNN on ResNet18 \cite{he2016deep} and would discuss the adaptability to other networks in ablation studies.
\subsubsection{Framework on A Single Convolutional Layer}
For each category $k$ and each convolutional layer $l$,
CSCNN learns a tensor $\mathbf A^k_{c}\in\mathbb R^{1\times 1 \times C'}$ that encodes the impact of category prior knowledge on the channel-wise attention for this layer. We omit the subscript $l$ for conciseness. The framework is shown in Fig \ref{frame}.
Given an intermediate feature map $\mathbf F \in \mathbb R^{H\times W\times C}$, the output of convolutional layer $l$, CSCNN first learns a channel attention map $\mathbf M_c\in \mathbb R^{1\times 1\times C}$ conditioned on both the current feature map and the category. Then the channel-wise attention is multiplied to the feature map to acquire a refined feature map $\mathbf F' \in \mathbb R^{H\times W\times C}$,
\begin{equation}
\mathbf F' =\mathbf M_c(\mathbf F, \mathbf A^k_{c})\odot \mathbf F,
\end{equation}
where $\odot$ denotes the element-wise product with $\mathbf M_c$ broadcasted along spatial dimensions $H \times W$.
Similarly, CSCNN also learns another tensor $\mathbf A^k_{s}\in\mathbb R^{H\times W \times 1}$ that encodes the category prior knowledge for spatial attention $\mathbf M_s\in \mathbb R^{H\times W\times 1}$. These two attention modules are used sequentially to get a 3D refined feature map $\mathbf F'' \in \mathbb R^{H\times W\times C}$,
\begin{equation}
\mathbf F'' =\mathbf M_s(\mathbf F', \mathbf A^k_{s})\odot \mathbf F',
\end{equation}
where spatial attention is broadcasted along the channel dimension before element-wise product. A practical concern is the large number of parameters in $\mathbf A_s^k$, especially on the first a few layers.
To address this problem, we propose to only learn a much smaller tensor $\mathbf A'^k_{s}\in\mathbb R^{H'\times W' \times 1}$, where $H'\ll H$ and $W'\ll W$, and then resize it to $\mathbf A_s^k$ through linear interpolation. The effect of $H'$ and $W'$ would be discussed with experimental results later. Note that $\mathbf A_s^k$ and $\mathbf A_c^k$ are randomly initialized and learnt during training, no additional category prior knowledge is needed except category id.
After refined by both channel-wise and spatial attention, $\mathbf F''$ is fed to the next layer. Note that CSCNN could be added to any CNNs, by only replacing the input to the next layer from $\mathbf F$ to $\mathbf F''$.
\subsubsection{Category-specific Channel-wise Attention}
Channel-wise attention tells ``what" to focus on.
In addition to the inter-channel relationship considered previously, we also exploit the relationship between category prior knowledge and features (Fig \ref{attention2}, top).
To gather spatial information, we first squeeze the spatial
dimension of $\mathbf F$ through max and average pooling.
The advantage for adopting both is supported by experiments conducted by the CBAM.
The two squeezed feature maps are then concatenated with the category prior knowledge $\mathbf A_c^k$ and forwarded through a shared two layer MLP, reducing the dimension from $1\times 1\times (C+C')$ to $1\times 1\times C$. Finally, we merge the two by element-wise summation.
\begin{eqnarray}
\mathbf M_c(\mathbf F,\mathbf A_c^k)= \sigma(\text{MLP}[\text{AvgP}(\mathbf F),\mathbf A_c^k]
+\text{MLP}[\text{MaxP}(\mathbf F),\mathbf A_c^k]),
\end{eqnarray}
\subsubsection{Category-specific Spatial Attention}
Our spatial attention module is illustrated in Fig \ref{attention2} (bottom).
Spatial attention tells where to focus by exploiting the inter-spatial relationship of features.
Inspired by the CBAM, we first aggregate channel-wise information of feature map $\mathbf F'$ by average pooling and max pooling along the channel dimension. To incorporate the category prior knowledge, these two are then concatenated with $\mathbf A_s^k$ to form an $H\times W \times 3$ dimensional feature map. Finally, this feature map is forwarded through a $7\times 7$ convolutional filter to get the attention weights.
\begin{eqnarray}
\mathbf M_s(\mathbf F',\mathbf A_s^k)= \sigma(\text{Conv}_{7\times 7}(\text{MaxP}(\mathbf F'),\text{AvgP}(\mathbf F'),\mathbf A_s^k)).
\end{eqnarray}
\begin{table}[t]
\caption{\# Parameters and \# GFLOPs of CSCNN and Baselines. We use ResNet18 as the baseline and the backbone network to adopt CBAM and CSCNN modules. Note that there is only 0.03\% addition computation from CBAM to CSCNN.
} \label{parameters_compare}
\begin{center}
\begin{tabular}{lrr}
\hline
Algorithm & \# params/M & \#GFLOPs\\\hline
Res18& 17.9961 &1.8206\\
Res18 + CBAM& 18.6936 &1.8322\\
Res18 + CSCNN & 21.6791 &1.8329\\
\hline
\end{tabular}\end{center}
\end{table}
\subsubsection{Complexity Analysis}
Note that CSCNN is actually a light-weighted module.
Specifically, we show the number of parameters and giga floating-point operations (GFLOPs) of Baseline, CBAM and our proposed algorithm in Table \ref{parameters_compare}.
We set $C\in \left\{64, 128,256,512\right\}, C'=20$, and the bottleneck reduction ratio to 4, \# categories $|\mathcal K|=3310$ (real production dataset in Table \ref{industrial}).
In the ``Shared FC" in each convolutional layer in CBAM, \# parameters is $2*C*C/4$.
For CSCNN \# parameters in FC and channel category embedding are $C*C/4+(C+C')*C/4+C'*|\mathcal K|$.
\#params increased compared to CBAM in channel attention for 1 conv layer is 67$\sim$69k.
And, $W'=H'=6$, \#additional params in spatial attention is $W'*H'*|\mathcal K|+6*6\approx$120k.
So, the total params increased is (120k+68k)*16 layers=3.0M.
The additional params introduced by us are acceptable, and the additional computation is only 0.03\% compared to CBAM.
\if 0
\begin{table}[t]
\caption{\# Parameters and \# GFLOPs of CSCNN and Baselines. We use CNN-F \cite{chatfield2014return}, a light neural network used in DVBPR, as the baseline and the base network structure to adopt CBAM and CSCNN modules. Note that there is only 0.03\% increase in \# parameters from CBAM to CSCNN.
} \label{parameters_compare}
\begin{center}
\begin{tabular}{lrr}
\hline
Algorithm & \# params/M & \#GFLOPs\\\hline
CNN-F& 74.2031 &0.5026\\
CNN-F + CBAM& 74.3346 &0.5044\\
CNN-F + CSCNN & 74.3570 &0.5045\\
\hline
\end{tabular}\end{center}
\end{table}
\subsubsection{Complexity Analysis}
Note that CSCNN is actually a light-weighted module.
Specifically, we show the number of parameters and giga floating-point operations (GFLOPs) of Baseline, CBAM and our proposed algorithm in Table \ref{parameters_compare}.
We set $C=256,C'=20$, and the bottleneck reduction ration to 4, \# categories $|\mathcal K|=62$ (Dataset Men in Table \ref{dataset}). In the ``Shared FC" in each convolutional layer in CBAM, \# parameters is
$2*C*C/4$. For CSCNN \# parameters in FC and channel category embedding are $C*C/4+(C+C')*C/4+C'*|\mathcal K|$. \#params increased compared to CBAM in channel attention for 1 conv layer is 2520.
And, $W'=H'=7$, \#additional params in spatial attention is $W'*H'*|\mathcal K|+7*7=3087$.
So, the total params increased is only (3087+2520)*4 layers=22.4k. The additional params and computation introduced by us are negligible (only 0.03\% increase compared to CBAM).
\fi
\begin{figure}[t]\begin{center}
\includegraphics[width=7.8 cm]{online.pdf}\end{center}
\caption{
The architecture of the online model system.
}\label{online_system}
\end{figure}
\subsection{System Deployment}\label{online}
We deploy CSCNN for the search advertising system of JD.com, the largest B2C e-commerce company in China, serving the main traffic of hundreds of millions of active users.
Fig. \ref{online_system} depicts the architecture of our online model system
\subsubsection{Offline training}
CSCNN is trained jointly with the whole CTR prediction system, on our
ten-billion scale real production dataset collected in the last 32 days.
In our preliminary investigation, CNN is the key
computational bottleneck during training.
Taking ResNet18 network with input pictures sized 224x224, a single machine with 4 P40 GPUs can only train 177 million images per day.
This means that even only considering CSCNN and with linear speedup in distributed training, we need 226 P40 GPUs to complete the training on the ten-billion impressions within 1 day, which is too expensive. To accelerate,
we adopt the sampling strategy in \cite{chen2016deep}.
At most 25 impressions with the same ad are gathered in one batch. The image embedding of one image is conducted only once and broadcasted to multiple impressions in this batch. Now with 28 P40 GPUs, training is can be finished in 1 day.
\if 0
CSCNN and the base DCN \cite{wang2017deep} are jointly trained with the ten-billion scale industrial data collected from the last 32 days.
In our preliminary investigation, we found that CSCNN has serious computational bottlenecks during the offline training.
Taking the medium-sized res18 network as the backbone CNN, input with 224x224 sized pictures, a single machine with 4 P40 GPUs can only train 177 million pictures per day.
This means that even only consider CSCNN and with linear speedup in distributed training, we need 226 P40 GPUs to complete the training of the ten-billion scale industrial dataset within 24 hours, which is too expensive and unnecessary.
We adopt the sampling strategy proposed in \cite{chen2016deep} to accelerate.
At most 25 training instances with the same item are gathered in one batch. The image embedding of one item is conducted only once and broadcasted to multiple instances.
With this strategy and a parameter server with 28 P40 GPUs, the training is efficient enough for the daily update.
\fi
\subsubsection{Offline inferring:} Images and categories are fed into the well trained CSCNN to inference visual features. Features are made into a lookup table and then loaded in the predictor memory to replace the CSCNN. After dimension reduction and frequency control, a 20 GB lookup table can cover over 90\% of the next day impression.
\subsubsection{Online serving:} Once a request is received, the visual feature is found directly from the lookup table according to ad id. The predictor returns an estimated CTR.
Under the throughput of over 3 million items per second at traffic peak, the tp99 latency of our CPU online serving system is below 20ms.
\if 0
We deployed CSCNN for a leading e-commerce website, serving the main traffic of hundreds of millions of active users.
Fig. \ref{online_system} depicts the architecture of our system, containing offline training, offline inferring and online serving.
\begin{itemize}
\item \textbf{Offline training:} Online user behaviours (click/impression) are streamed continuously into a log database.
CSCNN and the base DCN \cite{wang2017deep} are jointly trained with the ten-billion scale industrial data collected from the last 32 days.
During the training, we adopt the sampling strategy proposed in \cite{chen2016deep} to accelerate CSCNN. At most 25 training instances with the same item are gathered in one batch. The image embedding of one item is conducted only once and broadcasted to multiple instances.
With this strategy and a parameter server with 28 GPUs, the training is efficient enough for the daily update.
\item \textbf{Offline inferring:} Images and categories are fed into the CSCNN to inference visual features. These visual features are made into a hash-table and latter loaded in the predictor memory to replace the CSCNN. After dimension reduction and frequency control, the 20 GB hash-table can cover over 90\% next day impression.
\item \textbf{Online serving:} Once a request is send, the visual feature is found directly from the hash-table according to item id. With the visual feature and the DCN model, the predictor return an estimated CTR.
Under the throughput of over 3 million items per second at traffic peak, the tp99 lacency of our CPU online serving system is below 20ms.
\end{itemize}
\fi
\begin{table}[t]
\caption{Amazon Benchmark Dataset Statistics.}\label{dataset}
\begin{center}
\begin{tabular}{lrrrr}
\hline
Dataset & \#Users &\#Items& \# Interact & \#Category\\
\hline
Fashion&64,583&234,892&513,367&49\\
Women&97,678&347,591&827,678&87\\
Men&34,244&110,636&254,870&62\\
\hline
\end{tabular}\end{center}
\end{table}
\if 0
\subsection{Accelerating Strategies on Our Systems}
Given ten-billion scale industrial datasets,
training should be efficient enough so that the model could be updated daily.
And the online system should
meet the low latency requirements.
We now introduce necessary accelerating strategies for deploying CSCNN on our e-commerce website.
\subsubsection{Sampling in Training}
The crucial issue for training is that CNN is much slower compared to other parts of the network.
Our base DCN \cite{wang2017deep} model without the visual feature extractor can forward-backward ten-billion instances on seven 48-cored CPU machines within one day,
but the model with CNN takes more than 2 weeks even on 7 GPU machines with 4 Tesla P100.
We adopt the sampling strategy proposed in \cite{chen2016deep}. To be brief, training instances with the same item are gathered in one batch.
The image embedding of one item is conducted only once and broadcasted to many training instances.
This strategy greatly reduced the GPU computing bottleneck, speeding up the training dozens of times.
\subsubsection{Online System}
\if 0
It is worth noticing that online serving of CSCNN is a great challendge, especially for a CPU online serving system.
The throughput is required to be over 3 million items per second at traffic peak and the tp99 lacency is required to be less than 20ms.
In order to meet the online requirement, we proposed a `space-for-time' strategy:
1) The CNN embedding of each item are inferenced parallel by multiple GPU and made into a dictionary indexed by item id.
2) The dictionary and the model (CNN removed) are pushed to the same online service machine.
3) When online serving, we get CNN embedding directly from the dictionary in local memory.
With the help of these strategy, the tp99 latency of our CSCNN only increased 5ms compared to the DCN baseline model and meet the online requirement.
\fi
It is worth noticing that the online serving of CSCNN is a great challendge, especially for a CPU online serving system.
The throughput is required to be over 3 million items per second at traffic peak and the tp99 lacency is required to be less than 20ms.
In order to meet the online requirement, we proposed a `space-for-time' strategy:
The CNN embedding of each item are generated offline and made into a dictionary indexed by item id for online service.
With the help of these strategy, the tp99 latency of our CSCNN only increased 5ms compared to the DCN baseline model and meet the online requirement.
\fi
\section{Experimental Results}
We exam the effectiveness of both our proposed visual modeling module CSCNN and the whole CTR prediction system.
The experiments are organized into two groups:
\begin{itemize}
\item Ablation studies on CSCNN aims to eliminate the interference from the huge system.
We thus test the category-specific attention mechanism by plugging it
onto \textit{light-weighted} CNNs with a very \textit{simple} CTR prediction model. We use popular benchmark datasets for
repeatability.
\item We further exam the performance gain of our CTR prediction system acquired from the novel visual modeling module. Experiments include both off-line evaluations on a ten-billion scale real production dataset collected from ad click logs (Table \ref{industrial}),
and online A/B testing on the real traffic of hundreds of millions of active users on JD.com.
\end{itemize}
\subsection{Ablation Study Setup}
Our ablation study is conducted on the ``lightest" model. This helps to
eliminate the interference from the huge CTR prediction system and focus on our proposed category-specific attention mechanism.
Specifically, our light-weighted CTR model follows the Matrix Factorization (MF) framework,
VBPR \cite{he2016vbpr}, since it has achieved state-of-the-art performance in comparison with various light models.
The preference score of user $u$ to ad $a$ is predicted as:
\begin{equation}\label{MF}
\hat y_{u,a}=\alpha+\beta_u+\beta_a+\bm \gamma_u^\top \bm\gamma_a+ \bm\theta_u^\top \Phi(m_a,k_a),
\end{equation}
where $\alpha\in\mathbb R$ is an offset, $\beta_u,\beta_a\in\mathbb R$ are the bias. $\bm \gamma_u \in \mathbb R^{d'}$ and $\bm \gamma_a \in \mathbb R^{d'}$ are the latent features of $u$ and $a$. $\bm \theta_u \in \mathbb R^{d_v}$ encodes the latent visual preference of $u$. $\Phi$ is the light-weighted CNN.
Following VBPR \cite{he2016vbpr}, we use CNN-F \cite{chatfield2014return} as the base CNN $\Phi$, which consists of only 5 convolutional layers and 3 fully connected layers. We plug CSCNN onto layers from conv-2 to conv-5.
For comprehensive analysis, we will further test the effect of plugging attention modules on different layers (Figure \ref{parameter}) and our adaptability to other CNN structures (Table \ref{experiment3}) in following sections.
\begin{table*}[t]
\caption{Comparison with State-of-the-arts. For all algorithms, we report the mean over 5 runs with different random parameter initialization and instance permutations. The std $\approx$0.1\%, so the improvement is extremely statistically \textbf{significant} under unpaired t-test. CSCNN outperforms all due to 3 advantages: the additional category knowledge, the early fusion of category into CNN, effective structures to learn category-specific inter-channel and inter-spatial dependency.
}\label{experiment1}
\begin{center}
\begin{tabular}{ll | r | rr | rrr|rr}
\hline
&& No Image & \multicolumn{2}{c|}{With Image} & \multicolumn{5}{c}{With Image + Category}\\ \cline{3-10}
\multicolumn{2}{c|}{Datasets}&BPR-MF&VBPR&DVBPR&DVBPR-C&Sherlock&DeepStyle&DVBPR-SCA&Ours\\\hline
\multirow{2}{*}{Fashion} &All&0.6147&0.7557 &0.8011& 0.8022& 0.7640& 0.7530& 0.8032& \textbf{0.8156}\\
&Cold&0.5334& 0.7476& 0.7712& 0.7703& 0.7427& 0.7465& 0.7694& \textbf{0.7882}\\
\hline
\multirow{2}{*}{Women} &All&0.6506&0.7238& 0.7624& 0.7645&0.7265& 0.7232& 0.7772&\textbf{0.7931}\\
&Cold&0.5198&0.7086& 0.7078& 0.7099& 0.6945& 0.7120& 0.7273& \textbf{0.7523}
\\\hline
\multirow{2}{*}{Men} &All&0.6321&0.7079& 0.7491& 0.7549& 0.7239& 0.7279& 0.7547& \textbf{0.7749}\\
&Cold&0.5331&0.6880& 0.6985& 0.7018& 0.6910& 0.7210& 0.7048& \textbf{0.7315}\\
\hline
\end{tabular}\end{center}
\end{table*}
\subsection{Benchmark Datasets}
The ablation study is conducted on 3 wildly used benchmark datasets about products on \textit{Amazon.com} introduced in \cite{mcauley2015image} \footnote{Many works also use \textit{Tradesy} \cite{he2016vbpr} which is not suitable here due to the absence of category information.}.
We follow the identical category tree preprocessing method as used in \cite{he2016sherlock}. The dataset statistics after preprocessing are shown in Table \ref{dataset}.
On all 3 datasets, for each user, we randomly withhold one action for validation $\mathcal V_u$, another one for testing $\mathcal T_u$ and all the others for training $\mathcal P_u$,
following the same split as used in \cite{he2016vbpr}. We report test performance of the model with the best AUC on the validation set.
When testing, we report performance on two sets of items: \textit{All} items, and \textit{Cold} items with fewer than 5 actions in the training set.
\subsection{Evaluation Metrics}
AUC measures the probability that a randomly sampled positive item has higher preference than a sampled negative one,
\begin{equation}
\text{AUC}=\frac{1}{|\mathcal U|}\sum_{u\in\mathcal U} \frac{1}{|\mathcal D_u|} \sum_{(i,j)\in \mathcal D_u} \mathbb I(\hat y_{u,i}>\hat y_{u,j}),
\end{equation}
where $\mathbb I$ is an indicator function. $i,j$ are indexes for ads. $\mathcal D_u=\{(i,j)|(u,i)\in \mathcal T_u \text{ and } (u,j) \notin(\mathcal P_u\cup \mathcal V_u\cup \mathcal T_u)\}$.
In our ablation studies, algorithms are evaluated on AUC which is almost the default off-line evaluation metric in the advertising industry. Empirically, when the CTR prediction model is trained in binary classification, off-line AUC directly reflects the online performance. In JD.com, every 1\textperthousand increase in off-line AUC brings 6 million dollars lift in the overall advertising income.
\subsection{Compared Algorithms}
The compared algorithms are
either
1). representative in covering different levels of available information, or 2). reported to achieve state-of-the-art performance thanks to the effective use of
category:
\begin{itemize}
\item \textbf{BPR-MF}: The Bayesian Personalized Ranking (BPR) \cite{rendle2009bpr}, \textit{No} visual features. Only includes the first 4 terms in Eq (\ref{MF}).
\item \textbf{VBPR}: BPR + visual. The \textit{visual} features are extracted from pre-trained and \textit{fixed} CNN \cite{he2016vbpr}.
\item \textbf{DVBPR}: The \textit{visual} feature extractor CNN is trained \textit{end-to-end} together with the whole CTR prediction model \cite{kang2017visually}.
\item \textbf{DVBPR-C}: DVBPR + category. The \textit{Category} information is \textit{late} fused into MF by sharing $\bm \gamma_a$ among items from the same category.
\item \textbf{Sherlock}: DVBPR + category. \textit{Category} is used in the linear transform \textit{after} the visual feature extractor \cite{he2016sherlock}.
\item \textbf{DeepStyle}: \textit{Category} embedding is subtracted from the visual feature to obtain \textit{style information} \cite{liu2017deepstyle}.
\item \textbf{SCA}: This algorithm was originally designed for image captioning \cite{chen2017sca} where features of captioning were used in visual attention.
To make it a strong baseline in CTR prediction, we slight modify this algorithm by replacing the captioning features to category embedding, so that the category information is early fused into CNN.
\end{itemize}
In literature, some compared algorithms were originally trained with the \textit{pair-wise} loss (see Appendix \ref{appA}), which however, is not suitable for the industrial CTR prediction problem. For CTR prediction, the model should be trained in binary classification mode, or termed \textit{point-wise} loss, so that the scale of $\sigma(f(\mathbf x))$ directly represents CTR.
For fair comparison on the CTR prediction problem, in this ablation study, all algorithms are trained with the point-wise loss. While we also re-do all experiments with the pair-wise loss for consistent comparison with results in literature (Appendix \ref{appA}).
For fair comparison, all algorithms are implemented in the same environment using Tensor-flow, mainly based on the source code of DVBPR \footnote{For details, refer to \url{https://github.com/kang205/DVBPR/tree/b91a21103178867fb70c8d2f77afeeb06fefd32c}.}, following their parameter settings, including learning rate, regularization, batch size and latent dimension $d$ etc. Our category prior knowledge dimension is set to $C'=20$, $H'=W'=7$. We will discuss the effects of hyper-parameters in Fig \ref{parameter}.
\subsection{Comparison with State-of-the-arts}
We aim to show the performance gain from both the incorporating and the
effective utilization of valuable visual and category information.
Results are shown in Table \ref{experiment1} \footnote{AUC on the first 3
columns are from \cite{he2016vbpr}}.
First, we observe apparent performance gains from additional information along three groups, from ``No Image" to ``With Image", to ``With Image + Category", especially on cold items.
The gain from BPR-MF to group 2 validates the importance of visual features to CTR prediction.
The gain from VBPR to DVBPR supports significance of end-to-end training, which is one of our main motivation.
And the gain from group 2 to group 3
validates the importance of category information.
Second, by further comparing AUC within group 3, where all algorithms make use of category information, we find that CSCNN outperforms all. The performance gain lies in the different strategies to use category information.
Specifically, Sherlock and DeepStyle
incorporate the category into a category-specific linear module used at the end of image embedding.
While in DVBPR-C, items from the same category share the latent feature $\bm \gamma_a$ and $\beta_a$.
All of them late fuse the category information into the model after visual feature extraction.
In contrast, CSCNN early incorporates the category prior knowledge into convolutional layers, which enables category-specific inter-channel and inter-spatial dependency learning.
Third, CSCNN also outperforms DVBPR-SCA, a strong baseline created by us through modifying an image captioning algorithm. Although DVBPR-SCA also early fuses the category priors into convolutional layers through attention mechanism, it lacks effective structures to learn the inter-channel and inter-spatial relationships. While
our effective FC and convolutional structures in $\mathbf M_c$ and $\mathbf M_s$ are able to catch this channel-wise and spatial interdependency
\begin{table}[t]
\caption{Adaptability to Various Attention Mechanisms (Amazon Men).
\textbf{Left}: self attention nets. \textbf{Right}: our modified SE, CBAM-Channel, CBAM-All, by incorporating category prior knowledge $\mathbf A_c^k$ or $\mathbf A_s^k$ to attention using CSCNN. Results with CSCNN (right) significantly outperform original results (left), validating our effectiveness and adaptability.}\label{experiment2}
\begin{center}
\begin{tabular}{l | rr|rr}
\hline
& \multicolumn{2}{c|}{Original} & \multicolumn{2}{c}{+CSCNN}\\ \cline{2-5}
&All&Cold&All&Cold\\\hline
No Attention&0.7491 &0.6985 &--&--\\\hline
SE&0.7500 & 0.6989& \textbf{0.7673} &\textbf{0.7153}\\
CBAM-Channel&0.7506& 0.7002& \textbf{0.7683}& \textbf{0.7184}\\
CBAM-All& 0.7556& 0.7075 &\textbf{0.7749}& \textbf{0.7315}\\\hline
\end{tabular}\end{center}
\end{table}
\begin{figure*}[t]\begin{center}\begin{tabular}{rrr}
\includegraphics[width=4.9 cm]{channel.pdf}&
\includegraphics[width=4.9 cm]{spatial.pdf}&
\includegraphics[width=4.9 cm]{layer.pdf}
\end{tabular}\end{center}
\caption{Effects of Hyper-Parameters (Men, all).
\textbf{$C'$}: The size of category prior $\mathbf A_c^k$ for channel attention.
\textbf{$H',W'$}: The size of category prior $\mathbf A_c^k$ for spatial attention.
\textbf{$L'$}: Last \# layers to apply CSCNN.
}\label{parameter}
\end{figure*}
\subsection{Adaptation to Various Attentions}
Our key strategy is to use the category prior knowledge to guide the attention. Theoretically, this strategy could be used to improve any self attention module whose attention are originally learnt only from the feature map.
To validate the adaptability of CSCNN to various attention mechanism, we test it on three popular self attention structures: SE \cite{hu2018squeeze}, CBAM-Channel and CBAM-all \cite{woo2018cbam}. Their results with self attention is shown in Table \ref{experiment2}, left.
We slightly modify their attention module using CSCNN, i.e.
incorporating category prior knowledge $\mathbf A_c^k$ or $\mathbf A_s^k$. Results are in Table \ref{experiment2}, right.
Our proposed attention mechanism with category prior knowledge (right) significantly outperforms their self attention counterparts (left) in all 3 architectures, validating our adaptability
to different attention mechanisms.
\subsection{Adaptability to Various Network Backbones}
As mentioned, our CSCNN can be easily adopted to any network backbones by replacing the input to the next layer from the feature map $\mathbf F$ to the refined feature map $\mathbf F''$. Now we test the adaptability of CSCNN to Inception V1 \cite{szegedy2015going}, results in Table \ref{experiment3}.
CSCNN achieves consistent improvement on CNN-F and Inception V1 over CBAM, which validates our adaptability to different backbones. This improvement also reveals another interesting fact that even for complicated networks (deeper than CNN-F), there is still big room to improve due to the absent of category-specific prior knowledge. This again supports our main motivation.
\begin{table}[t]
\caption{Adaptability to Different Backbones (Amazon Men). We observe consistent improvement on CNN-F and Inception V1 over the self attention CBAM and no attention base, validating our adaptability. }\label{experiment3}
\begin{center}
\begin{tabular}{l|l |rr}
\hline
&&CNN-F&Inception\\\hline
\multirow{2}{*}{No Attention} &All& 0.7491 &0.7747\\
&Cold& 0.6985 &0.7259\\
\hline
\multirow{2}{*}{CBAM} &All& 0.7556 &0.7794\\
&Cold& 0.7075 &0.7267
\\\hline
\multirow{2}{*}{CSCNN}&All& \textbf{0.7749}&\textbf{0.7852}\\
&Cold& \textbf{0.7315} &\textbf{0.7386}\\
\hline
\end{tabular}\end{center}
\end{table}
\begin{table}[t]
\caption{Real Production Dataset Statistics. Bil, Feats are short for Billion, Features. Besides the features listed, we also do manual feature interaction making the total \# features= 95.}\label{industrial}
\begin{center}
\begin{tabular}{lrll}
\hline
Field& \# Feats & \#Vocab & Feature Example\\
\hline
Ad& 14 & 20M & ad id, category, item price, review\\
User & 6&400 M & user pin, location, price sensitivity\\
Time & 3& 62 & weekday, hour, date\\
Text & 13 & 40M & query, ad title, query title match\\
History&14 & 7 Bil & visited brands, categories, shops\\
\end{tabular}
\begin{tabular}{rrrr}
\hline
\#Users 0.2 bil.&\#Items 0.02 bil.& \# Interact 15 bil. & \#Cate 3310\\
\hline
\end{tabular}\end{center}
\end{table}
\begin{table}[t]
\caption{Experiments on Real Production Dataset.
}\label{experiment5}
\begin{center}
\begin{tabular}{l|l}
\hline
Offline & AUC\\\hline
DCN &0.7441\\
DCN + CNN fixed& 0.7463 (+\textbf{0.0022})\\
DCN + CNN finetune& 0.7500 (+\textbf{0.0059})\\
DCN + CBAM finetune& 0.7506 (+\textbf{0.0065})\\
DCN + CSCNN& 0.7527 (+\textbf{0.0086})\\\hline
\end{tabular}
\begin{tabular}{lrrr}
\hline
Online A/B Test &CTR Gain &CPC Gain & eCPM Gain\\\hline
DCN&0&0&0\\
DCN+CSCNN&3.22\%& -0.62\%& 2.46\%\\\hline
\end{tabular}\end{center}
\end{table}
\subsection{Effects of Hyper-Parameters}
We introduced 3 hyper-parameters in CSCNN: $C'$, the size of category prior $\mathbf A_c^k$ for channel-wise attention; $H'=W'$, the size of category prior $\mathbf A'^k_{s}$ for spatial attention; $L'$, the number of layers with CSCNN module. Namely, we add CSCNN to the last $L'$ convolutional layers of CNN-F. We exam their effects in Fig. \ref{parameter}.
When $H', W', C'$ are small, larger $H', W', C'$ result in higher AUC. This is because larger $\mathbf A_c^k$ and $\mathbf A'^k_{s}$ are able to carry more detailed information about the category, which further supports the significance of exploiting category prior knowledge in building CNN. But too large $H', W', C'$ will suffer from the overfit problem. We find the optimal setting $C'=20$ and $H'=W'=7$. Note that the setting is restricted to this dataset. For datasets with more categories, we conjecture a larger optimal size of $H', W', C'$.
When $L'\leq 4$, increasing $L'$ benefits. Namely, the more layers that use CSCNN, the better performance.
Furthermore, the continuous growth from $L'=1$ to $L'=4$ indicates that the AUC
gain from CSCNN at different layers are complementary.
But, adding CSCNN to \textsf{cov1} harms the feature extractor. This is because \textsf{cov1} learns general, low level features such as line, circle, corner, which never needs attention and are naturally independent to category.
\subsection{Experiments On Real Production Dataset \& Online A/B Testing}
Our real production dataset is collected from ad interaction logs in JD.com.
We use logs
in the first 32 days for training and sample 0.5 million interactions from the 33-th day for testing.
The statistics of our ten-billion scale real production dataset is shown in Table \ref{industrial}.
We present our experimental results in
Table \ref{experiment5}.
The performance gain from the fixed CNN validates the importance of visual features.
And the gain from finetuning validates the importance of our end-to-end training system.
The additional contribution of CBAM demonstrates that emphasizing meaningful features using attention mechanism is beneficial.
Our CSCNN goes one step further by early incorporating the category prior knowledge into the convolutional layers, which enables easier inter-channel and inter-spatial dependency learning. Note that on the real production data, 1\textperthousand increase in off-line AUC is significant and brings 6 million dollars lift in the overall advertising income of JD.com.
From 2019-Feb-19 to 2019-Feb-26, online A/B testing was conducted in the ranking system of JD.
CSCNN contributes 3.22\% CTR (Click Through Rate) and 2.46\% eCPM (Effective Cost Per Mille) gain compared to the previous DCN model online.
Furthermore, CSCNN reduced CPC (Cost Per Click) by 0.62\%.
\section{Discussion \& Conclusion}
Apart from the category, what other features could also be adopted to lift the effectiveness of CNN in CTR prediction?
To meet the low latency requirements of the online systems, CNN must be computed offline. So
dynamic features including the user and query should not be used.
Price, sales and praise ratio are also inappropriate due to the lack of visual prior.
Visual related item features including brand, shop id and product words could be adopted.
Effectively exploiting them to further lift the effectiveness of CNN in CTR prediction would be a promising direction.
We proposed Category-specific CNN, specially designed for visual-aware CTR prediction in e-commerce. Our early-fusion architecture enables category-specific feature recalibration and emphasizes features that are both important and category related, which contributes to significant performance gain in CTR prediction tasks. With the help of a highly efficient infrastructure, CSCNN has now been deployed in the search advertising system of JD.com, serving the main traffic of hundreds of millions of active users.
\bibliographystyle{ACM-Reference-Format}
| {'timestamp': '2020-06-22T02:12:44', 'yymm': '2006', 'arxiv_id': '2006.10337', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10337'} | arxiv |
\section{Introduction}
Gaussian processes (GPs) are a widely-used class of models for learning an unknown function within a Bayesian framework.
They are particularly attractive for use within decision-making systems, e.g. in Bayesian optimization \cite{snoek2012} and reinforcement learning \cite{deisenroth11, deisenroth13}, where well-calibrated uncertainty is crucial for enabling the system to balance trade-offs, such as exploration and exploitation.
A GP is specified through its mean and covariance kernel.
The Mat\'{e}rn family is a widely-used class of kernels, often favored in Bayesian optimization due to its ability to specify smoothness of the GP by controlling differentiability of its sample paths.
Throughout this work, we view the widely-used squared exponential kernel as a Mat\'{e}rn kernel with infinite smoothness.
Motivated by applications areas such as robotics \cite{jaquier19,calinon20} and climate science \cite{camps2016}, recent work has sought to generalize a number of machine learning algorithms from the vector space to the manifold setting.
This allows one to work with data that lives on spheres, cylinders, and tori, for example.
To define such a GP, one needs to define a positive semi-definite kernel on those spaces.
In the Riemannian setting, as a simple candidate generalization for the Mat\'{e}rn or squared exponential kernel, one can consider replacing Euclidean distance in the formula with the Riemannian geodesic distance.
Unfortunately, this approach leads to ill-defined kernels in many cases of interest \cite{feragen15}.
An alternative approach was recently proposed by \textcite{lindgren11}, who adopt a perspective introduced in the pioneering work of \textcite{whittle63} and define a Mat\'{e}rn GP to be the solution of a certain stochastic partial differential equation (SPDE) driven by white noise.
This approach generalizes naturally to the Riemannian setting, but is cumbersome to work with in practice because it entails solving the SPDE numerically.
In particular, setting up an accurate finite element solver can become an involved process, especially for certain smoothness values \cite{bolin17, bolin19}.
This also prevents one from easily incorporating recent advances in scalable GPs, such as sparse inducing point methods \cite{titsias09a, hensman13}, into the framework.
This in turn impedes one from easily employing mini-batch training, online training, non-Gaussian likelihoods, or incorporating GPs as differentiable components within larger models.
In this work, we extend Mat\'{e}rn GPs to the Riemannian setting in a fully constructive manner, by introducing Riemannian analogues of the standard technical tools one uses when working with GPs in Euclidean spaces.
To achieve this, we first study the special case of the $d$-dimensional torus $\bb{T}^d$.
Using ideas from abstract harmonic analysis, we view GPs on the torus as periodic GPs on $\R^d$, and derive expressions for the kernel and spectral measure of a Mat\'{e}rn GP in this case.
Building on this intuition, we generalize the preceding ideas to general compact Riemannian manifolds without boundary.
Using insights from harmonic analysis induced by the Laplace--Beltrami operator, we develop techniques for computing the kernel and generalized spectral measure of a Mat\'{e}rn GP in this setting.
These expressions enable computations via standard GP approaches, such as Fourier feature or sparse variational methods, thereby allowing practitioners to easily deploy familiar techniques in the Riemannian setting.
We conclude by showcasing how to employ the proposed techniques through a set of examples.
\section{Gaussian processes}
Let $X$ be a set, and let $f: X \-> \R$ be a random function.
We say that $f \~[GP](\mu, k)$ if, for any~$n$ and any finite set of points $\v{x} \in X^n$, the random vector $\v{f} = f(\v{x})$ is multivariate Gaussian with prior mean vector $\v\mu = \mu(\v{x})$ and covariance matrix $\m{K}_{\v{x}\v{x}} = k(\v{x},\v{x})$.
We henceforth, without loss of generality, set the mean function to be zero.
Given a set of training observations $(x_i, y_i)$, we let $y_i = f(x_i) + \eps_i$ with $\eps_i \~[N](0,\sigma^2)$.
Under the prior $f \~[GP](0,k)$ the posterior distribution $f\given\v{y}$ is another GP, with mean and covariance
\<
\E(f\given\v{y}) &= \m{K}_{(\cdot)\v{x}} (\m{K}_{\v{x}\v{x}} + \sigma^2\m{I})^{-1}\v{y}
&
\Cov(f\given\v{y}) &= \m{K}_{(\cdot,\cdot)} - \m{K}_{(\cdot)\v{x}} (\m{K}_{\v{x}\v{x}} + \sigma^2\m{I})^{-1} \m{K}_{\v{x}(\cdot)}
\>
where $(\cdot)$ denotes an arbitrary set of test locations. The posterior can also be written
\[
\label{eqn:pathwise}
(f\given\v{y})(\cdot) = f(\cdot) + \m{K}_{(\cdot)\v{x}} (\m{K}_{\v{x}\v{x}} + \sigma^2\m{I})^{-1} (\v{y} - f({\v{x}}) - \v\eps)
\]
where equality holds in distribution \cite{wilson20}.
This expression allows one to sample from the posterior by first sampling from the prior, and transforming the resulting draws into posterior samples.
On $X = \R^d$, one popular choice of kernel is the \emph{Mat\'{e}rn} family with parameters $\sigma^2,\kappa,\nu$, defined as
\[
\label{eqn:matern-kernel-eucl}
k_{\nu}(x,x') = \sigma^2 \frac{2^{1-\nu}}{\Gamma(\nu)} \del{\sqrt{2\nu} \frac{\norm{x-x'}}{\kappa}}^\nu K_\nu \del{\sqrt{2\nu} \frac{\norm{x-x'}}{\kappa}}
\]
where $K_\nu$ is the modified Bessel function of the second kind \cite{gradshteyn14}.
The parameters of this kernel have a natural interpretation: $\sigma^2$ directly controls variability of the GP, $\kappa$ directly controls the degree of dependence between nearby data points, and $\nu$ directly controls mean-square differentiability of the GP \cite{rasmussen06}.
As $\nu\->\infty$, the Mat\'{e}rn kernel converges to the widely-used squared exponential kernel
\[
\label{eqn:rbf-kernel-eucl}
k_{\infty}(x,x') = \sigma^2 \exp\del[3]{-\frac{\norm{x-x'}^2}{2 \kappa^2}}
\]
which induces an infinitely mean-square differentiable GP.
For a bivariate function $k:X\x X\->\R$ to be a kernel, it must be \emph{positive semi-definite}, in the sense that for any $n$ and any $\v{x}\in X^n$, the kernel matrix $\m{K}_{\v{x}\v{x}}$ is positive semi-definite.
For $X = \R^d$, a translation-invariant kernel $k(x,x') = k(x - x')$ is called \emph{stationary}, and can be characterized via Bochner's Theorem.
This result states that a translation-invariant bivariate function is positive definite if and only if it is the Fourier transform of a finite non-negative measure $\rho$, termed the \emph{spectral measure}.
This measure is an important technical tool for constructing kernels \cite{rasmussen06}, and for practical approximations such as \emph{Fourier feature} basis expansions \cite{rahimi08,hensman17}.
\subsection{A no-go theorem for kernels on manifolds}
We are interested in generalizing the Mat\'{e}rn family from the vector space setting to a compact Riemannian manifold $(M,g)$
such as the sphere or torus.
One might hope to achieve this by replacing Euclidean norms with the geodesic distances in \eqref{eqn:matern-kernel-eucl} and \eqref{eqn:rbf-kernel-eucl}.
In the latter case, this amounts to defining
\[
\label{eqn:rbf-geodesic}
k(x,x') = \sigma^2 \exp\del{-\frac{d_g(x,x')^2}{2 \kappa^2}}
\]
where $d_g$ is the geodesic distance with respect to $g$ on $M$.
Unfortunately, one can prove this is not generally a well-defined kernel.
\begin{theorem}
\label{thm:no-go}
Let $(M,g)$ be a complete, smooth Riemannian manifold without boundary, with associated geodesic distance $d_g$. If the geodesic squared exponential kernel \eqref{eqn:rbf-geodesic} is positive semi-definite for all $\kappa > 0$, then $M$ is isometric to a Euclidean space.
\end{theorem}
\begin{proof}
\textcite[Theorem 2]{feragen15}.
\end{proof}
Since Euclidean space is not compact, this immediately implies that \eqref{eqn:rbf-geodesic} is not a well-defined kernel on any compact Riemannian manifold without boundary.
We therefore call \eqref{eqn:rbf-geodesic} and its finite-smoothness analogues the \emph{na\"{i}ve generalization}.
In spite of this issue, the na\"{i}ve generalization is usually still positive semi-definite for some $\kappa$, and it has been used in a number of applied areas \cite{jaquier19}.
\textcite{feragen16} proposed a number of open problems arising from these issues.
In Section \ref{sec:torus}, we show that, on the torus, the na\"{i}ve generalization is \emph{locally correct} in a sense made precise in the sequel.
We now turn to an alternative approach, which gives well-defined kernels in the general case.
\subsection{Stochastic partial differential equations} \label{sec:spde}
\begin{figure}
\begin{subfigure}{.33\textwidth}
\centering
\includegraphics[height=2.5cm]{Figures/circle_kernel.pdf}
\label{fig:circle-kernel}
\end{subfigure}
\begin{subfigure}{.33\textwidth}
\centering
\includegraphics[height=2.5cm, trim=100 75 100 75, clip]{Figures/sphere_kernel.pdf}
\label{fig:sphere-kernel}
\end{subfigure}
\begin{subfigure}{.33\textwidth}
\centering
\includegraphics[height=2.5cm, trim=0 30 0 30, clip]{Figures/dragon_kernel.pdf}
\label{fig:dragon-kernel}
\end{subfigure}
\caption{The Mat\'{e}rn kernel $k_{1/2}(x, \cdot)$, defined on a circle, sphere and dragon. The point $x$ is marked with a red dot.
The height of the solid line and color, respectively, give the value of the kernel.
}
\label{fig:kernels}
\end{figure}
\textcite{whittle63} has shown that Mat\'{e}rn GPs on $X = \R^d$ satisfy the stochastic partial differential equation
\[
\label{eqn:spde-matern}
\del{\frac{2 \nu}{\kappa^2} - \lap}^{\frac{\nu}{2} + \frac{d}{4}}f = \c{W}
\]
for $\nu < \infty$, where $\lap$ is the Laplacian and $\c{W}$ is Gaussian white noise re-normalized by a certain constant.
One can show using the same argument that the limiting squared exponential GP satisfies
\[
\label{eqn:spde-rbf}
e^{-\frac{\kappa^2}{4} \Delta} f = \c{W}
\]
where $e^{-\frac{\kappa^2}{4} \Delta}$ is the (rescaled) heat semigroup \cite{evans10, grigoryan2009}.
This viewpoint on GPs has recently been reintroduced in the statistics literature by \textcite{lindgren11}, and a number of authors, including \textcite{simpson12, sarkka13b}, have used it to develop computational techniques, notably in the popular \textsc{inla} package \cite{rue09}.
One advantage of the SPDE definition is that generalizing it to the Riemannian setting is straightforward: one simply replaces $\lap$ with the Beltrami Laplacian and $\c{W}$ with the canonical white noise process with respect to the Riemannian volume measure.
The kernels of these GPs, computed in the sequel, are illustrated in Figure \ref{fig:kernels}.
Unfortunately, the SPDE definition is somewhat non-constructive: it is not immediately clear how to compute the kernel, and even less clear how to generalize familiar tools to this setting.
In practice, this restricts one to working with PDE-theoretic discretization techniques, such as Galerkin finite element methods, the efficiency of which depend heavily on the smoothness of $f$, and which can require significant hand-tuning to ensure accuracy.
It also precludes one from working in non-conjugate settings, such as classification, or from using recently-proposed techniques for scalable GPs via sparse inducing point methods \cite{titsias09a, hensman13, hensman17}, as they require one to either be able to compute the kernel point-wise, or compute the spectral measure, or both.
\subsection{State of affairs and contribution}
In this work, our aim is to generalize the standard theoretical tools available for GPs on $\R^d$ to the Riemannian setting.
Our strategy is to first study the problem for the special case of a $d$-dimensional torus.
Here, we provide expressions for the kernel of a Mat\'{e}rn GP in the sense of \textcite{whittle63} via \emph{periodic summation}, which yields a series whose first term is the na\"{i}ve generalization.
Building on this intuition, we develop a framework using Laplace--Beltrami eigenfunctions that allows us to provide expressions for the kernel and generalized spectral measure of a Mat\'{e}rn GP on a general compact Riemannian manifold without boundary.
The framework is fully constructive and compatible with sparse GP techniques for scalable training.
A number of closely related ideas, beyond those described in the preceding sections, have been considered in various literatures.
\textcite{solin2020} used ideas based on spectral theory of the Laplace--Beltrami operator to approximate stationary covariance functions on bounded domains of Euclidean spaces.
These ideas were applied, for instance, to model ambient magnetic fields using Gaussian processes by \textcite{solin2018}.
A truncated analog of the expression we provide in equation \eqref{eqn:mani-matern-formula} for the Riemannian Mat\'{e}rn kernel was previously proposed as a practical GP model by \textcite{coveney2020}---in this work, we \emph{derive} said expression from the SPDE formulation of Mat\'{e}rn GPs.
Finally, the Riemannian squared exponential kernel, also sometimes called the heat or diffusion kernel, has been studied by \textcite{gao2019}.
We connect these ideas with stochastic partial differential equations.
In this work, we concentrate on Gaussian processes $f : M \-> \R$ whose \emph{domain} is a Riemannian manifold.
We do not study models $f : \R \-> M$ where the \emph{range} is a Riemannian manifold---this setting is explored by \textcite{mallasto2018}.
\section{A first example: the $d$-dimensional torus} \label{sec:torus}
\begin{figure}
\<
&\mathclap{
\begin{tikzpicture}[baseline={([yshift=-.5ex]current bounding box.center)}]
\node at (-0.05,-0.1) {};
\node at (0,1) {};
\draw[thick] (0,0) node[circle, fill, inner sep=1] {} to[out=0, in=270] (0.5,0.5) node[circle, fill, inner sep=1] {} ;
\end{tikzpicture}
}
&
&\mathclap{
\begin{tikzpicture}[baseline={([yshift=-.5ex]current bounding box.center)}]
\draw[thick] (0,0) node[circle, fill, inner sep=1] {} to[out=180, in=270] (-0.5,0.5) to[out=90, in=180] (0,1) to[out=0, in=90] (0.5, 0.5) node[circle, fill, inner sep=1] {};
\end{tikzpicture}
}
&
&\mathclap{
\begin{tikzpicture}[baseline={([yshift=-.5ex]current bounding box.center)}]
\draw[thick] (0,0) node[circle, fill, inner sep=1] {} to[out=0, in=270] (0.5,0.5) to[out=90, in=0] (0,1.05) to[out=180, in=90] (-0.55,0.5) to[out=270, in=180] (0, -0.1) to[out=0, in=270] (0.6, 0.5) node[circle, fill, inner sep=1] {};
\end{tikzpicture}
}
&
&\mathclap{
\begin{tikzpicture}[baseline={([yshift=-.5ex]current bounding box.center)}]
\draw[thick] (0,0) node[circle, fill, inner sep=1] {} to[out=180, in=270] (-0.5,0.5) to[out=90, in=180] (0,1) to[out=0, in=90] (0.5, 0.45) to[out=270,in=0] (0,-0.1) to[out=180, in=270] (-0.6,0.5) to[out=90, in=180] (0,1.1) to[out=0, in=90] (0.6,0.5) node[circle, fill, inner sep=1] {};
\end{tikzpicture}
}
&
&\mathclap{
\begin{tikzpicture}[baseline={([yshift=-.5ex]current bounding box.center)}]
\draw[thick] (0,0)
node[circle, fill, inner sep=1] {}
to[out=0, in=270] (0.5,0.5)
to[out=90, in=0] (0,1.05)
to[out=180, in=90] (-0.55,0.5)
to[out=270, in=180] (0, -0.1)
to[out=0, in=270] (0.6, 0.5)
to[out=90, in=0] (0,1.15)
to[out=180, in=90] (-0.65,0.5)
to[out=270, in=180] (0, -0.2)
to[out=0, in=270] (0.7, 0.5)
node[circle, fill, inner sep=1] {};
\end{tikzpicture}
}
\nonumber
\\
&\mathclap{\norm{x - x'}}
&
&\mathclap{\norm{x - x' - 1}}
&
&\mathclap{\norm{x - x' + 1}}
&
&\mathclap{\norm{x - x' - 2}}
&
&\mathclap{\norm{x - x' + 2}}
\nonumber
\>
\caption{
The distances being considered in definitions \eqref{eqn:matern-torus} and \eqref{eqn:rbf-torus}.
}
\label{fig:dist-torus}
\end{figure}
To begin our analysis and build intuition, we study the $d$-dimensional torus $\bb{T}^d$, which is defined as the product manifold $\bb{T}^d = \bb{S}^1 \x ... \x \bb{S}^1$ where $\bb{S}^1$ denotes a unit circle\footnote{Note that $\bb{T}^2 = \bb{S}^1 \times \bb{S}^1$ is diffeomorphic but \emph{not} isometric to the usual donut-shaped torus whose metric is induced by embedding in $\R^3$. This is important, because it is the Riemannian metric structure that gives rise to the Laplace--Beltrami operator and hence to the generalized Mat\'{e}rn and squared exponential kernels. Diffeomorphisms do not necessarily preserve metric structure, so they may not preserve kernels.}.
Since functions on a circle can be thought of as periodic functions on $\R$, and similarly for $\bb{T}^d$ and $\R^d$, defining a kernel on a torus is equivalent to defining a periodic kernel.
For a general function $f : \R^d \-> \R$, one can transform it into a function $g : \bb{T}^d \-> \R$ by \emph{periodic summation}
\[ \label{eqn:periodic-summation}
g(x_1,...,x_d) = \sum_{n\in\Z^d} f(x_1 + n_1,...,x_d + n_d)
\]
where $x_j \in [0, 1)$ is identified with the angle $2\pi x_j$ and the point $\exp(2 \pi i x_j) \in \bb{S}^1$.
Define addition of two points in $\bb{S}^1$ by the addition of said numbers modulo $1$, and define addition in $\bb{T}^d$ component-wise.
Periodic summation preserves positive-definiteness, since it preserves positivity of the Fourier transform, which by Bochner's theorem is equivalent to positive-definiteness---see \textcite[Section 4.4.4]{scholkopf2002} for a formal proof.
This gives an easy way to construct positive-definite kernels on~$\bb{T}^d$.
In particular, we can generalize Mat\'{e}rn and squared exponential GPs from $\R^d$ to $\bb{T}^d$ by defining
\[
\label{eqn:matern-torus}
k_{\nu}(x,x')
=
\sum_{n\in\Z^d}
\frac{\sigma^22^{1-\nu}}{C'_\nu\Gamma(\nu)}
\del{
\sqrt{2\nu}
\frac{\norm{x-x' + n}}{\kappa}
}^\nu
K_\nu \del{
\sqrt{2\nu}
\frac{\norm{x-x' + n}}{\kappa}
}
\]
where $C'_{(\cdot)}$ is a constant given in Appendix \ref{apdx:examples} to ensure $k_{(\cdot)}(x,x) = \sigma^2$, and
\[
\label{eqn:rbf-torus}
k_{\infty}(x,x')
=
\sum_{n\in\Z^d}
\frac{\sigma^2}{C'_\infty}
\exp\del{
-
\frac{\norm{x-x' + n}^2}{2 \kappa^2}
}
\]
respectively.
We prove that these are the covariance kernels of the SPDEs introduced previously.
\begin{proposition}
\label{prop:matern-and-se-torus}
The Mat\'{e}rn (squared exponential) kernel $k$ in \eqref{eqn:matern-torus} (resp. \eqref{eqn:rbf-torus}) is the covariance kernel of the Mat\'{e}rn (resp. squared exponential) Gaussian process in the sense of \textcite{whittle63}.
\end{proposition}
\begin{proof}
Appendix \ref{apdx:torus-proof}.
\end{proof}
This result offers an intuitive explanation for \emph{why} the na\"{i}ve generalization based on the geodesic distance might fail to be positive semi-definite on non-Euclidean spaces for all length scales, yet work well for smaller length scales: on $\bb{T}^d$, it is \emph{locally correct} in the sense that it is equal to the first term in the periodic summation \eqref{eqn:matern-torus}.
To obtain the full generalization, one needs to take into account not just geodesic paths, but geodesic-like paths which include loops around the space---a Mat\'{e}rn GP incorporates global topological structure of its domain.
For the circle, these are visualized in Figure \ref{fig:dist-torus}.
For spaces where this structure is even more elaborate, definitions based purely on geodesic distances may not suffice to ensure positive semi-definiteness or good numerical behavior.
We conclude by presenting a number of practical formulas for Mat\'{e}rn kernels on the circle.
\begin{example}[Circle]
Take $M = \bb{S}^1$. For $\nu = \infty$, the kernel and spectral measure are
\<
k_{\infty}(x, x^\prime)
&=
\frac{\sigma^2}{C_\infty} \vartheta_3(\pi(x - x'), \exp(-2 \pi^2 \kappa^2))
&
\rho_{\infty}(n)
&=
\frac{\sigma^2}{C_\infty} \exp(-2 \pi^2 \kappa^2 n^2)
\>
where $n \in \Z$, $\vartheta_3(\cdot, \cdot)$ is the third Jacobi theta function \cite[equation 16.27.3]{abramowitz1972}, and $C_\infty = \vartheta_3(0, \exp(-2 \pi^2 \kappa^2))$.
This kernel is normalized to have variance $\sigma^2$.
\end{example}
\begin{example}[Circle]
Take $M = \bb{S}^1$. For $\nu = 1/2$, the kernel and spectral measure are
\<
k_{1/2}(x, x^\prime)
&=
\frac{\sigma^2}{C_{1/2}}
\cosh \del{\frac{\abs{x-x'} - 1/2}{\kappa}}
&
\rho_{1/2}(n)
&=
\frac{
2\sigma^2
\sinh\del{\nicefrac{1}{2 \kappa}}
}
{
C_{1/2} \kappa
}
\del{\frac{1}{\kappa^2} + 4\pi^2 n^2 }^{-1}
\!\!\!\!\!
\>
where $C_{1/2} = \cosh\del{\nicefrac{1}{2 \kappa} }$.
This kernel is normalized to have variance $\sigma^2$.
\end{example}
A derivation and more general formula, valid for $\nu = 1/2 + n$, $n \in \N$, can be found in Appendix \ref{apdx:examples}.
Note that these spectral measures are \emph{discrete}, as the Laplace--Beltrami operator has discrete spectrum.
Finally, we give the Fourier feature approximation \cite{rahimi08,hensman17} of the GP prior on $\bb{T}^1 = \bb{S}^1$,~which~is
\<
f(x)
&\approx
\sum_{n=-N}^{N}
\sqrt{\rho_{\nu}(n)}
\del[1]{
w_{n, 1} \cos(2 \pi n x)
+
w_{n, 2} \sin(2 \pi n x)
}
&
w_{n,j} &\~[N](0,1)
.
\>
We have defined Mat\'{e}rn and squared exponential GPs on $\bb{T}^d$ and given expressions for the kernel, spectral measure, and Fourier features on $\bb{T}^1$.
With sharpened intuition, we now study the general~case.
\section{Compact Riemannian manifolds} \label{sec:comp_man}
The arguments used in the preceding section are, at their core, based on ideas from abstract harmonic analysis connecting $\R^d$, $\bb{T}^d$, and $\Z^d$ as topological groups.
This connection relies on the algebraic structure of groups, which does not exist on a general Riemannian manifold.
As a result, different notions are needed to establish a suitable framework.
Let $(M,g)$ be a compact Riemannian manifold without boundary, and let $\lap_g$ be the Laplace--Beltrami operator.
Our aim is to compute the covariance kernel of the Gaussian processes solving the SPDEs \eqref{eqn:spde-matern} and \eqref{eqn:spde-rbf} in this setting.
Mathematically, this amounts to introducing an appropriate formalism so that one can calculate the desired expressions using spectral theory.
We do this in a fully rigorous manner in Appendix \ref{apdx:theory}, while here we present the main ideas and results.
First, we discuss how the operators on the left-hand side of SPDEs \eqref{eqn:spde-matern} and \eqref{eqn:spde-rbf} are defined.
By compactness of $M$, $-\lap_g$ admits a countable number of eigenvalues, which are non-negative and can be ordered to form a non-decreasing sequence with $\lambda_n\->\infty$ for $n\->\infty$.
Moveover, the corresponding eigenfunctions form an orthonormal basis $\{f_n\}_{n\in\Z_+}$ of $L^2(M)$, and $-\lap_g$ admits the representation
\[ \label{eqn:lap_spec}
-\lap_g f = \sum_{n=0}^\infty \lambda_n \innerprod{f}{f_n} f_n
\]
which is termed the \emph{Sturm--Liouville decomposition} \cite{chavel1984,canzani13}.
This allows one to define the operators $\Phi(-\lap_g)$ for a function $\Phi: [0, \infty) \to \R$, by replacing $\lambda_n$ with $\Phi(\lambda_n)$ in \eqref{eqn:lap_spec}, and specifying appropriate function spaces as domain and range to ensure convergence of the series in a suitable sense.
This idea is called \emph{functional calculus} for the operator $-\lap_g$.
Using it, we define
\< \label{eqn:operator_definitions}
\del{\frac{2 \nu}{\kappa^2} - \lap_g}^{\frac{\nu}{2}+\frac{d}{4}} f
&=
\sum_{n=0}^\infty \del{\frac{2 \nu}{\kappa^2} + \lambda_n}^{\frac{\nu}{2}+\frac{d}{4}} \innerprod{f}{f_n} f_n
\\
e^{-\frac{\kappa^2}{4} \lap_g} f
&=
\sum_{n=0}^\infty e^{\frac{\kappa^2 \lambda_n}{4}} \innerprod{f}{f_n} f_n
.
\>
Figure \ref{fig:eigenfuntions} illustrates the eigenfunctions $f_n$.
Note that when $M = \bb{T}^d$, the orthonormal basis $\{f_n\}_{n\in\Z_+}$ consists of sines and cosines, and thus the corresponding functional calculus is defined in terms of standard Fourier series.
This also agrees with the usual way of defining such operators in the Euclidean case using the Fourier transform.
\begin{figure}
\centering
\includegraphics[height=1.875cm, trim=0 0 20 0, clip]{Figures/circle_eigfs.pdf}
\includegraphics[height=1.875cm, trim=10 10 0 10, clip]{Figures/sphere_eigfs.pdf}
\includegraphics[height=1.875cm, trim=0 20 0 20, clip]{Figures/dragon_eigfs.pdf}
\caption{Examples of eigenfunctions of Laplace--Beltrami operator on a circle, sphere, and dragon. For the circle, the value of the eigenfunction is given by the (signed) distance between the solid line and dashed unit circle.
For the sphere and dragon, the value of the eigenfunction is given by the color.
}
\label{fig:eigenfuntions}
\end{figure}
Next, we proceed to define the remaining parts of the SPDEs.
The theory of stochastic elliptic equations described in \textcite{lototsky17} gives an appropriate notion of white noise $\c{W}$ for our setting, as well as a way to uniquely solve SPDEs of the form $\c{L} f = \c{W}$, where $\c{L}$ is a bounded linear bijection between a pair of Hilbert spaces.
We show that the operators
\<
\del{\frac{2 \nu}{\kappa^2} - \lap_g}^{\frac{\nu}{2}+\frac{d}{4}} &: H^{\nu + \frac{d}{2}}(M) \to L^2(M)
&
e^{\frac{\kappa^2}{4} \lap_g} &: \c{H}^{\frac{\kappa^2}{2}}(M) \to L^2(M)
\>
are bounded and invertible, where $H^s(M)$ are appropriately defined Sobolev spaces on the manifold, and $\c{H}^s(M)$ are the \emph{diffusion spaces} studied by \textcite{devito19}.
We prove that the solutions of our SPDEs in the sense of \textcite{lototsky17} are Gaussian processes with kernels equal to the reproducing kernels of the spaces $H^{\nu + d/2}(M)$ and $\c{H}^{\kappa^2/2}(M)$, which are given by \textcite{devito19}.
Summarizing, we get the following.
\begin{theorem}
Let $\lambda_n$ be eigenvalues of $-\lap_g$, and let $f_n$ be their respective eigenfunctions.
The kernels of the Mat\'{e}rn and squared exponential GPs on $M$ in the sense of \textcite{whittle63} are given by
\<
\label{eqn:mani-matern-formula}
k_{\nu}(x, x') &= \frac{\sigma^2}{C_\nu}\sum_{n=0}^\infty \del{\frac{2 \nu}{\kappa^2} + \lambda_n}^{-\nu-\frac{d}{2}} f_n(x)f_n(x')
\\
\label{eqn:mani-rbf-formula}
k_{\infty}(x, x') &= \frac{\sigma^2}{C_\infty}\sum_{n=0}^\infty e^{-\frac{\kappa^2}{2} \lambda_n} f_n(x)f_n(x')
\>
where $C_{(\cdot)}$ are normalizing constants chosen so that the average variance\footnote{The marginal variance $k_{(\cdot)}(x, x)$ can depend on $x$, thus we normalize the kernel by the average variance.}
over the manifold satisfies $\vol_g(M)^{-1} \int_X k_{(\cdot)}(x, x) \d x = \sigma^2$.
\end{theorem}
\begin{proof}
Appendix \ref{apdx:theory}.
\end{proof}
Our attention now turns to the spectral measure.
In the Euclidean case, the spectral measure, assuming sufficient regularity, is absolutely continuous---its Lebesgue density is given by the Fourier transform of the kernel.
In the case of $\bb{T}^d$, the spectral measure is discrete---its density with respect to the counting measure is given by the Fourier coefficients of the kernel.
Like in the case of the torus, for a compact Riemannian manifold the spectral measure is discrete---its density with respect to the counting measure is given by the generalized Fourier coefficients of the kernel with respect to the orthonormal basis $f_n(x)f_{n'}(x')$ on $L^2(M\x M)$.
For Mat\'{e}rn and square exponential GPs, these are
\<
\label{eqn:matern-spectral-manifold}
\rho_{\nu}(n) &= \frac{\sigma^2}{C_\nu} \del{\frac{2 \nu}{\kappa^2} + \lambda_n}^{-\nu-\frac{d}{2}}
&
\rho_{\infty}(n) &= \frac{\sigma^2}{C_\infty} \exp\del{-\frac{\kappa^2}{2} \lambda_n}
&
n &\in \N
.
\>
This allows one to recover most tools used in spectral theory of GPs.
In particular, one can construct a regular Fourier feature approximation of the GPs by taking the top-$N$ eigenvalues, and writing
\< \label{eqn:ff_approx}
f(x)
&\approx
\sum\limits_{n=0}^{N-1}
\sqrt{\rho(n)}
w_n
f_n(x)
&
w_n &\~[N](0,1)
.
\>
Other kinds of Fourier feature approximations, such as random Fourier features, are also possible.
We now illustrate an example in which these expressions simplify.
\begin{example}[Sphere]
Take $M = \bb{S}^d$ to be the $d$-dimensional sphere.
Then we have
\[
k_\nu(x,x') = \sum_{n=0}^\infty c_{n,d}\,\rho_\nu(n)\, \c{C}^{(d-1)/2}_n \del[2]{\cos\del[1]{d_g(x,x')}}
\]
where $c_{n,d}$ are constants given in Appendix \ref{apdx:examples}, $\c{C}_n^{(\cdot)}$ are the Gegenbauer polynomials, $d_g$ is the geodesic distance, and $\rho_\nu(n)$ can be expressed explicitly in terms of $\lambda_n = n(n+d-1)$ using \eqref{eqn:matern-spectral-manifold}.
See Appendix \ref{apdx:examples} for details on the corresponding Fourier feature approximation.
\end{example}
A derivation with further details can be found in Appendix \ref{apdx:examples}.
Similar expressions are available for many other manifolds, where the Laplace--Beltrami eigenvalues and eigenfunctions are known.
\subsection{Summary}
We conclude by summarizing the presented method of computing the kernel of Riemannian Mat\'{e}rn Gaussian processes defined by SPDEs.
The key steps are as follows.
\1 Obtain the Laplace--Beltrami eigenpairs for the given manifold, either analytically or numerically.
This step needs to be performed once in advance.
\2 Approximate the kernel using a finite truncation of the infinite sums \eqref{eqn:mani-matern-formula} or \eqref{eqn:mani-rbf-formula}.
\0
This kernel approximation can be evaluated pointwise at any locations, fits straightforwardly into modern automatic differentiation frameworks, and is simple to work with.
The resulting truncation error will depend on the smoothness parameter $\nu$, dimension $d$, and eigenvalue growth rate, which is quantified by Weyl's law \cite{zelditch2017}.
For $\nu < \infty$ convergence will be polynomial, and for $\nu = \infty$ it will be exponential.
If $\sigma^2$ is trainable, the constant $C_\nu$ which normalizes the kernel by its average variance can generally be disregarded.
If Fourier feature approximations of the prior are needed, for instance, to apply the pathwise sampling technique of \textcite{wilson20}, they are given by \eqref{eqn:ff_approx}.
\section{Illustrated Examples} \label{sec:examples}
Here we showcase two examples to illustrate the theory: dynamical system prediction and sample path visualization.
We focus on simplified settings to present ideas in an easy-to-understand manner.
\subsection{Dynamical system prediction}
\begin{figure}
\begin{center}
\begin{subfigure}{.26\linewidth}
\centering
\includegraphics[trim=50 45 50 50,clip]{Figures/pendulum_ground_truth}
\caption{Ground truth}
\label{fig:cylinder-ground-truth}
\end{subfigure}
\begin{subfigure}{.26\linewidth}
\centering
\includegraphics[trim=50 45 50 50,clip]{Figures/pendulum_learned_trajectories}
\caption{Posterior 95\% intervals}
\label{fig:cylinder-learned-trajectories}
\end{subfigure}
\begin{subfigure}{.44\linewidth}
\centering
\includegraphics[scale=0.75,trim=0 4 0 12,clip]{Figures/pendulum_predictive_intervals}
\caption{Posterior samples for one trajectory}
\label{fig:cylinder-single-trajectory}
\end{subfigure}
\end{center}
\caption{Visualization of the dynamical system's learned phase diagram.
Middle: we simulate 40 trajectories starting at the red dots, integrate the learned Hamilton's equations forward and backward in time until they approximately intersect other trajectories, and plot 95\% intervals in phase space.
Right: we simulate the trajectory beginning from the yellow dot, and plot mean and 95\% intervals.
}
\label{fig:cylinder}
\end{figure}
We illustrate how Riemannian squared exponential GPs can be used for predicting dynamical systems while respecting the underlying geometry of the configuration space the system is defined on.
This is an important task in robotics, where GPs are often trained within a model-based reinforcement learning framework \cite{deisenroth11,deisenroth13}.
Here, we consider a purely supervised setup, mimicking the model learning inner loop of said framework.
For a prototype physical system, consider an ideal pendulum, whose configuration space is the circle $\bb{S}^1$, and whose phase space is the cotangent bundle $T^*\bb{S}^1$, which is isometric to the cylinder $\bb{S}^1 \x \R$ equipped with the product metric.
The equations of motion are given by Hamilton's equations, which are parameterized by the Hamiltonian $H : T^*\bb{S}^1 \-> \R$.
To learn the equations of motion from observed data, we place a GP prior on the Hamiltonian, with covariance given by a squared exponential kernel on the cylinder, defined as a product kernel of squared exponential kernels on the circle and real line.
Following \textcite{hensman13}, training proceeds using mini-batch stochastic variational inference with automatic relevance determination.
The full setup is given in Appendix \ref{apdx:experiments}.
To generate trajectories from the learned equations of motion, following \textcite{wilson20}, we approximate the prior GP using Fourier features, and employ \eqref{eqn:pathwise} to transform prior sample paths into posterior sample paths.
We then generate trajectories by solving the learned Hamilton's equations numerically for each sample, which is straightforward because the approximate posterior is a basis function approximation and therefore easily differentiated in the ordinary deterministic manner.
Results can be seen in Figure \ref{fig:cylinder}.
From these, we see that our GP learns the correct qualitative behavior of the equations of motion, mirroring the results of \textcite{deisenroth11}.
\subsection{Sample path visualization}
To understand how complicated geometry affects posterior uncertainty estimates and illustrate the techniques on a general Riemannian manifold, we consider a posterior sample path visualization task.
We take $M$ to be the \emph{dragon} manifold from the Stanford 3D scanning repository, modified slightly to remove components not connected to the outer surface.
We represent the manifold using a $202490$-triangle mesh and obtain 500 Laplace--Beltrami eigenpairs numerically using the \emph{Firedrake} package \cite{rathgeber16}.
For training data, we introduce a ground truth function by fixing a distinguished point at the end of the dragon's snout, and compute the sine of the geodesic distance from that point.
We then observe this function at $52$ points on the manifold chosen from the mesh's nodes, and train a Mat\'{e}rn GP regression model with smoothness $\nu = 3/2$ by maximizing the marginal likelihood with respect to the remaining kernel hyperparameters.
By using the path-wise sampling expression \eqref{eqn:pathwise}, we obtain posterior samples defined on the entire mesh.
Results can be seen in Figure \ref{fig:dragon}.
Here, we see that posterior mean and uncertainty estimates match the manifold's shape seamlessly, decaying roughly in proportion with the geodesic distance in most regions.
In particular, we see that the two sides of the dragon's snout have very different uncertainty values, despite close Euclidean proximity.
This mimics the well-known \emph{swiss roll} example of manifold learning \cite[Section 6.1.1]{lee2007}, and highlights the value of using a model which incorporates geometry.
\begin{figure}
\begin{minipage}{0.01\textwidth}
\begin{subfigure}{\linewidth}
\centering
\includegraphics[width=\linewidth]{Figures/plasma.pdf}
\caption*{}
\label{fig:dragon-colorbar}
\end{subfigure}
\end{minipage}
\begin{minipage}{.95\textwidth}
\begin{subfigure}{.24\linewidth}
\centering
\includegraphics[width=\linewidth, trim=0 0 0 0, clip]{Figures/dragon/1_ground_thruth.pdf}
\caption{Ground truth}
\label{fig:dragon-ground-truth}
\end{subfigure}
\begin{subfigure}{.24\linewidth}
\centering
\includegraphics[width=\linewidth, trim=0 0 0 0, clip]{Figures/dragon/1_mean.pdf}
\caption{Mean}
\label{fig:dragon-mean}
\end{subfigure}
\begin{subfigure}{.24\linewidth}
\centering
\includegraphics[width=\linewidth, trim=0 0 0 0, clip]{Figures/dragon/1_standard_deviation.pdf}
\caption{Standard deviation}
\label{fig:dragon-sample-0}
\end{subfigure}
\begin{subfigure}{.24\linewidth}
\centering
\includegraphics[width=\linewidth, trim=0 0 0 0, clip]{Figures/dragon/1_sample_1.pdf}
\caption{One posterior sample}
\label{fig:dragon-sample-1}
\end{subfigure}
\end{minipage}
\begin{minipage}{0.01\textwidth}
\begin{subfigure}{\linewidth}
\centering
\includegraphics[width=\linewidth]{Figures/viridis.pdf}
\caption*{}
\label{fig:dragon-colorbar-right}
\end{subfigure}
\end{minipage}
\caption{Visualization of a Mat\'{e}rn Gaussian process posterior on the dragon.
We plot the true function values, posterior mean, marginal posterior variance, and one posterior sample evaluated on the entire mesh.
Here, black dots denote training locations, and color represents value of the corresponding functions.
Additional posterior samples can be seen in Appendix \ref{apdx:experiments}.
}
\label{fig:dragon}
\end{figure}
\section{Conclusion}
In this work, we developed techniques for computing the kernel, spectral measure, and Fourier feature approximation of Mat\'{e}rn and squared exponential Gaussian processes on compact Riemannian manifolds, thereby constructively generalizing standard Gaussian process techniques to this setting.
This was done by viewing the Gaussian processes as solutions of stochastic partial differential equations, and expressing the objects of interest in terms of Laplace--Beltrami eigenvalues and eigenfunctions.
The theory was demonstrated on a set of simple examples: learning the equations of motion of an ideal pendulum, and sample path visualization for a Gaussian process defined on a dragon.
This illustrates the theory in settings both where Laplace--Beltrami eigenfunctions have a known analytic form, and where they need to be calculated numerically using a differential equation or graphics processing framework.
Our work removes limitations of previous approaches, allowing Mat\'{e}rn and squared exponential Gaussian processes to be deployed in mini-batch, online, and non-conjugate settings using variational inference.
We hope these contributions enable practitioners in robotics and other physical sciences to more easily incorporate geometry into their models.
\section*{Broader Impact}
This is a purely theoretical paper.
We develop technical tools that make Mat\'{e}rn Gaussian processes easier to work with in the Riemannian setting.
This enables practitioners who are not experts in stochastic partial differential equations to model data that lives on spaces such as spheres and tori.
We envision the impact of this work to be concentrated in the physical sciences, where spaces of this type occur naturally.
Since the state spaces of most robotic arms are Riemannian manifolds, we expect these ideas to improve performance of model-based reinforcement learning by making it easier to incorporate geometric prior information into models.
Since climate science is concerned with studying the globe, we also expect that our ideas can be used to model environmental phenomena, such as sea surface temperatures.
By employing Gaussian processes for data assimilation and building them into larger frameworks, this could facilitate more accurate climate models compared to current methods.
These impacts carry forward to potential generalizations of our work.
We encourage practitioners to consider impacts on their respective disciplines that arise from incorporating geometry into models.
\section*{Acknowledgments and Disclosure of Funding}
VB was supported by the St. Petersburg Department of Steklov Mathematical Institute of Russian Academy of Sciences and by the Ministry of Science and Higher Education of the Russian Federation, agreement N\textsuperscript{\underline{o}} 075-15-2019-1620.
PM was supported by the Ministry of Science and Higher Education of the Russian Federation, agreement N\textsuperscript{\underline{o}} 075-15-2019-1619.
VB and PM were supported by "Native towns", a social investment program of PJSC Gazprom Neft, and by the Department of Mathematics and Computer Science of St. Petersburg State University.
AT was supported by the Department of Mathematics at Imperial College London.
\printbibliography
\newpage
| {'timestamp': '2022-03-22T01:52:11', 'yymm': '2006', 'arxiv_id': '2006.10160', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10160'} | arxiv |
\section{Introduction}
\label{sec:introduction}
\IEEEPARstart{S}{emantic} segmentation is to assign each pixel in the scene a semantic class, which is currently an active research topic in computer vision. In recent years, image semantic segmentation has achieved unprecedented accuracy benefited from the great progress of deep convolutional neural networks (DCNN)~\cite{long2015fully} and various datasets (\textit{e.g.}, Cityscapes~\cite{Cordts_2016_CVPR}, CamVid~\cite{brostow2009semantic}, and UAVid~\cite{lyu2020uavid}).
However, many real-world applications have strong demands for fast and accurate video semantic segmentation, \textit{e.g.}, robotics~\cite{kostavelis2015semantic}, autonomous driving~\cite{teichmann2018multinet}, and video surveillance~\cite{Liu_2017_CVPR}.
Compared to images, videos involve much larger volume of data, and thus always require more efficient segmentation algorithms.
\begin{figure}[t]
\begin{center}
\includegraphics[width=1.0\linewidth]{1.pdf}
\end{center}
\caption{\textbf{Illustration of distortion phenomenon in feature propagation.} The segmentation results of an example video produced by DFF~\cite{zhu2017deep} are demonstrated, where $T+i$ denotes the $i$-th frame from the key frame $T$. In particular, we also give the ground-truth segmentation of the frame $T+9$ for comparison. Red rectangles highlight the distorted regions caused by inaccurate optic flow estimation. Best viewed in color and zoom in.}
\label{dff_distortion}
\end{figure}
A naive approach for video segmentation is to directly apply the image segmentation model in a per-frame way. But such deployment is generally unacceptable in practice due to too heavy computational burden. Actually, the consecutive frames of a video are often similar in a large portion of content, and it is unnecessary to reprocess every pixel of the video frame using an image segmentation model~\cite{xu2018dynamic}. Then an intuitive idea for video semantic segmentation is to reuse the features extracted from the previous frames when segmenting the current frame~\cite{zhu2017deep}. Naturally, the feature propagation is proposed to reduce the overall computational complexity.
\IEEEpubidadjcol
In recent years, some feature propagation based methods have been proposed for video semantic segmentation, \textit{e.g.}, DFF~\cite{zhu2017deep}, NetWarp~\cite{gadde2017semantic}, DVSNet~\cite{xu2018dynamic}, and Accel~\cite{jain2019accel}. These methods first compute the optical flow between the key frame and the current frame, and then produce the features of the current frame by propagating the features of the key frame under guidance of optical flow. Here the bilinear interpolation is usually used as the feature warping operator. The CNN-based optical flow estimation methods (\textit{e}.\textit{g}., FlowNet~\cite{dosovitskiy2015flownet,ilg2017flownet}, FlowNet2.0~\cite{ilg2017flownet}) are preferred since they are easy to be embedded into the video segmentation framework for end-to-end training. Evidently, the accuracy of optical flow estimation would determine the quality of propagated features and performance of semantic segmentation.
Despite the great progress in the past decades, accurate optical flow estimation remains a challenging problem~\cite{liu2019selflow}. In particular, the occlusion caused by scene motion makes the optical flow estimation ill-posed since no visual correspondence exists for the occluded pixels~\cite{neoral2018continual}. When the inaccurate optical flow is used in feature propagation, the produced features would get distorted and incorrect segmentation results may be further generated. In addition, for small or slender areas of a single class (\textit{e}.\textit{g}., pedestrian, pole), a slight offset of predicted optical flow would cause sensible distortion, which is especially serious for long-distance propagation. We show the typical distortion phenomenon in Fig.~\ref{dff_distortion}. The distortion of feature propagation needs to be carefully tackled in video semantic segmentation.
\begin{figure}[t]
\begin{center}
\includegraphics[width=1.0\linewidth]{2.pdf}
\end{center}
\caption{\textbf{Visualization of false correction.} The propagated and corrected features are visualized and represented by their segmentation results. The upper case is from DFF and the blow one is from Accel50. Red rectangles highlight the areas corrected wrongly. Best viewed in color.}
\label{overly_correction}
\end{figure}
Some existing methods can alleviate feature distortion by modulating the propagated features. For example, DFF~\cite{zhu2017deep} attaches a scale field to optical flow estimation and adjusts the propagated features via element-wise multiplication. Accel~\cite{jain2019accel} proposes to extract features from the current frame with a lightweight model and then fuse the extracted and propagated features to perform semantic segmentation. However, these works equally treat every pixel of the current frame without distinguishing the quality of propagated features among different pixels. Consequently, the regions where the features are correctly propagated may be modulated to be wrong, namely, false correction may occur. We show typical cases of such a phenomenon in Fig.~\ref{overly_correction}. Besides, we check the ratio of the number of pixels wrongly and rightly rectified, and the statistics of different methods on \textit{Cityscapes val subset} are shown in Fig.~\ref{exp_correct_error}. Evidently, many correct features are wrongly rectified, even for models equipped with a heavy network (\textit{e}.\textit{g}., Accel50).
\begin{figure}[t]
\begin{center}
\includegraphics[width=0.7\linewidth]{3.pdf}
\end{center}
\caption{\textbf{Statistics of false correction on Cityscapes val subset.} Here the ratio of the number of pixels wrongly and rightly rectified is particularly calculated for different methods. It can be seen that some correct propagated features would be wrongly rectified, and our proposed method can achieve the best result. }
\label{exp_correct_error}
\end{figure}
In this work, we propose a novel distortion-aware feature correction method to rectify the propagated features, aiming at improving the accuracy of video semantic segmentation at a low price. Our key idea is to correct the features on the distorted regions while reserving the propagated features for other regions. With such a design, a lightweight network can be enough to perform the rectification. To this end, we need first to identify the distorted regions. An intuitive approach is to extract features from the current frame using an image segmentation model, and then get the misalignment regions by comparing the extracted and propagated features. However, extracting the features would involve too high computation cost. To tackle the issue, we propose to get the distorted regions through image comparison of video frames. Actually, the distortion is mainly caused by inaccurate optical flow, \textit{i.e.}, the distorted regions are essentially the regions where the optical flow is miscalculated. So we propose to concurrently propagate video frames with the same optical flow as in feature propagation, and then compare the propagated frame and current frame in the image space to get the distorted regions. Our proposed method essentially utilizes the consistency of the distortion patterns for images and features, as shown in Fig.~\ref{distortion_pattern}. Following this idea, we propose a very lightweight network to predict the distortion maps.
\begin{figure}[t]
\begin{center}
\includegraphics[width=1.0\linewidth]{4.pdf}
\end{center}
\caption{\textbf{Illustration of distortion consistency for images and features.} We provide the segmentation results of the propagated and extracted features in the first row, and the propagated image from previous frame and current frame in the second row. Red rectangles highlight the main distorted regions. It can be seen that similar distortion patterns present for images and features. Best viewed in color and zoom in.}
\label{distortion_pattern}
\end{figure}
Then we propose a feature correction module (FCM) to perform distortion correction on the propagated features. Here the predicted distortion maps are utilized in two folds. First, we propose a CFNet to extract the correction cues from the current frame, and enforce it to focus on the distorted regions by applying the distortion map to the calculation of training loss. CFNet can be designed very lightweight since only the capacity to process the distorted regions is required. Second, FCM uses the distortion maps to identify the important regions on which the propagated features need to be rectified greatly by correction cues. Consequently, the correction cues from the current frame dominate the distorted regions while the propagated features dominate other regions. Finally, we conduct semantic segmentation on the corrected features.
The contributions of this work are summarized as
\begin{itemize}
\item We propose a novel distortion-aware feature correction method for video semantic segmentation, which can effectively boost the segmentation performance at a low price by focusing on the distorted regions.
\item We propose a lightweight network to predict the distorted regions of propagated features, which works in the image space and can effectively guide feature correction.
\item We experimentally evaluate the effectiveness of our proposed method, and the results on Cityscapes, CamVid, and UAVid demonstrate the superiority of our method to previous state-of-the-art methods, especially for long-distance feature propagation.
\end{itemize}
The rest of this paper is organized as follows. We review the related works on image and video semantic segmentation, optical flow estimation, and attention mechanism in Section~\ref{sec:related}. Section~\ref{sec:approach} provides the details of our approach, and Section~\ref{sec:exp} experimentally evaluates the proposed method. Finally, we conclude the work in Section~\ref{sec:conclusion}.
\section{Related Work} \label{sec:related}
\subsection{Image Semantic Segmentation}
Benefited from the rapid development of DCNN~\cite{iandola2016squeezenet, simonyan2014very, he2016deep, szegedy2015going, huang2017densely}, more and more semantic segmentation networks spring up. Specifically, the fully convolutional network (FCN)~\cite{long2015fully} firstly uses the convolutional layers to replace fully-connected layers, and better performance is achieved. Inspired by FCN, many extensions~\cite{zhao2017pyramid, wu2019wider, lin2017refinenet} have been proposed, which together advance image semantic segmentation. The dilated layers~\cite{chen2018deeplab, yu2015multi} are also introduced to replace the pooling layers, which can better balance the computational cost and size of receptive fields. In addition, \cite{chen2018deeplab, chen2014semantic, zheng2015conditional} propose to use the conditional random field (CRF) to refine the results of image segmentation. Recently, spatial pyramid pooling~\cite{he2015spatial} and atrous spatial pyramid pooling (ASPP)~\cite{chen2017rethinking, chen2018deeplab} are respectively used in PSPNet~\cite{zhao2017pyramid} and DeepLab~\cite{chen2018deeplab} to capture multi-scale contextual information. MPF~\cite{wang2018detecting} uses a new structural context descriptor and a self-weighted multiview clustering method for robust group detection. Priori s-CNNs~\cite{wang2017joint} learns priori location information at superpixel level and adopts a soft restricted MRF energy function to reduce over smoothness. CCNet~\cite{Huang_2019_ICCV} contains a criss-cross attention module to harvest the contextual information. HRNet~\cite{Sun_2019_CVPR} maintains the high resolution feature in the whole process and fuses multi-resolution features repeatedly for reliable and discriminative representations. SANet~\cite{Zhong_2020_CVPR} applies the pixel-group attention to capture spatial-channel inter-dependencies. Li \textit{et al}.~\cite{Li_2020_CVPR} propose to generate data-dependent routes for adapting to the scale distribution of each image. Lin \textit{et al}.~\cite{lin2020cross} propose to use skeleton representation to effectively bridge the synthesis and real domains and achieve comparable performance on multi-person part segmentation without any human-annotated labels. Ca-crfs Net~\cite{ji2020encoder} introduces cascaded CRFs into the decoder to learn boundary information and enhance the ability of object boundary location. The great progress of image semantic segmentation offers foundation for video semantic segmentation.
\begin{figure*}[t]
\begin{center}
\includegraphics[width=0.8\linewidth]{5.pdf}
\end{center}
\caption{\textbf{Framework of our proposed approach}. $F$ and $F^{P}$ represent the original video frame and propagated one from previous frame, respectively. Particularly, the frames $F_{t}$ and $F_{t+3}$ are selected as the key frames for illustration. In real deployment, the key frames can be selected by a fixed-interval schedule like in~\cite{zhu2017deep} or an adaptive schedule like in~\cite{xu2018dynamic} and~\cite{li2018low}. For the key frames, the feature $\mathbf{f}^{S}$ is extracted via an image segmentation network Net$_{seg}$. For the non-key frames, the propagated feature $\mathbf{f}^{P}$ is first produced through frame-by-frame propagation, and then is rectified into $\mathbf{f}^{C}$ by feature correction module (FCM) that combines the correction cues extracted from the current frame under the guidance of the distortion map $M^{D}$. Here $M^{D}$ is predicted by a lightweight network DMNet taking as input the propagated and current frames. Best viewed in color.}
\label{framework}
\end{figure*}
\subsection{Optical Flow Estimation}
Optical flow is a representative pattern describing the apparent motion of objects in the video. Optical flow estimation is a fundamental task in the video analysis domain. Classical variational approaches formulate optical flow estimation as an energy minimization problem~\cite{horn1981determining,anguita2009optimization}. Such methods are effective for small motion, but tend to fail when displacements are relatively larger. Recent works use convolutional neural networks (CNNs) to improve sparse matching by learning an effective feature embedding~\cite{dosovitskiy2015flownet,ilg2017flownet,sun2018pwc,zhai2019optical}.
Although current methods can generate satisfactory optical flow in most common cases, it is still a challenging problem to calculate accurate optical flow for occlusion areas. Most methods detect occlusion by consistency check on the estimated forward and backward optical flow~\cite{chen2016full,sundaram2010dense}, and then extrapolating the occluded areas. But the used optical flow would be adversely affected by the occlusion. Evidently, the propagated features under the guidance of inaccurate optical flow would be severely distorted, especially for occlusion areas.
Actually, most video semantic segmentation methods prefer the current state-of-the-art CNN networks for predicting the optical flow~\cite{dosovitskiy2015flownet,ilg2017flownet,sun2018pwc,ranjan2017optical} because they are easily embedded for end-to-end training. However, these methods do not explicitly deal with occlusion, and consequently video segmentation would suffer from severe feature distortion. Thus how to deal with the feature distortion efficiently and effectively is crucial for the optical flow based video segmentation methods.
\subsection{Attention Mechanism}
Attention mechanism has been widely used in computer vision. It can effectively increases the representational power of neural networks by selectively weighting the feature maps. For example, ~\cite{hu2018squeeze} proposes a squeeze-and-excitation (SE) module to adaptively recalibrate channel-wise feature responses by explicitly modeling interdependencies between channels. OCNet~\cite{yuan2018ocnet} and DANet~\cite{fu2019dual} utilize self-attention mechanism to harvest the contextual information. Chen~\textit{et al}.~\cite{chen2018reverse} propose the reverse attention to guide side-output residual learning in a top-down manner. Chen~\textit{et al}.~\cite{chen2018embedding} propose a visual attention mechanism which can bridge high-level semantic information to help the shallow layers locate salient objects and filter out noisy response in the background region. BiANet~\cite{zhang2020bilateral} introduces a bilateral attention module to focus on the foreground region with a gradual refinement style and recover potentially useful salient information in the background region. Fan~\textit{et al}.~\cite{fan2020pranet} proposes a parallel reverse attention network to aggregate the features in high-level layers and mine the boundary cues using the reverse attention module. In this paper, we propose to only focus on the distorted regions of propagated features under the guidance of predicted distortion maps.
\subsection{Video Semantic Segmentation}
Different from static images, videos embody useful temporal information that can be exploited.
So many previous works focus on modeling cross-frame relations to integrate the information from different frames to boost the semantic segmentation accuracy. STFCN~\cite{fayyaz2016stfcn} utilizes a spatial-temporal LSTM over per-frame CNN features. Nilsson and Sminchisescu~\cite{nilsson2018semantic} propose to use the gated recurrent units to propagate semantic labels. Gadde~\textit{et al}.~\cite{gadde2017semantic} propose to fuse the features warped from the key frame and those from the current frame. V2V~\cite{tran2016deep} utilizes a 3D CNN to perform a voxel-level prediction. Wang~\textit{et al}.~\cite{wang2019superpixel} propose a metadata-based global projection model with the coordinate transformation to estimate motion information between frames.
On the other hand, many works reduce the overall computation cost of video semantic segmentation by utilizing the content continuity of consecutive frames. Clockwork Net~\cite{shelhamer2016clockwork} updates different levels of feature maps with different frequencies. DFF~\cite{zhu2017deep} estimates the optical flow fields from the key frame to other frames and then propagates the high-level features using the predicted optic flows. DVSNet~\cite{xu2018dynamic} builds a decision model to dynamically choose the key frames, which can achieve better balance between quality and efficiency. Li~\textit{et al}.~\cite{li2018low} propose spatially variant convolution to adaptively fuse the features over time. Accel~\cite{jain2019accel} proposes a reference branch to extract high-quality segmentation from the key frames and an update branch to efficiently extract low-quality segmentation from the current frames, and then fuses them to improve the segmentation accuracy. TDNet~\cite{hu2020temporally} distributes several sub-networks over sequential frames and then recomposes the extracted features for segmentation via an attention propagation module.
A related task to video semantic segmentation is video object segmentation. Several works~\cite{wang2005interactive,li2005video,price2009livecut} reduce the structural complexity of the graphical model with spatio-temporal superpixels. Chen~\textit{et al}.~\cite{chen2019motion} propose a two-stage framework of integrating motion and appearance cues for foreground object segmentation in unconstrained videos. Liu~\textit{et al}.~\cite{liu2020guided} propose a guided co-segmentation network to simultaneously incorporate the short-term, middle-term, and long-term temporal inter-frame relationships.
In this work, we follow the route of feature propagation for video semantic segmentation. Different from previous works that equally treat every pixel of a video frame, we propose to focus on the distorted regions when rectifying the propagated features. In this way, the semantic segmentation results can be more effectively enhanced, and the used network can be more lightweight for high efficiency.
\section{Our Approach} \label{sec:approach}
In this work, we try to boost the accuracy of video semantic segmentation on the non-key frames effectively and efficiently under the framework of optical flow based feature propagation. To this end, we propose a distortion-aware feature correction method, and the core idea is to correct the features on the distorted regions while reserving the propagated features for other regions. For such an idea, we need to design an elegant solution to address the following issues, namely, 1) how to identify the distorted regions, 2) how to extract the correction cues from the current frame, and 3) how to effectively perform feature correction.
In the following, we first introduce the framework of our proposed method. Then we elaborate on two main components of the proposed method: distortion map prediction and feature correction. Finally, we provide training details of our proposed network.
\subsection{Framework}
The framework of our proposed approach is illustrated in Fig.~\ref{framework}, where semantic segmentation is performed on the feature of each frame individually.
To be specific, each of the video frames is treated as the key or non-key frame. For the key frames, we directly conduct image semantic segmentation to get the results using an off-the-shelf network, and the intermediate features are propagated to subsequent non-key frames. In particular, we propagate the features in a frame-by-frame way during inference. That is, the feature of the current frame is first produced by propagating that of the previous frame, in which the predicted optical flow is used as the guidance and the bilinear interpolation is usually adopted as the warping operator. Along with feature propagation, we also propagate the video frame with the same optical flow, resulting in the propagated frame. For the non-key frames, we first feed the propagated frame and current frame into our proposed distortion map network (DMNet) to predict a distortion map, which actually represents the distortion pattern of the propagated feature. Then we use the current frame to rectify the propagated feature under the guidance of the predicted distortion map. We complete such feature rectification in the proposed feature correction module (FCM). Finally, we conduct semantic segmentation on the corrected feature to get the segmentation result of the current frame.
The key components of our proposed framework are the distortion map prediction and feature correction. In our implementation, we particularly adopt DeepLabv3+~\cite{chen2018encoder} as the image semantic segmentation model due to its great performance in both accuracy and efficiency. The modified FlowNet2-S~\cite{ilg2017flownet} is used for optical flow estimation.
\begin{figure}[t]
\begin{center}
\includegraphics[width=1.0\linewidth]{6.pdf}
\end{center}
\caption{\textbf{Illustration of our proposed DMNet}. Following the design of siamese networks, DMNet takes in the propagated frame and current frame to perform feature extraction and similarity computation.}
\label{DMNet}
\end{figure}
\begin{figure}[t]
\begin{center}
\includegraphics[width=0.9\linewidth]{7.pdf}
\end{center}
\caption{\textbf{Illustration of training DMNet}. $Flow_{t}$ represents the predicted optical flow from $F_{t}$ to $F_{t+k}$. The distortion map for training DMNet is obtained by calculating the difference between the segmentation results of the propagated features and current frame.}
\label{DMNet_training}
\end{figure}
\subsection{Distortion Map Prediction}
In this work, we propose a distortion map network (DMNet) to predict the distorted area of propagated features. Here we do not extract any high-level feature from the current frame since it involves too high computation cost. Instead, we compare the propagated frame and the current frame to get the distorted regions, which actually exploits the consistency of distortion pattern for images and features.
To be specific, we follow the design of siamese networks to build DMNet that calculates the difference between the propagated frame and the current frame, as shown in Fig.~\ref{DMNet}. To achieve high computational efficiency, the feature extractor is designed to only comprise four separable convolutional layers interlaced with BatchNorm and ReLU layers. Consequently, the involved computation cost is nearly negligible. Then we can calculate the cosine similarity of two features, resulting a similarity map ${S}$. Formally, let $\mathbf{f}_{t}$ and $\mathbf{f}^{D}_{t}$ denote the features from the current frame $F_{t}$ and propagated frame $F^{P}_{t}$, respectively. Then
\begin{equation}
S_{t}(p)=\langle\bar{\mathbf{f}}_{t}(p), \bar{\mathbf{f}}^{D}_{t}(p)\rangle=\bar{\mathbf{f}}^{D}_{t}(p) \bar{\mathbf{f}}^{T}_{t}(p),
\end{equation}
where $p$ denotes the spatial position, $\bar{\mathbf{f}}=\mathbf{f}/\|\mathbf{f}\|_{2}$ denotes the $\ell_{2}$-normalized feature, and $\bar{\mathbf{f}}^{T}$ is the transpose of $\bar{\mathbf{f}}$. Obviously, the distorted regions would have lower value on the similarity map. To obtain the distortion map $M^D_{t}$, we normalize the similarity map as
\begin{equation}
M^D_{t}=(-S_{t}+1)/2.
\end{equation}
In our implementation, we use the supervised learning to train DMNet, as shown in Fig.~\ref{DMNet_training}. Here the ground truth of distortion maps is obtained by calculating the difference of segmentation results between the propagated feature and extracted feature from the current frame. To be specific, we propagate the feature of $F_{t}$ to $F_{t+k}$ to get the propagated feature $\mathbf{f}^{P}_{t+k}$, where $F_{t+k}$ denotes the $k$-th frame from the frame $F_{t}$. Then we get the segmentation result of $\mathbf{f}^{P}_{t+k}$ via an argmax operation. Meanwhile, we get the segmentation result of $F_{t+k}$ using the image segmentation model.
Finally, we produce the distortion map for DMNet by applying the XOR operator on two segmentation results.
\begin{figure}[t]
\begin{center}
\includegraphics[width=1.0\linewidth]{8.pdf}
\end{center}
\caption{\textbf{Illustration of feature correction module (FCM)}. Here the predicted distortion map $M^{D}_{t}$ is used in two folds. First, it guides the training of the network to extract correction cues from the current frame by weighting the loss of different regions. Second, it determines how to fuse the propagated feature $\mathbf{f}^{P}_{t}$ and extracted correction cue $\mathbf{f}^{CC}_{t}$ to get the corrected feature $\mathbf{f}^{C}_{t}$. Best viewed in color.}
\label{FCM}
\end{figure}
\begin{figure}[t]
\begin{center}
\includegraphics[width=1.0\linewidth]{9.pdf}
\end{center}
\caption{\textbf{Illustration of training strategy}. We propose dual deep supervision (DDS) to improve the training of the network. Here $L_{P}$ and $L_{C}$ denote the loss calculated for feature propagation and correction, respectively. Best viewed in color.}
\label{framework_training}
\end{figure}
\subsection{Feature Correction Module}
In this work, we explicitly rectify the propagated feature using the information of the current frame. And we propose a feature correction module (FCM) to complete such feature rectification. Specifically, we consider two key goals of video semantic segmentation: high segmentation accuracy and low computation cost. To compromise two goals, we particularly propose to utilize the predicted distortion map to guide the feature correction.
In FCM, we utilize the distortion map in two folds, as shown in Fig.~\ref{FCM}.
First, it is used to guide the extraction of correction cues from the current frame. Here it is expected that the correction cue can produce accurate segmentation results over distorted regions and meanwhile the used network is lightweight enough for efficient computation. To this end, we propose CFNet in this work that mainly consists of ten convolutional layers interlaced with batchnorm and LReLU layers for feature encoding and four deconvolutional layers interlaced with LReLU layer for feature decoding. Then we use the distortion map to weight the \textit{CrossEntropy} loss when training CFNet, namely, distortion-guide feature learning (DGFL) is constructed. The loss function is
\begin{equation}
L_{DGFL}=-\frac{1}{HW}\sum_{h \in H,w \in W}M^{D}_{t}(h,w)\log{p_{t}^{CC}(h,w)},
\end{equation}
where $M^{D}_{t}$ is the distortion map and $p_{t}^{CC}$ is the predicted probability towards the ground truth from $\mathbf{f}_{t}^{CC}$. Through such loss weighting, CFNet would pay more attention on the distorted regions than others, and a lightweight model is enough to effectively extract discriminative features.
Second, the distortion map is used to determine how to rectify the propagated feature. Let $\mathbf{f}^{P}_{t}$ denote the propagated feature from the key frame to the current frame $F_{t}$, $\mathbf{f}^{CC}_{t}$ be the extracted correction cue, and $\mathbf{f}^{C}_{t}$ be the corrected feature.
FCM adopts the weighted sum to perform the feature correction, in which the features on the distorted regions are mainly rectified, namely, distortion-guided feature correction (DGFC) is constructed. Then we have
\begin{equation}
\mathbf{f}^{C}_{t}=\mathbf{f}^{P}_{t}\odot(1-M^{D}_{t})+\mathbf{f}^{CC}_{t}\odot M^{D}_{t},
\end{equation}
where $\odot$ represents the spatially element-wise multiplication.
It can be seen that the features on the distorted regions are dominated by the correction cue $\mathbf{f}^{CC}_{t}$ while the features on other regions are dominated by the propagated features $\mathbf{f}^{P}_{t}$.
\subsection{Training Strategy}
Here we explain the training strategy of our proposed method, which is illustrated in Fig.~\ref{framework_training}. Before elaborating on the details, we briefly introduce the training procedure~\cite{zhu2017deep} widely used in previous works. For video semantic segmentation, let ($F_{1}$, $F_{3}$, GT) denote one training sample, where $F_{1}$ and $F_{3}$ are the key frame and current frame respectively, and GT is the segmentation ground truth of $F_{3}$. During training, $F_{1}$ is fed into the image segmentation model to extract features, and meanwhile the optical flow between $F_{1}$ and $F_{3}$ is estimated with FlowNet. Then the extracted features are propagated to $F_{3}$, and the \textit{CrossEntropy} loss at $F_3$ is calculated to train networks. In practice, $F_{1}$ is randomly selected from a $10$ frames video clip and $F_{3}$ is always the last one with ground truth, which can enrich the diversity of training samples.
However, the above training procedure may be unstable due to inaccuracy of optical flow estimation, especially for long-distance propagation (\textit{e}.\textit{g}., larger than $5$ frames). In this work, we propose \emph{dual deep supervision} (DDS) to improve network training by providing more supervision. Specifically, we add an intermediate frame for each training sample, denoted by $F_{2}$, to reduce the propagation distance, and meanwhile impose the supervision signal on $F_{2}$. Note that our method propagates the features frame-by-frame in the inference phase, and thus two-warp operation in the training phase is more appropriate than the original one.
In our experiments, $F_{2}$ is randomly selected to ensure the diversity of training samples. To be specific, we extract the features of $F_{1}$, and conduct feature propagation twice ($F_1$ $\rightarrow$ $F_2$ $\rightarrow$ $F_3$). Then we produce the pseudo label of $F_2$ using the image segmentation model for more supervision. Actually, using the pseudo label has been a natural and popular way to improve the segmentation quality in domain adaptation~\cite{zou2018unsupervised} and semi-supervised learning~\cite{hungadversarial}. Finally, we use the generated pseudo label and ground truth to supervise both the feature propagation and correction procedures on $F_{2}$ and $F_{3}$, as shown in Fig.~\ref{framework_training}. In particular, the propagation loss $L_{P}$ works on the warped features $\mathbf{f}_{t}^{P}$ for improving the quality of optical flow, and the correction loss $L_{C}$ works on the rectified features $\mathbf{f}_{t}^{C}$ for enhancing the ability of feature correction. The two losses can be written as :
\begin{equation}
L_{P}=-\frac{1}{HW}\sum_{h \in H,w \in W}\log{p^{P}_{t}(h,w)},
\end{equation}
\begin{equation}
L_{C}=-\frac{1}{HW}\sum_{h \in H,w \in W}\log{p^{C}_{t}(h,w)},
\end{equation}
where $p^{P}_{t}$ and $p^{C}_{t}$ are the predicted probability towards the ground truth from $\mathbf{f}^{P}_{t}$ and $\mathbf{f}^{C}_{t}$, respectively.
Taking the loss of feature learning in FCM $L_{DGFL}$, our final loss for one single frame is
\begin{equation}
L=(L_{P}+L_{C}+L_{DGFL})/3.
\end{equation}
Our method consists of four main components, \textit{i}.\textit{e}., Net$_{seg}$, FlowNet, DMNet, and CFNet. Here we explain how they are trained. Net$_{seg}$ is pretrained on ImageNet and then finetuned on a particular segmentation dataset (\textit{e}.\textit{g}., Cityscapes, CamVid, and UAVid). DMNet is trained with the generated ground-truth distortion maps. Net$_{seg}$ and DMNet would keep fixed in the following training procedure. FlowNet is pretrained on the synthetic Flying Chairs dataset~\cite{dosovitskiy2015flownet} and then jointly trained with the randomly initialized CFNet by following the proposed DDS training strategy. For each step of training, we adopt the Adam optimizer~\cite{kingma2014adam} with $\beta_{1}=0.9$ and $\beta_{2}=0.99$. The learning rate is set to $10^{-4}$ for the first 50 epochs and then fixed to $10^{-5}$ for the rest 50 epochs.
\begin{table}[t]
\caption{Calculation of FLOPs for different operators. $H_{i}$, $W_{i}$, and $C_{i}$ are the height, width, and channel of the input feature map, and $H_{o}$, $W_{o}$, and $C_{o}$ correspond to the output feature map. $K_{h}$ and $K_{w}$ represent the size of convolutional kernel.}
\begin{center}
\renewcommand{\arraystretch}{1.3}
\begin{tabular}{l|c}
\hline
Layer & FLOPs \\
\hline
Convolution & $2H_{o}W_{o}(C_{i} K_{h}K_{w} + 1)C_{o}$ \\
Bilinear Upsampling & $11H_{o}W_{o}C_{o}$ \\
Batch Normalization & $2H_{i}W_{i}C_{i}$ \\
ReLU or LReLU & $H_{i}W_{i}C_{i}$ \\
\hline
\end{tabular}
\end{center}
\label{flops}
\end{table}
\section{Experiment} \label{sec:exp}
In this section, we experimentally evaluate our proposed method on three challenging datasets, namely, Cityscapes~\cite{cordts2016cityscapes}, CamVid~\cite{brostow2009semantic}, and UAVid~\cite{lyu2020uavid}, and compare it with some state-of-the-art methods. We conduct all of the experiments on the NVIDIA GTX 1080Ti GPUs.
\subsection{Datasets}
\textbf{Cityscapes}~\cite{cordts2016cityscapes} is a popular dataset in semantic segmentation and autonomous driving domain. It focuses on semantic understanding of urban street scenes. The training and validation subsets contain $2,975$ and $500$ video clips, respectively, and each video clip contains $30$ frames. The $20${th} frame in each clip is annotated by pixel-level semantic labels with $19$ categories.
\textbf{CamVid}~\cite{brostow2009semantic} also focuses on the semantic understanding of urban street scenes, but it contains less data than Cityscapes. It only has $701$ color images with annotations of $11$ semantic classes. CamVid is divided into the trainval set with $468$ samples and test set with $233$ samples. All samples are extracted from driving videos captured at daytime and dusk, and have pixel-level semantic annotations. Each CamVid video contains $3,600$ to $11,000$ frames at a resolution of $720\times960$.
\textbf{UAVid}~\cite{lyu2020uavid} is a high-resolution Unmanned Aerial Vehicle (UAV) semantic segmentation dataset, which brings new challenges, including large scale variation, moving object recognition and temporal consistency preservation. The training and validation subsets contain $20$ and $7$ video clips, respectively, and each video clip contains $900$ frames at a resolution of $2160\times3840$. Every $100$ frames in each clip are annotated by pixel-level semantic labels with $8$ categories.
\begin{figure}[t]
\begin{center}
\includegraphics[width=1.0\linewidth]{10.pdf}
\end{center}
\caption{\textbf{Performance comparison of different methods on Cityscapes val subset with CCA Curve.} Here $\bigstar$ denotes the results of per-frame image segmentation model. In particular, ''DeeplabFast*'' represents the segmentation model used in DVSNet, which processes the regions of frame multiple times and thus has higher computation cost. Best viewed in color.}
\label{exp_cityscapes}
\end{figure}
\begin{figure}[t]
\begin{center}
\includegraphics[width=1.0\linewidth]{11.pdf}
\end{center}
\caption{\textbf{Performance evaluation on Cityscapes val subset with PDA Curve.} All methods are equipped with Deeplabv3+ as the backbone of segmentation network for fair comparison. The colorbar represents the computation cost of different methods for the propagation distance $D_P=5$, in which lighter color indicates higher computation cost. Best viewed in color.}
\label{exp_SCM_cityscapes}
\end{figure}
\begin{figure}[t]
\begin{center}
\includegraphics[width=1.0\linewidth]{12.pdf}
\end{center}
\caption{\textbf{Performance evaluation on CamVid with PDA Curve.} All methods are equipped with Deeplabv3+ as the backbone of segmentation network for fair comparison. The colorbar represents the computation cost of different methods for the propagation distance $D_P=5$, in which lighter color indicates higher computation cost. Best viewed in color.}
\label{exp_SCM_camvid}
\end{figure}
\begin{figure}[t]
\begin{center}
\includegraphics[width=1.0\linewidth]{13.pdf}
\end{center}
\caption{\textbf{Performance evaluation on UAVid with PDA Curve.} All methods are equipped with Deeplabv3+ as the backbone of segmentation network for fair comparison. The colorbar represents the computation cost of different methods for the propagation distance $D_P=5$, in which lighter color indicates higher computation cost. Best viewed in color.}
\label{exp_SCM_uavid}
\end{figure}
\subsection{Evaluation Metrics}
We experimentally evaluate different video semantic segmentation methods by measuring the segmentation accuracy and computational efficiency.
For segmentation accuracy, we propose to use \emph{propagation distance vs. accuracy curve} (PDA Curve), which indicates how the segmentation accuracy changes along different propagation distances. Some previous works~\cite{zhu2017deep,jain2019accel} use the average accuracy among different propagation distances, which is inconvenient to figure out the actual performance. For computational efficiency, we propose to use \emph{computation cost vs. accuracy curve} (CCA Curve). CCA Curve is an important metric for model deployment, which indicates how the segmentation accuracy changes along different average computation cost.
Note that the PDA and CCA represent similar information on the segmentation performance since different computation costs are actually obtained by setting different propagation distances.
In the experiments on Cityscapes, we set the $11${th} to $19${th} frames as the key frame candidates, and propagate the feature of the selected key frame to the annotated $20${th} frame, which is used to measure the segmentation accuracy for each video clip. That is, the propagation distance (denoted by $D_{P}$) ranges from $1$ to $9$ for plotting the PDA Curve. When plotting the CCA Curve, we first calculate the computation cost of components used on the key frames (\textit{i}.\textit{e}., Net$_{seg}$) and non-key frames (\textit{i}.\textit{e}., FlowNet, CFNet, and DMNet), which are denoted by C$_{seg}$ and C$_{warp}$, respectively. The average computation cost is calculated by
\begin{equation}
C_{mean}=(C_{seg}+C_{warp}*D_{P})/(D_{P}+1). \label{eqn:cost}
\end{equation}
The evaluation on CamVid and UAVid is similar to Cityscapes. Here the mean intersection over union (mIoU) is adopted to measure the segmentation accuracy, and floating point operations (FLOPs) is used for the computation cost. Following common practices~\cite{molchanov2019pruning,howard2017mobilenets}, we calculate the FLOPs of convolutional layer, batch normalization layer, activation layer, and bilinear upsampling operator, of which the formulas are provided in Table~\ref{flops}.
\subsection{Performance Comparison}
We compare our proposed method with recent state-of-the-art methods, including DFF~\cite{zhu2017deep}, DVSNet~\cite{xu2018dynamic}, and Accel~\cite{jain2019accel}, and the CCA Curve is used for evaluation.
Considering the baseline methods only provide the model on Cityscapes, here we only give the results on Cityscapes for fair comparison (the results on other datasets using our implementation will be presented in ablation study). To be specific, DFF and DVSNet use the same network DeeplabFast as the segmentation backbone. But DVSNet splits the input frames into four overlapped regions to perform multiple times of segmentation, which is obviously more time-consuming. As for Accel, Deeplab with deformable ResNet-101 is used for image segmentation, and multiple versions of ResNets with different depths are adopted to process the current frame. Fig.~\ref{exp_cityscapes} shows the results of different methods on Cityscapes val subset. It can be seen that our proposed method significantly outperforms other method in both accuracy and efficiency.
\subsection{Ablation Study}
\subsubsection{Effectiveness of our method}
Here we verify the effectiveness of our method on Cityscapes, CamVid, and UAVid, and the results are shown in Fig.~\ref{exp_SCM_cityscapes}, Fig.~\ref{exp_SCM_camvid}, and Fig.~\ref{exp_SCM_uavid}, respectively. For fair comparison, we reimplement the baseline methods with DeepLabv3+ as the backbone of segmentation networks and same FlowNet as in our proposed method. In particular, our implemented DeepLabv3+ achieves a mIoU score of $76.61\%$ on Cityscapes, $72.46\%$ on CamVid, and $69.30\%$ on UAVid for per-frame image segmentation. From the results, it can be seen that our proposed method significantly outperforms other state-of-the-art methods, especially for long-distance feature propagation.
Besides, we calculate the average computation cost by fixing the propagation distance as $5$ for all methods. The results are shown in Fig.~\ref{exp_SCM_cityscapes}, Fig.~\ref{exp_SCM_camvid}, and Fig.~\ref{exp_SCM_uavid} with color bars, in which lighter color represents higher computation cost. Note that the computation cost of Accel34 is higher than that of Accel 50 because an extra deconvolutional layer is involved in Accel34 for feature upsampling. Each component in our proposed framework has a complexity of $O(HW)$, where $H$ and $W$ are height and width of the input images. Moreover, we analyze the computation cost of the main components and overall framework for key and non-key frames, and the statistics are provided in Table~\ref{computaion}. Note that the computation cost for key frames is that of the image segmentation model. It can be seen that the image segmentation network dominates the computation cost. As shown in Fig.~\ref{exp_SCM_cityscapes}, Fig.~\ref{exp_SCM_camvid}, and Fig.~\ref{exp_SCM_uavid}, our method has slightly higher computation cost than DFF and DVSNet, but gets significant accuracy improvement.
Actually, the key of the proposed method getting accuracy improvement and efficient computation is our designed distortion-aware mechanism. Benefited from such a design, both the feature extraction from current frames and feature correction can be completed by a lightweight network (e.g., DMNet and CFNet) due to only handling part of an image. Moreover, only correcting features in distorted regions can effectively avoid false correction and further boost segmentation accuracy. Therefore, our method can outperform state-of-the-art methods in terms of accuracy and computation cost.
\begin{table}[t]
\caption{Computation cost of different modules (GFLOPs). The resolution of input images is $1024\times2048$ on Cityscapes, $720\times960$ on CamVid, and $2160\times3840$ on UAVid.}
\begin{center}
\renewcommand{\arraystretch}{1.3}
\begin{tabular}{l|c|c|c}
\hline
Module & Cityscapes & CamVid & UAVid \\
\hline
FlowNet & 86.918 & 29.219 & 341.441 \\
CFNet & 123.775 & 41.741 & 484.319 \\
DMNet & 0.400 & 0.132 & 1.584 \\
\hline
Overall for key & 826.378 & 272.189 & 3265.457 \\
Overall for non-key & 212.910 & 71.448 & 830.515 \\
\hline
\end{tabular}
\end{center}
\label{computaion}
\end{table}
It is notable that our method can yield higher segmentation accuracy than per-frame image segmentation for short-distance feature propagation. It is because our proposed feature propagation can well exploit the information from multiple frames. That is, the segmentation of the current frame would benefit from the feature combination of the previous and current frames.
\subsubsection{Effect of different components}
\begin{table}[t]
\caption{Effect of different components in our method on Cityscapes val subset. ''mIoU'' is used as the metric.}
\begin{center}
\renewcommand{\arraystretch}{1.3}
\begin{tabular}{c|c|c|c|c|c|c}
\hline
\multirow{2}{*}{DDS} & \multicolumn{2}{c|}{FCM} & \multicolumn{4}{c}{Distance} \\
\cline{2-7}
& DGFL & DGFC & 1 & 5 & 9 & Mean \\
\hline
$\surd$ & $\surd$ & $\surd$ & \bf{77.33} & \bf{75.37} & \bf{72.99} & \bf{75.19} \\
& $\surd$ & $\surd$ & 77.30 & 74.30 & 71.37 & 74.26 (-0.93) \\
$\surd$ & & $\surd$ & 77.09 & 74.34 & 71.16 & 74.17 (-1.02) \\
$\surd$ & $\surd$ & & 74.98 & 73.65 & 71.92 & 73.56 (-1.63) \\
$\surd$ & & & 76.64 & 72.45 & 67.53 & 72.21 (-2.98) \\
\hline
\end{tabular}
\end{center}
\label{exp_distortion}
\end{table}
\begin{table}[t]
\caption{Upper bound analysis of different methods on Cityscapes val subset. mIoU is used as the metric. * denotes the upper bound, and $\uparrow$ represents the corresponding gap.}
\begin{center}
\renewcommand{\arraystretch}{1.3}
\begin{tabular}{l|c|c|c|c|c}
\hline
Distance & 1 & 5 & 9 & Mean & $\uparrow$ \\
\hline
DFF & 73.94 & 69.06 & 64.04 & 69.14 & \\
DFF* & 75.47 & 71.16 & 66.31 & 71.15 & 2.01 \\
\hline
Accel18 & 73.19 & 67.59 & 64.54 & 68.21 & \\
Accel18* & 77.37 & 70.44 & 66.92 & 71.26 & 3.05 \\
\hline
Accel34 & 73.01 & 69.03 & 67.19 & 69.64 & \\
Accel34* & 78.33 & 73.08 & 70.76 & 73.82 & 4.18 \\
\hline
Accel50 & 74.55 & 72.48 & 71.27 & 72.70 & \\
Accel50* & 78.97 & 75.98 & 74.52 & 76.36 & 3.66 \\
\hline
Ours & \bf{77.33} & \bf{75.37} & \bf{72.99} & \bf{75.19} & \\
Ours* & \bf{77.99} & \bf{76.59} & \bf{74.50} & \bf{76.37} & \bf{1.18} \\
\hline
\end{tabular}
\end{center}
\label{exp_upper_bound}
\end{table}
Here we investigate the contribution of each proposed component to the segmentation performance by removing them (\textit{i}.\textit{e}., DDS, DGFL, and DGFC) one by one. Table~\ref{exp_distortion} gives the results, in which the propagation distances $\{1,5,9\}$ are particularly used and the mean segmentation accuracy over all distances is also provided.
From the results, we have the following observations. (1) DDS can improve the network training of our proposed method and further bring accuracy increase, as shown in the first two rows. (2) FCM is the main source of performance gains, especially for long-distance feature propagation that usually would cause serious distortion. (3) DGFL and DGFC in FCM are both important. In particular, CFNet without DGFL cannot effectively extract the correction cues, and without DGFC, the false correction would become severe, especially for short-distance propagation.
Considering these results, it is convinced that our proposed distortion-aware feature correction is very effective for boosting the performance of propagation-based video semantic segmentation.
\subsubsection{Upper bound analysis}
Similar to our proposed method, DFF~\cite{zhu2017deep} and Accel~\cite{zhu2017deep} also rectify the propagated features. Here we explore the upper bound of segmentation accuracy of these methods, in which only the wrongly predicted regions are rectified during inference (the ground truth of semantic segmentation is used).
Table~\ref{exp_upper_bound} shows the results. It can be seen that DFF and Accel have a larger gap corresponding to their upper bounds while our method can achieve a smaller one. Such results imply that our method can effectively alleviate false correction with our proposed distortion prediction.
\subsubsection{Design of Distortion Map Prediction}
\begin{figure}[t]
\begin{center}
\includegraphics[width=1.0\linewidth]{14.pdf}
\end{center}
\caption{\textbf{The predicted distortion maps using different features.} It can be seen that the higher-level feature can get better distortion maps.}
\label{distortion_input}
\end{figure}
In this work, we propose to predict the distortion maps using images rather than features in order to achieve low computation cost. Here we compare different data to predict distortion maps regardless of the computational price. In particular, we take the propagated features after classifier (high-level feature) and features after entry flow block2 in DeepLabv3+ (low-level feature) as the inputs of DMNet. Besides, we use the ground truth of distortion maps to test the upper bound of segmentation performance, which can well demonstrate the effectiveness of our idea to exploit the distortion map in video semantic segmentation.
Fig.~\ref{distortion_input} provides the visual comparison of predicted distortion maps for different features, and Fig.~\ref{exp_distortion_input_with_computation} gives the corresponding segmentation performance. We have the following observations. First, the higher-level feature can bring higher segmentation accuracy for getting more consistent distortion maps with the ground truth, but would involve higher computation cost. Thus we need to find a good trade-off between the segmentation accuracy and computation cost. Second, from the results in Table~\ref{exp_distortion} and Fig.~\ref{exp_distortion_input_with_computation}, it can be seen that our proposed method can get significant performance improvement if the ground truths of distortion maps are used, which shows the rationality of focusing on the distortion regions in this work.
\subsubsection{Visualization}
To intuitively illustrate our proposed method, we provide the visualizations of four samples from the Cityscapes datasets in Fig.~\ref{visualization}, where the intermediate features are demonstrated by applying the segmentation head to them. For each sample, we extract the feature from the key frame, and then propagate it to the current frame (the $9$th one from the key frame). First, we can see that the predicted distortion maps can represent the distorted regions of propagated features. Second, under the guidance of distortion maps, our proposed method can accurately extract the correction cues, especially on the distorted regions, and then effectively correct the propagated features.
\begin{figure}[t]
\begin{center}
\includegraphics[width=1.0\linewidth]{15.pdf}
\end{center}
\caption{\textbf{Comparison of different data to predict distortion maps.} Here the segmentation accuracy on Cityscapes val subset is adopted for evaluation. It can be seen that higher-level feature can generate higher-quality distortion maps but would involve higher computation cost. Best viewed in color.}
\label{exp_distortion_input_with_computation}
\end{figure}
\begin{figure*}[t]
\begin{center}
\includegraphics[width=1.0\linewidth]{16.pdf}
\end{center}
\caption{\textbf{Visualization of some samples from Cityscapes.} It can be seen that the predicted distortion map can represent the distortion pattern of propagated features, and our proposed method can effectively correct the distorted features. Red rectangles highlight the main distorted regions. Best viewed in color.}
\label{visualization}
\end{figure*}
\section{Conclusion} \label{sec:conclusion}
We present a novel video semantic segmentation method in this paper, aiming at achieving high segmentation accuracy and competitive real-time performance simultaneously by tackling the feature distortion problem in propagation. Specifically, we propose DMNet to predict distorted regions of the propagated features, and then propose FCM to correct the distorted features with a lightweight model. Our experimental results on Cityscapes, CamVid, and UAVid show that the proposed method outperforms the state-of-the-art methods in both precision and speed.
\section*{Acknowledge} \label{sec:acknowledge}
We acknowledge the support of GPU cluster built by MCC Lab of Information Science and Technology Institution, USTC.
\ifCLASSOPTIONcaptionsoff
\newpage
\fi
\bibliographystyle{IEEEtran}
| {'timestamp': '2020-11-13T02:13:52', 'yymm': '2006', 'arxiv_id': '2006.10380', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10380'} | arxiv |
\section{Introduction} \label{sec:intro}
Active target tracking is an information gathering task where a mobile agent makes a sequence of control decisions to gather information about targets of interest using its on-board sensors. For instance, a camera angle can be controlled to find an exit in a room, or an autonomous vehicle can move to view and identify an occluded object. Its various applications include surveillance \cite{rybski00, hilal13}, search-and-rescue task \cite{kumar04}, active perception \cite{soatto11, zhang17, luo17, jayaraman18}, and environmental monitoring \cite{dunbabin12, choi09}.
Problems in active tracking for dynamic targets tackle challenges associated with target motions such as estimation of target states, non-myopic planning, cost function, and stochasticity of the targets, rather than placing the weight on processing and inferencing sophisticated raw sensory data. Previous studies applied various techniques from Bayesian estimation, information theory, and optimal control to solve a spectrum of problems.
However, many approaches often face a significant challenge in computational complexity due to their dependency on a planning horizon \cite{chung06, kreucher05, huber09}. Especially, it is often taxing to compute an information-theoretic cost function such as mutual information and variance reduction over a long planning horizon. Myopic policies have been proposed to lessen the computational burden, but often resulted in inefficient planning trajectories or failed to achieve the optimal performance. For example, short paths that are searched or sampled by a myopic planning approach fail to collect new information about a distant target, and thus such approaches struggle to find an optimal path until an agent gets close enough to the target. To improve the limitation, approximate non-myopic algorithms are presented and they reduce the complexity of obtaining a sub-optimal policy while providing strong performance guarantees \cite{atanasov14, schlotfeldt18}. An iterative sampling-based algorithm was also proposed, increasing efficiency under a given budget constraints \cite{hollinger2014sampling}. The complexity of their methods, however, are still not free of the planning horizon.
Another major limitation of previous works is a strong dependency of their methods on a specific problem formulation and system models. Due to such dependencies, they have focused on settings where the prior knowledge of targets (e.g. initial states and target dynamic models) are sufficiently known and/or the targets are initially located near the sensing range \cite{chung06, atanasov14, schlotfeldt18}. However, such conditions considerably simplify the problem as the main task becomes tightly following a target whose state is relatively accurately estimated. In real-world examples, we often have limited information about targets. For instance, an initial belief about a target can be inaccurate, leading to issues when the agent searches for the target near its incorrect belief location. Such scenarios require the agent to explore the environment until it discovers the targets.
These limitations can be also problematic when targets move quickly or when their states considerably differ from predicted states by the agent. The latter is caused by noisy target dynamics or insufficient target knowledge available to the agent.
In this paper, we address these main challenges and consider three major sub-tasks of active target tracking -- \textit{navigation}, \textit{discovery}, and \textit{in-sight tracking} (tracking within the range of a sensor). We propose a method of learning a unified reinforcement learning (RL) policy that is capable of all three tasks. We formulate the active target tracking problem as a Markov decision process (MDP) with an information-theoretic objective function where the value function is a discounted sum of future mutual information between target states and measurement history. An agent explicitly maintains a belief distribution of a target, and the belief state and its uncertainty are included in an RL state. One of the major advantages of using RL is its non-myopic behavior by its nature. A learned policy is executable online and its computational complexity is independent of the planning horizon. Another benefit is that it can drop the dependency of an algorithm on prior conditions and system models -- agent dynamics, target dynamics, and observation model. Therefore, it is able to learn a \textit{robust} behavior for a scenario where the agent's knowledge of the target model considerably differs from a true target model. We additionally incorporate map information and visit-frequency, which reflects how recently a certain area has been scanned by the sensor, into an RL state as images. This enables an RL policy to \textit{learn to navigate} and \textit{learn to explore}. Our model uses egocentric information with respect to the agent frame to drop the dependency of a learned policy on its training environment. We demonstrate the proposed method in a target tracking environment with various scenarios including agile targets, imperfect prior knowledge on a target model, and inaccurate initial beliefs. The results show that the RL policy significantly outperforms an existing search-based planning method.
A preliminary version of this paper appeared at the IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS) 2019 \cite{jeong19_iros}. The paper proposed a general framework for applying reinforcement learning to active information acquisition and demonstrated the method in an active target tracking problem using model-free deep reinforcement learning algorithms. This article presents a new method of learning a unified policy for active target tracking that improves the previous approach by utilizing map information and visit frequency as inputs to an RL policy. We also demonstrate the capability of the method in partially known environments. This extends the problem domain to a more highly complex and advanced level.
\begin{figure*}[t!]
\centering
\includegraphics[width=0.8\textwidth]{figures/cnn_architecture_2.png}
\caption{Illustration of the active target tracking network (ATTN) architecture. Egocentric maps with visit frequency of surroundings are fed to the convolutional neural network, and its output is concatenated by non-geographical features and finally estimates Q-values.}
\label{fig:architecture}
\end{figure*}
\section{Related Work} \label{sec:related_work}
\input{related_work}
\section{Approach} \label{sec:approach}
\subsection{Problem Formulation}
We are interested in an active target tracking problem where both an agent and a target are mobile following discrete-time dynamic models. We consider one robot and $N$ targets, and denote their states at time $t$ as $x_t$ and $y_{t} = [y_{1,t}^T, \cdots, y_{N,t}^T]^T$ where $y_{i,t}$ is an individual target state for $i=1, \cdots, N$. The robot state can be defined in a different form depending on its degree of freedom or its type. For instance, $x_t \in \mathbb{R}^2 \times SO(2)$ for a ground robot and $x_t\in \mathbb{R}^3 \times SO(3)$ for a quadrotor where $SO(n)$ is the special orthogonal group in dimension $n$. The goal of the robot is to maximize the cumulative mutual information between the belief states at $t$ and a measurement history $z_{1:t}$ for a time horizon $T$. More formally, the objective is to find a sequence of control inputs to the robot, $u_{1:T}$, which satisfies,
\begin{equation}
\text{maximize}_{u_{0:T-1}} \sum_{t=1,\cdots, T} \mathrm{I}(y_{t}; z_{1:t}|x_{1:t})
\label{eq:objective}
\end{equation}
\begin{align*}
s.t.\quad & x_{t+1} = f(x_t, u_t) & t=0,\cdots, T-1\\
& y_{i,t+1} = g(y_{i,t}) & t=0,\cdots, T-1 \\
& z_{i,t} = h(x_t, y_{i,t}) & t=1, \cdots, T
\end{align*}
where $f(\cdot)$ and $g(\cdot)$ are dynamic models of the robot and the targets, respectively, and $h(\cdot)$ is an observation model.
Since the robot does not have access to the ground truth of the target states, the robot infers the target states from its internal belief distributions. We denote the belief distribution for the $i$-th target as $B(y_{i,t}) = p(y_{i,t}|z_{1:t}, x_{1:t})$ and its predicted distribution for the subsequent step as $\bar{B}(y_{i,t+1})=p(y_{i,t+1}|z_{1:t},x_{1:t})$.
Assuming $y_{t+1}$ is independent of $x_{1:t}$, the optimization problem in (\ref{eq:objective}) can be reduced to minimizing the cumulative differential entropy, $H(y_{t+1}|z_{1:t}, x_{1:t})$ \cite{atanasov14}. Furthermore, when the belief is Gaussian $B(y_{i,t}) = \mathcal{N}(\hat{y}_{i,t}, \Sigma_{i,t})$,
\begin{equation}
H(y_{t}|z_{1:t}, x_{1:t}) = \frac{1}{2} \log\left( (2\pi e)^N \det(\Sigma_t)\right)
\end{equation}
and therefore, the optimization problem becomes :
\begin{equation}
\text{minimize} \sum_{t=1,\cdots,T} \log \det (\Sigma_{t})
\label{eq:objective_reduced}
\end{equation}
We formulate the procedure of the problem in discrete-time as follows. At each step $t$, the robot at the state $x_t$ chooses a control input, $u_t$, based on the prediction on the targets, $\bar{B}(y_{i,t+1})$, to maximize the objective (\ref{eq:objective}). At the same time, the target states will evolve to the next step ($y_t \rightarrow y_{t+1}$). Then, the robot receives measurements, $z_{t+1}$, from the sensor. If some targets are observed, the corresponding belief distributions are updated with the new measurements. This process is repeated at every step. The summary of these steps is presented in Algorithm \ref{table:alg}. Note that we do not study mapping and localization in this paper and assume that the map and the exact odometry of the robot are known to the robot.
\subsection{Active Target Tracking Network}
An Markov decision process is described by the tuple, $M=<\mathcal{S}, \mathcal{A}, P, R, \gamma>$. $\mathcal{S}$ and $\mathcal{A}$ are state and action spaces, respectively, $P: \mathcal{S} \times \mathcal{A} \times \mathcal{S} \rightarrow [0,1]$ is a transition probability function, $R: \mathcal{S} \times \mathcal{A} \rightarrow \mathbb{R}$ is a reward function, and $\gamma \in [0,1)$ is a discount factor. A policy, $\pi$, selects an action that maximizes the expected sum of discounted future rewards. This objective is formally defined as value or value function, $V^{\pi}(s) = \mathbb{E}_{\pi}[\sum^{\infty}_{t=0}\gamma^t R(s_t,a_t)|s_0=s]$, and action-value or Q-value, $Q^{\pi}(s,a) = \mathbb{E}_{\pi}[\sum^{\infty}_{t=0}\gamma^t R(s_t,a_t)|s_0=s, a_0=a]$.
In the active target tracking problem, we aim to find an optimal policy $\pi^*$ that maximizes the cumulative mutual information in (\ref{eq:objective}), or specifically $-\sum_{t=1,\cdots,T} \log \det (\Sigma_{t})$ in our problem setup. By defining $r_{t+1} = R(s_t, a_t) = -\log \det (\Sigma_{t+1})$, we approximate the objective as a discounted sum. In other words, the value function is :
\begin{equation}
V^{\pi}(s) = -\mathbb{E}_{\pi}[\sum^{T-1}_{t=0}\gamma^t \log \det (\Sigma_{t+1})|s_0=s]
\end{equation}
The RL action is defined as a control input to the robot. In this paper, we use a finite set of motion primitives for available control inputs.
Numerous papers have pointed out the limitation of RL methods when goals shift. In general, this requires a complete re-training even though the underlying environment remains the same. However, in an active target tracking setting, not only is a goal position changed in every episode, but a goal position can be continuously changed over time because it is dependent on the uncertainty of beliefs as well as target motions. Since the goal should be implicitly determined by the policy, simple solutions such as including a goal as a part of the RL state \cite{zhu17} will not work. Therefore, we use target information in the agent's perspective for the RL state and reduce the dependency on the training environment.
Information about the target states is essential for the agent to make an optimal decision. The exact target states, however, are unknown to the agent, resulting in the problem being formulated as a partially observable Markov decision process (POMDP) \cite{kaelbling}. Unfortunately, it is known that finding an optimal solution for a general POMDP is intractable \cite{sutton2018reinforcement, papadim}. Instead, we explicitly include the parameters of belief distributions on the targets in the RL state and solve it as an MDP. The target states evolve with their own dynamics independently from the agent's actions. Thus, the agent's decision at time $t$ should be based on predicted target states for $t+1$ rather than the current target states. We define a non-geographical feature vector $\phi_t=[\phi_{1,t}^T, \cdots, \phi_{N,t}^T, (o_t^{(x_t)})^T]^T$. $\phi_{i,t}$ is composed of the predicted belief state for the $i$-th target in the agent's current frame, its covariance, and the observability of the true $i$-th target :
\begin{equation}
\phi_{i,t} \equiv [(\hat{y}_{t+1|t}^{(x_t)})^T, \log \det \Sigma_{i,t+1|t}, \mathbb{I}(y_{i,t} \in \mathcal{O}(x_t))]^T
\end{equation}
$\mathcal{O}(x)$ is an observable space from the robot state $x$ and $\mathbb{I}(\cdot)$ is a boolean function which returns 1 if its given statement is true and 0 otherwise. $o_t^{(x_t)}$ is a coordinate of the closest obstacle point to the agent in the agent frame.
However, these non-geographical features are not enough for the agent to make an informed decision under all circumstances. As pointed out in the previous sections, the ability to navigate around obstacles is crucial. To achieve this, we need more information than just the closest obstacle point. For example, suppose the agent is located in front of an obstacle and its left corner is closer to the agent than the right corner. It is impossible for the agent to figure out the shorter path to pass the obstacle only with the closest obstacle point. Another important capability of the agent is to explore the current domain when a target is not near the corresponding belief. Note that this exploration means exploring a given environment with a deterministic policy and differs from the exploration problem in RL (action exploration) during learning. To learn to explore in the MDP setting, we build a visit frequency map similar to the occupancy grid mapping. Suppose that $\lambda_c$ is a visit-frequency value for a cell $c$. At $t$,
\begin{equation}
\lambda_{c,t} = \begin{cases} 1 & \quad \text{if c is scanned} \\
\lambda_{c,t-1}\cdot c \exp \left(\frac{\bar{v}_t \tau}{r_{sensor}} \right) & \quad \text{otherwise} \end{cases}
\label{eq:visit_freq}
\end{equation}
where $\bar{v}_t$ is the average speed of the targets from the beliefs, $\tau$ is a sampling period, $r_{sensor}$ is a sensing range of the sensor, and $c$ is a constant factor. Therefore, the most recently visited cells have the value 1.0 and it decays over time as a function of the current target speed estimate.
To reduce the dependency of a learned policy on training environments, we use egocentric maps of the surrounding areas of the current agent position as inputs to the convolutional neural network (CNN) in our architecture. The flatten output of the CNN is concatenated by the non-geographic features $\phi_t$, and then fed to the fully connected network. Fig. \ref{fig:architecture} shows the illustration of the network architecture and the inputs.
\begin{algorithm}[tb!]
\caption{Active Target Tracking Network (ATTN)}
\begin{algorithmic}[1]
\small
\State Randomly initialize a train Q-network, $Q(s,a|\xi)$
\State Initialize a target Q-network, $Q(s,a|\xi')$ with weights $\xi' \leftarrow \xi$
\State Initialize a replay buffer $D$
\For{episode =1:M}
\State Randomly initialize $x_0$, $y_{i,0}$, $\hat{y}_{i,0}$, $\Sigma_{i,0}$ for $i=1, \cdots, N$
\State Predict $\bar{B}(y_1)$
\State Initialize the RL state: $s_0=f_s(x_0, \bar{B}(y_{1}); M)$)
\For{step $t=0:T-1$}
\State Choose an action $a_t \sim \pi(s_t)$
\State Update the agent state $x_{t+1}=f(x_t, a_t)$
\For{$i=1:N$}
\State Update the $i$-th target state $y_{i,t+1}=g(y_{i,t})$
\State Observe the $i$-th target $z_{i,t+1}=h(x_{t+1}, y_{i,t+1})$
\If{$z_{i,t+1}$ exists}
\State $B(y_{t+1}) = Z^{-1} p(z_{t+1}|x_{t+1}, y_{t+1}) \bar{B}(y_{t+1})$
\EndIf
\EndFor
\State Compute a reward $r_{t+1} = R(B(y_{t+1}))$
\State Predict target states $\bar{B}(y_{t+2})$
\State Update the RL state: $s_{t+1}=f_s(x_{t+1}, \bar{B}(y_{t+2}) ; M)$
\State $D \leftarrow D \cup \{<s_t, a_t, r_{t+1}, s_{t+1}>\}$
\State Train the Q-network
\EndFor
\EndFor
\end{algorithmic} \label{table:alg}
\end{algorithm}
\section{Target Tracking Environment} \label{sec:ttenv}
In this section, we describe details of the target tracking environment. It is designed for reinforcement learning practice and follows the OpenAI Gym structure, a popular benchmark simulation environment for the RL community \cite{openaigym}. The source codes can be found at \url{https://github.com/coco66/ttenv}. \textit{Notations:} The xy-position and the orientation in $SE(2)$ are represented with a subscript 1, 2, $\theta$, for example, $(x_1, x_2)\in \mathbb{R}^2$ and $x_{\theta}\in SO(2)$, respectively.
\subsection{Target Model}
We design a non-linear target model based on the double integrator with Gaussian noise. In order to maneuver smoothly around obstacles, we add a non-linear term, $\zeta(\cdot)$, that pushes the target away from a nearby obstacle.
\begin{equation}
y_{t+1} = Ay_{t} + w_{t} + \zeta(y_{t};M) \qquad w_{t} \sim \mathcal{N}(0,W(q))
\label{eq:target_model}
\end{equation}
where $y_{t}=[y_{1,t}, y_{2,t}, \dot{y}_{1,t}, \dot{y}_{2,t}]^T$ and
\[
A=\begin{bmatrix} I_2 &\tau I_2 \\
0 & I_2 \end{bmatrix}, \qquad W(q)=q \begin{bmatrix} \tau^3/3 I_2 & \tau^2/2 I_2 \\ \tau^2/2 I_2 & \tau I_2 \end{bmatrix}
\]
$q$ is a noise constant and $I_n$ is an $n\times n$ identity matrix. $\zeta(\cdot)$ is a function of the current target state and the map, $M$, and it directs the target away from its closest obstacle which polar coordinate with respect to the current target frame is denoted as $r_o^{(y_t)}, \theta_o^{(y_t)}$.
\begin{equation}
\zeta(y_{t};M) = [0, 0, a_t\tau\cos(\theta_{rot, t}), a_t\tau\sin(\theta_{rot,t})]^T
\label{eq:nonlinear_target}
\end{equation}
where
\begin{align}
a_t =& \frac{\nu_{t}\cos_+ (\theta_o^{(y_t)})}{\max(r_{\min}, r_o^{(y_t)}-r_\text{margin})^2} \\
\theta_{rot,t} =& \begin{cases} y_{\theta, t} +\theta_o^{(y_t)} - \theta_{rep,t}\quad &\text{for } \theta_o^{(y_t)} \geq 0 \\[6pt] y_{\theta, t} + \theta_o^{(y_t)} + \theta_{rep,t} \quad & \text{otherwise} \end{cases} \\
\theta_{rep,t} =& \frac{\pi}{2}\left( 1 + \frac{1}{1+e^{-(\nu_{t}-\nu_{\max}/2)}} \right)\\ \nu_{t}=&\sqrt{ \dot{y}_{1,t}^2 + \dot{y}_{2,t}^2}
\end{align}
$r_{min}$ and $r_{margin}$ are design parameters that determine the maximum value of $a_t$ and a margin from an obstacle point with the maximum effect, respectively. $\nu_{max}$ is the maximum target speed, and $\cos_+(x) = \cos(x)$ if $-\pi/2 \leq x \leq \pi/2$ and $0$ otherwise. Fig. \ref{fig:obs_maneuver} illustrates the effect of $\zeta(\cdot)$ around the obstacle in different positions.
\begin{figure}[tb!]
\centering
\includegraphics[width=0.9\columnwidth]{figures/obs_maneuver_3.jpg}
\caption{An example of the effect of $\zeta(\cdot)$ in (\ref{eq:nonlinear_target}) at different target positions in the grid. Each arrow corresponds to the velocity components of $\zeta$, $[a_t\tau\cos(\theta_{rot, t}), a_t\tau\sin(\theta_{rot,t})]^T$ when $\tau=0.5, v_{max}=3.0, r_{margin}=0.1, r_{min}=1.0$. The blue arrows are for $v_t=3.0$ and the red arrows are for $v_t=1.0$. The black blocks are obstacles and the target orientation are $-3\pi/4$ [rad] for all.}
\label{fig:obs_maneuver}
\end{figure}
Additionally, if $y_{t+1}$ in (\ref{eq:target_model}) causes a collision with an obstacle, its velocity is changed while its position remains same :
\begin{equation}
y_{t+1} = y_{t} + (\nu_t+n_{t})[0, 0, \cos(\theta_{rot,t}), \sin(\theta_{rot,t})]^T
\end{equation}
where $n_{t} \sim \mathcal{N}(0,1)$.
\subsection{Agent and Observation Models}
The agent follows the differential drive dynamics,
\begin{align}
\begin{bmatrix}
x_{1,t+1} \\ x_{2,t+1} \\ x_{\theta, t+1}
\end{bmatrix} =
\begin{bmatrix}
x_{1,t} \\x_{2,t} \\ x_{\theta, t}
\end{bmatrix} +
\begin{bmatrix}
\nu \tau sinc(\frac{\omega \tau}{2}) \cos (x_{\theta, t} + \frac{\omega \tau}{2})\\
\nu \tau sinc(\frac{\omega \tau}{2}) \sin (x_{\theta, t} + \frac{\omega \tau}{2})\\
\tau \omega
\end{bmatrix}
\end{align}
controlled by linear and angular velocity commands, $v$ and $\omega$, respectively.
We use a range-bearing sensor which is commonly used in practice in robotics and assume that the agent can uniquely identify different targets.
The observation model of the sensor for each target is:
\begin{equation}
z_{i,t} = h(x_t, y_{i,t}) + v_t, \hspace{3mm} v_t \sim \mathcal{N}\begin{pmatrix}0, V \end{pmatrix}
\label{eq:observation_model}
\end{equation}
where $V$ is a observation noise covariance matrix and
\begin{equation*}
h(x,y) = \begin{bmatrix}r_{x,y}\\\alpha_{x,y}\end{bmatrix} := \begin{bmatrix} \sqrt{(y_1 - x_1)^2 + (y_2 -x_2)^2} \\ \tan^{-1} ((y_2 - x_2)(y_1 - x_1)) - x_{\theta} \end{bmatrix}
\end{equation*}
\subsection{Belief Update}
We use a Kalman Filter to update the beliefs on the targets. While previous works assume that the target model is known to the agent \cite{atanasov14, schlotfeldt18}, we release the assumption by allowing only the partial knowledge, a double integrator with $A$ and $W(q_b)$ in (\ref{eq:target_model}) where $q_b \neq q$, and excluding the $\zeta(\cdot)$ term. In a domain with obstacles, the effect of $\zeta(\cdot)$ is significant, and the belief update becomes considerably inaccurate leading to a more challenging task.
The observation model (\ref{eq:observation_model}) is approximated to a linear model in the Kalman filter and the Jacobian matrix of $h(y, x)$ with respect to $y$ is :
\begin{equation*}
\nabla_y h(x,y) = \frac{1}{r_{x,y}}
\begin{bmatrix} (y_1 - x_1) & (y_2 - x_2) & \mathbf{0}_{1x2} \\
-\sin (x_{\theta}+\alpha_{x,y}) & \cos (x_{\theta}+\alpha_{x,y})& \mathbf{0}_{1x2} \\ \end{bmatrix}
\end{equation*}
\section{Experiments} \label{sec:experiments}
Unlike many benchmark simulation environments in RL, the target tracking environment is highly stochastic and contains considerable randomness. First, the agent, beliefs, and targets can be randomly initialized within a large range in a domain. As discussed further in the following section, different abilities of an agent can be emphasized depending on initialization. Moreover, the noise components in the target motion, the belief model, and the observation model provide additional randomness in performance. Lastly, the agent can discover a target by chance as both the targets and the agent are dynamic and as the target motion is independent of an agent path. Therefore, it is important to have a learning environment that provides diverse samples while to carefully design evaluation environments that reduces a large performance variance across different trials.
We perform experiments in single-target scenarios as well as two-target scenarios.
When there is more than one target, the maximum velocity of the agent should be much higher than that of targets in order to continuously gather information about the targets while traveling among them. If targets are too far apart, committing to track nearby targets can return higher mutual information in a given time than attempting to track all targets. Therefore, we use different training and evaluation settings for single-target and two-target environments.
\subsection{Algorithms}
We learn a ATTN policy using Assumed Density Filtering Q-learning, a Bayesian Q-learning method which has shown promising performance in stochastic environments and tasks with a large action space \cite{adfq,jeong19_iros}. It is an off-policy temporal difference learning, and thus, we can have an action policy different from the target policy. For the action policy, we use Thompson sampling \cite{thompson} which samples Q-values for all actions given a state from the belief distributions and select an action with the maximum sample value. We use $\gamma=0.99$, the discount factor, which results in the length of the effective horizon as $T_{eff}=687$ ($T_{eff} = \operatornamewithlimits{argmax}_t \gamma^{t}$ s.t. $\gamma^t > 0.001$).
The dimension of the egocentric map input is $25 \times 25 \times 5$, and the two convolutional layers consist of 20, $4 \times 4$ filter, with a stride of 3 and 40, $3 \times 3$ filter, with a stride of 2. The following fully connected layers consist of 3 layers with 512 hidden units. The network is trained for 30K steps (or 300 episodes) with three different random seeds (thus, three models).
We compare the ATTN policy with the Anytime Reduced Value Iteration (ARVI) algorithm, an open-source search-based target tracking algorithm that has been verified in both simulations and real robot experiments \cite{schlotfeldt18}. Details of the algorithm is explained in Section \ref{sec:related_work}. The algorithm optimizes the same mutual information objective of ATTN in (\ref{eq:objective_reduced}). It also uses the same observation and agent models and the Kalman filter described in Section \ref{sec:ttenv}.
ARVI finds a near-optimal path at each step given a specified amount of time denoted as $T_{ARVI}$. Therefore, this allocated planning time is usually equal to or less than the sampling period or a time interval, $\tau$. In this experiment, we set this value to be $T_{ARVI}=\tau=0.5$[s]. The planning horizon for ARVI is set to 12 steps following the original paper. Since the algorithm finds a path in a given time, a longer planning horizon sometimes helps to find a better path but it can also lead to a worse plan since the search space becomes too large. We tested with 1, 5, and 10 for the number of control steps to be executed from a selected path, and 5 showed the best result.
\subsection{Training Setup}
\begin{figure}[b!]
\centering
\includegraphics[width=\columnwidth]{figures/obstacles4.png}
\caption{Obstacle polygons for generating a random map. (a) Obstacles used during training, (b) Unseen obstacles, (c) An example map of a randomly generated map.}
\label{fig:obstacles}
\end{figure}
The training environment is designed so that the learning agent can be exposed to various situations. The system models described in the previous section are used with the following parameters : $\tau=0.5$, $V=\text{diag}(0.2, 0.01)$, $r_\text{margin}=1.0$, $\nu_0=0.0$ [m/s]. The maximum sensing range is $r_\text{sensor}=10$ [m] and its field of view is 120 degrees. A set of motion primitives, or the action space, is $\mathcal{A}=\{(v,\omega)|v\in\{0,1,2,3\} [m/s], \omega \in\{0, -\pi/2, \pi/2\} [rad/s]\}$ and the time horizon of an episode, $T$ is set to 100.
In single-target scenarios, the noise constants of the target model and the belief model are set as $q=q_b=0.5$, and the maximum target velocity is set as $\nu_{\max}=3.5$ [m/s]. For two-target scenarios, lower values are used for training: $q=q_b=0.2$ and $\nu_{\max}=1.0$ [m/s]. As mentioned above, it is infeasible for an agent to keep tracking multiple targets that are diverging from each other with limited dynamic constraints. Additionally, high noise constant of the target model makes a target to be quickly diverged from its corresponding belief while the agent is tracking another target (when it is not available to cover both targets at once). While this requires an ability to explore near the belief when losing the target, it may also result in a case where committing to one target gives a higher return.
\textbf{Map.} To learn a policy that is robust to various environmental configurations, we randomly generate a map from a set of obstacle candidates as shown in Fig. \ref{fig:obstacles} (a). These obstacles include both convex concave polygons resulting in more challenging navigation tasks. At each episode, four randomly selected obstacles are placed at the center of each quadrant of an empty domain with random orientations (see Fig. \ref{fig:obstacles}(c)). The map resolution (cell size) is 0.4 [m] and the map dimension is $72.4 \times 72.4$ [$\text{m}^2$].
\textbf{Initialization.} For each episode, the robot is randomly initialized in a given domain. In single-target domains, the initial belief position is randomly chosen within a distance between 5.0 to 20.0 [m] from the agent, and the initial target position is randomly placed within (0.0, 20.0)[m] range from the belief. Since the agent may be required to travel between targets in two-target domains, smaller ranges are used -- (5.0, 10.0)[m] range for a distance between beliefs and the agent, and (0.0, 10.0)[m] range for a distance between a belief and its corresponding target. These ranges are chosen considering the maximum sensing range of the agent. Note that having a target placed too far from its corresponding belief can lead to learning a policy that does not trust the belief.
We add a penalty to the reward function when the agent chooses an action that immediately leads to a position within $r_{margin}$ distance to an obstacle. The penalty accelerated the learning by a marginal amount, but did not make any noticeable difference in performance.
\begin{figure}[b!]
\centering
\includegraphics[width=\columnwidth]{figures/initialization.png}
\caption{Illustration of the three initialization configurations. The black figure corresponds to the robot with a range-bearing sensor on top. The blue dotted circle is the sensing radius and the faded blue sector indicates a covered area by the sensor. Targets are represented with the red figures. The green figures are beliefs with uncertainty represented as the faded green circles. The black cuboid is an obstacle occluding the target and the belief in the configuration B.}
\label{fig:init_zone}
\end{figure}
\subsection{Evaluation Setup for Single-Target Domains}
In single-target domains, different sets of initial positions of the robot, targets, and beliefs emphasize different abilities of an agent. For example,
\begin{itemize}
\item Occlusion of a target and/or its corresponding belief: This requires an ability to navigate around obstacles.
\item The initial distance between $y_{i,t}$ and $x_t$: A larger value requires the ability to navigate with a long path.
\item The initial distance between $y_{i,t}$ and $\hat{y}_{i,t}$: A larger value requires the ability to explore the current domain until reaching the target.
\end{itemize}
Therefore, we consider three different initialization setups to evaluate capabilities of the testing algorithms in the sub-tasks of active target tracking -- \textit{in-sight tracking}, \textit{navigation}, \textit{discovery} -- separately.
\begin{enumerate}
\item In-sight tracking task: A target and the corresponding belief are randomly initialized within the sensing range ($||y_{i,t} - x_t||_2 \in [3,10]$), and they are located close to each other ($||y_{i,t} - \hat{y}_{i,t}||_2 \in [0,3]$). The case A in Fig. \ref{fig:init_zone} illustrates this initial condition. We experiment with different values for $q$ and $\nu_\text{max}$.
\item Navigation task: Both a target and the corresponding belief are initialized relatively far from the agent ($||y_{i,t} - x_t||_2 \in [15,20]$), and occluded as described in Fig. \ref{fig:init_zone} B. They are located close to each other ($||y_{i,t} - \hat{y}_{i,t}||_2 \in [0,3]$).
\item Discovery task : The initial belief is located within the sensing range ($||\hat{y}_{i,t} - x_t||_2 \in [3,10]$), but the target is initialized far from the belief ($||y_{i,t} - \hat{y}_{i,t}||_2 \in [15,20]$) as illustrated in Fig. \ref{fig:init_zone} C. Thus, the agent won't be able to discover the target by simply reaching the belief location and scanning around.
\end{enumerate}
We first generated a set of 10 episodes for each evaluation task. In each episode, the target trajectory, initial robot and belief states, and map configuration are randomly generated and they differ across episodes.
Three trained models of ATTN with different random seeds are evaluated on the evaluation sets. ARVI is also evaluated on the evaluation sets with three random seeds. To prevent a case where the target approaches the robot and is found by luck, the target starts to move once it is observed by the robot for the first time in each episode.
\begin{figure}[b!]
\centering
\includegraphics[width=\columnwidth]{figures/eval_all_qv_5.jpg}\\
\caption{$\bar{J}$ (solid line) and $\eta$ (dotted line) of ATTN (blue) and ARVI (yellow) in environments with different $q$ and $\nu_{\max}$ values. The error bars represent the standard deviation across 10 episodes. The mean values are averaged values over different seeds and 10 episodes. Left: $\nu_{\max}=3.0$[m/s] and $q\in\{0.02, 0.1, 0.2, 1.0, 2.0\}$. Right: $q=0.2$, $\nu_{max}\in \{2.5, 2.75, 3.0, 3.25, 3.5\}$}
\label{fig:eval_qv}
\end{figure}
\subsection{Results in Single-Target Domains}
\begin{figure}[tb!]
\centering
\includegraphics[width=\columnwidth]{figures/recovery_example.png}\\
\caption{Examples of ATTN (top) and ARVI (bottom) when the robot loses the target. The left figures are a few steps after the robot loses the target, and the right figures are after 10 steps passed. The blue triangle is the robot and the red circle is the current target position. The blue and red dots are paths of the robot and target so far. The green circle indicates the belief position. The green and purple shaded circles represent the position and velocity uncertainty of the belief, respectively. The circular sector is the sensing area. In the top figures, visited cells are filled with gray color based on $\lambda_{c,t}$ in (\ref{eq:visit_freq}), and the five blue squares indicate areas in the local map input.}
\label{fig:recovery}
\end{figure}
First, the robustness of the ATTN policy and ARVI is evaluated in the in-sight tracking task. In particular, we are interested in tracking fast and anomalous targets. Thus, we test ATTN and ARVI with different values for $q$ in the target model (\ref{eq:target_model}) and $\nu_{\max}$. The larger the $q$ value, the more deviated the belief state is from the target state. Furthermore, $q$ affects how much the target speed evolves over time. If the $q$ value is small, the target may never reach the maximum target speed in a given time horizon. $q_b$ is set to be 0.5 as same as the value used in training.
To quantitatively measure the performance of the algorithms, we consider mutual information, or in particular, a normalized sum of negative log of determinant of covariance in predictions within an episode:
\begin{equation}
\bar{J} = \frac{-\sum_{t=1,\cdots,T} \log \det (\Sigma_{t+1|t}) - J_{\min}}{J_{\max} - J_{\min}} \in [0,1]
\end{equation}The lower bound, $J_{\min}$, is found when there is no observation in an episode, and the belief is updated only by the prediction step in the Kalman filter. The upper bound, $J_{\max}$, is met when the target is observed at every step. According to Theorem 4 in \cite{sinopoli04}, $J_{\max} = - T\log\det(W)$ and $J_{\min} = - \sum_{t=1,\cdots,T} \log\det(\Sigma_{t+1})$ for $\Sigma_{t+1} = A\Sigma_t A^T + W$. We additionally evaluate resilience, $\eta \in [0,1]$, defined as the number of times the target is re-discovered by the sensor divided by the number of times the target is lost.
The left plot in Fig. \ref{fig:eval_qv} shows the average performances of both algorithms for $q\in \{0.02, 0.1, 0.2, 1.0, 2.0\}$ and $\nu_{\max}=3.0$, and the right plot shows their average performances for $q=0.2$ and $\nu_{\max}\in\{2.5, 2.75, 3.0, 3.25, 3.5\}$. Note that the maximum robot linear speed is 3.0 [m/s], and thus, it is likely that the robot will often lose the target when $\nu_{\max}=3.25$ and $\nu_{\max}=3.5$. In both $\bar{J}$ and $\eta$, ATTN outperformed ARVI. As expected, $\bar{J}$ and $\eta$ decrease as the target motion becomes noisier. Surprisingly, $\nu_{\max}$ did not have a significant impact on either $\bar{J}$ or $\eta$. This shows that the robot is capable of tracking a target that is faster than itself. The resilience tracks similarly with $\bar{J}$ indicating that the resilience is a significant factor of the performance. ATTN learns to explore near the belief when the target is not observed at the belief location and the uncertainty is high. Fig. \ref{fig:recovery} shows an example of each algorithm when the agent loses the target. In the top figures, the belief is located to the left of the robot, but the robot with the ATTN policy chooses to turn right instead to explore the surrounding areas. After a few steps, the robot re-discovers the target. On the other hand, ARVI in the bottom figures greedily follows the belief, failing to discover the target even though the uncertainty is relatively high and no observation is received.
Additionally, ATTN does not track the belief as tightly as ARVI, and instead leaves some buffer space to provide maneuverability when the target quickly changes its direction. Fig. \ref{fig:rel_target_density} is density plots of belief positions with respect to the robot during 10 episodes. The red dotted lines are the x-axis and y-axis of the robot frame, and the x-axis is the robot heading direction. Overall, ATTN results in scattered density plots while the belief positions in the ARVI plots are mostly concentrated in a few small areas.
\begin{figure}[t!]
\centering
\includegraphics[width=\columnwidth]{figures/rel_belief_pos_hist2d_4.png}
\caption{Density plots of belief positions in the agent frame during 10 episodes with different values for $q$ and $\nu_{max}$. The red triangle is the robot position (0.0, 0.0) and the horizontal and vertical red dotted lines are x and y axis of the agent frame, respectively. $x\in (-2.0,8.0)$ and $y\in(-5.0, 5.0)$[m].}
\label{fig:rel_target_density}
\end{figure}
\begin{figure}[b!]
\includegraphics[width=\columnwidth]{figures/eval_discovery_batch.jpg}
\caption{Performance evaluation for \textit{Discovery} and \textit{Navigation} tasks. Left: Evaluated in 10 different environments randomly generated by obstacles used in training. Right: Evaluated in 10 different environments randomly generated by unseen obstacles during training.}
\label{fig:eval_discovery}
\end{figure}
\begin{figure}[b!]
\centering
\includegraphics[width=\columnwidth]{figures/visit_freq_map_attnarvi_quad.jpg}
\caption{Density maps of scanned areas by the robot's sensor over single episode (top) and 20 episodes (bottom). The white circle are the initial position of the robot. The red filled circles in the top figures are the initial target positions, and the red hollow circles in the top figures are the initial belief positions. In the bottom figures, the target is randomly initialized in the area between the red dotted circles.}
\label{fig:visit_freq_map}
\end{figure}
For the navigation and discovery tasks, we measure a discovery rate to evaluate the performance of the algorithms. This discovery rate is defined as the number of episodes in which the target is found divided by the number of total episodes (=10). The faster the robot finds the target, the higher the resulting $\bar{J}$. However, $\bar{J}$ can vary significantly depending on the initial positions of the setup, and therefore is a poor measure for these tasks.
The results of the navigation task are depicted in the left figure of Fig. \ref{fig:eval_discovery}. The ATTN policy finds the target 93\% of the time on average (models trained with three different random seeds). On the other hand ARVI successfully finds the target only 40\% of the time. We observe that ARVI fails to find a path to the target given $T_{ARVI}$ when target is located far from the agent and is occluded by concave polygon obstacles.
Since ARVI uses a forward simulation, it guarantees to avoid any collision with a perfect map information. While ATTN does not provide the guarantee for the collision avoidance, ATTN results in 0.4 times of collision attempts on average in the navigation task and no collision attempt in the discovery task.
In the discovery task, as defined earlier, the initial target is placed far from the initial belief location requiring the robot to explore to find the target. As shown in Fig. \ref{fig:eval_discovery}, ARVI completely fails to find the target in any of the episodes in this task while ATTN finds it 93\% of the time on average. The four figures in Fig. \ref{fig:visit_freq_map} are density maps of areas that the robot's sensor has scanned in the global map. The top figures are examples of a single episode (left: ATTN, right: ARVI) and the bottom figures are examples of 20 episodes with random initialization. To solely evaluate the exploration capability, no obstacles are present in the map. The figures show that ATTN explores the global domain broadly when the target is not found near the belief while ARVI commits to the incorrect belief and leaves the global domain unexplored. This difference explains why ATTN achieves an 93\% discovery rate while ARVI never finds the target.
The computation time for planning of ATTN is 0.12 [sec] on average, which is much faster than the allocated computation used for ARVI ($=0.5$ [sec]) while ATTN has a significantly longer planning horizon.
Additional to the experiments described in the previous sections, we test the learned ATTN policy in environments with unseen obstacles during training (see Fig. \ref{fig:obstacles}). The results in the right figure of Fig. \ref{fig:eval_discovery} shows that the discovery rates of ATTN in both tasks are 93\% and 96\%, similar to the results in the training environments. Likewise, ARVI results in 60\% and 0\% discovery rates. Additionally, ATTN shows 0.4 and 0.0 collision attempts on average for the navigation and discovery tasks, respectively. These results demonstrate that the learned policy performs well in unseen environments promoting the benefit of using local information. Note that ARVI is an online search-based planning algorithm without having a training stage, and therefore it is not affected by a new set of obstacles.
\begin{figure}[t!]
\centering
\includegraphics[width=\columnwidth]{figures/eval_multi.jpg}
\caption{Performance evaluation on $N=2$ targets. Left: The normalized mean of log determinant of belief covariances averaged over 10 episodes and the error bars indicate standard deviations. Right: Standard deviation of log determinant of belief covariances averaged over 10 episodes and the error bars indicate their standard deviations.}
\label{fig:multi_target_eval}
\end{figure}
\subsection{Results in Two-Target Domains}
\begin{figure}[b!]
\centering
\includegraphics[width=0.85\columnwidth]{figures/t_distance_nnlogdetcov.jpg}
\caption{The relation between an average distance between two targets during an episode and $\bar{J}$ (blue circle: ATTN, yellow triangle: ARVI). }
\label{fig:eval_multi_distance}
\end{figure}
Unlike the single-target domains (where once the agent is nearby the target, the navigation and discovery abilities are not much needed), the agent may need to use all three abilities interchangeably throughout an episode or to use them at the same time. For instance, the agent must navigate from one target to another one when they are far apart. Moreover, while the agent is tracking one target, the other belief diverges from its corresponding target which requires the agent to explore to find the target. Lastly, the agent may explore to discover one target while tracking the other target when they both are around the agent's sensing range. Therefore, instead of evaluating the algorithms in the three subtasks, we evaluate the algorithms with an initialization similar to the in-sight tracking task in the single-target evaluation at different noise constants $q=\{0.002, 0.02, 0.2 \}$ and $v_{\text{max}}=1.0$ [m/s].
The average normalized objective, $\bar{J}$, are presented in the left figure of Fig. \ref{fig:multi_target_eval}. In all $q$ values, ATTN consistently outperforms ARVI. The right figure shows the average standard deviation between $\bar{J}$ of two targets. A lower value for $SD(\bar{J})$ indicates that the agent tracks the targets while balancing the objective brought by both targets. Similar to the single target case, ARVI aggressively tracks the beliefs. It especially harms the performance in a multi-target tracking case since the agent is often required to travel between two targets and a belief diverges from its corresponding target while the agent is tracking another one.
Fig.\ref{fig:eval_multi_distance} shows how the performance of ATTN and ARVI in terms of $\bar{J}$ decreases as a distance between two targets increases. Although ATTN shows a higher performance than ARVI, the value drops in general which indicates the difficulty of the problem.
\section{Conclusion and Discussion}
In this paper, we present Active Target Tracking Network (ATTN), an RL method for active target tracking that learns a unified policy capable of three main tasks - \textit{In-sight tracking}, \textit{Navigation}, and \textit{Discovery}. To demonstrate, we train an ATTN policy in a target tracking environment described in Section \ref{sec:ttenv} where a mobile robot is tasked with tracking mobile targets using noisy measurements from its onboard range-bearing sensor. The learned ATTN policy shows a robust performance for agile and anomalous target motions, despite the true target model differing from the target model used in the agent’s belief update. Moreover, the policy was able to navigate through obstacles to reach distant targets. Finally, it learns to explore surrounding areas and discovers a target when its belief on the target is inaccurate, while the existing algorithm failed to do so in all test examples.
\subsection{Learning with Uncertainty}
Although an RL method requires an extended training stage to obtain a policy, it provides flexibility in expanding a problem domain or changing system models. The objective of a problem is implicitly included in a reward function, and an optimal policy is learned without requiring knowledge on models. While we use partial knowledge on a target model and an observation model to update beliefs using a Kalman filter, we are able to use a target model that differs from the model known to the beliefs without violating any assumption or constraint required for an algorithm. Therefore, the target tracking scenarios considered in this article are more challenging in terms of stochasticity, uncertainty, and imperfect prior knowledge, compared to scenarios presented in previous works \cite{chung06,hoffmann,atanasov14,schlotfeldt18}. During learning, the learning agent is exposed to diverse and challenging experiences and is able to \textit{learn to track with uncertain beliefs}, \textit{learn to navigate}, and \textit{learn to explore}.
\subsection{Stochasticity of Tasks}
Active target tracking is not a trivial task for RL. The states of the learning agent and of the environment including targets and obstacles are high-dimensional, continuous, and stochastic. The recent advancement of deep RL have shown promising results in tasks where an RL state is continuous or high-dimensional -- for example, raw screen image in video games or continuous joint angles \cite{mnih2013, schulman2015trust}. Yet, the deterministic dynamics of popular deep RL benchmark environments such as the Arcade Learning Environment (ALE) and Mujoco has raised concern in the scientific community as the successfully evaluated algorithms can fail when extended to new domains \cite{machado18}. In most real-world problems, a transition function and/or a reward function are likely to be stochastic, resulting in challenges applying such approaches to more realistic problems. The active target tracking task is highly stochastic, even in its simulation setting. The innate partial observability feature brings high stochasticity in the task. A subsequent RL state is determined not only by the current agent action but also the real yet partially observable or unknown target. Therefore, the same action can result in very different RL states as the belief can be drastically updated due to a new measurement if the corresponding target is around as opposed to no target is observed. It is shown in the previous work \cite{jeong19_iros} that popular benchmark deep Q-learning methods, deep Q-network and double deep Q-network, failed to achieve optimal performance in relatively simple settings. Thus, it is important to note that the environment is stochastic and an algorithm capable in such a highly stochastic domain should be considered.
\subsection{United Policy}
One of the key contributions of this study is that we expand the problem domain and tackle three major capabilities with one united policy. One might argue that we could achieve similar performance by having three different algorithms for each capability and have an additional algorithm to heuristically decide which one to use at each step. For example, it is possible to improve the performance of ARVI by using an exploration method when a target is not detected. However, this not only burdens the computational cost but loses the interchangeable flexibility among different capabilities.
\subsection{Future Work}
We have pointed out the limitation of a single agent tracking multiple targets. This limitation, in fact, has been one of the major motivations for multi-agent tracking studies \cite{charrow14, motchallenge, schlotfeldt18}. Separately, multi-agent reinforcement learning has been widely studied for various applications including robotics, telecommunications, and distributed control \cite{bu2008comprehensive, omidshafiei2017deep, lanctot2017unified}. Combining advancements from these two fields of literature would present an interesting and more practical result in scalable target tracking problems.
Additionally, this work can be extended to adversarial target tracking problems where targets try not to be seen by the agent. By training an intelligent target that adapts its behavior to avoid being tracked by the agent with its newest policy, the agent can continuously improve the policy according to the updated target behavior. Such adversarial learning or self-supervised reinforcement learning approaches to active target tracking would be an interesting direction for future studies \cite{goodfellow2014generative, baker2019emergent}.
\bibliographystyle{IEEEtran}
| {'timestamp': '2020-06-19T02:05:29', 'yymm': '2006', 'arxiv_id': '2006.10190', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10190'} | arxiv |
\section{Introduction}
Recently, Neural Architecture Search (NAS) has attracted lots of attentions for its potential to democratize deep learning. For a practical end-to-end deep learning platform, NAS plays a crucial role in discovering task-specific architecture depending on users' configurations (e.g., dataset, evaluation metric, etc.).
Pioneers in this field develop prototypes based on reinforcement learning~\citep{nas}, evolutionary algorithms~\citep{amoebanet} and Bayesian optimization~\citep{pnas}. These works usually incur large computation overheads, which make them impractical to use.
More recent algorithms significantly reduce the search cost including one-shot methods~\citep{enas, oneshot}, a continuous relaxation of the space~\citep{darts} and network morphisms~\citep{morphisms}.
In particular,~\citet{darts} proposes a differentiable NAS framework - DARTS, converting the categorical operation selection problem into learning a continuous architecture mixing weight. They formulate a bi-level optimization objective, allowing the architecture search to be efficiently performed by a gradient-based optimizer.
While current differentiable NAS methods achieve encouraging results, they still have shortcomings that hinder their real-world applications.
Firstly,
several works have cast doubt on the stability and generalization of these differentiable NAS methods~\citep{smoothdarts, understanding}. They discover that directly optimizing the architecture mixing weight is prone to overfitting the validation set and often leads to distorted structures, e.g., searched architectures dominated by parameter-free operations.
Secondly, there exist disparities between the search and evaluation phases, where proxy tasks are usually employed during search with smaller datasets or shallower and narrower networks, due to the large memory consumption of differentiable NAS.
In this paper, we propose an effective approach that addresses the aforementioned shortcomings named Dirichlet Neural Architecture Search (DrNAS).
Inspired by the fact that directly optimizing the architecture mixing weight is equivalent to performing point estimation (MLE/MAP) from a probabilistic perspective, we formulate the differentiable NAS as a distribution learning problem instead, which naturally induces stochasticity and encourages exploration.
Making use of the probability simplex property of the Dirichlet samples, DrNAS models the architecture mixing weight as random variables sampled from a parameterized Dirichlet distribution. Optimizing the Dirichlet objective can thus be done efficiently in an end-to-end fashion, by employing the pathwise derivative estimators to compute the gradient of the distribution~\citep{pathwise}.
A straightforward optimization, however, turns out to be problematic due to the uncontrolled variance of the Dirichlet, i.e., too much variance leads to training instability and too little variance suffers from insufficient exploration.
In light of that, we apply an additional distance regularizer directly on the Dirichlet concentration parameter to strike a balance between the exploration and the exploitation.
We further derive a theoretical bound showing that the constrained distributional objective promotes stability and generalization of architecture search by implicitly controlling the Hessian of the validation error.
Furthermore, to enable a direct search on large-scale tasks, we propose a progressive
learning scheme, eliminating the gap between the search and evaluation phases.
Based on partial channel connection~\citep{pcdarts}, we maintain a task-specific super-network of the same depth and number of channels as the evaluation phase throughout searching.
To prevent loss of information and instability induced by partial connection, we divide the search phase into multiple stages and progressively increase the channel fraction via network transformation~\citep{net2net}.
Meanwhile, we prune the operation space according to the learnt distribution to maintain the memory efficiency.
We conduct extensive experiments on different datasets and search spaces to demonstrate DrNAS's effectiveness. Based on the DARTS search space~\citep{darts}, we achieve an average error rate of 2.46\% on CIFAR-10, which ranks top amongst NAS methods.
Furthermore, DrNAS achieves superior performance on large-scale tasks such as ImageNet. It obtains a top-1/5 error of 23.7\%/7.1\%, surpassing the previous state-of-the-art (24.0\%/7.3\%) under the mobile setting.
On NAS-Bench-201~\citep{nasbench201}, we also set new state-of-the-art results on all three datasets with low variance.
Our code is available at \url{https://github.com/xiangning-chen/DrNAS}.
\section{The Proposed Approach}
In this section, we first briefly review differentiable NAS setups and generalize the formulation to motivate distribution learning.
We then layout our proposed DrNAS and describe its optimization in section~\ref{subsec:drnas}.
In section~\ref{subsec:hessian}, we provide a generalization result by showing that our method implicitly regularizes the Hessian norm over the architecture parameter.
The progressive architecture learning method that enables direct search is then described in section~\ref{subsec:pal}.
\subsection{Preliminaries: Differentiable Architecture Search}
\paragraph{Cell-Based Search Space}
The cell-based search space is constructed by replications of normal and reduction cells~\citep{nasnet,darts}.
A normal cell keeps the spatial resolution while a reduction cell halves it but doubles the number of channels.
Every cell is represented by a DAG with $N$ nodes and $E$ edges, where every node represents a latent representation $\textbf{x}^i$ and every edge $(i,j)$ is associated with an operations $o^{(i,j)}$ (e.g., \textit{max pooling} or \textit{convolution}) selected from a predefined candidate space $\mathcal{O}$.
The output of a node is a summation of all input flows, i.e., $\textbf{x}^j=\sum_{i<j}o^{(i,j)}(\textbf{x}^i)$, and a concatenation of intermediate node outputs, i.e., $concat(\textbf{x}^2,...,\textbf{x}^{N-1})$, composes the cell output, where the first two input nodes $\textbf{x}^0$ and $\textbf{x}^1$ are fixed to be the outputs of previous two cells.
\paragraph{Gradient-Based Search via Continuous Relaxation}
To enable gradient-based optimization,~\citet{darts}
apply a continuous relaxation to the discrete space.
Concretely, the information passed from node $i$ to node $j$ is computed by a weighted sum of all operations alone the edge, forming a mixed-operation $\hat{o}^{(i,j)}(x) = \sum_{o\in\mathcal{O}} \theta_o^{(i,j)} o(x)$.
The operation mixing weight $\theta^{(i,j)}$ is defined over the probability simplex and its magnitude represents the strength of each operation.
Therefore, the architecture search can be cast as selecting the operation associated with the highest mixing weight for each edge.
To prevent abuse of terminology, we refer to $\theta$ as the architecture/operation mixing weight, and concentration parameter $\beta$ in DrNAS as the architecture parameter throughout the paper.
\paragraph{Bilevel-Optimization with Simplex Constraints}
With continuous relaxation, the network weight $w$ and operation mixing weight $\theta$ can be jointly optimized by solving a constraint bi-level optimization problem:
\begin{align}
\label{eq:bi}
\min_{\theta}\ \ \mathcal{L}_{val} (w^*, \theta) \ \
\text{ s.t.}\ \ w^* = \argmin_w\ \mathcal{L}_{train}(w,\theta), \ \ \ \
\sum_{o=1}^{|\mathcal{O}|}\theta_o^{(i,j)}=1,\ \forall\ (i,j),\ i<j,
\end{align}
where the simplex constraint $\sum_{o=1}^{|\mathcal{O}|} {\theta_o^{(i,j)} = 1}$ can be either solved explicitly via Lagrangian function~\citep{gaea}, or eliminated by substitution method (e.g., $\theta = Softmax(\alpha), \alpha\in \mathcal{R}^{|\mathcal{O}| \times |E|}$)~\citep{darts}.
In the next section we describe how this generalized formulation motivates our method.
\subsection{Differentiable Architecture Search as Distribution Learning}
\label{subsec:drnas}
\paragraph{Learning a Distribution over Operation Mixing Weight}
Previous differentiable architecture search methods view the operation mixing weight $\theta$ as learnable parameters that can be directly optimized~\citep{darts, pcdarts, gaea}.
This has been shown to cause $\theta$ to overfit the validation set and thus induce large generalization error~\citep{understanding,nasbench1shot1,smoothdarts}.
We recognize that this treatment is equivalent to performing point estimation (e.g., MLE/MAP) of $\theta$ in probabilistic view, which is inherently prone to overfitting~\citep{prml, bayesian}.
Furthermore, directly optimizing $\theta$ lacks sufficient exploration in the search space, and thus cause the search algorithm to commit to suboptimal paths in the DAG that converges faster at the beginning but plateaus quickly~\citep{WideShallow}.
Based on these insights, we formulate the differentiable architecture search as a distribution learning problem.
The operation mixing weight $\theta$ is treated as random variables sampled from a learnable distribution.
Formally, let $q(\theta|\beta)$ denote the distribution of $\theta$ parameterized by $\beta$.
The bi-level objective is then given by:
\begin{align}
\label{eq:cop}
&\min_{\beta} E_{q(\theta|\beta)} \big{[}\mathcal{L}_{val} (w^*, \theta)\big{]} +
\lambda d(\beta, \hat\beta) \
\text{ s.t. }\ w^* = \argmin_w\ \mathcal{L}_{train}(w,\theta).
\end{align}
where $d(\cdot, \cdot)$ is a distance function.
Since $\theta$ lies on the probability simplex, we select Dirichlet distribution to model its behavior, i.e., $q(\theta|\beta) \sim Dir(\beta)$, where $\beta$ represents the Dirichlet concentration parameter.
Dirichlet distribution is a widely used distribution over the probability simplex~\citep{drvae, lda, ndp, bcl}, and it enjoys nice properties that enables gradient-based training~\citep{pathwise}.
The concentration parameter $\beta$ controls the sampling behavior of Dirichlet distribution and is crucial in balancing exploration and exploitation during the search phase.
Let $\beta_o$ denote the concentration parameter assign to operation $o$.
When $\beta_o \ll 1$ for most $o=1\sim |\mathcal{O}|$, Dirichlet tends to produce sparse samples with high variance, reducing the training stability; when $\beta_o \gg 1$ for most $o=1\sim |\mathcal{O}|$, the samples will be dense with low variance, leading to insufficient exploration.
Therefore, we add a penalty term in the objective (\ref{eq:cop}) to regularize the distance between $\beta$ and the anchor $\hat\beta = 1$, which corresponds to the symmetric Dirichlet.
In section~\ref{subsec:hessian}, we also derive a theoretical bound showing that our formulation additionally promotes stability and generalization of the architecture search by implicitly regularizing the Hessian of validation loss w.r.t. architecture parameters.
\paragraph{Learning Dirichlet Parameters via Pathwise Derivative Estimator}
Optimizing objective (\ref{eq:cop}) with gradient-based methods requires back-propagation through stochastic nodes of Dirichlet samples.
The commonly used reparameterization trick does not apply to Dirichlet distribution,
therefore we approximate the gradient of Dirichlet samples via pathwise derivative estimators~\citep{pathwise}
\begin{align}
\label{eq:pathwise}
\frac{d\theta_i}{d\beta_j} = -\frac{\frac{\partial{F_{Beta}}}{\partial{\beta_j}}(\theta_j| \beta_j, \beta_{tot} - \beta_j) }{f_{Beta}(\theta_j | \beta_j, \beta_{tot} - \beta_j)} \times \big{(} \frac{\delta_{ij} - \theta_i}{1 - \theta_j} \big{)} \quad i, j = 1, ..., |\mathcal{O}|,
\end{align}
where $F_{Beta}$ and $f_{Beta}$ denote the CDF and PDF of beta distribution respectively, $\delta_{ij}$ is the indicator function, and $\beta_{tot}$ is the sum of concentrations.
$F_{Beta}$ is the iregularised incomplete beta function, for which its gradient can be computed by simple numerical approximation.
We refer to~\citep{pathwise} for the complete derivations.
\paragraph{Joint Optimization of Model Weight and Architecture Parameter}
With pathwise derivative estimator, the model weight $w$ and concentration $\beta$ can be jointly optimized with gradient descent.
Concretely, we draw a sample $\theta \sim Dir(\beta)$ for every forward pass, and the gradients can be obtained easily through backpropagation.
Following DARTS~\citep{darts}, we approximate $w^*$ in the lower level objective of \eqref{eq:cop} with one step of gradient descent, and run alternative updates between $w^*$ and $\beta$.
\paragraph{Selecting the Best Architecture}
At the end of the search phase, a learnt distribution of operation mixing weight is obtained.
We then select the best operation for each edge by the most likely operation in expectation:
\begin{align}
o^{(i,j)} = \argmax_{o\in \mathcal{O}} E_{q(\theta_o^{(i,j)}|\beta^{(i,j)})} \big{[}\theta_o^{(i,j)} \big{]}.
\end{align}
In the Dirichlet case, the expectation term is simply the Dirichlet mean $\frac{\beta_o^{(i,j)}}{\sum_{o'} \beta_{o'}^{(i,j)}}$.
Note that under the distribution learning framework, we are able to sample a wide range of architectures from the learnt distribution.
This property alone has many potentials.
For example, in practical settings where both accuracy and latency are concerned, the learnt distribution can be used to find architectures under resource restrictions in a post search phase.
We leave these extensions to future work.
\subsection{The implicit Regularization on Hessian}
\label{subsec:hessian}
It has been observed that the generalization error of differentiable NAS is highly related to the dominant eigenvalue of the Hessian of validation loss w.r.t. architecture parameter.
Several recent works report that the large dominant eigenvalue of $\nabla_\theta^2 \Tilde{\mathcal{L}}_{val}(w, \theta)$ in DARTS results in poor generalization performance~\citep{understanding,smoothdarts}.
Our objective (\ref{eq:cop}) is the Lagrangian function of the following constraint objective:
\begin{align}
&\min_{\beta} E_{q(\theta|\beta)} \big{[}\mathcal{L}_{val} (w^*, \theta)\big{]}\
\text{ s.t. }\ w^* = \argmin_w\ \mathcal{L}_{train}(w,\theta)\ ,\ d(\beta, \hat\beta) \leq \delta,
\label{eq:co}
\end{align}
Here we derive an approximated lower bound based on (\ref{eq:co}), which demonstrates that our method implicitly controls this Hessian matrix.
\begin{prop}
\label{prop:hessian}
Let $d(\beta, \hat\beta) = \|\beta - \hat\beta\|_2 \leq \delta$ and $\hat\beta = 1$ in the bi-level formulation (\ref{eq:co}).
Let $\mu$ denote the mean under the Laplacian approximation of Dirichlet.
If $\ \nabla_{\mu}^2\Tilde{\mathcal{L}}_{val} (w^*, \mu)$ is Positive Semi-definite,
the upper-level objective can be approximated bounded by:
\begin{align}
\label{eq:bound}
E_{q(\theta|\beta)}(\mathcal{L}_{val}(w, \theta)) \gtrsim \Tilde{\mathcal{L}}_{val} (w^*, \mu) + \frac{1}{2} (\frac{1}{1 + \delta}(1 - \frac{2}{|\mathcal{O}|}) + \frac{1}{|\mathcal{O}|}\frac{1}{1 + \delta}) tr\big{(} \nabla_{\mu}^2 \Tilde{\mathcal{L}}_{val} (w^*, \mu) \big{)}
\end{align}
with:
\begin{align*}
\Tilde{\mathcal{L}}_{val} (w^*, \mu) = \mathcal{L}_{val} (w^*, Softmax(\mu)),\ \
\mu_o = \log{\beta_o} - \frac{1}{|\mathcal{O}|} \sum_{o'} \log{\beta_{o'}},\ \ o=1,\dots ,|\mathcal{O}|.
\end{align*}
\end{prop}
This proposition is driven by the Laplacian approximation to the Dirichlet distribution~\citep{laplace,topic}.
The lower bound (\ref{eq:bound}) indicates that minimizing the expected validation loss controls the trace norm of the Hessian matrix.
Empirically, we observe that DrNAS always maintains the dominant eigenvalue of Hessian at a low level (Appendix~\ref{app:hessian_plot}).
The detailed proof can be found in Appendix~\ref{app:hessian}.
\subsection{Progressive Architecture Learning}
\label{subsec:pal}
The GPU memory consumption of differentiable NAS methods grows linearly with the size of operation candidate space.
Therefore, they usually use a easier proxy task such as training with a smaller dataset, or searching with fewer layers and number of channels~\citep{proxylessnas}.
For instance, the architecture search is performed on 8 cells and 16 initial channels in DARTS~\citep{darts}.
But during evaluation, the network has 20 cells and 36 initial channels.
Such gap makes it hard to derive an optimal architecture for the target task~\citep{proxylessnas}.
PC-DARTS~\citep{pcdarts} proposes a partial channel connection to reduce the memory overheads of differentiable NAS, where they only send a random subset of channels to the mixed-operation while directly bypassing the rest channels in a shortcut. However, their method causes loss of information and makes the selection of operation unstable since the sampled subsets may vary widely across iterations.
This drawback is amplified when combining with the proposed method since we learn the architecture distribution from Dirichlet samples, which already injects certain stochasticity.
As shown in Table~\ref{tab:partial channel},
when directly applying partial channel connection with distribution learning,
the test accuracy of the searched architecture decreases over 3\% and 18\% on CIFAR-10 and CIFAR-100 respectively if we send only 1/8 channels to the mixed-operation.
To alleviate such information loss and instability problem while being memory-efficient, we propose a progressive learning scheme which gradually increases the fraction of channels that are forwarded to the mixed-operation and meanwhile prunes the operation space based on the learnt distribution.
We split the search process into consecutive stages and construct a task-specific super-network with the same depth and number of channels as the evaluation phase at the initial stage.
Then after each stage, we increase the partial channel fraction, which means that the super-network in the next stage will be wider, i.e., have more convolution channels, and in turn preserve more information.
This is achieved by enlarging every convolution weight with a random mapping function similar to Net2Net~\citep{net2net}. The mapping function $g: \{1,2,\dots,q\}\rightarrow\{1,2,\dots,n\}$ with $q>n$ is defined as
\begin{equation}
g(j)=
\left\{
\begin{array}{lr}
j & j\leq n \\
\text{random sample from } \{1,2,\dots,n\} & j>n
\end{array}
\right.
\end{equation}
To widen layer $l$, we replace its convolution weight $\textbf{W}^{(l)}\in \mathbb{R}^{Out\times In\times H\times W}$ with a new weight $\textbf{U}^{(l)}$.
\begin{align}
\textbf{U}^{(l)}_{o,i,h,w} = \textbf{W}^{(l)}_{g(o),g(i),h,w},
\end{align}
where $Out, In, H, W$ denote the number of output and input channels, filter height and width respectively.
Intuitively, we copy $\textbf{W}^{(l)}$ directly into $\textbf{U}^{(l)}$ and fulfill the rest part by choosing randomly as defined in $g$.
Unlike Net2Net, we do not divide $\textbf{U}^{(l)}$ by a replication factor here because the information flow on each edge has the same scale no matter the partial fraction is.
After widening the super-network, we reduce the operation space by pruning out less important operations according to the Dirichlet concentration parameter $\beta$ learnt from the previous stage, maintaining a consistent memory consumption.
As illustrated in Table~\ref{tab:partial channel}, the proposed progressive architecture learning scheme effectively discovers high accuracy architectures and retains a low GPU memory overhead.
\begin{wraptable}{r}{0.4\textwidth}
\vspace{-4mm}
\centering
\caption{Test accuracy of the derived architectures when searching on NAS-Bench-201 with different partial channel fraction, where $1/K$ channels are sent to the mixed-operation.}
\resizebox{.4\textwidth}{!}{
\begin{tabular}{ccc}
\hline
\multicolumn{3}{c}{CIFAR-10} \\
$K$ & \textbf{\tabincell{c}{Test Accuracy\\(\%)}} &\textbf{\tabincell{c}{GPU Memory\\(MB)}} \\ \hline
1 & $94.36\pm 0.00$ & 2437 \\
2 & $93.49\pm 0.28$ & 1583 \\
4 & $92.85\pm 0.35$ & 1159 \\
8 & $91.06\pm 0.00$ & 949 \\
Ours & $94.36\pm 0.00$ & 949 \\ \hline \hline
\multicolumn{3}{c}{CIFAR-100} \\
$K$ & \textbf{\tabincell{c}{Test Accuracy\\(\%)}} &\textbf{\tabincell{c}{GPU Memory\\(MB)}} \\ \hline
1 & $73.51\pm 0.00$ & 2439 \\
2 & $68.48\pm 0.41$ & 1583 \\
4 & $66.68\pm 3.22$ & 1161 \\
8 & $55.11\pm 13.78$ & 949 \\
Ours & $73.51\pm 0.00$ & 949 \\ \hline
\end{tabular}}
\label{tab:partial channel}
\vspace{-3mm}
\end{wraptable}
\section{Discussions and Relationship to Prior Work}
Early methods in NAS usually include a full training and evaluation procedure every iteration as the inner loop to guide the consecutive search~\citep{nas,nasnet,amoebanet}.
Consequently, their computational overheads are beyond acceptance for practical usage, especially on large-scale tasks.
\paragraph{Differentiable NAS} Recently, many works are proposed to improve the efficiency of NAS~\citep{enas,morphisms,darts,oneshot,nasp,sif,Mei2020AtomNAS}.
Amongst them, DARTS~\citep{darts} proposes a differentiable NAS framework, which introduces a continuous architecture parameter that relaxes the discrete search space. Despite being efficient, DARTS only optimizes a single point on the simplex every search epoch, which has no guarantee to generalize well after the discretization during evaluation. So its stability and generalization have been widely challenged~\citep{randomnas,understanding,smoothdarts,wang2021rethinking}.
Following DARTS, SNAS~\citep{snas} and GDAS~\citep{gdas} leverage the gumbel-softmax trick to learn the exact architecture parameter.
However, their reparameterization is motivated from reinforcement learning perspective, which is an approximation with softmax rather than an architecture distribution.
Besides, their methods require tuning of temperature schedule~\citep{hman, mann}. GDAS linearly decreases the temperature from 10 to 1 while SNAS anneals it from 1 to 0.03. In comparison, the proposed method can automatically learn the architecture distribution without the requirement of handcrafted scheduling.
BayesNAS~\citep{BayesNAS} applies Bayesian Learning in NAS. Specifically, they cast NAS as model compression problem and use Bayes Neural Network as the super-network, which is difficult to optimize and requires oversimplified approximation. While our method considers the stochasticity in architecture mixing weight, as it is directly related to the generalization of differentiable NAS algorithms~\citep{understanding, smoothdarts}.
\paragraph{Memory overhead} When dealing with the large memory consumption of differentiable NAS, previous works mainly restrain the number of paths sampled during the search phase.
For instance, ProxylessNAS~\citep{proxylessnas} employs binary gates and samples two paths every search epoch.
PARSEC~\citep{parsec} samples discrete architectures according to a categorical distribution to save memory.
Similarly, GDAS~\citep{gdas} and DSNAS~\citep{dsnas} both enforce a discrete constraint after the gumbel-softmax reparametrization. However, such discretization manifests premature convergence and cause search instability~\citep{nasbench1shot1, mmf}. Our experiments in section~\ref{sec:201} also empirically demonstrate this phenomenon.
As an alternative, PC-DARTS~\citep{pcdarts} proposes a partial channel connection, where only a portion of channels is sent to the mixed-operation.
However, partial connection can cause loss of information as shown in section~\ref{subsec:pal} and PC-DARTS searches on a shallower network with less channels, suffering the search and evaluation gap.
Our solution, by progressively pruning the operation space and meanwhile widening the network, searches in a task-specific manner and achieves superior accuracy on challenging datasets like ImageNet (+2.8\% over BayesNAS, +2.3\% over GDAS, +2.3\% over PARSEC, +2.0\% over DSNAS, +1.2\% over ProxylessNAS, and +0.5\% over PC-DARTS).
\section{Experiments}
In this section, we evaluate our proposed DrNAS on two search spaces: the CNN search space in DARTS~\citep{darts} and NAS-Bench-201~\citep{nasbench201}. For DARTS space, we conduct experiments on both CIFAR-10 and ImageNet in section~\ref{sec:cifar10} and~\ref{sec:imagenet} respectively. For NAS-Bench-201, we test all 3 supported datasets (CIFAR-10, CIFAR-100, ImageNet-16-120~\citep{imagenet16}) in section~\ref{sec:201}. Furthermore, we empirically study the dynamics of exploration and exploitation throughout the search process in section~\ref{sec:ee}.
\subsection{Results on CIFAR-10}
\label{sec:cifar10}
\paragraph{Architecture Space}
For both search and evaluation phases, we stack 20 cells to compose the network and set the initial channel number as 36. We place the reduction cells at the 1/3 and 2/3 of the network and each cell consists of $N=6$ nodes.
\paragraph{Search Settings}
We equally divide the 50K training images into two parts, one is used for optimizing the network weights by momentum SGD and the other for learning the Dirichlet architecture distribution by an Adam optimizer.
Since Dirichlet concentration $\beta$ must be positive, we apply the shifted exponential linear mapping $\beta = \text{ELU}(\eta) + 1$ and optimize over $\eta$ instead.
We use $l_2$ norm to constrain the distance between $\eta$ and the anchor $\hat\eta = 0$.
The $\eta$ is initialized by standard Gaussian with scale 0.001, and $\lambda$ in (\ref{eq:cop}) is set to 0.001.
The ablation study in Appendix~\ref{app:sensitivity} reveals the effectiveness of our anchor regularizer, and DrNAS is insensitive to a wide range of $\lambda$.
These settings are consistent for all experiments.
For progressive architecture learning, the whole search process consists of 2 stages, each with 25 iterations.
In the first stage, we set the partial channel parameter $K$ as 6 to fit the super-network into a single GTX 1080Ti GPU with 11GB memory, i.e., only 1/6 features are sampled on each edge.
For the second stage, we prune half candidates and meanwhile widen the network twice, i.e., the operation space size reduces from 8 to 4 and $K$ becomes 3.
\paragraph{Retrain Settings}
The evaluation phase uses the entire 50K training set to train the network from scratch for 600 epochs.
The network weight is optimized by an SGD optimizer with a cosine annealing learning rate initialized as 0.025, a momentum of 0.9, and a weight decay of $3\times 10^{-4}$.
To allow a fair comparison with previous work, we also employ cutout regularization with length 16, drop-path~\citep{nasnet} with probability 0.3 and an auxiliary tower of weight 0.4.
\paragraph{Results}
Table~\ref{tab:cifar10} summarizes the performance of DrNAS compared with other popular NAS methods, and we also visualize the searched cells in Appendix~\ref{app:vis}.
DrNAS achieves an average test error of 2.46\%, ranking top amongst recent NAS results.
ProxylessNAS is the only method that achieves lower test error than us, but it searches on a different space with a much longer search time and has larger model size.
We also perform experiments to assign proper credit to the two parts of our proposed algorithm, i.e., Dirichlet architecture distribution and progressive learning scheme.
When searching on a proxy task with 8 stacked cells and 16 initial channels as the convention~\citep{darts,pcdarts}, we achieve a test error of 2.54\% that surpasses most baselines.
Our progressive learning algorithm eliminates the gap between the proxy and target tasks, which further reduces the test error.
Consequently, both of the two parts contribute a lot to our performance gains.
\begin{table}[!t]
\centering
\caption{Comparison with state-of-the-art image classifiers on CIFAR-10.}
\resizebox{.8\textwidth}{!}{
\begin{threeparttable}
\begin{tabular}{lcccc}
\hline
\textbf{Architecture} & \textbf{\tabincell{c}{Test Error\\(\%)}} & \textbf{\tabincell{c}{Params\\(M)}} & \textbf{\tabincell{c}{Search Cost\\(GPU days)}} & \textbf{\tabincell{c}{Search\\Method}} \\ \hline
DenseNet-BC~\citep{densenet}\tnote{$\star$} & 3.46 & 25.6 & - & manual \\ \hline
NASNet-A~\citep{nasnet} & 2.65 & 3.3 & 2000 & RL \\
AmoebaNet-A~\citep{amoebanet} & $3.34\pm 0.06$ & 3.2 & 3150 & evolution \\
AmoebaNet-B~\citep{amoebanet} & $2.55\pm0.05$ & 2.8 & 3150 & evolution \\
PNAS~\citep{pnas}\tnote{$\star$} & $3.41\pm 0.09$ & 3.2 & 225 & SMBO \\
ENAS~\citep{enas} & 2.89 & 4.6 & 0.5 & RL \\ \hline
DARTS (1st)~\citep{darts} & $3.00\pm 0.14$ & 3.3 & 0.4 & gradient \\
DARTS (2nd)~\citep{darts} & $2.76\pm 0.09$ & 3.3 & 1.0 & gradient \\
SNAS (moderate)~\citep{snas} & $2.85\pm 0.02$ & 2.8 & 1.5 & gradient \\
GDAS~\citep{gdas} & 2.93 & 3.4 & 0.3 & gradient \\
BayesNAS~\citep{BayesNAS} & $2.81\pm 0.04$ & 3.4 & 0.2 & gradient \\
ProxylessNAS~\citep{proxylessnas}\tnote{$\dagger$} & 2.08 & 5.7 & 4.0 & gradient \\
PARSEC~\citep{parsec} & $2.81\pm 0.03$ & 3.7 & 1 & gradient \\
P-DARTS~\citep{pdarts} & 2.50 & 3.4 & 0.3 & gradient \\
PC-DARTS~\citep{pcdarts} & $2.57\pm 0.07$ & 3.6 & 0.1 & gradient \\
SDARTS-ADV~\citep{smoothdarts} & $2.61\pm 0.02$ & 3.3 & 1.3 & gradient \\
GAEA + PC-DARTS~\citep{gaea} & $2.50\pm 0.06$ & 3.7 & 0.1 & gradient \\ \hline
DrNAS (without progressive learning) & $2.54\pm 0.03$ & 4.0 & 0.4\tnote{$\ddagger$} & gradient \\
DrNAS & $2.46\pm 0.03$ & 4.1 & 0.6\tnote{$\ddagger$} & gradient \\ \hline
\end{tabular}
\begin{tablenotes}
\item[$\star$] Obtained without cutout augmentation.
\item[$\dagger$] Obtained on a different space with PyramidNet~\citep{pyramidnet} as the backbone.
\item[$\ddagger$] Recorded on a single GTX 1080Ti GPU.
\end{tablenotes}
\end{threeparttable}}
\label{tab:cifar10}
\vspace{-2.5mm}
\end{table}
\subsection{Results on ImageNet}
\label{sec:imagenet}
\paragraph{Architecture Space}
The network architecture for ImageNet is slightly different from that for CIFAR-10 in that we stack 14 cells and set the initial channel number as 48. We also first downscale the spatial resolution from $224\times 224$ to $28\times 28$ with three convolution layers of stride 2 following previous works~\citep{pcdarts,pdarts}.
The other settings are the same with section~\ref{sec:cifar10}.
\paragraph{Search Settings}
Following PC-DARTS~\citep{pcdarts}, we randomly sample 10\% and 2.5\% images from the 1.3M training set to alternatively learn network weight and Dirichlet architecture distribution by a momentum SGD and an Adam optimizer respectively.
We use 8 RTX 2080 Ti GPUs for both search and evaluation, and the setup of progressive pruning is the same with that on CIFAR-10, i.e., 2 stages with operation space size shrinking from 8 to 4, and the partial channel $K$ reduces from 6 to 3.
\paragraph{Retrain Settings}
For architecture evaluation, we train the network for 250 epochs by an SGD optimizer with a momentum of 0.9, a weight decay of $3\times 10^{-5}$, and a linearly decayed learning rate initialized as 0.5.
We also use label smoothing and an auxiliary tower of weight 0.4 during training.
The learning rate warm-up is employed for the first 5 epochs following previous works~\citep{pdarts,pcdarts}.
\paragraph{Results}
As shown in Table~\ref{tab:imagenet}, we achieve a top-1/5 test error of 23.7\%/7.1\%, outperforming all compared baselines and achieving state-of-the-art performance in the ImageNet mobile setting. The searched cells are visualized in Appendix~\ref{app:vis}.
Similar to section~\ref{sec:cifar10}, we also report the result achieved with 8 cells and 16 initial channels, which is a common setup for the proxy task on ImageNet~\citep{pcdarts}. The obtained 24.2\% top-1 accuracy is already highly competitive, which demonstrates the effectiveness of the architecture distribution learning on large-scale tasks.
Then our progressive learning scheme further increases the top-1/5 accuracy for 0.5\%/0.2\%.
Therefore, learning in a task-specific manner is essential to discover better architectures.
\begin{table}[!t]
\centering
\caption{Comparison with state-of-the-art image classifiers on ImageNet in the mobile setting.}
\resizebox{.9\textwidth}{!}{
\begin{threeparttable}
\begin{tabular}{lccccc}
\hline
\multirow{2}*{\textbf{Architecture}} & \multicolumn{2}{c}{\textbf{Test Error(\%)}} & \multirow{2}*{\textbf{\tabincell{c}{Params\\(M)}}} &
\multirow{2}*{\textbf{\tabincell{c}{Search Cost\\(GPU days)}}} &
\multirow{2}*{\textbf{\tabincell{c}{Search\\Method}}} \\ \cline{2-3}
& top-1 & top-5 & & & \\ \hline
Inception-v1~\citep{inception-v1} & 30.1 & 10.1 & 6.6 & - & manual \\
MobileNet~\citep{mobilenets} & 29.4 & 10.5 & 4.2 & - & manual \\
ShuffleNet $2\times$ (v1)~\citep{shufflenet-v1} & 26.4 & 10.2 & $\sim 5$ & - & manual \\
ShuffleNet $2\times$ (v2)~\citep{shufflenet-v2} & 25.1 & - & $\sim 5$ & - & manual \\ \hline
NASNet-A~\citep{nasnet} & 26.0 & 8.4 & 5.3 & 2000 & RL \\
AmoebaNet-C~\citep{amoebanet} & 24.3 & 7.6 & 6.4 & 3150 & evolution \\
PNAS~\citep{pnas} & 25.8 & 8.1 & 5.1 & 225 & SMBO \\
MnasNet-92~\citep{mnasnet} & 25.2 & 8.0 & 4.4 & - & RL \\ \hline
DARTS (2nd)~\citep{darts} & 26.7 & 8.7 & 4.7 & 1.0 & gradient \\
SNAS (mild)~\citep{snas} & 27.3 & 9.2 & 4.3 & 1.5 & gradient \\
GDAS~\citep{gdas} & 26.0 & 8.5 & 5.3 & 0.3 & gradient \\
BayesNAS~\citep{BayesNAS} & 26.5 & 8.9 & 3.9 & 0.2 & gradient \\
DSNAS~\citep{dsnas}\tnote{$\dagger$} & 25.7 & 8.1 & - & - & gradient \\
ProxylessNAS (GPU)~\citep{proxylessnas}\tnote{$\dagger$} & 24.9 & 7.5 & 7.1 & 8.3 & gradient \\
PARSEC~\citep{parsec} & 26.0 & 8.4 & 5.6 & 1 & gradient \\
P-DARTS (CIFAR-10)~\citep{pdarts} & 24.4 & 7.4 & 4.9 & 0.3 & gradient \\
P-DARTS (CIFAR-100)~\citep{pdarts} & 24.7 & 7.5 & 5.1 & 0.3 & gradient \\
PC-DARTS (CIFAR-10)~\citep{pcdarts} & 25.1 & 7.8 & 5.3 & 0.1 & gradient \\
PC-DARTS (ImageNet)~\citep{pcdarts}\tnote{$\dagger$} & 24.2 & 7.3 & 5.3 & 3.8 & gradient \\
GAEA + PC-DARTS~\citep{gaea}\tnote{$\dagger$} & 24.0 & 7.3 & 5.6 & 3.8 & gradient \\ \hline
DrNAS (without progressive learning)\tnote{$\dagger$} & 24.2 & 7.3 & 5.2 & 3.9 & gradient \\
DrNAS\tnote{$\dagger$} & 23.7 & 7.1 & 5.7 & 4.6 & gradient \\ \hline
\end{tabular}
\begin{tablenotes}
\item[$\dagger$] The architecture is searched on ImageNet, otherwise it is searched on CIFAR-10 or CIFAR-100.
\end{tablenotes}
\end{threeparttable}}
\label{tab:imagenet}
\vspace{-2.5mm}
\end{table}
\subsection{Results on NAS-Bench-201}
\label{sec:201}
Recently, some researchers doubt that the expert knowledge applied to the evaluation protocol plays an important role in the impressive results achieved by leading NAS methods~\citep{HardEvaluation, randomnas}.
So to further verify the effectiveness of DrNAS, we perform experiments on NAS-Bench-201~\citep{nasbench201},
where architecture performance can be directly obtained by querying in the database.
NAS-Bench-201 provides support for 3 dataset (CIFAR-10, CIFAR-100, ImageNet-16-120~\citep{imagenet16}) and has a unified cell-based search space containing 15,625 architectures.
We refer to their paper~\citep{nasbench201} for details of the space.
Our experiments are performed in a task-specific manner, i.e., the search and evaluation are based on the same dataset. The hyperparameters for all compared methods are set as their default and for DrNAS, we use the same search settings with section~\ref{sec:cifar10}.
We run every method 4 independent times with different random seeds and report the mean and standard deviation in Table~\ref{tab:nasbench201}.
As shown, we achieve the best accuracy on all 3 datasets. On CIFAR-100, we even achieve the global optimal.
Specifically, DrNAS outperforms DARTS, GDAS, DSNAS, PC-DARTS, and SNAS by 103.8\%, 35.9\%, 30.4\%, 6.4\%, and 4.3\% on average.
We notice that the two methods (GDAS and DSNAS) that enforce a discrete constraint, i.e., only sample a single path every search iteration, perform undesirable especially on CIFAR-100.
In comparison, SNAS, employing a similar Gumbel-softmax trick but without the discretization, performs much better.
Consequently, a discrete constraint during search can reduce the GPU memory consumption but empirically suffers instability.
In comparison, we develop the progressive learning scheme on top of the architecture distribution learning, enjoying both memory efficiency and strong search performance.
\begin{table}[!htb]
\vspace{-2mm}
\centering
\caption{Comparison with state-of-the-art NAS methods on NAS-Bench-201.}
\resizebox{1.\textwidth}{!}{
\begin{tabular}{lccccccc}
\hline
\multirow{2}*{\textbf{Method}} & \multicolumn{2}{c}{\textbf{CIFAR-10}} & \multicolumn{2}{c}{\textbf{CIFAR-100}} & \multicolumn{2}{c}{\textbf{ImageNet-16-120}} \\ \cline{2-7}
& validation & test & validation & test & validation & test \\ \hline
ResNet~\citep{resnet} & 90.83 & 93.97 & 70.42 & 70.86 & 44.53 & 43.63 \\ \hline
Random (baseline) & $90.93\pm 0.36$ & $93.70\pm 0.36$ & $70.60\pm 1.37$ & $70.65\pm 1.38$ & $42.92\pm 2.00$ & $42.96\pm 2.15$ \\
RSPS~\citep{randomnas} & $84.16\pm 1.69$ & $87.66\pm 1.69$ & $45.78\pm 6.33$ & $46.60\pm 6.57$ & $31.09\pm 5.65$ & $30.78\pm 6.12$ \\
Reinforce~\citep{nasnet} & $91.09\pm 0.37$ & $93.85\pm 0.37$ & $70.05\pm 1.67$ & $70.17\pm 1.61$ & $43.04\pm 2.18$ & $43.16\pm 2.28$ \\ \hline
ENAS~\citep{enas} & $39.77\pm 0.00$ & $54.30\pm 0.00$ & $10.23\pm 0.12$ & $10.62\pm 0.27$ & $16.43\pm 0.00$ & $16.32\pm 0.00$ \\
DARTS (1st)~\citep{darts} & $39.77\pm 0.00$ & $54.30\pm 0.00$ & $38.57\pm 0.00$ & $38.97\pm 0.00$ & $18.87\pm 0.00$ & $18.41\pm 0.00$ \\
DARTS (2nd)~\citep{darts} & $39.77\pm 0.00$ & $54.30\pm 0.00$ & $38.57\pm 0.00$ & $38.97\pm 0.00$ & $18.87\pm 0.00$ & $18.41\pm 0.00$ \\
GDAS~\citep{gdas} & $90.01\pm 0.46$ & $93.23\pm 0.23$ & $24.05\pm 8.12$ & $24.20\pm 8.08$ & $40.66\pm 0.00$ & $41.02\pm 0.00$ \\
SNAS~\citep{snas} & $90.10\pm 1.04$ & $92.77\pm 0.83$ & $69.69\pm 2.39$ & $69.34\pm 1.98$ & $42.84\pm 1.79$ & $43.16\pm 2.64$ \\
DSNAS~\citep{dsnas} & $89.66\pm 0.29$ & $93.08\pm 0.13$ & $30.87\pm 16.40$ & $31.01\pm 16.38$ & $40.61\pm 0.09$ & $41.07\pm 0.09$ \\
PC-DARTS~\citep{pcdarts} & $89.96\pm 0.15$ & $93.41\pm 0.30$ & $67.12\pm 0.39$ & $67.48\pm 0.89$ & $40.83\pm 0.08$ & $41.31\pm 0.22$ \\
DrNAS & $\bf{91.55\pm 0.00}$ & $\bf{94.36\pm 0.00}$ & $\bf{73.49\pm 0.00}$ & $\bf{73.51\pm 0.00}$ & $\bf{46.37\pm 0.00}$ & $\bf{46.34\pm 0.00}$ \\ \hline
\textbf{optimal} & 91.61 & 94.37 & 73.49 & 73.51 & 46.77 & 47.31 \\ \hline
\end{tabular}}
\label{tab:nasbench201}
\vspace{-2mm}
\end{table}
\subsection{Empirical Study on Exploration v.s. Exploitation}
\label{sec:ee}
We further conduct an empirical study on the dynamics of exploration and exploitation in the search phase of DrNAS on NAS-Bench-201.
After every search epoch, We sample 100 $\theta$s from the learned Dirichlet distribution and take the $\argmax$ to obtain 100 discrete architectures. We then plot the range of their accuracy along with the architecture selected by Dirichlet mean (solid line in Figure~\ref{fig:exploration201}).
Note that in our algorithm, we simply derive the architecture according to the Dirichlet mean as described in Section~\ref{subsec:drnas}.
As shown in Figure~\ref{fig:exploration201}, the accuracy range of the sampled architectures starts very wide but narrows gradually during the search phase.
It indicates that DrNAS learns to encourage exploration in the search space at the early stages and then gradually reduces it towards the end as the algorithm becomes more and more confident of the current choice.
Moreover, the performance of our architectures can consistently match the best performance of the sampled architectures, indicating the effectiveness of DrNAS.
\begin{figure}[ht!]
\vspace{-1.5mm}
\begin{minipage}{1.\linewidth}
\centering
\subfloat[CIFAR-10]{\includegraphics[clip, width=0.33\textwidth]{fig/drnas_min_max_cifar10.png}}
\subfloat[CIFAR-100]{\includegraphics[clip, width=0.33\textwidth]{fig/drnas_min_max_cifar100.png}}
\subfloat[ImageNet16-120]{\includegraphics[clip, width=0.33\textwidth]{fig/drnas_min_max_imagenet16-120.png}}
\end{minipage}%
\caption{
Accuracy range (min-max) of the 100 sampled architectures. Note that the solid line is our derived architecture according to the Dirichlet mean as described in Section~\ref{subsec:drnas}.
}
\label{fig:exploration201}
\vspace{-2.0mm}
\end{figure}
\section{Conclusion}
In this paper, we propose Dirichlet Neural Architecture Search (DrNAS). We formulate the differentiable NAS as a constraint distribution learning problem, which explicitly models the stochasticity in the architecture mixing weight and balances exploration and exploitation in the search space.
The proposed method can be optimized efficiently via gradient-based algorithm, and possesses theoretical benefit to improve the generalization ability.
Furthermore, we propose a progressive learning scheme to eliminate the search and evaluation gap.
DrNAS consistently achieves strong performance across several image classification tasks, which reveals its potential to play a crucial role in future end-to-end deep learning platform.
\section*{Acknowledgement}
The paper is supported by NSF IIS-1901527, IIS 2008173, IIS-2048280 and the research gifts from Facebook and Intel.
| {'timestamp': '2021-03-17T01:09:43', 'yymm': '2006', 'arxiv_id': '2006.10355', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10355'} | arxiv |
\section{Supplementary material}
\subsection{Sampling error in UV-grids}
\label{app:sampling}
We quantitatively measure how well the UV-grids approximate the original surface geometry. We chose a random selection of 132,492 models from the ABC dataset, and converted them into our UV-grid representation: curves are represented by grids with 10 points and unit tangents, while surface are represented by 10$\times$10 grids with points and unit surface normals.
We then compute four metrics, two related to edge curve approximation and two related to surface approximation:
\begin{itemize}
\item
Chordal error (curves): The distance between the center of the line joining two points and the ground truth curve evaluated at the average $u$ parameter value of two successive sample points.
\item
Chordal error (surfaces): The distance between the average of four points defining a patch on a 10$\times$10 point grid and the real surface evaluated at the average $(u,v)$ of the patch. This error metric is considering the point grid as a bi-linear approximation of the surface.
\item
B\'ezier~ approximation error (curves): A cubic B\'ezier~{} span is constructed from the points and unit tangent vectors following Equation 9.47 in \cite{piegl1996:nurbsbook}. The B\'ezier~ approximation error is then taken as the average distance between the center of the B\'ezier~{} and the real edge curve evaluated at the average $u$ parameter value of the two sample points used to construct the B\'ezier~ span.
\item
B\'ezier~ approximation error (surfaces): A cubic B\'ezier~{} patch is constructed from the 4 points and unit normals following Equation 9.58 in \cite{piegl1996:nurbsbook}. The B\'ezier~ approximation error is then taken as the average distance between the center of the patch, and the real surface evaluated the central $(u,v)$ parameter value. This error metric is considering the point grid as a cubic B\'ezier~ approximation of the surface.
\end{itemize}
To allow these errors to be compared for solids of different sizes we divide each by then longest length of the bounding box of the entire solid.
\begin{table}[b]
\centering
\caption{Percentage of curves and surfaces with approximation errors exceeding various thresholds computed on random samples from the ABC dataset.}
\small
\begin{tabular}{lcccc}
\toprule
\multirow{2}{1.5cm}{Factor of box size} & \multicolumn{2}{c}{Surfaces} & \multicolumn{2}{c}{Curves} \\
\cmidrule{2-5}
& B\'ezier~ & Chordal & B\'ezier~ & Chordal\\
\midrule
Above $10^{-3}$ & 3.16\% & 10.81\% & 0.23\% & 6.67\% \\
Above $10^{-2}$ & 0.80\% & 2.65\% & 0.06\% & 1.33\% \\
Above $10^{-1}$ & 0.09\%& 0.10\%& 0.02\%& 0.02\%\\
\bottomrule
\end{tabular}
\label{tab:uvgrid-sampling-error}
\end{table}
As the neural network is passed ordered lists of edge curve points and tangents and an ordered grid of points and normals, the network has sufficient information to understand the curve and surface information as a linear/bilinear interpolation. Chordal errors of \textbf{89.19\%} surface patches and \textbf{93.33\%} curves are within $10^{-3}$ of the longest length of the B-rep's bounding box as shown in Table~\ref{tab:uvgrid-sampling-error}.
The network also has access to curve tangent and surface normal information. If we assume that the surface normal information can be used by the network then the approximation error is further reduced and we find that the B\'ezier~ approximation errors of \textbf{96.84\%} surface patches and \textbf{99.77\%} are within $10^{-3}$ of the longest length of the B-rep's bounding box.
While it is unclear if the network actually uses this information to build an interpolation of the curve/surface geometry, this information is part of the input and is empirically found to help in our ablation studies (see Section~\ref{sec:ablation}).
\subsection{SolidLetters dataset}
\label{app:dataset}
A publicly available, balanced, and labeled dataset is vital to assist in designing and testing B-rep neural network architectures.
To this end, we create ``SolidLetters'', a new, synthetic, labeled dataset for solid models that includes both geometric and topological variations.
It comprises upper and lower case letters in various styles obtained from a collection of 2002 system and Google Fonts.
Each data point has three labels: (1) the alphabet, (2) the case (upper or lower), and (3) the name of the font.
\begin{figure}[b]
\centering
\begin{subfigure}[b]{0.22\textwidth}
\centering
\includegraphics[height=0.49\textwidth, keepaspectratio]{images/wire.png}
\caption{}\label{fig:solid_mnist_running_example_a}
\end{subfigure}
\begin{subfigure}[b]{0.24\textwidth}
\centering
\includegraphics[height=0.4\textwidth, keepaspectratio]{images/sheet.png}
\caption{}\label{fig:solid_mnist_running_example_b}
\end{subfigure}
\\
\begin{subfigure}[b]{0.23\textwidth}
\centering
\includegraphics[height=0.49\textwidth, keepaspectratio]{images/extrusion.png}
\caption{}\label{fig:solid_mnist_running_example_c}
\end{subfigure}
\begin{subfigure}[b]{0.23\textwidth}
\centering
\includegraphics[height=0.49\textwidth, keepaspectratio]{images/fillet.png}
\caption{}\label{fig:solid_mnist_running_example_d}
\end{subfigure}
\caption{Running example of data generation. (a) 2D wire B-rep going through boundary of the font face. (b) Trimmed planar sheet filling the interior of the boundary. (c) Extrude. (d) Fillet edges of the topmost face (SolidLetters).}
\label{fig:solid_mnist_running_example}
\end{figure}
\myparagraph{Creation}
We first create the outline of each letter with every font (size 10) (Figure~\ref{fig:solid_mnist_running_example_a}), and fill its interior with a trimmed planar sheet surface, see Figure~\ref{fig:solid_mnist_running_example_b}.
Treating the planar sheet as a profile surface on the XY-plane, we extrude it along a vector $\mathbf{e}$ pointing upwards, see Figure~\ref{fig:solid_mnist_running_example_c}.
We define this vector such that its head lies at a random point in the spherical cap situated along the z-axis to introduce variance in the extrusion direction.
By sampling two random numbers $\xi_1$ and $\xi_2$ from a uniform distribution $U(0, 1)$, we can define the vector $\mathbf{e}$ as: $\mathbf{e}_x = \sqrt{1 - \mathbf{e}_z^2} \cos(2\pi \xi_2)$, $\mathbf{e}_y = \sqrt{1 - \mathbf{e}_z^2} \sin(2\pi \xi_2)$, $\mathbf{e}_z = \xi_1 (1 - \cos\theta) + \cos\theta$, where $\theta$ is the angle subtended by the spherical cap that we set to $45^\circ$.
Furthermore, to break the symmetry of the shape across the XY-plane and introduce more complexity in the model, we identify the topmost face in the extruded solid and perform filleting by blending the edges with a constant radius $0.1$, see Figure~\ref{fig:solid_mnist_running_example_d}.
This introduces new curved faces in the model along the edges of the topmost face, and changes the topology as well.
Filleting is prone to failure when the face has edges that meet at sharp angles or the local thickness is small compared to the filleting radius.
Hence, we attempt to fillet three times by successively reducing the filleting radius by 50\%, and upon failure leave the extruded solid as such.
After removing fonts that are non-English and symbols, we end up with a total of 95,795 data points.
\begin{figure}
\centering
\includegraphics[width=\columnwidth]{images/solidletters_stats.pdf}
\caption{Per-class distribution of solids in the SolidLetters dataset.}
\label{fig:solidletters_stats}
\end{figure}
There is an average of 33 faces per solid in the dataset.
The per-class distribution of data is shown in Figure~\ref{fig:solidletters_stats}.
We show a visual overview of the entire dataset in Figure~\ref{fig:SolidLetters_mosaic}.
\myparagraph{Data split}
We partition the dataset into an official 80-20 train-test split based on the complexity of the solids, which can be roughly measured using the number of faces.
We place the solids in the datasets into three bins based on the number of faces: $[F_\text{min}, F_1), [F_1, F_2), [F_2, F_\text{max}]$, where $F_\text{min}$ and $F_\text{max}$ are the minimum and maximum number of faces in a solid in the entire dataset, respectively.
$F_1$ is defined as $0.15\times (F_\text{max} - F_\text{min})$, while $F_2$ is set to $0.30\times (F_\text{max} - F_\text{min})$.
The solids in each bin are partitioned randomly into an 80-20 train-test split and finally combined.
\begin{figure*}
\centering
\includegraphics[width=0.99\textwidth]{images/mosiac.png}
\caption{Visual overview of the SolidLetters dataset.}
\label{fig:SolidLetters_mosaic}
\end{figure*}
\subsection{Other datasets}
\label{app:other-datasets}
\subsubsection{Machining feature}
The Machining feature dataset~\cite{zhang2018:featurenet} is available at \url{github.com/madlabub/Machining-feature-dataset}.
The original train-test split information was not available, so we created a random 85-15 split within each category, and held out 20\% of the training set for validation.
\subsubsection{FabWave}
The FabWave dataset~\cite{atin2019:fabsearch} is available at \url{dimelab.org/fabwave}.
We use the subset of data that the authors call ``Standard" which contains mechanical part categories.
There are a total of 52 part categories, this is 4 less than what is provided in the dataset because we removed some categories that have very few or no models available in them.
There is no official train-test split, so we randomly partitioned the data in a 80-20 ratio within each class.
\begin{figure*}
\centering
\includegraphics[width=0.8\linewidth]{images/fabwave_stats.pdf}
\caption{Distribution of categories in the FabWave dataset.}
\label{fig:fabwave_stats}
\end{figure*}
The data distribution is shown in Figure~\ref{fig:fabwave_stats}.
\subsubsection{MFCAD}
The MFCAD dataset~\cite{cao2020:gnn} is available at \url{github.com/hducg/MFCAD}.
The dataset has 15,488 files (this is 2 more than listed in the paper).
The train-validation-test ratio is 60-20-20, and we use the official split shared by the authors which partitions the models while considering the number of labels per solid.
Unlike the full set of labels described in the paper, the dataset only has labels on planar faces.
This is likely because Cao et al.~\cite{cao2020:gnn}'s method only supports planar faces.
\begin{figure}
\centering
\includegraphics[width=\columnwidth]{images/mfcad_example.pdf}
\caption{Example 3D models from the MFCAD dataset, colored by segmentation label.}
\label{fig:mfcadvisual}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=\columnwidth]{images/mfcad_stats.pdf}
\caption{Distribution of segmentation labels in the MFCAD dataset.}
\label{fig:mfcadstats}
\end{figure}
There are a total of 350,295 faces in the dataset classified into 16 segmentation categories.
Some visual examples are shown in Figure~\ref{fig:mfcadvisual}, and the class distribution in Figure~\ref{fig:mfcadstats}.
\subsubsection{ABC}
The entire ABC dataset~\cite{koch2019:abc} consists of over 1 million CAD assemblies containing over 13 million individual B-rep bodies created by users of the Onshape CAD software. It is available at \url{deep-geometry.github.io/abc-dataset}. To use the dataset in our experiments we use the following process to remove duplicates and generate segmentation labels.
\myparagraph{Duplication removal}
We remove duplicates from the ABC dataset in four steps. All duplicate removal is performed at the B-rep body level, rather than with assemblies.
\begin{enumerate}[leftmargin=*]
\item \textbf{Remove small files}: A significant number of models in the dataset are simple primitives that are unsuitable for our experiments. We first remove models with a file size of less than 15kB as a simple but effective proxy for removing simple primitives.
\item \textbf{Remove file duplicates and invalid files}: We next remove exact file duplicates and invalid file type such as $\mathtt{.xmm\_txt}$.
\item \textbf{Remove non-solid and simple solids}: We next remove non-solid models, such as those containing only wires or open solids, as well as simple solids with less than 30 faces.
\item \textbf{Remove geometric duplicates}: Finally we remove geometric duplicates by creating and comparing a unique hash string for each model using the number of edges, number of faces, number of shells, number of lumps, area, volume, and moments of inertia. This approach is efficient and invariant to rotation.
\end{enumerate}
From the pool of unique models we choose a random sample of 46k models to use in our experiments.
\myparagraph{Segmentation labels}
Since the ABC dataset is unlabeled, we create our own labels to test UV-Net's segmentation performance on a real-world dataset.
We use the Autodesk Shape Manager (ASM)~\cite{asm} kernel to perform a rule-based feature prediction for each of the faces in the solids.
ASM predicts the modeling operation that could have created the face, e.g., chamfer, fillet, extrude and revolve.
ASM is unable to identify the modeling operation in some cases, and we ignore such faces during training/testing.
Additionally, it also predicts whether the \texttt{change} made by the extrusion was additive or subtractive.
We consolidate this information into labels as follows:
\begin{itemize}[leftmargin=*]
\item \textit{Chamfer}, \textit{Fillet} and \textit{Revolve} are retained as such. However, we notice that \textit{Chamfer} and \textit{Revolve} are virtually non-existent in our data.
\item In the case of extrusion, we utilize the extrude direction and the surface normals of a sample of points in the visible region of each face to make a fine-grained categorization.
\begin{itemize}[leftmargin=*]
\item If the normals and extrude direction are aligned, then we set the label as \textit{ExtrudeEnd} if the \texttt{change} type is additive, and \textit{CutEnd} if the \texttt{change} type is subtractive.
\item If the normals and extrude direction are near perpendicular, then we set the label as \textit{ExtrudeSide} if the \texttt{change} type is additive, and \textit{CutSide} if the \texttt{change} type is subtractive.
\end{itemize}
\end{itemize}
\begin{figure}
\centering
\includegraphics[width=\columnwidth]{images/abc_example.pdf}
\caption{Example 3D models from the ABC dataset, colored by segmentation label.}
\label{fig:abc_example}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=\columnwidth]{images/abc_stats.pdf}
\caption{Distribution of segmentation labels in the ABC dataset.}
\label{fig:abc_stats}
\end{figure}
Our subset of the ABC dataset has a total of 4,218,036 faces.
Figure~\ref{fig:abc_example} shows some example segmentation labels while the label distribution shown in Figure~\ref{fig:abc_stats}.
The dataset is split into train and test sets randomly in a 80-20 ratio.
\subsection{Training details}
Our implementation is in PyTorch and we use DGL (\url{dgl.ai}) for graph operations.
All experiments were conducted on NVIDIA GV100, Quadro P6000, or Tesla V100 GPUs.
All networks in Section~\ref{sec:experiments} are optimized using the Adam optimizer with default parameters (learning rate: 0.001, $\beta_1$: 0.9, $\beta_2$: 0.999).
UV-Net's mini-batches are created by concatenating the nodes and edges of all the graphs in the batch to form a supergraph.
For all classification and segmentation experiments, we used a batch size of 128 for UV-Net, PointNet, and FeatureNet.
We reduced the batch size to 64 for DGCNN, due to its high memory consumption, and used the default mini-batch size of 16 with MeshCNN.
Contrastive learning generally requires a higher batch size since the quality of negative views depend on the data points in the mini-batch, hence, we set it to 256 in this case.
DGCNN has a hyperparameter $k$ to define the number of k-nearest neighbors used to build the graph dynamically in each of its layers.
We set this to 20 in the classification and segmentation experiments.
In the sensitivity to sampling study in Section~\ref{ssec:sensitivity_sampling}, we set $k$ to 10 in the case of $1024$ points, and 5 in the case of $512$ and $256$ points, so that the local neighborhood is well defined.
We adapted the following implementations for our comparisons:
\begin{itemize}[leftmargin=*]
\item \textbf{PointNet}: we used the PyTorch implementation from the official DGCNN code (\url{github.com/WangYueFt/dgcnn}) for classification, and an unofficial implementation for segmentation (\url{github.com/fxia22/pointnet.pytorch}).
\item \textbf{DGCNN}: we used the official PyTorch implementation available at \url{github.com/WangYueFt/dgcnn} for classification. Since the segmentation implementation was not available in the official version, we used another implementation from \url{github.com/AnTao97/dgcnn.pytorch} that is recommended by the authors.
\item \textbf{FeatureNet}: we implemented this model based on the network architecture provided in the paper~\cite{zhang2018:featurenet}.
\item \textbf{MeshCNN}: we used the official implementation from \url{github.com/ranahanocka/MeshCNN}.
\end{itemize}
\subsection{Additional self-supervised results}
\subsubsection{Ablation on CLR transformations}
We perform an ablation study on the different transformations that we proposed to generate views for contrastive learning.
We train our CLR model on the SolidLetters dataset for 100 epochs while removing one transformation at a time.
While training for 100 epochs is not sufficient for the network to converge, it gives us a fair understanding of the importance of each transformation.
\begin{figure}
\centering
\includegraphics[width=0.98\columnwidth]{images/ablation_retrieval.pdf}
\caption{Ablation on the transformations used in contrastive learning.}
\label{fig:ablation_retrieval}
\end{figure}
The clustering and linear SVM classification scores are computed as described in Section~\ref{ssec:clr} and reported in Figure~\ref{fig:ablation_retrieval}.
It is apparent from the results that using all the proposed transformations together is generally beneficial and improves the shape embeddings.
It is important to note that the transformations may have to be tuned for practical use cases based on the dataset and potential downstream tasks.
For example, the right number of hops used to define the subgraphs may vary based on the complexity of the B-reps in the dataset.
We did not explore this in our experiments, and directly applied the method that gave best results in the SolidLetters dataset on the ABC dataset.
\subsubsection{Shape retrieval}
Here we share more qualitative results for shape retrieval on the SolidLetters and ABC datasets with k-nearest search in the latent space generated by our contrastive learning method in Figure~\ref{fig:more_solidmnist_retrievals} and Figure~\ref{fig:more_abc_retrievals}.
\begin{figure*}
\centering
\includegraphics[height=0.94\textheight,keepaspectratio]{images/solidmnist-more-retrievals.png}
\caption{More self-supervised shape retrieval results on SolidLetters. Column 1: Query, Columns 2--11: Retrieved results sorted left to right by distance in latent space.}
\label{fig:more_solidmnist_retrievals}
\end{figure*}
\begin{figure*}
\centering
\includegraphics[height=0.94\textheight,keepaspectratio]{images/abc-more-retrievals.png}
\caption{More self-supervised shape retrieval results on ABC. Column 1: Query, Columns 2--11: Retrieved results sorted left to right by distance in latent space.}
\label{fig:more_abc_retrievals}
\end{figure*}
\section{Conclusion}
We have presented UV-Net, a neural network and representation that can work on B-rep data, and leverage existing image and graph convolutional neural networks.
We have shown its benefits and versatility on both supervised and self-supervised tasks spanning five B-rep datasets, outperforming other representations such as point clouds, voxels, and meshes.
In addition, we introduced SolidLetters, a new synthetic B-rep dataset with variations in both geometry and topology.
We believe our work can unlock data-driven applications in established CAD modeling pipelines, and revitalize research interest in this domain.
\myparagraph{Limitations \& future work}
We fixed the sampling step size for each curve or surface regardless of its geometry.
Choosing the step using derivatives~\cite{zheng2000:estimatetesselation,kawasaki2018:imageprocbspline} or learning it in a task-dependent manner could be an interesting extension.
While UV-grids are versatile, we did not exploit other information available in the B-rep such as curve and surface types, edge convexity, halfedge ordering, etc. which might prove useful in certain applications.
Finally, our UV-grid features are not rotation-invariant. Although we can use local coordinates for each UV-grid~\cite{deng2018:ppfnet,deng2018:ppffoldnet} or switch to other features like mean-curvature, this may make the network lose sight of the relative orientation of various faces and edges. We leave the detailed study of various invariances to future work.
We also believe there is tremendous potential to improve our self-supervised method for transfer learning from large datasets like ABC.
Finally, it is worth investigating how ideas from this work can be adapted to other representations like subdivision surfaces, where the limit surface can be parametrized as a regular structure using the faces of the control mesh.
\section{Experiments}
\label{sec:experiments}
In this section, we qualitatively and quantitatively evaluate UV-Net on 3D shape classification, segmentation, and shape retrieval on unlabelled data.
\subsection{Datasets}
We briefly introduce the five datasets used in our experiments and provide further details in the supplementary material. We select the datasets below as they are available in B-rep format, unlike many common benchmark datasets provided in mesh format.
\myparagraph{Machining feature dataset~\cite{zhang2018:featurenet}} a synthetic labeled, balanced dataset representing machining features such as chamfers and circular end pockets applied to a cube. It has 23,995 3D shapes ($\sim$1000 per class) split into 24 classes.
\myparagraph{MFCAD dataset~\cite{cao2020:gnn}} a synthetic segmentation dataset of 15,488 3D shapes, similar to the Machining feature dataset, but with multiple machining features. 16 different segmentation labels are used and applied per face.
\myparagraph{FabWave dataset~\cite{atin2019:fabsearch}} a small labeled, imbalanced collection of 5,373 3D shapes split into 52 mechanical part classes, such as brackets, gears, and o-rings.
\myparagraph{ABC dataset~\cite{koch2019:abc}} a real-world collection of millions of 3D shapes.
The dataset is unlabelled, imbalanced, and has many duplicates.
We remove duplicates and use a subset of 46k models in our experiments.
\myparagraph{SolidLetters dataset} our dataset consists of 96k 3D shapes generated by randomly extruding and filleting the 26 alphabet letters (a--z) to form class categories across 2002 style categories from fonts.
Compared to other synthetic datasets that have similar intra-class topology, SolidLetters contains significant variations in both geometry and topology, due to font variety, and is well-balanced.
\subsection{Tasks}
We now compare UV-Net to PointNet~\cite{qi2017:pointnet}, DGCNN~\cite{wang2019:dgcnn}, and MeshCNN~\cite{hanocka2019:meshcnn} on several standard tasks. We show additional results from the baseline methods presented with the Machining feature and MFCAD datasets.
\subsubsection{Classification}
We first evaluate our method on the task of 3D shape classification. The ability to classify 3D components in large B-rep assemblies is valuable for numerous applications including product lifecycle management and automation of repetitive tasks such as simulation setup.
We show the advantages of using both geometry and topology in the B-rep.
This is particularly important in datasets where data within a class has high geometric variance but similar topology, as is common in parametric CAD modeling.
Our network comprises the UV-Net encoder network in Figure~\ref{fig:network_arch} followed by a non-linear classifier (2-layer MLP) that maps the 128D shape embedding into class logits.
Our input geometric features include xyz coordinates and the trimming mask.
We train point cloud-based methods on 2048 points sampled uniformly from the solid model,
FeatureNet~\cite{zhang2018:featurenet}, the baseline for the Machining feature dataset, on 64$^3$ voxel grids, and MeshCNN~\cite{hanocka2019:meshcnn} on triangle meshes.
For the Machining Feature dataset we convert B-reps into high-quality, watertight, manifold meshes as required by MeshCNN using the finite-element mesher in Autodesk Fusion 360 with a target edge-count of 2000 edges. As MeshCNN requires all meshes to have a similar edge count, we find it is impractical to use with datasets of varying shape complexity, such as FabWave, SolidLetters, and ABC. Although it may be feasible to use a target edge count suitable for the most complex shape in the dataset, in practice this dramatically increases training time and limits the advantages of mesh pooling.
We train all models to a maximum of 350 epochs with cross-entropy loss and the Adam~\cite{kingma2014:adam} optimizer.
Table~\ref{tab:classification} shows that our method achieves the best classification accuracy on all datasets.
Unstructured representations suffer when data within a class has high geometric variance but similar topology, since they cannot model the latter explicitly.
Notably, we outperform FeatureNet~\cite{zhang2018:featurenet} on their dataset, and obtain the highest results on SolidLetters, demonstrating that our method can exploit both geometry and topology.
\begin{table}
\small
\centering
\caption{Solid model classification.}
\begin{tabular}{llcr}
\toprule
Dataset &Model &Accuracy (\%) &\#Param. \\
\midrule
\multirow{4}{1.5cm}{Machining Feature} &UV-Net & {\bf 99.94 $\pm$ 0.00} & 1.34M \\
&PointNet (2048) & 87.13 $\pm$ 0.15 & 0.81M\\
&DGCNN (2048) & 92.81 $\pm$ 0.69 & 1.81M\\
&FeatureNet (64$^3$) & 98.85 $\pm$ 0.48 & 33.94M\\
&MeshCNN (2000) & 98.90 $\pm$ 0.70 & 0.67M\\
\midrule
\multirow{3}{1.5cm}{FabWave} &UV-Net & {\bf 94.51 $\pm$ 0.10} & 1.35M \\
&PointNet (2048) & 80.08 $\pm$ 3.61 & 0.82M\\
&DGCNN (2048) & 69.95 $\pm$ 2.37 & 1.81M\\
\midrule
\multirow{3}{1.5cm}{SolidLetters} &UV-Net & {\bf 97.24 $\pm$ 0.10} & 1.34M\\
&PointNet (2048) & 94.72 $\pm$ 0.17 & 0.81M\\
&DGCNN (2048) & 96.62 $\pm$ 0.13 & 1.81M\\
\bottomrule
\end{tabular}
\label{tab:classification}
\end{table}
\subsubsection{Segmentation}
We now consider the problem of segmenting the faces of a B-rep, a classic task with applications in machining feature recognition, computer-aided process planning and CAD modeling history reconstruction.
We consider the MFCAD and ABC datasets in this experiment and demonstrate the benefit of directly working with B-rep entities.
To work around lack of labels in the ABC dataset, we use the Autodesk Shape Manager~\cite{asm}, a commercial solid-modeling kernel, to assign labels indicating the CAD operation likely to have created the face, such as \textit{ExtrudeSide}, \textit{ExtrudeEnd}, or \textit{Fillet}, we provide more details in supplementary material.
Our segmentation network is similar to the classification network with a small difference: we concatenate the shape embedding to each of the node embeddings, and use a non-linear classifier to output per-node logits.
We additionally include curve tangents and surface normals in the edge and face input features, respectively.
To investigate the benefits of working with B-rep data directly, we compare against established point and mesh-based methods.
We mesh the B-reps in the MFCAD dataset, as previously described and discard $27$ shapes that fail to mesh.
To generate point clouds for both the MFCAD and ABC datasets, we first convert the B-reps into render-meshes, i.e., non-watertight, disjoint meshes.
We then sample the triangles uniformly based on the surface area to generate 2048 points.
The mapping between the faces and primitives (edges, and points) are retained, so that we can perform a per-face voting to compute face-level scores.
\begin{table*}
\centering
\caption{Solid face segmentation. The per-primitive scores refer to per-point scores for point cloud-based models and per-edge scores for MeshCNN. The corresponding per-face scores are computed by voting the predictions from all primitives in a face.}
\small
\begin{tabular}{llccccccc}
\toprule
\multirow{2}{*}{Dataset} & \multirow{2}{*}{Model} &\multicolumn{2}{c}{Accuracy} &\multicolumn{2}{c}{Per-class accuracy} &\multicolumn{2}{c}{Intersection-over-Union} & \multirow{2}{*}{\#Param.}\\
\cmidrule{3-8}
& &Per-face &Per-prim. &Per-face &Per-prim. &Per-face &Per-prim.\\
\midrule
\multirow{6}{*}{MFCAD} & UV-Net & {\bf 99.95 $\pm$ 0.02}&- & {\bf 99.93 $\pm$ 0.20}&- & {\bf 99.87 $\pm$ 0.03}&- &1.23M\\
& UV-Net (xyz) & 99.83 $\pm$ 0.06&- & 99.80 $\pm$ 0.00 &- & 99.63 $\pm$ 0.06 &- &1.23M\\
& PointNet &32.13 $\pm$ 7.92 &59.13 $\pm$ 7.54 &16.20 $\pm$ 8.51 & 15.78 $\pm$ 8.17 &7.15 $\pm$ 5.22 &8.27 $\pm$ 4.66 &0.87M\\
& DGCNN &82.50 $\pm$ 2.46 &91.60 $\pm$ 2.18 &80.43 $\pm$ 4.51 &78.80 $\pm$ 4.57 &67.70 $\pm$ 4.73 &78.67 $\pm$ 6.27 &0.98M\\
& GNN &-&- &-&- &93.60~\cite{cao2020:gnn}&- &0.53M\\
& MeshCNN & 99.89 $\pm$ 0.01 & 98.52 $\pm$ 0.04 & 99.84 $\pm$ 0.03 & 98.29 $\pm$ 0.09 & 99.70 $\pm$ 0.06 & 95.93 $\pm$ 0.05 &2.29M\\
\midrule
\multirow{4}{*}{ABC} & UV-Net &{\bf 88.87 $\pm$ 0.70} &- &{\bf 56.81 $\pm$ 0.93} &- &{\bf 50.37 $\pm$ 1.11} &- &1.23M\\
& UV-Net (xyz) &77.33 $\pm$ 0.48 &- &47.38 $\pm$ 0.54 &- & 38.99 $\pm$ 0.42 &- &1.23M\\
& PointNet &40.77 $\pm$ 1.79 &61.27 $\pm$ 0.55 &19.87 $\pm$ 0.51 &25.53 $\pm$ 0.32 &11.10 $\pm$ 0.70 &18.47 $\pm$ 0.31 & 0.87M\\
& DGCNN &54.18 $\pm$ 3.19 &67.80 $\pm$ 0.59 &27.30 $\pm$ 1.34 &34.93 $\pm$ 1.52 &18.14 $\pm$ 1.97 &26.26 $\pm$ 1.27 &0.98M\\
\bottomrule
\end{tabular}
\label{tab:segmentation}
\end{table*}
We train the models as before using the cross-entropy loss.
Considering each face in the B-rep as a data point, we report the accuracy, per-class accuracy and intersection-over-union (IoU) metrics in Table~\ref{tab:segmentation}.
Results show that UV-Net solves the face segmentation problem in the MFCAD dataset, outperforming their baseline method~\cite{cao2020:gnn} and point cloud-based methods by a wide margin.
MeshCNN~\cite{hanocka2019:meshcnn} obtains very similar results to UV-Net; we suggest this is due to the dihedral angle feature used, which many segmentation labels in the MFCAD dataset strongly correlate with.
Our method achieves state-of-the-art results while operating on B-reps directly and avoids the problem of producing consistent meshing.
We observe a similar trend with the ABC dataset.
Point cloud methods are unable to discover the topological information necessary to identify rare classes, and suffer from loss of fidelity.
\subsubsection{Self-supervised learning}
\label{ssec:clr}
Learning from unlabeled data is important with solid models since real-world labeled datasets are limited, and representation learning by an encoder-decoder scheme is non-trivial due to a lack of B-rep decoders.
We leverage contrastive learning~\cite{wu2018:unsupervised,chen2020:simclr2,he2020:moco,sanghi2020:info3d} (CLR) and propose the following transformations to create positive views for training on B-rep data, each of which enforces a useful prior on the model.
\myparagraph{Connected patch} Extract a random node and its $n$-hop neighbors ($n\in\{1, 2\}$). This implies that local patches in a B-rep hint about the global shape.
\myparagraph{Drop nodes} Randomly delete nodes with uniform probability (0.4) along with attached edges to encourage B-reps with partially similar faces to be clustered together in the latent space.
\myparagraph{Drop edges} Randomly delete edges with uniform probability (0.4), to encourage B-reps that look similar visually, but have different topology be clustered together.
\begin{figure}
\centering
\includegraphics[width=0.95\columnwidth]{images/retrieval.png}
\caption{Self-supervised shape retrieval on SolidLetters and ABC datasets. Column 1: Query, Columns 2--11: Retrieved results sorted left to right by distance in latent space.}
\label{fig:retrieval}
\end{figure}
Our CLR model has three components~\cite{chen2020:simclr2}.
Given a B-rep in UV-grid+graph representation $G$, we uniformly sample two i.i.d. transformations $T_1$ and $T_2$ to obtain two positive views $T_1(G)$ and $T_2(G)$.
Occasionally (10\% of the time), we set $T_1$ to the identity transformation so that the global shape is available to the neural network to associate with the other partial views.
An ablation study for these transformations is provided in the supplementary material.
Our UV-Net encoder extracts the 128D shape embeddings $h_i$ and $h_j$ of positive pairs.
A 3-layer non-linear projection head (MLP) with ReLU activations maps these embeddings to 64D latent vectors $z_i$ and $z_j$.
Given a mini-batch of size $N=256$, we compute $\{z_k~|~k\in 1 \ldots 2N\}$, and bring together the positive pairs while treating the remaining $2(N - 1)$ data as negative examples, with the normalized temperature scaled
cross-entropy~\cite{chen2020:simclr2} loss.
We first use the SolidLetters dataset (upper case only since CLR performs per-instance discrimination) to quantitatively understand how our method performs.
After training the model for $350$ epochs, we extract the shape embeddings of the test set and perform k-means clustering to generate $26$ clusters.
We measure the clustering quality against ground truth clusters (labels) using the adjusted mutual-information metric~\cite{vinh2010:ami}.
We also classify the shape embeddings using a linear Support-Vector Machine (SVM) and compute the classification accuracy.
Results in Table~\ref{tab:clr_solidletters} show that the shape embeddings obtained with our CLR model is rich with category information even though it is trained without labels.
\begin{table}
\centering
\caption{Quality of self-supervised shape embeddings obtained with our contrastive learning method on SolidLetters.}
\small
\begin{tabular}{lc}
\toprule
Method & Score (\%) \\
\midrule
Linear SVM & 79.40 $\pm$ 0.20\\
K-means clustering & 58.17 $\pm$ 0.25\\
\bottomrule
\end{tabular}
\label{tab:clr_solidletters}
\end{table}
To perform shape retrieval, we take random shape embeddings from the test set of SolidLetters and ABC (random 20\% split) as queries, and compute their k-nearest neighbors in the UV-Net shape embedding space as shown in Figure~\ref{fig:retrieval}.
The results demonstrate that our CLR approach is viable, and shows high potential to learn from large-scale unlabeled CAD datasets, an unaddressed problem until now.
\subsection{Sensitivity to sampling}
\label{ssec:sensitivity_sampling}
We now study the effect of the sampling resolution on the accuracy produced by the network.
A robust method should degrade gracefully when the sample count is reduced, or leverage other information to produce consistent results.
\begin{figure}
\centering
\includegraphics[width=0.85\columnwidth]{images/sensitivity_sampling.pdf}
\caption{Sensitivity of input representations and methods to sampling resolution for machining feature classification.}
\label{fig:sensitivity_sampling}
\end{figure}
The classification networks are all trained with reduced resolution data and the accuracy is reported in Figure~\ref{fig:sensitivity_sampling}.
We see that our method is robust to sampling resolution in the machining feature detection task.
This is because we not only capture the geometry, but also the topological information that can be leveraged for the task.
Moreover, every face in the solid is \textit{seen} by UV-Net regardless of its surface area, while other representations suffer from loss of fidelity.
\subsection{Feature and architecture ablation}
\label{sec:ablation}
Here we study the importance of the input features, and network components on the MFCAD segmentation problem:
\myparagraph{Full UV-Net (xyz only)} We remove the normals from the set of input features but use the full architecture.
\myparagraph{UV-Net (Face only)} This is similar to the full architecture, but without the input curve features and curve CNN ($f_\Theta(h_{uv})$ term in Eq.~\ref{eq:node_message_passing} and entire Eq.~\ref{eq:edge_message_passing} are removed).
\myparagraph{Face features only} We replace the GNN portion of the network with an MLP (similar parameter count as the GNN). Edge features are also removed since they cannot be considered without a message-passing scheme.
\myparagraph{Topology only} We remove the curve and surface CNNs, and set the edge and node attributes of the graph as noise sampled from a normal distribution, so that the network is forced to solve the task with topology features only.
\begin{figure}
\centering
\includegraphics[width=0.95\columnwidth]{images/ablation_study.pdf}
\caption{Ablation study with input features and components of UV-Net on the MFCAD segmentation problem.}
\label{fig:ablation}
\end{figure}
These networks are trained for 100 epochs on the MFCAD segmentation task and the IoU score is compared against the full model.
The benefits of jointly considering the geometric features and topology as proposed is evident from Figure~\ref{fig:ablation}, and validates the merits of our approach.
\subsection{Invariance to reparametrization}
A solid can be altered in subtle ways without changing the 3D appearance by reparametrizing the curve/surface geometry.
This can occur when converting models from one format to another (e.g. STEP to SAT), changing the surface type (e.g. plane to spline), or as a result of some high level CAD modeling operation.
The UV-grid is to a large extent invariant to common reparametrizations as discussed earlier.
On the other hand, reversing a surface parametrization along the u- or v-axis amounts to flipping the UV-grid about the same axis, while transposing the surface parametrization by exchanging the u- and v-axis is equivalent to rotating and flipping the UV-grid.
\begin{table}
\centering
\caption{Effect of reparametrizing the SolidLetters classification \textit{test set} on UV-Net.}
\small
\label{tab:additional:augmentation}
\begin{tabular}{lccc}
\toprule
Convolution & Reparametrized &Test Accuracy\\
\midrule
\multirow{2}{*}{Regular} & No &96.74 $\pm$ 0.06\\
& Yes &55.98 $\pm$ 2.36\\
\midrule
\multirow{2}{*}{$\text{D}_2$ equivariant} & No &96.58 $\pm$ 0.01\\
& Yes &96.59 $\pm$ 0.02\\
\bottomrule
\end{tabular}
\label{tab:augmentation}
\end{table}
Flips about u- and v-axis and rotations by $\{k\frac{\pi}{2}~|~k \in [0, 1, 2, 3]\}$ belong to the Dihedral symmetry group $\text{D}_2$, and regular image convolutions are not invariant to them as we show in Table~\ref{tab:augmentation}.
We see that randomly performing these transformations to surfaces in the test set but not the training set affects the classification accuracy.
However, employing $\text{D}_2$ group equivariant convolutions~\cite{weiler2019:e2cnn} followed by a group pooling layer in the surface CNN~(Section~\ref{sec:input_representation}) makes the model resilient to these reparametrizations.
\section{Introduction}
Parametric curves and surfaces form the basis of computer-aided design (CAD) and are widely used in design, simulation, and manufacturing.
CAD software is primarily concerned with modeling and representing 3D solids---closed, watertight shapes which describe objects unambiguously with consistently oriented patches of surface geometry.
The industry-wide standard to represent solid models is the Boundary representation (B-rep)~\cite{weiler1986:topological,lee2001:partialentity}. The B-rep is a versatile data structure comprised of faces (bounded portions of surfaces), edges (bounded pieces of curves) and vertices (points), glued together with topological connections between them.
The B-rep enables a variety of parametric curves and surfaces, such as lines, arcs, planes, cylinders, toruses and Non-Uniform Rational B-Splines (NURBS), to precisely represent complex 3D shapes formed from CAD modeling operations such as extrusions, fillets, and Booleans.
CAD users interact directly with B-rep faces, edges, and vertices to select, align, and modify 3D shapes. To leverage the recent advances of deep neural networks in CAD software, an appropriate representation of B-rep data is required. Such a representation has the potential to unlock numerous CAD applications such as auto-complete of modeling operations, smart selection tools, shape similarity search and many more. Critical to enabling these applications is a representation that encodes the B-rep entities themselves.
\begin{figure}
\centering
\includegraphics[width=0.98\columnwidth]{images/Teaser_v01.pdf}
\caption{UV-Net builds features by sampling points on the edges and faces of solid models. These features are then message-passed among adjacent topological entities.}
\label{fig:teaser}
\end{figure}
Despite widespread usage of B-rep data in the industry, there exists limited research on applying deep neural networks to this representation directly.
There are numerous challenges in feeding B-rep data to neural networks.
B-rep data consists of disparate geometric and topological entities, such as parametric curves and surfaces, each with their own set of parameters.
Moreover, the mapping between a shape and a surface type is not one-to-one, for example, a plane can be represented as a B-spline of arbitrary degree. This means raw surface information, such as parametric coefficients or spline control points, cannot be fed directly into a neural network, as it would not be invariant to the specific parameterization.
Finally, consideration must be given to how different curve and surface geometry are connected to form the entire shape, i.e. the topology.
An alternate approach is to preprocess B-rep data into well-studied representations, such as images, voxels, point clouds, or triangle meshes.
Although plausible, such conversions are neither differentiable, nor trivial. Discretized representations, such as point clouds or voxels, suffer from loss of fidelity and may lose the critical mapping back to the original B-rep entities.
Conversion to triangle meshes can be non-trivial and prone to failure when high quality, manifold meshes are required~\cite{christophe2009:gmsh}.
To tackle these challenges, we present UV-Net, a novel neural network architecture and representation designed to operate directly on B-rep entities (Figure~\ref{fig:teaser}). In this paper, we make the following contributions:
\begin{itemize}[leftmargin=*]
\item We present a new representation of 3D CAD models derived from B-reps, which captures geometric features from the parameter domain as a regular grid, and topological information as a graph.
\item We propose a novel architecture which couples an image CNN and a hierarchical graph-neural network in a compute and memory-efficient manner.
\item We create and release a synthetic labeled dataset: SolidLetters, which unlike other synthetic datasets, is balanced, and has variations in both geometry and topology.
\item We demonstrate the efficacy of UV-Net on multiple tasks including 3D shape classification, segmentation, and self-supervised shape retrieval on unlabeled data. We achieve state-of-the-art results on both classification and segmentation tasks by leveraging the full B-rep data structure.
\end{itemize}
\section{Method}
In this section we review the B-rep data structure, and introduce UV-Net's representation and network architecture.
\subsection{Input representation}
\label{sec:input_representation}
The B-rep data structure comprises several topological entities---faces, edges, halfedges, and vertices, with connections between them, see Figure~\ref{fig:uvnet_representation} (a). Faces are the visible portion of parametric surfaces such as planes, cones, cylinders, toruses, and splines. Edges are the visible interval of parametric curves and vertices are the endpoints of edges. Each face is delimited by one or more loops of halfedges. Anti-clockwise loops define outer boundaries while clockwise loops define internal holes. Solid modeling packages are designed to generate closed and watertight B-rep models, in which every edge contains two halfedges on adjacent faces. The data structure also stores many references allowing efficient navigation between all adjacent entities \cite{ lee2001:partialentity}.
Although expressive, the B-rep is a complex data structure and is difficult to feed to neural networks in its original form.
Our goal is to extract the most informative geometric and topological information from the B-rep, and convert it into a representation that can easily and efficiently work with existing neural network architectures.
\myparagraph{Topology}
UV-Net uses a face-adjacency graph derived from the B-rep, $G(V, E)$, to model the topology where the vertices $V$ represent the faces in the B-rep, while the edges $E$ encode the connectivity between the faces, as shown in Figure~\ref{fig:uvnet_representation} (b).
This can be easily built in constant time complexity by traversing through the halfedges of the B-rep: current face $\rightarrow$ halfedges $\rightarrow$ twin-halfedges $\rightarrow$ neighboring faces.
The face adjacency captures the two most geometrically and topologically rich entities: faces and edges from the B-rep, and is sufficient to capture both local and global information about a solid, as we later demonstrate.
\begin{figure*}
\centering
\includegraphics[width=0.92\textwidth]{images/network_architecture.pdf}
\caption{UV-Net encoder architecture. (a) A solid model is represented by (b) a set of regular UV-grids representing each face's and edge's geometry by discretizing the parameter domain, and a graph that captures its topology with face-adjacency information. (c) Curve and surface features are extracted from the UV-grids with 1D and 2D CNNs, respectively. (d) These features are treated as edge and node embeddings of the graph and further processed by graph convolutions. The result is a set of node embeddings, that can be pooled to get the shape embedding of the solid model.}
\label{fig:network_arch}
\end{figure*}
\myparagraph{Curve geometry}
Each topological edge in a B-rep has an associated parametric curve to define the actual geometry.
Consider one such parametric curve $\mathbf{C}(u)$, which is a map from an interval $[u_{\text{min}}, u_{\text{max}}] \in \mathbb{R}$, the parameter domain, to the geometry domain $\mathbb{R}^3$.
The curve could be parameterized as a line, circular arc, or B-spline;
we only expect that an interface is available to evaluate the curve and optionally, its first order derivative.
Our idea is to represent the geometry of the curve by discretizing its parameter domain~\cite{kawasaki2018:imageprocbspline} as a regular 1D grid by a uniform step size $\delta u = \frac{u_{\text{max}} - u_{\text{min}}}{M - 1}$, where $M$ is the number of chosen samples, as shown in Figure~\ref{fig:uvnet_representation} (c).
At each of the discretized points in the parameter domain $u_k$, we can attach a set of features evaluated from the curve, e.g.,
absolute point coordinates $\mathbf{C}(u_k)$, and optionally the unit tangent vector $\hat{\mathbf{C}_u}(u_k)$ as features.
This 1D UV-grid is set as input edge features in $G$ as shown in Figure~\ref{fig:uvnet_representation}(c).
\myparagraph{Surface geometry}
Each topological face in a B-rep has an associated surface geometry that can be a plane, sphere, cylinder, cone, or a freeform NURBS surface.
The surfaces are trimmed by the halfedge loops that run along the boundary of the face to expose only a portion of the surface as a visible region.
Consider one such parametric surface $\mathbf{S}(u, v)$ which is a map from a 2D interval $[u_{\text{min}},u_{\text{max}}]\times [v_{\text{min}},v_{\text{max}}] \in \mathbb{R}^2$, the parameter domain, to the geometry domain $\mathbb{R}^3$.
We discretize the parameter domain into a regular 2D grid of samples with step sizes $\delta u = \frac{u_{\text{max}} - u_{\text{min}}}{M - 1}$, and $\delta v = \frac{v_{\text{max}} - v_{\text{min}}}{N - 1}$, where $M$ and $N$ are the number of samples along each dimension, as shown in Figure~\ref{fig:uvnet_representation} (c).
The intervals $[u_{\text{min}}, u_{\text{max}}]$ and $[v_{\text{min}}, v_{\text{max}}]$ are chosen such that they closely bound the loop that defines the visible region.
At each of these grid points indexed by $(k, l)$, we attach the following local features encoding the geometry of the surface as channels:
(1) 3D absolute point position $\mathbf{S}(u_k, v_l)$ (the scale of the solid is normalized into a cube of size 2 and centered at origin).~
(2) Optionally, the 3D absolute surface normal $\frac{\mathbf{S}_u(u_k, v_l)\times \mathbf{S}_v(u_k, v_l)}{\|\mathbf{S}_u(u_k, v_l)\times \mathbf{S}_v(u_k, v_l)\|}$ pointing outwards consistently.
(3) Trimming mask with $1$ and $0$ representing samples that are in the visible region and trimmed region, respectively.
This 2D UV-grid is defined as input node features in $G$.
The representation is flexible enough to incorporate other features like curvature based on the downstream task.
We set the number of samples $M$=$N$=$10$ in all experiments throughout the paper.
This is not a technical restriction, rather it is convenient to form mini-batches of features.
A fixed step size is sufficient when the mapping between parameter and geometry domains are roughly uniform.
We quantitatively evaluate this in the supplementary material.
In the case of extreme parameterizations with high stretching, it is possible to derive a step size to upper bound the distance between samples~\cite{zheng2000:estimatetesselation}.
\myparagraph{Advantages}
The UV-Net representation has several advantages:
(1) Evaluating curves/surfaces at a set of parameters is fast for both primitive and spline surfaces~\cite{sederberg2012:cagd}.
(2) The representation is sparse and scales with the number curves and surfaces in the B-rep.
(3) The grid is largely invariant to the exact parametrization.
For example, the grid does not change when a planar surface is converted into a NURBS patch, or when degree elevation or knot insertion is performed, since the parameterization and geometry remain identical~\cite{piegl1996:nurbsbook}.
In contrast, the raw curve/surface equation will change significantly.
(4) Finally, local neighborhoods in the parameter domain (UV-grids) correspond to local neighborhoods in curve/surface geometry domain, hence hierarchical feature extraction on the manifold~\cite{bronstein2017:geometricdl} is possible.
\subsection{Network architecture}
\label{sec:network_arch}
With this representation, we first perform image convolutions on the curve and surface UV-grids.
These local curve/surface features are then propagated over the entire B-rep with graph convolutions as shown in Figure~\ref{fig:network_arch}.
\myparagraph{Curve \& surface convolution}
Our surface CNN takes in 2D UV-grids with typically 4 or 7 channels (3 xyz, 3 normals, 1 trimming mask) and is defined as:
\(\text{Conv}(4/7, 64, 3)\rightarrow \text{Conv}(64, 128, 3)\rightarrow \text{Conv}(128, 256, 3)
\rightarrow \text{Pool}(1, 1) \rightarrow \text{FC}(256, 64),\)
where \(\text{Conv}(i, o, k)\) is an image convolutional layer with $i$ input channels, $o$ output channels, and kernel size $k$, \(\text{Pool}(n, n)\) is an adaptive average pooling layer which outputs a \(n\times n\) feature map, and \(\text{FC}(i, o)\) is a fully connected layer which takes an input in $i$-D vector and maps it to $o$-D vector.
Our curve CNN takes 1D UV-grids computed from the curves lying in the edges of the B-rep, and is defined similarly with 1D convolutional and pooling layers.
The weights of the curve and surface CNN are shared among all edges and faces in a B-rep, respectively, making them permutation-invariant.
Both convolutional and fully-connected layers do not have biases, and include batch normalization and the LeakyReLU activation function.
We pad the features with size $\lfloor\nicefrac{k}{2}\rfloor$ to retain the spatial dimensions of the input.
\myparagraph{Message passing}
The output of curve and surface CNNs are hidden features treated as input edge and node features to the graph neural network.
Given the initial features, we compute the hidden node features $h_v^{(k)}$ in graph layer $k\in 1\ldots K$, by aggregating the input node features $h_v^{(k-1)}$ from a one-hop neighborhood $u \in N(v)$ while conditioning them on the edge features $h_{uv}^{(k-1)}$:
\begin{align}
h_v^{(k)} = \phi^{(k)}\bigg(&(1 + \epsilon^{(k)})~h_v^{(k-1)} +\nonumber\\
&\sum_{u \in N(v)} f_\Theta \big(h_{uv}^{(k-1)}\big) \odot h_u^{(k-1)} \big)
\bigg),
\label{eq:node_message_passing}
\end{align}
where $\phi^{(k)}$ is a multi-layer perceptron (MLP) with two fully connected layers $FC(64, 64)\rightarrow FC(64, 64)$, $\epsilon^{(k)}$ is a learnable parameter to distinguish the center nodes from the neighbors and $f_\Theta$ is a linear projection from the edge to node feature space.
This update equation extends the Graph Isomorphism Network~\cite{xu2018:gin}, with additional consideration of edge features.
The hidden edge features are next updated similarly while considering the features of the endpoint nodes:
\begin{equation}
h_{uv}^{(k)} = \psi^{(k)}\bigg( (1 + \gamma^{(k)})~h_{uv}^{(k-1)} + f_\Xi\big(h_{u}^{(k-1)} + h_{v}^{(k-1)}\big) \bigg),
\label{eq:edge_message_passing}
\end{equation}
where $\psi^{(k)}$ is a 2-layer MLP as before, $\gamma^{(k)}$ is a learnable parameter to distinguish the edge features from its neighbors, and $f_\Xi$ is a linear projection from the node to edge feature space.
At the end, we then take all the hidden node features $\{ h_v^{(k)}~|~ k \in 1\ldots K \}$ and apply an element-wise max-pooling operation across the nodes to obtain hierarchical graph-level feature vectors from every layer $\{ h^{(k)}~|~k \in 1\ldots K\}$, where $h^{(k)} = {\textrm{maxpool}_{v \in V}(h_v^{(k)})}$.
These features are then linearly projected into 128D vectors and summed to obtain the final shape embedding:
\begin{equation}
h_G = \sum_{k=1}^K w^{(k)} \cdot h^{(k)} + b^{(k)} .
\end{equation}
We use $K=2$ graph layers in all experiments.
The node and graph embeddings obtained from the network can be used for several downstream applications as detailed next.
\section{Related Work}
\myparagraph{Common geometric representations}
Modern neural networks work with several discrete 3D representations like point clouds, voxels, meshes and multi-view images.
A B-rep can be easily sampled to obtain point clouds~\cite{qi2017:pointnet,wang2019:dgcnn}.
A problem with this conversion is that CAD models often contain small features that convey important information.
A prohibitively dense point cloud might be required to capture such fine details.
3D CNNs~\cite{wu2015:3dShapeNets} can be applied to voxelized B-reps, as shown by Zhang et al.~\cite{zhang2018:featurenet} for classification.
Unfortunately, there is a cubic compute and memory cost to increasing the voxel grid resolution to capture small faces from a B-rep.
O-CNN~\cite{wang2017:ocnn} can alleviate this problem using sparse octrees, however, very deep octrees may be needed to delineate tiny faces common in B-rep data.
Neural networks representing signed distance~\cite{park2019:deepsdf,chen2019:imnet} or occupancy~\cite{mescheder2019:occupancynet} functions are grid-free and concise, but need to learn mappings to B-rep face and edges along with positional encodings to support downstream applications, which is a challenging problem.
Triangle meshes on the other hand better preserve the geometric and topological information of a solid model~\cite{hanocka2019:meshcnn,wiersma2020:surfrotequivcnn}.
These methods require the B-rep to be converted to watertight, manifold meshes with tight constraints on vertex/edge count, edge length, and angles; a difficult task prone to failure~\cite{hu2019:triwild,christophe2009:gmsh}.
Finally, multi-view images represent 3D shapes by rendering, and have shown excellent results on shape classification and retrieval~\cite{su2015:mvcnn}.
Such renderings are not expressive enough to represent and map back to the multitude of entities in a B-rep, thereby limiting applications.
There is a recent interest in the machine learning community
in the generation of parametric geometry such as B\'ezier~ curves \cite{lopes2019:svgvae,wang2020:attr2font,smirnov2020:dps}, splines \cite{gao2019:deepspline}, Coons patches \cite{smirnov2020:coons} and binary space partitioning planes \cite{chen2020:bspnet}.
However, these methods do not deal with feature extraction from B-reps with disparate parametric curve/surface types.
\myparagraph{3D geometry as images}
Closely related to our consideration of geometry as regular grids or images are geometry images~\cite{gu2002:geometryimages} where arbitrary meshes were parametrized into 2D grids for compression and resampling.
Sinha et al.~\cite{sinha2016:learngeomimages} parametrized meshes globally as images to apply CNNs.
Groueix et al.~\cite{groueix2018:atlasnet} learnt the parametrization of point clouds by deforming grids of points.
Kawasaki et al.~\cite{kawasaki2018:imageprocbspline} smoothed the normal map of B-spline surfaces for fairing.
Different from these works, we deal with parametric shapes employed in CAD, and focus on deriving a representation from the B-rep while retaining geometric and topological information.
\begin{figure*}
\centering
\includegraphics[width=0.92\linewidth]{images/representation.pdf}
\caption{Our representation. (a) The B-rep is a complex data structure with several geometric and topological entities that is difficult to feed to neural networks. (b) We derive a face-adjacency graph from the B-rep to capture topological information. (c) Each face and edge in a B-rep contains a parametric surface and curve, respectively, which we represent as regular UV-grids, and store as node and edge attributes in the graph. Local neighborhoods in UV-grids map to local regions in the geometry.}\label{fig:uvnet_representation}
\end{figure*}
\myparagraph{Boundary representations}
Few neural networks are capable of directly consuming B-rep data.
Initial attempts before the deep learning era focused on automatically recognizing machining features in a solid model.
These methods convert the B-rep into a face-adjacency graph~\cite{ansaldi1985:geometric}, with features such as surface type and edge convexity, that is then used by rule-based schemes~\cite{joshi1988:graphbasedheuristics} or simple neural networks~\cite{prabhakar1992:affm,konstantinos1997:recog212d}.
However, hand-engineered features struggle to generalize well to other tasks.
Babic et al.~\cite{babic2008:reviewrulebased} surveys several classic machine learning methods for feature classification on B-reps.
Very recently, Cao et al.~\cite{cao2020:gnn} used a graph neural network to segment the faces of a B-rep by converting it into a face-adjacency graph.
A major limitation of this method is that it can only work on B-reps with planar faces, as it uses the coefficients of the scalar plane equation as node features to describe the geometry.
In contrast to these works, we aim to derive a general representation from the B-rep that is suitable for a wide range of tasks, and can leverage advances in modern deep learning methods. | {'timestamp': '2021-04-27T02:24:49', 'yymm': '2006', 'arxiv_id': '2006.10211', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10211'} | arxiv |
\section{Introduction}
\label{sec:introduction}
Contact-aided compliant mechanisms (CCMs) are special cases of compliant mechanisms (CMs) that undergo contact while transferring force/motion by means of (large) elastic deformation of its members. Compliant mechanisms offer advantages of zero backlash, high repeatability, assembly-free manufacturing amongst many others, all possible due to absence of rigid-body joints. Consequently, compliant mechanisms readily find applications in areas like electro-mechanical devices, e.g., \cite{masters2005three}, medical equipment, e.g., \cite{frecker2005design} and mechanical devices, e.g., \cite{yin2004optimal}. Contact-aided compliant mechanisms inherit most advantages of compliant mechanisms, and with contact permitted between their constituents and external surfaces and/or between members themselves, CCMs can be designed to deliver intricate mechanical characteristics. CCMs have many applications in compliant joints \cite{cannon2005compliant,moon2007bio}, surgical tools \cite{eastwood2018design,halverson2008flexure}, mechanical devices \cite{howell2001compliant,saxena2013contact, howell2013compliant,song2019new} and flapping wing mechanisms\cite{tummala2014design,calogero2018tuning} and offer immense potential yet to be tapped. Many design methods exist for compliant mechanisms that could be broadly classified into {\it pseudo-rigid-body model} and {\it structural optimization} approaches \cite{howell1994method,howell1996loop,howell2001compliant,edwards2001pseudo,jensen2003identification,masters2005three,sonmez2008compliant,su2009pseudorigid,howell2013compliant}. However, few address a generic design procedure for Contact-aided compliant mechanisms. Mankame and Ananthasuresh\cite{mankame2004topology} are the first to introduce Contact-aided compliant mechanisms to impart special displacement characteristics to CMs. They demonstrate synthesis of CCMs by allowing their members to interact with pre-identified external surfaces in the {\it mutual contact mode} \cite{mankame2007synthesis} to trace non-smooth ($ C^{0} $) paths. Contact between members of the continuum also contributes in CCMs tracing non-smooth paths. Such, \textit{self contact} CCMs are designed in \cite{Reddy2012systematic}, wherein contact location information is not available \textit{a-priori}, rather determined systematically. Using this methodology, a displacement delimited gripper is designed in \cite{saxena2013contact}. Kumar et al. \cite{kumar2019computational} design CCMs for paths with mostly single kinks wherein the design region is represented with hexagonal tessellation, material mask overlay strategy is employed for topology design, and both self, and mutual contact modes are considered assuming frictionless contact. Yin and Lee \cite{lan2008analytical} propose an analytical contact model to design compliant fingers. Mehta et al. \cite{mehta2009stress} demonstrate increase in stretching capacity of contact-aided cellular structures due to the induced stress relief. Jin et al. \cite{jin2020large,jin2020cprbm} propose methodologies to analyze CCMs undergoing mutual contact, beam-to-beam contact and beam-to-rigid contacts.
\section{Aim, novelty, scope and organization}
\label{sec:aim}
The objective, and novelty of this work is systematic continuum design of large deformation CCMs that trace non-smooth paths with multiple (three or more) kinks. To accomplish this, we propose using external surfaces of three different kinds -- circular, elliptical and rectangular. These surfaces, individually or in combination, can offer a variety of local curvatures that CCMs can interact with and benefit from, in delivering the desired intricate characteristics. The methodology proposed herein is significantly improved compared to those in \cite{Reddy2012systematic} and \cite{kumar2019computational}. In \cite{Reddy2012systematic}, only self-contact between members is considered. In \cite{kumar2019computational}, CCMs are synthesized using hexagonal cells with both, self and mutual contact modes, however, rigid external surfaces used are circular in shape. We permit both, self and mutual contact modes in our designs. Compared to \cite{Reddy2012systematic}, (i) contact surfaces are identified efficiently by modeling each as a closed loop. (ii) Many 2D elements are used across frame members to model the latter, thereby addressing mesh independence, a feature absent in both \cite{Reddy2012systematic} and \cite{kumar2019computational} wherein a single element across member width is employed. (iii) Contact interactions between members and junctions and those with free ends of dangling members are all considered. (iv) Care is taken to ensure absence of external surfaces close to the output port, to avoid trivial CCM solutions. Contact is assumed frictionless and external surfaces are rigid. Design generation, evaluation and evolution is performed via \texttt{MATLAB\textsuperscript{TM}} while all intermediate/final designs are analysed using a commercial software, \texttt{ABAQUS\textsuperscript{TM}} which, notwithstanding computational time, offers generic analysis capabilities.
The outline of the paper is as follows. In Sec. \ref{sec:synthesis}, design parameters, methodology for mesh generation of the continuum and that for generating and modeling potential contact surfaces are presented. While a commercial software is used for design evaluation, large deformation friction-free contact analysis is summarized in Sec. \ref{Large_Deformation_contact}. Sec. \ref{sec:objective} discusses the search algorithm. Synthesis of a 3-kink Contact-aided compliant switch is presented in Sec. \ref{sec:examples}, while in Sec. \ref{sec:Discussion}, the 3-kink switch is analysed further for effects of friction and wear. Aspects covering computational efficiency, effect of mesh size on final solution and search algorithm are also discussed, and finally, conclusions are drawn in Sec. \ref{sec:conclusion}.
\section{Methodology}
\label{sec:synthesis}
Procedure for generation of a candidate CCM design is described below.
\subsection{Generation of candidate solution}
\label{sec:design_setup}
The initial design domain comprises of blocks of either square or rectangular shape (Fig. \ref{fig:Design_Domain}a) over which external objects are placed (Fig. \ref{fig:Design_Domain}b). Each block consists of eight members connected with five vertices. External objects are initially assumed circular in shape and are distributed uniformly over the domain space (\textit{nine} external contact surfaces are shown in Fig. \ref{fig:Design_Domain}b).
\begin{figure}[h!]
\centering
\includegraphics[scale=1]{Design_Domain.eps}
\caption{Design domain without (a) and with (b) external contact surfaces. Set of \textit{eight} \textit{red} lines in (a) represent one block. \textit{Blue} circles in (b) represent initial placement of external contact surfaces. ${I} $ represents the input/actuation port, while, ${O} $ represents the output port.}
\label{fig:Design_Domain}
\end{figure}
Each member $m_j$ in the initial domain is associated with both, continuous and discrete variables \cite{Reddy2012systematic}. Continuous variables are varied between the upper and lower bounds specified by the user. Discrete variables take the binary value of either 0 or 1. A different set of continuous and discrete variables define each external surface $S_k$. Design variables for both members and external surfaces are detailed hereunder.
\subsection{Design variables for members} Presence of each member $m_j$ in a candidate design is decided by the continuum topology choice variable $v_{m_j}^c$, that assumes a value of either $0$ or $1$. $v_{m_j}^c=0$ indicates absence of the $j^{th}$ member in the topology, while, $v_{m_j}^c=1$ denotes its presence. If required, as explained in Sec. \ref{sec:Design_Preprocessing}, all members intersecting with any external surface of the candidate design are filtered out by assigning $v_{m_j}^c$ to $0$. Each member, whether present or absent, is modeled as a Hermite cubic curve with end slopes $v_{m_j}^{T_1}$ and $v_{m_j}^{T_2}$, both continuous variables. Each end slope varies between the user specified limits [$v^{ {T}}_L, v^{ {T}}_U$]. The in-plane width $v_{m_j}^w$, a continuous variable for each member $m_j$, varies between the lower and upper bounds [$v_L^{w},v_U^w$]. The out-of-plane thickness $v^{th}$ is the same for all members of the continuum and varies between $v_L^{th}$ and $v_U^{th}$. Also, each vertex $i$ of the domain, with coordinates [$v_{p_i}^x, v_{p_i}^y$], can move freely within a rectangular space controlled by the user specified limits [$v_L^x, v_U^x$] and [$v_L^y, v_U^y$]. As suggested by Borrvall and Petersson \cite{borrvall2001topology}, a continuous variable $v_{I}^F$ representing the magnitude of the input force acting on node $ I $ is considered. $v_{I}^F$ is varied between the user specified limits [$v_{L}^F, v_{U}^F$] like other continuous variables.
\subsection{Design variables for external surfaces} Similar to the discrete choice variable $v_{m_j}^c$ for members, $v_{s_k}^c$ represents the contact topology choice variable for the $k^{th}$ external surface ($S_k$). $v_{s_k}^c$ can be either $0$ or $1$ based on its presence ($v_{s_k}^c=1$) or absence ($v_{s_k}^c=0$). In addition to the topology contact choice variable ($v_{s_k}^c$), \textit{one} discrete ($v_{s_k}^{sh}$) and \textit{six} continuous ($v_{s_k}^x, v_{s_k}^y, v_{s_k}^R, v_{s_k}^{f1}, v_{s_k}^{f2}, v_{s_k}^{\theta}$) variables, define each external surface. The discrete shape variable $v_{s_k}^{sh}$ possesses information about the shape of the $k^{th}$ external surface. Each external surface is either circular, elliptical or rectangular in shape. Accordingly, $v_{s_k}^{sh}$ is assigned with $1$ for circular, $2$ for elliptical, and $3$ for rectangular shapes. Variables [$v_{s_k}^x, v_{s_k}^y$] represent position of the center of $k^{th}$ external surface. Lower and upper limits of the centroid of the $k^{th}$ external surface are set to the size of design domain, i.e., the centroid of $k^{th}$ external surface can lie anywhere within the design domain. $v_{s_k}^R$ indicates the radius of the bounding circle that encloses the $k^{th}$ external surface. $v_{s_k}^R$ varies between the lower and upper bounds [$v_L^R, v_U^R$] as specified by the user. $v_{s_k}^{f1}$ and $v_{s_k}^{f2}$ are continuous factors, varying between 0 and 1, that help determine the size of $k^{th}$ external surface when combined with the radius of the enclosing circle, $v_{s_k}^R$.
\noindent For circular external surfaces, radius of the $k^{th}$ external surface is
\begin{align}
R_{s_k} = \frac{v^{f1}_{s_k} v^R_{s_k} + v^{f2}_{s_k} v^R_{s_k}}{2}
\end{align}
\noindent For elliptical external surfaces, semi-major axis of the $k^{th}$ external surface is $a_{s_k}=v^{f1}_{s_k} v^R_{s_k}$ and the semi-minor axis is $b_{s_k}=v^{f2}_{s_k} v^R_{s_k}$. For rectangular external surfaces, length of the $k^{th}$ external surface is $l_{s_k}=2 v^{f1}_{s_k} v^R_{s_k}$ and width is $b_{s_k}=2v^{f2}_{s_k} v^R_{s_k}$. However, if corners of a rectangular surface are not completely within the bounding circle, variables $v_{s_k}^{f1}, v_{s_k}^{f2}$ are scaled down further by multiplying with a parameter $ v^f_{s_k}$, where
\begin{align}
v^f_{s_k} = \frac{v^R_{s_k}}{\sqrt{(v^{f1}_{s_k} v^R_{s_k})^2 + (v^{f2}_{s_k} v^R_{s_k})^2}}
\end{align}
so that corners of the external rectangular surface always lie within the bounding circle as shown in Fig. \ref{fig:Resize_ext_body}. This, though not necessary, is done to maintain consistency in having all external surfaces lie within their bounding circles. For elliptical and circular external contact surfaces, resizing is not applicable since they always lie within the respective bounding circles. Finally, orientation of the external surface is defined by $v_{s_k}^{\theta}$ (for a circular surface, this variable is redundant), that takes the lower and upper bounds of $0$ and $\pi$ respectively.
\begin{figure}[h!]
\centering
\includegraphics[scale=1]{Resize_ext_body.eps}
\caption{Resizing of external rectangular contact surface (dashed \textit{red}) whose corners A, B, C and D are initially outside the bounding circle (\textit{black}) of radius $v^R_{s_k}$. \textit{Blue} dotted lines represent the resized surface.}
\label{fig:Resize_ext_body}
\end{figure}
\subsection{Stage II candidate solution}
\begin{figure}[h!]
\begin{subfigure}{0.48 \textwidth}
\centering
\includegraphics[scale=1]{Candidate_solution.eps}
\caption{}
\label{fig:Candidate_solution}
\end{subfigure} \hfill
\begin{subfigure}{0.48 \textwidth}
\centering
\includegraphics[scale=1]{Candidate_solution2.eps}
\caption{}
\label{fig:Candidate_solution_2}
\end{subfigure}
\caption{(\subref{fig:Candidate_solution}) A candidate solution, with external surfaces, fixed at specified corners. Each external surface with $v_{s_k}^c =1 $ is shown in \textit{blue}. External surface $S_8 $ with $v_{s_k}^c =0 $ is shown with \textit{red} dotted line to exemplify its absence. \textit{Black} dashed lines represent the bounding circles of external surfaces. $ I $ and $ O $ represent the input and output ports respectively. External surfaces $ S_3, S_6 $ and $ S_7, S_9 $ overlap to form complex shaped external surfaces exhibiting more variety in surface curvatures. Surface $ S_2 $ intersects with member $m_8$ resulting in non-consideration of the latter in the analysis. Members $ m_6 \text{ and } m_7$ intersect with each other and are both not considered in further processing. $ p_3 $ represents the common junction of members $ m_2, m_3 $ and $ m_4 $. $p_i$, $i = 1, 2, ..., 7$ are similar junctions. (\subref{fig:Candidate_solution_2}) Candidate solution after ignoring members $ m_j , j= 6, 7, 8, 9 \text{ and } 10$. External surfaces are shown without bounding circles. This solution is ready to be \textit{fleshed-out} for further processing and analysis. }
\label{fig:Candidate_solutions}
\end{figure}
Given all discrete and continuous variables for both, design members and external surfaces, a candidate solution can be generated. An example candidate solution, as depicted in Fig. \ref{fig:Candidate_solution}, comprises of all members and external surfaces with topology choice variable $v_{m_j}^c =1$ and $v_{s_k}^c = 1 $ respectively. The absent external surface ($ S_8 $ for which $v_{s_k}^c = 0 $) is shown with \textit{red} dotted line only for representation purpose. Bounding circles of all external surfaces are shown as \textit{black} dashed lines. One observes that the external surface $ S_2 $ intersects with member $ m_8 $. One has a choice of either deleting the member and retaining the surface, or vice versa. The third option is to delete both. We choose to retain more external contact surfaces, for better design choices, and thus, members intersecting with external surfaces are filtered out by assigning the corresponding topology choice variable of members $v_{m_j}^c$ to 0. One notes that deletion of member $ m_8 $ makes members $ m_9 $ and $ m_{10} $ as well as a fixed boundary form a sub-continuum separate from main continuum containing the output port. For simplicity, all sub-continua not connected to the main design are deleted. An option of retaining such sub-continua which are fixed and can interact with the primal design will be explored in future. As members $ m_6 $ and $ m_7 $ intersect, they are also removed by assigning the corresponding topology variables to zero. Candidate design after deleting intersecting members ($ m_6 $ and $ m_7 $), those intersecting with external surfaces ($ m_8 $) and those not connected to the main continuum ($ m_9 \, \mathrm{and} \,m_{10} $) is shown in Fig. \ref{fig:Candidate_solution_2}. It is observed next that the external surface $ S_4 $ is very close to member $ m_{11} $, but does not intersect with it when we consider the continuum skeleton. All such external surfaces that are very close to members are deleted, if found intersecting with a member, after converting the wire mesh to a corresponding quadrilateral mesh as explained in Sec. \ref{sec:Design_Preprocessing}. Stage II candidate design is checked for absence of the input port, output port and fixed vertices. If the input and/or output port is absent and if no fixed vertex is present, the design is penalized. Else, it is preprocessed and prepared for analysis.
\subsection{Design preprocessing}
\label{sec:Design_Preprocessing}
\subsubsection{Mesh conversion from skeleton to 2D elements}
With wire/skeletal meshes representing an assemblage of beams, contact between only the neutral axes of members can be analysed. For a realistic finite element model, it becomes essential to discretize members with quadrilateral elements to capture the contact behavior accurately. A new and improved \textit{mesh independent} methodology compared to the one in \cite{Reddy2012systematic} is proposed below.
\begin{figure}[h!]
\captionsetup[subfigure]{position=b}
\centering
\subcaptionbox
{Discretization of member-$ m_1 $ with quadrilateral elements\label{fig:mesh_1Dto2D}} {\includegraphics[scale=1]{1D_2D_mesh.eps}}
\hfill
\subcaptionbox
{Members at the junction without proper connectivity when discretized with quadrilateral elements\label{fig:mesh_disturbed_junction}}
{\includegraphics[scale=1]{Junction_stage_0.eps}}
\caption{(\subref{fig:mesh_1Dto2D}) Discretization of design members with 4 node quadrilateral elements with node and element numbering. One row of quadrilateral elements along the width of a member (e.g., element numbers 1, 21, 41, 61) are considered as one \textit{w-set}. A similar row of the quadrilateral elements along the length of the member (e.g., element numbers $ 1, 2,..., 20 $) is referred to as \textit{l-set}. A sample element, with side numbers of the element encircled, is also shown. (\subref{fig:mesh_disturbed_junction}) Design members $ m_2, m_3 $, and $ m_4 $ overlapping at junction $ ju_2 $ located at $ p_3 $, are shown in \textit{red, green}, and \textit{blue} colors respectively}
\label{fig:mesh}
\end{figure}
All curved frame members are divided into $n_{el}$ segments of equal length along the respective arc-lengths. Based on the in-plane width $v_{m_j}^w$ of each member, width of the quadrilateral element corresponding to the $ m_j^{th} $ member is computed as $\frac{v_{m_j}^w}{n_{ew}}$. $ n_{ew} $ indicates the number of elements along the width of each member. Based on the required mesh density, a user can assign any reasonable value to both $n_{el} \text{ and } n_{ew} $. Herein, each member is discretized into 80 quadrilateral elements by choosing $n_{el}=20$ and $n_{ew}=4$. Discretization of member-$ m_1 $ along with node (\textit{blue}) and element (\textit{red}) numbering of selected area is shown in Fig. \ref{fig:mesh_1Dto2D}. A row of quadrilateral elements along the width of a member is referred as a \textit{w-set}. Similarly, one row of quadrilateral elements along the length of member is considered as \textit{l-set}. Each quadrilateral element has four sides SURF\textsubscript{1}, SURF\textsubscript{2}, SURF\textsubscript{3}, and SURF\textsubscript{4} (numbers encircled on top right in Fig. \ref{fig:mesh_1Dto2D}). Side of any quadrilateral element is represented as $ \mathrm{SURF}^e_d $, where, $ e $ represents the element number and $ d $ represents the side. To specify contact interactions easily between surfaces, all nodes of quadrilateral elements are numbered in sequence such that, for each member, group of SURF\textsubscript{1} edges of all boundary elements along the length represent SURF\textsubscript{1} of the member. Similarly, group of SURF\textsubscript{2} edges of boundary elements represent SURF\textsubscript{2} of the member and so on. Connectivity at the junctions gets disturbed when the wireframe member is discretized with quadrilateral elements as shown in Fig. \ref{fig:mesh_disturbed_junction}. To connect members at junctions, each junction, $ ju $, is modeled as a circle of radius $R_{ju}$, and quadrilateral elements (of members) are connected to the peripheral nodes of the circular junction. Each circular junction contains $ 8\times n_{ew} $ peripheral nodes. Also, the periphery of each circular junction is divided into \textit{eight} segments, and each segment is connected to a unique member (if present) of the candidate design (as detailed in the following section). Radius of any junction, $R_{ju}$ is computed based on the maximum in-plane width of all members sharing the junction. For example, radius of junction $ ju_2 $ located at vertex-$ p_3 $ (Fig. \ref{fig:mesh_disturbed_junction}) that connects members $ m_2, m_3 \text{ and } m_4 $ is given as
\begin{align}
R_{2} = & \frac{0.85 \times \text{max }(v^w_{m_2}, v^w_{m_3},v^w_{m_4})}{\sqrt{2- \sqrt{2}} }
\end{align}
where $ v^w_{m_2}, v^w_{m_3}, v^w_{m_4} $ are the in-plane widths of members $ m_2, m_3 $ and $ m_4 $ respectively. $ R_{ju} $ is the radius of the circle that circumscribes an imaginary regular octagon of side equal to 85\%\footnote{We chose 85\% after several trials so that the junction doesn't look very big. } of the maximum in-plane width of members sharing the junction $ ju $. Since in the entire domain, maximum \textit{eight} members can share a junction, an imaginary octagonal representation is considered at every junction. Circular junction ($ ju_2 $) along with imaginary octagon (shown with dashed line) located at vertex $ p_3 $ is shown in Fig. \ref{fig:OctagonalJunction}.
\begin{figure}[h!]
\centering
\includegraphics[scale=1]{OctagonalJunction.eps}
\caption{Junction $ ju_2 $ located at vertex-$ p_3 $ (ref: Fig. \ref{fig:Candidate_solution}) modeled as circle of radius $R_{ju}$ based on the side of the imaginary octagon (shown with dashed line) that depends on the in-plane widths of members $ m_2, m_3 $ and $ m_4 $. Members $ m_4, m_3 $ and $ m_2 $ are attached to arc segments 1, 3 and 4 respectively.}
\label{fig:OctagonalJunction}
\end{figure}
\begin{figure}[h!]
\captionsetup[subfigure]{position=b}
\centering
\subcaptionbox
{Deletion of elements of \textit{w-set} if the centroid of any element of a set falls inside the circular junction\label{fig:Junction_stage_1}}
{\includegraphics[scale=1]{Junction_stage_1.eps}}
\hfill
\subcaptionbox
{Discretization of circular junction and connection of elements of design members with the peripheral nodes of circular junction\label{fig:Junction_stage_2}}
{\includegraphics[scale=1]{Junction_stage_2.eps}}
\vspace{\fill}
\subcaptionbox
{Repositioning of nodes to reduce distortion of some elements while connecting to junctions\label{fig:Junction_stage_3}}
{\includegraphics[scale=1]{Junction_stage_3.eps}}
\hfill
\subcaptionbox
{Repositioning of nodes of circular junctions for better overall appearance\label{fig:Junction_stage_4}}
{\includegraphics[scale=1]{Junction_stage_4.eps}}
\caption{Steps involved in formulating well connected circular junctions. (\subref{fig:Junction_stage_1}) Junction after deleting the overlapping elements of members. (\subref{fig:Junction_stage_2}) Discretized junction connected to the quad node elements of members. (\subref{fig:Junction_stage_3}) Shifting of node to mid point (\textit{black} point) of the line joining itself (\textit{yellow} triangle) with the midpoint (\textit{green} square) of another line (dashed \textit{purple} line) formed by joining the adjacent nodes of the quadrilateral elements along the length of the respective member. (\subref{fig:Junction_stage_4}) Re-shaping the circular junctions.}
\label{fig:mesh}
\end{figure}
\subsubsection{Connecting members to junctions}
The process of connecting quadrilateral elements to circular junctions involves \textit{four} stages. In stage-1, at each junction, all elements whose centroids lie within a circle of radius $R_{ju}$ are deleted as shown in Fig. \ref{fig:Junction_stage_1}. It is important to delete the entire set of elements (\textit{w-set}) even if the centroid of one element belonging to the set falls inside the circular junction. Discretization of circular junction and repositioning of nodes of quadrilateral elements of the design members to ensure connectivity with the respective segment of the circular junction is depicted in Fig. \ref{fig:Junction_stage_2}. One observes that number of elements of all junctions remains same and depends on the number of quadrilateral elements along the width of any design member ($n_{ew} $). To discretize junctions, every circular junction is mapped to a square with side discretized with $ 2n_{ew} $ elements. Thus, the number of quadrilateral elements of each junction becomes $ 4\times n_{ew}^2 $. Connecting nodes of quadrilateral elements to the respective peripheral node of the circular junction leads to distortion of the elements (Fig. \ref{fig:Junction_stage_2}). To reduce this undesirable effect, nodes (\textit{yellow} triangles) of quadrilateral elements of the design members that are adjacent to the peripheral nodes (black circles) are re-positioned as shown in Fig. \ref{fig:Junction_stage_3}. A line ($ l $) connecting a peripheral node with the last node (\textit{purple} diamond) of its adjacent element along the length of the member is drawn (\textit{purple} dashed line in Fig. \ref{fig:Junction_stage_3}). Midpoint (black dot) of the line joining the node (\textit{yellow} triangle) adjacent to peripheral node with the midpoint (\textit{green} square) of the newly drawn line ($ l $) is considered as the new nodal position. The methodology proposed here yields satisfactory results though there may be other (and better) methods of avoiding distortion of the quadrilateral elements. Finally, to avoid unintended \textit{bulges} at junctions, nodes of circular junctions not connected to any quadrilateral element of the design members are shifted. An imaginary polygon (represented as \textit{black} dotted line) connecting end nodes of the quadrilateral elements (of design members) that are attached to the peripheral nodes of the circular junction is created as shown in Fig. \ref{fig:Junction_stage_4}. All nodes of the quadrilateral elements whose centroids fall outside this newly created polygon, are moved towards the nearest edge of the polygon based on a compression parameter, considered as 0.75 herein. In Fig. \ref{fig:Junction_stage_4}, \textit{yellow} diamonds and \textit{purple} squares represent nodes of the elements of the junction before and after shifting towards the nearest edge of the polygon. The above procedure is repeated for all junctions to achieve the final mesh by properly connecting members of the candidate design. To avoid repetition of the above procedure of mesh generation, any external surface that intersects with or encloses a quadrilateral element of any member is flagged and deleted by assigning $v_{s_k}^c$ to 0. In addition, all external surfaces intersecting with the quadrilateral element of any junction are also deleted from the design. Final mesh along with valid members and external surfaces for the candidate design in Fig. \ref{fig:Candidate_solution} is shown in Fig. \ref{fig:Final_Mesh}. External surfaces are also discretized (discretization not shown) using quadrilateral elements.
\begin{figure}[h!]
\begin{subfigure}{0.49\textwidth}
\centering
\includegraphics[scale=1]{Final_Mesh_1.eps}
\caption{ }
\label{fig:Final_Mesh1}
\end{subfigure}\hfill
\begin{subfigure}{0.49\textwidth}
\centering
\includegraphics[scale=1]{Final_Mesh_2.eps}
\caption{ }
\label{fig:Final_Mesh2}
\end{subfigure}
\caption{(\subref{fig:Final_Mesh1}) Mesh shows discretization of frame members with four node quadrilateral elements and reshaped junctions. External surface ($ S_4 $) intersects with the quadrilateral elements of members, and is ignored in this design. (\subref{fig:Final_Mesh2}) Final mesh with valid external surfaces.}
\label{fig:Final_Mesh}
\end{figure}
\subsubsection{Identifying contact surfaces}
It is essential to identify potential contact surfaces, in an efficient way, for large deformation contact analysis. We model each contact surface as a closed loop. A continuum can be approximated by an annular area enclosed within many loops. For example, the mesh in Fig. \ref{fig:Final_Mesh2} is represented as a set of loops (Fig. \ref{fig:Loops_3}) by extracting information from all surface nodes using the proposed algorithm explained below.
\begin{figure}[h!]
\centering
\includegraphics[scale=1.2]{Loops.eps}
\caption{ Depiction of the CCM continuum as loops. $I_1, I_2 \text{ and } I_3$ represent inner loops. $O_1$ represents the outer loop. $S_1, S_2, S_{3}, S_{5}, S_6, S_{7} \text{ and } S_{9}$ represent the external contact surfaces present in the candidate design. Contact interactions between $O_1 \text{ and } S_2, O_1 \text{ and } S_5, O_1 \text{ and } S_{7\cup 9}, O_1 \text{ and } S_{3\cup6}, I_2 \text{ and } S_1$ are specified along with self contact interactions ($O_1$ with $O_1$, $I_1$ with $I_1$, $I_2$ with $I_2$ and $I_3$ with $I_3$) of loops.}
\label{fig:Loops_3}
\end{figure}
\subsubsection{Identifying closed loops}\label{Identifying_Loops}
\begin{figure}[h!]
\centering
\includegraphics[scale=1]{Loops_0.eps}
\caption{ Process of identifying members that belong to a path.}
\label{fig:Loops_0}
\end{figure}
\begin{figure}[h!]
\centering
\includegraphics[scale=1]{Loops_1.eps}
\caption{ Process of identifying surface elements of loops. \textit{Red} continuous line represents portion of the loop traversed while \textit{red} dotted line represents the remaining portion to be traced}
\label{fig:Loops_1}
\end{figure}
\begin{figure}[h!]
\centering
\includegraphics[width=0.9\textwidth]{Loops_FlowChart.eps}
\caption{ Flow chart representing steps involved in the process of identifying paths.}
\label{fig:Loops_FlowChart}
\end{figure}
Closed loops are identified in two stages. In the first, paths are identified by traversing along the neutral axes of members starting from each junction. Each path represents group of members that belong to a loop. In the second, surface elements of members belonging to the identified paths are captured to form loops.
\noindent \textbf{Stage-1}: To identify paths, we propose the following methodology (Fig. \ref{fig:Loops_FlowChart}). One dimensional wire-frame candidate solution (Fig. \ref{fig:Candidate_solution_2}) without external contact surfaces is chosen as an example to describe how members are identified to form paths. Steps involved are as follows.
\begin{enumerate}[label=Step-{\arabic*}]
\item
We chose a junction and commence traversing along the member that makes minimum angle in anti-clockwise direction, among all members sharing that junction, with respect to a horizontal line (in positive $ x- $direction). Once, we reach the other vertex of the traversed member, we append the path with the index of that member, to signify that the member is a part of the corresponding path. For example, consider a portion of 1D candidate solution (Fig. \ref{fig:Candidate_solution_2}) with members $m_1, m_2 \dots, m_4 $ as shown in Fig. \ref{fig:Loops_0}. The search algorithm commences from junction $ ju_1 $ ($ p_2 $) of the wire-frame mesh. From $ ju_1 $, we move along the member $m_1$, since, $ \gamma_{ju_1}^{m_1} < \gamma_{ju_1}^{m_2} $, where, $ \gamma_{ju_1}^{m_j}$ is the end-slope of member-$ m_j$ with respect to $ l_{ju_1} $ (horizontal line passing through junction ${ju_1} $). $ m_j, j = 1 \text{ and } 2,$ represent the members sharing ${ju_1} $. After reaching vertex $p_1$ of member $m_1$, we append the path with the index of member $m_1$ i.e., 1.
\item Once at the other end, we check whether it belongs to set of all junctions ($ \Psi $).
\begin{enumerate}
\item If yes, we consider the succeeding member at that vertex (junction), the end-slope of which makes the least angle with respect to that of a traversed member when measured in anti-clockwise direction. Once the succeeding member is identified, we move along it and append the path with its index.
\item If the other end is a free end, we move back along the traversed member itself to reach the junction and append its index to path.
\end{enumerate}
\end{enumerate}
Stopping criteria: We repeat Step-2 till we reach the initial junction we started with and the succeeding member is first member of the identified path. Once we satisfy this, we have complete information about one complete path or loop. We repeat above steps by considering other members sharing the junction.
In Fig. \ref{fig:Loops_0}, As vertex $p_1$ is not a junction, we traverse along member $m_1$ back to junction ${ju_1} $ and append path with index 1 as per step-2(b). Thus the traversed path becomes $ 1\to 1 $. Further, as per step-2(a), we traverse along member $m_2$ since it succeeds $m_1$ at ${ju_1} $ and reach junction ${ju_2} $ (vertex $p_3$) after appending the path with index 2 (path: $ 1\to 1 \to 2 $). The traverse process is continued from ${ju_2}$, and it is identified that member $ m_4 $ succeeds $m_2$. We traverse along $ m_4 $ and append path with index 4 (path: $ 1\to 1 \to 2 \to 4$). We continue until we satisfy the stopping criteria and the path becomes $ 1\to 1 \to 2 \to 4 \cdots 3\to 2 \to 1$. Further, we repeat the above process considering member $ m_2 $ as the starting member to get path $ 2 \to 4 \to 4 \to 3 \cdots 3\to 2 \to 1 \to 1 \to 2$.
We follow the above process starting from all junctions of the candidate CCM continuum and identify the remaining paths. If we choose junction $ ju_2 $ and repeat the above procedure of identifying paths, we get a path $ 4 \to 4 \to 3 \cdots 3 \to 2 \to 1 \to 1 \to 2 \to 4$. With the proposed algorithm, some paths do get repeated. For example, in Fig. \ref{fig:Loops_3}, path corresponding to the inner loop $ I_1$ is traced every time we start from any junction located at vertices $ p_4, p_6 \text{ and } p_7 $. Repeated paths are flagged off and unique paths used to identify closed loops containing surface elements of the members. We proceed to stage-2 to form closed loops after identifying unique paths.
\noindent \textbf{Stage-2}: Once members belonging to a path are identified, relevant sides of surface quadrilateral elements of members that form a loop are grouped. For example, in Fig. \ref{fig:Loops_1}, side-1s (side number encircled) of all bottom surface elements of member-$ m_4 $ form group-1 (group number enclosed in square; highlighted with \textit{red} dashed line), all side-2s of right side surface elements form group-2 (highlighted with black dotted line) and all side-3s of top surface elements form group-3 (highlighted with \textit{blue} dashed-dotted line). All three groups (1, 2 and 3) collectively become a part of loop $ O_1 $. This procedure is repeated for all members that belong to the path to get the closed loop $ O_1 $. Similarly, additional loops are formed by considering the groups of surface quadrilateral elements of members belonging to each unique path. While considering surface elements of members, those belonging to junctions are also added to get a closed loop. For example, at $ ju_1 $, bottom surface elements of the junction are added to the loop before considering the bottom surface elements of member $ m_2$ (refer inset in top-left of Fig. \ref{fig:Loops_1}).
After identifying all loops, outer and inner loops are separated to specify contact interactions between loops and external surfaces. In Fig. \ref{fig:Loops_3}, $I_1, I_2,\text{ and } I_3 $ represent the inner loops and $O_1 $ represents the outer loop. All external contact surfaces are also modeled as closed loops by grouping appropriate sides of surface quadrilateral elements. Contact interaction between any external body and the continuum is specified based on position of the contact surface. If any internal loop encloses an external contact surface, contact interaction is specified amongst them. Contact interaction between an external contact surface and the outer loop is specified if the external contact surface lies outside the outer loop. Referring to Fig. \ref{fig:Loops_3}, it is necessary to specify contact interactions between the external surface $ S_1 $ and inner loop $I_2 $. Similarly, contact interactions between external surface $ S_5 $ and outer loop $O_1 $; external surface $ S_2 $ and outer loop $ O_1$ are also specified. External contact surfaces ($ S_3 \text{ and } S_6 , S_7 \text{ and } S_9 $) overlap to form more complex shapes, thus, promising to offer more intricate deformation characteristics of the continuum, as intended. Interactions of respective loops with such complex external surfaces are also specified. For the candidate design shown in Fig. \ref{fig:Candidate_solution_2} we specify contact interactions between loops $O_1 \text{ and } S_2, O_1 \text{ and } S_5, O_1 \text{ and } S_{7\cup 9}, O_1 \text{ and } S_{3\cup6}, I_2 \text{ and } S_1$ are specified along with self contact interactions ($O_1$ with $O_1$, $I_1$ with $I_1$, $I_2$ with $I_2$ and $I_3$ with $I_3$) of loops.
\section{Large displacement contact analysis} \label{Large_Deformation_contact}
\begin{figure}[h!]
\centering
\begin{subfigure}[t]{0.24 \textwidth}
\centering
\includegraphics[scale=1]{contact_bodies.eps}
\caption{Bodies in deformed configuration}
\label{fig:contact_bodies}
\end{subfigure}\hfill
\begin{subfigure}[t]{0.24 \textwidth}
\centering
\includegraphics[scale=1]{contact_traction.eps}
\caption{Contact tractions}
\label{fig:contact_traction}
\end{subfigure}\hfill
\begin{subfigure}[t]{0.48 \textwidth}
\centering
\includegraphics[scale=1]{contact_discretization.eps}
\caption{Discretization of contact surfaces as piece-wise linear segments}
\label{fig:contact_discretization}
\end{subfigure}
\caption{Contact modeling}
\end{figure}
\noindent Even though large displacement contact analysis is accomplished using a commercial software, for sake of completeness, the same is briefed below. Consider two bodies $\mathcal{B}^{(\alpha)}$, $ \alpha = 1, 2$ in contact in deformed configuration (Fig. \ref{fig:contact_bodies}). Boundary $ \Omega^{(\alpha)} $ comprises of three segments: $ \Omega^{(\alpha)}_t$ over which surface tractions $ \mathbf{t}^{(\alpha)} $ act; $ \Omega^{(\alpha)}_u $ with specified displacements $\mathbf{u}^{(\alpha)}$, and $ \Omega^{(\alpha)}_c $ with contact tractions $\mathbf{t}^{(\alpha)}_c$ (Fig. \ref{fig:contact_traction}). Weak form\footnote{For rigid bodies, $ \nabla\mathbf{u} $ and $ \delta\mathbf{u} $ are both $ \mathbf{0} $, thus, the corresponding contribution to the equilibrium equation becomes zero.} to compute displacement fields $ \mathbf{u}^{(\alpha)} \in \mathcal{R}^{(\alpha)} $ is
\begin{align}\label{eq:weak_form}
\begin{split}
\sum_{\alpha=1}^{2}
\underbrace{\int_{\mathcal{B}^{(\alpha)}} \bm{\sigma}^{(\alpha)}:\nabla\left(\delta\mathbf{u}^{(\alpha)}\right)\mathrm{d}v^{(\alpha)}}_{\text{internal virtual work}}
- & \sum_{\alpha=1}^{2} \underbrace{\int_{\Omega^{(\alpha)}_c} \delta\mathbf{u}^{(\alpha)} \cdot \mathbf{t}^{(\alpha)}_c \mathrm{d}a^{(\alpha)}}_{\text{contact virtual work}}\\
- & \sum_{\alpha=1}^{2} \underbrace{\left\{\int_{\Omega^{(\alpha)}_t} \delta\mathbf{u}^{(\alpha)} \cdot \mathbf{t}^{(\alpha)} \mathrm{d}a^{(\alpha)} + \int_{\mathcal{B}^{(\alpha)}} \delta\mathbf{u}^{(\alpha)} \cdot \rho^{(\alpha)}\mathbf{b}^{(\alpha)} \mathrm{d}v^{(\alpha)}\right\}}_{\text{external virtual work}} = 0 \\
& \qquad \forall \, \delta\mathbf{u}^{(\alpha)} \in \mathcal{S}^{(\alpha)}
\end{split}
\end{align}
where $\bm{\sigma}^{(\alpha)}$ is Cauchy stress tensor, $ \nabla\mathbf{u}^{(\alpha)}$ is the gradient of $\mathbf{u}^{(\alpha)}$ with respect to spacial/deformed coordinates, $ \mathbf{b}^{(\alpha)} $ represent body forces per unit volume, $\mathcal{R}^{(\alpha)} $ and $\mathcal{S}^{(\alpha)} $ are permissible sets of deformations and variations respectively, and $ \mathrm{d}a^{(\alpha)} $ and $ \mathrm{d}v^{(\alpha)} $ are elemental areas and volumes in deformed configuration. Elemental displacement field ($ \bm{u}_e$) and its variation ($ \delta\bm{u}_e$) are approximated using finite element shape functions as
\begin{align}
\begin{split}
\bm{u}_e \approx &\sum_{j=1}^{T_n=4}N_j\bm{u}_j = \mathbf{N}\{\mathbf{u}_e\}\\
\delta\bm{u}_e \approx &\sum_{j=1}^{T_n=4}N_j\bm{v}_j = \mathbf{N}\{\mathbf{v}_e\}\\
\end{split}
\end{align}
$ N_j $ represent shape functions for quadrilateral elements with $\mathbf{N} = [N_1\mathbf{I}, N_2\mathbf{I},..., N_{T_n}\mathbf{I}]$, where $ \mathbf{I} $ represents the $ 2 \times 2 $ unit matrix, nodal displacements and variations are represented as $ \bm{u}_j $ and $ \bm{v}_j $ respectively and $\{\mathbf{u}_e\} = [\bm{u}_1^\mathrm{T}, \bm{u}_2^\mathrm{T},...,\bm{u}_{T_n}^\mathrm{T}]^\mathrm{T}$. With these approximations, the following weak form (from Eq. \ref{eq:weak_form}) may be obtained.
\begin{align}\label{eq:Discretized}
\bm{v}^\mathrm{T}[\mathbf{f}_{int}+ \mathbf{f}_c-\mathbf{f}_{ext}] = 0 \quad \forall \, \bm{v}\in\mathcal{S}^{(\alpha)}
\end{align}
where $ \mathbf{f}_{int}, \mathbf{f}_c \mbox{ and } \mathbf{f}_{ext}$ represent internal, contact and input forces respectively. $ \bm{v} $ comprises variation in nodal displacements $ \bm{u}_j $. Internal elemental forces are $ \mathbf{f}_{int} = \int_{\mathcal{B}^{\alpha}_e} \mathbf{B}^T\bm{\sigma} \mathrm{d}v^{(\alpha)}$, where $ \mathbf{B} $ is strain-displacement matrix. Nonlinear equations $g(\mathbf{u}) \equiv \mathbf{f}_{int}+ \mathbf{f}_c-\mathbf{f}_{ext} = \mathbf{0}$ in terms of the force residual $g(\mathbf{u}) $ derived from Eq. \eqref{eq:Discretized} may be solved either using the Newton Raphson or the Arc Length method \cite{riks1979incremental}. An augmented Lagrangian formulation \cite{Wriggers_2006} is used to compute contact forces ($ \mathbf{f}_c $). Each contact surface is discretized with piece-wise linear segments.
Following is the process to compute contact forces for one body (say, $ \mathcal{B}^{(1)}$) with respect to the other (say, $ \mathcal{B}^{(2)} $)\footnote{To compute contact forces on $ \mathcal{B}^{(2)}$, the process is reversed.}. Contact tractions are given by
\begin{align}
\label{contact_tractions}
\mathbf{t}^{(\alpha)}_c =
\begin{cases}
\lambda\mathbf{n}^p \qquad & g_n<0\\
\textbf{0} &g_n \ge 0
\end{cases}
\end{align}
where $ \lambda=\lambda_{prev}-\epsilon g_n $ is the Lagrange multiplier modified at every stage from its previous value $\lambda_{prev}$ in the augmented Lagrange setting. $ \epsilon $ is a specified penalty parameter. $ g_n $ is the normal gap given as \begin{align}\label{eq:normal_gap}
\begin{split}
g_n = & \mathbf{g}\cdot \mathbf{n}^p\\
= & \left(\mathbf{x}^{(1)}-\mathbf{x}^p\right)\cdot\mathbf{n}^p
\end{split}
\end{align}
where $ \mathbf{x}^{(1)} $ is the position vector of $ p^{(1)} \in \Omega^{(1)}_c $ (Fig. \ref{fig:contact_discretization}). $ p^p $ is closest projection of $ p^{(1)} $ onto $\Omega^{(2)}_c $, $ \mathbf{x}^p $ is its position vector and $ \mathbf{n}^p $ is normal at $ p^p $. To identify $ \mathbf{x}^p $, boundary $\Omega^{(2)}_c $ is parameterized using convective coordinates $ \bm{\xi}={\xi^{1},\xi^{2}} $ \cite{wriggers1992coupled}. As we work with 2D elements, contact surface $\Omega^{(2)}_c $ is approximated as a set of piece-wise linear segments with only $ \xi^p $ as convective coordinate. The tangent ($ \mathbf{a}^p $) at $ p^p $ is computed as $ \mathbf{a}^p = \frac{ \mathbf{x}^{(2)}_b - \mathbf{x}^{(2)}_a}{l^{(2)}_e}$, where, $\mathbf{x}^{(2)}_b, \mathbf{x}^{(2)}_a $ are coordinates of endpoints of segment $ e $ on $ \Omega^{(2)}_c $, and $ l^{(2)}_e $ is the length of segment. $ p^p $ and $ \xi^p $ are computed by minimizing the distance $ d =||\mathbf{x}^{(1)} - \mathbf{x}^p(\xi^p) || $ as given below.
\begin{align}\label{key}
\frac{\partial d}{\partial \xi^p} = \left(\mathbf{x}^{(1)}-\mathbf{x}^p(\xi^p)\right). \mathbf{a}^p =0
\end{align}
The closest projection point $ \mathbf{x}^p $ on $ \Omega^{(2)}_c $ becomes $ \mathbf{x}^{(2)} $ and the normal gap $ g_n $ is computed using Eq. \eqref{eq:normal_gap}. The $ e^{th} $ segment of the contact surface $ {\Omega^{(2)}_c} $ is approximated using linear shape functions; $ N^{(2)}_a = 0.5(1-\xi^p), N^{(2)}_b = 0.5(1+\xi^p)$. Thus, $ \mathbf{x}^{(2)} = N^{(2)}_a(\xi^p) \mathbf{x}^{(2)}_a + N^{(2)}_b(\xi^p) \mathbf{x}^{(2)}_b $. Elemental contact forces are computed from virtual contact work using contact traction in Eq. \ref{contact_tractions}, and contact stiffness matrix is obtained by differentiating the elemental contact forces with respect to element displacements.
An active set strategy is used to identify and track contact pairs. At each load step, closest projection point is identified and then the normal gap $ g_n $ is computed. For self contact, $ \mathcal{B}^{(1)} $ is the same as $ \mathcal{B}^{(2)} $. Contact forces and stiffness matrices are evaluated if a contact pair is found active, otherwise, they are set to zero if contact is absent or is lost.
Implementation of contact analysis delineated above is quite tedious and involved, in particular when designs and contact modes considered are very generic. Many packages, commercial or otherwise, exist that makes themselves amenable and accessible for large deformation analysis with contact modeling. We chose \texttt{ABAQUS\textsuperscript{TM}} to analyze candidate solutions. Procedures highlighted in Sec. \ref{sec:synthesis} for preparation of a candidate design for analysis are all implemented in \texttt{MATLAB\textsuperscript{TM}}. Input data for use in \texttt{ABAQUS\textsuperscript{TM}} pertaining to a candidate CCM design is generated as follows.
\subsection{ABAQUS\textsuperscript{TM} input file generation} \label{sec:inp_file_gen}
\begin{figure}[h!]
\centering
\includegraphics[width=\textwidth]{Input_file.eps}
\caption{ Structure of the \texttt{ABAQUS\textsuperscript{TM}} input file. Only select lines are shown for compactness.}
\label{fig:Input_file}
\end{figure}
Mesh information, details of contact surfaces, input force data etc. are prepared using \texttt{MATLAB\textsuperscript{TM}} and supplied to \texttt{ABAQUS\textsuperscript{TM}} solver. \texttt{ABAQUS\textsuperscript{TM}} input file is divided into two main sections. The first part comprises information about the mesh called \textit{model data}. The second part consists of loading conditions and the output data requirements (such as nodal displacements etc) called \textit{history data}. Data of both parts is grouped into \textit{option blocks}. Each option block starts with a \textit{keyword line} and contains several \textit{data lines\footnote{None of these lines can exceed 256 characters.}}. A typical structure of the input file is shown in Fig. \ref{fig:Input_file}. Complete mesh information, i.e., nodal coordinates and element connectivity along with element type, is specified as per the structure of the input file. Further, contact surfaces, i.e., element numbers and corresponding side of the elements are defined, and external and self contact interactions are specified as explained in the previous section. Boundary conditions and input force details along with required output parameters and step information are specified in the history data part as shown in the structure of input file. After preparing the input file as per the standard format, data is analysed by \texttt{ABAQUS\textsuperscript{TM}} standard solver and the output, i.e., the $ x $ and $ y $ displacements of the output port, as sought in output option block of history data part, is written to a \texttt{.dat} file. Displacement of the output port after each time step is extracted from the \texttt{ABAQUS\textsuperscript{TM}} output(\texttt{.dat}) file. Deformed coordinates of the output port for each time step are compared with the required path, specified by the user, and objective function is evaluated using Fourier Shape Descriptors as explained in the next section.
\section{Objective and search}
\label{sec:objective}
Contact analysis coupled with geometrically nonlinear analysis is performed in \texttt{ABAQUS\textsuperscript{TM}} to obtain the deformation characteristics of a candidate solution. As we require path generating CCMs to offer repeatability in functionality, we assume that their deformation is in the elastic range. Thus, material nonlinearity is not considered. Fourier Shape Descriptors (FSDs), that help compare shapes of two curves, are given by Zahn and Roskies \cite{zahn1972fourier} for curves defined by a set of points forming a closed polygon. Ullah and Kota \cite{ullah1997optimal}, Mankame and Ananthasuresh \cite{mankame2007synthesis}, Rai et al.\cite{rai2007synthesis}, Reddy et al. \cite{Reddy2012systematic} and Kumar et al.\cite{kumar2019computational} successfully demonstrate the use of FSDs in synthesis of path generating mechanisms. FSDs are obtained by modeling the user specified path and actual output path as closed non-self intersecting curves by chosing an appropriate start point.
Consider $ \alpha_f^d \text{ and } \beta_f^d$ as Fourier coefficients, $l^d \text{ and } \theta^d $ as the length and orientation of the desired path respectively. Similarly, let $ \alpha_f^a \text{ and } \beta_f^a$ represent the Fourier coefficients corresponding to the actual path traced by the candidate solution. Let $l^a \text{ and } \theta^a $ denote the length and orientation of the actual path. The total error objective, $ \mathcal{T}_e $, with necessary weights of individual errors ($ \alpha_e, \beta_e, l_e, \theta_e $), between actual and desired path is minimized subjected to design variables of both, continuum and the external bodies. Weights corresponding to the errors in shape ($ \varepsilon_\alpha, \varepsilon_\beta $) are kept sufficiently high (100, 100), while, those for errors in length and orientation ($ \varepsilon_l, \varepsilon_\theta $) are chosen low (0.1 and 0) for the examples presented. Reason for choosing zero weight for error in orientation is that a CCM can always be rotated to match initial angles of both the actual and desired paths. The number of Fourier coefficients (N) used for all examples is 100. The objective function $ \mathcal{T}_e $ that is minimized is
\begin{align*}
\displaystyle\text{min }\mathcal{T}_e = \varepsilon_\alpha\alpha_e + \varepsilon_\beta\beta_e &+ \varepsilon_l l_e +\varepsilon_\theta \theta_e
\end{align*}
\text{where}
$\displaystyle
\alpha_e = \sum_{p=1}^N (\alpha_f^d-\alpha_f^a)^2,
\beta_e = \sum_{p=1}^N (\beta_f^d-\beta_f^a)^2,
l_e = (l^d-l^a)^2,
\theta_e = (\theta^d-\theta^a)^2$
\noindent over \textbf{v} =
$\begin{Bmatrix}
v_{m_j}^c,v_{s_k}^c ~| \text{ both are discrete variables and take values of either 0 or 1} \\
v_{s_k}^{sh} ~| \text{ discrete variable and takes values of either 1 or 2 or 3} \\
v_{m_j}^{T_1}, v_{m_j}^{T_2}, v_{m_j}^w, v^{th}, v_{p_i}^x, v_{p_i}^y, v_{s_k}^x, v_{s_k}^y, v_{s_k}^R, v_{s_k}^{f1}, v_{s_k}^{f2}, v_{s_k}^{\theta}, v_p^F ~| \text{ all continuous}
\end{Bmatrix}$
\noindent subject to:\vspace{-5mm}
\begin{enumerate}
\item$ \textbf{v}_L \le \textbf{v} \le \textbf{v}_U $ (all continuous variables of \textbf{v} are within the user specified limits).
\item Equilibrium in large displacement contact analysis.
\end{enumerate}
A volume constraint is not employed. A random mutation based stochastic Hill Climber search is used to systematically evolve the path generating CCMs. Though computationally costlier compared to a gradient based search, stochastic (function-based) search algorithms have the advantage of penalizing non-convergent solutions. All incomplete intermediate candidate solutions, i.e., candidate designs without either input port, outport or boundary condition, are flagged off by assigning large penalty. Also, both, discrete and continuous variables are handled well by stochastic searches. {Besides, in the continuum setting (e.g., \cite{kumar2019computational}) and even herein, it is difficult to solve a contact problem with all elements in the void state but physically present, a requirement by the gradient search method. Such void elements will hinder/not permit accurate contact analysis.
In every iteration, the design vector \textbf{v} is mutated to get new vector $ \textbf{v}^{new} $, according to the mutation probability set by the user, based on a random value generated for each design variable. The total number of variables of the design vector \textbf{v} depends on the intial design domain. For the design domain shown in Fig. \ref{fig:Design_Domain}, the size of design vector \textbf{v} is
\begin{align*}
N_v & = N_{m} \times 4 + 1 + N_{p} \times 2 + N_s \times 8 + 1\\
& = 364
\end{align*}
where $N_{m}, N_{p}, \text{and } N_s$ represent the total number of members, vertices and external surfaces respectively in the initial design domain.
Once the new design vector ($ \textbf{v}^{new} $) is obtained, the mesh is modified as per Sec. \ref{sec:synthesis}, and the objective function is evaluated. If the new function $ \mathcal{T}_e^{new} $ is less than the earlier function value $\mathcal{T}_e $, $ \textbf{v}^{new} $ is considered and mutated for next iteration; otherwise, $ \textbf{v}$ is mutated further. This is continued until a satisfactory path generating Contact-aided compliant mechanism is obtained.
\section{Example: A three-kink CCM switch}
\label{sec:examples}
\begin{figure}[h!]
\centering
\includegraphics[scale=1.2]{LockSchematic.eps}
\caption{Schematic of the 3-kink mechanical lock. $\mathbb{R}$ represents the region that contains the CCM and key, $ I $ and $ O $ represent input port and output ports respectively. P represents switch pad, $O_1, O_2, \cdots, O_4$ represent obstacles.}
\label{LockSchematic}
\end{figure}
\begin{figure}[h!]
\centering\label{fig:Ex_1_1}
\begin{subfigure}[t]{0.33\textwidth}
\centering
\includegraphics[scale=0.65]{Ex_1_1a.eps}
\caption{ }
\label{fig:ex_1_1a}
\end{subfigure}\hfill
\begin{subfigure}[t]{0.33\textwidth}
\centering
\includegraphics[scale=0.65]{Ex_1_1b.eps}
\caption{ }
\label{fig:ex_1b}
\end{subfigure}\hfill
\begin{subfigure}[t]{0.33\textwidth}
\centering
\includegraphics[scale=0.65]{Ex_1_2a.eps}
\caption{ }
\label{fig:ex_1_2a}
\end{subfigure}\\
\begin{minipage}[c]{0.66\linewidth}
\begin{subfigure}[t]{\textwidth}
\centering
\includegraphics[scale=1.24]{Ex_1_2b.eps}
\caption{ }
\label{fig:ex_1_2b}
\end{subfigure}
\end{minipage}
\begin{minipage}[c]{0.33\linewidth}
\begin{subfigure}[t]{\textwidth}
\centering
\includegraphics[scale=0.6]{Ex_1_4a.eps}
\caption{ }
\label{fig:ex_1_4a}
\end{subfigure}\\
\begin{subfigure}[t]{\textwidth}
\centering
\includegraphics[scale=0.6]{Ex_1_4b.eps}
\caption{ }
\label{fig:ex_1_4b}
\end{subfigure}
\end{minipage}
\begin{subfigure}[t]{0.33\textwidth}
\centering
\includegraphics[scale=0.65]{Ex_1_4c.eps}
\caption{ }
\label{fig:ex_1_4c}
\end{subfigure}\hfill
\begin{subfigure}[t]{0.33\textwidth}
\centering
\includegraphics[scale=0.65]{Ex_1_4d.eps}
\caption{ }
\label{fig:ex_1_4d}
\end{subfigure}\hfill
\begin{subfigure}[t]{0.33\textwidth}
\centering
\includegraphics[scale=0.55]{Ex_1_4e.eps}
\caption{ }
\label{fig:ex_1_4e}
\end{subfigure}
\caption{(a) Initial domain for CCM for the 3-kink path. (b) \textit{Black} circles represent the initial placement of candidate external contact surfaces for the mechanical key. (c) Optimized design of the 3-kink CCM evolved in 1758 iterations along with dangling/non-participating members (enclosed within dashed rectangles) and non-participating external surfaces (encircled). (d) Final design after deleting dangling members and non-participating external surfaces. Members of this CCM are discretized with 3352 quadrilateral elements and 4090 nodes. Continuum in \textit{red} represents deformed and \textit{grey} represents initial/undeformed configurations. Intermediate (e-h) and final deformed configurations (i) of optimized design of CCM. Contact locations are enclosed in dotted ellipses. Desired (dashed \textit{green}) and portion of traced (continuous \textit{blue}) path are shown for each configuration.}
\label{ThreekinkSwitch}
\end{figure}
A three-kink electro-mechanical switch is conceived, schematic of which is shown in Fig. \ref{LockSchematic}. The mechanical portion of the switch consists of two parts --- a contact-aided compliant mechanism, and the insulated \textit{key} comprising external surfaces with which the CCM interacts. The CCM and the key are designed simultaneously to lie within the region $\mathbb{R}$, maintained at positive potential. When actuated via an insulated horizontal force at $I$, portion $O$ of the CCM switch is intended to traverse the three-kink path, avoiding obstacles $O_1$, $O_2$ and $O_3$ as shown in the schematic. Prior to its actuation, the mechanical key has to be inserted suitably within $\mathbb{R}$. With a proper mechanical key, the output port of the CCM, after tracing the three-kink path, is expected to make contact with the switch pad for the lock to open. In case the mechanical key is improper, the CCM is expected to deform differently causing the output port to interact with any of the obstacles, and raise an alarm.\\
To seek a CCM and the mechanical key that together generate a 3 kink-path (Fig. \ref{fig:ex_1_3b}), initial domain of size 45 cm $ \times $ 45 cm, with 9 blocks, is considered. Per Fig. \ref{ThreekinkSwitch}a, the design domain comprises 60 members and 25 vertices. Vertices 1, 17, 22 and 25 are fixed, input force is applied at vertex-8 while vertex-4 represents the output port. Magnitude of the input force varies between 0N and 10N. Young's Modulus of continuum is \SI{20}{\newton\per\square\milli\meter} and Poisson's ratio is 0.33. Lower and upper bounds of continuous design variables of members as well as external surfaces are per Tables \ref{Table:Range_v_members} and \ref{Table:Range_v_external}. Optimization parameters used are given in Table \ref{Table:Common_parameters}.
\begin{table}[h]
\centering
\caption{Range of design variables for members}
\label{Table:Range_v_members}
\begin{tabular}{c P{0.4\textwidth} c c c}
\toprule
S. No & Design variable & Lower bound & Upper bound & Units\\
\toprule
1 & End-slopes $ (v_{m_j}^{T_1}, v_{m_j}^{T_2}) $ & $ - $0.5 & 0.5 & radians \\
2 & In-plane width $(v_{m_j}^w)$& 2 & 6 & mm \\
3 & Out of plane thickness $(v^{th})$& 6& 6 & mm \\
4 & $ x $ and $ y $ coordinates of the bounding box $(v_{p_i}^x, v_{p_i}^y)$ & $ - $20 & 20 & mm \\
\bottomrule
\end{tabular}
\end{table}
\begin{table}[h]
\centering
\caption{Range of design variables for external surfaces}
\label{Table:Range_v_external}
\begin{tabular}{c P{0.4\textwidth} c c c}
\toprule
S. No & Design variable & Lower bound & Upper bound & Units\\
\toprule
1 & $ x $ and $ y $ coordinates of center $(v_{s_k}^x, v_{s_k}^y)$ & 0 & 45 & cm \\
2 & Radius of bounding circle $ (v^R_{s_k}) $ & 1 & 5 & cm \\
3 & Size factors $ (v^{f1}_{s_k}, v^{f2}_{s_k}) $ & 0.1 & 1 & ---\\
4 & Orientation of external surface $ (v^\theta_{s_k}) $ & 0 & $ \pi $ & radians \\
\bottomrule
\end{tabular}
\end{table}
\begin{table}[b!]
\centering
\caption{Optimization parameters}
\label{Table:Common_parameters}
\begin{tabular}{clc}
\toprule
S. No & Parameter & Value \\ \toprule
1 & Mutation probability & 0.08 \\
2 & Weight of error ($ \alpha_e, \beta_e$) in shape ($ \varepsilon_\alpha, \varepsilon_\beta $) & 100 \SI{}{\per\square\radian} \\
3 & Weight of error ($ l_e $) in length ($ \varepsilon_l $) & 0.1 \SI{}{\per\square\milli\meter}\\
4 & Weight of error ($ \theta_e$) in angle ($ \varepsilon_\theta $) & 0 \SI{}{\per\square\radian} \\
5 & Number of Fourier coefficients & 100 \\
6 & Number of elements along width of member ($n_{ew}$) & 4\\
7 & Number of elements along length of member ($n_{el}$) & 20\\ \bottomrule
\end{tabular}
\end{table}
Fig. \ref{ThreekinkSwitch}b shows the design region along with 36 external contact surfaces, all candidates for the mechanical key. The lower and upper bounds of all continuous variables are chosen to ensure manufacturability. A candidate design (CCM and key) is generated and mutated further as described in section \ref{sec:objective}. The final CCM tracing the desired path, evolved in 1758 iterations, is shown in Fig. \ref{ThreekinkSwitch}c. The magnitude of input force is \SI{7.35}{\newton}. Dangling members, enclosed within thick dashed black rectangles, and external contact surfaces, enclosed within thin \textit{blue} circles, that do not influence the performance of the switch, are removed. Fig. \ref{ThreekinkSwitch}d shows the final design with the CCM in red and the set of external surfaces comprising the key, in black. Convergence history is depicted in Fig. \ref{fig:ex_1_3a}. Both actual and desired paths are compared in Fig. \ref{fig:ex_1_3b}. Figs. \ref{ThreekinkSwitch}e-i show intermediate deformed configurations of the final design. Contact with external surfaces (key) is observed at six different locations (encircled with dotted ellipse), not all active simultaneously. Sliding contact at $ \mathrm{C}_1$ and rolling contact at $\mathrm{C}_2 $ are simultaneously active (Fig. \ref{ThreekinkSwitch}e) in the initial load steps. However, no sudden change in output is observed. Further increment in load causes contact at $\mathrm{C}_3 $ (Fig. \ref{ThreekinkSwitch}f) which deviates the direction of output port, thus generating the first kink. Second kink is generated by the sliding contact that becomes active at $\mathrm{C}_4 $ as shown in Fig. \ref{ThreekinkSwitch}g. Further, successive occurrence of contacts at $\mathrm{C}_5 $ and $\mathrm{C}_6 $ cause the final kink. However, in the mean time contact at $\mathrm{C}_2 $ becomes inactive.
\begin{figure}[h!]
\centering\label{fig:Ex_1_3}
\begin{subfigure}[t]{0.48\textwidth}
\centering
\includegraphics[scale=1]{Ex_1_3a.eps}
\caption{}
\label{fig:ex_1_3a}
\end{subfigure}\hfill
\begin{subfigure}[t]{0.48\textwidth}
\centering
\includegraphics[scale=1]{Ex_1_3b.eps}
\caption{}
\label{fig:ex_1_3b}
\end{subfigure}
\caption{(\subref{fig:ex_1_3a}) Convergence history (\subref{fig:ex_1_3b}) Comparison of desired (dashed \textit{green}) and actual (continuous \textit{blue}) paths pertaining to the CCM switch. }
\end{figure}
\section{Discussion}
\label{sec:Discussion}
\subsection{Functionality of the 3-kink switch}
\begin{figure}[t!]
\centering
\begin{subfigure}[t]{0.32\textwidth}
\centering
\includegraphics[scale=0.84]{DWrong_Key_1.eps}
\caption{ }
\label{fig:DWrong_Key_1}
\end{subfigure}
\begin{subfigure}[t]{0.32\textwidth}
\centering
\includegraphics[scale=0.84]{DWrong_Key_2.eps}
\caption{ }
\label{fig:DWrong_Key_2}
\end{subfigure}
\begin{subfigure}[t]{0.32\textwidth}
\centering
\includegraphics[scale=0.84]{DWrong_Key_3.eps}
\caption{ }
\label{fig:DWrong_Key_3}
\end{subfigure}\\
\begin{subfigure}[t]{0.32\textwidth}
\centering
\includegraphics[scale=0.84]{DWrong_Key_4.eps}
\caption{ }
\label{fig:DWrong_Key_4}
\end{subfigure}
\begin{subfigure}[t]{0.32\textwidth}
\centering
\includegraphics[scale=0.84]{DWrong_Key_5.eps}
\caption{ }
\label{fig:DWrong_Key_5}
\end{subfigure}
\begin{subfigure}[t]{0.32\textwidth}
\centering
\includegraphics[scale=0.84]{DWrong_Key_6.eps}
\caption{ }
\label{fig:DWrong_Key_6}
\end{subfigure}\\
\begin{subfigure}[t]{0.32\textwidth}
\centering
\includegraphics[scale=0.84]{DWrong_Key_12.eps}
\caption{ }
\label{fig:DWrong_Key_12}
\end{subfigure}
\begin{subfigure}[t]{0.32\textwidth}
\centering
\includegraphics[scale=0.84]{DWrong_Key_23.eps}
\caption{ }
\label{fig:DWrong_Key_23}
\end{subfigure}
\begin{subfigure}[t]{0.32\textwidth}
\centering
\includegraphics[scale=0.84]{DWrong_Key_34.eps}
\caption{ }
\label{fig:DWrong_Key_34}
\end{subfigure}\\
\begin{subfigure}[t]{0.32\textwidth}
\centering
\includegraphics[scale=0.84]{DWrong_Key_45.eps}
\caption{ }
\label{fig:DWrong_Key_45}
\end{subfigure}
\begin{subfigure}[t]{0.32\textwidth}
\centering
\includegraphics[scale=0.84]{DWrong_Key_56.eps}
\caption{ }
\label{fig:DWrong_Key_56}
\end{subfigure}
\begin{subfigure}[t]{0.32\textwidth}
\centering
\includegraphics[scale=0.84]{DWrong_Key_61.eps}
\caption{ }
\label{fig:DWrong_Key_61}
\end{subfigure}\\
\begin{subfigure}[t]{0.32\textwidth}
\centering
\includegraphics[scale=0.84]{DWrong_Key_R3.eps}
\caption{ }
\label{fig:DWrong_Key_R3}
\end{subfigure}
\begin{subfigure}[t]{0.32\textwidth}
\centering
\includegraphics[scale=0.84]{DWrong_Key_R5.eps}
\caption{ }
\label{fig:DWrong_Key_R5}
\end{subfigure}
\begin{subfigure}[t]{0.32\textwidth}
\centering
\includegraphics[scale=0.84]{DWrong_Key_R6.eps}
\caption{ }
\label{fig:DWrong_Key_R6}
\end{subfigure}
\caption{Wrong key combinations. (\subref{fig:DWrong_Key_1}-\subref{fig:DWrong_Key_6}) represent the absence of an external contact surface one at a time. (\subref{fig:DWrong_Key_12}-\subref{fig:DWrong_Key_61}) represent the wrong key combinations where two external contact surfaces are absent. (\subref{fig:DWrong_Key_R3}-\subref{fig:DWrong_Key_R6}) represent the combinations of wrong key when a non-circular external contact surface is rotated by `one' radian in anti-clockwise direction about its center. Deformed positions of continuum are shown in \textit{red} and undeformed configurations are shown in \textit{light gray}. Obstacles are shown as \textit{gray} circles.} \label{fig:WrongKeys}
\end{figure}
The switch is operated in two stages: (i) the key comprising the external surfaces is inserted, and then (ii) desired input force is applied at the input port of the switch via an insulated servo motor. On insertion of the correct key, i.e., positions, sizes, types and orientations of external contact surfaces are as per the design, the applied force causes the CCM to deform and interact with external contact surfaces. The output port traces the 3-kink path, avoiding the obstacles, and makes contact with the switch pad to open the lock. However, if a wrong key is inserted, the output port does not trace the desired path. Use of a wrong key can cause the continuum to deform in a different manner, which may result in the output port making contact with any obstacle and trigger a security alarm system. Though one can formulate numerous key combinations, we chose 15 candidate wrong key combinations as shown in Fig. \ref{fig:WrongKeys} to demonstrate functionality of the switch. These combinations are achieved by removing either one (Figs. \ref{fig:WrongKeys}\subref{fig:DWrong_Key_1}-\subref{fig:DWrong_Key_6}) or two (Figs. \ref{fig:WrongKeys}\subref{fig:DWrong_Key_12}-\subref{fig:DWrong_Key_61}) external contact surfaces and/or rotating (Figs. \ref{fig:WrongKeys}\subref{fig:DWrong_Key_R3}-\subref{fig:DWrong_Key_R6}) some non-circular external surfaces by `one' radian in counter-clockwise direction. In all chosen combinations, one observes that the output port does not reach the switch pad, thus keeping the lock intact. However, in three cases (Figs. \ref{fig:WrongKeys}\subref{fig:DWrong_Key_2}, \subref{fig:DWrong_Key_56} and \subref{fig:DWrong_Key_R5}), neither the output port nor any member of the CCM touches any of the obstacles and does not trigger the safety alarm. Nevertheless, the lock does not get open. In all other cases, deformation of the CCM is such that the alarm system is triggered. It is observed in most cases that either the output port touches the obstacle-1 ($ O_1 $) or obstacle-4 ($ O_4 $) or the member attached to output port touches the obstacle-1 ($ O_1 $) and raises the alarm.
\subsection{Effect of friction}
\label{sec:friction}
The 3-kink switch in Fig. \ref{ThreekinkSwitch}d is designed with zero friction assuming the contact surfaces are very smooth and well polished. In case friction exists, we chose different coefficients, $ \mu = 10^{-3}, 10^{-2}, 0.05$ and $10^{-1}$ at all contact-sites and analyse the final design. Behavior of the 3-kink CCM with respect to different coefficients of friction is depicted in Figs. \ref{fig:Friction}\subref{fig:Friction_mu_0_001}-\subref{fig:Friction_mu_0_1}. One observes that even though the paths are not very different from that desired, the input force required is quite high, and increases significantly with the coefficient of friction. It is suggested that the mechanical key has very smooth external surfaces ($C_1$ to $C_6$ in Fig. \ref{ThreekinkSwitch}d) to maintain low friction coefficients for the output port to reach the switch pad with minimum effort.
\begin{figure}[h!]
\centering
\begin{subfigure}[t]{0.24\textwidth}
\centering
\includegraphics[scale=0.5]{Friction_mu_0-001.eps}
\caption{$ \mu = 0.001, F = 10.35 $N}
\label{fig:Friction_mu_0_001}
\end{subfigure}\hfill
\begin{subfigure}[t]{0.24\textwidth}
\centering
\includegraphics[scale=0.5]{Friction_mu_0-01.eps}
\caption{$ \mu = 0.01, F = 25.35 $N}
\label{fig:Friction_mu_0_01}
\end{subfigure}\hfill
\begin{subfigure}[t]{0.24\textwidth}
\centering
\includegraphics[scale=0.5]{Friction_mu_0-05.eps}
\caption{$ \mu = 0.05, F = 30.35 $N}
\label{fig:Friction_mu_0_05}
\end{subfigure}\hfill
\begin{subfigure}[t]{0.24\textwidth}
\centering
\includegraphics[scale=0.5]{Friction_mu_0-1.eps}
\caption{$ \mu = 0.1, F = 100.35 $N}
\label{fig:Friction_mu_0_1}
\end{subfigure}
\begin{subfigure}[t]{0.24\textwidth}
\centering
\includegraphics[scale=0.55]{Wear_mu_0-05_w_0-5.eps}
\caption{$ w $ = 0.5\%, $ \mu = 0.05 $}
\label{fig:Wear_mu_0.05_w_0.5}
\end{subfigure}\hfill
\begin{subfigure}[t]{0.24\textwidth}
\centering
\includegraphics[scale=0.55]{Wear_mu_0-05_w_1.eps}
\caption{$ w $ = 1.0\%, $ \mu = 0.05 $}
\label{fig:Wear_mu_0.05_w_1}
\end{subfigure}\hfill
\begin{subfigure}[t]{0.24\textwidth}
\centering
\includegraphics[scale=0.55]{Wear_mu_0-05_w_5.eps}
\caption{$ w $ = 5.0\%, $ \mu = 0.05 $}
\label{fig:Wear_mu_0.05_w_5}
\end{subfigure}\hfill
\begin{subfigure}[t]{0.24\textwidth}
\centering
\includegraphics[scale=0.55]{Wear_mu_0-05_w_10.eps}
\caption{$ w $ = 10\%, $ \mu = 0.05 $}
\label{fig:Wear_mu_0.05_w_10}
\end{subfigure}
\begin{subfigure}[t]{0.24\textwidth}
\centering
\includegraphics[scale=0.6]{new_5_nel_20.eps}
\caption{$ n_{ew} = 5 $}
\label{fig:new_5_nel_20}
\end{subfigure}\hfill
\begin{subfigure}[t]{0.24\textwidth}
\centering
\includegraphics[scale=0.6]{new_6_nel_20.eps}
\caption{$ n_{ew} = 6 $}
\label{fig:new_6_nel_20}
\end{subfigure}\hfill
\begin{subfigure}[t]{0.24\textwidth}
\centering
\includegraphics[scale=0.6]{new_7_nel_20.eps}
\caption{$ n_{ew} = 7 $}
\label{fig:new_7_nel_20}
\end{subfigure}\hfill
\begin{subfigure}[t]{0.24\textwidth}
\centering
\includegraphics[scale=0.6]{new_8_nel_20.eps}
\caption{$ n_{ew} = 8 $}
\label{fig:new_8_nel_20}
\end{subfigure}
\caption{Effect of various parameters on performance of the 3-kink CCM. (\subref{fig:Friction_mu_0_001}-\subref{fig:Friction_mu_0_1}) compares the desired and actual paths for different coefficients of friction i.e., $ \mu = 0.001, 0.01, 0.05 $ and 0.1. Required input force $ F $ is increased such that the entire path is traced. (\subref{fig:Wear_mu_0.05_w_0.5}-\subref{fig:Wear_mu_0.05_w_10}) represent variation of output path with respect to different wear percentages ($ w $). Coefficient of friction $ \mu = 0.05$ for all four cases. Input force $ F $ is 30.35N for all cases. (\subref{fig:new_5_nel_20}-\subref{fig:new_8_nel_20}) represent comparison of desired and actual paths for different mesh densities.}\label{fig:Mesh_Density}
\label{fig:Friction} \label{fig:Wear}
\end{figure}
\subsection{Effect of wear}
To demonstrate the effect of wear on performance of 3-kink switch, we model wear by uniformly shrinking regions of the CCM that come in contact with external surfaces of the key. This is achieved by reducing the width of each quadrilateral element of such regions by $w = 0.5\%, 1\%, 5\%, \mbox{ and } 10\%$. Here, we assume that the CCM wears out uniformly at all contact-sites and no wear is considered for rigid external contact surfaces. With the above assumptions and methodology, mechanism tracing the 3-kink path is analysed considering the coefficient of friction as $0.05$ with the aforementioned wear percentages at contact locations. Figs. \ref{fig:Wear}\subref{fig:Wear_mu_0.05_w_0.5}-\subref{fig:Wear_mu_0.05_w_10} show the effect of wear. Change in objective function value with respect to different wear percentages are given in Table \ref{Table:Wear}. The output paths deviate but not much from the desired suggesting that even when the contact regions of the mechanism wear out, the latter will still retain its functionality. Further, from Figs. \ref{fig:Wear_mu_0.05_w_5} and \ref{fig:Wear_mu_0.05_w_10} one observes an increase in length of the output path that is because of reduced stiffness of CCM members at contact-sites, due to wear. Contribution of wear at each contact-site to overall deviation (though less) of output path will be explored in future studies along with wear of external surfaces.
\begin{table}[h!]
\centering
\caption{Effect of wear on performance of CCMs}
\label{Table:Wear}
\begin{tabular}{ccc}\toprule
Wear percentage ($ w $) & Objective value & Output path \\ \toprule
0.5 & 41.7132 & Fig. \ref{fig:Wear_mu_0.05_w_0.5} \\
1 & 38.5558 & Fig. \ref{fig:Wear_mu_0.05_w_1} \\
5 & 39.744 & Fig. \ref{fig:Wear_mu_0.05_w_5} \\
10 & 46.1985 & Fig. \ref{fig:Wear_mu_0.05_w_10} \\ \bottomrule
\end{tabular}
\end{table}
\subsection{Computational time}
Time involved in generating an optimized CCM design comprises time consumed for each analysis and the time taken for the optimization process.
\subsubsection{Time for single analysis}
\begin{table}[h!]
\centering
\caption{Comparison of time taken for single analysis with respect to mesh size}
\label{Table:Time_Mesh_Size}
\begin{tabular}{@{}ccccccc@{}}
\toprule
Sr.No & new & nel & Total number of elements & Objective function value & Time taken (sec) & Path \\ \midrule
1 & 5 & 20 & 4060 & 41.3980 & 134 & Fig. \ref{fig:new_5_nel_20} \\
2 & 6 & 20 & 4856 & 41.9402 & 158 & Fig. \ref{fig:new_6_nel_20} \\
3 & 7 & 20 & 5740 & 44.0356 & 186 & Fig. \ref{fig:new_7_nel_20} \\
4 & 8 & 20 & 6712 & 45.047 & 203 & Fig. \ref{fig:new_8_nel_20} \\ \bottomrule
\end{tabular}
\end{table}
For the 3-kink CCM, typical clock-time for generation and analysis of a candidate design is approximately 120 seconds. Mesh generation, plotting, identifying contact surfaces as loops, specifying contact interactions amongst them and preparation of \texttt{ABAQUS\textsuperscript{TM}} input file takes approximately 10 seconds on a desktop computer equipped with Intel(R) i5-6400 CPU @ 2.71GHz processor and 16 GB RAM. The remaining time goes into analysis and extraction of nodal displacements. Considering large number of quadrilateral elements and nodes the analysis time is justified. Further, considering self and mutual contact modes and book keeping of contact related information, based on our experience, this time cannot be avoided even if one develops an in-house code. A comparison of time taken for single analysis with respect to number of elements and nodes is presented in Table \ref{Table:Time_Mesh_Size}. Also, implementation of friction is possible which may take marginally additional time (presented in Sec. \ref{sec:friction}). A comparative study is performed to demonstrate variation of output path with respect to mesh density and the same is presented in Figs. \ref{fig:Mesh_Density}\subref{fig:new_5_nel_20}-\subref{fig:new_8_nel_20}. Number of elements along width of member ($ n_{ew} $) is varied to modify mesh density. From Figs. \ref{fig:Mesh_Density}\subref{fig:new_5_nel_20}-\subref{fig:new_8_nel_20}, one observes that optimum mesh density needs to be chosen for better results. Slender elements may be formed if number of elements along width are not in proportion to number of elements along length, which may leads to more deviation in output path as given in Fig. \ref{fig:new_8_nel_20}. Time reduction for single analysis is possible but perhaps at the cost of accuracy.
\subsubsection{Search algorithm and time taken}
We chose zero order Hill Climber search which is expected to yield a desired CCM requiring significantly large number of function evaluations compared to a gradient search and hence, it is computationally expensive. Hill Climber search is chosen to cater to discrete variables responsible not only to generate external surfaces but also to identify contact surface types (elliptical, circular and rectangular). Also, discrete variables are used in determining the continuum topology. In addition, final/intermediate designs are also evaluated for feasibility of contact analysis by checking whether external surfaces intersect with skeleton of continuum members or whether the fleshed out members. In the first case, discrete variables are modified to remove the intersecting members while in the second case the same is done to remove external surfaces. The overall goal is to consider as many potential CCM designs for analysis. The aforementioned may not be possible with gradient search. In addition, a gradient search will not proceed in case the analysis for an intermediate design does not converge. With zero order searches, such designs can be penalized and ignored, facilitating smooth/uninterrupted search.
\section{Closure}
\label{sec:conclusion}
A methodology to systematically design and synthesize CCMs that trace non-smooth paths with multiple kinks using self and mutual contact with external surfaces of varying shapes is presented. A novel method of identifying contact surfaces as closed loops is conceived. Geometrically nonlinear finite element analysis is performed using \texttt{ABAQUS\textsuperscript{TM}}. Since, it is felt that a gradient search cannot be employed, a zero order Hill Climber search is adopted to easily penalize incomplete/non-convergent intermediate designs. Fourier shape descriptors are employed to compare desired and actual paths. A three-kink CCM switch is designed using the proposed methodology. Functionality of CCM switch with different wrong key combinations is studied. It is observed that lock does not open with any of these candidate wrong keys, however, in very few cases the alarm does not get activated. We further perform a detailed study on effect of friction and wear on performance of CCM switch. With friction at contact-sites, more input force is required to get the same output path. This additional force requirement increases significantly with increase in friction coefficient. Thus, use of smooth and polished external surfaces is recommended to minimize friction. Wear at contact-sites is modeled by shrinking the quadrilateral elements of the continuum at those sites. It is observed that wear does not have much impact on the desired deformation of the CCM. Further, mesh independence is demonstrated. It is suggested that the number of elements along width and length directions should be proportional to member dimensions to avoid elements with high aspect ratio, and also for efficient analysis. In future, we intend to explore more features/applications of CCMs, including static balancing, with generically shaped external surfaces, either rigid or deformable.
\section*{Acknowledgment}
\addcontentsline{toc}{section}{Acknowledgment}
First author acknowledges the support received from Knowledge Incubation for TEQIP (KIT) Office, IIT Kanpur and its staff, during his visit to IIT Kanpur. He also acknowledges the help received from fellow CARS lab members, Mr. Shyam Sundar Nishad, Mr. Nikhil and Mr. Vitthal during the initial stages of preparation of this manuscript.
| {'timestamp': '2020-06-19T02:12:37', 'yymm': '2006', 'arxiv_id': '2006.10385', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10385'} | arxiv |
\section{Introduction}
Writing scientific papers is crucial but a laborious task in research activities, especially for non-native English speakers.
\citet{Zhao2017} and \citet{Wu2020} demonstrated that the quality of English academic writing is significantly different between native and non-native researchers.
Also, it is time-consuming to look up words in a dictionary or ask for English proofreading.
Thus, writing assistance can be a great help to non-native researchers to improve the quality of their papers and to save much time in writing, which will accelerate their research activities.
As a means of writing assistance, the use of \textit{formulaic expressions} has previously been investigated \citep{AlHassan2015,Mizumoto2017,Iwatsuki2018}.
Formulaic expressions are continuous or discontinuous word sequences that are frequently used in scientific papers to convey specific \textit{communicative functions} \citep{Cortes2013,Adel2014}.
For example, the formulaic expression `\textit{little attention has been paid to}' conveys the communicative function `\textit{referring to the paucity of past work}'.
Instead of having to compose everything by themselves, the use of formulaic expressions helps authors express their intended meaning more properly and effectively.
To utilise them, formulaic expressions should first be collected from a corpus of scientific papers.
However, the difficulty lies in both automatic extraction of formulaic expressions and automatic evaluation of formulaic expressions.
In previous studies \citep{Hyland2008,Chen2010,Simpson-vlach2010}, frequent word $n$-grams have been extracted from a corpus and the usefulness of extracted word sequences has been evaluated manually because of a lack of automatic evaluation methods.
However, formulaic expressions are not always fixed lexical units.
Some words can be replaced with others and spans are also flexible.
For example, `\textit{in this paper we propose}' is a formulaic expression, but `\textit{in this study we propose}' and `\textit{in this work we propose}' sometimes appear instead.
Also, both `\textit{in this paper we propose}' and `\textit{in this paper we propose a new method to}' can be regarded as formulaic expressions because they both convey the communicative function `\textit{showing the aim of the paper}'.
However, `\textit{paper we propose a}' should not be labelled as a formulaic expression.
In short, forms of formulaic expressions can vary according to the syntax and content of the sentence in which they appear.
Therefore, the existing approach has made it difficult to automatically determine which word sequences should be formulaic expressions.
\begin{figure}[t]
\centering
\includegraphics[scale=0.7]{Fig1.pdf}
\caption{Sentence from a paper \citep{He2008} presented in ACL Anthology. We assume that a sentence consists of a formulaic expression that conveys a specific communicative function and content. Thus, extraction of formulaic expressions is to distinguish formulaic part from the non-formulaic part of a sentence. Also, to evaluate the extraction methods, how strongly a formulaic expression and communicative function are connected is measured.}
\label{fig:disentanglement}
\end{figure}
To solve these problems, we redefine the extraction and evaluation problems in the following way.
First, formulaic expressions are always used in a sentence, never alone.
Therefore, we assume that a sentence consists of two parts: a formulaic expression that conveys a specific communicative function and a remaining non-formulaic part that expresses content such as names of materials and details of methods (Figure~\ref{fig:disentanglement}).
From this viewpoint, the extraction task can be regarded as a sequential labelling problem, that is, labelling each word in a sentence formulaic or non-formulaic.
For evaluation we measure how strongly connected are an extracted formulaic expression and a communicative function.
Unlike previous methodologies, which focus only on formulaic expressions rather than whole sentences, our approach makes it possible to deal with short, long, frequent and infrequent formulaic expressions at once.
Additionally, based on this approach, we propose an extraction method that utilises named entities and a dependency structure to remove the non-formulaic part from a sentence (Figure~\ref{fig:propsoed_method_image}).
First, we remove named entities in a sentence, resulting in a few spans split by the named entities.
Secondly, we select words to remove based on the dependency structure of the sentence.
Words that do not belong to a span containing the root of the sentence and that are not organised by the root are removed.
\begin{figure}[t]
\centering
\includegraphics[scale=0.6]{Fig2.pdf}
\caption{We first remove named entities (NE) from a sentence, resulting in three spans in this example. Then, we remove words not satisfying the two conditions: (1) all the words in the span that contains a root \textit{and} (2) words organised by a root.}
\label{fig:propsoed_method_image}
\end{figure}
For evaluation, we also measure how much a formulaic expression conveys a communicative function by assigning different weights to formulaic and non-formulaic words in a sentence.
To do so, we propose using the sentence retrieval task \citep{Iwatsuki2020} as an extrinsic evaluation method.
In this task, a query sentence is given and sentences that have the same communicative function as the query should be retrieved.
Sentences are converted into vector representations and ranked according to their similarity with the query.
Each sentence is tagged with its communicative function in advance.
The difference between the original task and our evaluation task lies in how the sentence vectors are created.
In the original setting, sentence vectors are created by averaging vectors of each word in a sentence, which is a well-known way to create them.
On the contrary, to examine how much the formulaic part of a sentence conveys a communicative function, we propose creating sentence vectors by assigning different weights to formulaic words and non-formulaic words in a sentence.
We compare the performance of our proposed method to that of existing extraction methods.
The results show that the proposed method achieves the best performance among all compared methods.
Our contributions are as follows.
First, we propose a comprehensive approach to extract and evaluate formulaic expressions that can take a variety of forms.
Secondly, we propose a new method to evaluate extraction methods by assigning different weights to formulaic expression candidates to create sentence representations and applying a sentence retrieval task as an extrinsic evaluation.
Thirdly, we empirically demonstrate that the proposed evaluation method is valid by testing formulaic and non-formulaic expressions.
Finally, we propose a new method to extract formulaic expressions. We empirically verified that the proposed method achieves the best performance among all the methods we tested.
The proposed method does not require additional data labelled with formulaic expressions and it can be immediately applied to other corpora.
Thus, this work will accelerate the construction of multi-disciplinary database of formulaic expressions and research on computer-aided writing assistance using formulaic expressions.
Moreover, because formulaic expressions are used not only in scholarly papers but also in other documents and speeches, we hope the present study can contribute to enhancing writing communications.
\section{Related Work}
\subsection{Communicative Functions in Scholarly Papers}
Communicative functions represent the intentions of authors of scholarly articles.
Authors must communicate with readers in order for them to understand their research properly.
Thus, every part of a scientific paper has a specific function, such as providing background information, explaining methodology and discussing experimental results, and readers interpret these functions to understand why that text is written.
Communicative functions should be aligned in a reasonable order that is conventionally established by the research community to make papers easily understandable.
\citet{Swales1981} first introduced the concept of \textit{move}, which is a rhetorical unit conveying a communicative function in scholarly papers.
Transitions of moves have been found to be fixed to some extent.
In Figure~\ref{fig:swales4moves} moves and their transitions in introduction sections are described.
Each move has several \textit{steps}, denoted by A), B) and C), which are finer-grained units.
Following his work \citep{Swales1981,Swales1990,Swales2004}, which focused on the introduction sections in research articles, \citet{Cotos2015} and \citet{Maswana2015} analysed moves in every section.
They created lists of moves and steps found in scholarly articles.
Units where communicative functions are realised are flexible.
Several sentences sometimes realise one communicative functions, while a clause may also do.
However, in previous work \citep{Hirohata2008,Dayrell2012,Fiacco2019,Iwatsuki2020}, a sentence was regarded as a unit of communicative function.
We follow this manner; we assume that one sentence has a communicative function and thus one sentence has one formulaic expression that conveys the communicative function.
\begin{figure}[t]
\centering
\includegraphics[scale=0.75]{Fig3.pdf}
\caption{Moves in introduction sections proposed by \citet{Swales1981}. There are four moves appearing in this order in the section. Each move has two or three steps, which are finer-grained communicative functions.}
\label{fig:swales4moves}
\end{figure}
There are a few studies dealing with classification of communicative functions.
\citet{Dayrell2012} and \citet{Hashimoto2016} proposed feature-based machine learning methods to classify sentences according to their communicative functions.
The limitation of these studies is that they used only abstracts of papers.
Thus, classification of communicative functions of a whole paper remains an open issue.
\subsection{Formulaic Expressions and Communicative Functions for Writing Assistance}
Formulaic expressions used in academic writing, also known as formulaic sequences, lexical bundles and phraseologies, have been studied by many researchers \citep{Simpson-vlach2010,Adel2012,Liu2012,Vincent2013,Perez-Llantada2014,Omidian2018}.
The usage of formulaic expressions differs across disciplines \citep{Hyland2008,Nekrasovabeker2019}.
Domain-specific studies on formulaic expressions, including mathematics \citep{Cunningham2017}, social sciences \citep{Lu2018}, medicine \citep{Jalali2014}, psychology \citep{Esfandiari2017} and applied linguistics \citep{Qin2014}, have been conducted.
Therefore, not only general-purpose formulaic expressions but also domain-specific formulaic expressions should be collected for writing assistance.
\citet{Cortes2013} and \citet{Adel2014} proposed combining formulaic expressions and communicative functions.
This combination makes it relatively easy to search for specific formulaic expressions because formulaic expressions labelled with their communicative functions can be searched for by not only keywords but also authors' intentions.
Thus, a recently proposed writing assistance system adopts this approach \citep{Mizumoto2017}.
Following these studies, in this work, we adopt the definition that formulaic expressions are combined with communicative functions.
\subsection{Multi-Word Expressions and Formulaic Expressions}
Generally, multi-word expression is a different concept to formulaic expression but there is some overlap between the two concepts.
Multi-word expressions do not always convey a communicative function.
According to the survey by \citet{Constant2017}, multi-word expressions can be categorised in several ways.
For instance, `\textit{kick the bucket}' is a typical multi-word expression and categorised into the \textit{idiom} class and `\textit{International Business Machines}' is categorised into the \textit{multi-word named entity} class.
However, both do not convey any specific communicative function in scientific papers.
PARSEME \citep{Savary2017} is the most comprehensive dataset for multi-word expression identification.
In this dataset, multi-word expressions are classified into three categories: general, quasi-general and other; these categories are not based on communicative functions.
Therefore, state-of-the-art models for identification of multi-word expressions trained on the dataset \citep{Waszczuk2019,Saied2019} cannot be directly applied to the extraction of formulaic expressions.
\subsection{Evaluation of Formulaic Expressions}
Manual evaluation has been a common method of formulaic expression evaluation.
\citet{Simpson-vlach2010} asked experts whether they thought extracted formulaic expressions were formulaic or had cohesive meaning and \citet{Iwatsuki2018} asked annotators whether they thought extracted formulaic expressions were helpful for writing.
Generally speaking, for tasks of building new vocabulary, there is no reference.
If some reference data exist, we do not need to create another, which \citet{Brooke2015} also pointed out.
Thus, an automated evaluation in which all extracted candidates are compared to a reference lexicon is not realistic.
Additionally, the flexibility of formulaic expressions also makes automated intrinsic evaluations difficult, where extracted formulaic expression candidates are evaluated by their properties, such as frequency and mutual information.
For example, both `\textit{beyond the scope}' and `\textit{is beyond the scope of this paper}' are good formulaic expressions that convey the same communicative function, i.e., `\textit{describing the limitations of current research}'.
Therefore, even if manually annotated formulaic expressions are available, there are still other allowable formulaic expressions as long as they convey the same communicative function.
To avoid these problems, we first propose an extrinsic evaluation method that utilises communicative functions conveyed by formulaic expressions.
The idea is that a sentence can be split into a formulaic expression and a content part and the former should convey a communicative function.
Therefore, how strongly a formulaic expression candidate is connected to a sentence's communicative function can be considered a good proxy for measuring of the quality of the formulaic expression candidate.
We adopt the communicative-function-oriented sentence retrieval task to check the degree of the connections.
\section{Methods}
\subsection{Dataset}
We use two datasets for different purposes.
The first dataset is the ACL Anthology Sentence Corpus (AASC)\footnote{\url{https://github.com/KMCS-NII/AASC}}, which consists of 13,923 papers retrieved from ACL Anthology\footnote{\url{https://www.aclweb.org/anthology/}}.
For each paper, narrative texts are split into sentences and sentences are labelled with their section.
Generally, section headers in papers are not always fixed to a set of labels such as introduction, methods, results and discussion, even though the content of the sections can be classified into these fixed categories.
For example, there is a case where two sections of two different papers explain methodologies but the section headers are different: `Learning Method' and `Approach'.
Thus, it is necessary to integrate these variants into one content-based section header, i.e., `methods' in this example.
However, in this dataset, the section labels are normalised into a limited number of labels; thus, we can use sentences without checking the original section titles.
The second dataset (FECFeval)\footnote{\url{https://github.com/Alab-NII/FECFevalDataset}} created by \citet{Iwatsuki2020} consists of 5 sections (introduction, background, method, result and discussion).
Each instance in the dataset consists of a sentence extracted from AASC, annotated with its communicative function and formulaic expression (see examples in Figure~\ref{fig:FECF}).
The number of communicative functions is 39: 11 for introduction, 7 for background, 6 for method and result and 9 for discussion; the total number of instances is 691.
The communicative functions are based on the existing resource, Academic Phrasebank\footnote{John Morley, \url{http://www.phrasebank.manchester.ac.uk/}}.
\begin{figure}[t]
\centering
\includegraphics[scale=0.7]{Fig4.pdf}
\caption{Two examples recorded in the FECFeval dataset. Each instance consists of a section label, communicative function, formulaic expression and sentence. These sentences were originally retrieved from \citet{Hee2015} and \citet{Liu2011}.}
\label{fig:FECF}
\end{figure}
\subsection{Extraction}
We assume that a sentence consists of a formulaic expression that conveys a communicative function and named entities that realise a content of a sentence\footnote{Of course, there are sentences that do not contain formulaic expressions but this task is the extraction of formulaic expressions; thus, we focus only on sentences containing formulaic expressions. Also, some sentences do not contain any named entities but this method can still be applied; nothing will be removed from a sentence.}.
Therefore, instead of directly identifying the formulaic part, we apply named entity recognition (NER) to remove the content part from a sentence.
We also investigated how many manually annotated formulaic expressions in the FECFeval dataset contain words that are roots in the sentence dependency structure and we found that 442 out of 686 (64.4\%) formulaic expressions contain roots.
Thus, we extract a root of a sentence using the dependency structure of a sentence.
Named entity removal is conducted in the following way.
In a sentence, there can be both named entities specific to scientific papers, such as names of methods, and datasets and general named entities, such as locations.
Thus, we use two different datasets to train the NER model: SciERC \citep{Luan2018} and CoNLL04 \citep{Roth2004}.
SciERC is a dataset based on scholarly papers and named entities are annotated.
Its entity types are specific to scientific papers: task, method, evaluation metric, material, other scientific terms and generic.
CoNLL04's entity annotations are general ones: location, organisation, people and other.
The NER model we trained on the two datasets is SpERT\footnote{We used the implementation presented by the authors: \url{https://github.com/markus-eberts/spert} .} \citep{Eberts2020}, which is the top of the leader board of NER tasks in SciERC\footnote{Spert achieves the best performance on NER on SciERC according to `paper with code' (\url{https://paperswithcode.com/sota/named-entity-recognition-ner-on-scierc}) as of 12 April 2020.}.
By the removal of named entities, a sentence can be split into several spans (if no named entity is in a sentence, no split happens).
We applied the Stanford CoreNLP dependency parser \citep{Qi2018} to remove words that did not belong to a span containing a root and were not organised by a root.
In Figure~\ref{fig:NERdepparse}, an example of a sentence processed by NER and dependency parsing is shown.
In this example, named entity removal results in three spans: `when comparing the two', `it can be seen that' and `outperforms the'.
The root of this sentence is `seen'; thus, the span `it can be seen that' was marked as the formulaic part.
Additionally, the words in the other spans that are organised by the root, namely `comparing' and `outperforms', remained.
All the other words were dropped; then, the formulaic expression candidate is `comparing * it can be seen that * outperforms'.
\begin{figure}[t]
\centering
\includegraphics[scale=0.5]{Fig5.pdf}
\caption{Result of dependency parsing and named entity recognition. Named entities are coloured grey and underlined.}
\label{fig:NERdepparse}
\end{figure}
\subsection{Evaluation}
\subsubsection{Sentence Representations}
As mentioned in the introduction, we assume that a communicative function is conveyed by a formulaic expression and thus, the extraction can be evaluated by the strength of connection between a formulaic expression and a communicative function.
Therefore, we create sentence vectors by assigning different weights to the formulaic and non-formulaic parts.
It is a common way to average word embeddings of each word of a sentence to create a sentence vector.
Unlike the ordinary method, we assign different weights to word vectors of formulaic and non-formulaic parts when averaging them, which can be formalised as follows:
\begin{eqnarray}
\mathrm{s}(W) = \frac{1}{|W|} \Biggl\{ \alpha \cdot \sum_{w_i \in \mathrm{FE}} \mathrm{v}(w_i) + (1-\alpha) \cdot \sum_{w_j \in \mathrm{nonFE}} \mathrm{v}(w_j) \Biggr\}, \nonumber
\end{eqnarray}
where $\mathrm{s}(\cdot)$ is a vector of a sentence, $W$ is a sequence of words in the sentence, which consists of $\mathrm{FE}$ (formulaic expression) and $\mathrm{nonFE}$ (the remaining words in the sentence), $\mathrm{v}(w)$ is a function that returns a vector representation of $w$ and $\alpha (0 \leq \alpha \leq 1)$ is a parameter determining the weights of the formulaic and non-formulaic parts.
When $\alpha=0.5$, the sentence vector is simply the average of each word embedding.
When $\alpha=1.0$, it consists of only the formulaic part.
Unlike the experiments conducted in \citet{Iwatsuki2020}, where $\alpha$ was fixed to 0.5, we vary $\alpha$.
In our experimental setting, we use skip-gram models for $\mathrm{v}(w)$ trained on AASC. We follow the experimental settings used in \citet{Iwatsuki2020}: the dimension is 200 and the window size is 2.
It should be noted that our experiments do not rely on specific word embedding models or parameters.
\subsubsection{Sentence Retrieval Task}
Instead of directly evaluating extracted formulaic expressions, we propose an extrinsic evaluation method that utilises communicative functions conveyed by formulaic expressions.
We adopt the sentence retrieval task proposed by \citet{Iwatsuki2020} to measure the strength of connection between extracted formulaic expressions and communicative functions.
In this task, a query sentence is given and then a retrieval system should return an ordered list of sentences ranked according to the similarities of communicative functions between the query and other sentences.
Then, the top-$N$ sentences in the list are selected and for evaluation, it is checked how many sentences have the same communicative function as the query.
In the system, sentences are converted into vector representation, as described above.
Then, sentence vectors are ranked according to the cosine similarity with the query.
Mean average precision (MAP) is used for evaluation of the retrieval task, which is formulated as follows:
\[
\mathrm{MAP}(S^i) = \frac{1}{|S^i|} \sum_{s_j \in S^i} \frac{1}{n_{s_j}} \sum_{k=1}^{|R_j^i|}
\left\{
\begin{array}{ll}
0 & (\mathrm{CF}(r_k) \neq \mathrm{CF}(s_j)) \\
\mathrm{P}_j^i(k) & (\mathrm{CF}(r_k) = \mathrm{CF}(s_j))
\end{array},
\right.
\]
where $S^i$ is a set of sentences in section $i$, $n_{s_j}$ is the number of correct answers when the query sentence is $s_j$, $R^i_j$ is an ordered list of the sentence retrieval result, $\mathrm{P}_j^i(k)$ is the precision at position $k$-th in the list and $\mathrm{CF}(r_k)$ is a communicative function of the $k$-th ranked sentence $r_k \in R_j^i$.
\section{Experiments}
\subsection{Overview}
We conducted two experiments.
The first one is for validating whether our proposed evaluation method works or not.
We prepared manually annotated formulaic and non-formulaic expressions and compared their performances in sentence retrieval.
The second one compared our proposed extraction method to other existing methods.
Both experiments are proceeded in the following way.
First, the FECFdataset was split into five sections (introduction, background, method, result and discussion).
Secondly, for each section, one sentence was chosen as a query, and the sentence retrieval was applied to a set of other sentences.
Then, another sentence in the section was chosen as a query, and the same process was repeated.
After all the sentences were used as a query, the MAP score for the section was calculated.
Finally, the average of all five MAP scores was calculated for evaluation.
For simplicity, we refer to the averaged MAP score as MAP score hereafter.
\subsection{Validity of the Evaluation Method}
In the FECFeval dataset \citep{Iwatsuki2020}, the \textit{CoreFEs} are labelled for each sentence.
CoreFEs are phrases that are manually labelled as formulaic expressions that convey a specific communicative function, but only the core part of a formulaic expression is annotated because CoreFEs are used as query keywords for the retrieval of sentences from a corpus, in which a query that is too long would result in no matching results.
For example, `\textit{to the best of our knowledge no work exists on}' can be regarded as a formulaic expression but `\textit{no work exists}' is only labelled as a CoreFE.
Thus, it should be noted that a CoreFE can be regarded as a formulaic expression but it misses some words that could also be included in the formulaic expression.
We used the CoreFEs as the result of manual extraction to compare other methods of extraction.
For comparison purposes, we prepare three other types of expressions: NonFE, OneWordCoreFE and NonFE+CoreFE.
Figure~\ref{fig:CoreFE_random_example} shows the examples of the four patterns.
NonFE represents words that are randomly extracted from a sentence in which a CoreFE is removed.
The length of NonFE expressions is the same as that of the corresponding CoreFE.
These are regarded as bad formulaic expressions.
OneWordCoreFE represents one word randomly picked from a CoreFE for each sentence.
NonFE+CoreFE represents combinations of NonFE and CoreFE.
OneWordCoreFE simulates an extraction method that misses most parts of formulaic expressions.
Putting more weight on OneWordCoreFE means applying less weight to most parts of formulaic expressions.
Thus, the performance should start to deteriorate at some point.
NonFE+CoreFE simulates an extraction method that extracts the same number of formulaic and non-formulaic words.
This should cause lower performance than CoreFE because non-formulaic words are heavily weighted.
\begin{figure}[t]
\centering
\includegraphics[scale=0.5]{Fig6.pdf}
\caption{Examples of four methods: CoreFE, NonFE, OneWordCoreFE (OneWord) and CoreFE+NonFE (Core+NonFE), all of which are extracted from the sentence.}
\label{fig:CoreFE_random_example}
\end{figure}
\subsection{Baselines for Extraction}
\subsubsection{Phrase Extraction and Sequential Labelling}
We compared our proposed method to other existing methods, which can be classified into two types: phrase extraction and sequential labelling.
For phrase extraction, we adopted LatticeFS \citep{Brooke2017}, a method to extract phrases from a whole corpus.
For sequential labelling \citep{Iwatsuki2018}, each word in a sentence was labelled as either formulaic or non-formulaic.
We adopt two methods: frequency-based and latent Dirichlet Allocation (LDA)-based \citep{Liu2016}.
\subsubsection{LatticeFS}
\citet{Brooke2017} proposed a method (LatticeFS) to extract formulaic expressions by comparing candidate formulaic expressions according to a proposed objective function called \textit{explainedness}.
Their idea is that if one $n$-gram can be explained by another $n$-gram, both can be grouped into one $n$-gram.
They first created an $n$-gram lattice in which the $(n-1)$-gram and $(n+1)$-gram are connected to the $n$-gram.
Then, using the concepts of \textit{covering}, \textit{clearing} and \textit{overlap}, they optimised explainedness to determine which nodes in the lattice should be labelled as formulaic expressions.
We used the implementation provided by the authors\footnote{\url{https://github.com/julianbrooke/LatticeFS}} and applied it to the FECFeval dataset (for an example, see Figure~\ref{fig:example_Brooke}).
For statistical calculation, a whole corpus is needed and we used AASC.
\begin{figure}[t]
\centering
\includegraphics[scale=0.48]{Fig7.pdf}
\caption{Example of LatticeFS. This method extracts all formulaic expressions from a corpus that are labelled as such by the proposed algorithm. There can be some formulaic expressions that overlap each other.}
\label{fig:example_Brooke}
\end{figure}
\subsubsection{Frequency-Based Sequential Labelling}
Formulaic expressions are considered to consist of words that occur more frequently than words that are specific to certain research topics.
According to past work \citep{Iwatsuki2018}, simply removing words with low frequencies improves the performance of classification of communicative functions.
Following this idea, we implemented a frequency-based extraction method consisting of the following steps.
First, we calculated the frequencies of all words occurring in AASC.
Secondly, from a given sentence, we removed all words whose frequencies were lower than the threshold.
In our experiment, we used several thresholds.
\subsubsection{LDA-Based Sequential Labelling}
\citet{Liu2016} applied a topic-modelling to remove unnecessary words from a sentence.
They assumed that words that frequently appear in a certain research topic do not compose formulaic expressions.
They use LDA to assign topic-dependency to each word in a sentence.
They calculated the score that indicates how much a word is a structure word (non-topic word) rather than a topic word as follows:
\begin{eqnarray}
\mathrm{P}(w) = 1 - \frac{\max p_w(i)}{\sum p_w(i)}, \nonumber
\end{eqnarray}
where $p_w(i)$ is the probability of word $w$ in a topic $i$.
Words with $\mathrm{P}(w)$ smaller than the threshold are removed from a sentence.
Following \citet{Liu2016}'s experimental settings, we set the threshold to 0.65 and the number of topics to 10.
The calculation of $\mathrm{P}(w)$ was conducted on AASC.
Figure~\ref{fig:LDA} shows an example.
\begin{figure}[t]
\centering
\includegraphics[scale=0.48]{Fig8.pdf}
\caption{Example that the LDA-based method was applied to. The numbers $\mathrm{P}(w)$ were assigned to each word. Words coloured grey are below the threshold (0.65).}
\label{fig:LDA}
\end{figure}
\section{Results}
\subsection{Validity of the Sentence Retrieval Task as an Extrinsic Evaluation Method}
In Figure~\ref{fig:CoreFE_and_random} the MAP scores of CoreFE, NonFE, CoreFE+NonFE and OneWordCoreFE are shown.
Comparing the performances between CoreFE and NonFE extraction, it can be said that good extraction methods improve the sentence retrieval performance as $\alpha$ increases while bad methods deteriorate the performance as $\alpha$ increases.
Therefore, the MAP score at $\alpha=1.0$ can be used as an indicator of effectiveness of extraction methods.
We conducted further analysis of the transitions of the performances according to $\alpha$.
As for CoreFEs, i.e., good formulaic expressions, MAP increases monotonically as $\alpha$ increases.
Conversely, for NonFE, MAP decreases monotonically.
MAP of CoreFE+NonFE is located between the two.
The performance increases as well as CoreFEs, but due to non-formulaic words, it is not as good as CoreFEs.
However, for OneWordCoreFE, the peak is at, $\alpha=0.8$, and MAP decreases after that.
This phenomenon can be explained as follows.
As $\alpha$ increases from 0.5 to 0.8, heavier weight on the one-word formulaic expressions has a good effect on the performance.
In other words, less weight is put on the remaining formulaic expressions.
This smaller weight on the remaining formulaic expressions deteriorates the performance with higher $\alpha$.
From these observations, we argue that the sentence retrieval task is valid to evaluate extraction methods.
Basically, comparing MAP scores at $\alpha=1.0$ is a good indicator.
The change of MAP score gives additional insight.
If it increases monotonically, most formulaic words are extracted from a sentence.
If there is a peak between $\alpha=0.5$ and $1.0$, the method seems to fail to extract a significant part of a formulaic expression.
\begin{figure}[t]
\centering
\includegraphics[scale=0.75]{Fig9.pdf}
\caption{Relationships between MAP and $\alpha$. MAP of CoreFE monotonically increases, while that of NonFE behaves inversely. CoreFE+NonFE shows that lower performance is attributed to extraction of unnecessary words. OneWordCoreFE shows that by missing indispensable words the peak of MAP appears between $\alpha=0.5$ and $1.0$.}
\label{fig:CoreFE_and_random}
\end{figure}
\subsection{Formulaic Expression Extraction}
\begin{table}[h]
\centering
\caption{Results of all compared methods. The proposed method, named entity removal (NER) and dependency parsing (depparse) achieved the best performance.}
\begin{tabular}{ccccccc} \hline
& CoreFE & NonFE & Frequency & LatticeFS & LDA & NER+depparse \\ \cline{2-7}
MAP & 56.2\% & 26.9\% & 36.8\% & 35.2\% & 38.6\% & \textbf{42.2\%} \\ \hline
\end{tabular}
\label{tab:result}
\end{table}
Table~\ref{tab:result} shows the results of the extraction of formulaic expressions with the proposed and existing methods.
CoreFE and NonFE are also included in the table for comparison.
MAP scores are computed at $\alpha=1.0$.
Among the four extraction methods, the proposed method achieved the best performance.
We also tested various parameter settings for the frequency-based and LDA-based methods to see the differences.
Table~\ref{tab:frequency} shows the MAP scores of the frequency-based method at $\alpha=1.0$ with different thresholds.
Too strict a threshold ($10^{-4}$) seems to remove formulaic words.
There is not much difference between $10^{-5}$ and $10^{-6}$, which implies that almost all words, including formulaic and non-formulaic words, remain as the formulaic part, resulting in the use of whole sentences.
Table~\ref{tab:lda_parameters} shows the MAP scores with different parameters of the LDA-based method.
\citet{Liu2016} reported that based on their experiments, they set the number of topics to 10 and the threshold to 0.65.
This setting is not the best in our experimental settings, but using different parameters did not result in sufficient improvement to outperform our proposed method.
\begin{figure}[t]
\centering
\includegraphics[scale=0.48]{Fig10.pdf}
\caption{Two examples of results by each method. These sentences were originally retrieved from \citet{Frermann2014} and \citet{McDonald2005}.}
\label{fig:example_4methods}
\end{figure}
\begin{table}[h]
\centering
\caption{Results at $\alpha=1.0$ with different thresholds of frequency.}
\begin{tabular}{cccccc} \hline
Threshold & $10^{-4}$ & $5\times10^{-4}$ & $10^{-5}$ & $5\times10^{-5}$ & $10^{-6}$ \\ \hline
MAP & 35.8\% & 36.8\% & 36.7\% & 36.7\% & 36.6\% \\ \hline
\end{tabular}
\label{tab:frequency}
\end{table}
\begin{table}[h]
\centering
\caption{MAP scores of LDA-based method with different parameters. Although some combination of parameters achieved relatively low scores, most patterns resulted in no significant difference. We used parameters reported by \citep{Liu2016}, namely 10 topics and 0.65 as the threshold.}
\begin{tabular}{lcccc} \hline
& \multicolumn{4}{c}{Number of topics} \\
Threshold & 5 & 10 & 15 & 20 \\ \hline
0.55 & 39.7\% & 38.6\% & 38.3\% & 38.5\% \\
0.65 & 36.0\% & 38.6\% & 38.3\% & 38.9\% \\
0.75 & 31.9\% & 30.3\% & 36.4\% & 39.3\% \\ \hline
\end{tabular}
\label{tab:lda_parameters}
\end{table}
\section{Discussion}
In Figure~\ref{fig:example_4methods}, the formulaic expression candidates extracted by all the methods we tested are depicted.
It was found that the proposed method extracted shorter formulaic expressions than the others did, which implies that it removed non-formulaic words more thoroughly, resulting in better performance.
In Figure~\ref{fig:proposed_method}, the relationships between $\alpha$ and MAP scores are illustrated.
The peak of the performance of the proposed method, NER+depparse, is at $\alpha=0.9$.
Thus, although it achieved the best performance among other methods, the proposed method missed some formulaic words.
Without dependency-structure-based word selection, the MAP score was 39.8\%, which is higher than that of the LDA-based method (38.6\%) but lower than that of the proposed method (42.2\%).
Therefore, the word selection method worked well to remove non-formulaic words that were not removed by simply applying named entity removal.
We have two types of named entities: general named entities with the CoNLL04 dataset \citep{Roth2004} and scientific entities with the SciERC dataset \citep{Luan2018}.
The MAP score of NER was 39.8\%, but without CoNLL04 dataset, the performance reduced to 39.7\%.
Although the difference was small, it can still be said that both types of named entities worked complementarily.
\begin{figure}[t]
\centering
\includegraphics[scale=0.75]{Fig11.pdf}
\caption{Relationships between MAP and $\alpha$. The peak of the proposed method (NER+depparse) is at $\alpha=0.9$.}
\label{fig:proposed_method}
\end{figure}
\section{Conclusion}
There exists a problem that formulaic expressions appear in a sentence with different spans and forms, which has brought difficulty to the extraction and evaluation of formulaic expressions.
To alleviate this problem, we presented the idea that a sentence can be split into a formulaic expression that conveys a communicative function and non-formulaic part that expresses content.
With this approach, formulaic expressions with different spans and forms can be dealt with.
Based on this formulation, we proposed an extraction and evaluation method for formulaic expressions.
Our extraction method consists of named entity removal and dependency structure-based word selection and it achieved the best performance compared to other existing methods.
Our evaluation method adopts the sentence retrieval task as a means of extrinsic evaluation, which measures the strength of the connection between formulaic expression candidates and communicative functions.
We experimentally demonstrated that the proposed evaluation method worked well by evaluating formulaic and non-formulaic expressions.
This work can be utilised to create lists of formulaic expressions automatically, which will accelerate multi-disciplinary academic writing assistance.
We hope that this work will promote research on formulaic expressions in natural language processing and the applied linguistic community.
\section*{Acknowledgements}
This work was supported by JSPS KAKENHI Grant Numbers 19J12466 and 18H03297 and by Atlanstic 2020 sabbatical grant IKEBANA.
| {'timestamp': '2020-06-19T02:10:40', 'yymm': '2006', 'arxiv_id': '2006.10334', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10334'} | arxiv |
\section{Introduction}
\label{sec:intro}
\paragraph{Problem.}
In black-box testing, the internal structure of the system under test,
including its hardware and the algorithms and data structures
implemented, are unknown to the tester. The need for black-box
testing arises when testers have no access to, or auxiliary
information about, the system under test, other than what they
can observe by interacting with the system over its interface, e.g.,
by providing the system with inputs and observing
its outputs.
Despite the simplicity of the black-box setting and the manifest
importance of testing in general, the theory of black-box testing is
under-developed and a solid understanding of its strength and
limitations is lacking. For instance, it is commonly agreed upon that
the purpose of testing a system with respect to a requirement is to
refute the hypothesis that the system satisfies the
requirement~\cite{dijkstra70,myers11}. Yet existing testing theory is
inadequate for answering basic questions in the black-box setting such
as: which class of requirements are refutable, given a class of tests?
Or, which class of tests, if any, can refute a class of requirements?
We develop a theory of black-box testing that explicates what can be
determined about systems by observing their behavior. Our theory
fully characterizes the class of refutable and verifiable
requirements. This means it precisely specifies for which system
requirements the violation (respectively satisfaction) can, or cannot,
be demonstrated through black-box tests.
Establishing the limits of testing this way is analogous to
establishing elementary results in complexity theory that delimit the
boundaries of effective computation. Moreover, our theory helps
testers understand the consequences of implicit assumptions they may
be making when carrying out tests, for example, that systems are
deterministic. Our theory also provides a foundation for bridging
results in testing with related disciplines.
\paragraph{Approach.}
We start with an abstract model of systems and requirements
(\S\ref{sec:refut}) and introduce two types of requirements: obligations
and prohibitions (\S\ref{sec:reqtype}). A requirement is an obligation
if it obliges the systems to exhibit certain (desired) behaviors, and it
is a prohibition if it prohibits the systems from exhibiting (undesired)
behaviors. Here, a behavior could be, for example, sets of input/output
pairs, or sets of traces. Functional requirements are typically
obligations, and security requirements are, by and large,
prohibitions. We show that these two requirement types admit a
straightforward order-theoretic characterization. Namely, given a
refinement (or abstraction) partial-order on a set of systems, the
satisfaction of an obligation is abstraction-closed, and for a
prohibition it is refinement-closed.
We turn next to black-box tests (\S\ref{sec:bbt}). Given a black-box
system, the tester can observe its input and output, but cannot
observe \emph{how} the latter is produced from the former. The tester
can therefore analyze such a system only by interacting with it over
its interface, and not by, for example, analyzing its software. In
black-box testing, sometimes called ``testing by
sampling''~\cite{dijkstra70}, testing amounts to inspecting a sample
of system behaviors. The sample obtained through tests can be seen as
a refinement of the system under test, a notion we make precise in
subsequent sections. All a tester learns by sampling is that the
system exhibits certain behaviors. From this, the tester cannot infer
that the system does not exhibit other behaviors as well. Such a
conclusion could only be justified through the sample's
exhaustiveness, which black-box testing alone cannot establish. A
requirement is therefore refutable through tests if, for any system
that violates the requirement, the hypothesis that the system
satisfies the requirement can be refuted by inspecting a refinement of
the system.
It follows that a requirement whose violation is contingent upon
demonstrating the absence of behaviors cannot be refuted through
black-box testing. Based on this, we prove that any refutable
requirement is a prohibition, and all non-trivial obligations are
irrefutable (\S\ref{sec:refreq}). We then define the notion of
verification dual to refutation, and show that any verifiable
requirement is an obligation and that non-trivial prohibitions cannot
be verified through tests (\S\ref{sec:verif}).
The theory sketched above is aimed to delimit the scope and reach of
black-box testing in general. However, it does not account for two
central limitations of black-box tests in practice: testing must proceed
in a finite amount of time, and test oracles must be computable. We
specialize our theory to accommodate these limitations. Namely,
we introduce the notions of \emph{finite refutability} (and dually
\emph{finite verifiability}), and characterize the class of finitely
refutability (verifiable) requirements (\S\ref{sec:temporal}). Our main
result here relates finitely refutable temporal requirements to safety
properties and hyper-safety hyper-properties. We further specialize
the theory by considering the case when test oracles are constrained to
be computable (\S\ref{sec:alg}). We use this specialization to separate
properties that are refutable from those that are enforceable by runtime
monitoring.
While \S\ref{sec:temporal} and \S\ref{sec:alg} pertain to
specializations of our black-box testing theory, in \S\ref{sec:aux} we consider a
generalization: testing in the grey-box setting where testers may have
partial information about the system under test. It is not surprising
that access to auxiliary information can enlarge the set of refutable
requirements. Our main result here is to show that refutation with the
help of auxiliary information can be reduced to the task of refuting a
prohibition. This result further illustrates the tight connection between
prohibitions and refutability mentioned above. We also use this generalization
to explicate the assumptions that are implicit in
several well-known testing techniques (\S\ref{sec:practice}).
Overall, we present a basic theory for reasoning about the strength
and limitations of black-box testing. Our theory is abstract and
has minimal formal machinery, which makes it easy to extend. We
present specializations and generalizations that account for refutation in
finite time, refutation under computational constraints, and
refutation aided by auxiliary information. We use these to prove new
results and to obtain known results as special cases, as
explained in the following.
\paragraph{Contributions.}
Our first contribution is the theory sketched above. We use it to
fully characterize the requirements that can be refuted and those that
can be verified through black-box tests.
Our proofs are short; they often amount to simply
unrolling definitions. This suggests that our theory is at the
right level of abstraction for reasoning about black-box tests, a
claim which is further supported by observing that the theory lends
itself to direct, straightforward extensions, as discussed
above.
Our second contribution is to show how our theory can be used to
derive both known and new results in a straightforward way. In
particular, we present different applications of our theory of finite
refutability (\S\ref{sec:temporal}). For instance, we demonstrate
that the finite falsifiability of hyper-safety temporal
requirements established by Clarkson and Schneider~\cite{DBLP:journals/jcs/ClarksonS10}
can be derived as a special case in our theory. As
another example, we use our characterization to separate refutability
from enforceability: we show that any enforceable temporal requirement
is refutable, but refutable requirements need not be enforceable.
This separation hinges upon analyzing the
computational constraints of refutation (and enforcement) via a notion
of algorithmically refutable requirements (\S\ref{sec:alg}). Moreover,
the abstract nature of our theory allows us to establish connections
between algorithmic refutability, topology, and recursion theory.
Our third contribution is to use our characterization of refutability
through black-box tests to augment and shed light on the folkloric
understanding of testing that exists in the community. As an example,
consider Dijkstra's statement that ``program testing can be used to
show the presence of bugs, but never to show their absence'', which is
widely quoted in software testing community. We make precise a
stronger version of this statement, and show that its proof is
independent of the cardinality of the input domain, i.e., the number
of test cases one must consider. Moreover, we use our
characterization to rectify the folklore surrounding Dijkstra's
statement, for example, that testing can never be used to establish
that a system satisfies a requirement. As a second example, we
highlight the fundamental role that determinacy assumptions play in
making sense of day-to-day black-box functional tests
(\S\ref{sec:aux}). In particular, we examine three prominent testing
techniques, namely functional testing, model-based testing, and fuzz
testing, in light of our theory, and explicate their implicit
assumptions (\S\ref{sec:practice}).
We discuss other related work in~\S\ref{sec:relwork} and conclude by
discussing the limitations of our theory in~\S\ref{sec:conc}.
Parts of the work described here were published
in~\cite{DBLP:conf/atva/DashtiB17}. The current article extends this
previous work with additional technical details, examples, and
explanations, pertaining to the notions of refutability,
verifiability, and black-box testing. Moreover, the notion of
refutability under auxiliary assumptions (\S\ref{sec:aux}) as well as
the systematic review of testing practice (\S\ref{sec:practice}) are
entirely new.
\section{Systems and Requirements}
\label{sec:refut}
We give a simple abstract model of systems and requirements, the main
ingredients of our theory.
A system is an entity that is capable of exhibiting
observable behaviors. Operating systems, digital circuits and vending
machines are all examples of systems. We keep the notion of an
observable behavior unspecified for now and instead work with systems
as a set of objects with an associated partial order. Namely,
let~$\Sys$ denote the nonempty set of all systems under consideration,
which is our domain of discourse. We assume that~$(\Sys,\preceq)$ is
a partially-ordered set (poset), where~$\preceq$ denotes a refinement
relation:~$S_1\preceq S_2$ means that~$S_2$ exhibits all the behaviors
of~$S_1$. In this case, we say system~$S_1$ {\bf refines}
system~$S_2$, or system~$S_2$ {\bf abstracts} system~$S_1$.
There exists a large body of research on refinement and abstraction;
see for instance~\cite{DBLP:conf/lics/AbadiL88,morgan,glabbeek90}.
Examples of refinement relations include trace containment and various
algebraic simulation relations. In the interest of generality, we do
not bind~$\preceq$ to any particular relation. We write~$\ceiling{S}$
and~$\floor{S}$ respectively for the set of systems that abstract a
system~$S$ and those that refine it: $\ceiling{S}=\{S'\in
\Sys\mid S\preceq S'\}$ and~$\floor{S}=\{S'\in \Sys\mid
S'\preceq S\}$. We assume that the poset~$(\Sys,\preceq)$ is
bounded: it has a greatest element~$\top$ and a least element~$\bot$.
The ``chaos'' system~$\top$ (sometimes called the ``weakest''
system~\cite{unifying}), abstracts every system, and the ``empty''
system~$\bot$ refines every system in~$\Sys$. In short, our
{\bf system model} is a four-tuple~$(\Sys,\preceq,\bot,\top)$.
We remark that $\top$ and $\bot$ are fictitious entities in the sense
that there is no need to construct them. We will use $\top$
to reason about the testers' epistemic limitations. In contrast,
$\bot$ is, strictly speaking, not necessary for our theory's
development. We introduce it for the sake of symmetry and
as a shorthand for ``empty'' systems.
We extensionally define a {\bf requirement} to be a set of systems. A
system {\bf satisfies} a requirement~$R$ if it belongs to~$R$. For
example, the requirement stipulating that systems are deterministic
consists of all the deterministic systems in $\Sys$. For now, we need
not expound on the satisfaction relation between systems and
requirements; we will give examples later. We write~$\chi_R$ for a
requirement~$R$'s characteristic function, which maps~$\Sys$ to
$\{0,1\}$. A requirement~$R$ is {\bf trivial} if all or none of the
systems in $\Sys$ satisfy it, i.e.~$\chi_R$ is a constant function iff
$R$ is trivial.
It is immediate that~$(\mathcal{R},\subseteq)$ is a complete lattice,
where~$\mathcal{R}$ is the set of all requirements and~$\subseteq$ is the standard set
inclusion relation. We define the {\bf
conjunction} of two requirements~$R_1$ and~$R_2$, denoted~$R_1\wedge
R_2$, as their meet, and their {\bf disjunction}, denoted $R_1 \vee
R_2$, as their join. For a nonempty set~$R$ of systems, we
write~$\ceiling{R}=\bigcup_{S\in R}\ceiling{S}$
and~$\floor{R}=\bigcup_{S\in R}\floor{S}$. A set~$R$ is {\bf
abstraction-closed} if~$R=\ceiling{R}$, and {\bf refinement-closed}
if~$R=\floor{R}$. Such a set is called an upper set, and respectively,
a lower set in order theory.
\section{Requirement Types}
\label{sec:reqtype}
We define obligations and prohibitions, and prove a lemma that
separates these requirement types (\S\ref{sec:oblpro}). Afterward, we
characterize the requirements that can be expressed as the conjunction
of an obligation and a prohibition (\S\ref{sec:semi}). Finally, we
present an intuitive interpretation of obligations and prohibitions
as, respectively, lower-bounds and upper-bounds on system behaviors
(\S\ref{sec:interp}).
\subsection{Obligations and Prohibitions}
\label{sec:oblpro}
A requirement is an obligation if it obliges the systems to exhibit
certain (desired) behaviors, such as intended
functionalities and features. For example, a requirement for a
database system obliges it to provide the user with an option to
commit transactions. This requirement cannot be violated
by adding behaviors to the system, for example by providing the user
the option to review transactions. The satisfaction of an
obligation~$R$ is therefore abstraction-closed:~$\forall S,
S'\in\Sys.\ S\in R\ \wedge\ S\preceq S'\ \to\ S'\in R$.
A requirement is a prohibition if it prohibits the systems from
exhibiting certain (undesired) behaviors. For instance, consider the
requirement that prohibits a database system from committing malformed
transactions. This requirement cannot be violated by
removing behaviors from the system, for example removing the option
for committing transactions altogether. That is, the satisfaction of
a prohibition~$R$ is refinement-closed: $\forall
S,S'\in\Sys.\ S\in R\ \wedge\ S'\preceq S\ \to\ S'\in R$.
Rewriting the previous two formulas gives us the following definition.
\begin{definition}
\label{def:obl-proh}
A requirement~$R$ is an {\bf obligation} if~$R=\ceiling{R}$, and~$R$
is a {\bf prohibition} if~$R=\floor{R}$.
\end{definition}
The following example illustrates the system model
of~\S\ref{sec:refut},
obligations, and prohibitions. The example also introduces the {\bf
extensional input-output} system model $\eio{}$, which we use
throughout the paper. This model highlights two features of interactive
systems that (1) distinguish between inputs and outputs,
and (2) react to any input, either by producing an output
(including undesired ones, such as throwing an exception or crashing)
or by diverging, i.e.\ not terminating.
\begin{example}
\label{eio-def-ex}
Consider the system
model~$(2^{\nat\times\nat},\subseteq,\emptyset,\nat\times\nat)$, where
a system is extensionally defined as a subset of~$\nat\times\nat$,
with~$\nat$ being the set of natural numbers, and the refinement
relation is the standard subset relation. For an input~$i\in\nat$, a
system~$S$ produces an output~$o$, non-deterministically chosen from
the set~$\{n\in\nat\mid (i,n)\in S\}$, and it does not produce any
outputs when~$\{n\in\nat\mid (i,n)\in S\}$ is empty. We call this
system model~$\eio{}$. Note that, due to its extensional definition,
this model makes no distinctions between two systems that define the
same subset of $\nat\times\nat$ but are otherwise different, e.g., one
of them runs faster than the other.
The requirement~$P$ stipulating that systems are deterministic is a
prohibition: if~$S$ is deterministic, meaning~$\forall
i\in\nat.\ |\{n\in\nat \mid (i,n)\in S\}|\le 1$, then so is any
refinement, i.e.\ subset, of~$S$. In particular, the empty system
satisfies the definition of determinacy.
The requirement~$O$ stipulating that systems define total relations is
an obligation: if~$S$ is total, meaning~$\forall
i\in\nat.\ |\{n\in\nat \mid (i,n)\in S\}|> 0$, then so is any
abstraction, i.e.\ superset, of~$S$. In particular, $\top$ is total.
The requirement~$R$, stating that systems extensionally define total
functions, is clearly neither a prohibition nor an obligation:
from~$\forall i\in\nat.\ |\{n\in\nat \mid (i,n)\in S\}|=1$ we cannot
conclude that an arbitrary subset or superset of~$S$ defines a total
function. Note that~$R=O\wedge P$.~\eoe
\end{example}
Two remarks are due here. First, Definition~\ref{def:obl-proh}
qualifies the relationship between a requirement's
satisfaction and the notion of refinement. Analogous formulations are
found, for example, in logic. A satisfiable sentence remains
satisfiable after enlarging the set of models, whereas a valid
sentence remains valid after reducing the set of models.
In this sense, obligations resemble satisfiability, and prohibitions resemble
validity.
Second, syntactically reformulating a requirement's description does
not affect its type. For example, the prohibition stating that
\emph{systems may not produce two (or more) different outputs for any
input} can be syntactically reformulated as \emph{systems may
produce at most one output for each input} without affecting its
type. The latter formulation permits, and the former forbids, certain
behaviors. As a second example, the requirement $F$
that forbids ``doing nothing'' is abstraction-closed, simply because all systems
except $\bot$ satisfy $F$. That is, $F$ is an obligation, in spite of
the term ``forbid'' appearing in its statement. In short, the
syntactic disguise of a requirement plays no role in determining its
type.
We now separate obligations and prohibitions by showing that a
nontrivial requirement cannot belong to both these types.
A requirement~$R$ is an obligation iff~$\chi_R$ is monotonically
increasing in~$\preceq$, that is,~$S\preceq S'\to \chi_R (S)\le
\chi_R(S')$. Similarly,~$R$ is a
prohibition iff~$\chi_R$ is monotonically decreasing, that
is,~$S\preceq S'\to \chi_R(S')\le \chi_R(S)$. Therefore, any
requirement that is both an obligation and a prohibition must have a
constant characteristic function and hence is trivial. The following
lemma is now immediate.
(See Appendix~\ref{app-proof} for all proofs.)
\begin{lemma}
\label{lem:distinct}
If a requirement~$R$ is both an obligation and a prohibition, then~$R$
is trivial.
\end{lemma}
This lemma implies that a prohibition cannot be replaced with an
obligation and vice versa. For example, the prohibition \emph{smoking
is forbidden} has no equivalent obligation, and the obligation
\emph{sacrifice a ram} has no equivalent prohibition. The lemma does
not however imply that obligations and prohibitions exhaust the set of
requirements. A {\bf non-monotone} requirement, i.e.\ one
whose characteristic function is neither monotonically increasing nor
monotonically decreasing, is neither an obligation nor a
prohibition. For instance, the requirement~$R=O\wedge P$, defined in
Example~\ref{eio-def-ex}, is neither an obligation nor a prohibition,
as it is not monotone.
Many practically-relevant requirements turn out to be the conjunction
of an obligation and a prohibition, similarly to~$R$ above. We
generalize this to the notion of semi-monotonicity.
\subsection{Semi-Monotonicity}
\label{sec:semi}
A requirement is {\bf semi-monotone} if it is the conjunction of two
(or more) monotone requirements. In~\S\ref{sec:refreq} we show that,
when it comes to refutability, a semi-monotone requirement behaves
like a monotone one, but only for \emph{some} systems. This motivates
studying semi-monotonicity.
Semi-monotonicity is strictly weaker than monotonicity. Consequently,
obligations and prohibitions are (trivially) semi-monotone, but a
semi-monotone requirement need not belong to either of these types. The
following lemma states that obligations and prohibitions, closed under
conjunction, are necessary and sufficient for expressing all
semi-monotone requirements. Note that, due to the idempotence
of~$\ceiling{\cdot}$ and~$\floor{\cdot}$, $\ceiling{R}$ is an
obligation and $\floor{R}$ a prohibition for any requirement~$R$.
\begin{lemma}
\label{lem:semi}
A requirement $R$ is semi-monotone iff $R = \ceiling{R} \wedge
\floor{R}$.
\end{lemma}
Although semi-monotonicity holds for many requirements, not all
requirements are semi-monotone, as the following example illustrates.
\begin{example}
\label{ex:zigzag}
Consider the~$\eio{}$ model and the requirement~$R$ that is satisfied
by a system~$S$ if for each $(i,o)\in S$ there exists some $(i', o)\in
S$, with~$i\neq i'$. This requirement, which can be seen as a
simplified form of a~$k$-anonymity requirement~\cite{sweeney}, states
that by solely inspecting a system's outputs, an observer cannot
determine whether or not the input is some particular~$i\in\nat$.
Consider the ascending chain of systems $S_0\preceq S_1\preceq
S_2\preceq\cdots$, where $S_0=\{(0,0)\}$, and
$S_j=S_{j-1}\cup\{(j,o)\}$, where~$o=j/2$ if~$j$ is even,
and~$o=(j-1)/2$ otherwise.
That is,~$S_1=S_0\cup\{(1,0)\}$,~$S_2=S_1\cup\{(2,1)\}$, and so forth.
Note that~$S_j$ satisfies~$R$ iff~$j$ is odd, with~$j\in\nat$. The
diagram below illustrates~$\chi_R$ with respect to the systems'
indices in the chain.
\begin{center}
\begin{tikzpicture}
\draw[line width=.24mm] (0,0) -- (0,0.8);
\node [above] at (0,.8) {\footnotesize{$\chi_R$}};
\draw[line width=.24mm] (0,0) -- (2.8,0);
\node [right] at (2.8,0) {\footnotesize{$\nat$}};
\draw[dotted] (0,.5) -- (3,0.5);
\node [left] at (0,0.5) {\footnotesize{1}};
\node [below] at (0,0) {\footnotesize{0}};
\draw (.5,0) -- (.5,.1);
\draw (1,0) -- (1,.1);
\draw (1.5,0) -- (1.5,.1);
\draw (2,0) -- (2,.1);
\draw (2.5,0) -- (2.5,.1);
\node [below] at (0.5,0) {\footnotesize{1}};
\node [below] at (1,0) {\footnotesize{2}};
\node [below] at (1.5,0) {\footnotesize{3}};
\node [below] at (2,0) {\footnotesize{4}};
\draw[fill=black] (0,0) circle (.07);
\draw[fill=black] (.5,.5) circle (.07);
\draw[fill=black] (1,0) circle (.07);
\draw[fill=black] (1.5,0.5) circle (.07);
\draw[fill=black] (2,0) circle (.07);
\draw[fill=black] (2.5,0.5) circle (.07);
\end{tikzpicture}
\end{center}
It is easy to check that on any chain~$S_0\preceq S_1 \preceq \cdots$,
a monotone requirement's characteristic function changes its value at
most once. A semi-monotone requirement's characteristic function
changes at most once from 0 to 1, and at most once from 1 to 0. From
the zigzagging~$\chi_R$ of the above diagram, it is evident that~$R$
is not semi-monotone.
Alternatively, note that $\ceiling{R}\wedge \floor{R}=\Sys\neq
R$, and hence $R$ is not semi-monotone due to
Lemma~\ref{lem:semi}.~\eoe
\end{example}
We conclude this section by remarking that semi-monotonicity is
invariant under conjunction: $\bigwedge_{R\in \rho} R$ is
semi-monotone for any nonempty set~$\rho$ of semi-monotone
requirements (see the appendix for details).
This justifies the practice of piece-wise specification of
(semi-monotone) requirements, e.g.\ one for negative integers and one
for non-negative ones, and then combining them with conjunction.
Note however that semi-monotonicity is not an invariant under
disjunction because \emph{any} nonempty requirement~$R$ is the
disjunction of (infinitely many) semi-monotone requirements:
$R=\bigvee_{S\in R}\ceiling{S}\wedge \floor{S}$.
\subsection{Lower-Bound and Upper-Bound Interpretations}
\label{sec:interp}
Here we present an intuitive interpretation of obligations and
prohibition that we illustrate using the $\eio$ model. In the
$\eio{}$ model, an obligation~$O$ is a set of systems that can be
characterized also by a set of desired behaviors. Any violation
of~$O$ is therefore due to the behaviors that~$S$ lacks. Consequently,
$O$ can be seen as a lower-bound for the set of~$S$'s behaviors.
Similarly,~$S$ satisfies a prohibition~$P$ iff the set of behaviors
of~$S$ is contained in the set of behaviors~$P$ permits. Any violation
of~$P$ is therefore due to excessive behaviors of~$S$. In this
sense,~$P$ gives rise to an upper-bound for the set of~$S$'s
behaviors.
\begin{example}
\label{ex:ooi}
Consider the $\eio{}$ system model, and the obligation~$O$ stating
that a (non-deterministic) system~$S$
must produce $i+1$ as one of its possible outputs for every even input~$2i$.
Then, $S\in O\ \leftrightarrow\ F\subseteq S$, where
$F=\{(2i,i+1)\mid i\in \nat\}$.
Now, consider the prohibition~$P$ stating that a system may only
output~$i+1$ for an even input~$2i$, and for odd numbers the system
never outputs~0. Then, $S\in P\ \leftrightarrow\ S\subseteq G$, where
$G=F\cup\{(2i+1,o+1)\mid i,o\in\nat\}$.
We can now express the satisfaction relation between~$S$
and~$R=O\wedge P$ as $S\in R\ \leftrightarrow\ F\subseteq S\subseteq
G$. A system violates~$R$ iff it lacks a behavior of~$F$, or it
exhibits a behavior outside~$G$.~\eoe
\end{example}
\begin{figure}[t]
\begin{center}
\begin{tikzpicture}
\draw[pattern=north east lines, pattern color=gray] (1.4,-1.2) -- (3.2,-1.2) -- (3.2, .2) -- (1.4, .2);
\draw[fill=white] (-3.4,-1.2) -- (1.4,-1.2) -- (1.4,.2) -- (-3.4,.2) -- (-3.4,-1.2) ;
\draw (-.4,-.4) ellipse (1.6 and 0.3);
\draw [line width = .3mm] (-1.4,.1) -- (2.4,0.1) -- (0.2,-1.1) -- (-1.4,.1);
\draw (-1.2,-.4) circle (.08);
\draw [fill=black](1.6,-.14) circle (.08);
\node [above] at (2.4,-1.2) {\footnotesize Prohibited};
\node [above] at (-2.6,-1.2) {\footnotesize Permissible};
\node [above] at (0.3,-0.7) {\footnotesize Obligatory};
\node [above] at (0.2,-1.1) {\footnotesize{$S$}};
\end{tikzpicture}
\end{center}
\caption{The set of all behaviors is partitioned into the set of
prohibited behaviors, represented by the hatched area, and the
set of permissible ones, represented by the white box. The set of
obligatory behaviors, represented by the oval, is included in the
set of permissible behaviors. The triangle stands for a
system~$S$'s behaviors. The white circle represents a violation of
the obligation denoted by the oval, and the black circle represents
a violation of the prohibition depicted by the hatched area.}
\label{fig:pos-neg-ex}
\end{figure}
The diagram of Figure~\ref{fig:pos-neg-ex} illustrates the lower-bound
and upper-bound interpretations, where the oval is the lower-bound and
the white box is the upper-bound on system behaviors.
A similar figure is given
in~\cite{fuzzing-book}.
Two remarks are due here. First, interpreting
prohibitions as a set of prohibited behaviors leads to a natural
definition of permissible behaviors. Namely, the set of {\bf
permissible behaviors} complements the set of prohibited ones,
cf.\ deontic logic~\cite{deontic}. To avoid inconsistency, all
obligatory behaviors must be permissible, but not all permissible
behaviors need be obligatory. Consequently, the set of permissible
behaviors for a system, delimited by the prohibitions, does not
necessarily coincide with its set of obligatory behaviors, as
illustrated in Figure~\ref{fig:pos-neg-ex}.
Second, a requirement $R$ that is not semi-monotone does not admit the
lower-bound and upper-bound interpretations: a system may violate $R$
even when it is bounded from below and from above by systems that
satisfy $R$. As Example~\ref{ex:zigzag} shows, $S_1\in R$, $S_3\in R$,
and $S_1\preceq S_2 \preceq S_3$ do not entail $S_2\in R$.
\section{Black-Box Tests}
\label{sec:bbt}
Recall that a system is a black-box if we can observe its input and
output, but cannot observe how the latter is produced from the former.
In black-box testing, a tester can only interact with the system over
its interface. We now characterize this in our system model. We
start by defining a test setup, which enables us to distinguish system
behaviors from what a tester observes.
Let~$(\Sys,\preceq,\bot,\top)$ be a system model. By sampling the
behaviors of a system~$S\in\Sys$, a tester makes an {\bf
observation}. We do not further
specify observations. We give examples shortly. A {\bf test setup} is
a pair~$(T,\alpha)$, where~$T$ is a domain of observations
and~$\alpha: \Sys \to 2^T$ is an {\bf order-preserving} function,
i.e.,~$S\preceq S'\ \to\ \alpha(S)\subseteq \alpha(S')$.
Intuitively,
the set~$\alpha(S)$ consists of all the observations that can be made
by testing a system~$S$ in this test setup and a black-box test
simply amounts to making an observation from this set.
Since~$\alpha$ is
order-preserving, if~$t$ belongs to $\alpha(S)$ for some system~$S$,
then~$t\in\alpha(S')$ for any system~$S'$ that abstracts~$S$. This
reflects the nature of black-box testing where analyzing a system~$S$
``by sampling'' amounts to inspecting a sample of~$S$'s
behaviors~\cite{dijkstra70}. Therefore, if an observation can be made
on~$S$ by inspecting the behaviors $S$ exhibits, then the same
observation can also be made on any system~$S'$ that abstracts~$S$,
simply because~$S'$ exhibits all of~$S$'s behaviors. We illustrate
these notions with an example.
\begin{example}
\label{ex:cir}
Consider the $\eio{}$ system model and the test
setup~$\mathbf{T}_r=(\Sys,\floor{\cdot})$, where a tester may observe
an arbitrary refinement of the system under test. Note that~$\floor{\cdot}$ is order-preserving
and hence~$\mathbf{T}_r$ is a test setup. The subscript $r$ indicates
\emph{reflexivity}: a system $S$ is itself a legitimate observation on
$S$ in the test setup $\mathbf{T}_r$. In Section~\ref{sec:refutbbt},
we explain reflexive test setups in detail.
Suppose a tester observes that a system~$S$ outputs 0 on input 0, and
1 on input 1. That is, the tester makes the
observation~$t=\{(0,0),(1,1)\}$ on~$S$, which is a refinement of $S$.
Clearly $\top$ could also
yield~$t$, simply because $t\in \floor{\top}$.~\eoe
\end{example}
We define the function~$\hat\alpha:T\to 2^\Sys$ to map
an observation to the set of systems that can yield that
observation. Formally,~$\hat\alpha(t)=\{S\in \Sys\mid t\in
\alpha(S)\}$, for any~$t\in T$. In black-box testing, a tester knows
nothing about the behaviors of the system under test beyond what is
observed by interacting with it. Therefore, all the tester can
conclude from an observation~$t$ is that the system under test can be
\emph{any} system that could yield~$t$. That is, solely based on an
observation~$t$, the tester cannot distinguish between the system
under test and any other system in~$\hat\alpha(t)$. We call
this the {\bf indistinguishability condition}.
The indistinguishability condition can be seen as providing an
epistemic basis for the standard structurally-oriented definition of
black-box testing given in the introduction.
In fact, the key observation enabling
our theorems on refutation and verification, given in the forthcoming sections,
is that test setups for black-box systems satisfy the
indistinguishability condition.
The indistinguishability condition delimits the knowledge a tester can
obtain through black-box testing. Suppose Ted (the tester) performs a
black-box analysis of a system $S$. Ted cannot distinguish $S$ from,
say,~$\top$, simply because~$\top$ abstracts every system. This
epistemic limitation is not alleviated by {\bf complete} tests:
regardless of whether or not Ted samples and analyzes all the
behaviors of~$S$ during testing, $\top\in\ceiling{S}$ is still true.
Rephrasing this in terms of system behaviors, black-box testing can
neither demonstrate the absence of behaviors nor the completeness of
an observation; otherwise, Ted could tell that the system under test
is not~$\top$, which exhibits all behaviors, thereby
distinguishing~$S$ from~$\top$. But, as just discussed, this falls
outside the scope of black-box testing.
\begin{example}
\label{ex:cir0}
Consider Example~\ref{ex:cir}. After observing $t=\{(0,0),(1,1)\}$, the
tester cannot conclude that~$S$ extensionally defines the identity
function. This is not surprising as~$S$ cannot be distinguished
from~$\top$ by observing~$t$ alone, and $\top$ does not define the
identity function. The same argument shows that the tester cannot
conclude that $S$ is deterministic.~\eoe
\end{example}
Note that the indistinguishability condition holds true regardless of
whether or not observations can be carried out in a finite amount of
time; we return to this point in~\S\ref{sec:temporal}. The condition
is also independent from the practical infeasibility of complete tests
(that complete tests are infeasible is demonstrated, e.g.,
in~\cite{kaner}). Moreover, whether the observations are actively
triggered by providing the system under test with selected inputs, or
they are obtained by simply monitoring the system's behaviors is
immaterial; we examine monitoring in~\S\ref{sec:refvsenf}.
We conclude this section with a remark: not all analysis techniques
are constrained by the indistinguishability condition and some,
therefore, can demonstrate the absence of behaviors. One example is
static analysis, which falls outside the scope of black-box testing as
it relies on a program’s source code as opposed to inspecting a sample
of the program's behaviors~\cite{nielson}. Similarly, a Fagan
inspection, based on structured reviews of source code and design
documents, is not black-box~\cite{fagan}. Both of these techniques
can indeed demonstrate the absence of system behaviors. We return to
the question of how our theory can be extended with additional
information, itself not discernible through black-box testing, in
\S\ref{sec:aux}.
\section{Refutable Requirements}
\label{sec:refreq}
We formally define the notion of refutability through black-box tests
and prove that any refutable requirement is a prohibition
(\S\ref{sec:refutbbt}). Afterward, we investigate the (ir)refutability
of two important classes of requirements: semi-monotone and
non-semi-monotone requirements (\S\ref{sec:semiref}).
\subsection{Refutability through Black-Box Tests}
\label{sec:refutbbt}
The purpose of testing a system with respect to a requirement is to
refute the hypothesis that the system satisfies the
requirement~\cite{popper,dijkstra70,myers11}. This is in practice
realized by finding a test case where the system does not produce the expected
output. But for which class of requirements do
such test cases exist?
We characterize below
the class of requirements that can be refuted using black-box tests.
We begin with an illustrative special case that
relates observations, which are refinements of
systems, with requirements, which are sets of systems.
Any system model~$\model=(\Sys,\preceq,\bot,\top)$ induces a {\bf
reflexive} test setup~$\mathbf{T}_r^\model=(\Sys,\floor{\cdot})$,
where each observation on a system~$S$ is a system in~$\Sys$ that
refines~$S$.
When~$\model$ is clear from the context, we simply
write~$\mathbf{T}_r$ for~$\model$'s reflexive test setup, as we did in
Example~\ref{ex:cir}. In a reflexive setup, testing a system~$S$
against a requirement~$R$ amounts to inspecting a refinement~$S_w$
of~$S$ to refute the hypothesis~$S\in R$. By merely observing~$S_w$,
with~$S_w\in \floor{S}$, the tester cannot distinguish~$S$ from any
other system that abstracts~$S_w$, due to the indistinguishability
condition. Therefore, the tester can infer~$S\not\in R$ after
observing~$S_w$ iff every system in~$\ceiling{S_w}$ violates~$R$.
Hence $R$ is refutable in a reflexive test setup if, for any~$S$ that
violates~$R$, there is at least one {\bf witness}
system~$S_w\in\floor{S}$ such that every system that abstracts~$S_w$
violates~$R$. That is,~$R$ is refutable in~$\mathbf{T}_r$
if\ $\forall S\in\Sys.\ S\not\in R\to\exists
S_w\in\floor{S}.\ \ceiling{S_w}\cap R=\emptyset$.
\begin{example}
\label{ex:sort}
Consider systems whose input and output domains are the set of lists of
natural number. Let $R$ be the requirement that
restricts the system's outputs to ascending lists. Suppose that a
system~$S$ violates~$R$. Then there must exist an input~$i$ for
which~$S$ produces an output list~$o$ that is not ascending. Let us
refer to the system that exhibits just this forbidden behavior
as~$S_w=\{(i,o)\}$. Clearly~$S_w$ refines~$S$, and any system that
abstracts~$S_w$ violates~$R$ by exhibiting the forbidden behavior.
Therefore,~$R$ is refutable in the test setup~$\mathbf{T}_r$.~\eoe
\end{example}
We generalize the above and define refutability in an arbitrary
test setup.
\begin{definition}
\label{def:refutable}
Let~$\mathbf{T}=(T,\alpha)$ be a test setup for a system
model~$(\Sys,\preceq,\bot,\top)$. A requirement~$R$ is {\bf
$\mathbf{T}$-refutable} if~$\forall S\in\Sys.\ S\not\in R\to
\exists t\in\alpha(S).\ \hat\alpha(t)\cap R=\emptyset$.
\end{definition}
Let~$R$ be a $(T,\alpha)$-refutable requirement. Then, for any
system~$S$, $S\not\in R\to\ceiling{S}\cap R=\emptyset$, simply
because~$\alpha$ is order-preserving. The contrapositive implies that
if~$S_1\in R$ and~$S_2\preceq S_1$, then~$S_2\in R$. That is,~$R$ is a
prohibition. The following theorem is now immediate.
\begin{theorem}
\label{thm:test-neg}
Any $\mathbf{T}$-refutable requirement is a prohibition.
\end{theorem}
We illustrate this theorem with a simple example.
\begin{example}
Consider the model where each system extensionally defines a binary
tree where each node is colored either red or black, and~$\preceq$ is
the subtree relation. The requirement~$R$ stipulates that the two
children of any red node must have the same color. Observing a
tree~$t$ in which a red node has a red child and a black child implies
that any tree that abstracts~$t$ violates~$R$. Therefore,~$R$ is
refutable in~$\mathbf{T}_r$, and it is a prohibition due to
Theorem~\ref{thm:test-neg}.~\eoe
\end{example}
The following lemma can be seen as a basic sanity check
on our definition:
if requirements are refutable, then so is their conjunction.
\begin{lemma}
\label{lem:compos}
Let $\rho$ be a nonempty set of $\mathbf{T}$-refutable
requirements. Then, $\bigwedge_{R\in\rho}R$ is $\mathbf{T}$-refutable.
\end{lemma}
Given a system model, we say a test setup~$\mathbf{T}_i$ is {\bf more
permissive} than a test setup~$\mathbf{T}_j$ if any
$\mathbf{T}_j$-refutable requirement is $\mathbf{T}_i$-refutable. The
following lemma along with Theorem~\ref{thm:test-neg} imply that, in
any system model, the reflexive test setup is the {\bf most
permissive} test setup.
\begin{lemma}
\label{lem:most-permissive}
In any system model~$\model$, any prohibition
is~$\mathbf{T}_r^\model$-refutable.
\end{lemma}
An intuitive account of this lemma is as follows. Any test
setup~$\mathbf{T}=(T,\alpha)$ induces a set of
obligations: $\mathcal{O}(\mathbf{T})=\{\hat\alpha(t)\mid t\in T\}$.
Testing a system~$S$ in~$\mathbf{T}$ amounts to the conclusion
that~$S$ satisfies an obligation that includes~$S$, namely the
obligation~$\hat\alpha(t)$, where~$t\in \alpha(S)$ is the observation
obtained through testing. Therefore, the smaller~$\hat\alpha(t)$ is,
the more we learn about~$S$ by observing~$t$; recall the
indistinguishability condition. For any system~$S$, the smallest
obligation in~$\mathcal{R}$ that includes $S$ is~$\ceiling{S}$, which
belongs to~$\mathcal{O}(\mathbf{T}_r)=\{\ceiling{S}\mid
S\in\Sys\}$.
We illustrate Lemma~\ref{lem:most-permissive} with an example from
temporal requirements.
\begin{example}
\label{ex:tmpdef}
To investigate temporal requirements, we model systems that induce
infinitely long sequences of events, such as operating systems, and
their requirements following~\cite{DBLP:journals/jcs/ClarksonS10}.
Let~$\Sigma$ be an alphabet, e.g.\ of events or states. We write
$\Sigma^\omega$ for the set of countably infinite sequences
of~$\Sigma$'s elements. A behavior is an element of~$\Sigma^\omega$
and a system is a set of behaviors. The complete
lattice~$(2^{\Sigma^\omega},\subseteq,\emptyset,\Sigma^\omega)$
instantiates our system model, defined in~\S\ref{sec:refut}.
A temporal property~$\phi$ is a set of behaviors. By overloading the
notion of satisfaction, we say a system~$S$ satisfies~$\phi$ if
$S\subseteq \phi$. That is, $\phi$ defines a refinement-closed
requirement: $R_\phi=\floor{\phi}$. Therefore, any property is a
prohibition, hence refutable in $\mathbf{T}_r$ due to
Lemma~\ref{lem:most-permissive}.~\eoe
\end{example}
We return to temporal requirements in~\S\ref{sec:temporal}, where we
show that $\mathbf{T}_r$ can be ``too permissive'' in some settings,
going beyond what is refutable in finite time.
As~$\mathbf{T}_r$ is the most permissive test setup, a
requirement that is irrefutable in~$\mathbf{T}_r$ is also irrefutable for
any test setup. Obligations are prominent examples of such irrefutable
requirements, as stated in the following lemma. The proof is immediate
by Lemma~\ref{lem:distinct} and Theorem~\ref{thm:test-neg}.
\begin{lemma}
\label{thm:pos-not-ref}
Nontrivial obligations are irrefutable in any test setup.
\end{lemma}
We illustrate this lemma with an example.
\begin{example}
\label{ex:precirc}
In the $\eio{}$ model, the obligation~$O$ stipulates that systems must
exhibit the behavior~$(1,0)$. Suppose Ted observes~$t=\{(1,1)\}$ while
testing a system~$S$. Based on $t$, he cannot refute the
hypothesis~$S\in O$, simply because~$\top$ also yields~$t$, and
$\top\in O$. Of course interpreting~$O$ as the requirement~$P$
stating that \emph{the system may output nothing but~0 for input~1}
results in a refutable requirement. But~$O$ and~$P$ are not
equivalent:~$O$ is an obligation and~$P$ is a prohibition; recall
Lemma~\ref{lem:distinct}.
Note that if it were known (through means outside black-box analysis)
that $S$ is deterministic, then observing~$t$ would justify the
conclusion~$S\not\in O$. We explicate the role of determinacy
assumptions in testing in~\S\ref{sec:practice}.~\eoe
\end{example}
We conclude this section with an intuitive account of (ir)refutability
based on Figure~\ref{fig:pos-neg-ex}. Recall that the figure depicts a
system $S$'s set of behaviors, and its obligation and prohibition,
which are both violated by $S$. To refute the prohibition's
satisfaction, one must locate the black circle in the figure. This is
achievable through black-box testing, which amounts to inspecting a
portion of the triangle (standing for $S$'s set of behaviors). To
refute the obligation's satisfaction, one must locate the white
circle, which lies outside the triangle. This is not achievable
through black-box tests because observations come only from the
triangle's interior.
Next, we turn to the irrefutability of semi-monotone requirements.
\subsection{The Irrefutability of Semi-Monotone Requirements}
\label{sec:semiref}
Every requirement~$R$ is either (1) semi-monotone, or (2)
not semi-monotone. In case (1), although~$R$ is irrefutable by
Theorem~\ref{thm:test-neg}, the violation of~$R$ can be demonstrated
through tests for \emph{some} systems. Recall Lemma~\ref{lem:semi}:
$R= \ceiling{R}\wedge \floor{R}$ for a semi-monotone $R$. Any
system~$S$ that violates~$\floor{R}$ violates~$R$ as
well, and black-box tests can demonstrate $S\not\in\floor{R}$.
\begin{example}
The non-monotone requirement~$R=O\wedge P$, defined in
Example~\ref{eio-def-ex}, is semi-monotone. It states that systems
must extensionally define a total function.
The system~$S=\{(0,n)\mid n\in\nat\}$ violates $P$, which states that
systems must be deterministic. Any observation that
demonstrates~$S\not\in P$ also demonstrates $S\not\in R$. Examples
include the observation $\{(0,1),(0,2)\}$ in $\mathbf{T}_r$. That is,
the hypothesis $S\in R$ can be refuted using tests that
refute $S\in P$.
Note the contrast to system $S'=\{(0,0)\}$, which violates $R$ but
satisfies $P$. No black-box test refutes~$S'\in R$, simply because it
would have to refute $S'\in O$, contradicting
Lemma~\ref{thm:pos-not-ref}. Recall that $O$ states that systems must
be total.~\eoe
\end{example}
In case (2), where~$R$ is not semi-monotone, it is possible that
testing cannot demonstrate $R$'s violation for \emph{any} system, as the
following example illustrates.
\begin{example}
\label{ex:infflow}
Consider Example~\ref{ex:zigzag}, and the requirement~$R$ defined
there: for each $(i,o)\in S$ there exists some $(i', o)\in S$,
with~$i\neq i'$. Let~$(T,\alpha)$ be a test setup.
Any observation~$t\in T$ obtained
by testing any system belongs to~$\alpha(\top)$, and~$\top\in R$. That
is, through black-box tests, we cannot distinguish any system
from~$\top$, which indeed satisfies~$R$. Therefore,~$R$'s violation
(for any system) cannot be demonstrated through tests in any test
setup.~\eoe
\end{example}
To summarize, a requirement is refutable through black-box tests iff
it is a prohibition. Nontrivial obligations are irrefutable, and so
are non-monotone requirements. However, the violation of a
semi-monotone requirements that is not monotone can be demonstrated
through tests, but only for some of the systems that violate them. It
is possible that the violation of the requirements that are not
semi-monotone cannot be demonstrated through black-box tests for any
system.\footnote{The reason for ``it is possible'' is that a
requirement that is not semi-monotone can have a semi-monotone
component. For instance, let~$R$ be a requirement that is
not semi-monotone and $\top\not\in R$. Define the prohibition
$P=\Sys\setminus \{\top\}$. Note that $R \wedge P=R$. Clearly
$\top\not\in P$ can be demonstrated through tests, thereby refuting
the hypothesis $\top\in R$.}
\section{Verifiable Requirements}
\label{sec:verif}
We define testing with the purpose of verifying the satisfaction of a
requirement as dual to testing for refutation.
\begin{definition}
\label{def:verif}
Let~$\mathbf{T}=(T,\alpha)$ be a test setup for a system
model~$(\Sys,\preceq,\bot,\top)$. A requirement~$R$ is {\bf
$\mathbf{T}$-verifiable} if~$\forall S\in\Sys.\ S\in R\to
\exists t\in\alpha(S).\ \hat\alpha(t)\subseteq R$.
\end{definition}
In particular, a requirement~$R$ is $\mathbf{T}_r^\model$-verifiable
in the system model~$\model=(\Sys,\preceq,\bot,\top)$ if\ $\forall
S\in\Sys.\ S\in R \to \exists S_w\in\floor{S}.\ \ceiling{S_w}\subseteq
R$. That is, if there exists a witness system~$S_w$ that refines~$S$
and any system that abstracts~$S_w$ satisfies~$R$, then by
observing~$S_w$ we have conclusively demonstrated~$S\in R$.
The following
theorem is dual to Theorem~\ref{thm:test-neg}.
\begin{theorem}
\label{thm:dual}
Any $\mathbf{T}$-verifiable requirement is an obligation.
\end{theorem}
An observation~$t\in\alpha(S)$ proves that the system~$S$ satisfies
the obligation $O=\hat\alpha(t)$. It also proves that $S\in R$ for any
requirement~$R\supseteq O$. Therefore, as $O$ becomes smaller, more
requirements are proved by the observation.
This explains why~$\mathbf{T}_r$ is the most permissive test setup for
verification: any~$\mathbf{T}$-verifiable requirement
is~$\mathbf{T}_r$-verifiable.
Consequently, a requirement that is not~$\mathbf{T}_r$-verifiable is
non-verifiable in any test setup.
Prohibitions are prominent examples of such non-verifiable
requirements, as the following lemma states.
\begin{lemma}
\label{lem:prohver}
Nontrivial prohibitions are non-verifiable in any test setup.
\end{lemma}
It is instructive to compare this lemma and Dijkstra's often-quoted
statement~\cite{dijkstra70} in the context of black-box testing
that ``program testing can be used to show the presence of bugs, but
never to show their absence.''
Dijkstra argues that programs have large,
typically infinite, input domains. It is intractable to test a
program's behavior for each input. It follows then that testing
cannot prove the absence of bugs, i.e.\ deviations from expected
behavior. Note the contrast to Lemma~\ref{lem:prohver}, which holds
even if a tester could run an infinite number of tests. As
discussed in~\S\ref{sec:bbt}, non-determinism poses an epistemic
limitation on what testing can achieve, regardless of the cardinality
of input domains and the number of tests we execute.
Contrary to the folklore, Lemma~\ref{lem:prohver}, and by extension
Dijkstra's statement, do not imply that no requirements are verifiable
through black-box tests.
For instance, the requirement that obliges a magic 8-ball to output
\emph{ask again later} is clearly verifiable through tests:
observing this output once demonstrates the obligation's satisfaction.
We further illustrate this point with an example from temporal
requirements.
\begin{example}
\label{ex:ctl}
Consider the system model of Example~\ref{ex:tmpdef}. Let~$e$ be an
element of $\Sigma$. The requirement~$R_e$ consists of the systems
that exhibit at least one behavior in which~$e$ appears.
Note that~$R_e$ is an obligation since its satisfaction is
abstraction-closed. Let $S \in R_e$. Observing a refinement~$S_w$
of~$S$ where~$S_w$ exhibits one behavior~$\pi$ in which~$e$ appears
demonstrates~$S\in R_e$: any abstraction of~$S_w$ exhibits~$\pi$ as
well, hence satisfying~$R_e$. We conclude that the obligation~$R_e$ is
verifiable through tests in~$\mathbf{T}_r$.~\eoe
\end{example}
We can now sharpen {\bf Dijkstra's dictum} to:
\begin{quote}
{\bf (D)}\quad Program testing can be used to show the presence of
behaviors, but never to show their absence, even if an infinite
number of tests were allowed.
\end{quote}
If a software \emph{bug} is a prohibited behavior, then {\bf (D)}
extends Dijkstra's statement, simply stipulating that prohibitions are
refutable, but not verifiable. However, if a \emph{bug} is the absence
of an obliged behavior, then {\bf (D)} translates to: program testing
can be used to show the absence of bugs, but never to show their
presence. This sentence unrolls to: program testing can be
used to show the presence of obliged behaviors, but never to show
their absence. In other words, obligations are verifiable, but not
refutable. That tests cannot show the absence of obliged behaviors has
tangible implications. For example, fuzz testing can hardly reveal
omission bugs, i.e.\ bugs due to developers' failure to implement a
desired feature or functionality~\cite{fuzzing-book}.
The folklore that testing is capable of refutation, but not proving
correctness, is sometimes held by members of the software testing community
and presumably reflects the wide-spread testing of prohibitions.
An example of this is the statement in \cite{Aichernig:2007}:
``Rather than doing verification by testing, a doubtful
endeavour anyway, here we focus on falsification. It is falsification,
because the tester gains confidence in a system by designing test cases
that would uncover an anticipated error. If the falsification fails, it
follows that a certain fault does not exist.''
But testing is not only a refutation technique: it is also a proof
technique, as it can prove that the system under test satisfies an
obligation, such as the one given in Example~\ref{ex:ctl}.
\section{Refutation in Finite Time}
\label{sec:temporal}
A requirement that is deemed refutable in our theory might not be
refutable in practice. For example, a requirement whose refutation
hinges upon measuring the exact momentum and position of a quantum
object is impossible to refute due to the laws of physics. This
limitation, not unexpectedly, does not follow from our theory
of black-box tests.
Below, we extend our theory to account for a
practically relevant limitation of system testing: we consider
refutation through black-box tests that proceed in a finite amount of
time. We define the notion of finite refutability (\S\ref{sec:finref}), and
illustrate it by characterizing finitely refutable temporal properties
and hyper-properties (\S\ref{sec:hyper}).
\subsection{Finite Refutability}
\label{sec:finref}
Intuitively, a test proceeds in a finite amount of time if
observations can be carried out in finite time.
This motivates the following definition.
\begin{definition}
\label{def:finref}
Let~$\mathbf{T}=(T,\alpha)$ be a test setup for a system model
$(\Sys,\preceq,\bot,\top)$. A requirement~$R$ is {\bf finitely
refutable} in $\mathbf{T}$ if
\begin{enumerate}[(i)]
\item $R$ is $\mathbf{T}$-refutable, and
\item every observation in~$\bigcup_{S\in\Sys}\alpha(S)$ can be
carried out in finite time.
\end{enumerate}
The notion of {\bf finite verifiability} is defined dually.
\end{definition}
Condition (ii) of Definition~\ref{def:finref} refers to the world:
determining whether an arbitrary observation can be carried out in
finite time falls outside our theory's scope, and this condition's
satisfaction must be substantiated by other means. Thus our theory
cannot establish a requirement's finite (ir)refutability unless
assumptions are made about what can be observed in finite time in the
world.
To illustrate Condition (ii), we consider a family of test setups for the
$\eio{}$ system model; a similar notion can be defined for other
system models. The {\bf family of test
setups}~$\mathbf{T}_k=((\nat\times\nat)^k,\alpha_k)$, with~$k\ge 1$,
and $\alpha_k$ maps system~$S$ to~$S^k$ and is inductively
defined by~$S^1=S$ and~$S^{k+1}=S\times S^{k}$. Clearly $\alpha_k$ is
order-preserving for any $k \in\nat$, and testing a system~$S$ in the
setup~$\mathbf{T}_k$ amounts to observing~$k$ input-output pairs
belonging to~$S$. We can now illustrate Condition (ii) as follows.
\begin{example}
\label{ex:tn}
Consider the $\eio{}$ system model, and assume that natural numbers
are observable in finite time. Then, observing any element
of~$(\nat\times\nat)^k$, where~$k\ge 1$ belongs to~$\nat$, takes
finite time. The requirement~$R_\nz$ stating that \emph{systems never
output zero} is, under this assumption, finitely refutable
in~$\mathbf{T}_1$.
Now consider the requirement~$R_\fz$, stating that \emph{systems may
output zero for at most finitely many inputs}. Note that~$R_\fz$ is
refutable in the reflexive test setup~$\mathbf{T}_r$, but not
finitely so, and moreover it is
not~$\mathbf{T}_k$-refutable for any~$k\ge 1$.
It now seems reasonable to conclude that~$R_\fz$ is not finitely
refutable: no finite set of behaviors can refute~$R_\fz$. This
conclusion does not however follow from our theory. To illustrate,
consider an alternative test setup~$\mathbf{T}=(\{*,\times\},
\alpha)$, where~$\alpha(S)=\{*\}$ if~$S$ outputs zero for finitely
many inputs, and~$\alpha(S)=\{*,\times\}$ otherwise. Since~$\alpha$ is
order-preserving,~$\mathbf{T}$ is formally a test setup. The
requirement~$R_\fz$ is finitely refutable in~$\mathbf{T}$, under the
assumption that $\alpha(S)$ is observable in
finite time. Whether this is a tenable assumption cannot be settled
inside our theory. Although~$\mathbf{T}$ hardly appears realizable,
such observations are possible in certain cases, for example by
measuring the electromagnetic radiation emitted from a black-box
system; see, e.g.,~\cite{Standaert:2009:UFA:1533674.1533709}.~\eoe
\end{example}
Although the satisfaction of Condition~(ii) cannot be
settled in our theory, this condition has implications
relevant to our theory: any test setup in which observations amount to
inspecting infinite objects cannot be used to show finite
refutability. For example, it follows that only finite portions of
finitely many system behaviors can be inspected for each observation,
even if those behaviors are not themselves finite objects. We
illustrate this point with an example.
\begin{example}
\label{ex:real}
Consider the system model~$(2^{\mathbb{R}\times\mathbb{R}}, \subseteq,
\emptyset, \mathbb{R}\times\mathbb{R})$, where~$\mathbb{R}$ is the set
of real numbers. This system model is similar to the~$\eio{}$ model
except its inputs and outputs are real numbers.
Define~$\prefix(r)$ as the set of finite truncations of the decimal
expansion of a real number~$r$. For
instance,~$\prefix(\sqrt{2})=\{1,1.4,1.41,1.414,\cdots\}$. Note that a
real number can have more than one decimal expansions, for example, 1
and $0.999\cdots$, but accounting for this point is unnecessary for
our discussion here.
We define the test setup~$\mathbf{T}=(\mathbb{F}\times\mathbb{F},
\alpha)$, where~$\mathbb{F}$ is the set of rational numbers that have
a finite decimal expansion and~$\alpha$ maps any system~$S$ to the
set~$\bigcup_{(i,o)\in S}\prefix(i)\times\prefix(o)$. An observation
of a system $S$ in this setup is a pair $(f_1, f_2)$, where $f_1$ is a
truncation of an input $i$ and $f_2$ is a truncation of an output $o$,
where $(i, o) \in S$. That is, we may observe only finite portions of
the decimal expansions of the inputs and outputs. If~$\mathbb{F}$'s
elements are observable in finite time, then any
$\mathbf{T}$-refutable requirement is finitely refutable.
Now consider the requirement $R_<$, stating that system outputs are
strictly smaller than $\sqrt 2$. Clearly $R_<$ is a prohibition, hence
$\mathbf{T}_r$-refutable. Define the system $S=\{(1,
1.4142\cdots)\}$, which outputs $\sqrt 2$, decimally expanded, for the
input 1. Even though $S$ violates $R_<$, no truncation of $S$'s
output's decimal expansion conclusively demonstrates this, because the
set of permissible outputs according to~$R_<$, namely $\{o
\in\mathbb{R}\mid o < \sqrt 2\}$, is not a closed set
in~$\mathbb{R}$'s standard topology. That is, there is a number,
namely $\sqrt 2$, that is arbitrarily close to the elements of this
set, but is not a member of the set. No finite truncation of this
number's decimal expansion can therefore conclusively determine
whether it is a member, or not. We conclude that $R_<$ is not
$\mathbf{T}$-refutable.
An analogous argument shows that the requirement $R_\le$ stating that
system outputs must be less than or equal to $\sqrt 2$ is
$\mathbf{T}$-refutable, and hence finitely refutable, because the set
of permissible outputs it induces, namely~$(-\infty,\sqrt{2}]$, is
topologically closed.~\eoe
\end{example}
The example hints at a fundamental connection between refutability and
topological closure when system behaviors are infinite sequences. This
connection was investigated by Alpern and Schneider in the
context of temporal properties~\cite{AlpernS85}, which we turn to next.
\subsection{Finitely Refutable Temporal Requirements}
\label{sec:hyper}
In this section, we characterize finitely refutable temporal
requirements. We start by extending the system
model~$(2^{\Sigma^\omega},\subseteq,\emptyset,\Sigma^\omega)$,
associated with temporal requirements (defined in
Example~\ref{ex:tmpdef}), with some additional temporal notions.
Let $\Sigma^*$ be the set of all finite sequences of $\Sigma$'s
elements. For a behavior~$\pi\in \Sigma^\omega$, we
write~$\prefix(\pi)$ for the set of all finite prefixes of~$\pi$, and
define the test setup~$\mathbf{T}_*$ as~$(T_*,\alpha_*)$, where~$T_*$
is the set of all finite subsets of~$\Sigma^*$, and~$\alpha_*(S)$ is
the set of all finite subsets of~$\bigcup_{\pi\in S} \prefix(\pi)$ for
a system~$S$.
Intuitively, any element of~$\alpha_*(S)$ is a possible observation
of~$S$, where finite prefixes of finitely many behaviors of~$S$ are
inspected. For any~$\mathbf{T}_*$-refutable requirement~$R$ and
any~$S\not \in R$, there exists a finite (witness) set~$t_w$ of finite
prefixes of~$S$'s behaviors such that any system~$S'$ that could have
yielded the observation~$t_w$, i.e.\ $t_w\in \alpha_*(S')$,
violates~$R$. Clearly, any~$\mathbf{T}_*$-refutable requirement is
finitely refutable, if elements of~$\Sigma$ can be observed in finite
time. Next, we relate~$\mathbf{T}_*$-refutability
and~$\mathbf{T}_*$-verifiability to the notions of temporal properties
and hyper-properties.
A temporal {\bf property} is a set of permissible
behaviors~\cite{pnueli,AlpernS85}, i.e.\ a subset of~$\Sigma^\omega$.
Any property~$\phi$ defines a prohibition, namely the
refinement-closed requirement $R_\phi=\floor{\phi}$ (recall
Example~\ref{ex:tmpdef}).
We illustrate this with an example.
\begin{example}
\label{ex:ltlvsctl}
Recall the requirement~$R_e$ from Example~\ref{ex:ctl}, consisting of
the systems that exhibit at least one behavior where~$e$ appears.
Since properties are prohibitions, this obligation
is not a property as otherwise~$R_e$ would have to
be trivial by Lemma~\ref{lem:distinct}.
As a side note, that~$R_e$ is not a property shows that $R_e$ cannot
be expressed as a formula in the linear-time temporal logic (LTL),
whose formulas define properties~\cite{pnueli}. Since $R_e$ is
expressed as~$\mathsf{EF}\ e$ in the computation tree logic CTL, we
can conclude the well-known result that LTL is \emph{not} more
expressive than CTL; for an introduction to CTL and its expressiveness
see~\cite{ctl-star}.~\eoe
\end{example}
We now turn to safety and liveness property types. We denote the
concatenation of an element of $\Sigma^*$ with one of $\Sigma^\omega$
by their juxtaposition. A property~$\phi$ is {\bf safety} if~$\forall
\pi\not\in \phi.\,\exists \sigma\in \prefix(\pi).\, \forall
\pi'\in\Sigma^\omega.\ \sigma\pi'\not\in \phi$ and {\bf liveness}
if~$\forall \sigma\in\Sigma^*.\exists \pi\in\Sigma^\omega.\ \sigma
\pi\in \phi$. That is, safety and liveness properties are closed and
dense sets, respectively~\cite{AlpernS85}.
The following lemma, whose proof hinges upon Lemma~\ref{lem:distinct}
and Theorem~\ref{thm:test-neg}, implies that nontrivial liveness
properties, although $\mathbf{T}_r$-refutable, are
not~$\mathbf{T}_*$-refutable; cf.~\cite{AlpernS85}.
\begin{lemma}
\label{lem:temporal}
A temporal property~$\phi$ is~$\mathbf{T}_*$-refutable iff~$\phi$ is
safety. Moreover, all temporal properties are
$\mathbf{T}_r$-refutable and any $\mathbf{T}_*$-verifiable property
is trivial.
\end{lemma}
Any property~$\phi$ is the conjunction of a safety property~$\phi_s$
and a liveness property $\phi_l$~\cite{AlpernS85}. Therefore, if a
system~$S$ violates $\phi_s$, then the hypothesis $S\in\phi$ can be
refuted through tests aimed at refuting $S\in \phi_s$. However,
if~$S$ violates only the liveness conjunct of $\phi$, namely $S\in
\phi_s$ and $S\not\in \phi_l$, then the hypothesis $S\in \phi$ cannot
be (finitely) refuted in $\mathbf{T}_*$, due to
Lemma~\ref{lem:temporal}. This is akin to the refutability of
semi-monotone requirements for \emph{some} systems, discussed
in~\S\ref{sec:refreq}. See also~\cite{approx,more}.
We now turn to hyper-properties. A {\bf hyper-property} is a set of
properties~\cite{DBLP:journals/jcs/ClarksonS10}, i.e.\ a requirement in
our model. A system~$S$ satisfies a hyper-property~$\mathbb{H}$,
if~$S\in \mathbb{H}$. In our setting, a hyper-property~$\mathbb{H}$ is
{\bf hyper-safety} \cite{DBLP:journals/jcs/ClarksonS10} if for
any~$S\not\in \mathbb{H}$, there exists an observation~$t\in \alpha(S)$
such that~$\forall S'\in\hat\alpha(t).\ S'\not\in \mathbb{H}$; It is
easy to check that a temporal requirement~$R$ is hyper-safety iff~$R$
is~$\mathbf{T}_*$-refutable.
Now it is immediate by Theorem~\ref{thm:test-neg} that any
hyper-safety requirement is a prohibition. Therefore, finitely
verifiable hyper-safety requirements must be trivial.
For instance, Example~\ref{ex:ctl}'s requirement~$R_e$, which is
clearly finitely verifiable in~$\mathbf{T}_*$, cannot be hyper-safety
and it is therefore not finitely refutable in~$\mathbf{T}_*$.
These results show how existing, specialized concepts and their
refutability follow as special cases of the notions we defined.
We revisit properties and hyper-properties in~\S\ref{sec:refvsenf}.
In light of this discussion, one
can see the test setup~$\mathbf{T}_k$, defined
in~\S\ref{sec:finref}, as the setup where a single observation is
carried out over $k$ copies of the system under test. As a side remark,
we note that for each $k$ there is a requirement that is
$\mathbf{T}_{k+1}$-refutable but not $\mathbf{T}_k$-refutable. That
is, self-composing a system $k$ times, namely observing $k$ system
behaviors, is not sufficient for demonstrating that the system
violates the requirement. For example, sampling a curve three times
is not sufficient for refuting the requirement stating that the
curve is a circle: there is a circle that passes any three points on
the plane. Sampling the curve four times could however refute this
particular requirement.
\section{Refutability through Algorithmic Means}
\label{sec:alg}
A {\bf test oracle} for a requirement $R$ is a (partial) decision
function that given an observation on a system decides whether the
system violates $R$. Our definition of finitely refutable
requirements poses no constraints on their test oracles. In
particular, whether an observation demonstrates a violation of a
finitely refutable requirement need not be decidable. Such
``undecidable'' requirements are uncommon in testing
practice. However, we show that explicating the computational
constraints of refutation not only clarifies the limits of algorithmic
testing (\S\ref{sec:algref}), it also sheds light on the
relationship between refutation through testing and enforcement
through monitoring (\S\ref{sec:refvsenf}).
\subsection{Algorithmic Refutability}
\label{sec:algref}
We start with two auxiliary definitions, and assume that the reader is
familiar with basic computability theory. For an introduction to this topic
see, e.g.,~\cite{rogers}.
Given a countable set~$U$, a set~$E\subseteq U$ is {\bf recursively
enumerable} if there is a (semi-)algorithm~$\mathcal{A}_E$ that
terminates and outputs \emph{true} for any input~$u\in U$ that is a
member of~$E$. If~$u\not\in E$, then~$\mathcal{A}_E$ does not
terminate.
Any requirement~$R$ induces a set~$\Omega_R$ of {\bf irremediable
observations}~$\{t\in T\mid \hat\alpha(t)\cap R=\emptyset\}$ in a
test setup~$\mathbf{T}=(T,\alpha)$.
It follows that a system~$S$ violates a~$\mathbf{T}$-refutable~$R$
iff~$\alpha(S)\cap \Omega_R\neq\emptyset$.
Intuitively, a requirement is algorithmically refutable
if it induces
a recursively enumerable set of irremediable
observations.
This is
because if a system~$S$ violates such a requirement~$R$
in~$\mathbf{T}$, then there is at least one observation~$t\in
\alpha(S)$ that can be made in finite time,
where~$\mathcal{A}_{\Omega_R}$ terminates on~$t$ and outputs
\emph{true}. Here, \emph{true} means~$t\in\Omega_R$,
demonstrating~$S\not\in R$. Observing such a~$t$ through testing,
therefore, conclusively refutes the hypothesis~$S\in R$.
\begin{definition}
\label{def:alg}
Let~$\mathbf{T}=(T,\alpha)$ be a test setup for a system model
$(\Sys,\preceq,\bot,\top)$. A requirement~$R$ is {\bf algorithmically
refutable} in $\mathbf{T}$ if~$R$ is finitely refutable
in~$\mathbf{T}$, and~$\Omega_R$ is a recursively enumerable subset of
the countable set~$T$.
\end{definition}
\noindent
Note that, from the standpoint of refutation, nothing is
gained by requiring the set $\Omega_R$ to be recursive
since determining that an element is not an irremediable observations does not contribute to
the requirement's refutation. It is therefore not necessary to
determine non-membership.
The following example illustrates Definition~\ref{def:alg}.
\begin{example}
In $\eio{}$, the prohibition~$P$ states that a system may never
output~$0$ for an odd input. Clearly, $P$ is~$\mathbf{T}_1$-refutable,
and its set of irremediable observations~$\Omega_P=\{\{(2i+1,0)\}\in
T_1\mid i\in\nat\}$ is recursive.
If natural numbers are observable in finite time, then~$P$ is
algorithmically refutable in~$\mathbf{T}_1$: any~$S$ that violates~$P$
induces an observation, for example~$t=\{(3,0)\}$, where a Turing machine
arrives at the verdict~$t\in \Omega_P$ in finite time.~\eoe
\end{example}
Let~$R$ be an algorithmically refutable requirement
in~$\mathbf{T}=(T,\alpha)$, and~$S$ be a system where~$\alpha(S)$ is a
recursively enumerable subset of~$T$. Note that, as previously
discussed, black-box testing cannot establish the absence of behaviors
in the system under test~$S$. Therefore, it is crucial that $\alpha(S)$
is recursively enumerable, but not, say, co-recursively enumerable or
recursive: these would imply that the tester could ``see'' absent
behaviors. The decision problem that asks whether~$S$ violates~$R$ is
semi-decidable, as the following test algorithm illustrates.
\begin{algorithm}[Test Algorithm]
\label{alg}
Fix an arbitrary total order on~$T$'s elements.
Dovetail~$\mathcal{A}_{\alpha(S)}$'s computations on the elements
of~$T$.\footnote{Dovetailing, which is a primitive parallelization
technique, proceeds in stages. Given an ordered list of inputs
$x_0,x_1,\cdots$, one step of computation is performed on $x_0$ in
stage 1. In stage $n+1$, we perform $n+1$ steps of the computations
for $x_0, \cdots,x_n$. In contrast to performing the computations on
$x_0$, and then on $x_1$, and so forth, the benefit of dovetailing
is the following: suppose the computation for $x_0$ never
terminates, whereas it terminates for $x_1$. Then, dovetailing's
parallelization ensures that in a finite amount of time the result
of the computation on $x_1$ becomes available.
As a side note, dovetailing a system $S$'s executions is not hindered by
$S$ being a black-box. To perform dovetailing, a tester merely needs a
mechanism for controlling the progress of $S$'s computations. For
example, when $S$ is given as a computer program, dovetailing can be
achieved by controlling the CPU cycles allocated to $S$'s
computations, which does not require inspecting the program's source
code.} In parallel, dovetail~$\mathcal{A}_{\Omega_R}$'s computations
on those observations for which~$\mathcal{A}_{\alpha(S)}$
terminates. Output \emph{true} and terminate, when a computation
of~$\mathcal{A}_{\Omega_R}$ terminates.
\end{algorithm}
The algorithm checks whether the intersection of two recursively
enumerable sets, namely $\alpha(S)$ and $\Omega_R$, is empty.
If~$S\not \in R$, then there exists at least one observation~$t_w$ in
the set~$\alpha(S)\cap\Omega_R$. The test algorithm is bound to
terminate on~$t_w$ and output \emph{true}, thus
demonstrating~$S\not\in R$ in finite time. However, if~$S\in R$, then
the test (semi-)algorithm does not terminate.
Algorithm~\ref{alg} achieves the (impractical) ideal of testing: it
not only has ``a high probability of detecting an as yet undiscovered
error''~\cite{myers11}, the algorithm is in fact guaranteed to reveal
flaws in any system that violates a requirement, if the preconditions
are met. In this sense, Algorithm~\ref{alg} demonstrates the limits of
algorithmic testing. We remark that although this algorithm is not a
recipe for testing practice, there are similarities. For instance,
standard test selection methods place likely witnesses of~$R$'s
violation early in the ordering assumed on~$T$~\cite{myers11}. This
would speed up Algorithm~\ref{alg} too.
We illustrate Algorithm~\ref{alg} with an example.
\begin{example}
Let $M$ be a Turing machine that is available to us as a black-box: we
may provide $M$ with an input $i$ and observe \emph{halt} if $M$ halts
on $i$. If $M$ diverges on $i$, then we observe no outputs.
In the $\eio{}$ model, the requirement~$R$ is defined as:~$S\in R$ if
for any~$(i,1)\in S$ the machine~$M$ diverges on the
input~$i$. It is easy to check that~$R$ is
$\mathbf{T}_1$-refutable, with $\mathbf{T}_1=(T_1,\alpha_1)$, and the
set~$\Omega_R$ is recursively enumerable: given an observation
$\{(i,1)\}$ in $T_1$, if $\{(i,1)\}\in \Omega_R$, then $M$ is bound to
halt on $i$.
Suppose that~$\alpha_1(S)$ is recursively enumerable for a
system~$S$. That is,~$\mathcal{A}_{\alpha(S)}$ is guaranteed to
terminate on any~$(i,o)\in S$. If~$S\not\in R$, then there is a
witness~$(w,1)\in S$ where~$M$ terminates on~$w$. Therefore,
dovetailing~$M$'s computations on~$i$ for all~$(i,1)$ on
which~$\mathcal{A}_{\alpha(S)}$ terminates is bound to exhibit a
terminating computation, thus demonstrating~$S\not\in R$ in finite
time.
Now consider the requirement~$U$ stating that a system may contain
$(i,1)$ only if $M$ halts on $i$. Clearly~$U$ is
$\mathbf{T}_1$-refutable. However,~$\Omega_U=\{\{(i,1)\}\mid i\in\nat,
M\ \mbox{diverges on}\ i\}$ is not recursively enumerable: $M$
produces no outputs for such an input $i$. This shows that $U$ cannot
be algorithmically refuted in $\mathbf{T}_1$.~\eoe
\end{example}
Next we apply the notion of algorithmic refutability to establish a
duality between refutation and enforcement in the context of temporal
requirements.
\subsection{Refutation versus Enforcement}
\label{sec:refvsenf}
It is easy to check that a safety property~$\phi$ is algorithmically
refutable in $\mathbf{T}_*$ iff~$\phi$'s set of {\bf irremediable
sequences}~$\nabla_\phi=\{\sigma\in \Sigma^*\mid \forall
\pi\in\Sigma^\omega.\ \sigma\pi\not\in \phi\}$ is recursively
enumerable.
This condition separates refutability from {\bf enforceability}, as
explained below. To enforce the safety property~$\phi$ on a
system~$S$, a reference monitor observes some~$t\in \alpha(S)$. If~$t$
demonstrates that~$S$ violates~$\phi$, then the monitor
\emph{stops}~$S$. Otherwise, the monitor \emph{permits}~$S$ to
continue its execution. For enforcement, the set~$\nabla_\phi$ must
therefore be recursive~\cite{Hamlen}.
It then follows that any enforceable temporal property is
algorithmically refutable. In contrast, any property~$\phi$, where~$\nabla_\phi$
is recursively enumerable but not recursive, is algorithmically
refutable, but not enforceable.
To further illustrate the relationship between refutability and
enforceability, we define {\bf weak enforceability} for a hyper-safety
requirement~$R$ as follows. By monitoring the executions of a
system~$S$, a monitor observes some~$t\in\alpha_*(S)$. If~$t$ does
\emph{not} conclusively demonstrate~$S\not\in R$,
then the monitor permits~$S$ to continue. However, if~$t$ does
conclusively demonstrate~$R$'s violation, then the monitor
may either stop~$S$, or diverge and thereby stall~$S$.
Recall that a system~$S$ violates a hyper-safety requirement~$R$
iff~$\alpha_*(S)\cap \Omega_{R}\neq\emptyset$.
To weakly enforce~$R$, the set~$\Omega_R$ must therefore be
co-recursively enumerable, i.e.~$T_*\setminus\Omega_R$ must be
recursively enumerable. This observation, which
concurs with~\cite[Theorem 4.2]{popl15}, illustrates that weak
enforceability and algorithmic refutability are complementary in the
sense that the former requires~$\Omega_R$ to be co-recursively
enumerable and the latter requires~$\Omega_R$ to be recursively
enumerable.
This duality between refutability and enforceability becomes evident
only after explicating the computational constraints of testing and
enforcement.
\section{Refutability under Auxiliary Assumptions}
\label{sec:aux}
Testers might have partial information about a black-box system. For
example, they might have knowledge that an otherwise black-box system
is deterministic. In this section we explore how black-box testing can
be augmented with such information. Strictly speaking, this topic
falls outside the black-box setting of~\S\ref{sec:refut}, where the
domain~$\Sys$ contains at least one non-determinism system,
namely~$\top$. Testing under auxiliary assumptions can in fact be
seen as a form of {\bf gray-box testing}, where testers know,
through means outside of black-box analysis, that a system's internal
operations are in some way constrained.
\subsection{Generalized Refutability}
We start by generalizing the definition of refutability to
\emph{refutability under auxiliary assumptions} since a tester's
partial information about the system under test can be modeled as
assumptions.
We define an {\bf assumption} as a set of systems. An assumption~$A$
is valid for a system~$S$, or $S$ satisfies $A$, if $S$ is included in
$A$. Clearly assumptions and requirements have the same type in our
model. However, in contrast to requirements, assumptions are in
general not subjected to analysis.
An assumption~$A$ about the system under test~$S$ can alleviate a
tester's epistemic limitation (rooted in the indistinguishability
condition). Namely, if $S$ is assumed to satisfy $A$, then from an observation
$t$ the tester can conclude that $S$ belongs to a subset of
$\hat\alpha(t)$, namely the subset that consists of the systems that
satisfy $A$. This motivates the following definition.
\begin{definition}
\label{def:refutunder}
Let $(\Sys,\preceq,\bot,\top)$ be a system model,
$\mathbf{T}=(T,\alpha)$ a test setup, and $A$ an assumption. A
requirement $R$ is $\mathbf{T}$-{\bf refutable under} $A$ if $\forall
S\in A.\ S\not\in R\ \to\ \exists t\in\alpha(S).\ (\hat\alpha(t)\cap
A)\cap R =\emptyset$.
\end{definition}
Note that letting $A=\Sys$ in Definition~\ref{def:refutunder}
results in Definition~\ref{def:refutable}. That is, refutability is a
special case of refutability under assumptions where no assumptions
are made about systems.
We illustrate Definition~\ref{def:refutunder} with an example.
\begin{example}
\label{ex:orefut}
Consider Example~\ref{ex:precirc}, where the obligation $O$ consists
of the systems that exhibit the behavior $(1,0)$. We define the
assumption $A$ as the set of total, deterministic systems, to reflect
the information that the system under test is known to be total and
deterministic.
The obligation $O$ is $\mathbf{T}_1$-refutable under $A$, simply
because any system that satisfies $A$ and violates $O$ must exhibit a
behavior $(1,i+1)$, with $i\in \nat$, due to totality. Observing such
a behavior demonstrates that the system does not exhibit $(1,0)$, due
to determinacy. Therefore the system violates $O$.
Clearly the above argument falls apart without the determinacy
assumption. To see why $A$'s totality conjunct is also necessary for
the argument, consider the deterministic system $S=\{(0,0)\}$, which
violates $O$ as well as the totality conjunct of $A$. No observation
in $\alpha_1(S)$ can demonstrate $S\not\in O$.~\eoe
\end{example}
Example~\ref{ex:orefut} shows that irrefutable requirements can be refuted if the
system under test is known to satisfy certain assumptions. This is
because an assumption $A$ reduces the set of the systems
that could have yielded a given observation. The smaller $A$ is, the
weaker the indistinguishability condition becomes. Note however that
the set of test subjects shrinks along with $A$: refutability under
$A$ pertains only to the systems in $A$.
The process of adding assumptions to obtain refutability does not
undermine Theorem~\ref{thm:test-neg}'s statement that prohibitions are
the only requirements that can be refuted through tests.
Theorem~\ref{thm:test-neg} is a special case of the following theorem
where $A=\Sys$: that \emph{any refutable
requirement is a prohibition} pertains to the special case where no
assumptions are made about systems.
\begin{theorem}
\label{thm:replace}
Let $\mathbf{T}=(T,\alpha)$ be a test setup, and $A$ an assumption.
If a requirement $R$ is $\mathbf{T}$-refutable under $A$, then there
exists a prohibition $P_{R\mid A}$ such that $\forall S\in
A.\ S\not\in P_{R\mid A} \leftrightarrow S\not\in R$. Namely,
$P_{R\mid A}=\floor{A\cap R}$.
\end{theorem}
\noindent This theorem implies that the task of refuting an (irrefutable) $R$
under $A$ can be reduced to the task of refuting the prohibition
$P_{R\mid A}$.
The following example illustrates
Theorem~\ref{thm:replace}.
\begin{example}
\label{ex:rgivena}
Consider Example~\ref{ex:orefut}. Note that $A\cap O$ consists of
deterministic total systems that exhibit the behavior $(1,0)$. We
define~$P$ as the requirement that forbids exhibiting any behavior
$(1,i+1)$, with $i\in\nat$. Roughly speaking, $P$ is found by adding
the closed-world assumption~\cite{Reiter} to $O$: the outputs not
obliged by $O$ are prohibited by $P$.
Below, we show $P$ is equal to $P_{O\mid A}$, when confining our
attention to the systems that satisfy $A$.
If a deterministic total system $S$ belongs to $P_{O\mid A}$, then $S$
belongs to $O$ due to Theorem~\ref{thm:replace}. That is, $(1,0)\in
S$. Then, due to $S$'s determinacy, no behavior $(1,i+1)$, with $i\in
\nat$, can belong to $S$. Therefore, $S\in P$.
If a deterministic total system $S$ belongs to $P$, then, due to its
totality and determinacy, $S$ must exhibit $(1,0)$. Therefore, $S\in
O$, and hence $S\in A\cap O$. This entails $S\in \floor{A\cap
O}$. That is, $S\in P_{O\mid A}$.
That $P = P_{O\mid A}$ further justifies the definition of $P_{R\mid
A}$, given in Theorem~\ref{thm:replace}: $P_{O\mid A}$ is indeed the
prohibition we try to refute when refuting $O$ under $A$.~\eoe
\end{example}
\subsection{Scope and Applications}
We discuss here the scope and possible applications of
Theorem~\ref{thm:replace}.
First, Theorem~\ref{thm:replace} implies that assumptions can
undermine the separation of
obligations and prohibitions that was presented in
Lemma~\ref{lem:distinct}. This is because, under assumptions,
obligations can be replaced with prohibitions and vice versa.
But this is not surprising
when a system's set of behaviors is known to be limited (assumptions
can reflect such limitations). For example, the obligation to turn
right at a crossroad prohibits turning left.
Second, the previous examples show that it is possible to refute
non-prohibitions under assumptions, such as totality and determinacy.
Such assumptions cannot be substantiated by testing, but may be
established using white-box techniques that analyze a system's
internal wiring or its source code.
Third, it is possible to refute
some non-prohibitions for some systems using purely
black-box analysis. Namely, we can use Theorem~\ref{thm:replace} to
reduce the testing of an irrefutable requirement $R$ to a black-box
refutation and a black-box verification.
For our reduction, Ted (the tester) first formulates an assumption~$A$
based on possibly unreliable information he has about the system under
test~$S$. Afterward, Ted tries to refute the hypothesis $S\in P_{R\mid
A}$. If this succeeds, then he has shown $S\not\in R$, if $S\in
A$. In case $A$ is verifiable through tests,
Ted tries to verify $S\in A$. If this succeeds as well,
then he has an unconditional proof of $S\not\in R$.
We illustrate this reduction with an example.
\begin{example}
\label{ex:combine}
In $\eio{}$, consider the requirement $R$ stating that if a system
exhibits the behavior $(1,0)$ then it should not output 0 for any
other odd input. Otherwise, it must output 0 for infinitely many
inputs.
Clearly $R$ is not a prohibition, hence it is irrefutable. We assume
the system under test~$S$ outputs 0 for input 1, and formulate the
assumption $A$ as the set of systems that exhibit $(1,0)$. The
prohibition $P_{R\mid A}$ then consists of the systems that do not
exhibit $0$ for any odd input larger than 1. We refute $S\in P_{R\mid
A}$ by observing, say, $\{(3,0)\}$ in the test setup $\mathbf{T}_1$.
Again in $\mathbf{T}_1$, we verify that $S$ exhibits $(1,0)$. If these
steps succeed, we obtain $S\in A$ and $S\not \in P_{R\mid A}$. These
together entail $S\not\in R$, due to Theorem~\ref{thm:replace}.
Note that, in accordance to the results of~\S\ref{sec:semiref},
testing can refute $R$'s satisfaction only for some systems that
violate $R$.~\eoe
\end{example}
Investigating practical applications of combining black-box refutation
with black-box verification, following the above reduction, remains as
future work. In~\S\ref{sec:practice}, we present other applications of
refutability under auxiliary assumptions.
Fourth, dual to Theorem~\ref{thm:replace}, assumptions can also
facilitate verification through black-box testing. For instance,
\emph{regularity} and \emph{uniformity} assumptions enable testers
to execute a limited number of tests and generalize their findings to
a large section of, or even the entire, input
domain~\cite{gaudel,survey}. These assumptions enable testers to
conclude that a system satisfies a requirement by observing the
system's behaviors for a limited set of inputs.
We conclude this section with a side remark.
We have previously explored the importance of determinacy assumptions, but
obviously determinacy cannot be assumed for systems that are
known to be non-deterministic. Weaker assumptions are needed for such
systems. For example, the \emph{complete test assumption} states that
there exists a number $n$ where if a test is executed $n$ times, then
all non-deterministic system behaviors are observed for that
particular test; see, for
instance,~\cite{CAVALCANTI20151,DBLP:journals/ipl/Hierons06}. This
assumption can be justified if there is a fairness constraint on
non-determinism, meaning that the system exercises all available
non-deterministic internal choices in a fair manner, e.g.~by
tossing a fair coin. The complete test assumption enables testers to,
in effect, treat a non-deterministic system as a deterministic one by
repeated testing.
\section{Testing Practice Revisited}
\label{sec:practice}
Below, we review three prominent testing techniques, namely functional
testing, model-based testing, and white-box fuzz testing, and
examine them in light of our theory. This review serves two
purposes. First, it demarcates the scope and reach of our
theory. Second, it illustrates the theory's applications.
For example, we explicate the implicit assumptions
upon which functional testing is typically based.
\paragraph{Black-box Functional Testing.}
Functional testing refers to testing functional requirements. A
requirement is deemed {\bf functional} if it prescribes a system's
desired functionality or features.
For example, a functional requirement states that systems must have a
feature where by entering a client's identification number, a system
user obtains the client's phone number.
Functional requirements generally correspond to obligations, which are
irrefutable.
\footnote{Here, we focus our attention on those requirements that
oblige a certain system functionality or feature. Functional
requirements that are not obligations, e.g.\ exception-freeness,
are exempt from our discussion. We remark that there is no canonical
definition of functional, as opposed to non-functional, requirements
in the literature~\cite{Glinz07}.}
Yet, functional testing is common
practice~\cite{pezze,myers11}. This seeming discrepancy can be
resolved by noticing that the practice of functional testing is based
upon (implicit) auxiliary assumptions, as the following example
illustrates.
\begin{example}
\label{ex:phone}
Consider the $\eio{}$ model. The functional requirements $R$ obliges
systems to output $p_c$ for input $c$, where $c$ is a client
identification number, and
$p_c$ is the client $c$'s phone number.
Testing $R$ in practice amounts to providing the system under test~$S$
with the input $c$. If $S$'s output differs from $p_c$ (crash is
one such output), then the tester concludes that $S$ violates $R$.
This conclusion is justified under the assumption that $S$ is
deterministic: only then observing any behavior other than $(c,p_c)$
demonstrates $S\not\in R$.
To make $R$ refutable, the totality assumption is also needed here;
recall Example~\ref{ex:orefut}.~\eoe
\end{example}
As the example suggests, assuming that the system under test is
deterministic facilitates refuting functional requirements.
The determinacy assumption is in fact implicit in much of testing
practice. For example, if a program passes the test that checks the
output when the input is the empty list, then most test engineers
would take this as a proof that the program behaves correctly on
empty lists. This reasoning hinges upon the assumption that the
program is deterministic, which may or may not be justified in the case
at hand.
We can now say that functional requirements are in practice refuted
under the implicit assumption of determinacy. That is, functional
requirements are taken to forbid all outputs other than those prescribed
for a given input. For
instance, in Example~\ref{ex:phone}, for the input $c$, any output
different from $p_c$ is forbidden. However, not all obligations admit
this interpretation, as the following example illustrates.
\begin{example}
\label{ex:slot}
Consider a coffee vending machine~$V$, and a slot machine~$S$.
Suppose that~$V$ is required to output a cup of coffee and~$S$ is
required to output a winning combination, after inserting a coin. Both
these requirements are obligations. We expect a coffee machine to be
deterministic, and therefore (implicitly) add to its obligation the
following requirement:~$V$ may exhibit no behavior other than
outputting coffee. This is a prohibition and can in fact be refuted.
A slot machine, in contrast, is non-deterministic. It would be absurd
to forbid~$S$ from exhibiting non-winning combinations. Hence, the
hypothesis that~$S$ satisfies its requirement remains
irrefutable through tests.~\eoe
\end{example}
The success of day-to-day functional testing indicates that assuming
determinacy is by and large justified in practice. Without explicating
such implicit assumptions, however, their existence and role remain
obscure. Moreover, only after explicating the determinacy assumption can
we see that functional tests that rely upon determinacy rely upon an
assumption that cannot be discharged through black-box analysis alone
(determinacy, being a prohibition, cannot be verified through
black-box tests). Therefore, either more powerful
techniques, such as white-box analysis, should be employed for
justifying determinacy, or test results should be presented along with
the untested assumption.
We conclude this discussion by remarking that categorically assuming
that testing only applies to deterministic systems is unjustified: it
excludes concurrent systems and those that interact with an
environment containing humans, quantum sensors, and hardware prone to
stochastic failures. Moreover, substantiating determinacy assumptions
is a formidable challenge in practice. For example, checking a
concurrent system's determinacy, even when the system's source code is
available, is hard; see,
e.g.,~\cite{DBLP:journals/cacm/BurnimS10}. This is because concurrent
systems behave differently in the presence of different
schedulers. Even if the system is amenable to white-box analysis, the
scheduler is typically either unavailable to testers or it is a
``black-box''. This substantially increases the complexity of finding
violations of requirements such as determinacy, atomicity, and
deadlock-freeness in concurrent systems. Indeed, several existing
test methods for concurrent systems rely on instrumenting the system
or the scheduler to tame non-deterministic behaviors \cite{carver91,heisenbug,preemption}.
\paragraph{Model-based Testing.}
In model-based testing, a system's obligations (and in some cases its
prohibitions) are represented as an
ideal model, for example by an extended state
machine~\cite{Utting:2006:PMT:1200168}. Refuting the hypothesis that
the system exhibits all the desired behaviors, specified by the model,
amounts to identifying a behavior in the model that is not exhibited
by the system. This conforms to the lower-bound interpretation of
obligations: to find the white circle in Figure~\ref{fig:pos-neg-ex},
one can explore the oval, which represents all the obligatory
behaviors, and check if the system lacks any of them. This is the
central idea of model-based
tests~\cite{DBLP:conf/fortest/Tretmans08,Utting:2006:PMT:1200168}.
The above account of model-based testing runs into a discrepancy
similar to the one raised by black-box functional testing: the tester
is provided with an ideal model for the system under test, but has no
reasons to believe that the system does not exhibit more behaviors
than those observed during testing. The resolution again lies in
explicating auxiliary assumptions. We illustrate this point with an
example.
\begin{example}
\label{ex:mbt}
This example is based on the test method described
in~\cite[Chapter~5]{Utting:2006:PMT:1200168}. Suppose the desired
behaviors for a system~$S$ are given as a deterministic finite-state
Mealy machine. At each state, the machine specifies the desired system
output for any input. It also specifies the system's next state, but
we ignore that part here. Suppose that the system's input domain
is~$\mathcal{I}$, and it is required to output some~$o_i$ for
input~$i$, with~$i\in \mathcal{I}$, at a certain state.
This requirement, which we call~$R$, is often implicitly interpreted
as a semi-monotone requirement~$O\wedge P$, where~$O$ obliges $S$ to
output~$o_i$ for input~$i$, and~$P$ prohibits $S$ from outputting
any~$o'\neq o_i$ for input~$i$ at that particular state.
Note that refuting~$S\in R$, under the assumption that~$S$ is
deterministic and total, is logically equivalent to refuting~$S\in P$:
if~$S$ violates~$P$, then it immediately violates~$R$. Conversely,
if~$S$ violates~$R$ because~$S\not\in O$, then~$S$ violates~$P$ as
well due to its determinacy and totality.
A tester can therefore focus on~$P$, which is indeed refutable through
tests; recall Theorem~\ref{thm:replace}.
The above reasoning is the basis of the test method prescribed
in~\cite{Utting:2006:PMT:1200168}: choose an execution of the Mealy
machine. If the system produces an input-output sequence different
from the one prescribed by the machine, then it violates its specified
requirement. Conversely, if the system violates the requirement, then
it is bound to deviate from the Mealy machine in at least one
execution.~\eoe
\end{example}
The example explicates the auxiliary assumptions that are necessary
for meaningful model-based testing in practice. Such assumptions are
given elsewhere in the literature in different contexts, see for
example~\cite{brucker13,survey,DBLP:conf/fortest/Tretmans08,Utting:2006:PMT:1200168}.
\paragraph{White-box Fuzz Testing.}
As illustrated in previous sections, black-box tests cannot establish
the absence of behaviors. This limitations applies to white-box fuzz
testing if the program source code is used only for generating test
inputs, as opposed to inferring the absence of behaviors. Namely,
after observing a set of behaviors, whose generation has been guided
by the source code, the tester is not justified in concluding that the
program exhibits no other behaviors. See,
e.g.,~\cite{KLEE,DBLP:journals/queue/GodefroidLM12}.
An analogous argument shows that unit testing, as in
JUnit~\cite{junit}, cannot establish the absence of behaviors if the
source code, although \emph{accessible} to testers, is not inspected
for demonstrating the absence of behaviors.
Fuzz testing is typically concerned with refuting generic
prohibitions, such as \emph{the system does not access unallocated
memory for any input}~\cite{fuzzing-book}. To refute such
requirements, a white-box fuzzing tool covers as exhaustively as
possible the program code of the system under
test~\cite{KLEE,DBLP:journals/queue/GodefroidLM12}. This conforms to
the upper-bound interpretation of prohibitions: to refute a
prohibition, one looks for a system behavior that is forbidden
by the prohibition. Returning to Figure~\ref{fig:pos-neg-ex}, one
explores the triangle (which represents the set of system behaviors)
to find the black circle where the triangle intersects with
the hatched area (forbidden behaviors).
The above line of reasoning also sheds light on the suitability of the
approximation techniques that are common in (white-box) static
program analysis. For example, a \emph{may} summary over-approximates
a program's set of behaviors~\cite{nielson}. If this does not contain
a set of obligatory behaviors, then the program violates the
corresponding obligation. Similarly, a \emph{must} summary
under-approximates a program's set of behaviors~\cite{nielson}. If
this intersects a set of prohibited behaviors, then the program
violates the corresponding prohibition.
Note that none of these approximations is immediately applicable to
refuting requirements that are not semi-monotone because such
requirements do not admit the lower-bound and upper-bound
interpretations, as discussed in~\S\ref{sec:reqtype}.
\section{Related Work}
\label{sec:relwork}
Testing is a broad domain. We group the most closely related work into
three areas, which we present below. This complements the related work
discussed in previous sections.
\paragraph{Refutability and Verifiability.}
Our definition of refutability is inspired by Popper's notion of
\emph{testable} theories~\cite{popper}. Theories of black-box testing
proposed in the software engineering literature are largely concerned
with the notions of test selection, test adequacy, and
exhaustiveness; see,
e.g.,~\cite{6312836,Weyuker,gaudel,DBLP:conf/fortest/Tretmans08,DBLP:journals/stvr/AiguierAGL16}.
Refutable requirements have not been investigated in prior work,
except for temporal properties and hyper-properties, which we
discussed in~\S\ref{sec:hyper} and~\S\ref{sec:refvsenf}.
Tests for \emph{verifying} the correctness of programs have been
studied in the literature; see, for
example,~\cite{howden78,budd80,Zhu97}. The correctness guarantees
that such tests provide are inherently different from the
verifiability of obligations (\S\ref{sec:verif}), as they are reliable
guarantees only when programs and their faults satisfy assumptions
that cannot be justified solely through black-box analysis.
Finally, tests for obtaining probabilistic correctness guarantees,
investigated for example in~\cite{focs94}, fall outside the scope of
this paper.
\paragraph{Obligations and Prohibitions.}
Obligations and prohibitions, as requirement types, implicitly appear
in various domains of software engineering. For example, Damm and
Harel introduce \emph{existential} charts for specifying the
obligatory behaviors of a system, and \emph{universal} charts for
specifying all the behaviors the system
exhibits~\cite{DBLP:journals/fmsd/DammH01}. An existential chart
intuitively corresponds to an obligation, and a universal chart
corresponds to a semi-monotone requirement in our theory, which is the
conjunction of an obligation and a prohibition. The notions of
necessity and possibility also have a central role in modal logic. For
example, Larsen and Thomsen's modal transition systems specify
obligations and prohibitions through, respectively, \emph{must} and
\emph{may} transitions~\cite{DBLP:conf/lics/LarsenT88}. Similarly,
Tretmans' testing theory~\cite{DBLP:conf/fortest/Tretmans08} is based
on specifications that define both a lower-bound and an upper-bound on
a system's behaviors, which roughly speaking correspond to,
respectively, obligations and prohibitions. These works define
prohibitions and obligations in concrete modeling formalisms. In
contrast, we present abstract definitions that can be instantiated by
the existing ones.
Finally, security requirements are sometimes called
\emph{negative}~\cite{mcgraw2006}
and \emph{universal}~\cite{tap2011}
because they do not endow a system with features and functions;
rather, they define the system's permitted behaviors. They are simply
prohibitions.
\paragraph{Testability.}
The notion of \emph{testability} is widely used in software
engineering. The IEEE glossary of software engineering
terminology~\cite{glossary} defines testability as: ``(1) The degree
to which a system or component facilitates the establishment of test
criteria and the performance of tests to determine whether those
criteria have been met. (2) The degree to which a requirement is
stated in terms that permit establishment of test criteria and
performance of tests to determine whether those criteria have been
met''. Condition~(1) qualifies systems, and condition~(2)
requirements. Our definition of refutability applies to
condition~(2). An instance of irrefutability due to failure to meet
condition~(1) is a system with unobservable error states. Such
considerations fall outside the scope of our theory, which is built
around observations.
\section{Concluding Remarks}
\label{sec:conc}
We have formalized a simple abstract model of systems and
requirements, upon which we have built a theory of testing. Our theory
is centered around elementary notions, such as satisfiability,
refinement, and observations, and it allows us to reason precisely
about the limits and methods of black-box testing. We have used it to
fully characterize the classes of refutable and verifiable
requirements for black-box tests. We have also clarified testing
folklore and practice. For example, we have shown that non-exhaustive
testing can be used to verify obligations. And methodologically it
becomes clear that functional requirements can be tested only based on
assumptions that are not themselves verifiable through black-box
tests.
Our focus has been on black-box testing, defined in a general way that
encompasses different concrete testing techniques, and its extension to
certain types of gray-box analysis. Naturally black-box tests can be
combined with other analysis techniques, like static analysis. The
indistinguishability condition of~\S\ref{sec:bbt}, stating that the
system under test can be any abstraction of an observation obtained
through tests, would then no longer be applicable. For instance, if
the system under test is known to be deterministic, then clearly more
requirements become refutable, as discussed in~\S\ref{sec:aux}. It is
not surprising that augmenting black-box analysis with knowledge that
itself cannot be verified through black-box tests expands the
analysis's capabilities. This paves the way for more powerful
refutation methods capable of refuting more requirements. Developing
such an extension of our theory, and exploring its
applications remain as future work.
We remark that our theory of black-box tests is not readily
applicable to probabilistic constraints. For example, a gambling
regulation requiring that slot machines have a 95\% payout cannot be
refuted through black-box test. Nevertheless, tests refuting such
probabilistic constraints with a controllable margin of error can be
devised. Developing a corresponding theory of tests and refutation
also remains as future work.
\bibliographystyle{plain}
| {'timestamp': '2020-06-19T02:12:42', 'yymm': '2006', 'arxiv_id': '2006.10387', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10387'} | arxiv |
\section{Background}
\label{sec:background}
\paragraph{Attention Mechanism}
\label{sec:limitselfattn}
Attention mechanisms were introduced as a supplement to encoder-decoder RNN architectures to address the problem of long-term dependencies between source and target tokens.
This serves a purpose similar to token alignments \cite{ibm}, used in statistical machine translation models.
Two varieties, Luong \cite{luong} and Bahndau \cite{bahndau} attention, take different approaches to combine alignment weights and a context vector to generate the next hidden token and/or an output token.
Vaswani et al. \cite{transformer} introduced a layered encoder-decoder architecture that relies only on \textit{self-attention} between layers and attention on the output of the encoder.
It uses scaled dot-product attention to obtain the context vector, where the scores are computed by dot-products of keys and queries.
\paragraph{Auto-encoder Language Model}
\label{sec:autolm}
A Transformer encoder is often sufficient for language understanding and generation tasks \cite{autoencoder}, which are often fine-tuned via transfer learning to solve NLP tasks.
Devlin et al. introduced BERT, which has a similar architecture but is pre-trained to learn bidirectional representations.
Based on the BERT architecture, recent models such as GPT-2 \cite{gpt2} and MegatronLM \cite{megatronlm} have achieved better performance by increasing the number of parameters by an order of magnitude.
On the other hand, models such as Albert \cite{albert} reduce the number of parameters while retaining performance.
XL-Net \cite{xlnet} integrates techniques from Transformer-XL \cite{tfxl} which tries to extend the context length of Transformer models using recurrence and relative positional encoding \cite{relativeposition}, and introduces a novel pre-training objective that permutes the input sequence.
It also incorporates a two-stream attention mechanism, consisting of a content stream identical to self-attention and a query-stream that does not have information about the current position.
\paragraph{Inductive Bias of Neural Network}
The parallel nature of the self-attention mechanism shortens its critical computation path length to $O(1)$, which enables efficient parallelism at the cost of losing the inductive bias.
In particular, the fact that Transformers cannot generalize learned algorithmic rules beyond observed context lengths has been proved theoretically \cite{theorylimit} and empirically \cite{numbersequenceprediction}.
Universal Transformer \cite{universaltransformer} tries to overcome this limit via repetition, but it shows limited generalization on algorithmic tasks.
Besides attention-based methods, many studies have tried to augment neural networks with external memory structures to learn and generalize algorithmic rules \cite{ntm, stackrnn, nueralgpu, dnc}, but they have not been proven to be effective at practical domains like NLP.
\paragraph{Recurrent Transformers}
Many recent papers have examined the incorporation of recurrence to Transformer models.
One such model is R-Transformer \cite{rtransformer}, which uses a series of \textit{LocalRNNs} where RNNs operate on a local window.
Other similar papers, such as \cite{arn}, add a distinct RNN separate from the Transformer model, piping its outputs to an attention layer.
The Highway Recurrent Transformer model \cite{highway} recurrently applies an attention mechanism to route information from previous tokens to the current one.
Recurrent Transformer models have also been introduced in domains such as computer vision \cite{rtn} and time series analysis \cite{tft} with similar results.
Such models, although incorporating recurrent components, do not enjoy the full benefits of recurrent models and their ability to extend their performance to longer sequences.
\section{Discussion}
In this section, we discuss possible issues that arise in the design and application of our model.
The first possible issue is that even though we extend the computation path of the Transformer architecture from $O(1)$, it is still limited to $O(n)$.
In fact, the computation path depends on the number of \textit{timesteps} $t$, which is proportional to the number of tokens $n$ in our sequence-to-sequence setup because we only allow one timestep per token.
If we can find a training scheme that allows multiple timesteps per token, the same architecture can be applied to tasks of any time complexity.
For instance, if we use our architecture along with reinforcement learning, it is possible to let the model take enough time to produce each output by allowing \textit{no-op} actions.
Another issue is that the model's inductive generalization accuracy degrades as we give longer input sequences.
So one can argue that the model does not truly inductively generalize because a human's inductive generalization capability does not degrade for longer context.
However, this is not a fair comparison because we need to \textit{write down} the symbols somewhere to extend the rules to arbitrary lengths.
If we solely rely on our memory to perform such generalization, our performance would degrade much faster than what we observe from \pname{}.
That is, we need to devise a reliable external memorization method, like memory-augmented neural networks (MANN), to achieve inductive generalization that does not degrade over longer contexts.
The final issue is that \pname{} outperforms the others only in character-level tasks so the practicality of our model is questionable.
However, advancements in character-level tasks~\cite{character-level-transformer} are possibly more important than improvements in word-level tasks.
Since word embeddings require a predetermined vocabulary, word-level models have a limited scope of applicability~\cite{liang2017combining}.
For example, it is impossible for a word-level model to process typoglycemia sentences like "Aoccdrnig to a rseearch taem at Cmabrigde" because the words will be translated to \textit{unknown} tokens.
Therefore, advancements in character-level tasks will greatly extend the scope of NLP applications of our model.
\section{Conclusion}
In this paper, we examined the generalization of Transformer models to context lengths unseen in training, which we refer to as inductive generalization.
We identified the limits of self-attention mechanisms to this problem, in turn evaluating a series of other common model architectures such as LSTM, BERT, and XLNet.
We proposed \pname{}, a novel Transformer architecture which replaces the positional encoding with a recurrent layer to overcome computational limits of self-attention.
Also, we defined inductive generalization task setups of number sequence prediction tasks and Penn Treebank masked language modeling tasks to check if a model truly extends its context length.
\pname{} outperforms state-of-the-art Transformers at algorithmic tasks and character-level language modeling tasks.
We demonstrated that \pname{} is capable of generalizing to unseen sequence lengths while maintaining a competitive space and time complexity.
\section*{Broader Impact}
Inductive generalization is one of the key challenges in implementing human-level artificial general intelligence.
For example, we are naturally capable of extending the Addition rule to arbitrarily long digits after learning rules for limited digit additions.
If we can make a breakthrough for achieving inductive generalization via deep learning, the finding can shed light on other fields studying human intelligence, including neuroscience, cognitive psychology, and linguistics.
These findings will significantly improve the understanding of inductive bias and further facilitate communication between two different groups and mitigate the social inequality caused by artificial intelligence. In particular, from an education perspective, it will provide quantifiable insights for educators to understand to what extent of knowledge students would be able to produce when given a certain amount of content. From an industry perspective, leaders and technicians will experience a clear agreement process by being provided with predictions and estimates automatically generated from inductive bias.
Unlike the number prediction dataset, however, any natural language dataset carries a challenge where it fails to include interests and conflicts from diverse societal representatives. In our setting, we took advantage of the number prediction dataset, which is relatively free from demographic bias \cite{socialimpact}. Since more investigation is needed to overcome demographic bias, we will keep exploring the difference between the number prediction dataset and the natural language dataset to find an objective model which most members of society can intuitively accept.
\begin{ack}
We would like to thank Julia Hockenmaier, Zhenbang Wang and our advisors Josep Torrellas, Wen-mei Hwu, Bertram Lud\"ascher and other anonymous reviewers for their helpful comments and feedbacks.
Vikram Sharma Mailthody was partly supported by Joan and Lalit Bahl Fellowship from University of Illinois.
Lastly, this work would not have been possible without the generous hardware donations from NVIDIA, AMD and the University of Illinois.
\end{ack}
\section{Experimental Result}
\label{sec:result}
\subsection{Experimental Setup}
\renewcommand{\arraystretch}{1.3}
\begin{table}[htbp]
\vspace{-3ex}
\caption{Baseline and \pname{} Model hyperparameters and parameter sizes used for experiments.}
\label{tab:modelparam}
\vspace{1ex}
\centering
\begin{tabular}{ lllll } \toprule
Model & \textbf{\#}Layers & \textbf{\#}Heads & Hidden Size & Param Size\\ \midrule
\pname{} (ours) & 12 & 12 & 768 & 69M\\
BERT~\cite{bert} & 12 & 12 & 768 & 71M \\
XLNet~\cite{xlnet} & 12 & 12 & 768 & 73M \\
LSTM seq2seq & 2 &1 &768 & 8M \\ \bottomrule
\hline
\end{tabular}
\vspace{-3ex}
\end{table}
\paragraph{Baseline models }
Since we follow a BERT-like architecture, we choose BERT-base and XLNet-base as baseline models for comparison.
Table~\ref{tab:modelparam} describes the hyperparameters used in the evaluation.
The parameter size overhead is marginal compared to the rest of the models as we only add a recurrent layer at the bottom.
We also compare with the LSTM seq2seq model with attention from the fairseq~\cite{fairseq} library as a baseline to show that our method outperforms traditional combinations of LSTM and attention.
The pre-trained models cannot be applied to our tasks, so we replicate the existing PyTorch implementations~\cite{huggingface} and train them from scratch.
Our implementations are publicly available on GitHub~\footnote{https://github.com/hwnam831/ibert}.
\paragraph{Controlled variables}
We train the baseline and \pname{} models using an Adam optimizer with the learning rate decay of 0.97 per epoch.
For NSP tasks, we train them for 50 epochs with an initial learning rate of 3e-5, and for both character-level and word-level masked LM tasks, we train them for 100 epochs with an initial learning rate of 1e-4.
To fit our NVIDIA Titan V GPU used for training, the batch sizes are set to 16 in character-level masked LM tasks, and 32 for the other tasks.
\subsection{Number Sequence Prediction Result}
\begin{figure}[htbp]
\vspace{-2ex}
\begin{subfigure}[b]{0.33\linewidth}
\centering
\includegraphics[width=1.0\linewidth]{figures/task1-fib.pdf}
\caption{Addition}
\label{fig:nsp_a}
\end{subfigure}%
\begin{subfigure}[b]{0.33\linewidth}
\centering
\includegraphics[width=1.0\linewidth]{figures/task1-copy.pdf}
\caption{Copy}
\label{fig:nsp_b}
\end{subfigure}%
\begin{subfigure}[b]{0.33\linewidth}
\centering
\includegraphics[width=1.0\linewidth]{figures/task1-palindrome.pdf}
\caption{Reverse}
\label{fig:nsp_c}
\end{subfigure}
\caption{Across all the different NSP tasks, \pname{} achieves SOTA accuracy.}
\label{fig:nsp_experiment}
\vspace{-2ex}
\end{figure}
The objective of the number sequence prediction experiment is to see if a machine learning model can extend learned algorithmic rules to unseen long inputs.
Figure~\ref{fig:nsp_experiment} shows validation sequence accuracy of the models when trained on sequences up to $k=12$ digits.
Although all models could achieve near 100\% sequence accuracy during training, most of them find it hard to generalize on out-of-distribution validation sets.
As shown in Figure~\ref{fig:nsp_a}, \pname{} is the only model that successfully extends the addition rule to longer input sequences, while other state-of-the-art Transformers completely fail to do so.
The result is expected given the nature of the carry rule in addition.
Because carry digits require at least $O(log(n))$ steps to be determined, it is impossible for typical Transformers with $O(1)$ compute paths to determine them.
Therefore, the only possible way for them to train is to memorize the specific rule for each observed length, which cannot be generalized to arbitrarily long inputs.
A similar pattern appears on simpler algorithmic tasks such as Copy and Reverse as seen in Figure~\ref{fig:nsp_b} and Figure~\ref{fig:nsp_c}.
The failures of BERT are expected because the encoded positions of longer parts of validation sequences cannot be observed during training.
The interesting result is that XLNet's relative positional encoding also finds it hard to generalize on validation sets, despite the claim that it can extend the Transformer's context lengths.
This can be explained by temporal distances between corresponding digits.
The relative temporal distance between corresponding digits becomes longer as we use longer digit sequences, but the relative positional encodings cannot resolve this if such long distances had not been observed during training.
On the other hand, \pname{}'s recurrent layer can encode such relative position information within a sequence as shown in Figure~\ref{fig:nsp_experiment}.
Comparisons with the LSTM seq2seq model proves that our architecture which combines self attention with an RNN is superior to the traditional combination of RNN and attention.
The LSTM seq2seq model fails to generalize on the addition task and, although it can achieve some generalization on the other tasks, its validation accuracy degrades faster than that of \pname{} for longer inputs.
Therefore, compared to the single-head content-based attention, we can conclude that the key-query-value mechanism and multi-head architecture of self-attention are beneficial for inductive generalization.
\begin{figure}[h!]
\vspace{-2ex}
\begin{subfigure}[b]{0.33\linewidth}
\centering
\includegraphics[width=1.0\linewidth]{figures/task2-5digit.pdf}
\caption{$k=2\dots5$}
\label{fig:ablation_a}
\end{subfigure}%
\begin{subfigure}[b]{0.33\linewidth}
\centering
\includegraphics[width=1.0\linewidth]{figures/task2-8digit.pdf}
\caption{$k=2\dots8$}
\label{fig:ablation_b}
\end{subfigure}
\centering
\begin{subfigure}[b]{0.33\linewidth}
\centering
\includegraphics[width=1.0\linewidth]{figures/task2-12digit.pdf}
\caption{$k=2\dots12$}
\label{fig:ablation_c}
\end{subfigure}%
\caption{Ablation study of \pname{} using addition tasks in different training and validation setups. $k=i\dots j$ means that the difficulties of the training set ranges from $i$ to $j$. \pname{}2 is an \pname{} model where every feed-forward layer is replaced by an LSTM layer.}
\label{fig:nsp_ablation}
\vspace{-2ex}
\end{figure}
We perform an ablation study to find the optimal design variant for \pname{}.
Our ablation study covers two variants: (1) the combination with the positional encodings, and (2) replacement of every feed-forward layers with an LSTM layer.
We perform the ablation study using NSP addition tasks and the results are shown in Figure~\ref{fig:nsp_ablation}.
As before, all models can achieve 100\% sequence accuracy during training.
From our study, we hypothesized that providing absolute position information to the architecture makes it harder to inductively generalize.
These results empirically demonstrate this hypothesis in that the addition of the positional encodings makes a model overfit to the training data.
Moreover, adding additional recurrent layers as in the case of \pname{}2 is not advantageous. %
Figure~\ref{fig:ablation_c} shows that \pname{} generalizes better if we provide longer sequences during training.
In contrast, \pname{}2, an \pname{} where all feed-forward layers are replaced by LSTM layers, shows an opposite trend.
It could not generalize well given longer training sequences, indicating that adding more recurrence makes the model weaker to longer sequence inputs.
Therefore, the proposed architecture is best performing implementation of \pname{} among the different variants we studied.
\subsection{Penn Treebank Masked Language Modeling}
\renewcommand{\arraystretch}{1.3}
\begin{table}[htbp]
\caption{Penn Treebank masked language model results. The models are evaluated by the metrics of training sequences per second (Seq/s), bits per character (BPC), and perplexity (PPL).}
\vspace{2ex}
\label{table:maskedlm}
\centering
\begin{tabular}{lllllllllll} \toprule
{} & \multicolumn{5}{c}{Character-level} & \multicolumn{5}{c}{Word-level} \\ \cmidrule(lr){2-6} \cmidrule(lr){7-11}
\multirow{2}{*}{Models} & \multirow{2}{*}{Seq/s} & \multicolumn{2}{c}{Training} & \multicolumn{2}{c}{Validation} & \multirow{2}{*}{Seq/s} & \multicolumn{2}{c}{Training} & \multicolumn{2}{c}{Validation} \\
\cmidrule(lr){3-4} \cmidrule(lr){5-6} \cmidrule(lr){8-9} \cmidrule(lr){10-11}
{} & {} & Acc & BPC & Acc & BPC & {} & Acc & PPL & Acc & PPL \\ \midrule
\textbf{\pname{}} (ours) & 72 & 0.44 & 1.46 & \textbf{0.32} & \textbf{2.07} & 343 & 0.58 & 6.86 & 0.32 & 21.02 \\
XLNet \cite{xlnet} & 35 & 0.36 & 1.81 & 0.30 & 2.10 & 217 & 0.58 & 5.22 & \textbf{0.39} & \textbf{14.05}\\
LSTM seq2seq & 200 & 0.35 & 1.97 & 0.30 & 2.16 & 1280 & 0.34 & 15.11 & 0.29 & 22.95 \\
BERT \cite{bert} & 88 & 0.10 & 2.69 & 0.08 & 2.77 & 394 & 0.57 & 5.31 & 0.25 & 34.43 \\ \bottomrule
\end{tabular}
\end{table}
The masked language modeling results in Table~\ref{table:maskedlm} show that \pname{} can be extended on the NLP tasks.
\pname{} outperforms both XLNet and BERT on the character-level task, while its performance lies between XLNet and BERT on the word-level task.
Considering that word-level tokenization makes the natural language sentences much shorter than character-level tokenization, it seems natural that inductive generalization does not play a key role in word-level tasks.
However, our architecture outperforms BERT in both tasks because BERT cannot handle masked tokens beyond the observed context lengths during training.
Since the performance overhead of our model is much smaller than the expensive two-stream attention and relative positional encoding of XLNet, our method is a cheaper alternative to overcome the limited context length of basic Transformers.
\section{Introduction}
Neural network models based on self-attention, known as Transformers ~\cite{attentionisalluneed, bert,transformer} have proven to be effective at natural language processing (NLP) tasks such as language modeling, translation, question-answering, and summarization.
Recent state-of-the-art NLP models are based on pre-trained Transformer encoders such as BERT~\cite{bert}, GPT-2~\cite{gpt2}, XLNet~\cite{xlnet}, RoBERTa~\cite{roberta}, and Megatron-LM~\cite{megatronlm}, which are trained by language modeling tasks.
Compared with the recurrent neural network (RNN) based models, Transformer models are easy to parallelize and are scalable, because parallel self-attention with positional encodings replaces sequential recurrent connections~\cite{transformer}.
This parallel nature of self-attention limits the observable context length of a Transformer to a fixed size.
Prior works have shown that Transformer models cannot generalize to inputs of longer lengths in algorithmic tasks that require inductive bias ~\cite{universaltransformer, theorylimit, numbersequenceprediction}.
Transformer~\cite{transformer} relies on the absolute positional encodings for locality, which cannot be generalized to arbitrarily long context lengths.
Approaches such as Transformer-XL~\cite{tfxl} and XLNet~\cite{xlnet} enable longer context lengths using the relative positional encodings.
Although they achieve state-of-the-art performance in NLP tasks, there is no proof that they can extend learned rules to unobserved longer inputs.
We define \textit{inductive generalization} to verify a model's capability of extending the rules to unobserved context lengths.
Inductive generalization requires a model to extend the rules learned during training to validation dataset of higher-dimensional samples.
Of course, this requires a change in the method one uses to sample training and validation sets.
Existing interpolation and extrapolation methods evaluate models on data that share the same sample space with the training data.
But for the case of inductive generalization, we need to split the data samples into a lower-dimensional training set and a higher-dimensional validation set based on the sequence length threshold $k$.
The two sets are mutually exclusive in that the lengths of the validation samples cannot be observed during training.
Successful inductive generalization means that the model infers the rule applicable to higher-dimensional spaces by only observing the samples from a lower-dimensional subspace.
Using the BERT~\cite{bert} architecture as a baseline, we first identify the computational limits of self-attention.
BERT uses absolute positional information and constant computation path~\cite{transformer}.
We hypothesize that these structural limits prevent the BERT model from achieving inductive generalization.
To resolve these limitations, we propose \textit{\pname}, an \textit{inductive} bi-directional Transformer that replaces the positional encodings with a recurrent layer.
The RNN layer allows an $O(n)$ computational path to determine sequential dependencies between tokens.
This replacement preserves the performance benefits of self-attention while enjoying the flexibility of RNNs.
To evaluate a model's performance on input lengths unseen during training, we use three algorithmic and two masked language modeling inductive generalization tasks.
Algorithmic tasks from number sequence prediction (NSP) problems~\cite{numbersequenceprediction} are ideal for evaluating inductive generalization as they allow flexible tuning of task difficulty via the number of digits.
For masked character-level and word-level language modeling tasks, we partition the Penn Treebank~\cite{penntreebank} dataset into the training and validation sets by their length to test inductive generalization.
We validate \pname{} on three algorithmic and two masked language modeling inductive generalization tasks.
The results show that \pname{} is the only model capable of generalizing to longer inputs on algorithmic tasks.
For the masked language modeling tasks, \pname{} outperforms the state-of-the-art (SOTA) models on the character-level task and comes close to the performance of SOTA XLNet in the word-level setup.
Even though \pname{} does not achieve SOTA on the word-level task, it overcomes BERT's limited context length with higher computational throughput compared to XLNet.
The contributions of this work are as follows:
\begin{itemize}
\item We formally introduce the problem of generalizing a model to unseen input lengths, which we refer to as \textit{inductive generalization}.
\item We propose \pname{}, an inductive bi-directional Transformer encoder that replaces positional encodings with a recurrent layer to overcome the computational limits of self-attention.
\item Out of three algorithmic and two natural language inductive generalization tasks, \pname{} achieves state-of-the-art results on four tasks.
\end{itemize}
\section{Inductive Generalization}
\label{sec:indgen}
\begin{figure}[ht]
\centering
\begin{subfigure}[b]{0.25\linewidth}
\includegraphics[width=\linewidth]{figures/interpolation.pdf}
\caption{Interpolation}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.25\linewidth}
\includegraphics[width=\linewidth]{figures/extrapolation.pdf}
\caption{Extrapolation}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.25\linewidth}
\includegraphics[width=\linewidth]{figures/indgen.pdf}
\caption{Inductive Generalization}
\end{subfigure}
\caption{Conceptual visualizations of how inductive generalization differs from other generalizations. The circles are training data points and the triangles are generalization targets.\vspace{-2ex}}
\label{fig:indgen}
\end{figure}
Generalization has always been a major issue in machine learning since models easily overfit the training data.
A common practice for resolving this is using a validation dataset independently drawn from the same training data distribution.
Formally, validation and training datasets $\boldsymbol{V},\boldsymbol{T}$ are drawn from the same data distribution $\mathcal{D}$ whose support\footnote{A set of points in the sample space with non-zero probabilities} is $\boldsymbol{D}$.
Since this method mostly verifies \textit{interpolation} (as in Figure~\ref{fig:indgen}a), there have been studies that test \textit{extrapolation} on an out-of-distribution set $\boldsymbol{O}$, of which most of the cases share the \textit{same sample space} as in Figure~\ref{fig:indgen}b.
However, one key aspect of human intelligence is that we can generalize symbolic rules learned from small dimensional samples to unbounded dimensions using induction.
For example, when we learn the addition rule of decimal digits, we first learn the carry rules for adding two or three-digit numbers.
Then, we can easily generalize the rule to longer decimal numbers whose dimensions can be arbitrarily large.
This kind of generalization is also important in natural language processing because the ability to generate arbitrarily long sentences using recursion is a core characteristic of human languages~\cite{recursivemind}.
Therefore, generalization to higher dimensional spaces is important for achieving human-level intelligence, which we define as \textit{inductive generalization}.
The idea of inductive generalization is illustrated in Figure~\ref{fig:indgen}c.
Given a data distribution $\mathcal{D}$, inductive generalization trains a model only by data from $\boldsymbol{D}'$, an intersection of $\boldsymbol{D}$ with a \textit{lower-dimensional subspace}.
To verify if the model can extend the learned rules, we validate it with the higher-dimensional samples from $\boldsymbol{D} \setminus \boldsymbol{D}'$.
Specifically, assume $\mathcal{D}$ has a sample space consists of sequences of tokens whose representation vector space is $\boldsymbol{E}$, so that the sample space is $\boldsymbol{E}^1\cup\boldsymbol{E}^2\dots\cup\boldsymbol{E}^N$.
Once a dataset $\boldsymbol{S}$ is drawn from $\mathcal{D}$, we split the set into the training set $\boldsymbol{T} = \boldsymbol{S} \cap (\boldsymbol{E}^1 \cup \dots \cup \boldsymbol{E}^k)$ and the validation set $\boldsymbol{V} = \boldsymbol{S} \cap (\boldsymbol{E}^{k+1} \cup \dots \cup \boldsymbol{E}^N)$ based on the dimensions of the samples.
The two sets are exclusive in that a validation sample's context length cannot be observed during the training stage.
If a model can generalize the rule learned from $\boldsymbol{T}$ to $\boldsymbol{V}$, we conclude that it is capable of achieving inductive generalization.
Successful inductive generalization means that the model infers the rule applicable to the entire space by only observing the samples from a lower-dimensional subspace.
Hence, the difficulty of inductive generalization depends on the underlying rule of the data distribution.
Parallel architectures like CNNs can inductively generalize if the tokens are independent of one other, while a Turing-complete automaton may be required to emulate the sequential dependency between the tokens.
If the critical path for computing such a dependency is longer than $O(1)$, it is impossible for a Transformer to extend the rule because self-attention only allows constant computational paths~\cite{transformer}.
\section{\pname{} Model}
\label{sec:model}
\begin{figure}[ht]
\begin{subfigure}[b]{0.32\linewidth}
\centering
\includegraphics[width=\linewidth]{figures/rnns2s.pdf}
\caption{RNN seq2seq}
\label{fig:seq2seq}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.32\linewidth}
\centering
\includegraphics[width=\linewidth]{figures/Bert.pdf}
\caption{BERT}
\label{fig:selfatten}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.32\linewidth}
\centering
\includegraphics[width=\linewidth]{figures/Ibert.pdf}
\caption{\pname{}}
\label{fig:ours}
\end{subfigure}
\caption{Architecture comparison between (a) RNN sequence-to-sequence model with attention (b) BERT's self-attention and (c) \pname{}'s self-attention with recurrence.}
\label{fig:compareAttRtx}
\end{figure}
Unlike traditional sequence-to-sequence models as shown in Figure~\ref{fig:seq2seq}, the self-attention mechanism of Transformers shown in Figure~\ref{fig:selfatten} replaces recurrent computations with a positional encoding layer to capture positional relations inside the sequence.
The key benefit of the Transformer architecture is that the computation and gradient paths of each output shortens to $O(1)$ from $O(n)$ of RNNs, making the model easier to stack deeply and achieve parallelism.
However, this makes Transformers incapable of generalizing rules that have a critical path greater than $O(1)$~\cite{theorylimit}. %
For instance, the carry rule of addition has a critical path length of at least $O(log(n))$, making the self-attention based Transformers impossible to learn the rules beyond the observed lengths.
Furthermore, absolute positional encodings make a model inapplicable to an input longer than any of the training inputs. Relative positional encodings~\cite{relativeposition} can resolve this issue~\cite{tfxl, xlnet}, but they still cannot allow longer computation paths.
Therefore, we propose \pname{}, a BERT based model for inductive generalization.
\pname{} addresses these limitations by augmenting self-attention with a recurrent layer and is shown in the Figure~\ref{fig:ours}.
Besides removing the positional encodings and adding a bi-directional LSTM layer, we share all other architectural details with BERT \cite{bert}.
This architecture brings three upsides.
First, the model can be leveraged for any application where BERT can be used.
Second, both computation and parameter overheads remain constant regardless of the network depth.
Lastly, paths for computing gradients of most of the parameters do not elongate because the recurrent layer is positioned at the bottom.
To sum up, \pname{} overcomes the computational limits of self-attention without sacrificing its adaptability and scalability.
We consider a few variations of \pname{} to verify if our architecture is optimal.
First, since a recurrent layer and a positional encoding layer are not exclusive to one other, we can leverage both methods simultaneously.
However, it is possible that absolute positional encodings cause overfitting.
We can also try using a recurrent layer for every self-attention layer to allow more computational paths.
Our experiment results discussed in Section~\ref{sec:result} show that the only augmenting the self-attention with a recurrent layer such as LSTM is sufficient and effective over its variants.
\section{Problem and Data}
\label{sec:indgentasks}
\begin{figure}[htbp]
\vspace{-4ex}
\includegraphics[width=\linewidth]{figures/fig_dataset.pdf}
\caption{Data samples and separation of training and validation datasets. Asterisks represent masks and blank cells represent padding tokens.
}
\vspace{-4ex}
\label{fig_dataset}
\end{figure}
\subsection{Number Sequence Prediction}
Learning arithmetic operations between digital numbers is one of the basic symbolic inference tasks.
Number sequence prediction (NSP) problems \cite{numbersequenceprediction} are well-defined arithmetic rule inference tasks designed for evaluating machine learning models.
One desired property of them is that it is easy to generate inductive generalization validation sets by modifying the number of digits used.
For example, we can easily generate training sets on numbers of length $\leq k$ and evaluation sets on numbers of length $> k$.
Therefore, we utilize digit-level number sequence prediction tasks from \cite{numbersequenceprediction} for the experiments.
As illustrated in Figure~\ref{fig_dataset}, a digit-level NSP problem is similar to a character-level masked language modeling task in that it requires the model to predict the digits of the masked number given the previous numbers.
We use Fibonacci (Add) and palindrome (Reverse) tasks from \cite{numbersequenceprediction} along with the copying sequence (Copy) tasks in a similar manner.
A data sequence consists of three (two for reverse and copy) numbers $a_1$, $a_2$, and $a_3$, where the initial numbers are sampled randomly and the final number is determined by the generation rule.
Each sequence has a difficulty parameter $d$, which forces all initial numbers to have digits less than or equal to $d$ and makes the second to last number sampled only from $d$-digit numbers.
All the numbers are represented by decimal digits in little-endian order, separated by delimiter tokens.
Shorter sequences are padded with padding tokens to match the length of the longest sequence for mini-batch training.
In an input sequence, all digits of the last number are masked out, and we train the model to restore the original sequence.
To validate inductive generalization, the training dataset has 25600 sequences with $d=2 \dots 12$,and the validation set has 1536 sequences with $d=13 \dots 16$ where the occurrences of difficulties are equally distributed.
\subsection{Penn Treebank Masked Language Modeling}
To verify the generality of \pname{}, we compare it to other state-of-the-art models in masked language modeling tasks.
We use the Penn Treebank dataset \cite{penntreebank} for both the character-level and word-level setups.
The right part in Figure~\ref{fig_dataset} shows how the sentences are sampled and masked for the character-level setup.
In the character-level setup, we mask all characters of a randomly chosen word just like the NSP setup.
The only difference for the word-level setup is that the sentences are tokenized by words, not by characters.
To test inductive generalization, we partition training sentences by their length into separate training and validation datasets.
For the character-level setup, we choose 16 to 192 character sentences for the training dataset and 193 to 224 character sentences for the validation dataset.
Likewise, we choose 2 to 32 word sentences for training, and 33 to 64 word sentences for validation in the word-level setup.
The thresholds are chosen to make the train-to-validation size ratio around 4:1.
All sequences are padded to match the length of the longest sentence in the dataset. | {'timestamp': '2020-06-23T02:02:55', 'yymm': '2006', 'arxiv_id': '2006.10220', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10220'} | arxiv |
\section*{Acknowledgements}
This work was partially supported by the NSF under CCF-1813188, the ARO under W911NF1910294 and a JP Morgan Chase Faculty Fellowship.
\section{Conclusions and Open Problems}
Our work introduces a framework for smoothed analysis of online and private learning
and obtain regret and error bounds that depend only on the VC dimension and the bracketing
number of a hypothesis class and are independent of the domain size and Littlestone dimension.
Our work leads to several interesting questions for future work.
The first is to characterize learnability in the smoothed setting --- via matching lower bounds --- in terms of a combinatorial quantity, e.g., bracketing number.
In \hyperref[app:brackextra]{Appendix \ref*{app:brackextra}}, we discuss \emph{sign rank} and its connection to bracketing number
as a promising candidate for this characterization.
A related question is whether there are finite VC dimension classes that cannot be learned in presence of smoothed adaptive adversaries.
Let us end this paper by noting that the Littlestone dimension plays a key role in characterizing learnability and algorithm design in the worst-case for several socially and practically important constraints~\citep{ben2009agnostic,AlonWezlHaussler}.
It is essential then to develop models that can bypass Littlestone impossibility results and provide rigorous guidance in achieving these constraints in practical settings.
\section{Differential Privacy} \label{sec:DP}
In this section, we consider smoothed analysis of differentially private learning in \emph{query answering} and \emph{data release} paradigms.
We primarily focus on $(\sigma , 0)$-smooth distributions and defer the general case of $(\sigma , \chi)$-smooth distributions to \hyperref[app:SmallDB]{Appendix \ref*{app:SmallDB}}.
For finite query classes $\Q$ and small domains, existing differentially private mechanisms achieve an error bound that depends on $\ln(|\Q|)$ and $\ln(|\X|)$.
We leverage smoothness of data sets to improve these dependencies to $\vc(\Q)$ and $\ln(1/\sigma)$.
\paragraph{An Existing Algorithm.}
\cite{NIPS2012_4548} introduced a practical algorithm for data release, called Multiplicative Weights Exponential Mechanism (MWEM). This algorithm works for a finite query class $\Q$ over a finite domain $\X$.
Given an data set $B$ and its corresponding empirical distribution $\D_B$, MWEM iteratively builds distributions $\D_t$ for $t\in[T]$, starting from $\D_1= \U$ that is the uniform distribution over $\X$.
At stage $t$, the algorithm picks a $q_t \in \Q$ that approximately maximizes the error $\left| q_t\left(\D_{t-1}\right)-q_t(\D_B)\right|$ using a differentially private mechanism (Exponential mechanism).
Then data set $\D_{t-1}$ is updated using the multiplicative weights update rule
$\D_t(x) \propto \D_{t-1}(x) \exp\left( q_t( x) (m_t - q_t(\D_{t-1}))/2 \right)$
where $m_t$ is a differentially private estimate (via Laplace mechanism) for the value $q_t \left( \D_B \right)$.
The output of the mechanism is a data set $ {\overline{\D}} = \frac 1T \sum_{t\in[T]}\D_t$.
The formal guarantees of the algorithm are as follows.
\begin{theorem}[\cite{NIPS2012_4548}] \label{thm:MWEM}
For any data set $B$ of size $n$, a finite query class $\Q$, $T \in \mathbb{N}$ and $\epsilon>0$, MWEM is $\epsilon$-differentially private and with probability at least $1 - \nicefrac{2T}{|\mathcal{\Q}|}$ produces a distribution $ {\overline{\D}}$ over $\X$ such that $ \max_{q \in \Q }\left\{ \abs{q\left( {\overline{\D}}\right) - q\left(\D_B \right) } \right\} \leq 2 \sqrt{\frac{\log |\mathcal{X}|}{T}}+\frac{10 T \log |\mathcal{Q}|}{\epsilon n} .$
\end{theorem}
The analysis of MWEM keeps track of the KL divergence $\mathrm{D}_{\mathrm{KL}} \left(\D_B\| \D_t \right)$ and shows that at time $t$ this value decreases by approximately the error of query $q_t$. At a high level,
$\mathrm{D}_{\mathrm{KL}} \left(\D_B\| \D_1 \right) \leq \ln(|\X|)$. Moreover, KL divergence of any two distributions is non-negative. Therefore, error of any query $q\in \Q$ after $T$ steps follows the above bound.
\paragraph{Query Answering.}
To design a private query answering algorithm
for a query class $\Q$ without direct dependence on $\ln(|\Q|)$ and $\ln(|\X|)$ we leverage smoothness of distributions.
Our algorithm called the Smooth Multiplicative Weight Exponential Mechanism (Smooth MWEM), given an infinite set of queries $ \mathcal{Q} $, considers a $\gamma$-cover $ \mathcal{Q}'$ under the uniform distribution.
Then, it runs the MWEM algorithm with $\mathcal{Q}'$ as the query set and constructs an empirical distribution $ {\overline{\D}}$.
Finally, upon being requested an answer to a query $q \in \mathcal{Q} $, it responds with $ q'( {\overline{\D}} )$, where $q' \in \mathcal{Q} '$ is the closest query to $q$ under the uniform distribution.
This algorithm is presented in \hyperref[sec:DPProofs]{Appendix \ref*{sec:DPProofs}}.
Note that $\mathcal{Q}'$ does not depend on the data set $B$.
This is the key property that enables us to work with a finite $\gamma$-cover of $\Q$ and extend the privacy guarantees of MWEM to infinite query classes. In comparison, constructing a $\gamma$-cover of $\Q$ with respect to the empirical distribution $\D_B$ uses private information.
Let us now analyze the error of our algorithm and outline the reasons it does not directly depend on $\ln(|\Q|)$ and $\ln(|\X|)$.
Recall that from the $\left( \sigma , 0 \right) $-smoothness, there is a distribution $\overline{\D_B}$ that is $\sigma$-smooth and $q \left( \D_B \right) = q\left( \overline{\D_B} \right) $ for all $q \in \mathcal{Q} $.
Furthermore, $\mathcal{Q}'$ can be taken to be a subset of $\mathcal{Q}$ and thus $B$ is $ \left( \mathcal{\sigma} , 0 \right) $-smooth with respect to $\mathcal{Q}' $.
The approximation of $\mathcal{Q}$ by a $\gamma$-cover introduces error in addition to the error of \autoref{thm:MWEM}.
This error is given by $ \abs{ q \left( \D_B \right) - q' \left( \D_B \right) } \leq 2 \cdot\Pr_{\U} \left[ q'\left( x \right) \neq q\left( x \right) \right] \sigma^{-1} \leq 2\gamma/\sigma$.
Note that $|\Q'| \leq (41/\gamma)^{\vc( \mathcal{Q} )}$, therefore, this removes the error dependence on the size of the query set $\mathcal{Q}$ while adding a small error of $2\gamma/\sigma$.
Furthermore, \autoref{thm:MWEM} dependence on $\ln(|\X|)$ is due to the fact that for a worst-case (non-smooth) data set $B$, $\mathrm{D}_\mathrm{KL}(\D_B\| \U)$ can be as high as $\ln(\abs{ \X } )$. For a $\left( \sigma , 0 \right)$-smooth data set, however, $\mathrm{D}_\mathrm{KL}( \overline{\D_B} \|\U)\leq \ln(1/\sigma)$.
This allows for faster error convergence.
Applying these ideas together and setting $\gamma = \sigma/2n$ gives us the following theorem whose proof is
{deferred to \hyperref[app:datareleaseanalysis]{Appendix \ref*{sec:DPProofs}}.}
\begin{theorem} \label{thm:DPMW}
For any $ \left( \sigma , 0 \right) $-smooth dataset $B$ of size $n$, a query class $\Q$ with VC dimension $d$, $T \in \mathbb{N}$ and $\epsilon>0$, \hyperref[alg:QueryAnswering]{Smooth Multiplicative Weights Exponential Mechanism} is $\epsilon$-differentially private and with probability at least $1 - 2T \left( \nicefrac{\gamma}{41} \right)^{ \vc\left( \mathcal{Q} \right) }$,
{calculates values $v_{q}$ for all $q\in \Q$ such that}
\begin{equation*}
\max_{q \in \Q }\left\{ \abs{ v_{q} - q\left(\D_B \right) } \right\} \leq \frac{1}{n} + 2 \sqrt{\frac{\log\left( \nicefrac{1}{\sigma} \right) }{T}}+\frac{10 T d \log\left( \nicefrac{2n}{\sigma} \right) }{\epsilon n }.
\end{equation*}
\end{theorem}
\paragraph{Data Release.}
Above we described a procedure for query answering that relied on the construction of a data set. One could ask whether this leads to a solution to the data release problem as well.
An immediate, but ineffective, idea is to output distribution $ {\overline{\D}}$ constructed by our algorithm in the previous section.
The problem with this approach is that while $q'( {\overline{\D}})\approx q'(\D_B)$ for all queries in the cover $\Q'$, there can be queries $q\in \Q\setminus \Q'$ for which $\abs{q( {\overline{\D}}) - q(\D_B)}$ is quite large. This is due to the fact that even though {$B$ is $(\sigma,0)$-smooth (and $\overline{\D_B}$ is $\sigma$-smooth),} the repeated application of multiplicative update rule may result in distribution $ {\overline{\D}}$ that is far from being smooth.
To address this challenge, we introduce
\hyperref[alg:QueryAnswering]{Projected Smooth Multiplicative Weight Exponential Mechanism} (Projected Smooth MWEM)
that
ensures that $\D_t$ is also $\sigma$-smooth by projecting it on the convex set of all $\sigma$-smooth distributions. More formally, let $\mathcal{K}$ be the polytope of all $\sigma$-smooth distributions over $\X$ and let $\tilde{\D}_t$ be the outcome of the multiplicative update rule of \cite{NIPS2012_4548} at time $t$. Then, Projected Smooth MWEM mechanism uses
$\D_t= \argmin_{\D \in \mathcal{K} } \mathrm{D}_{\mathrm{KL}}(\, \D \| \tilde{\D }_t ).$
To ensure that these projections do not negate the progress made so far, measured by the decrease in KL divergence, we note that for any $ \overline{ \D_B} \in \mathcal{K}$ and any $\tilde \D_t$, we have
$\mathrm{D}_{\mathrm{KL}}( \overline{ \D_B} \| \tilde\D_t\, ) \geq \mathrm{D}_{\mathrm{KL}}( \overline{ \D_B} \| \D_t)+\mathrm{D}_{\mathrm{KL}}( \D_t \| \tilde\D_t ).$
That is, as measured by the decrease in KL divergence, the improvement with respect to $\D_t$ can only be greater than that of $\tilde \D_t$.
Optimizing parameters $T$ and $\gamma$, we obtain the following guarantees.
See \hyperref[sec:DPDataRelease]{Appendix \ref*{sec:DPDataRelease}} for more details on Projected Smooth MWEM mechanism and its analysis.
\begin{theorem}[Smooth Data Release]
\label{thm:PSMWEM}
Let $B$ be a $\sigma$-smooth database with $n$ data points.
For any $\epsilon , \delta > 0 $ and any query set $\mathcal{Q} $ with VC dimension $d$, \hyperref[alg:DataRelease]{Projected Smooth Multiplicative Weight Exponential Mechanism} is $\left( \epsilon , \delta \right)$ differentially private and with probability at least $1 - 1/poly\left( n / \sigma \right)^d$ its outcome $ {\overline{\D}}$ satisfies
\begin{equation*}
\max_{q\in \mathcal{Q}} \left\{ \abs{q\left(\, {\overline{\D}} \right) - q\left( \D_B \right) } \right\} \leq O\left( \sqrt{ \frac{d}{\epsilon n} \log ^{ \frac{1}{2} } \left(\frac{1}{\sigma} \right) \log\left( \frac{n}{\sigma } \right) \log\left( \frac{1}{ \delta} \right)} \right).
\end{equation*}
\end{theorem}
\section{Query Answering} \label{sec:DPProofs}
\subsection{Smooth MWEM Algorithm}
\begin{algorithm}[H]
\SetAlgoLined
\caption{Smooth Multiplicative Weights Exponential Mechanism}
\label{alg:QueryAnswering}
\DontPrintSemicolon
\KwIn{ Universe $\X$ with $\abs{\X} = N $, Data set $B$ with $n$ records, Query set $\mathcal{Q}$, Privacy parameters $\epsilon$ and $\delta$, Smoothness parameter $\sigma$.}
\;
Let ${\D_0} \left( x \right) = \nicefrac{1}{N} $ for all $x\in \X$.\;
\emph{Cover Construction:} Compute $ \mathcal{Q}' \subseteq \mathcal{Q} $ that is a $\gamma$-cover of $\Q$ with respect to the uniform distribution for $\gamma = \frac{\sigma}{2n} $. \;
\For{$i = 1 \dots T $}{
\emph{Exponential Mechanism:} Sample $q_i \in \mathcal{Q}' $ according to the exponential mechanism with parameter $\nicefrac{\epsilon}{2T}$ and score function
\begin{equation*}
s_{i}( \D_B, q)=n \left|q\left(\D_{i-1}\right)-q( \D_B )\right|.
\end{equation*} \;
\emph{Laplace Mechanism:} Let $m_i = q_i \left( \D_B \right) + \frac{1}{n} Lap \left( \nicefrac{2T}{\epsilon} \right) $ .\;
\emph{Multiplicative Update:} Update $\D_{i-1}$ using the rule
\begin{equation*}
\D_i\left( x \right) \propto \D _{i-1}\left( x \right) \exp\left( \frac{ q_{i} \left( x \right) \left( m_i - q_i( \D_{i-1} ) \right) }{2 } \right) .
\end{equation*}
}
Let $ \overline{\D} = \frac{1}{T} \sum_{i=1}^T \D_{i} $. \;
\KwOut{For each $q \in \mathcal{Q} $, answer with $v_q = q'\left( \overline{\D} \right)$ where $q'$ is the closest function in $ \mathcal{Q}'$ to $q$.}
\end{algorithm}
\subsection{Proof of Theorem~\ref{thm:DPMW}} \label{app:datareleaseanalysis}
In this section we prove the following theorem.
\medskip
\textbf{Theorem~\ref{thm:DPMW} (restated).~}\emph{
For any $(\sigma,0)$-smooth dataset $B$ of size $n$, a query class $\Q$ with VC dimension $d$, $T \in \mathbb{N}$ and $\epsilon>0$, \hyperref[alg:QueryAnswering]{Smooth Multiplicative Weights Exponential Mechanism} is $\epsilon$-differentially private and with probability at least $1 - 2T \left( \nicefrac{\gamma}{41} \right)^{ \vc\left( \mathcal{Q} \right) } $, calculates values $v_{q}$ for all $q\in \Q$ such that
\begin{equation*}
\max_{q \in \Q }\left\{ \abs{ v_q - q\left(\D_B \right) } \right\} \leq \frac{1}{n} + 2 \sqrt{\frac{\log\left( \nicefrac{1}{\sigma} \right) }{T}}+\frac{10 T d \log\left( \nicefrac{2n}{\sigma} \right) }{\epsilon n }.
\end{equation*}
}
Let us first provide a few useful lemmas.
\begin{lemma}[Cover under Smoothness] \label{lem:SmoothCover}
Let $B$ be $(\sigma, 0)$-smooth data set.
Let $ \mathcal{Q} '\subseteq \Q$ be a $\gamma$-cover of $\mathcal{Q}$ under the uniform distribution.
For a $q \in \mathcal{Q} $, let $ q' \in \mathcal{Q} $ be such that $ \Pr_{x \sim \U } \left[ q\left( x \right) \neq q' \left( x \right) \right] \leq \gamma $. Then,
\begin{equation*}
\abs{ q \left( \D_B \right) - q' \left( \D_B \right) } \leq \frac{2 \gamma}{\sigma }.
\end{equation*}
\end{lemma}
\begin{proof} \label{pf:SmoothCover}
From the $ \left( \sigma, 0 \right)$-smoothness of $B$, we get
\begin{align*}
\abs{ q \left( \D_B \right) - q' \left( \D_B \right) } & = \abs{ q \left( \overline {\D_B} \right) - q' \left( \overline{\D_B} \right) } \\
& \leq \sum_{x \in D} \abs{ \left( q\left( x \right) - q' \left( x \right) \right) }\, \overline{\D_B}(x) \\
& \leq \sum_{x \in \X } 2 \mathbb{I} \left( q(x) \neq q'\left( x \right) \right) \overline{\D_B}(x)\\
& \leq \frac{2}{ \sigma} \sum_{x \in \X } \mathbb{I} \left( q(x) \neq q'\left( x \right) \right) \U\left( x \right) \\
& \leq \frac{2}{\sigma} \Pr_{x \sim \U} \left[ q\left( x \right) \neq q' \left( x \right) \right] \\
& \leq \frac{2 \gamma}{\sigma }
\end{align*}
as required.
\end{proof}
Define the potential function $\Psi_{i}=\sum_{x \in \X } \overline{ \D_{B} } (x) \log \left( \overline{ \D_{B} } (x) / \D_{i}(x)\right) $, where $\overline{\D_B}$ is a corresponding $\sigma$-smooth distribution that matches the query answers for the $(\sigma, 0)$-smooth data set $B$.
Here we make a few observations about the potential function.
\begin{fact} \label{fact:potentialfacts}
For all $i \leq T$, we have $\Psi_i \geq 0.$ Furthermore,
$\Psi_0 \leq \log \frac{1}{\sigma}.$
As a result, $\Psi_0 - \Psi_T \leq \log \frac{1}{\sigma}.$
\end{fact}
\begin{proof}
The first claim follows from the positivity of the KL divergence. For the second one, recall that from the $\sigma$-smoothness of $\D_B$ and the fact that $\D_1$ is the uniform distribution, we have $ \D_B \left( x \right) \leq \sigma^{-1} \D_0 \left( x \right) $ for all $x \in \mathcal{X} $.
\begin{align*}
\Psi_0 &= \sum_{x\in \X } \overline{\D_B} \left( x \right) \log \frac{ \overline{\D_B} \left( x \right) }{\D_0 \left( x \right) } \leq \sum_{x\in \X } \overline{\D_B} \left( x \right) \log \frac{1 }{ \sigma } = \log \frac{1}{\sigma}
\end{align*}
as required.
\end{proof}
Below is a direct adaptation of a result of \citet{NIPS2012_4548} for bounding the change in the potential functions.
\begin{lemma}[Lemma A.4 in \cite{NIPS2012_4548}] \label{lem:potential_improve}
\begin{equation*}
\Psi_{i-1} -{\Psi}_{i} \geq\left(\frac{q_{i}\left( \D_{i-1}\right)-q_{i}( \overline{ \D_{B} } )}{2 }\right)^{2}-\left(\frac{m_{i} - q_{i}( \overline{ \D_{B} }) }{2 } \right)^{2}.
\end{equation*}
\end{lemma}
\begin{lemma}[Exponential and Laplace Mechanism guarantees] \label{lem:ExpLapcon}
With probability at least $1 - \nicefrac{2T}{ \abs{\mathcal{Q} ' } } $, we have
\begin{equation*}
\abs{q_i\left( \D_{i - 1} \right) - q_i \left( \D_B \right) } \geq \max_{q' \in \mathcal{Q}'} \left\{ q'\left( \D_i \right) - q' \left( \D_B \right) \right\} - \frac{8T \log \abs{\mathcal{Q}'} }{\epsilon n}
\end{equation*}
and
\begin{equation*}
\abs{m_i - q_i \left( \D_B \right) } \leq \frac{2T \log \abs{\mathcal{Q}'} }{\epsilon n }.
\end{equation*}
\end{lemma}
Here we recall again the error guarantees from \cite{NIPS2012_4548}.
\begin{theorem}[\cite{NIPS2012_4548}] \label{thm:MWEM_App}
For any data set $B$ of size $n$, a finite query class $\Q$, $T \in \mathbb{N}$ and $\epsilon>0$, MWEM is $\epsilon$-differentially private and with probability at least $1 - \nicefrac{2T}{|\mathcal{\Q}|}$ produces a distribution $\overline{\D}$ over $\X$ such that
\begin{equation*}
\max_{q \in \Q }\left\{ \abs{q\left(\overline{\D}\right) - q\left(\D_B \right) } \right\} \leq 2 \sqrt{\frac{\log |\mathcal{X}|}{T}}+\frac{10 T \log |\mathcal{Q}|}{\epsilon n} .
\end{equation*}
\end{theorem}
\begin{proof}[Proof of \autoref{thm:DPMW}]
Our proof closely resembles that of \autoref{thm:MWEM_App} from \cite{NIPS2012_4548}.
Note that since $B$ is $\left( \sigma , 0 \right)$-smooth, we have a $\sigma$-smooth distribution $ \overline{\D_B } $ with $ \overline{\D_B } \left( x \right) \leq \frac{1}{\sigma N}$ such that for all $q \in \mathcal{Q}$, $ q\left( \mathcal{D}_B \right) = q\left( \overline{ \mathcal{D}_B} \right) $.
Furthermore, note that we chose a cover $\Q'\subseteq \Q$. Therefore, $ q'\left( \mathcal{D}_B \right) = q'\left( \overline{ \mathcal{D}_B} \right)$ holds for all $q' \in \mathcal{Q}' $ as well.
Note that since $ q'\left( \D_B \right) = q'\left( \overline{\D_B} \right) $ for all $q' \in \mathcal{Q}' $, we can replace this in the above equation.
For the sake of completeness, we sketch the rest of the proof.
From Jensen's inequality, we have
\begin{equation}
\label{eq:app:jensen}
\max_{q' \in \mathcal{Q}' } \abs{ q'\left(\overline{\D} \right) - q'\left( \D_{B} \right) } \leq \frac{1}{T } \sum_{i = 1}^T \max_{ {q'} \in \mathcal{Q}' } \abs{ q'\left( \D_i \right) - q'\left( \D_{B} \right) }.
\end{equation}
From \hyperref[lem:ExpLapcon]{Lemma \ref*{lem:ExpLapcon}} and \hyperref[lem:potential_improve]{Lemma \ref*{lem:potential_improve}}, we get that with probability at least $1- 2T / \abs{\mathcal{Q'}} $, we get
\begin{equation*}
\Psi_{i-1} -{\Psi}_{i} \geq\left(\frac{ \max_{q' \in \mathcal{Q}'} \left\{ q'\left( \D_i \right) - q' \left( \D_B \right) \right\} - \frac{8T \log \abs{\mathcal{Q}'} }{\epsilon n}}{2 }\right)^{2}-\left(\frac{ T\log \abs{ \mathcal{Q} } }{ \epsilon n } \right)^{2}.
\end{equation*}
Rearranging this and taking the average, we get
\begin{equation*}
\frac{1}{T }\sum_{i = 1}^T \max_{q' \in \mathcal{Q}' } \abs{ q'\left( \D_i \right) - q'\left( \D_B \right) } \leq \frac{1}{T }\sum_{i = 1}^T\left[ \sqrt{ 4 \left( \Psi_{i - 1} - \Psi_i \right) + \frac{4T^2 \log^2 \abs{\mathcal{Q}' } }{ n^2\epsilon^2} } + \frac{8T \log \abs{\mathcal{Q}' } }{ n\epsilon} \right] .
\end{equation*}
Applying the concavity of the square root function i.e., $\frac 1T \sum_{i=1}^T (x_i)^{1/2} \leq \left( \frac 1T \sum_{i=1}^{T } x_i \right)^{1/2}$,
\begin{align*}
\frac{1}{T }\sum_{i = 1}^T \max_{q \in \mathcal{Q}' } \abs{ q'\left( \D_i \right) - q'\left( \D_B \right) } &\leq \sqrt{ \sum_{i = 1}^T \frac{4 \left( \Psi_{ i - 1} - \Psi_i \right) }{T }+ \frac{4T^2 \log^2 \abs{\mathcal{Q}' } }{ n^2\epsilon^2} } + \frac{8T \log \abs{\mathcal{Q}' } }{ n\epsilon} \\
&\leq \sqrt{ \frac{4 \left( \Psi_0 - \Psi_T \right) }{T }+ \frac{4T^2 \log^2 \abs{\mathcal{Q}' } }{ n^2\epsilon^2} } + \frac{8T \log \abs{\mathcal{Q}' } }{ n\epsilon} \\
& \leq \sqrt{ \frac{4\log\left( \frac{1}{\sigma} \right) }{ {T}}+ \frac{4T^2 \log^2 \abs{\mathcal{Q}'} }{ n^2\epsilon^2} } + \frac{8T \log \abs{\mathcal{Q}' } }{ n\epsilon} \\
& \leq 2 \sqrt{\frac{ \log\left( \frac{1}{\sigma} \right) }{T}} + \frac{10T \log \abs{\mathcal{Q}' } }{ n\epsilon}.
\end{align*}
The second inequality follows by summing the telescoping series.
The third follows from \hyperref[fact:potentialfacts]{Fact \ref*{fact:potentialfacts}}.
The last equation follows from the fact that $ \sqrt{x+y} \leq \sqrt{x} + \sqrt{y} $ for all positive $x,y$.
{Using Equation~\ref{eq:app:jensen} and the fact that
$ \abs{\mathcal{Q}}' \leq \left( \nicefrac{41}{\gamma} \right)^d$ we have}
\begin{equation*}
\max_{q' \in \mathcal{Q}' } \abs{ q'\left( \overline{\D} \right) - q'\left( \D_B \right) } \leq 2 \sqrt{\frac{ \log\left( \nicefrac{1}{\sigma} \right) }{T}} + \frac{10 T d \log\left( \nicefrac{2n}{\sigma} \right) }{\epsilon n }.
\end{equation*}
{Let
$v_q = q'(\overline{\D})$ for
$q'\in \Q'$ that is the closest hypothesis to $q$ with respect to the uniform distribution.} Then
\begin{align*}
\abs{ q\left( \D_B \right) - v_q } & = \abs{ q\left( \D_B \right) - q'\left( \D_B \right) + q' \left( \D_B \right) - q' \left(\, {\overline{\D}} \right) } \\
& \leq \abs{ q\left( \D_B \right) - q'\left( \D_B \right) } +\abs{ q' \left( \D_B \right) -q'\left( {\overline{\D}} \right) } \\
& \leq \frac{2 \gamma }{\sigma} + 2 \sqrt{\frac{\log \nicefrac{1}{\sigma} }{T}}+\frac{10 T d \log \left( \nicefrac{41}{ \gamma} \right) }{\epsilon n } .
\end{align*}
Setting $\gamma = \frac{\sigma}{ 4 n } $, we get the desired result.
\end{proof}
Setting $T = \epsilon^{2/3} n^{2/3} \log ^{1/3} \left( 1 / \sigma \right) d^{-2/3} \log^{-2/3} (2 n / \sigma) $, we get $\left( \epsilon , 0 \right)$ differential privacy with
\begin{equation*}
\max_{q\in \mathcal{Q}} \left\{ \abs{ {v_q} - q\left( \D_B \right) } \right\} \leq O\left( \sqrt[3]{ \frac{d \log\left( \nicefrac{1}{\sigma} \right) \log \left(\nicefrac{2n}{\sigma} \right) }{n \epsilon} } \right).
\end{equation*}
Also, as noted in \cite{NIPS2012_4548}, one can use adaptive $k$-fold composition (see e.g. \cite{AlgorithmicFoundationsDp}) to get $\left( \epsilon , \delta \right)$-differential privacy with
\begin{equation*}
\max_{q\in \mathcal{Q}} \left\{ \abs{ {v_q} - q\left( \D_B \right) } \right\} \leq O\left( \sqrt{ \frac{d}{\epsilon n} \log ^{ \frac{1}{2} } \left(\frac{1}{\sigma} \right) \log\left( \frac{n}{\sigma } \right) \log\left( \frac{1}{ \delta} \right)} \right).
\end{equation*}
\allowdisplaybreaks
\subsection{Running Time of the Algorithm} \label{sec:running_SMWEM}
The running time of the algorithm is similar to the running time of the MWEM algorithm of \cite{NIPS2012_4548}.
The main additional step is the construction of the cover $ \mathcal{Q}'$.
Similar to \hyperref[app:running_regret]{ Appendix \ref*{app:running_regret} }, this cover can be constructed in time $O\left(|\Q'|\right)$.
The exponential mechanism requires $ O\left( n \abs{ \mathcal{Q} }' \right) $ to evaluate all the queries on the cover and time $O\left( \abs{ \mathcal{Q} }' \abs{\X} \right)$ to execute each iteration of the algorithm.
Recall that $|\Q'| \leq \left(41 n / \sigma \right)^d$, thus the running time is bounded by $O \left(n \left( 41 n / \sigma \right)^d + T \left( 41 n / \sigma \right)^d \abs{\X} \right).$
This runtime can also be improved using several theoretical tricks, e.g., $q(\D_i)$ can be approximated by taking random points from $\D_i$ in time that is independent of $\X$.
Note that the runtime of our algorithm improves upon the runtime of MWEM by using smaller query sets. As noted in \cite{NIPS2012_4548}, their algorithm is amenable to many optimizations and modifications that make it very fast and practical~\cite{NIPS2012_4548}.
\section{Data Release} \label{sec:DPDataRelease}
\subsection{Projected Smooth MWEM Algorithm}
\begin{algorithm}[H]
\SetAlgoLined
\caption{Projected Smooth Multiplicative Weight Exponential Mechanism}
\label{alg:DataRelease}
\DontPrintSemicolon
\KwIn{Universe $\X$ with $\abs{\X} = N $, Data set $B$ with $n$ records, Query set $\mathcal{Q}$, Privacy parameters $\epsilon$ and $\delta$, Smoothness parameter $\sigma$.}
\;
Let $\D_0 \left( x \right) = \nicefrac{1}{N} $ for all $x\in \X$.\;
\emph{Cover Construction:} Compute $ \mathcal{Q}' \subseteq \mathcal{Q} $ that is a $\gamma$-cover of $\Q$ with respect to the uniform distribution for $\gamma = \frac{\sigma}{2n} $. \;
\For{$i = 1 \dots T $}{
\emph{Exponential Mechanism:} Sample $q_i \in \mathcal{Q}' $ according to the exponential mechanism with parameter $\nicefrac{\epsilon}{2T}$ and score function
\begin{equation*}
s_{i}( \D_B, q)=n \left|q\left(\D_{i-1}\right)-q( \D_B )\right|.
\end{equation*} \;
\emph{Laplace Mechanism:} Let $m_i = q_i \left( \D_B \right) + \frac{1}{n} Lap \left( \nicefrac{2T}{\epsilon} \right) $ .\;
\emph{Multiplicative Update:} Update $\D_{i-1}$ using the rule
\begin{equation*}
\tilde{\D}_i\left( x \right) \propto \D _{i-1}\left( x \right) \exp\left( \frac{ q_{i} \left( x \right) \left( m_i - q_i( \D_{i-1} ) \right) }{2 } \right) .
\end{equation*} \;
\emph{KL Projection:} Project $\tilde{\D}_i$ onto the polytope $\mathcal{K} = \big\{ \vec z : z_i \geq 0, \; \sum\limits_{i=1}^N z_i =1 , z_i \leq \frac{1}{\sigma N} \big\} $ of smooth distributions:
\begin{equation*}
\D_i = \argmin_{ \D \in \mathcal{K}} \mathrm{D}_{\mathrm{KL}}( \D \|\tilde{\D }_i )
\end{equation*}
}
Let $\overline{\D} = \frac{1}{T} \sum_{i=1}^T \D_{i} $. \;
\KwOut{Distribution $\overline{\D}$. }
\end{algorithm}
\subsection{Proof of Theorem~\ref{thm:PSMWEM}}
As before, let $\overline{\D_B}$ be a corresponding $\sigma$-smooth distribution that matches the query answers for the $(\sigma, 0)$-smooth data set $B$.
Define $ {\Psi}_i = \sum_{x \in \X } \overline{\D_{B} } (x) \log \left( \overline{\D_{B} } (x) / {\D}_{i}(x)\right) $ and $ \tilde{\Psi}_i = \sum_{x \in \X } \overline{\D_{B} } (x) \log \left( \overline{\D_{B} } (x) / \tilde{\D}_{i}(x)\right) $ as the intermediate potential.
From \hyperref[lem:potential_improve]{Lemma \ref*{lem:potential_improve}}, we know
\begin{equation*}
\Psi_{i-1} - \tilde{\Psi}_{i} \geq\left(\frac{q_{i}\left( \D_{i-1}\right)-q_{i}(\D_B)}{2 }\right)^{2}-\left(\frac{m_{i} - q_{i}( \D_B) }{2 } \right)^{2}.
\end{equation*}
Using the properties of relative entropy, we show the following claim.
\begin{claim}
For every $i \leq T$, we have $\tilde{\Psi}_i \geq \Psi_i$.
\end{claim}
\begin{proof}
The claim follows from the following fact about the KL divergence.
Let
\begin{equation*}
\D_i =\argmin_{\D \in \mathcal{K}} \mathrm{D}_{\mathrm{KL}}( \D \| \tilde{\D }_{i} )
\end{equation*}
for some convex set $\mathcal{K}$.
Then, for $ \overline{\D_{B} } \in \mathcal{K}$,
\begin{equation*}
\mathrm{D}_{\mathrm{KL}}( \overline{\D_{B} } \| \tilde\D_i \, ) \geq \mathrm{D}_{\mathrm{KL}}\left( \overline{\D_{B} } \| \D_i \right)+\mathrm{D}_{\mathrm{KL}}\left( \D_i \| \tilde\D_i \right).
\end{equation*}
The claim follows by $ \tilde{\Psi}_i = \mathrm{D}_{\mathrm{KL}}( \D_B \| \tilde\D_i\, )$, $ \Psi_i = \mathrm{D}_{\mathrm{KL}}\left(\D_B \| \D_i \right) $ and $\mathrm{D}_{\mathrm{KL}}\left( \D_i \| \tilde\D_i \right) \geq 0 $.
\end{proof}
Together this gives
\begin{equation*}
\Psi_{i-1} - {\Psi}_{i} \geq\left(\frac{q_{i}\left( \D_{i-1}\right)-q_{i}(\D_B)}{2 }\right)^{2}-\left(\frac{m_{i} - q_{i}( \D_B) }{2 } \right)^{2}.
\end{equation*}
The remainder of the analysis follows that of \autoref{thm:DPMW}.
Note that we have $\overline{\D}$ is $\sigma$-smooth since each $ \mathcal{D}_i \in \mathcal{K } $ and $\mathcal{K}$ is a convex set.
By \hyperref[lem:SmoothCover]{Lemma \ref*{lem:SmoothCover}}, we have $ \abs{ q' \left(\overline{\D} \right)- q\left( \overline{\D} \right) } \leq \nicefrac{2\gamma}{\sigma} $. Thus,
\begin{align*}
\abs{ q\left( \D_B \right) - q \left(\overline{\D} \right) } & = \abs{ q\left( \D_B \right) - q'\left( \D_B \right) + q' \left( \D_B \right) -q'\left(\overline{\D} \right) + q' \left(\overline{\D}\right)
- q\left(\overline{\D} \right) } \\
& \leq \abs{ q\left( \D_B \right) - q'\left( \D_B \right) } +\abs{ q' \left( \D_B \right) -q'\left(\overline{\D} \right) } + \abs{ q' \left(\overline{\D} \right)
- q\left(\overline{\D} \right) } \\
& \leq \frac{4 \gamma }{\sigma} + 2 \sqrt{\frac{\log \nicefrac{1}{\sigma} }{T}}+\frac{10 T d \log \left( \nicefrac{41}{ \gamma} \right) }{\epsilon n } .
\end{align*}
Setting $ \gamma = \nicefrac{\sigma}{4n} $, we get
\begin{equation*}
\abs{ q\left( \D_B \right) - q \left( \overline{\D} \right) } = \frac{1}{n} + 2 \sqrt{\frac{\log\left( \nicefrac{1}{\sigma} \right) }{T}}+\frac{10 T d \log\left( \nicefrac{4n}{\sigma} \right) }{\epsilon n }.
\end{equation*}
\subsection{Running Time of \hyperref[alg:DataRelease]{Projected Smooth Multiplicative Weights Exponential Mechanism}}
The running time is similar to the running time \hyperref[sec:running_SMWEM]{Smooth Multiplicative Weights Exponential Mechanism},with the additional projection step in each step.
Note that the projection in each step is a convex program and can be solved in time $\mathrm{poly} \left( \abs{\X} \right)$.
This gives us a total running time of $O \left(n \left( 41 n / \sigma \right)^d + T \left( 41 n / \sigma \right)^d \abs{\X} + T\mathrm{poly}(|\X|) \right).$
In addition to the improvements discussed in the previous sections, the projection step can be performed faster by taking an approximate Bregman projection as considered by \cite{ApproxBreg}.
Incorporating this into our algorithm would lead to significant speed ups.
\section{Additional Related Work} \label{app:related}
Analogous models of smoothed online learning have been explored in prior work.
\citet{NIPS2011_4262} consider online learning when the adversary is constrained in several ways and work with a notion of sequential Rademacher complexity for analyzing the regret.
In particular, they study a related notion of smoothed adversary and show that one can learn thresholds with regret of $O( \sqrt{T} )$ in presence of smoothed adversaries.
\citet{Gupta_Roughgarden} consider smoothed online learning in the context online algorithm design.
They show that while optimizing parameterized greedy heuristics for Maximum Weight Independent Set imposes linear regret in the worst-case, in presence of smoothing this problem can be learned with sublinear regret (as long they allow per-step runtime that grows with $T$).
\cite{Cohen-Addad} consider the same problem with an emphasis on the per-step runtime being logarithmic in $T$. They show that piecewise constant functions over the interval $[ 0,1 ]$ can be learned efficiently within regret of $O ( \sqrt{T} ) $ against a \emph{non-adaptive} smooth adversary.
Our work differs from these by upper bounding the regret using a combinatorial dimension of the hypothesis class and demonstrating techniques that generalize to large class of problems in presence of \emph{adaptive} adversaries.
{In another related work, \cite{Dispersion} introduce a notion of dispersion in online optimization (where the learner picks an instance and the adversary picks a function) that is a constraint on the number of discontinuities in the adversarial sequence of functions. They show that online optimization can be done efficiently under certain assumptions. Moreover, they show that sequences generated by \emph{non-adaptive} smooth adversaries in one dimension satisfy dispersion.
In comparison, our main results in online learning consider the more powerful adaptive adversaries.
}
{
Smoothed analysis is also used in a number of other online settings. In the setting of linear contextual bandits, \cite{kannan2018smoothed} use smoothed analysis to show that the greedy algorithm achieves sublinear regret even though in the worst case it can have linear regret. \cite{raghavan2018externalities} work in a Bayesian version of the same setting and achieve improved regret bounds for the greedy algorithm.
{Since several algorithms are known to have sublinear regret in the linear contextual bandit setting even in the worst-case, the main contribution of these papers is to show that the simple and practical greedy algorithm has much better regret guarantees than in the worst-case.}
In comparison, we work with a setting where no algorithm can achieve sublinear regret in the worst-case.
}
{Smoothed analysis has also been considered in the context of differential privacy.
\cite{DPMultWeights} consider differential privacy in the interactive setting, where the queries arrive online.
They analyze a multiplicative weights based algorithm whose running time and error they show can be vastly improved in the presence of smoothness.
{Some of our techniques for query answering and data release are inspired by that line of work.}
\cite{Dispersion} also differential privacy in presence of dispersion and analyze the gaurantees of the exponential mechanism.}
{Generally, our work is also related to a line of work on online learning in presence of additional assumptions resembling properties exhibited by real life data.
\cite{PredictableSequences} consider settings where additional information in terms of an estimator for future instances is available to the learner. They achieve regret bounds that are in terms of the path length of these estimators and can beat $\Omega(\sqrt{T})$ if the estimators are accurate.
\cite{dekel2017online} also considers the importance of incorporating side information in the online learning framework and show that regrets of $O(\log(T))$ in online linear optimization maybe possible when the learner knows a vector that is weakly correlated with the future instances.}
{
More broadly, our work is among a growing line of work on beyond the worst-case analysis of algorithms~\citep{roughgarden_2020}
that
considers the design and analysis of algorithms on instances that satisfy properties demonstrated by real-world applications. Examples of this in theoretical machine learning mostly include improved runtime and approximation guarantees of numerous supervised
(e.g., \citep{LearningSmoothed,kalai2008decision,onebit,Masart}),
and unsupervised settings~(e.g., \citep{bilu_linial_2012, kcenter, stable_clustering, TopicModelling, Decoupling,VDW, MMVMaxCut,llyods, HardtRoth}).
}
\section{Smooth Data Release using SmallDB Algorithm} \label{app:SmallDB}
In this section,, we look at a different algorithm to get differential privacy when dealing with $\left( \sigma , \chi \right)$-smooth data sets.
{Our algorithm displayed below uses several pieces that have been introduced} by \cite{SmallDB} and \cite{DPMultWeights}.
\begin{algorithm}[H]
\SetAlgoLined
\caption{Subsampled Net Mechanism}
\label{alg:SubNetMech}
\DontPrintSemicolon
\KwIn{ Database $ B $ of size $n$, Query set $\mathcal{Q}$, Privacy parameter $\epsilon$, Subsampling parameter $M$, Accuracy parameter $\gamma$.}
Sample (with replacement) a subset $V$ of size $M$ from $\X$. \;
Sample $B'$ from amongst all data sets supported on $V$ of size
\begin{equation*}
O\left( \frac{d }{\gamma^2} \right)
\end{equation*}
with probability proportional to
\begin{equation*}
\exp \left( - \frac{\epsilon \cdot n \cdot s\left( \D_{B'} , \D_B \right) }{2} \right)
\end{equation*}
where $s \left( \D_{B'} , \D_B \right) = \max_{q \in \mathcal{Q}} \abs{q(\D_B) - q(\D_{B'}) } $. \;
\KwOut{Database $B'$}
\end{algorithm}
First, we analyze the privacy of this algorithm.
\begin{theorem}
The Subsampled Net Mechanism is $(\epsilon,0)$ differentially private.
\end{theorem}
\begin{proof}
The privacy claim follows from the privacy of the exponential mechanism.
\end{proof}
{Next we bound the error of this mechanism. Let us recall the standard uniform convergence bound.}
\begin{fact}[Uniform Convergence for VC Classes, see e.g. \cite{shalev2014understanding}] \label{fact:uniformconv}
Let $\X$ be the domain, $\mathcal{Q}$ be a class of queries over $\X$ with VC dimension $d$ and let $\D$ be a distribution.
Let $\D'$ be a distribution gotten by sampling $ O\left( (\log(2 / \eta ) + d) / \gamma^2 \right) $ items iid from $\D$ and normalizing the frequencies.
Then, with probability $1 - \eta$, for all $q \in \mathcal{Q} $, $\abs{q(\D') -q(\D) } \leq \gamma $.
\end{fact}
In the following, we use the above fact to show that a randomly sampled subset of the universe approximates a $\left( \sigma , \chi \right)$-smooth database.
The proof largely follows the domain reduction lemma of \cite{DPMultWeights} {that achieve a similar bond by with a dependence on $\log(|\Q|)$}. We include this proof for completeness.
\begin{lemma} \label{lem:subsampling}
Let $\X $ be a data universe and $\mathcal{Q}$ a collection of queries over $ \X$ with VC dimension $d$ and $\D$ be $\left( \sigma , \chi \right)$-smooth with respect to $\mathcal{Q}$.
Let $V \subset \X $ of size $M$ be sampled from $\X$ at random with replacement with
\begin{equation*}
M = O\left( \frac{ \log\left( 1 / \eta \right) + d }{ \sigma \gamma^2 } \right) .
\end{equation*}
Then, with probability $1-\eta$, there exists a $\D'$ on $V$ such that for all $q \in \mathcal{Q} $
\begin{equation*}
\abs{q\left( \D \right) - q\left( \D' \right) } \leq \chi + \gamma.
\end{equation*}
\end{lemma}
\begin{proof}
Let $\D_1$ be $\sigma$-smooth distribution that witnesses the $\left( \sigma, \chi \right)$-smoothness of $\D$.
If we could sample from $\D_1$, we would be done from \hyperref[fact:uniformconv]{Fact \ref*{fact:uniformconv}}.
But we want to get a subset that is oblivious to the distribution $\D$.
To achieve this, we use the smoothness of $\D_1$.
The idea is to sample from $\D_1$ using rejection sampling.
Since $\D_1$ is $\sigma$-smooth, the following procedure produces samples from $\D_1$: sample from the uniform distribution and accept sample $u$ with probability $\sigma N \D_1\left(u\right) $.
Note that accepted samples are distributed according to $\D_1$.
We repeat this process until $O\left( (\log(2 / \eta ) + d) / \gamma^2 \right)$ samples are accepted.
Since the accepted samples are distributed according to $\D_1$, from \hyperref[fact:uniformconv]{Fact \ref*{fact:uniformconv}}, there is a distribution {$\D_2$} supported on the accepted samples such that {with probability at least $1 - \eta/2 $ for all $q \in \mathcal{Q} $,}
\begin{equation*}
\abs{ q \left( \D_2 \right) - q\left( \D \right) } \leq \chi + \gamma.
\end{equation*}
Let $S_1$ be the coordinates corresponding to the accepted samples and $S_2$ be the coordinates corresponding to the rejected ones.
The key observation is that $S= S_1 \cup S_2$ is subset generated by sampling from the uniform distribution and has a distribution supported on it that approximates $\D$.
So, it suffices to bound the size of $S$.
The probability that a given sample gets accepted is
\begin{equation*}
\sum_{x \in \mathcal{X}} \frac{\D_1 \left( x \right) N \sigma }{N} = \sigma .
\end{equation*}
Thus the expected number of samples needed in the rejection sampling procedure is $M = O\left( \frac{ \log\left( 2 / \eta \right) + d }{ \sigma \gamma^2 } \right) $.
Using a Chernoff bound, we can bound the probability that this is greater than its mean by a factor of $4$ by
\begin{equation*}
e^{ - M } \leq \frac{\eta}{2}
\end{equation*}
where we used that fact that $M \geq \log \left( 2/\eta \right)$ .
\end{proof}
{We are finally ready to prove our theorem.}
\begin{theorem}
For any {data set $B$} that is $(\sigma,\chi)$-smooth with respect to a set of queries $\mathcal{Q}$ of VC dimension $d$, the output $\D''$ of the Subsampled Net Mechanism satisfies that
with probability $1- \eta$,
for all $q \in \mathcal{Q}$
\begin{equation*}
\abs{q\left(\, {\D_B}\right) - q\left( \D'' \right) } \leq \chi + \tilde{O} \left( \sqrt[3]{ \frac{ d \log\left( 1 / \sigma \right) +\log\left( 1 / \eta \right) }{\epsilon n } } \right)
\end{equation*}
\end{theorem}
\begin{proof}
Consider a subset $V$ sampled with size $M = O\left( \frac{ \log\left( 1 / \eta_1 \right) + d }{ \sigma\gamma^2 } \right) $ where $\eta_1$ and $\gamma$ are parameters we will set later.
From \hyperref[lem:subsampling]{Lemma \ref*{lem:subsampling}}, with probability $1-\eta_1$ we have that there exists a distribution $\D'$ supported on $V$ such that for all $q \in \mathcal{Q}$
\begin{equation*}
\abs{q(\D') - q(\D_B) } \leq \chi + \gamma.
\end{equation*}
Let us work conditioned on this event.
Let $A$ denote the set of all data sets supported on $V$ and let $C$ denote all data sets supported on $V$ with size $ O\left( d \gamma^{-2} \right) $.
From \hyperref[fact:uniformconv]{Fact \ref*{fact:uniformconv}}, for any distribution $\D_1$ supported on $V$, there is a data set in $C$ whose distribution $\D_2$ satisfies
\begin{equation*}
\abs{ q\left( \D_1 \right) - q \left( \D_2 \right) } \leq \gamma.
\end{equation*}
We recall the guarantees of the exponential mechanism (see e.g. \cite{AlgorithmicFoundationsDp}):
Let ${B''}$ be the data base output by the exponential mechanism.
Then,
\begin{equation*}
\Pr \left[ s \left( \D_{B''} , \D_B \right) \geq \min_{B_1 \in C} s \left( \D_{B_1 } , \D_B \right) - \frac{2}{\epsilon n} \left( \log \abs{C} + t \right) \right] \leq e^{ - t},
\end{equation*}
where $s\left( \D_B , \D_{B'} \right) {=}\max_{q \in \mathcal{Q}} \abs{q(\D_B) - q(\D_{B'}) } $.
Note that $\log \abs{C} \leq M^{O\left( d \gamma^{-2} \right) } $.
Thus, with probability $1- \eta_2$,
\begin{equation*}
s \left( \D_{B''} , \D_B \right) \geq \min_{B_1 \in C } s \left( \D_{B_1 } , \D_B \right) - \gamma
\end{equation*}
for
\begin{equation*}
\gamma \geq \frac{4 }{\epsilon n } \log \frac{M^{O( d \gamma^{-2} ) }}{ \eta_2 }.
\end{equation*}
Since, $\min_{B_1 \in C} s \left( \D_{B_1 } , \D_B \right) \leq \chi + 2 \gamma $,
setting $\eta_1 = \eta_2 = \eta/2$ and solving for $\gamma$, we get
\begin{equation*}
\gamma = \tilde{O} \left( \sqrt[3]{ \frac{ d \log\left( 1 / \sigma \right) + \log\left( 1 / \eta \right) }{\epsilon n } } \right)
\end{equation*}
as required.
\end{proof}
\subsection{Running Time of \hyperref[alg:SubNetMech]{Subsampled Net Mechanism}}
The running time of the algorithm involves first sampling $M$ elements uniformly from the domain which takes time $O\left( M \log \abs{\X} \right) $.
Each query needs to be evaluated on the data set $B$ which takes time $n \abs{ \mathcal{Q} } $.
Evaluating and sampling from all data bases as required by the exponential mechanism naively takes time $M^{O\left( d \gamma^{-2} \right) }$.
As discussed earlier, this can be sped up using sampling for approximation.
\section{More Details on Bracketing Number and Sign Rank} \label{app:brackextra}
Though bracketing numbers are a fundamental concept in statistics, until recently their connection to VC theory was not well understood.
\cite{adams2010,adams2012} show that for
countable (can be generalized to classes that are well approximated by countable classes) classes with finite VC dimension the bracketing numbers with respect to any measure is finite ({this establishes what is known as a universal Gilvenko--Cantelli theorem under ergodic sampling.)}
\begin{theorem}[Finite Bracketing Bounds for VC Classes]
Let $\mathcal{C}$ be a countable class with finite VC dimension.
Then, $ \bnumber{ \mathcal{C}}{\mu}{\epsilon} < \infty$.
\end{theorem}
Though the above theorem proves that $\epsilon$-bracketing numbers are finite, their growth rate in $1/\epsilon$ can be arbitrarily large.
See \cite{UGC} for some interesting examples of classes where the bracketing numbers grow arbitrarily fast.
Another combinatorial quantity that can help bound the regret in presence of adaptive smooth adversaries is \emph{sign rank}.
\begin{definition}[Sign Rank]
Let $\mathcal{X}$ be an instance space and let $\mathcal{F} $ be a class.
We can denote the class naturally as $\{-1,1\}$-valued $ \mathcal{X} \times \mathcal{F} $ matrix $M_{\mathcal{F}}$ where the entry corresponding to $\left( x , f \right)$ is $ f\left( x \right) $.
The sign rank of a class is the highest rank of a real matrix that agrees with a finite submatrix of $M_{\mathcal{F}}$ in sign.
If this is unbounded, the class is said to have infinite sign rank.
\end{definition}
The sign rank of a class captures the dimension in which the class can be embedded as thresholds.
\begin{fact}[Sign Rank Embedding, see e.g. \cite{Satya_LinearComplexity}]
The sign rank of a class corresponds to the smallest dimension $d$ that the class can be embedded as thresholds.
\end{fact}
\autoref{thm:embeddable} effectively says that classes with small sign rank have a slowly growing bracketing numbers and thus have low regret in the smoothed online learning setting.
Thus, the complexity of smoothed online learning lies somewhere in between the sign rank and VC dimension.
On the other hand, it is known that even classes with small VC dimension can have arbitrarily large sign rank \citep{AlonWezlHaussler,Embedding,Signrank}.
An intermediate question is whether classes with slow growing bracketing number also have good sign rank.
It would be interesting to characterize the complexity of smoothed online learning in terms of either the sign rank or bracketing numbers.
\subsection{Proof of \autoref{thm:embeddable}}
Consider the map $\psi : \mathcal{X} \to \br^m $ that embeds $\mathcal{G}$ in $m$ dimensions and let $\H$ be the class of halfspaces in $\br^m$.
We want to bound the bracketing number of $\mathcal{G}$ by that of $\H$.
Let $\B(\H) =\{ [ h_i , h^i ]\}_{i}$ be an $\epsilon$-bracketing for $\H$ with respect to a measure $\mu$ that we will specify later.
Consider the set of brackets $\B' = \{ [ h_i \circ \psi , h^i \circ \psi ] \mid \text{ for all } [ h_i , h^i ]\in \B(\H) \} $.
We first argue that $\B'$ is a bracketing for $\G$ with respect to $\nu$.
To see this, note that any $ g \in \mathcal{G} $ can be expressed as $g = h \circ \psi$ for some halfspace $h$.
Considering the bracket $[ h_i , h^i ] \ni h$ in $\B(\H)$. Note that $h_i\circ \psi \preceq h \circ \psi \preceq h^i \circ \psi$ and thus $g\in [ h_i \circ \psi , h^i \circ \psi ]$. We next argue that these are $\epsilon$-brackets under measure $\nu$. Let $\mu$ be the measure such that to sample $z\sim \mu$ we first sample $x \sim \nu$ and let $z = \psi\left( x \right)$. Note that
\begin{equation*}
\Pr_{x \sim \nu} \left[ h^i \left( \psi \left( x \right) \right) \neq h_i \left( \psi\left( x \right) \right) \right] = \Pr_{z\sim \mu} \left[ h^i \left( z \right) \neq h_i \left( z \right) \right] \leq \epsilon,
\end{equation*}
where the last transition is by the fact that $\B(\H)$ is an $\epsilon$-bracketing for $\H$ with respect to $\mu$. This concludes that $\B'$ is an $\epsilon$-bracketing for $\G$ with respect to $\nu$. We complete the proof by using \autoref{thm:half_brack} to bound $|\B'| = |\B(\H)| \leq (\nicefrac{m}{\epsilon})^{O\left( m \right)} $.
\subsection{Proof of \autoref{thm:k-fold}}
We first consider the case of $k=2$ and then extend our argument to general $k$. Let $\epsilon' = \epsilon/k$ and
let $\B(\F_1)$ and $\B(\F_2)$ be $\epsilon'$-bracketings for $\F_1$ and $\F_2$, respectively.
For $\F_1 \cdot \F_2$, construct $\B = \left\{ [f_\ell \cap g_\ell, f^u \cap g^u] \mid \text{for all } [f_\ell, f^u]\in \B(\F_1) \text{ and } [g_\ell, g^u]\in \B(\F_2)\right\}$.
First note for any $f_1\in \F_1$ and $f_2\in \F_2$, $f_1\cap f_2$ is included in one of these brackets. In particular, for brackets $[f_\ell, f^u]\ni f_1$ and $[g_\ell,g^u]\ni f_2$, we have that $f_\ell \cap g_\ell \preceq f_1\cap f_2 \preceq f^u \cap g^u$ and $[f_\ell \cap g_\ell, f^u \cap g^u] \in \B$. Furthermore,
\begin{align*}
\Pr_{x \sim \mu} \left[ \left( f_\ell(x) \cap g_\ell( x) \right) \neq \left( f^u(x) \cap g^u(x) \right) \right] &\leq \Pr_{x \sim \mu} \left[ \left( f_\ell(x) \cap g_\ell(x) \right) \neq \left( f_\ell(x) \cap g^u ( x) \right) \right] \\
& \hphantom{=} + \Pr_{x \sim \mu} \left[ \left( f_\ell(x) \cap g^u ( x) \right) \neq \left( f^u(x)\cap g^u ( x) \right) \right] \\
& \leq 2 \epsilon'.
\end{align*}
Therefore, $\B$ is a $2\epsilon'$-bracketing for $\F_1\cdot \F_2$ of size $ \bnumber{\F_1}{\mu}{\epsilon'} \cdot \bnumber{\F_2}{\mu}{\epsilon'}$. Repeating this inductively and using $\epsilon' = \epsilon/k$, we get the claim for $k$ classes.
Similarly, for $\F_1+\F_2$, construct $\B = \left\{ [f_\ell \cup g_\ell, f^u \cup g^u] \mid \text{for all } [f_\ell, f^u]\in \B(\F_1) \text{ and } [g_\ell, g^u]\in \B(\F_2)\right\}$.
First note for any $f_1\in \F$ and $f_2\in \F_1$ and
their respective brackets $[f_\ell, f^u]\ni f_1$ and $[g_\ell,g^u]\ni f_2$, we have that $f_\ell \cup g_\ell \preceq f_1\cup f_2 \preceq f^u \cup g^u$ and $[f_\ell \cup g_\ell, f^u \cup g^u] \in \B$. Furthermore,
\begin{align*}
\Pr_{x \sim \mu} \left[ \left( f_\ell(x) \cup g_\ell( x) \right) \neq \left( f^u(x) \cup g^u(x) \right) \right] &\leq \Pr_{x \sim \mu} \left[ f_\ell \left( x \right) \neq f^u \left( x \right) \right] + \Pr_{x \sim \mu} \left[ g_\ell \left( x \right) \neq g^u \left( x \right) \right] \\
& \leq 2 \epsilon'.
\end{align*}
Therefore, $\B$ is a $2\epsilon'$-bracketing for $\F_1+\F_2$ of size $ \bnumber{\F_1}{\mu}{\epsilon'} \cdot \bnumber{\F_2}{\mu}{\epsilon'}$.
Repeating this inductively and using $\epsilon' = \epsilon/k$, we get the claim for $k$ classes.
As for the $\G $, the set of all symmetric differences, note that $ f_1 \Delta f_2 = \left( f_1 \cup f_2 \right) \setminus \left( f_1 \cap f_2 \right) = \left( f_1 \cup f_2 \right) \cap \overline{\left( f_1 \cap f_2 \right)} $. Furthermore, for any class $\F$, the class $\overline{\F}=\{\overline{f} \mid \forall f\in \F \}$ has the same bracketing number as $\F$. Therefore, the bracketing number of $\G$ follows from using the bracketing number $\F+\F$, $\overline{\F+\F}$, and their intersection.
\subsection{Proof of \hyperref[cor:bnumber]{Corollary \ref*{cor:bnumber}}}
The set of polynomial threshold functions in $n$ variables and of degree $d$ is embeddable as halfspaces in $O(n^d)$ dimensions using the map
\[
\phi \left( x_1 , \dots , x_n \right) = \left( \prod_{i\in S} x_i \right)_{S\in \{1,\dots, n\}^{\leq d}},
\]
which maps variables to all monomial of degree $d$. It can be seen that the number of monomials of degree at most $d$ in $n$ variables is given by $ \binom{n+d+1}{d+1} $ which is approximately $O\left(n^d \right)$ when $d$ is small.
Combining \autoref{thm:embeddable} and \autoref{thm:half_brack} completes the proof for polynomial threshold functions.
A $k$-polytope in $\br^n$ is an intersection of $k$-halfspaces in $\br^n$. Combining \autoref{thm:k-fold} and \autoref{thm:half_brack} completes the proof.
\section{Lack of Uniform Convergence in Smooth Adaptive}
\subsection{Adaptive Adversary} \label{subsec:ada}
As we observed in the previous section (Lemma~\ref{lem:non-ada-gen}),
any hypothesis class $\G$ with bounded VC dimension demonstrates
uniform convergence on any non-adaptive sequence of distributions
$\bP$, regardless of the smoothness of $\bP$ or other properties of
$\G$.
The next example demonstrates that this property fails to hold with
adaptive adversaries.
\begin{example}
Let $\X = [0,1]$ and $\G = \{g_b(x) = \one(x\geq b) \mid \forall b\in[0,1] \}$ be the set of one-dimensional thresholds. Let $\td$ be an adaptive sequence of distributions, such that $\P_1$ is a uniform distribution over $[0,\frac 14]\cup [\frac 34, 1]$ and $\P_2 = \dots = \P_T$ all are the uniform distribution on $[0,\frac 14]$ if $x_1\in[0,1/4]$, and otherwise, are the uniform distribution on $[\frac 34, 1]$. In this case, we do not achieve concentration for any value of $T$, as
\[
\frac 1T \sum_{t=1}^T g_{0.5}(x_t) = \begin{cases} 0 & \text{w.p. $1/2$}\\ 1 & \text{w.p. $1/2$} \end{cases} \qquad and \qquad \E_{\vec x \sim \td} \left[ \frac 1T \sum_{t=1}^T g_{0.5}(x_t) \right] = \frac 12.
\]
\end{example}
An even more troubling aspect of the above example is that $\td$ is $\frac 14$-smooth and $\G$ has a VC dimension of $1$. So, smoothness of an adaptive distribution is not sufficient for obtaining uniform convergence over $\G$, even if $\G$ has a small VC dimension.
At a high level, one of the challenging aspects of the above example
is that $\{ x \mid g_{0.5}(x) = 1\}$ is relatively large. This allows
an adaptive adversary to create a smooth $\td$ where the supports of
$\P_2, \dots, \P_T$ are all within the set $\{x \mid g(x) =1\}$ if
some constant-probability event takes place in the first round, and
otherwise choosing smooth $\P_2, \dots, \P_T$ whose supports are
within the set $\{x \mid g(x) = 0\}$.
A key observation is that the hypotheses that we really care
about are those in $\A$, each of which is the symmetric
difference of two similar hypotheses. That is, $\Pr_\U[a(x) = 1]$ is
small for all $a \in \A$. As we'll see, this additional property is
sufficient to obtain good regret bounds in the adaptive case.
\section{Lack of Uniform Convergence with Adaptive Adversaries} \label{app:ExampleUC}
The following example for showing lack of uniform convergence over adaptive sequences is due to ~\citet{haghtalab2018foundation} and is included here for completeness.
Let $\X = [0,1]$ and $\mathcal{G} = \{g_b(x) = \mathbb{I}(x\geq b) \mid \forall b\in[0,1] \}$ be the set of one-dimensional thresholds.
Let the distribution of the noise $\eta_i$ be the uniform distribution on $\left( - \nicefrac{1}{4} , \nicefrac{1}{4} \right)$.
Let $x_1 = \nicefrac{1}{2} $ and $x_2 = x_3 = \dots = x_T = \nicefrac{1}{4} $ if $\eta_1 \leq 0 $ while $x_2 = x_3 = \dots = x_T = \nicefrac{3}{4} $ otherwise.
In this case, we do not achieve concentration for any value of $T$, as
\[
\frac 1T \sum_{t=1}^T g_{0.5}(x_t + \eta_t) = \begin{cases} 0 & \text{w.p. $ \nicefrac{1}{2} $}\\ 1 & \text{w.p. $ \nicefrac{1}{2} $} \end{cases} \qquad and \qquad \mathbb{E} \left[ \frac 1T \sum_{t=1}^T g_{0.5}(x_t + \eta_t) \right] = \frac 12.
\]
\section{Proofs from \hyperref[sec:regret-prelim]{Section \ref*{sec:regret-prelim}}}
\subsection{Algorithm and its Running Time} \label{app:running_regret}
While our main focus is to provide sublinear regret bounds for smoothed online learning our analysis also provides an algorithmic solution describe below.
\begin{algorithm}[H]
\SetAlgoLined
\caption{Smooth Online Learning}
\label{alg:QueryAnswering}
\DontPrintSemicolon
\KwIn{Instance Space $\X$, Hypothesis Class $\mathcal{H}$, Smoothness parmeter $\sigma$, Time horizon $T$}
\;
\emph{Cover Construction:} Compute $ \mathcal{H}' \subseteq \mathcal{H} $ that is a $ \gamma $-cover of $\H$ with respect to the uniform distribution on $\X$ for $\gamma = \frac{\sigma }{4\sqrt{T}}$. \;
\For{$t = 1 \dots T $}{
Use a standard online learning algorithm, such as Hedge, on $\H'$ to pick an $h_t$, where the history of the play is $\{s_\tau\}_{\tau<t}$ and $\{h_\tau\}_{\tau < t}$ \;
Receive $s_t = \left( x_t , y_t \right)$ and suffer loss $\err_{s_t} \left( h_t \right) $.
}
\end{algorithm}
The running time of the algorithm comprises of the initial construction {of $\H'$} and then running a standard online learning algorithm on $\H'$.
Standard online learning algorithms such as Hedge and FTPL take time polynomial in the size of the cover since in standard implementations they maintain a state corresponding to each hypothesis in $\H'$.
In our setting, the size of the cover is $( 41 \sqrt{T} / \sigma)^d $.
The time required to construct a cover depends on the access we have to the class.
One method is to randomly sample a set $S$ with $m= O( \vc\left( \H \right) T/ \sigma^2 )$ points from the domain uniformly and construct all possible labelings on this set induced by the class.
The number of labellings of $S$ is bounded by $O(m^{ \vc\left( \H \right)} )$ by the Sauer--Shelah lemma. The cover is constructed by then finding functions in the class $\H$ that are consistent with each of these labellings. This requires us to be able to find an element in the class consistent with a given labeling, which can be done by a ``consistency'' oracle. Naively, the above makes $2^m$ calls to the consistency oracle, one for each possible labeling of $S$.
The above analysis and runtime can be improved in several ways. First, $\H'$ can be constructed in time $O(m^{ \vc\left( \H \right)} )$ rather than $2^m$. This can be done by constructing the cover in a hierarchical fashion, where the root includes the unlabeled set $S$ and at every level one additional instance in $S$ is labeled by $+1$ or $-1$. At each node, the consistency oracle will return a function $h\in \H$ that is consistent with the labels so far or state that none exists. Nodes for which no consistent hypothesis so far exists are pruned and will not expand in the next level. Since the total number of leaves is the number of ways in which $S$ can be labeled by $\H$, i.e., $O(m^d)$, the number of calls to the consistency oracle is $O(m^d)$ as well.
The runtime of standard online learning algorithms can also be improved significantly when an empirical risk minimization oracle is available to the learner, in which case a runtime of $O(\sqrt{ |\H'|})$ for general classes~\citep{HazanKoren} or even $\mathrm{polylog}(|\H'|) )$ for structured classes ~\citep{Oracle_Efficient} is possible.
\subsection{Proof of \hyperref[lem:union-ada]{Lemma \ref*{lem:union-ada}}} \label{app:Proofoffinite}
At a high level, note that any $f\in \F$ has measure at most $\epsilon/\sigma$ on any (even adaptively chosen) $\sigma$-smooth distribution. Therefore, for any fixed $f$, $\E_\adist[\sum_{t=1}^T f(x_t)] \leq T\epsilon/\sigma$. To achieve this bound over all $f\in \F$, we take a union bound over all such functions.
More formally, for any $s$
\begin{align*}
\exp\left(s\E_\adist\left[\max_{f\in \F} \sum_{t=1}^T f(x_t) \right] \right)
& \leq \E_\adist\left[ \exp\left( s \max_{f\in \F} \sum_{t=1}^T f(x_t) \right) \right] \qquad \text{(Jensen's inequqlity)} \\
& \leq \E_\adist\left[\max_{f\in \F} \exp\left(s \sum_{t=}^T f(x_t) \right) \right] \qquad \text{(Monotonicity of $\exp$)} \\
& \leq \sum_{f\in \F}\E_\adist\left[\exp\left( s \sum_{t=1}^T f(x_t) \right) \right] . \numberthis \label{eq:exp-union}
\end{align*}
Consider a fixed $f\in \F$. Note that even when the choice of a $\sigma$-smoothed distribution $\D$ depends on earlier realizations of $x_1, \dots, x_{i-1}$, $\Pr_{x_i \sim \D}[f(x_i)] \leq \frac{\epsilon}{\sigma}$. Therefore, $\sum_{t=1}^T f(x_t)$ for $\vec x\sim \adist$ is stochastically dominated
by that of a binomial distribution $Bin(T, \epsilon/\sigma)$.
Note that $\exp(\cdot)$ is a monotonically increasing functions and let $p = \epsilon/\sigma$. We have
\begin{equation}
\label{eq:fixed-f-exp}
\E_\adist\left[\exp\left(s \sum_{t=1}^T f(x_t) \right) \right] \leq \sum_{v=0}^T \exp(sv) {T \choose v} p^v (1-p)^{T-v} = \big(p (\exp(s) - 1) +1 \big)^T.
\end{equation}
Combining Equations~\eqref{eq:exp-union} and \eqref{eq:fixed-f-exp} and noting that $\ln(1+x) \leq x$, we have
\begin{align*}
\E_\adist\left[\max_{f\in \F} \sum_{t=1}^T f(x_t) \right] &\leq \frac{\ln(|\F|) + T p\left(\exp(s) - 1 \right)}{s}.
\end{align*}
Let $s = \sqrt{\ln(|\F|)}/Tp$. Note that because $s\in (0,1)$, we have $\exp(s) \leq 1 + 2s$. Hence, by replacing $s$ in the above inequality we have
\begin{align*}
\E_\adist\left[\max_{f\in \F} \sum_{t=1}^T f(x_t) \right] \in O\left(Tp \sqrt{\ln(|\F|)} \right).
\end{align*}
\subsection{Proof of \autoref{thm:main-ada} }
Consider any hypothesis class $\H'$ and an algorithm that is no-regret with respect to any adaptive adversary on hypotheses in $\H'$. It is not hard to see that
\begin{align*}
\E[\regret(\A, \adist)] &= \E_{\vec s\sim \adist} \left[\sum_{t=1}^T \err_{s_t}(h_t) - \min_{h\in \H} \err_{s_t}(h_t) \right] \\
& \leq \E_{\vec s\sim \adist} \left[\sum_{t=1}^T \err_{s_t}(h_t) - \min_{h\in \H'} \sum_{t=1}^T\err_{s_t}(h) \right] + \E_{\vec s\sim \adist}\left[\min_{h'\in \H'} \sum_{t=1}^T \err_{s_t}(h') - \min \sum_{t=1}^T \err_{s_t}(h) \right]\\
& \leq O\left( \sqrt{T \ln(|\H'|)} \right) + \E_{\adist}\left[\max_{h\in \H}\min_{h'\in \H'} \sum_{t=1}^T 1\left(h(x_t) \neq h'(x_t) \right) \right]. \numberthis \label{eq:regret-total}
\end{align*}
Therefore, it is sufficient to choose an $\H'$ of moderate size such that every function $h\in \H$ has a proxy $h'\in \H'$ even when these functions are evaluated on instances drawn from a \emph{non-iid and adaptive sequence of smooth distributions}. We next describe the choice of $\H'$.
Let $\H'$ be a $\frac \epsilon 2$-net of $\H$ with respect to the uniform distribution $\U$, for an $\epsilon$ that we will determine later. Note that
any $\epsilon$-bracket with respect to $\U$ is also an $\epsilon$-net, so $|\H'| \leq \bnumber\H\U {\epsilon/2}$.\footnote{Alternatively, we can bound $|\H'|\leq (41/\epsilon)^{\vc(\H)}$ by \cite{ HAUSSLER1995217}.}
Let $\G$ be the set of symmetric differences between $h\in \H$ and its closest proxy $h'\in \H'$, that is,
\[ \G = \{g_{h, h'}(x) = 1(h(x)\neq h'(x)) \mid \forall h\in \H \text{ and } h'\in \H', \text{ s.t. } \E_\U[g_{h,h'}(x)]\leq \epsilon/2 \}.
\]
Note that because $\G$ is a subset of all the symmetric differences of two functions in $\H$, by Theorem~\ref{thm:k-fold} its bracketing number is bounded as follows.
\begin{equation}
\label{eq:bnumber-delta}
\bnumber{\G}{\U}{\epsilon/2} \leq \left(\bnumber{\H}{\U}{\epsilon/4}\right)^4.
\end{equation}
Let $\B(\G)$ be the set of upper $\epsilon/2$-brackets of $\G$ with respect to $\U$, i.e., for all $g\in G$, there is $b\in \B(\G)$ such that for all $x\in \X$, $g(x) \leq b(x)$ and $\E_\U[b(x) - g(x)]\leq \epsilon/2$. Note that
\[
\E_{\adist}\left[ \max_{h\in \H}\min_{h'\in \H'} \sum_{t=1}^T 1\left(h(x_t) \neq h'(x_t) \right) \right] = \E_{\adist}\left[\max_{g\in \G} \sum_{t=1}^T g(x_t) \right] \leq \E_{\adist}\left[\max_{b\in \B(\G)} \sum_{t=1}^T b(x_t) \right],
\]
where the last transition is by the fact that $\B(\G)$ includes all upper brackets of $\G$.
We now note that $\B(\G)$ meets the conditions Lemma~\ref{lem:union-ada}, namely because all $g\in \G$ have measure at most $\epsilon/2$ over $\U$ and $\B(\G)$ is the set of $\epsilon/2$-upper brackets of $\G$, we have that $\E_\U[b(x)]\leq \epsilon$ for all $b\in \B(\G)$. Therefore, by Lemma~\ref{lem:union-ada} and Equation~\ref{eq:bnumber-delta}, we have
\[\E_{\adist}\left[\max_{b\in \B(\G)} \sum_{t=1}^T b(x_t) \right] \leq O\left( T\frac \epsilon \sigma \sqrt{\ln\left( \bnumber{\H}{\U}{\epsilon/4} \right)} \right)
\]
Replacing this in Equation~\ref{eq:regret-total} we have that
\[
\E[\regret(\A, \adist)]\in O\left( \sqrt{T \ln\left( \bnumber \H\U{\epsilon/4}\right) } + T\frac \epsilon \sigma\sqrt{\ln\left( \bnumber{\H}{\U}{\epsilon/4} \right)} \right)
\]
Choosing $\epsilon = \sigma/\sqrt{T}$ proves the claim.
\section{Introduction}
Robustness to changes in the data and protecting the privacy of data
are two of the main challenges faced by machine learning and have led
to the design of \emph{online} and \emph{differentially private}
learning algorithms. While offline PAC learnability is
characterized by the finiteness of VC dimension, online and
differentially private learnability are both characterized by the
finiteness of the Littlestone dimension~\citep{PrivatePACLD,ben2009agnostic,bun2020equivalence}.
This latter characterization is often interpreted as an impossibility
result for achieving robustness and privacy on worst-case instances,
especially in classification where even simple hypothesis classes
such as $1$-dimensional thresholds have constant VC dimension but
infinite Littlestone dimension.
Impossibility results for worst-case adversaries do not invalidate the
original goals of robust and private learning with respect to
practically relevant hypothesis classes; rather, they indicate
that a new model is required to provide rigorous guidance on the
design of online and differentially private learning algorithms.
In this work, we go beyond worst-case analysis and \emph{design online
learning algorithms and differentially private learning algorithms
as good as their offline and non-private PAC learning counterparts
in a realistic semi-random model of data.}
Inspired by smoothed analysis~\citep{ST04}, we introduce frameworks
for online and differentially private learning in which adversarially
chosen inputs are perturbed slightly by nature (reflecting, e.g.,
measurement errors or uncertainty).
Equivalently, we consider an adversary restricted to choose an input
distribution that is not overly concentrated, with the realized input
then drawn from the adversary’s chosen distribution. Our goal is to
design algorithms with good expected regret and error bounds, where
the expectation is over nature’s perturbations (and any random coin
flips of the algorithm). Our positive results show, in a precise
sense, that the known lower bounds for worst-case online and
differentially private learnability are fundamentally brittle.
\paragraph{Our Model.}
Let us first consider the standard online learning setup with an
instance space $\X$ and a set $\H$ of binary hypotheses each mapping
$\X$ to $\Y =\{+1,-1\}$. Online learning is played over $T$ time
steps, where at each step the learner picks a prediction function from
a distribution
and the \emph{adaptive} adversary chooses a pair of $(x_t, y_t) \in \X\times \Y$. The regret of an algorithm
is the difference between the number of mistakes the algorithm makes
and that of the best fixed hypothesis in $\H$. The basic goal in
online learning is to obtain a regret of $o(T)$. In comparison, in
differential privacy the data set
$B =\{(x_1,y_1), \dots, (x_n, y_n) \}$ is specified ahead of time.
Our goal here is to design a randomized mechanism that with high
probability finds a nearly optimal hypothesis in $\H$ on the set $B$,
while ensuring that the computation is \emph{differentially private.}
That is, changing a single
element of $B$ does not significantly alter the probability with which
our mechanism selects an outcome. Similar to agnostic PAC learning,
this can be done by ensuring that the error of each hypothesis
$h\in \H$ on $B$ (referred to as a query) is calculated accurately and
privately.
We extend these two models to accommodate smoothed adversaries. We
say that a distribution $\D$ over instance-label pairs is
{\em $\sigma$-smooth} if its density function over the instance domain is
pointwise bounded by at most $1/\sigma$ times that of the uniform
distribution. In the online learning setting this means that at step
$t$, the adversary chooses an arbitrary $\sigma$-smooth distribution
$\D_t$ from which $(x_t, y_t)\sim \D_t$ is drawn. In the differential
privacy setting, we work with a database $B$ for which the answers to
the queries could have been produced by a $\sigma$-smooth
distribution.
Why should smoothed analysis help in online learning? Consider the
well-known lower bound for $1$-dimensional thresholds over
$\X = [0,1]$, in which the learner may as well perform binary search
and the adversary selects an instance within the uncertainty region of
the learner that causes a mistake. While the learner's uncertainty
region is halved each time step, the worst-case adversary can use
ever-more precision to force the learner to make mistakes
indefinitely. On the other hand, a $\sigma$-smoothed adversary
effectively has bounded precision. That is, once the width of the
uncertainty region drops below $\sigma$, a smoothed adversary can no
longer guarantee that the chosen instance lands in this region.
Similarly for differential privacy, there is a $\sigma$-smooth
distribution that produces the same answers to the queries. Such a
distribution has no more than $\alpha$ probability over an interval of
width $\sigma\alpha$. So one can focus on computing the errors of the
$1/(\sigma\alpha)$ hypotheses with discreized thresholds and learn a
hypothesis of error at most $\alpha$.
Analogous observations have been made in prior works
(\cite{NIPS2011_4262}, \cite{Cohen-Addad},
\cite{Gupta_Roughgarden}), although only for very specific
settings (online learning of $1$-dimensional thresholds,
$1$-dimensional piecewise constant functions, and parameterized greedy
heuristics for the maximum weight independent set problem, respectively).
Our work is the first to demonstrate the breadth of the settings
in which fundamentally stronger learnability guarantees are possible
for smoothed adversaries than for worst-case adversaries.
\paragraph{Our Results and Contributions.}
\begin{itemize}
\item Our main result concerns online learning with \emph{adaptive} $\sigma$-smooth adversaries where $\D_t$ can depend on the history of the play, including the earlier realizations of $x_\tau\sim \D_\tau$ for $\tau < t$. That is, $x_t$ and $x_{t'}$ can be highly correlated.
We show that regret against these powerful adversaries is bounded by
$\tilde O (\sqrt{T \ln(\mathcal{N})})$, where $\mathcal{N}$ is the
\emph{bracketing number} of $\H$ with respect to the uniform
distribution.\footnote{Along the way, we also demonstrate a stronger
regret bound for the simpler case of non-adaptive adversaries,
for which each distribution $\D_t$ is independent of the realized
inputs in previous time steps.}
Bracketing number is the size of an $\epsilon$-cover of $\H$ with the additional property that hypotheses in the cover are \emph{pointwise} approximations of those in $\H$.
We show that for many hypothesis classes, the bracketing number is nicely bounded as a function of the VC dimension. This leads to the regret bound of $\tilde O( \sqrt{T\ \vc(\H)\ln(1/\sigma)})$ for commonly used hypothesis classes in machine learning, such as halfspaces, polynomial threshold functions, and polytopes.
In comparison, these hypothesis classes have infinite Littlestone
dimension and thus cannot be learned with regret $o(T)$ in the worst case~\citep{ben2009agnostic}.
From a technical perspective, we introduce a novel approach for
bounding time-correlated non-independent stochastic processes over
infinite hypothesis classes using the notion of bracketing
number. Furthermore, we introduce systematic approaches, such as
high-dimensional linear embeddings and $k$-fold operations, for
analyzing the bracketing number of complex hypothesis classes. We
believe these techniques are of independent interest.
\item For differentially private learning, we obtain an error bound of
$\tilde O\big( \ln^{\frac 38}(1/\sigma)\sqrt{\vc(\H) /n} \big)$; the
key point is that this bound is independent of the size~$|\X|$ of
the domain and the size $|\H|$ of the hypothesis class. We obtain
these bounds by modifying two commonly used mechanisms in
differential privacy, the Multiplicative Weight Exponential Mechanism of
\cite{NIPS2012_4548} and the SmallDB algorithm of \cite{SmallDB}.
With worst-case adversaries,
these algorithms achieve only error bounds of
$\tilde O(\ln^{\frac 14}(|\X|)\sqrt{\ln(|\H|) /n})$ and
$\tilde O( \sqrt[3]{\vc(\H) \ln(|\X|) / n} )$, respectively.
Our results also improve over those in~\citet{DPMultWeights} which
concern a similar notion of
smoothness and achieve an error bound of
$\tilde O( \ln^{\frac 12}(1/\sigma)\sqrt{ \ln(|\H|) / n})$.
\end{itemize}
\paragraph{Other Related Works.}
At a higher level, our work is related to several works on the intersection of machine learning and beyond the worst-case analysis of algorithms (e.g., \citep{Dispersion,dekel2017online,kannan2018smoothed})
that are covered in more detail in \hyperref[app:related]{Appendix \ref*{app:related}}.
\section{Preliminaries}
\textbf{Online Learning.}~
We consider a measurable instance space $\X$ and the
label set $\Y = \{+1 , -1\}$. Let $\H$ be a hypothesis class on $\X$ with its VC dimension denoted by $\vc(\H)$.
Let $\U$ be the uniform distribution over $\X$ with density function $u(\cdot)$.
For a distribution $\D$ over $\X\times \Y$, let $p(\cdot)$ be the \emph{probability density function} of its marginal over $\X$. We say that $\D$ is \emph{$\sigma$-smooth} if for all $x\in \X$, $p(x) \leq u(x) \sigma^{-1}$.
For a labeled pair $s = (x, y)$ and a hypothesis $h\in \H$,
$\err_{s}(h) = 1(h(x) \neq y)$ indicates whether $h$ makes a
mistake on $s$.
We consider the setting of \emph{online adversarial and (full-information) learning}. In this setting, a learner and an adversary play a repeated game over $T$ time steps.
In every time step $t\in [T]$ the learner picks a hypothesis $h_t$ and adversary picks a $\sigma$-smoothed distribution $\D_t$ from which a labeled pair $s_t = (x_t, y_t)$ such that $s_t\sim \D_t$ is generated. The learner then incurs penalty of $\err_{s_t}(h_t)$.
We consider two types of adversaries. First (and the subject of our main results) is called
an \emph{adaptive} $\sigma$-smooth adversary. This adversary at every time step $t\in [T]$ chooses $\D_t$ based on the actions of the
learner $h_1,\dots, h_{t-1}$ and, importantly, the realizations of the previous
instances $s_1, \dots, s_{t-1}$. We denote this adaptive random process by
$\vec s \sim \adist$.
A second and less powerful type of adversary is called a \emph{non-adaptive} $\sigma$-smooth adversary. Such an adversary first chooses an unknown sequence of
distributions $\nadist = (\D_1, \dots, \D_T)$ such that $\D_t$ is a
$\sigma$-smooth distribution for all $t\in [T]$. Importantly, $\D_t$ does not depend on realizations of adversary's earlier actions $s_1, \dots, s_{t-1}$ or the learner's actions $h_1, \dots, h_{t-1}$. We denote this non-adaptive random process by $\vec s \sim \nadist$.
With a slight abuse of notation, we denote by $\vec x\sim \adist$ and $\vec x\sim \nadist$ the sequence of (unlabeled) instances in $\vec s \sim \adist$ and $\vec s\sim \nadist$.
Our goal is to design an online algorithm $\A$ such that expected regret against an adaptive adversary,
\[
\E[\regret(\A, \adist)]{:=}\E_{\vec s\sim \adist} \left[ \sum_{t=1}^T \err_{s_t}(h_t)
- \min_{h\in \H} \sum_{t=1}^T \err_{s_t}(h)
\right]
\]
is sublinear in $T$. We also consider the regret of an algorithm against a non-adaptive adversary defined similarly as above and denoted by $\E[\regret(\A, \nadist)]$.
\paragraph{Differential Privacy.}
We also consider differential privacy. In this setting, a data set $S$ is a multiset of elements from domain $\X$. Two data sets $S$ and $S'$ are said to be \emph{adjacent} if they differ in at most one element.
A randomized algorithm $\M$ that takes as input a data set is $(\epsilon, \delta)$-differentially private if for all $\mathcal{R}\subseteq \mathrm{Range(\M)}$ and for all adjacent data sets $S$ and $S'$, $\Pr \left[ \M \left(S \right) \in \mathcal{R} \right] \leq \exp(\epsilon) \Pr\left[ \M\left(S' \right) \in \mathcal{R} \right] + \delta$.
If $\delta = 0$, the algorithm is said to be purely $\epsilon$-differentially private.
For differentially private learning, one considers a fixed class of \emph{queries} $\Q$.
The learner's goal is to evaluate these queries on a given data set $S$.
For ease of notation, we work with the empirical distribution $\D_S$ corresponding to a data set $S$.
Then the learner's goal is to approximately compute $q(\D_S) = \E_{x\sim \D_S}[q(x)]$ while preserving privacy\footnote{In differentially private learning, queries are the error function of hypotheses and take as input a pair $(x,y)$.}.
We consider two common paradigms of differential privacy. First, called \emph{query answering}, involves designing a mechanism that outputs values $v_q$ for all $q\in \mathcal{Q}$ such that
with probability $1-\beta$ for every $q\in Q$, $|q(\D_S) - v_q| \leq \alpha$.
The second paradigm, called \emph{data release}, involves designing a mechanism that outputs a synthetic distribution $\overline{\D}$, such that with probability $1-\beta$ for all $q\in \mathcal{Q}$, $|q(\overline{\D}) - q(\D_S)|\leq \alpha$. That is, the user can use $\overline{\D}$ to compute the value of any $q(\D_S)$ approximately.
Analogous to the definition of smoothness in online learning, we say that a distribution $\D$ with density function $p(\cdot)$ is \emph{$\sigma$-smooth} if $p(x) \leq \sigma^{-1}u(x)$ for all $x \in \X$. We also work with a weaker notion of smoothness of data sets. A data set $S$ is said to be
\emph{$\left(\sigma, \chi\right)$-smooth} with respect to a query set $\Q$ if there is a $\sigma$-smooth
distribution $\D $ such that for all $q \in \Q$, we have $ \abs{ q\left({\D} \right) - q\left(\D_S \right) } \leq \chi $.
The definition of $\left(\sigma, \chi\right)$-smoothness, which is also referred to as \emph{pseudo-smoothness} by
\cite{DPMultWeights}, captures data sets that though might be concentrated on some elements, the query class is not capable of noticing their lack of smoothness.
\paragraph{Additional Definitions.}
Let $\H$ be a hypothesis class and let $\D$ be a distribution.
$\H'$ is an $\epsilon$-cover for $\H$ under $\D$ if for all $ h\in \H $, there is a $h' \in \H' $ such that $ \Pr_{x \sim \D} \left[ h \left( x \right) \neq h'\left( x \right) \right] {\leq \epsilon} $.
For any $\H$ and $\D$, there an $\epsilon$-cover $\H'\subseteq \H$ under $\D$ such that $|\H'| \leq (41/\epsilon)^{\vc(\H)}$ (\cite{HAUSSLER1995217}).
We define a partial order $\preceq$ over functions such that $f_1\preceq f_2$ if and only if for all $x\in \X$, we have $f_1(x) \leq f_2(x)$.
For a pair of functions $f_1, f_2$ such that $f_1\preceq f_2$, a \emph{bracket} $\left[ f_1 , f_2 \right]$ is defined by $
\left[ f_1 , f_2 \right] = \left\{ f : \X \to \left\{ -1,1\right\} : f_1 \preceq f \preceq f_2 \right\}.$
Given a measure $\mu$ over $\X$, a bracket $\left[f_1, f_2 \right]$ is called an \emph{$\epsilon$-}bracket if $\Pr_{x\sim \mu}\left[ f_1(x) \neq f_2(x) \right]\leq \epsilon$.
\begin{definition}[Bracketing Number]
Consider an instance space $\X$, measure $\mu$ over this space, and hypothesis class $\F$.
A set $\bnet$ of brackets is called an \emph{$\epsilon$-bracketing of $\F$ with respect to measure $\mu$} if all brackets in $\bnet$ are $\epsilon$-brackets with respect to $\mu$ and for every $f\in \F$ there is $[f_1, f_2] \in \bnet$ such that $f\in [f_1,f_2]$.
The \emph{$\epsilon$-bracketing number} of $\F$ with respect to measure $\mu$, denoted by $\bnumber{\mathcal{F}}{ \mu }{ \epsilon }$, is the size of the smallest $\epsilon$-bracketing for $\F$ with respect to $\mu$.
\end{definition}
\section{Regret Bounds for Smoothed Adaptive and Non-Adaptive Adversaries}
\label{sec:regret-prelim}
In this section, we obtain regret bounds against smoothed adversaries.
For finite hypothesis classes $\H$, existing no-regret algorithms such as Hedge~\citep{HEDGE} and Follow-the-Perturbed-Leader~\citep{FTPL} achieve a regret bound of $O( \sqrt{T \ln(\H)} )$.
For a possibly infinite hypothesis class our approach uses a finite set $\H'$ as a \emph{proxy} for $\H$ and only focuses on competing with hypotheses in $\H'$ by running a standard no-regret algorithm on $\H'$.
Indeed, in absence of smoothness of $\adist$, $\H'$ has to be a good proxy with respect to every distribution or know the adversarial sequence ahead of time, neither of which are possible in the online setting. But when distributions are smooth, $\H'$ that is a good proxy for the uniform distribution can also be a good proxy for all other smooth distributions.
We will see that how well a set $\H'$ approximates $\H$ depends on adaptivity (versus non-adpativity) of the adversary.
Our main technical result in \hyperref[sec:regret]{Section \ref*{sec:regret}} shows that
for adaptive adversaries this approximation depends on the size of the $\frac{\sigma}{4\sqrt{T}}$-bracketing cover of $\H$. This results in an algorithm whose regret
is sublinear in $T$ and logarithmic in that bracketing number for adaptive adversaries (\hyperref[thm:main-ada]{Theorem~\ref*{thm:main-ada}}). In comparison, for simpler non-adaptive adversaries this approximation depends on the size of the more traditional $\epsilon$-covers of $\H$, which do not require pointwise approximation of $\H$. This leads to an algorithm against non-adaptive adversaries with an improved regret bound of $\tilde O(\sqrt{T \cdot \vc(\H)})$ (\autoref{thm:main-ada}).
In \hyperref[sec:bracket-eg]{Section \ref*{sec:bracket-eg}}, we demonstrate that the bracketing numbers of commonly used hypothesis classes in machine learning are small functions of their VC dimension. We also provide systematic approaches for bounding the bracketing number of complex hypothesis classes in terms of the bracketing number of their simpler building blocks. This shows that for many commonly used hypothesis classes --- such as halfspaces, polynomial threshold functions, and polytopes --- we can achieve a regret of $\tilde O(\sqrt{T \cdot \vc(\H)})$ even against an adaptive adversary.
\subsection{Regret Analysis and the Connection to Bracketing Number}
\label{sec:regret}
In more detail, consider an algorithm $\A$ that uses Hedge on a finite set $\H'$ instead of $\H$. Then,
\begin{equation} \label{eq:regretdecomposition}
\E[\regret(\A, \adist)] \leq O\left( \sqrt{T \ln(|\H'|)} \right) + \E_{\adist}\left[\max_{h\in \H}\min_{h'\in \H'} \sum_{t=1}^T 1\left(h(x_t) \neq h'(x_t) \right) \right],
\end{equation}
where the first term is the regret against the best $h'\in \H'$ and the second term captures how well $\H'$ approximates $\H$.
A natural choice of $\H'$ is an $\epsilon$-cover of $\H$ with respect to the uniform distribution, for a small $\epsilon$ that will be defined later.
This bounds the first term using the fact that there is an $\epsilon$-cover $\H'\subseteq \H$ of size $|\H'|\leq (41/\epsilon)^{\vc(\H)}$.
To bound the second term, we need to understand whether there is a hypothesis $h\in \H$ whose value over \emph{an adaptive sequence of $\sigma$-smooth distributions} can be drastically different from the value of its closest (under uniform distribution) proxy $h'\in \H'$. Considering the symmetric difference functions $f_{h, h'} = h\Delta h'$ for functions $h\in \H$ and their corresponding proxies $h'\in \H'$, we need to bound (in expectation) the maximum value an $f_{h,h'}$ can attain over an adaptive sequence of $\sigma$-smooth distributions.
\paragraph{Non-Adaptive Adversaries.} To develop more insight, let us first consider the case of \emph{non-adaptive} adversaries. In the case of non-adaptive adversaries, $x_t\sim \D_t$ are \emph{independent} of each other, while they are not identically distributed.
This independence is the key property that allows us to use the VC dimension of the set of functions $\{f_{h, h'}\mid \forall h\in \H \text{ and the corresponding proxy } h'\in \H' \}$ to establish a uniform convergence property where with high probability every function $f_{h,h'}$ has a value that is close to its expectation --- the fact that $x_t$s are not identically distributed can be easily handled because the double sampling and symmetrization trick in VC theory can still be applied as before.
Furthermore, $\sigma$-smoothness of the distributions implies that
$\E_{\nadist}[\sum f_{h,h'}(x_t)] \leq \sigma^{-1} \E_{\U}[\sum f_{h,h'}(x_t)] \leq \epsilon/\sigma$. This leads to the following theorem for non-adaptive adversaries.
\begin{theorem}[Non-Adaptive Adversary~\citep{haghtalab2018foundation}] \label{thm:nonadaptive}
Let $\H$ be a hypothesis class of VC dimension $d$. There is an algorithm such that for any $\nadist$ that is an non-adaptive sequence of $\sigma$-smooth distributions has regret
$ \E[\regret(\A,\nadist)] \in O \left( \sqrt{ d T \ln\left(\frac T \sigma \right)} \right).$
\end{theorem}
\paragraph{Adaptive Adversaries.}
Moving back to the case of adaptive adversaries, we unfortunately lose this uniform convergence property (see \hyperref[app:ExampleUC]{Appendix \ref*{app:ExampleUC}} for an example).
This is due to the fact that now the choice of $\D_t$ can depend on the earlier realization of instances $x_1, \dots, x_{t-1}$.
To see why independence is essential, note that the ubiquitous double sampling and symmetrization techniques used in VC theory require that taking two sets of samples $\vec x$ and $\vec x'$ from the process that is generating data, we can swap $x_i$ and $x'_i$ independently of whether $x_j$ and $x'_j$ are swapped for $j\neq i$. When the choice of $\D_t$ depends on $x_1, \dots, x_{t-1}$ then swapping $x_\tau$ with $x'_\tau$ affects whether $x_t$ and $x'_t$ could even be generated from $\D_t$ for $t>\tau$.
In other words, symmetrizing the first $t$ variables generates $2^t$ possible choices for $x^{t+1}$ that exponentially increases the set of samples over which a VC class has to be projected, therefore losing the typical $\sqrt{T \cdot\vc(\H)}$ regret bound and instead obtaining the trivial regret of $O(T)$. Nevertheless, we show that the earlier ideas for bounding the second term of \autoref{eq:regretdecomposition} are still relevant as long as we can side step the need for independence.
Note that $\sigma$-smoothness of the distributions still implies that for a fixed function $f_{h,h'}$ even though $\D_t$ is dependent on the realizations $x_1, \dots, x_{t-1}$, we still have $\Pr_{x_t\sim \D_t}[f_{h,h'}(x_t)]\leq \epsilon/\sigma$.
Indeed, the value of any function $f$ for which $\E_{\U}[f(x)] \leq \epsilon$ can be bounded by the convergence property of an appropriately chosen Bernoulli variable. As we demonstrate in the following lemma, this allows us to bound the expected maximum value of a $f_{h,h'}$ \emph{chosen from a finite set of symmetric differences.} For a proof of this lemma refer to \hyperref[app:Proofoffinite]{Appendix \ref*{app:Proofoffinite}}.
\begin{lemma}
\label{lem:union-ada}
Let $\F: \X\rightarrow \{0,1\}$ be any finite class of functions such that $\E_{\U}[f(x)]\leq \epsilon$ for all $f\in \F$, i.e., every function has measure $\epsilon$ over the uniform distribution.
Let $\adist$ be any adaptive sequence of $T$, $\sigma$-smooth distributions for some $\sigma\geq \epsilon$ such that $T\frac\epsilon\sigma \geq \sqrt{\ln(|\F|)}$. We have that
\[
\E_{\vec x \sim \adist} \left[\max_{f\in \F}\sum_{t=1}^T f(x_t) \right] \leq O\left(T\frac{\epsilon}{\sigma} \sqrt{ \ln(|\F|)} \right).
\]
\end{lemma}
The set of symmetric differences $\G = \{f_{h, h'}\mid \forall h\in \H \text{ and the corresponding proxy } h'\in \H' \}$ we work with is of course infinitely large. Therefore, to apply \hyperref[lem:union-ada]{Lemma \ref*{lem:union-ada}} we have to approximate $\G$ with a finite set $\F$ such that
\begin{equation}\label{eq:need-bracket}
\E_{\vec x \sim \adist}\left[\max_{f_{h,h'}\in \G} \sum_{t=1}^T f_{h,h'}(x_t) \right] \lesssim \E_{\vec x \sim\adist}\left[\max_{f\in \F} \sum_{t=1}^T f(x_t) \right].
\end{equation}
What should this set $\F$ be? Note that choosing $\F$ that is an $\epsilon$-cover of $\G$ under the uniform distribution is an ineffective attempt plagued by the the same lack of independence that we are trying to side step.
In fact, while all functions $f_{h,h'}$ are $\epsilon$ close to the constant $0$ functions with respect to the uniform distribution, they are activated on different parts of the domain. So it is not clear that an adaptive adversary, who can see the earlier realizations of instances, cannot ensure that one of these regions will receive a large number realized instances.
But a second look at \autoref{eq:need-bracket} suffices to see that this is precisely what we can obtain if $\F$ were to be the set of (upper) functions in an $\epsilon$-bracketing of $\G$.
That is, for every function $f_{h ,h'}\in \G$ there is a function $f \in \F$ such that $f_{h,h'}\preceq f$. This proves \autoref{eq:need-bracket} with an exact inequality using the fact that pointwise approximation $f_{h,h'}\preceq f$ implies that the value of $f_{h,h'}$ is bounded by that of $f$ for any set of instances $x_1, \dots, x_T$ that could be generated by $\adist$. Furthermore, functions in $\G$ are
within $\epsilon$ of the constant $0$ function over the uniform distribution, so $\F$ meets the criteria of \hyperref[lem:union-ada]{Lemma \ref*{lem:union-ada}} with the property that for all $f\in \F$, $\E_\U[f(x)]\leq \epsilon$.
It remains to bound the size of class $|\F|$ in terms of the bracketing number of $\H$. This can be done by showing that the bracketing number of class $\G$, that is the class of all symmetric differences in $\H$, is approximately bounded by the same bracketing number of $\H$ (See \autoref{thm:k-fold} for more details).
Putting these all together we get the following regret bound against smoothed adaptive adversaries.
\begin{theorem}[Adaptive Adversary]
\label{thm:main-ada}
Let $\H$ be a hypothesis class over domain $\X$, whose $\epsilon$-bracketing number with respect to the uniform distribution over $\X$ is denoted by $\bnumber{\H}{\U}{\epsilon}$. There is an algorithm such that for any $\adist$ that is an adaptive sequence of $\sigma$-smooth distributions has regret
\[ \E[\regret(\A,\adist)] \in
O\left( \sqrt{T \ln\left( \bnumber{\H}{\U}{ \frac{\sigma}{4\sqrt T}} \right)}
\right).
\]
\end{theorem}
\subsection{Hypothesis Classes with Small Bracketing Numbers.}
\label{sec:bracket-eg}
In this section, we analyze bracketing numbers of some commonly used hypothesis classes in machine learning.
We start by reviewing the bracketing number of halfspaces and provide two systematic approaches for extending this bound to other commonly used hypothesis classes.
Our first approach bounds the bracketing number of any class using the dimension of the space needed to embed it as halfspaces.
Our second approach shows that $k$-fold operations on any hypothesis class, such as taking the class of intersections or unions of all $k$ hypotheses in a class, only mildly increase the bracketing number.
Combining these two techniques allows us to bound the bracketing number of commonly used classifiers such as halfspaces, polytopes, polynomial threshold functions, etc.
The connection between bracketing number and VC theory has been explored in recent works. \citet{adams2010,adams2012} showed that finite VC dimension class also have finite $\epsilon$-bracketing number but \cite{AlonWezlHaussler} (see \cite{UGC} for a modern presentation) showed the dependence on $1/\epsilon$ can be arbitrarily bad.
Since \autoref{thm:main-ada} depends on the growth rate of bracketing numbers, we work with classes for which we can obtain $\epsilon$-bracketing numbers with reasonable growth rate, those that are close to the size of standard $\epsilon$-covers.
\begin{theorem}[\cite{Bracket_Halfspaces}]\label{thm:half_brack}
Let $\H$ be the class of halfspaces over $\br^d$. For any $\epsilon >0$ and any measure $\mu$ over $\br^d$,
$ \bnumber{\H}{\mu}{\epsilon} \leq \left( \frac{d}{\epsilon} \right)^{ O\left( d \right) }.$
\end{theorem}
Our first technique uses this property of halfspaces to bound the bracketing number of any hypothesis class as a function of the dimension of the spaces needed to embed this class as halfpsaces.
\begin{definition}[Embeddable Classes]
Let $\mathcal{G}$ be a hypothesis class on $ \mathcal{X} $.
We say that $ \mathcal{G} $ is embeddable as halfspaces in $m$ dimensions if there exists a map $ \psi : \mathcal{X} \to \br^m $ such that for any $g \in \mathcal{G} $, there is a linear threshold function $h$ such $ g = h \circ \psi $.
\end{definition}
\begin{theorem}[Bracketing Number of Embeddable Classes]
\label{thm:embeddable}
Let $\mathcal{G}$ be a hypothesis class embeddable as halfspaces in $m$ dimensions.
Then, for any measure $\nu$,
$ \bnumber{ \mathcal{G} }{\nu}{\epsilon} \leq \left( \frac{m}{\epsilon} \right) ^{O\left( m \right)}.
$
\end{theorem}
Our second technique shows that combining $k$ classes, by respectively taking intersections or unions of any $k$ functions from them, only mildly increases their bracketing number.
\begin{theorem}[Bracketing Number of $k$-fold Operations]
\label{thm:k-fold}
Let $\F_1, \dots, \F_k$ be $k$ hypothesis classes. Let $\F_1\cdot \F_2\cdots \F_k$ and $\F_1+\F_2 + \cdots + \F_k$ be the class of all hypotheses that are intersections and unions of $k$ functions $f_i\in \F_i$, respectively. Then,
\[ \bnumber{\F_1\cdot \F_2 \cdots \F_k}{\mu}{k \epsilon} \leq \prod_{i\in [k]} \bnumber{\F_i}{\mu}{\epsilon} \]
and
\[ \bnumber{\F_1+\F_2 +\cdots + \F_k}{\mu}{k\epsilon} \leq \prod_{i\in [k]} \bnumber{\F_i}{\mu}{\epsilon}. \]
For any hypothesis class $\F$ and $\G = \{ f\Delta f' \mid \text{ for all} f, f'\in \F\}$,
$ \bnumber{\G}{\mu}{4 \epsilon} \leq \left( \bnumber{\F}{\mu}{\epsilon} \right)^4.$
\end{theorem}
We now use our techniques for bounding the bracketing number of complex classes by the bracketing number of their simpler building blocks to show that online learning with an adaptive adversary on a class of halfspaces, polytopes, and polynomial threshold functions has $\tilde O(\sqrt{T\ \vc(\H)})$ regret.
\begin{corollary}
\label{cor:bnumber}
Consider instance space $\X = \br^n$ and let $\mu$ be an arbitrary measure on $\X$.
Let $\mathcal{P}^{n,d}$ be the class of $d$-degree \emph{polynomial thresholds} and $\mathcal{Q}^{n,k}$ be the class $k$-polytopes in $\br^n$. Then,
\[
\bnumber{\mathcal{P}^{n,d}}{\mu}{\epsilon} \leq \exp\left(c_1 n^d \ln\left( n^d/\epsilon \right) \right)
\text{ and }
\bnumber{\mathcal{Q}^{n, k}}{\mu}{\epsilon}\leq \exp\left(c_2 nk \ln\left( \frac{nk}{\epsilon} \right) \right),
\]
for some constants $c_1$ and $c_2$. Furthermore, there is an online algorithm whose regret against an adaptive $\sigma$-smoothed adversary on the class
$\mathcal{P}^{n,d}$
and $\mathcal{Q}^{n, k}$ is respectively $\tilde O(\sqrt{T \cdot \vc(\mathcal{P}^{n,d})\ln(1/\sigma)} )$ and $\tilde O(\sqrt{T \cdot \vc(\mathcal{Q}^{n,k}) \ln(1/\sigma)} )$.
\end{corollary}
| {'timestamp': '2020-06-19T02:02:49', 'yymm': '2006', 'arxiv_id': '2006.10129', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10129'} | arxiv |
\section{INTRODUCTION}
\IEEEPARstart{I}{n} the past, people have been developing both exchangeable robotic end-effectors, e.g., parallel grippers and suction cups, and dexterous robotic end-effectors, e.g., anthropomorphic hands, to meet the multi-purpose requirements in both industry and academia. Unfortunately, none of these end-effectors are general enough to meet all needs. The exchangeable end-effectors require extra tool-changing mechanisms and power cables or vacuum supply tubes to be firmly connected to the end of a robot arm. The exchanging process is time-consuming and fragile. On the other hand, dexterous hands are complicated, expensive, and difficult to control. Even if the control problem is solved, the generality of a dexterous hand is still unclear as they assimilate a human hand, and may not be more flexible than a human hand.
\begin{figure}[!t]
\begin{center}
\includegraphics[width=0.97\linewidth]{figure/teaser.jpg}
\caption{The proposed mechanical screwing tool. It employs a Scissor-Like Element (SLE) mechanism and a double-ratchet mechanism to convert parallel gripping motion to continuous rotating motion. (a-1,2) The CAD models of the design. (b-1) A prototype. (b-2,3) The prototype held by a parallel gripper. Note: Only the front end is visible. The back end is the same as the front end except that the rotating direction is reversed.}
\label{teaser}
\end{center}
\end{figure}
Under this background, we proposed that instead of directly using the end-effectors, robots may use the mechanical tools to perform various tasks. Over the years, humans were developing tools for themselves. Instead of humans, we proposed to develop tools for intelligent robots. We design mechanical gadget tools considering the constraints from a general robotic gripper and specific tasks. We demonstrate that intelligent robots could select and use the designed tool through vision and planning, and successfully work in narrow workspaces where they cannot reach using their hands. These tools are purely mechanical and free of power supply. They are small and convenient. They can be freely placed in a robot workspace and selected and used by robots.
In our previous study \cite{zhengtao2019}, we designed a nipper tool for a robot hand to squeeze various sized objects. The nipper enforces a robot gripper by extending the parallel motion. Following a similar conception, we in this paper present a new type of mechanical tool which converts the parallel motion of a robotic gripper to continuous rotation, as is shown in Fig.\ref{teaser}. The tool's essential structure is based on a Scissor-Like Elements (SLEs) and a double-ratchet mechanism. The SLEs form the mainframe of the tool. It helps to keep a fixed rotation center during transmission. In order to make the structure compact, the holding pads are optimized to have a curved profile to reduce the length of the SLE arms. The double-ratchet unit is installed concentrically to the pivoting center of the SLEs. It is made of two ratchets with reversed locking directions. The two ratchets are fixed to the arms of the front and back SLEs respectively. They are connected to each other by a central shaft. Torsion springs are installed at the SLE joints to both provide enough resistant pressure for being held by robotic grippers and stretching the tool. The tool is entirely mechanical, allowing robots to use the tool without any peripherals and power supply. The paper presents the details of the tool design, optimizes its dimensions and effective stroke lengths, and studies the contacts and forces to achieve stable grasping and screwing.
Besides the design, the paper develops manipulation policies for the tool. The policies include visual recognition, picking-up and manipulation, and exchanging tooltips. The developed tool produces clockwise rotation at the front end and anti-clockwise rotation at the back end. Various tooltips can be installed at both two ends. Robots may employ the developed manipulation policies to exchange the tooltips as well as switching the rotating directions following the needs of specific fastening or loosening tasks. Robots can also reorient the tool using pick-and-place or handover, and move the tool to work poses using the policies.
The remaining sections of this paper present the design and optimization of the mechanical screwing tool, its manipulation policies, as well as experiments and analysis. Three prototypes of the tool are fabricated and compared to show the design's advantages and its optimization. Experiments are carried out to verify the design. Real-world robotic applications are performed to demonstrate the robustness and usefulness. The tool is small, cordless, convenient, and has good robustness and adaptability.
\section{RELATED WORK}
We concentrate the literature review on screw fastening tasks, robotic end-effector design, and robotic applications that use tools.
\subsection{Screw Fastening Tasks}
The screw fastening is a labor-intensive task faced widely in industrial assembly. A screw fastening task consists of alignment, joining, insertion, and fastening \cite{seneviratne1992theoretical}, which is challenging for robotic manipulation\cite{lee2005studying}. Previous solutions usually use (1) special-purpose robots or special-purpose robotic end-effectors, or (2) general robots plus screwing tools to perform screw fastening tasks.
Lots of specially designed screwing robots are available in the literature. For example, a mobile robot designed for drilling and fastening was presented in \cite{adams2014next}. A 4-DoF screw fastening robot with a visual servo system was presented in \cite{pitipong2010automated}. These robots can effectively complete the fastening job in the structural environment but short in flexibility. Besides the special-purpose robots, many studies use special-purpose end-effectors mounted on the end of a robot arm to perform the screw fastening tasks \cite{cherubini2015unified}\cite{matsuno2013fault}\cite{dhayagude1996fuzzy}. The advantage of a special-purpose end-effector is since it can move more freely and stably following the hosting robot arm. The drawback is an end-effector highly constrains the function of a robot arm into a single-purpose manipulator. Some interesting multi-purpose end-effectors are introduced in \cite{yokokohji2019assembly} to solve the problem, where a robot hand with a built-in screwdriver can both grip and screw, but the mechanism and the various peripheral connections are complex and bulky.
Beyond the special-purpose design, robots can also complete the screw fastening task by using driver tools like humans. For example, an electric driver with a tool adapter for humanoid robots was presented in \cite{pfeiffer2017nut}. The electric driver is a general one, and thus, the system is more flexible, although the tool adapter still needs to be designed carefully. Drigalski et al. \cite{von2020team} and Nie et al. \cite{nie2020team} respectively proposed electric drivers and wrenches which have cuboid bodies for being grasped by general parallel grippers. In \cite{murooka2019self}, a robot is demonstrated to use a hex wrench to fasten the screws of its own body. Developing robots to use tools is an important research topic in robotics. Most previous studies concentrated on the recognition and manipulation of the tools. The relative work to these topics will be reviewed later in the third part of this section.
Unlike using an electric tool or manipulating a driver to perform a screwing motion, we design a mechanical tool which can convert the parallel gripping motion into rotation, and use the tool to fasten screws. Our work involves both the design and manipulation policies for tool use. Thus in the next two subsections, related work on tool design and tool use are presented. Especially since the tool design requires similar knowledge and principles as robotic end-effector design without power supplies, we review the literature in the boarder field of robotic end-effector design.
\subsection{Robotic End-effector Design}
An end-effector is a device mounted on the end of a robot. It is determined according to the usage of a robot, such as suction cups for picking, grippers for grasping, guns and torches for welding, sprayers for painting, sanders for polishing and buffing, etc \cite{miller2013industrial}. Designing a high-performance end-effector is an old and continuing topic in robotics. Previous studies cover a wide range of topics like the mechanical design, the actuation system, and the control of robotic end-effectors \cite{nof1999handbook}\cite{monkman2007robot}\cite{wolf2018grippers}. Since our goal is to design a mechanical tool for screwing, we focus on the literature about the mechanical structure. Our expectation is when the tool is held by a gripper, it can continuously output rotating torque in accordance with the continuous close-and-open of the gripper. Scissor-Like Element (SLE) and ratchet mechanism are employed as basic elements for the tool. Elastic elements are used to provide resisting force for holding the tool and producing torque output when the gripper releases the tool. We consequently focus our review on the SLE mechanism, the ratchet mechanism, and the elastic elements below.
SLE is a widely seen mechanical unit in scissors and scissor-like tools like pliers. A basic SLE element has two scissor arms that can freely rotate around a pivoting point \cite{zuk1970kinetic}. This basic element has many variations. For example, Monkman et al. \cite{monkman2007robot} and Khasawneh et al. \cite{khasawneh2014enhanced} respectively extended basic SLEs to a pantograph for transmitting the grasp stroke of grippers. Maden et al. \cite{maden2011review} reviewed Chained SLEs (C-SLE) used in planar or spatial structures. The C-SLE is a popular mechanism for robotic end-effector design. Yang et al. \cite{yang2017novel} presented a 2-DoF planar translational mechanism based on SLE-parallel -- a mechanism consisting of two identical SLE limbs which are connected at the two corresponding nodes by link. Corinaldi et al. \cite{corinaldi2016synthesis} proposed 3-DoF deployable gripper mechanism using SLEs and Sarrus linkages, which has a spatial structure to transmit motion symmetrically. Kocabas et al. \cite{kocabas2009gripper} developed a 1-DoF spherical gripper mechanism consisting of spiral SLEs and linkages for power grasping of various shapes. Ndawula et al. \cite{ndawula2018conceptual} proposed a double planar scissor mechanism mounted with multi-gripper for handling a row of seedlings. Not only the robotic end-effector designing, but SLE is also widely used in the structure of robot bodies \cite{bamdad2015design}\cite{luo2016scissor}, exoskeleton \cite{castro2019compact}, as well as more general mechatronic devices to perform tasks like mobile pavilions, foldable stairs, collapsible doors, etc \cite{zhao2011structure}\cite{akgun2011novel}.
A ratchet is a mechanism that allows continuous linear or rotary motion in one direction but locks the motion in the opposite direction. The feature makes a ratchet a widely used transmission mechanism \cite{rao2014power}\cite{dao2008micro}. In robotics, a ratchet is usually used as a locking device \cite{plooij2015lock}. Li et al. \cite{li2009spherical} developed a hopping robot, in which a locked ratchet mechanism is released to trigger an energy storage mechanism. Geeroms et al. \cite{geeroms2013ankle} developed an active knee-ankle prosthesis, in which a ratchet unit is used to lock the weight acceptance mechanism. As for the end-effector design, Abe et al. \cite{abe2012development} designed a reconfigurable end-effector for endoscopic surgery by using a bending mechanism where a ratchet unit is employed to lock and release transmission following the bending conditions. Gerez et al. \cite{gerez2018compact} and Sabetian et al. \cite{sabetian2011compound} focused on the development of underactuated grippers using ratchets. Besides, an electrostatic microgripper was presented in \cite{hao2015microgripper} by taking advantage of the locking feature of a ratchet.
Elastic elements are usually used for passive actuation in robotic mechanism design. Laliberte et al. \cite{laliberte2002underactuation} designed an underactuated finger by using elastic elements as switches for the underactuated joints. Xu et al. \cite{xu2016continuum} applied continuum differential mechanisms to a gripper design, in which elastic elements are used as bendable backbones. Chen et al. \cite{chen2018mechanical} analyzed the adaptability of the underactuated grippers constrained by elastic elements.
Instead of an end-effector, we design a tool for 2-finger parallel robotic grippers. The actuation force of the tool is only from the robotic grippers. Two modified C-SLE (mC-SLE) are used to convert the parallel robotic gripping motion into oscillating rotation. A double-ratchet mechanism is then connected to the two mC-SLEs to further convert the oscillating rotation into a unidirectional rotation. Like our previous nipper tool \cite{zhengtao2019}, elastic elements are used to provide resisting force for robotic grasping. They are also used to stretch the tool and maintain rotation when a robotic gripper releases the tool.
\subsection{Robotic Manipulation of Tools}
Using tools is an extensively studied robotic manipulation problem. With known models, developing robotic applications to use tools can be formulated and solved as a logical reasoning problem \cite{toussaint2018differentiable}\cite{brown2012relational}. The motion for using the tool can be planned by combined task and motion planning \cite{chen2019}. The task routine for using a tool is complicated, which, however, can be resolved into several subproblems \cite{gupta1998micro}\cite{tikhanoff2013exploring} like tool selection, tool recognition, constrained grasping and tool reorientation, etc. \cite{saito2018detecting}\cite{fang2020learning}\cite{saito2018tool}\cite{li1988task}. Practical systems can thus be implemented in a divide-and-conquer way.
Learning from demonstrations is also a popular approach to transfer the routine of using tools to robots. In \cite{Rajeswaran-RSS-18}, robots learned complicated manipulation like using a hammer through simulated demonstrations. In \cite{zhu2015understanding}, human demonstrations were captured by pose-tracking and were then employed to learn how to identify and use tools. Raessa et al. \cite{raessa2019teaching} proposed a human demonstration-based method for teaching robots to use tools with special consideration of regrasp planning. Additionally, instead of demonstration, Xie et al. \cite{xie2019improvisation} presented the method of using video prediction for reasoning the potential robot action to use the available objects as tools in an improvisational way. Besides the motion and task routine, many studies also focus on the various constraints and force problems. For example, Rachel et al. \cite{holladay2019force} studied the force constraints in the tool manipulation tasks. Toussaint et al. \cite{toussaint2018differentiable} studied the physical interaction between a tool and an object.
In this work, we design the mechanical screwing tool and develop the manipulation policies for a robot to use the tools for screw fastening tasks. Our novelty in using the tool is two-fold. First, the tool is a mechanical one with links, pivoting joints, and elastic elements. Thus we have to carefully study the contacts and forces for stable grasping and use. Second, our manipulation policies include recognition, picking-up and manipulation, and exchanging tooltips. The manipulation policies, especially exchanging the tooltips, extends the flexibility of the tool and the robotic system.
\section{THE MECHANICAL STRUCTURE}
\subsection{Scissor-Like Elements (SLEs)}
\subsubsection{The basic SLE and its problems}
Fig.\ref{basicsle}(a, b) show a basic SLE. The rotation of the basic SLE induces the translational motion of $segment$ $P_{1}P_{2}$ and $segment$ $P_{3}P_{4}$ (see the red segments and the arrows in Fig.\ref{basicsle}(a-b)). This property makes the basic SLE a good candidate mechanism for our tool, for the linear motion of $segment$ $P_{1}P_{2}$ and $segment$ $P_{3}P_{4}$ affords the motion of a parallel gripper.
\begin{figure}[!htbp]
\begin{center}
\includegraphics[width=0.97\linewidth]{figure/sle.jpg}
\caption{(a) A basic Scissor-Like Element (SLE). (b) The rotation of a basic SLE is around its pivoting joint. The rotation is converted into the translation motion of $segment$s $P_{1}P_{2}$ and $P_{3}P_{4}$, which could potentially afford the motion of a parallel gripper. However, the length of $segment$ $P_{1}P_{2}$ (also $segment$ $P_{3}P_{4}$) changes during the translation, making them not suitable to be held by fingers. (c) An intuitive solution to implement two graspable pads. $P_{2}$ and $P_{4}$ are rotating joints that connect the SLE arms and the two pads. $P_{1}$ and $P_{3}$ are free ends. The two pads keep steady as they close. A problem of this intuitive solution is the pivoting joint $O$ moves with the free ends.}
\label{basicsle}
\end{center}
\end{figure}
A shortcoming of the basic SLE is the length of $segment$ $P_{1}P_{2}$ (also $segment$ $P_{3}P_{4}$) changes during the translation. They turn into longer $segment$s $P^{'}_{1}P^{'}_{2}$ and $P^{'}_{3}P^{'}_{4}$, making them not suitable to be held by fingers. Thus, to ensure a stable hold, some points on the SLE arms must be fixed. Fig.\ref{basicsle}(c) shows an intuitive solution used in mini scissor lift. In this case, $P_{2}$ and $P_{4}$ are attached to two pads using rotational joints. $P_{1}$ and $P_{3}$ are free ends. As the two pads move close, $P_{2}$ and $P_{4}$ move up to $P^{'}_{2}$ and $P^{'}_{4}$. The pads move in a stable linear motion, which is suitable to be held.
The intuitive solution enables stable and linear pad motion but still does not meet the requirements of a screwing tool. As the pads close, the pivoting joint $O$ also moves up to $O^{'}$, as shown in Fig.\ref{basicsle}(c). A changing pivoting joint is not a good candidate for attaching the tooltip of a screwing tool. Thus further modification is needed to make the basic SLE valuable.
\subsubsection{Chained SLE (C-SLE) and the proposed modification}
We propose to use a modifiend C-SLE to solve the problems mentioned above. Following the C-SLE concept, one full and two half SLEs can be chained together to keep the position of the pivoting joint fixed while the two pads close. Fig.\ref{chainedsle} illustrates the idea. In Fig.\ref{chainedsle}(a), the blue links form a full SLE. The yellow links form two half SLEs. $P_{5}$ and $P_{6}$ are the rotational joints connected to the holding pads. While the gripper squeezes the mechanism, the distance between $P_{5}$ and $P_{6}$ will decrease so that $\alpha$ will be increased to make the arms rotate around the pivoting joint $O$. Also, $O$ is the center of $segment$ $P_{5}P_{6}$, and $P_{5}$-$O$-$P_{6}$ keep collinear all the time. The position of $O$ will remain unchanged while the robot gripper presses against $P_{5}$ and $P_{6}$.
\begin{figure}[!htbp]
\begin{center}
\includegraphics[width=0.97\linewidth]{figure/chainedsle.jpg}
\caption{(a) The structure and motion of a kinematic SLE chain made of one full SLE (blue) and two half SLEs (yellow). While $P_{5}$ and $P_{6}$ get close, $\alpha$ will increase so that the arms will rotate around $O$. Compared to Fig.\ref{basicsle}(c), the position of $O$ remains unchanged in the structure. The disadvantage of this design is that it cannot withstand external torque as there are only rotational constraints at $P_{5}$ and $P_{6}$. (b) The proposed C-SLE (Chained SLE) design. In this design, the arms of $OH_i (i=1,2,3,4)$ are further extended to $P_{i}$ to resist torque.}
\label{chainedsle}
\end{center}
\end{figure}
The disadvantage of the configuration shown in Fig.\ref{chainedsle}(a) is that it cannot withstand an external torque as there are only rotational constraints at $P_{5}$ and $P_{6}$. The design collapses if the pressing forces are not exactly exerted at $P_{5}$ and $P_{6}$. To avoid this problem, we extend the arms of the full basic SLE for support. As shown in Fig.\ref{chainedsle}(b), the cross $H_1H_4$-$H_2H_3$ is the full SLE. The $H_1$-$H_5$-$H_2$ and $H_3$-$H_6$-$H_4$ on the two sides are the two half SLEs. By extending $OH_1$ to $P_1$, $OH_2$ to $P_2$, $OH_3$ to $P_3$, and $OH_4$ to $P_4$, and use $P_1$-$P_4$ as the supporting joints, the mechanism can accept pressure at any positions on the two holding pads. The parallel motion of a robot gripper can be converted into a rotational motion around $O$. $P_{1}$-$H_{5}$-$P_{2}$ and $P_{3}$-$H_{6}$-$P_{4}$ maintain collinear during the rotation. Note that all the $P_{i} (i=1,2,3,4)$ play the role of a free end. Supporting wheels are therefore installed on them to enable the free motion. The arms $H_1P_1$, $H_2P_2$, $H_3P_3$, $H_4P_4$ are called the supporting arms. They are symmetric and have the same length. The arms $OH_1$, $OH_2$, $OH_3$, $OH_4$ are called the driving arms. They are also symmetric and have the same length.
This modified C-SLE design is called mC-SLE. We install two mC-SLEs in parallel to hold the double-ratchet mechanism and realize continuous rotating motion. The details are presented in the next subsection.
\subsection{Double-Ratchet Mechanism}
\subsubsection{The basic ratchet and its problems}
At the pivoting joint of the mC-SLE, as shown by the blue arrows in Fig.\ref{basicratchet}(b, c), the rotating motion oscillates with the open and close of the holding pads. Such motion does not meet the requirements of a screwing tool, where only a single-direction motion is needed. Thus, we use a ratchet mechanism to regulate the oscillating rotation into a single-direction rotation. Fig.\ref{basicratchet}(a) illustrates a basic ratchet. It comprises a ratchet gear or a rack with teeth and a pawl engaged with the gear teeth for locking. We attach the gear and the pawl of the basic ratchet to the pivoting center and one arm of the mC-SLE respectively. The arm will drive the pawl to push the ratchet gear to rotate in a locked condition, as shown by the yellow arrow in Fig.\ref{basicratchet}(b). In a released condition, as shown in Fig.\ref{basicratchet}(c), the pawl is pushed up by the ratchet gear and the rotation stops.
\begin{figure}[!htbp]
\begin{center}
\includegraphics[width=0.48\textwidth]{figure/basicratchet.jpg}
\caption{(a) The sketch of a basic ratchet. (b, c) The pawl of the ratchet is fixed on a driving mC-SLE arm. (b) The locking condition. In this condition, a mC-SLE arm drives the ratchet gear to rotate anti-clockwise. (c) The released condition. In this condition, the pawl is pushed up by the ratchet gear, and the gear does not rotate with the motion of the pawl. Note that the illustration in (c) is not always true. When the friction between the pawl tip and the gear teeth is larger than the gear's rotational resistance, the gear may rotate back together with the pawl, leading to a failure in the single-direction regulation.}
\label{basicratchet}
\end{center}
\end{figure}
A problem with the attachment is the ratchet gear does not necessarily stay stationary in a released condition. If the friction between the pawl tip and the gear teeth is larger than the rotational resistance of the gear, the gear may rotate back together with the pawl, leading to a failure in the single-direction regulation. Although a heavy rotation load may provide enough external torque to overcome the friction, it is, however, not a reasonable assumption as not all objects provide heavy load.
Also, even if the external torque in the released condition is large enough, the resulted motion is still an intermittent rotation instead of a continuous one. Thus, some modification to the basic ratchet must be included.
\subsubsection{The proposed double-ratchet mechanism}
We propose using a double-ratchet mechanism to solve the aforementioned problems. The design is shown in Fig.\ref{doubleratchet}(a). The pawls of the two basic ratchets are attached to two inversely rotating arms. When the front ratchet is in a locked condition, the back ratchet in a released condition. The front gear and also the central shaft can be driven by the front pawl to rotate in clockwise. The back gear also moves clockwise together with the central shaft. The friction between the pawl tip and the gear teeth of the bear ratchet mechanism is overcome by the driving force of the front ratchet. When the front ratchet is in a released condition, the back ratchet is in a locked condition. It will rotate clockwise and drive the central shaft and the gear of the front ratchet to rotate in the same way. Continuous clockwise rotation can thus be realized.
\begin{figure}[!htbp]
\begin{center}
\includegraphics[width=0.48\textwidth]{figure/doubleratchet.jpg}
\caption{(a) A double-ratchet mechanism driven by inversely rotating arms. (b) The proposed mechanical screwing tool design using two C-SLEs and a double-ratchet mechanism. The design is capable of producing continuous rotation.}
\label{doubleratchet}
\end{center}
\end{figure}
Fig.\ref{doubleratchet}(b) illustrates a mechanical screwing tool designed considering both the aforementioned mC-SLE and double-ratchet mechanism. The design can output rotation continuously. It involves two parallel and colinear mC-SLEs. On the front mC-SLE, a ratchet is attached to perform clockwise rotation when the pads are closed. Another ratchet is attached to an arm on the back mC-SLE to continue the rotation when the pads are open. The two ratchets are attached to inversely rotating arms to make sure they perform a rotation in a different direction when locked.
\section{ANALYSIS AND OPTIMIZATION}
In this section, we perform quasi-static force analysis on the design to study and optimize the output of the tool, as well as to make the tool stable and compact.
\subsection{Grasping the Tool}
\subsubsection{The condition to stably hold the tool}
We formulate the contact between the robot fingers and the holding pads as soft finger contacts \cite{harada2014stability}. The friction and force at the contact meet the following equation:
\begin{equation}
f_{grpr}^{2}+\frac{T_{grpr}^{2}}{e^{2}}\leqslant \mu^{2}P_{grpr}^{2}\label{eq-fa-1},
\end{equation}
where $P_{grpr}$ is the pressure force exerted by the robot finger, $T_{grpr}$ and $f_{grpr}$ are the torque and tangential force, $\mu$ is the friction coefficient, $e$ is an eccentricity parameter which can be computed as:
\begin{equation}
e^{2}=\frac{\max T_{grpr}^{2}}{\max f_{grpr}^{2}}\label{eq-fa-2}.
\end{equation}
When grasping the tool, the robotic finger pad may contact with the tool holding pad at an arbitrary position. Fig.\ref{fbd-sideview} shows an example. Here, $d_{com}$ indicates the distance between the Center of Mass (CoM) of the tool and the center of the contact. The forces at the contact can be analyzed following two conditions, as shown in Fig.\ref{fbd-vertical}. The first one is when the robot grasps the tool sufficiently. In this case, the force at the contact is a distribution shown in Fig.\ref{fbd-vertical}(a). The contact position must meet the following equation to make sure the tool can be stably held:
\begin{equation}
d_{com}\leqslant\sqrt{\frac{4\mu^{2} P^{2}_{grpr}e_{grpr}^{2}}{G_{tool}}-e^{2}}.
\label{condition}
\end{equation}
Here, $P_{grpr}$ can be computed by
\begin{equation}
P_{grpr}=\frac{4T_{sprg}+T_{rtct}}{4r_{drv}\cos{\alpha}},
\end{equation}
and
\begin{equation}
T_{sprg}=\xi(\gamma+\alpha-\alpha_{init}),
\label{springco}
\end{equation}
where $\xi$ is the elasticity coefficient of the torsion springs ($N\cdot mm/^{\circ}$). $\gamma$ indicates the pre-set rotational deformation of the torsion springs used in assembling the tool. $\alpha$ is the angle between the mC-SLE's driving arm and the holding pad. $\alpha_{init}$ is the $\alpha$ angle when the tool is at a free (initial) state. $r_{drv}$ is the length of the mC-SLE's driving arm. $T_{rtct}$ is the resisting torque caused by a reversing pawl.
\begin{figure}[!htbp]
\begin{center}
\includegraphics[width=0.48\textwidth]{figure/fbd-sideview.jpg}
\caption{The free body diagram of the tool from a side view.}
\label{fbd-sideview}
\end{center}
\end{figure}
\begin{figure}[!htbp]
\begin{center}
\includegraphics[width=0.48\textwidth]{figure/fbd-veritical.jpg}
\caption{(a) The free body diagram of the tool when it is held by a robot gripper. (b) The freebody diagram of the tool when it is bearing a maximum rotational load.}
\label{fbd-vertical}
\end{center}
\end{figure}
The second one follows a critical condition where the contact forces concentrate at one side of the finger pads. It happens when the tool is bearing a maximum rotational load. The forces must also meet \eqref{condition} to firmly hold the tool. Compared to the first one, the second case allows us to analyze the extremes, namely the maximum output torques at the tooltip. Thus we are more interested in it and analyze it in detail.
\subsubsection{Maximum output torque at the tooltip}
The critical condition in the second case has two extremes. The first extreme appears when the tool holding pads are squeezed. At this extreme, the output ends of the tool are rotated by the grabbing force of the robot gripper. The second extreme appears when the tool holding pads get stretched freely. At this extreme, the output ends are rotated by the repulsive force of the compressed torsion springs. The output torque at the tooltip reaches the squeezing maxima and the stretching maxima at the two extremes. Assume the grabbing force is $F_{grpr}$. At the first extreme, $F_{grpr}$ concentrates at $F_{grpr1}$, while $F_{grpr2}=0$. The maximum output torque can be computed by:
\begin{equation}
T_{sqz}=(F_{grpr}-\frac{T_{sprg}}{r_{drv}\cos{\alpha}})d_{fgr},
\label{output_sqz}
\end{equation}
where
\begin{equation}
d_{fgr}=w_{fgr}\sin{\beta} + l_{fgr}\sin{\beta}.
\label{output-dfinger}
\end{equation}
The symbols in equation \eqref{output-dfinger} are illustrated in Fig.\ref{fbd-sideview}. $w_{fgr}$ and $l_{fgr}$ are the width and height of the holding finger pad respectively. $\beta$ is the holding angle.
At the second extreme, $F_{grpr}$ concentrates at $F_{grpr2}$, while $F_{grpr1}=0$. The maximum output torque can be computed by:
\begin{equation}
T_{stch}=\frac{T_{sprg}}{r_{drv}\cos{\alpha}}d_{fgr}.
\label{output_stch}
\end{equation}
To have an intuitive view of the relation between $F_{grpr}$ and $T_{sqz}$, we set the parameters $\gamma$, $\xi$ to constants ($\gamma\leftarrow$0$^{\circ}$, $\xi\leftarrow$6.00$N\cdot mm/^{\circ}$) and examine the changes of $T_{sqz}$ with repsect to varying $F_{grpr}$, $\alpha$, $\beta$, and $r_{drv}$. The changes show insights on how the grasping force, jawwidth, and grasping pose influence the squeezing output. Fig.\ref{squeezingplot}(a) plots the results. Here, $\alpha$, $\beta$ and $r_{drv}$ are decoupled to make the function map visualizable. In Fig.\ref{squeezingplot}(a-1), $\beta$ and $r_{drv}$ are set to 57$^\circ$ and 20$mm$ to visualize the relation between ($F_{grpr}$, $\alpha$) and $T_{sqz}$. Fig.\ref{squeezingplot}(a-2) shows the changes of $T_{sqz}$ with repsect to different $F_{grpr}$ and $\beta$. $\alpha$ and $r_{drv}$ are set to fixed values, i.e., 45$^{\circ}$ and 20$mm$. The influence of $F_{grpr}$ and $\beta$ on $T_{sqz}$ is shown in Fig.\ref{squeezingplot}(a-3). Here, $\alpha$ and $\beta$ are fxied to 45$^{\circ}$ and 57$^{\circ}$.
\begin{figure}[!htbp]
\begin{center}
\includegraphics[width=0.48\textwidth]{figure/calculation-outputtk.jpg}
\caption{The left and right columns respectively show the changes of the output torque with respect varying $F_{grpr}$, $\alpha$, $\beta$, $r_{drv}$ in the squeezing phase, and varying $\xi$, $\alpha$, $\beta$, $r_{drv}$ in the stretching phase.}
\label{squeezingplot}
\end{center}
\end{figure}
Likewise, for the stretching output, Fig.\ref{squeezingplot}(b) plots changes of $T_{stch}$ with respect varying $\xi$, $\alpha$, $\beta$, and $r_{drv}$. $\gamma$ is set to $0^{\circ}$ in the analysis. The other parameters are fixed in the same way as the analysis in the squeezing phase.
\subsubsection{Velocities at the tooltip}
The rotation of the tooltips continuously spans the squeezing and stretching phases, as is shown in Fig.\ref{output-direction}. The black arrow in the figure marks the rotation of the output end. The triangle markers indicate the rotating angle from the starting position. Fig.\ref{output-direction}(a, b) is the squeezing phase. In this phase, the black arrow points to the yellow triangle marker initially. As the tool gets squeezed, the output end rotates clockwise to the blue triangle marker. The angle between the blue and yellow triangle markers is the squeezing phase's output rotation angle, which can be expressed as:
\begin{equation}
\delta_{sqz}=\alpha_{init}-\sin^{-1}{\left(\sin{\alpha_{init}}-\frac{v_{sqz}\cdot t_{sqz}}{4r_{drv}}\right)},
\end{equation}
where $\delta_{sqz}$, $t_{sqz}$ and $v_{sqz}$ indicate the output angle, the operating time, and the velocity of the gripper fingers in the squeezing phase, respectively.
\begin{figure}[!htbp]
\begin{center}
\includegraphics[width=0.48\textwidth]{figure/output-direction.jpg}
\caption{(a) The initial angle in a squeezing phase. (b) The output angle at the end of a squeezing phase. (c) The initial angle of a stretching phase. (d) The output angle at the end of a stretching phase.}
\label{output-direction}
\end{center}
\end{figure}
Fig.\ref{output-direction}(c, d) is the stretching phase that follows (a, b). The black arrow points to the blue marker initially. It is at the end state of the squeezing. As the tool gets stretched, the output end continues to rotate clockwise to the green triangle marker. The angle between the green and blue triangle markers is the output rotation angle of the stretching phase, which can be expressed as:
\begin{equation}
\delta_{stch}=-(\alpha_{init}-\delta_{sqz})+\sin^{-1}{\left(\sin{(\alpha_{init}-\delta_{sqz})}+\frac{v_{stch}\cdot t_{stch}}{4r_{drv}}\right)},
\end{equation}
where $\delta_{stch}$, $t_{stch}$ and $v_{stch}$ indicate the output angle, the operating time, and the velocity of gripper fingers in the stretching phase.
For a whole squeezing-stretching cycle, the total rotation angle, $\delta_{out}$, equals to the sum of $\delta_{sqz}$ and $\delta_{stretch}$. It is represented by a green sector in Fig.\ref{output-direction}(d). $\delta_{out}$ can be represented as a piecewise function of $t$ as follows
\begin{equation}
\begin{aligned}
\delta_{out}(t)=\left\{
\begin{array}{lcr}
\alpha_{init}-\sin^{-1}{\left(\sin{\alpha_{init}}-\frac{v_{sqz}\cdot t}{4r_{drv}}\right)} & & {t \leq t_{m}},\\
& & \\
\alpha_{init}-2\sin^{-1}{\left(\sin{\alpha_{init}}-\frac{v_{sqz}\cdot tm}{4r_{drv}}\right)} & & \\
+\sin^{-1}{\left(\sin{\alpha_{init}}-\frac{v_{sqz}\cdot (t-t_{m})}{4r_{drv}}-\frac{v_{stch}\cdot (t-t_{m})}{4r_{drv}}\right)} & & {t > t_{m}}.
\end{array} \right.
\end{aligned}
\end{equation}
Here, $0\leq t\leq t_m$ is the squeezing time interval, $t>t_m$ is the ensuing stretching time interval. The tool is squeezed to the extreme at $t_{m}$. After that, the stretching phase gets started. Fig.\ref{output-angle} shows the curves of these two equations under different $v_{sqz}$$_/$$_{stch}$ values. The range is from 10 to 110$mm/s$ with a 10$mm/s$ step length. The curve corresponding to each of these values is rendered in a different color. The results show that an increased $v_{sqz}$$_/$$_{stch}$ significantly reduces the operating time.
\begin{figure}[htbp]
\begin{center}
\includegraphics[width=0.48\textwidth]{figure/output-angle.jpg}
\caption{The changes of the output angle with respect to $t$ and different $v_{sqz}$$_/$$_{stch}$. The curves with different colors compare different finger speeds. (a) The changes in a squeezing phase. (b) The changes in a stretching phase. (c) The changes in a whole squeezing-stretching cycle. $v_{sqz}$ is set to be equal to $v_{stch}$ in computing the curves in a whole cycle.}
\label{output-angle}
\end{center}
\end{figure}
\subsection{Selecting Proper Torsional Springs}
We choose the torsional springs considering the balance of the output torques in both squeezing and stretching phases. The reversed signs of $T_{sprg}$ in equations \eqref{output_sqz} and \eqref{output_stch} imply a trade-off between $T_{sqz}$ and $T_{stch}$: $T_{sqz}$ monotonically increases with $T_{sprg}$. Contrarily, $T_{stch}$ monotonically decreases with $T_{sprg}$. The spring forces are resistant in the squeezing phase but propulsive in the stretching phase. A larger spring coefficient will lead to large output torque in the stretching phase, but a weaker one in the squeezing phase.
The relations between $T_{sqz}$, $T_{stch}$, and $T_{sprg}$ are visualized in Fig.\ref{output_tk}(a). Here, $\alpha$ is set to a constant $ 45^{\circ}$ and $d_{fgr}$ is set to a constant $45mm$ to reduce the number of variables. The vertical axis indicates the output values of $T_{sqz}$ or $T_{stch}$. The horizontal axis indicates the coefficient of the torsional springs, $\xi$. The solid blue curves show the $T_{sqz}$-$\xi$ relation under different $F_{grpr}$ values. The yellow dash curve shows the $T_{stch}$-$\xi$ relation ($F_{grpr}$ is passive in computing the yellow dash curve). The graph shows that $T_{stch}$ increases as the coefficient of the torsional springs increases. At the same time, the gripper will need a larger force to produce the same amount of $T_{sqz}$.
\begin{figure}[!htbp]
\begin{center}
\includegraphics[width=0.48\textwidth]{figure/output-outtk.jpg}
\caption{(a) Blue curves: The $T_{sqz}$-$\xi$ relation under different gripper forces. The yellow dash curve: The $T_{sqz}$-$\xi$ relation when $F_{grpr}$ is at its minimum value. (b) Black curves: The output torque-angle relation when a theoretically optimal spring is used ($\xi$=$19.27 N\cdot mm/^{\circ}$, $F_{grpr}$=125$N$). Red curves: The output torque-angle relation when a best commercially available spring is used ($\xi$=$6.00 N\cdot mm/^{\circ}$, $F_{grpr}$=125$N$).}
\label{output_tk}
\end{center}
\end{figure}
Considering this trade-off, we propose to select a proper $\xi$ by optimizing equation \eqref{output_minimize}:
\begin{equation}
argmax_\xi\int ^{\alpha_{init}}_{\alpha_{end}}\left | T_{sqz}(\alpha, \xi)\cdot T_{stch}(\alpha, \xi)\right |d\alpha
\label{output_minimize}
\end{equation}
The equation computes the definite integral of $| T_{sqz}(\alpha, \xi)\cdot T_{stch}(\alpha, \xi) |$ under bounds $\alpha_{init}$ and $\alpha_{end}$. $\alpha_{init}$ and $\alpha_{end}$ are previous mentioned in Fig.\ref{output-direction}. They are the angles at the stretching extreme and the squeezing extreme, repectively. The reason we propose this optimization is the $\xi$ that induces the maximum integrand will make $T_{sqz}$ and $T_{stch}$ simultaneously large.
The optimal $\xi_{balanced}$ by solving equation \eqref{output_minimize} is $19.52N\cdot mm/^{\circ}$. The black curves in Fig.\ref{output_tk}(b) show the changes of $T_{sqz}$ and $T_{stch}$ under this value with repsect to a varying $\alpha$. The solid black curve is $T_{sqz}$($\alpha$). The dashed black curve is $T_{stch}$($\alpha$). From their positions, we get that under $\xi_{balanced}=19.52N\cdot mm/^{\circ}$, $T_{sqz}$ is close to $T_{stch}$ at all $\alpha$ angles, which makes the tool rotate smoothly and steadily in a whole squeezing-stretching cycle.
Unfortunately, commercial torsional springs with the theoretically optimal $\xi_{balanced}$ are too large to fit the size of our tool. Thus, we give up this optimal value and choose a spring with $\xi = 6.00 N\cdot mm/^{\circ}$ instead. This spring's coefficient value is most near to the optimal one. Meanwhile, it meets the dimensional requirements. The performance of the chosen spring is shown by the red curves in Fig.\ref{output_tk}(b). Like the black curves, the solid red one shows the $T_{sqz}$-$\alpha$ relation. The dashed curve shows the $T_{stch}$-$\alpha$ relation.
Under this spring selection, the designed tool can provide forces to fasten the screw sizes shown in the grey area of Table.\ref{table-1}. Here, a Robotiq Hand-E gripper with a maximum $125N$ grabbing force is assumed to squeeze and stretch the tool. The values in the table are from the Japanese Industrial Standards for general machinery (JIS B \cite{jis20091082} \cite{jis20081083}). The tool can output torque between 3.83$N\cdot m$$\sim$4.04$N\cdot m$ in the squeezing phase and between 0.66$N\cdot m$$\sim$0.85$N\cdot m$ in the stretching phase. According to the table, it could maximumly fasten M5 screws with 4.8 property class. Note that since the stretching force is weak, the tool may get stuck after a strong squeeze. To avoid this problem, one may choose to use a single-ratchet mechanism instead of the double-ratchet one. A single-ratchet tool only produces rotation in the squeezing phase. The stretching phase is free of load. The maximum fastening force of a single-ratchet tool equals to the maximum squeezing force.
\begin{table}[!htbp]
\caption{Fastenable Screw Sizes}
\label{table_example}
\begin{center}
\begin{tabular}{|c|c|c|c|c|c|}
\hline
\multirow{3}{*}{Screw size}&\multicolumn{5}{c|}{Tightening torque ($N\cdot m$)}\\
\cline{2-6}
&\multicolumn{5}{c|}{Property class}\\
\cline{2-6}
&4.8&6.8&8.8&10.9&12.9\\
\rowcolor{black!20}
\hline{}
\cellcolor{white}M3&0.56&1.10&1.45&2.08&2.43\\
\hline{}
M3.5&\cellcolor{black!20}0.89&\cellcolor{black!20}1.73&\cellcolor{black!20}2.28&\cellcolor{black!20}3.27&\cellcolor{black!20}3.82\\
\hline{}
M4&\cellcolor{black!20}1.31&\cellcolor{black!20}2.57&\cellcolor{black!20}3.38&4.84&5.66\\
\hline{}
M5&\cellcolor{black!20}2.65&5.19&6.80&9.78&11.43\\
\hline
M6&4.50&8.81&11.60&16.60&19.40\\
\hline
\end{tabular}
\end{center}
\label{table-1}
\end{table}
\subsection{Optimizing the Geometric Dimensions}
In this part, we optimize the rotational travel of the tool's output end as well as the geometric dimensions of the tool.
\subsubsection{The maximum rotational travel}
Our geometric optimization's top priority is to maximize the rotational travel of the tool's output end. As shown in Fig.\ref{fbd-extreme}, the difference between $\alpha_{max}$ and $\alpha_{min}$ represents the maximum rotation travel, which equals to
\begin{equation}
\Delta\alpha_{max}=\sin^{-1}{\frac{w_{tool_{max}}-2r_{whl}}{4r_{drv}}}-\sin^{-1}{\frac{w_{tool_{min}}-2r_{whl}}{4r_{drv}}}.
\end{equation}
The value is dependent on four parameters $r_{drv}$, $w_{tool_{max}}$, $w_{tool_{min}}$, and $r_{whl}$. The constraints induced by each of them are as follows.
\begin{figure}[!htbp]
\begin{center}
\includegraphics[width=0.48\textwidth]{figure/fbd-extreme.jpg}
\caption{The various parameters studied in the optimization. (a) The parameters at an intermediate state. (b) The parameters at an end (closed) state. (c) The parameters at an initial (open) state.}
\label{fbd-extreme}
\end{center}
\end{figure}
(i) $r_{drv}$. $\Delta\alpha_{max}$ monotonically increases with $1/r_{drv}$, thus $r_{drv}$ should be small. On the other hand, $r_{drv}$ should be designed to meet the requirements of the maximum output torque, as shown in equations \eqref{output_sqz} and \eqref{output_stch}.
(ii) $w_{tool_{max}}$ and $w_{tool_{min}}$. Their values must meet the following equation
\begin{equation}
w_{tool}=4r\sin{\alpha}+2w_{hldr},
\label{opimization-1}
\end{equation}
where $w_{hldr}$ is the distance from the outer surface of a holding pad to its hinge center. The equation shows that $w_{tool}$ monotonically increases with $\alpha$. In an initial state shown in Fig.\ref{fbd-extreme}(c), the supporting wheels are halted by two stoppers and $\alpha$ reaches maximum $\alpha_{max}$. The width of the tool reaches maximum $w_{tool_{max}}$. This value shall be smaller than the jaw width of a robotic gripper. In a final state shown in Fig.\ref{fbd-extreme}(b), when the holding pads contact the ratchet units, $\alpha$ reaches $\alpha_{min}$ and the width of the tool reaches $w_{tool_{min}}$. This value should be larger than the diameter of the ratchet.
(iii) $r_{whl}$. This value shall be as small as possible. It is limited by the availability of commercial products.
Considering these constraints, we determine the ratchet first. Then, considering the diameter of the ratchet and the jaw width of an expected robot gripper, we decide $w_{tool_{min}}$ and $w_{tool_{max}}$. Finally, we optimize $r_{drv}$ following the selected spring (Section.IV.B) and the torque constraints discussed in (Section.IV.A.3).
\subsubsection{The minimum height}
The second goal of our geometric optimization is to reduce the height of the tool. The distance between the two supporting wheels reaches a maximum value at a final state shown in Fig.\ref{fbd-extreme}(b). The lengths of the holding pads must be equal to or longer than this value. Thus, we name this value $l_{tool_{min}}$. $l_{tool_{min}}$ is computed as
\begin{equation}
l_{tool_{min}}=2(r_{drv}+r_{sprt})\cos{\alpha_{max}}.
\label{opimization2}
\end{equation}
This equation can be easily obtained from the geometric relations in Fig.\ref{fbd-extreme}(b). The equation indicates that the length of the holding pad is affected by three parameters $r_{drv}$, $r_{sprt}$, and $\alpha_{max}$. Since $r_{drv}$ and $\alpha_{max}$ have been determined in the previous optimization, we focus on $r_{sprt}$, the length of the supporting arm, and study how to reduce it.
\paragraph{Curved supporting surface}
The idea we use to lessen $r_{sprt}$ is to introduce a curved profile to the holding pads' inner surface. The curved profile converts the wheel and the holding pad pair into a mechanical cam pair. The blue curve in Fig.\ref{fbd-sptwheel} exemplifies such a curved profile. The design shortens $r_{sprt}$ and thus compresses the lengths of the holding pads.
\begin{figure}[!htbp]
\begin{center}
\includegraphics[width=0.48\textwidth]{figure/fbd-sptwheel.jpg}
\caption{(a) Introducing a curved supporting profile to the inner surface of a holding pad. The solid blue curve is the supporting profile. The blue dash curve is the trajectory of the supporting wheel center. (b) A close-up view of the supporting wheel.}
\label{fbd-sptwheel}
\end{center}
\end{figure}
We can derive the parametric form of the curved profile as follows. We set up a reference frame at $P_{hnge}$. The $x$ axis of the frame points to the center of the ratchet. The $y$ axis aligns with the holding pad. They are illustrated by the red and green arrows in Fig.\ref{fbd-sptwheel}. Suppose the center of the supporting wheel in the frame is ($x_{whl}$, $y_{whl}$), we can get the following relations:
\begin{equation}
\alpha=\sin^{-1}{\frac{x_{whl}}{r_{drv}-r_{sprt}}},
\end{equation}
\begin{equation}
y_{whl}=(r+r_{sprt})\cos{\alpha}.
\end{equation}
The curve implied by $f_{whl}$=($x_{whl}$, $y_{whl}$) is the trajectory of the supporting wheel center. The blue dash line in Fig.\ref{fbd-sptwheel}(b) shows this curve. The profile of the holding pad's inner surface is essentially the trajectory of the contact point $P_{sprt}$. It can be obtained by shifting the curve $f_{whl}$ with an offset $r_{whl}$ along its reversed normal direction. Since the reversed normal direction equals to:
\begin{equation}
\theta(\alpha)=\tan^{-1}{\frac{-1}{f^{'}_{whl}}},
\end{equation}
the profile of the holding pad's inner surface consequently has the following parametric form:
\begin{equation}
\left\{\begin{matrix}
\begin{aligned}
&x_{sprt}=x_{whl}+r_{whl}\cos{\theta(\alpha)} \\
&y_{sprt}=y_{whl}(\alpha)-r_{whl}\sin{\theta(\alpha)}
\end{aligned}
\end{matrix}\right..
\label{curvepara}
\end{equation}
Here, ($x_{sprt}$, $y_{sprt}$) indicates the supporting point under the reference frame. $x\in (0, r-r_{sprt})$. Equation \eqref{curvepara} is the parametric form of the curved profile. Its shape can keep the contact between the finger pad and the supporting wheel along with the rotation process. Meanwhile, it forces the motion of the SLE arms to a rotation around the ratchet center.
\paragraph{Structural stability}
The disadvantage of a curved profile is that it decreases the structural stability of the tool. This is a trade-off caused by reducing the length of $r_{sprt}$. A smaller $r_{sprt}$ lessens $l_{tool_{min}}$ but makes the structure less stable. Thus, we perform an optimization for $r_{sprt}$, and formulate the problem as finding a smallest $r_{sprt}$ that has satisfying stability.
We evaluate the stability by measuring the wrench cone formed by the Grasp Wrench Set (GWS) of contact points on the holding pads. To simplify the model, we assume the motion is 2D, and the contact surfaces are rigid and smooth. Fig.\ref{stabilityindex}(a) shows all the contact points on the holding pad. We represent them using symbols $c_{i} (i=1\sim 6)$, where $c_{1}$ and $c_{2}$ denote the contacts with by the robot gripper. $c_{3}$ and $c_{4}$ denote the contacts with the supporting wheel. The connections at the hinge are represented as two contacts $c_{5}$ and $c_{6}$. At each $c_{i}$, we use $f_{i}$ and $\tau_{i}$ to denote the exerted force and moment. We assume that there are friction forces at $c_{1}$ and $c_{2}$ but $c_{3}\sim c_{6}$ are frictionless, as $c_{3}\sim c_{6}$ are on the surface of supporting wheels or are hinges. The wrench $\omega$ exerted by all the contacts thus equals to:
\begin{equation}
\omega=\sum_{i=1}^{6}G_{i}
\begin{bmatrix}
\bm{f_{i}}\\
\tau_{ni}
\end{bmatrix},
\end{equation}
\begin{equation}
G_{i}=
\begin{bmatrix}
\bm{I}&0\\
\left[\bm{p_{i}\times}\right]&\bm{n_{i}}
\end{bmatrix},
\end{equation}
where $p_i$ and $n_{i}$ indicate the contact positions and the contact normals.
\begin{figure}[!htbp]
\begin{center}
\includegraphics[width=0.48\textwidth]{figure/stabilityindex.jpg}
\caption{(a) We formulate the evaluation of the structural stability into measuring the wrench cone formed by the grasp wrench set at six contact points $c_{1}\sim c_{6}$. (b) The changes in the structural stability with respect varying $r_{sprt}$ and $\alpha$. The horizontal axis is the $\alpha$ angle. The curves with different colors are the results of different $r_{sprt}$ values. The $w_{hldr}$ used to get the results is set to $6.5mm$.}
\label{stabilityindex}
\end{center}
\end{figure}
Then, we use the Minkovski sum of the wrenches to find the wrench cone following \cite{harada2014stability}. The structural stability index ($Q$) is computed as the minimum distance from the wrench cone boundary to the origin wrench space \cite{ferrari1992planning}. Fig.\ref{stabilityindex}(b) shows the results of our computation under varying $r_{sprt}$ and $\alpha$. The results imply that the structural stability decreases with the increase of both $\alpha$ and $r_{sprt}$. The decreasing speed significantly rises when $r_{sprt}$ is shorter than 10.0$mm$. Thus, we fabricate the tool by using $r_{sprt}$=10.0$mm$.
\section{PROTOTYPING THE DESIGN}
Following the optimization discussed in the previous section, we fabricated three versions of prototypes. Especially, we compare two major versions. The first major version is the one with flat holding pads, as shown in Fig.\ref{threeprototypes}(a). The second major version uses holding pads with curved profiles, as shown in Fig.\ref{threeprototypes}(b). We compare them from the perspectives of dimension, output torque, and output angle. The frames of these two versions are made by using a 3D printer (ABS materials). Besides them, we further made an aluminum version of the second prototype, as is shown in Fig.\ref{threeprototypes}(c). This version has better structural strength and is used to develop real-world experiments in the experimental section.
\begin{figure}[!htbp]
\begin{center}
\includegraphics[width=0.48\textwidth]{figure/comparison.jpg}
\caption{Three versions of prototypes. (a) The version with flat holding pads. (b) The version with curved holding pads. (c) The aluminum version of the second prototype. It is used in the real-world applications developed in the experimental section.}
\label{threeprototypes}
\end{center}
\end{figure}
Note that the images in Fig.\ref{threeprototypes} are taken on the same scale. By listing them side-by-side, we can observe that the curved profile (Fig.\ref{threeprototypes}(b)) significantly reduces the dimension of the tool made by flat holding pads (Fig.\ref{threeprototypes}(a)). The widths of the two prototypes are both 70$mm$. The height of the holding pad decreases from 80$mm$ to 54$mm$, leading to a more compact design. Meanwhile, although the dimension is significantly reduced, the second major version has similar output performance as the first one. Fig.\ref{twoprototypecomparison} shows the details. Here, the maximum output torques of both the two major prototypes are tested with a 20$N$ gripping force. The rotation angles are tested with a 40$mm/s$ grasp velocity in the squeezing phase, and a 55$mm/s$ grasp velocity in the stretching phase. The results indicate that there is no significant difference between the output performance of the two prototypes.
\begin{figure}[!htbp]
\begin{center}
\includegraphics[width=0.48\textwidth]{figure/comparison-output.jpg}
\caption{Comparing the output performance of the first and second prototypes. The results of the prototype with curved holding pads are shown in yellow. The results of the prototype with flat holding pads are shown in blue. (a) The maximum output torque under a 20$N$ gripping force. The results are based on 5$times$ of repetition. (b) The changes in rotation angles under a 55$mm/s$ grasp velocity.}
\label{twoprototypecomparison}
\end{center}
\end{figure}
Table.\ref{table_para} lists up the various parameters we used to fabricate the first and second versions of prototypes. The ratchet units used to make the double-ratchet mechanism are widely available commercial products\footnote{ANEX, http://www.anextool.co.jp/item/316}. It finalizes the diameter of the ratchet (32$mm$). The remaining parameters are the optimal values found considering the constraints discussed in the previous section.
\begin{table}[!htbp]
\begin{center}
\centering
\setlength{\tabcolsep}{0.1mm}{
\caption{The Parameters Used to Prototype the Tool}
\label{table_para}
\begin{tabular}{lll}
\toprule
Parameter~ & Value & Definition \\
\midrule
$w_{tool_{max}}$ & $83mm$ &
Maximum width between two holding pads \\
$w_{tool_{min}}$ & $40mm$ &
Minimum width between two holding pads \\
$w_{hldr}$ & $6.5mm$ &
Dist. from a holding surface to the hinge center\\
$w_{pad}$ & $2mm$ &
Thickness of the holding pads \\
$r_{drv}$ & $20mm$ &
Length of the driving arm (mC-SLE)\\
$r_{sprt}$ ($ver.1$)~~ & $20mm$ &
Length of the supporting arm (mC-SLE)\\
$r_{sprt}$ ($ver.2$)~~ & $10mm$ &
-\\
$r_{whl}$ & $1.5mm$ &
Radius of the supporting wheel (mC-SLE)\\
$l_{tool}$ ($ver.1$) & $80mm$ &
Height of the holding pads \\
$l_{tool}$ ($ver.2$) & $54mm$ &
- \\
$\xi$ & $6.00N\cdot mm/^{\circ}$~~ &
Elastic coefficient of the torsional spring\\
$d_{rtct}$ & $32mm$&
Diameter of the ratchet\\
\bottomrule
\end{tabular}}
\end{center}
\end{table}
\section{THE MANIPULATION POLICIES TO USE THE TOOL}
This section develops the manipulation policies for using the designed tool. It consists of three parts: (1) Recognizing the tool; (2) Automatically planning grasps and manipulation sequences; (3) Exchanging the tooltips.
\subsection{Recognizing the Tool}
We assume a depth sensor to be employed for visual recognition. One may use a depth sensor to scan the workspace and locate the tool by registering its model to the collected point cloud. Conventional algorithms like DBSCAN-based segmentation \cite{witten2002data}, RANSAC-based global search \cite{zhou2016fast}, and ICP-based local refinement \cite{pomerleau2013comparing} are employed in the registration. Fig.\ref{recognizing} shows an example of the collected point cloud and the matched tool pose using the mentioned rough estimation and local refinement routine.
\begin{figure}[htbp]
\begin{center}
\includegraphics[width=0.48\textwidth]{figure/recognizing.jpg}
\caption{Recognizing the tool using a depth sensor. (a) The real-world system setting. (b) The matched tool model in the simulation environment.}
\label{recognizing}
\end{center}
\end{figure}
\subsection{Picking-up and Manipulation}
We use the grasp planning methods presented in \cite{harada2014stability}\cite{tsuji2014grasp} to plan grasping poses, and use the methods presented in \cite{wan2016integrated}\cite{wan2017teaching}\cite{wan2019preparatory}\cite{wan2016achieving} to plan placements and regrasp sequences.
Fig.\ref{motionplanning-grasp}(a) exemplifies some grasp candidates found by a grasp planner. The plan is automatically performed using the mesh model of the tool. The red hands refer to the grasp poses that can use the tool. These poses are named as the tool-control grasp poses. The green hands refer to the grasp poses that can only hold the tool. They are called the tool-holding grasp poses.
\begin{figure}[!htbp]
\begin{center}
\includegraphics[width=0.48\textwidth]{figure/motionplanning-grasp.jpg}
\caption{(a) Grasp candidates without considering the environmental constraints. The red hand indicates the tool-control grasp. (b) Stable placements of the tool.}
\label{motionplanning-grasp}
\end{center}
\end{figure}
Fig.\ref{motionplanning-grasp}(b) shows the stable placements of the tool on a table. The tool could be placed at an arbitrary position on a worktable with any of these stable placements.
Fig.\ref{motionplanning-regrasp}(a) further shows the collision-free tool-control and tool-holding grasp poses for each of the stable placements. Given a specific task, the goal position of the tool can be generated according to the position of the objective screw. Then, based on the goal position, the collision-free tool-control grasp poses of the tool at the goal can be generated, as shown in Fig\ref{motionplanning-regrasp}(b). To compute the tool-control grasp poses, besides the collision constraints, the geometric backtracking between the tool's initial pose and the final goal pose shall also be considered. In the case that there is no shared tool-control grasp poses between the initial tool pose and the goal tool pose, the planner will trigger a handover to change the tool pose. For example, there is no tool-control pose in the initial grasp poses shown in Fig.\ref{motionplanning-regrasp}(a-3). Thus, a handover regrasp is necessary, as shown in Fig.\ref{motionplanning-regrasp}(c).
\begin{figure}[!htbp]
\begin{center}
\includegraphics[width=0.48\textwidth]{figure/motionplanning-regrasp.jpg}
\caption{(a) Initial grasp poses. They are the collision-free grasp candidates for the tool placed on a table. (b) Final grasp poses. (c) The grasp poses for handover.}
\label{motionplanning-regrasp}
\end{center}
\end{figure}
\subsection{Exchanging the Tooltips}
The tool has two hexagonal magnetic sockets at its output ends for attaching tooltips. A group of tooltips with hexagonal connecting ends can be exchanged and attached to the sockets to meet various task requirements. Attaching the tooltip into the socket is essentially a peg-in-hole task. A compliant strategy integrating linear, spiral, and rotation search with impedance control is developed to conduct this task.
\subsubsection{Linear search}
In linear search, the robotic hand holding the tooltip moves along a straight line to make the tooltip end contact the pre-insertion surface. An example is shown in Fig.\ref{forcecontrol}(a). The robot hand in the example moves along an orange direction $\mathbf{v}^{att}$ to search for the contact between the tooltip end and the socket. The linear motion stops when equation \eqref{linear-rsch} is satisfied.
\begin{equation}
\left | \mathbf{v}^{att}(\mathbf{R}^{grpr} \cdot \mathbf{F}^{grpr})\right | \geq F_{threshold}.
\label{linear-rsch}
\end{equation}
Here, $\mathbf{R}^{grpr}$ is the rotation matrix of the holding hand, $\mathbf{F}$ is the observed force from the F/T sensor mounted at the wrist. $F_{threshold}$ is the desired contact threshold.
\begin{figure}[htbp]
\begin{center}
\includegraphics[width=0.48\textwidth]{figure/forcecontrol.jpg}
\caption{(a) Linear search. The hand holding the tooltip moves linearly along the orange vector until it hits the connecting surface. (b) Spiral search. The orange spiral curve indicates the generated spiral path. The purple vector shows the initial spiral direction. (c) Rotation search and impedance control.}
\label{forcecontrol}
\end{center}
\end{figure}
\subsubsection{Spiral search}
Assume that the tooltip end stops at position $\mathbf{P}^{hnd}_0$ at the end of linear search, as is shown in Fig.\ref{forcecontrol}(b), then, based on this position, a spiral curve and spiral search is planned. The spiral curve is generated according to equation \eqref{spiral-rsch} in the $\mathbf{R}^{socket}_{x}$-$\mathbf{R}^{socket}_{y}$ plane. Here, $\mathbf{R}^{socket}$ represents the pose of the socket. The $x$ and $y$ at the subscript denote the local $x$ and $y$ axes of the rotation matrix.
\begin{equation}
\mathbf{P}^{hnd}_{i+1}=r^{sprl}_{i+1}\cdot\mathtt{rodrigues}(\theta^{sprl}_{i+1}, \mathbf{v}^{att})\cdot\mathbf{v}^{sprl}+\mathbf{P}^{hnd}_{i}.
\label{spiral-rsch}
\end{equation}
Here, $\mathbf{v}^{sprl}$ indicates the initial spiral direction (the purple vector in Fig.\ref{forcecontrol}(b)). $\mathbf{P}^{hnd}_{i}$ and $\mathbf{P}^{hnd}_{i+1}$ are the current position and the planned next position, respectively. $\mathtt{rodrigues}(\theta, \mathbf{v})$ is the Rodrigues' rotation formula. $\theta^{sprl}$ and $r^{sprl}_{i+1}$ are computed as as:
\begin{equation}
\theta^{sprl}_{i+1} = \theta^{sprl}_{i}+\delta\theta^{sprl},~r^{sprl}_{i+1} = r^{sprl}_{i}+\delta r^{sprl},
\end{equation}
where $\delta \theta^{sprl}$ and $\delta r^{sprl}$ are the discretized step rotation and step length of the spiral curve. Since the end of tooltip are chamfered, when the tooltip end is aligned to the pre-inserting position as shown in Fig.\ref{forcecontrol}(c), equation \eqref{spiral-rsch} will be violated and the robot will stop the spiral research.
\subsubsection{Rotation research and impedance control}
After the spiral search, rotation search and impedance control are applied to complete the insertion. We define the impedance control in the workspace following the conventional impedance control law:
\begin{equation}
\mathbf{F}^{insrt} + \mathbf{F}^{rsst}_i = m\cdot\mathbf{\ddot{P}}^{hnd}_i+c\cdot\mathbf{\dot{P}}^{hnd}_i+k\cdot(\mathbf{P}^{hnd}_i-\mathbf{P}^{hnd}_{i-1})
\end{equation}
where $m$, $c$, and $k$ are inertia of the held object, damping coefficient, and stiffness respectively. $\mathbf{\ddot{P}}^{hnd}_i$, $\mathbf{\dot{P}}^{hnd}_i$, and $\mathbf{{P}}^{hnd}_i$ are the acceleration, velocity, and displacement of the holding hand. $\mathbf{F}^{insrt}$ is the desired insertion force which points to the same direction as $\mathbf{v}^{att}$. $\mathbf{F}^{rsst}_i$ is the external force of the environment.
The generated hand motion is thus:
\begin{equation}
\mathbf{P}^{hnd}_{i+1} = \frac{\mathbf{F}^{insrt} + \mathbf{F}^{rsst}_i+m\frac{(2\mathbf{P}^{hnd}_{i}-\mathbf{P}^{hnd}_{i-1})}{dt^2}+c\frac{\mathbf{P}^{hnd}_{i-1}}{dt}+k\mathbf{P}^{hnd}_{i}}{\frac{m}{dt^2}+\frac{c}{dt}+k}.
\end{equation}
Along with the impedance control, the hand holding the tool will rotate around $\mathbf{v}^{att}$ to perform rotation research. Thus, $\mathbf{F}^{rsst}_i$ changes with the environment contact and varies with rotation and insertion. The two robots stop simultaneously when $\mathbf{F}^{insrt}$ equals to $(-\mathbf{F}^{rsst}_{i})_{\mathbf{v}^{att}}$, namely when the tooltip end contacts with the bottom of the socket and the insertion is successfully conducted.
\section{EXPERIMENTS AND ANALYSIS}
We perform experiments using two UR3 robotic arms, with a Robotiq Hand-E two-finger parallel gripper mounted at the tool center point of each arm. The vision sensor used in the experiments is a Photoneo PhoXi 3D Scanner M. The sensor is mounted above the workspace for visual recognition. The experimental section consists of two main parts. In the first part, we study the performance of the design. We test the maximum output torque with respect to the designed parameters and examine the relationship between the gripping velocity and the rotation velocity. In the second part, we study the manipulation policies of the tool. We implement programs for the robot to exchange the tooltips and develop real-world applications to verify the proposed strategies.
\subsection{The Performance of the Design}
\subsubsection{Torque at the tooltip}
This section presents the experiments used to measure the real output torque $T_{out}$ with respect to changing tool width $w_{tool}$ and holding angle $\beta$, respectively. The experimental setting is shown in Fig.\ref{exp-output-set}. A DynPick Capacitive 6-axis force sensor (200N, WACOH-TECH Inc.) is used to measure the torque values. One of the robotic grippers held the tool. The tooltip is inserted into a slot fixed on the torque sensor. The robotic gripper can close as well as open its jaw to exert force on the tool. The force sensor can thus measure the output torque on-line for both the squeezing and stretching phases. The stable peak torque measured by the force sensor is recorded as the maximum torque.
\begin{figure}[!htbp]
\begin{center}
\includegraphics[width=0.48\textwidth]{figure/experiment-output-set.jpg}
\caption{The experimental setting for measuring the real maximum output torque. A DynPick Capacitive 6-axis force sensor (200N, WACOH-TECH Inc.) is used to measure the output torque. The tool is held by one Robotiq Hand-E gripper. The tooltip is inserted into a slot fixed on the torque sensor.}
\label{exp-output-set}
\end{center}
\end{figure}
The results are shown in Fig.\ref{exp-output-data} where the yellow curves indicate the theoretical values, the black curves indicate the experimental values. The experimental results are identical to the theoretical analysis.
\begin{figure}[!htbp]
\begin{center}
\includegraphics[width=0.48\textwidth]{figure/experiment-output-data.jpg}
\caption{The maximum output torque $T_{out}$ with respect to the tool width $w_{tool}$ and the holding angle $\beta$. Yellow curves indicate the theoretical values. Black curves indicate the experimental values. (a, b) The relation between the maximum output torque $T_{out}$ and a changing $\beta$. (c, d) The relation between $T_{out}$ nd a changing $w_{tool}$. The $\beta$ angle is selected to be a fixed value 90$^{\circ}$. The theoretical curves are computed using $\xi$=6$N\cdot mm/^{\circ}$ and $F_{grpr}$=125$N$.}
\label{exp-output-data}
\end{center}
\end{figure}
Fig.\ref{exp-output-data}(a, b) are the relation between the maximum output torque $T_{out}$ and a changing holding angle $\beta$. In both the squeezing and stretching phases, the maximum output torques increase with $\beta$ in the beginning, after it reaches the peak at $\beta$=60$^{\circ}$, the torque starts to decrease. The yellow curves and black curves have a similar tendency but a statistically observable difference. The difference is caused by the various errors like assembly errors, machining errors, imperfect rigid body assumption for the links, etc.
Fig.\ref{exp-output-data}(c, d) are the relation between $T_{out}$ and a changing $w_{tool}$. The $\beta$ angle is selected to be a fixed value 90$^{\circ}$. The maximum output torque slightly increases with $w_{tool}$ in the squeezing phase and slightly decreases in the stretching phase. The variations are minor, and the maximum output torques in both phases are nearly unchanged. Thus, one may ignore the influence of $w_{tool}$ in practice. Note that the theoretical curves are computed using $F_{grpr}$=125$N$ (maximum of Robotiq Hand-E) and $\xi$=6.00$N\cdot mm/^{\circ}$.
\subsubsection{Velocities at the tooltip}
This section presents the experiments used to examine the rotation of the tooltip. Particularly, we compared four cases. They are (1) the rotation in the squeezing phase, (2) the rotation in the stretching phase, (3) the rotation in a whole squeezing-stretching cycle, and (4) the rotation during a continuous rotation. An AR marker is used to assist in tracking the rotation. It is attached to plates installed at the tool's output ends, as shown in Fig.\ref{visionsetting}(a). Fig.\ref{visionsetting}(b) illustrates the front end. Fig.\ref{visionsetting}(c) illustrates back end. Note that since the two ends rotate identically except for their directions, we only show the measured results of the front end below.
\begin{figure}[htbp]
\begin{center}
\includegraphics[width=0.48\textwidth]{figure/visionsetting.jpg}
\caption{An AR marker is used to detect the rotating velocity. (a) The setting for tracking the rotation. (b) The clockwise rotation at the front end. (c) The counter-clockwise rotation at the back end. Note: The CW and CCW are counted in the tool frame.}
\label{visionsetting}
\end{center}
\end{figure}
Fig.\ref{exprotation} shows the measured results. Like Fig.\ref{exp-output-data}, the yellow curves indicate the theoretical values, and the black curves indicate the experimental values. The four subfigures in Fig.\ref{exprotation} correspond to the results of the four cases mentioned above. Fig.\ref{exprotation}(a) and (b) are respectively the relation between the rotation angle and time in the squeezing phase and the stretching phase. For these to single-direction stroke, the results of the experiments well match the theoretical values. Fig.\ref{exprotation}(c) is the relation in a whole squeezing-stretching cycle. The curves show that the experiment results start to deviate from the theoretical values when the tooltip switches its rotation direction. Instead of a continuous smooth increase, the rotation angle keeps constant from 3.1$s$ to 3.4$s$, drops from 3.4$s$ to 3.9$s$, and resumes to increase following a pattern like Fig.\ref{exprotation}(b) after 3.9$s$. The reason for the constant rotation is that there is a short switching delay between the two phases. The reason for the drop is because of the coupling backlash and the errors in machining accuracy. The coupling backlash occurs when ratchet gears switch the directions. It blocks the motion from being transmitted to the output end.
\begin{figure}[!htbp]
\begin{center}
\includegraphics[width=0.48\textwidth]{figure/experiment-rotation.jpg}
\caption{The velocities at the tooltip. Yellow curves indicate the theoretical values. Black curves indicate measured values. (a) The changes in the rotation angle with respect to time in the squeezing phase. (b) The changes in the stretching phase. (c) The changes in a whole squeezing-stretching cycle. (d) The changes in the rotation angle during continuous squeezing and stretching. Note that the results are from the front end. The back ends rotate identically except that the direction is reversed.}
\label{exprotation}
\end{center}
\end{figure}
Note that the hand speed used to measure the real angle as well as computing the theoretical values for the first three subfigures is 0\% (20$mm/s$ according to the specification of Robotiq Hand-E). This slow motion was selected since we would like to have a detailed view of the changes.
Fig\ref{exprotation}(d) further shows the results where the gripper squeezes and stretches the tool continuously. The curve is made of a sequence of smaller patterns where each of them is like the one shown in Fig.\ref{exprotation}(c). In this case, the hand speed used to measure the real angle is selected to be 100\% (150$mm/s$). The tool can output a 360$^\circ$ rotation in 5.8$s$ under this speed.
\subsection{Real-world Applications}
Next, we develop applications to examine the manipulation policies of the tool. The video clips of these applications are available in the supplementary file of the article.
\subsubsection{Exchanging tooltips for various tasks}
First, we program the robot to exchange the tooltips for the tool. The goal is to remove the current \#3 hexagonal screwdriver tooltip and replace it with a \#6 one. Some snapshots showing the execution results are shown in Fig.\ref{Experiment-exchange}. With the tool held by the left hand, the right hand unplugs the \#3 tooltip and inserts a \#6 tooltip into the tool's output socket. To ensure a successful insertion, the linear research, spiral research, and rotation search and impedance control mentioned in Section IV.C are exercised. The insertion process is shown in detail in Fig.\ref{Experiment-insertion}. Here, (a) is the starting position for linear research. (b) is the starting position for spiral search. The tooltip gets in contact with the tool's output surface at the end of the linear search, and the spiral search gets started. The spiral search finishes at (c). After that, the rotation research and impedance control start, as is shown in (d, e). (f) shows the final replaced tooltip.
\begin{figure}[!htbp]
\begin{center}
\includegraphics[width=0.48\textwidth]{figure/experiment-exchange.jpg}
\caption{Exchanging a \#3 hexagonal screwdriver tooltip with a \#6 one. (a) Unplugging the \#3 tooltip and returning it to the tooltip holder. (b) Picking up the \#6 tooltip and inserting it into the output socket.}
\label{Experiment-exchange}
\end{center}
\end{figure}
\begin{figure}[!htbp]
\begin{center}
\includegraphics[width=0.48\textwidth]{figure/experiment-insertion.jpg}
\caption{Detailed snapshots showing the insertion of the \#6 tooltip. The linear research stars from (a) and stops at (b). The spiral research starts from (b). It stops when the hole is found at (c). (d, e) Rotation search and impedance control. (f) The insertion is done.}
\label{Experiment-insertion}
\end{center}
\end{figure}
Besides the exchanging task mentioned above, another three different tooltips, including an extra hexagonal socket, a short hexagonal screwdriver, and a cross screwdriver, are used to test the robustness and adaptability of the manipulation policies for exchanging the tooltips. The snapshots of them are shown in Fig.\ref{Experiment-varioustip}.
\begin{figure}[!htbp]
\begin{center}
\includegraphics[width=0.48\textwidth]{figure/experiment-varioustip.jpg}
\caption{Some other validations of the manipulation policies for exchanging tooltips. (a) Exchanging to an extra hexagonal socket. (b) Exchanging to a short hexagonal screwdriver. (c) Exchanging to a cross screwdriver.}
\label{Experiment-varioustip}
\end{center}
\end{figure}
\subsubsection{Fastening task with automatic recognition and planning}
Second, we program the robot to conduct fastening tasks. The goal is to verify the robustness and reliability of the tool while also demonstrating the advantages of mechanical screwing compared with other solutions.
\paragraph{Flexibility in collision-free motion planning}
We compare the flexibility of the proposed mechanical screwing tool with a conventional pneumatic screwdriver widely used in the manufacturing industry. In the case that the robot uses the pneumatic screwdriver, as shown in Fig.\ref{Experiment-badexample}, the robot has difficulty in dealing with the vacuum tube. The vacuum tube may knock down the spray bottle placed in the workspace during the manipulation, as is shown in Fig.\ref{Experiment-badexample}(a). Also, the robot may get entangled with the vacuum tube during manipulation, as is shown in Fig.\ref{Experiment-badexample}(b). Very smart modeling algorithms and motion planners must be developed to avoid these problems.
\begin{figure}[!htbp]
\begin{center}
\includegraphics[width=0.48\textwidth]{figure/experiment-badexample.jpg}
\caption{Manipulating a vacuum driver can be difficult due to the annoying cable connection. (a) The cable (vacuum tube) knocks down an obstacle in the environment. (b) One robot arm gets entangled with the tube.}
\label{Experiment-badexample}
\end{center}
\end{figure}
Contrarily, since our tool is mechanical, it does not have any ``tails'' like electric cables, signal wires, or vacuum tubes. There is thus no need to consider the negative influence of them. Fig.\ref{Experiment-motion} exemplifies a fastening task using the proposed tool. According to the tool's initial states, our planner found two motion sequences to finish the given task. In the first initial state shown in Fig.\ref{Experiment-motion}(a), the tool is placed on the table in a pose that the holding pads are vertical to the table. Under this state, the robot can directly pick up the tool using a tool-control pose and move the tool to the goal position to perform the fastening task. In the second initial sate shown in Fig.\ref{Experiment-motion}(b), the tool is standing on one side of the holding pad. The robot cannot grasp the tool using the tool-control pose. It thus picks up the tool using a tool-holding grasp pose and adjusts to tool-control pose by handing the tool over to the second arm.
\begin{figure}[!htbp]
\begin{center}
\includegraphics[width=0.48\textwidth]{figure/experiment-motion.jpg}
\caption{(a) The robot uses the tool to fasten a screw. (b) Handover is applied to reorient the tool to reach a feasible tool-control grasp pose.}
\label{Experiment-motion}
\end{center}
\end{figure}
\paragraph{Working in narrow spaces}
We also study the ability of the tool to fasten a screw in a narrow space. Fig.\ref{Experiment-narrow} shows the scenario. The robot cannot use commercial tools to work in the narrow space shown in the scene. It is even not convenient for humans to use a commercial hexagon wrench, as shown in Fig.\ref{Experiment-narrow}(a). In contrast, the proposed tool is compact and has many tool-control grasp poses, and it can work in the narrow space to fasten the screw, as shown in Fig.\ref{Experiment-narrow}(b).
\begin{figure}[!htbp]
\begin{center}
\includegraphics[width=0.48\textwidth]{figure/experiment-narrow.jpg}
\caption{(a) The robot cannot use commercial tools to work in a narrow space. It is even inconvenient for humans to use a commercial hexagon wrench. (b) The robot can finish the fastening task by selecting a feasible tool-control grasp pose.}
\label{Experiment-narrow}
\end{center}
\end{figure}
\section{CONCLUSIONS AND FUTURE WORK}
This paper presented the design, optimization, and the manipulation policies of a mechanical tool for robots with 2-finger parallel grippers. The tool can convert linear motion into rotational motion. Thus, it could be used by a robot to fasten screws. Two mC-SLE mechanisms and a double-ratchet mechanism are employed in the design. Force analysis and geometric constraints are considered to make the tool have effective transmission capabilities and a compact structure. The manipulation policies combining linear search, spiral search, and rotation search and impedance control are developed to exchange the tooltips and adjust grasp poses. Experiments show a prototype of the designed tool has a good expected performance. Robots can use the tool to exchange the tooltip and conduct various fastening tasks with visual detection and grasp and motion planning. The tool has good robustness and adaptability.
A significant problem of the tool is its efficiency. In our future work, we plan to improve the efficiency by including additional layers, i.e., reduction gear layers, to the current design.
\bibliographystyle{IEEEtran}
| {'timestamp': '2020-06-19T02:11:34', 'yymm': '2006', 'arxiv_id': '2006.10366', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10366'} | arxiv |
\section{Introduction}
Learning the distribution of observed data is a basic task in unsupervised learning which has been studied for decades. The recently-introduced concept of Generative Adversarial Networks (GANs) \cite{goodfellow2014generative} has demonstrated great success in various distribution learning tasks. Unlike the traditional maximum-likelihood-based approaches, GANs learn the distribution of observed data through a zero-sum game between two machine players, a generator $G$ mimicking the true distribution of data and a discriminator $D$ distinguishing the generator's produced samples from real data points. This zero-sum game is typically formulated through a minimax optimization problem where $G$ and $D$ optimize a minimax objective quantifying how dissimilar $G$'s generated samples and real training samples are.
In GAN minimax optimization problems, the generator and discriminator functions are commonly chosen as two deep neural networks (DNNs). Leveraging the expressive power of DNNs, GANs have achieved state-of-the-art performance in learning complex distributions of image data \cite{karras2017progressive,zhang2018self,brock2018large}. This success, however, is achieved at the cost of their notoriously difficult training procedure which has introduced several challenges to the machine learning community. Addressing these challenges requires a deeper theoretical understanding of GANs, including their approximation, generalization, and optimization properties.
Specifically, GANs have been frequently observed to fail in learning multi-modal distributions \cite{goodfellow2016nips}. As a widely-recognized training issue, a trained GAN model may collapse into only one or a few modes of the underlying distribution, a phenomenon known as \emph{mode-collapse} in the literature. Despite the recent advances in improving the generalization and stability properties of GAN models, state-of-the-art GAN architectures are often observed to struggle in learning even the simplest class of mixture distributions, i.e., the Gaussian mixture models (GMMs). Such empirical observations question the superiority of GANs over traditional methods of learning mixture models such as the expectation-maximization (EM) algorithm \cite{dempster1977maximum}. A natural question here is whether this gap fundamentally exists in learning multi-modal distributions or is due to a lack of appropriate design for the GAN players and loss function. In order to better understand how GANs learn multi-modal distributions, we focus on a GAN architecture that is amenable for learning the simplest, nontrivial model: a mixture of two Gaussians. After all, unless we understand how an adversarial learning architecture behaves in the simplest of cases, it would be hard to understand what happens in the case of deep neural networks.
In what follows, we show that with a proper design of the generator and discriminator function classes and choice of the minimax objective in the GAN's optimization problem, it is possible to achieve performance similar to that of the EM algorithm in learning mixtures of two Gaussians. To achieve this goal, we propose \emph{Generative Adversarial Training for Gaussian Mixture Models (GAT-GMM)}, a minimax GAN framework for learning GMMs. GAT-GMM is formulated based on minimizing the Wasserstein distance between the underlying and generative GMMs. Leveraging optimal transport theory, we characterize optimal function spaces for training the generator and discriminator players as well as the minimax objective of the GAN problem. We show that GAT-GMM represents a non-convex concave minimax optimization problem which can be efficiently solved by a gradient descent ascent (GDA) method to reach a stationary minimax point.
In the well-studied benchmark case of symmetric mixtures of two well-separated Gaussians, we theoretically support GAT-GMM by providing approximation, generalization, and optimization guarantees. We show that the designed generator and discriminator will suffice for reaching zero approximation error in learning such two-component GMMs. Furthermore, we prove that the underlying GMM provides the only stationary minimax point satisfying a separability condition. We also bound the generalization error of estimating the minimax objective and its derivatives from empirical samples. The generalization bounds scale linearly with the dimension of the data as a consequence of GAT-GMM's specific design. The generalization and optimization guarantees together show that a learnt well-separated GMM will generalize to the underlying distribution.
Finally, we experimentally demonstrate the success of GAT-GMM in learning symmetric mixtures of two Gaussians. We show that in practice, GAT-GMM can be optimized efficiently using a simple GDA optimization algorithm. Numerically, we find that GAT-GMM performs favorably compared to GANs with neural network players and achieves EM-like numerical performance in learning symmetric mixtures of two Gaussians. Our empirical results indicate that the generative adversarial training approach can potentially achieve state-of-the-art performance in learning GMMs. We summarize the main contributions of this work as follows:
\begin{itemize}[leftmargin=*]
\item Proposing GAT-GMM as a generative adversarial training approach for learning GMMs,
\item Reducing GAT-GMM to a non-convex concave minimax optimization problem with convergence guarantees to stationary minimax points,
\item Demonstrating theoretical guarantees for GAT-GMM in learning symmetric mixtures of two well-separated Gaussians,
\item Providing numerical support for the GAT-GMM approach in learning two-component GMMs.
\end{itemize}
\section{Related Work}
\textbf{Theory of GANs:}
A large body of recent works have studied the theoretical aspects of GANs, including their approximation \cite{liu2017approximation,farnia2018convex,liu2018inductive}, generalization \cite{arora2017generalization,arora2017gans,zhang2017discrimination}, and optimization \cite{nagarajan2017gradient,mescheder2017numerics,roth2017stabilizing,daskalakis2017training,heusel2017gans,mescheder2018training,lin2018pacgan,farnia2020gans,lei2019sgd} properties. We note that our model-based GAN framework for GMMs is similar to the approaches in \cite{feizi2017understanding,bai2018approximability} for learning Gaussians and invertible neural net generators. Specifically, \cite{bai2018approximability} proposes a discriminator function for learning GMMs which matches our proposed model in the special case of identity covariance matrix. However, our work further analyzes the optimization properties of the resulting GAN problem. Also, multiple recent works \cite{arjovsky2017wasserstein,bousquet2017optimal,feizi2017understanding,salimans2018improving,sanjabi2018convergence,genevay2018sample} explore the applications of optimal transport theory in improving GANs' stability and convergence behavior.
\textbf{GANs for Learning GMMs:} Regarding the applications of GANs in learning GMMs, Pac-GAN~\cite{lin2018pacgan} seeks to resolve the mode collapse issue by learning the distribution of two samples and reports improved performance scores in learning mixtures of Gaussians. The related references~\cite{ben2018gaussian,richardson2018gans,xiao2018bourgan} propose considering a GMM input to GAN's generator, and report empirical success for fitting GMMs. Flow-GANs~\cite{grover2018flow} combine the maximum likelihood approach with GAN training and improve the performance of GANs in learning GMMs. Reference~\cite{metz2016unrolled} suggests unrolling the discriminator's optimization and shows it improves learning an underlying GMM. Reference~\cite{li2017limitations} analyzes the convergence behavior of GANs in learning univariate mixtures of two Gaussians. Unlike our work, the above papers consider standard neural network players, with the exception of~\cite{li2017limitations}.
\textbf{Theory of Learning GMMs:} Several related works have studied the theoretical aspects and limits of learning GMMs, including the convergence and generalization behavior of learning GMMs with the EM algorithm \cite{daskalakis2016ten,xu2016global,balakrishnan2017statistical,regev2017learning,yan2017convergence,barazandeh2018behavior,zhao2020statistical,nagarajan2020analysis}, the method of moments \cite{moitra2010settling,anandkumar2012method,hsu2013learning,hardt2015tight,ge2015learning,hopkins2018mixture}, optimal transport tools \cite{chen2018optimal,kolouri2018sliced,gaujac2018gaussian}, and recovery guarantees under separability assumptions \cite{dasgupta1999learning,sanjeev2001learning,dasgupta2007probabilistic,chaudhuri2009learning}. Specifically, \cite{daskalakis2016ten,xu2016global} analyze a similar benchmark setting of mixtures of two symmetric Gaussians for the EM algorithm. We note that these papers also assume a known covariance matrix and aim to learn only the mean parameter, while our theoretical setup further considers and learns an unknown covariance matrix.
\section{Preliminaries}
\subsection{Gaussian Mixture Models}
We denote a $k$-component Gaussian mixture model (GMM) by $
p_{{\pi}_i,\boldsymbol{\mu}_i,{\Sigma}_i}(\mathbf{x}) := \sum_{i=1}^k \pi_i\mathcal{N}(\mathbf{x}\,\vert\, \boldsymbol{\mu}_i,\Sigma_i ),$
where $\mathcal{N}(\mathbf{x}\,\vert\, \boldsymbol{\mu},\Sigma) $ is the multivariate Gaussian distribution with mean $\boldsymbol{\mu}$ and covariance matrix $\Sigma$, and, $\pi_i$ stands for the probability of observing a sample from component $i$. A GMM uniformly distributed among its components will also satisfy $\pi_i=\frac{1}{k}$ for every $i$. If the covariance matrix is shared among the components we will have $\Sigma_i=\Sigma_j$ for every $i,j$. We call a two-component GMM symmetric if in addition to the uniform distribution and common covariance among components, we also have opposite means $\boldsymbol{\mu}_1=-\boldsymbol{\mu}_2$.
\subsection{GANs and Optimal Transport Costs}
The GAN framework learns the distribution of data through a minimax problem optimizing generator $G$ and discriminator $D$. The following minimax optimization is the vanilla GAN problem introduced in \cite{goodfellow2014generative}:
\begin{equation}
\min_{G\in\mathcal{G}}\; \max_{D\in\mathcal{D}}\; \mathbb{E}[\log(D(\mathbf{X}))] + \mathbb{E}[\log(1- D(G(\mathbf{Z})))].
\end{equation}
In the above equation, $\mathcal{G}$ and $\mathcal{D}$ are function spaces for $G$ and $D$, respectively. $\mathbf{Z}\sim\mathcal{N}(\mathbf{0},I)$ is the random input to the generator, which we assume has a standard multivariate Gaussian distribution throughout this work. To improve the stability in training GANs, \cite{arjovsky2017wasserstein} proposes a GAN minimax problem minimizing an optimal transport cost. For a transportation cost $c(\mathbf{x},\mathbf{x}')$, the optimal transport cost $W_c$ is defined as $W_c(P,Q) := \inf_{M \in \Pi(P,Q)}\: \mathbb{E}_M[c(\mathbf{X},\mathbf{X}')]$. Here, $\Pi(P,Q)$ is the set of all joint distributions with marginals $P$ and $Q$. A special case of interest is the 2-Wasserstein cost corresponding to quadratic $c(\mathbf{x},\mathbf{x}')=\frac{1}{2}\Vert \mathbf{x} -\mathbf{x}' \Vert_2^2$. The following minimax problem formulation, called W2GAN~\cite{feizi2017understanding}, minimizes the 2-Wasserstein cost where $D$ is called $c$-concave if for a function $\widetilde{D}$ we have $D(\mathbf{x})=\inf_{\mathbf{x}'}\, \widetilde{D}(\mathbf{x}')+c(\mathbf{x},\mathbf{x}')$, and the $c$-transform is defined as $D^c(\mathbf{x}):=\sup_{\mathbf{x}'} D(\mathbf{x}')-c(\mathbf{x},\mathbf{x}')$:
\begin{equation}\label{Eq: general WGAN}
\min_{G\in \mathcal{G}}\; \max_{D\, \operatorname{c-concave}}\; \mathbb{E}\bigl[D(\mathbf{X})\bigr]-\mathbb{E}\bigl[D^c\bigl(G(\mathbf{Z})\bigr)\bigr].
\end{equation}
\section{An Optimal Transport-based Design of GAN Players for GMMs}
Consider the W2GAN minimax problem \eqref{Eq: general WGAN} for learning a GMM. Solving the minimax problem over the original class of $c$-concave $D$'s will be statistically and computationally complex \cite{arora2017generalization,feizi2017understanding}. Therefore, we need to characterize appropriate function spaces for learning $G$ and $D$.
To obtain a tractable minimax optimization problem, these functions need to be optimized over parameterized sets of functions with bounded statistical complexity.
To find a tractable generator set $\mathcal{G}$ for $k$-component GMMs, we propose a random linear mapping that produces only mixtures of $k$ Gaussians. Here, we consider a randomized mapping of the Gaussian input $\mathbf{Z}\sim \mathcal{N}(\mathbf{0},I_{d\times d})$, specified by matrices $\Lambda_i\in \mathbb{R}^{d\times d}$, vectors $\boldsymbol{\mu}_i\in\mathbb{R}^d$, and random $Y\in\mathcal{Y}=\{1,\ldots,k\}$ distributed as $\Pr(Y=i)=\pi_i$ for each $1\le i\le k$:
\begin{equation}\label{Eq: Generator_general}
G(\mathbf{z})= \sum_{i=1}^k \mathbb{I}(Y=i)\bigl(\Lambda_i\mathbf{z}+\boldsymbol{\mu}_i\bigr).
\end{equation}
Here $\mathbb{I}(\cdot)$ denotes the indicator function which is equal to $1$ if the input outcome holds and $0$ otherwise. Therefore, the above generator can output any $k$-component GMM. If the underlying GMM is uniformly distributed among its components, we can further take $Y$ to be uniform, that is, $\pi_i=\frac{1}{k}$ for each $i$. If the Gaussian components are also assumed to share the same covariance matrix, we can use the same $\Lambda_i=\Lambda$ in the formulation. In the special case of a symmetric two-component underlying GMM with opposite means, $G$ can be reduced to the following randomized mapping where $Y$ is uniform on $\{-1,+1\}$:
\begin{equation}\label{Eq: Generator_binary}
G(\mathbf{z})=Y(\Lambda \mathbf{z}+\boldsymbol{\mu}).
\end{equation}
To find an appropriate discriminator set $\mathcal{D}$, we can consider the set of all discriminator functions that are optimal for two GMMs in \eqref{Eq: general WGAN}'s maximization problem. Therefore, we need to analytically characterize an optimal $D$ in \eqref{Eq: general WGAN} for two GMMs. Since we consider the quadratic cost $c(\mathbf{x},\mathbf{x}')=\frac{1}{2}\Vert\mathbf{x}-\mathbf{x}'\Vert^2_2$, we can apply Brenier's theorem from the optimal transport theory literature.
\begin{lemma}[Brenier's theorem, \cite{villani2008optimal}]
Suppose the generator's distribution $P_{G(\mathbf{Z})}$ has finite first-order moment, i.e. $\mathbb{E}[\Vert G(\mathbf{Z})\Vert_2]<\infty$, and is absolutely continuous with respect to the data distribution. Then for $c(\mathbf{x},\mathbf{x}')=\frac{1}{2}\Vert\mathbf{x}-\mathbf{x}'\Vert^2_2$, the optimal $D^*$ in \eqref{Eq: general WGAN} satisfies
\begin{equation}
\mathbf{X}-\nabla D^*(\mathbf{X}) \stackrel{\tiny\text{\rm dist}}{=} G(\mathbf{Z}),
\end{equation}
where $ \stackrel{\tiny\text{\rm dist}}{=}$ means the two random vectors have the same probability distribution.
\end{lemma}
The above result implies that the optimal discriminator's gradient $\nabla D^*(\mathbf{x})$ provides an optimal transport map between the two GMMs. However, characterizing the precise optimal transport map between two GMMs is known to be challenging~\cite{chen2018optimal}. To address this issue, we use an idea that is adapted from reference~\cite{gozlan2020mixture}'s randomized transportation map between two distributions. As we show here, we can find such a randomized transportation between two GMMs uniformly distributed among their components. This randomized map is employed to obtain a deterministic transport map and bound its approximation error in the W2GAN problem.
Given $\mathbf{X},\widetilde{\mathbf{X}}$ distributed according to two GMMs, uniformly distributed among their components and parameterized by $(\boldsymbol{\mu}_i,\Sigma_i)$'s and $(\widetilde{\boldsymbol{\mu}}_i,\widetilde{\Sigma}_i)$'s, consider the following randomized transportation map from $\mathbf{X}$ to $\widetilde{\mathbf{X}}$:
\begin{align}
\Psi(\mathbf{X},Y) := \sum_{i=1}^k \mathbb{I}(Y=i)\bigl(\Gamma_i(\mathbf{X}-\boldsymbol{\mu}_i)+\widetilde{\boldsymbol{\mu}}_i \bigr).
\end{align}
where $\Gamma_i = \widetilde{\Sigma}_i^{1/2}\Sigma_i^{-1/2}$ converts the covariance matrix for the $i$-th component and $Y$ represents the random component label for $\mathbf{X}$. Note that $\Psi(\mathbf{X},Y)$ has the same distribution as the GMM $P_{\widetilde{\mathbf{X}}}$. However, $\Psi$ is a function of both $\mathbf{X}$ and $Y$, so to obtain a deterministic mapping of $\mathbf{X}$, we take the conditional expectation:
\begin{equation}\label{def: psi function}
\psi(\mathbf{x}) := \mathbb{E}\bigl[\Psi(\mathbf{X},Y)\,\vert\,\mathbf{X}=\mathbf{x}\bigr] = \sum_{i=1}^k\bigl[ \Pr(Y=i\,\vert\,\mathbf{X}=\mathbf{x})(\Gamma_i(\mathbf{x}-\boldsymbol{\mu}_i) +\widetilde{\boldsymbol{\mu}}_i)\bigr].
\end{equation}
The following theorem bounds the approximation error of considering the above transportation map in the W2GAN problem.
\begin{thm}\label{Thm: Approimxating Wasserstein Distance}
Consider the W2GAN problem \eqref{Eq: general WGAN} with quadratic cost $c(\mathbf{x},\mathbf{x}')=\frac{1}{2}\Vert \mathbf{x}-\mathbf{x}'\Vert_2^2$. Assume $\psi$ defined in \eqref{def: psi function} is the gradient of a convex function $\phi$. Then, the following inequalities hold for $\widetilde{D}(\mathbf{x})=\frac{1}{2}\Vert \mathbf{x}\Vert_2^2 - \phi(\mathbf{x})$:
\begin{equation}
0\, \le \, W_c(P_{\mathbf{X}},P_{\widetilde{\mathbf{X}}}) - \bigl\{\mathbb{E}[\widetilde{D}(\mathbf{X})] - \mathbb{E}[\widetilde{D}^c(\widetilde{\mathbf{X}})]\bigr\} \, \le \, \left(\frac{3}{2}M_1+\sqrt{M_1 M_2}\right)\sqrt{P_e} + \sqrt{M_1 M_2} \sqrt[4]{P_e},
\end{equation}
where $P_e=\Pr(Y^{\text{\rm opt}}(\mathbf{X})\neq Y)$ is the probability of miclassification of the Bayes classifier $Y^{\text{\rm opt}}(\mathbf{X})$ for predicting label $Y$ from $\mathbf{X}$. We define $M_1,M_2$ in the following equations with $\Vert\cdot\Vert_\sigma$ denoting the maximum singular value, i.e., the spectral norm,
\begin{align*}
M_1 \, & =\, 8\max_{i} \Vert\Gamma_i\Vert^2_{\sigma} \sqrt{\mathbb{E}[\Vert\mathbf{X}\Vert_2^4]} \, + \, 8\sqrt{P_e}\max_i \Vert \Gamma_i\boldsymbol{\mu}_i - \widetilde{\boldsymbol{\mu}}_i \Vert^2_2, \\
M_2\, &= \, 2\max_i \Vert \Gamma_i-I \Vert^2_{\sigma} \mathbb{E}[ \Vert\mathbf{X}\Vert_2^2] \, + \, 2\max_i\Vert \Gamma_i\boldsymbol{\mu}_i -\widetilde{\boldsymbol{\mu}}_i\Vert^2_2.
\end{align*}
\end{thm}
\begin{proof}
We defer the proof to the Appendix.
\end{proof}
The above theorem suggests that the transportation map $\psi$ in \eqref{def: psi function} provides an approximation of the original optimal transport cost $W_c(P_{\mathbf{X}},P_{\widetilde{\mathbf{X}}})$ with an approximation error vanishing with the Bayes error of classifying the GMM's components. Consequently, Theorem \ref{Thm: Approimxating Wasserstein Distance} implies that if the Gaussian components in the data distribution are well-separated, the integral of the approximate transportation map provides a near optimal discriminator in the W2GAN problem. Our next result characterizes a parametric set of functions whose gradient can approximate the above transportation map $\psi$.
\begin{prop}\label{Prop 1}
Consider GMM vectors $\mathbf{X}, \widetilde{\mathbf{X}}$ with parameters $(\boldsymbol{\mu}_i,\Sigma_i)$'s and $(\widetilde{\boldsymbol{\mu}}_i,\widetilde{\Sigma}_i)$'s. Suppose $\Sigma_i$ and $\widetilde{\Sigma}_i$ commute for each $i$, i.e., $\Sigma_i \widetilde{\Sigma}_i = \widetilde{\Sigma}_i \Sigma_i $. For every $\mathbf{x}$, assume $\sum_{i=1}^k \vert \Pr(Y=i\,\vert\,\mathbf{X}=\mathbf{x}) - \Pr(\bar{Y}=i\,\vert\,\bar{\mathbf{X}}=\mathbf{x})\vert \le \epsilon$ is satisfied when $\bar{\mathbf{X}}$ and its label $\bar{Y}$ have parameters $(\boldsymbol{\mu}_i , \widetilde{\Sigma}^{-1/2}_i\Sigma^{1/2}_i)$ and when $\bar{\mathbf{X}},\bar{Y}$ have parameters $(\widetilde{\boldsymbol{\mu}}_i , I)$.
Then, a parameterized $D$ exists with the form
\begin{equation}\label{Eq: Discriminator_general}
D_{(A_i)_{i=1}^k,(\mathbf{b}_i,c_i)_{i=1}^{2k}}(\mathbf{x}) = \log\,\biggl(\,\frac{\sum_{i=1}^k \exp\bigl(\frac{1}{2}\mathbf{x}^TA_i\mathbf{x}+\mathbf{b}_i^T\mathbf{x}+c_i\bigr)}{\sum_{i=k+1}^{2k} \exp\bigl(\mathbf{b}_i^T\mathbf{x}+c_i\bigr)}\,\biggr),
\end{equation}
that satisfies the following inequality for $\psi$ defined in \eqref{def: psi function}: \begin{align*}\mathbb{E}[\Vert \psi(\mathbf{X}) - \nabla D(\mathbf{X}) \Vert_2]
\le \: \epsilon \left( \max_{i,j,l}\, \Vert \boldsymbol{\mu}_i\Vert_2 + \sqrt{\Vert\widetilde{\Sigma}_j\Sigma^{-1}_j\Vert_{\sigma}}\mathbb{E}[\Vert\mathbf{X}\Vert_2]+ \sqrt{\Vert\widetilde{\Sigma}_l\Sigma^{-1}_l\Vert_{\sigma}}\Vert\widetilde{\boldsymbol{\mu}}_l\Vert_2\bigr) \right).
\end{align*}
\end{prop}
\begin{proof}
We defer the proof to the Appendix.
\end{proof}
Proposition \ref{Prop 1} implies that if the conditional distribution $P_{Y|\mathbf{X}}$ for $\mathbf{X},\widetilde{\mathbf{X}}$ can be well-approximated using the means of $\mathbf{X}$, then the mapping $\psi$ can be captured by a softmax-based function in \eqref{Eq: Discriminator_general}. As a special case, in the Appendix we show that Proposition \ref{Prop 1}'s assumption when $\mathbf{X},\widetilde{\mathbf{X}}$ are symmetric mixtures of two well-separable Gaussians with means $\boldsymbol{\mu},\widetilde{\boldsymbol{\mu}}$ translates to $\boldsymbol{\mu}^T\widetilde{\boldsymbol{\mu}}>O(\log(1/\epsilon))$.
\begin{remark}\label{Remark 1}
In the setting of Proposition \ref{Prop 1}, assume that each GMM's components share the same covariance matrix. Then, Proposition \ref{Prop 1} remains valid for the following softmax-based quadratic $D_{A,(\mathbf{b}_i,c_i)_{i=1}^{2k}}$. For a symmetric mixture of two Gaussians, constant $c_i$'s can also be removed while the approximation guarantee still applies.
\begin{equation}\label{Eq: Discriminator_Uniform}
D_{A,(\mathbf{b}_i,c_i)_{i=1}^{2k}}(\mathbf{x}) = \frac{1}{2}\mathbf{x}^T A\mathbf{x}+\log\,\biggl(\,\frac{\sum_{i=1}^k \exp(\mathbf{b}_i^T\mathbf{x}+c_i)}{\sum_{i=k+1}^{2k} \exp(\mathbf{b}_i^T\mathbf{x}+c_i)}\,\biggr)
\end{equation}
\end{remark}
We note that given a shared identity covariance for the two GMMs, \eqref{Eq: Discriminator_Uniform} reduces to the difference of two softmax functions, which revisits \cite{bai2018approximability}'s proposed architecture for this special case.
Proposition \ref{Prop 1} combined with Theorem \ref{Thm: Approimxating Wasserstein Distance} shows that the proposed softmax-based quadratic architecture results in an approximate optimal transport map between the two GMMs. Therefore, we use the architectures in \eqref{Eq: Generator_general} and \eqref{Eq: Discriminator_Uniform} for learning mixtures of Gaussians with a common covariance.
\section{GAT-GMM: A Minimax GAN Framework for Learning GMMs}
As shown earlier, we can constrain the generator and discriminator to the class of functions specified by \eqref{Eq: Generator_general} and \eqref{Eq: Discriminator_Uniform} to approximate the solution to the W2GAN problem when the underlying GMM has common covariance across components. Considering the W2GAN minimax objective in \eqref{Eq: general WGAN}, Proposition \ref{Proposition: c-transform reduction} suggests regularizing the expected c-transform in order to reduce the computational complexity of optimizing the c-transform function. We later show that this regularization will lead to a concave objective in the discriminator maximization problem which can be efficiently solved by a gradient descent ascent (GDA) algorithm.
\begin{prop}\label{Proposition: c-transform reduction}
Consider the discriminator function $D_{A,(\mathbf{b}_i,c_i)_{i=1}^{2k}}$ defined in \eqref{Eq: Discriminator_Uniform}. For constant $\eta > 0$, assume $\lambda_{\max}(A)+2\max_i \Vert \mathbf{b}_i \Vert^2_2\le \eta < 1$ where $\lambda_{\max}(\cdot)$ denotes the maximum eigenvalue. Then, for any set of vectors $(\mathbf{d}_i)_{i=1}^k$ and constants $(e_i)_{i=1}^k$ we have
\begin{align}\label{Eq: Prop 2 D^c upperbound}
&\mathbb{E}\bigl[ D^c_{A,(\mathbf{b}_i,c_i)_{i=1}^{2k}}(\mathbf{X}) \bigr] \, \le \, \mathbb{E}\bigl[ D_{A,(\mathbf{b}_i,c_i)_{i=1}^{2k}}(\mathbf{X})\bigr] \\
&\quad + \frac{3k^2(\mathbb{E}[\Vert\mathbf{X}\Vert^2_2]+1)}{1-\eta}\biggl(\Vert A\Vert^2_F + \sum_{i=1}^k \bigl[ \Vert\mathbf{b}_i - \mathbf{d}_i \Vert^2_2 + \Vert\mathbf{b}_{k+i} - \mathbf{d}_i \Vert^2_2 +(c_i-e_i)^2+ (c_{k+i}-e_i)^2\bigr] \biggr). \nonumber
\end{align}
\end{prop}
\begin{proof}
We defer the proof to the Appendix.
\end{proof}
Replacing the c-transform expectation in \eqref{Eq: general WGAN} with its upper-bound in \eqref{Eq: Prop 2 D^c upperbound}, we reach the following regularized minimax problem for learning GMMs with a common covariance. We call the minimax framework \emph{Generative Adversarial Training for Gaussian Mixture Models (GAT-GMM)}:
\begin{align}\label{Eq: GM-GAN: general case}
\min_{{\Lambda,(\boldsymbol{\mu}_i)_{i=1}^k}}\;\max_{{A,(\mathbf{b}_i,c_i)_{i=1}^{2k}}}\; &\mathbb{E}\bigl[D_{A,(\mathbf{b}_i,c_i)_{i=1}^{2k}}(\mathbf{X})\bigr] - \mathbb{E}\bigl[D_{A,(\mathbf{b}_i)_{i=1}^{2k}}\bigl(G_{\Lambda,(\boldsymbol{\mu}_i)_{i=1}^k} (\mathbf{Z})\bigr)\bigr] \\
& \;\; - \frac{\lambda}{2} \biggl(\Vert A\Vert^2_F + \sum_{i=1}^k \bigl[ \Vert\mathbf{b}_i - \mathbf{d}_i \Vert^2_2 + \Vert\mathbf{b}_{i+k} - \mathbf{d}_i \Vert^2_2 +(c_i-e_i)^2+ (c_{k+i}-e_i)^2\bigr] \biggr). \nonumber
\end{align}
Here $\lambda $ denotes the coefficient of the regularization term suggested by Proposition \ref{Proposition: c-transform reduction}. Also, $(\mathbf{d}_i,e_i)$'s represent a fixed set of real vectors and constants. The $\mathbf{d}_i$'s should be chosen to make the underlying GMM well-separable along their directions; we discuss how to select $\mathbf{d}_i$'s for symmetric mixtures of two Gaussians in the next section. To solve \eqref{Eq: GM-GAN: general case}, we propose a GDA algorithm where we iteratively apply one step of gradient descent for minimization followed by one step of gradient ascent for maximization. The following theorem provides optimization guarantees for the convergence of this algorithm to approximate stationary minimax points. In this theorem, we use $\mathcal{L}(\Lambda,(\boldsymbol{\mu}_i)_{i=1}^k)$ to denote the optimal value of the discriminator objective for generator parameters $\Lambda,(\boldsymbol{\mu}_i)_{i=1}^k$. Also, $\operatorname{vec}(\cdot)$ denotes the vector concatenating the inputs' entries.
\begin{thm}
Consider the GAT-GMM minimax problem \eqref{Eq: GM-GAN: general case} with the constraint that $\Vert \Lambda \Vert^2_F + \max_i \Vert \boldsymbol{\mu}_i\Vert_2^2 +1 \le \eta$. Suppose $\mathbb{E}[\Vert \mathbf{X} \Vert^2_2] \le \eta < \frac{\lambda}{2}$. Then, the GDA algorithm with maximization and minimization stepsizes $\alpha_{\max}=\frac{1}{\lambda+2\eta}$ and $\alpha_{\min}= \frac{1}{\kappa^2L}$ for $L=2\lambda+4\eta + 10(k+1)(\frac{\eta}{\lambda} +\max_i\Vert\mathbf{d}_i\Vert^2_2)$ and $\kappa=\frac{L}{\lambda-2\eta}$ will find an approximate stationary point such that $\bigl\Vert \nabla_{\operatorname{vec}(\Lambda,(\boldsymbol{\mu}_i)_{i=1}^k)} \mathcal{L}\bigl(\Lambda,(\boldsymbol{\mu}_i)_{i=1}^k\bigr) \bigr\Vert_2 \le \epsilon$ over $\mathcal{O}\bigl(\frac{\kappa L ((2\eta/\lambda)^2 + \kappa)}{\epsilon^2} \bigr)$ iterations.
\end{thm}
\begin{proof}
We defer the proof to the Appendix.
\end{proof}
The above theorem shows that the GAT-GMM's minimax problem, which reduces to a non-convex concave minimax optimization problem \cite{lin2019gradient} for $\lambda$ values characterized in the theorem, can be efficiently solved by GDA to obtain an approximate stationary minimax point characterized by \cite{jin2019minmax}.
\section{Theoretical Guarantees for Symmetric Two-component GMMs}
Here, we focus on the application of GAT-GMM for learning a symmetric mixture of two Gaussians $\frac{1}{2}\mathcal{N}(\boldsymbol{\mu}_{\mathbf{X}},\Sigma_{\mathbf{X}})+\frac{1}{2}\mathcal{N}(-\boldsymbol{\mu}_{\mathbf{X}},\Sigma_{\mathbf{X}})$. This benchmark class of GMMs has been well studied in the literature for analyzing the convergence properties of the EM algorithm \cite{daskalakis2016ten,xu2016global}. We similarly provide theoretical guarantees for GAT-GMM in this benchmark setting. To apply GAT-GMM \eqref{Eq: GM-GAN: general case} for learning such a GMM, we use the discriminator architecture in \eqref{Eq: Discriminator_Uniform} with a norm-squared regularization penalty such that $\mathbf{d}_1 = - \mathbf{d}_2 = \mathbf{d}$ to obtain the minimax problem
\begin{align}\label{Eq: GMGAN Binary Case}
\min_{\Lambda,\boldsymbol{\mu}}\;\max_{A,(\mathbf{b}_i)_{i=1}^4}\; &\mathbb{E}\bigl[D_{A,(\mathbf{b}_i)_{i=1}^4}(\mathbf{X})\bigr] - \mathbb{E}\bigl[D_{A,(\mathbf{b}_i)_{i=1}^4}\bigl(G_{\Lambda,\boldsymbol{\mu}} (\mathbf{Z})\bigr)\bigr] \nonumber \\
&\quad - \frac{\lambda}{2} \biggl(\Vert A\Vert^2_F + \Vert\mathbf{b}_1 - \mathbf{d} \Vert^2_2 + \Vert\mathbf{b}_2 + \mathbf{d} \Vert^2_2 + \Vert\mathbf{b}_3 - \mathbf{d} \Vert^2_2 + \Vert\mathbf{b}_4 + \mathbf{d} \Vert^2_2 \biggr).
\end{align}
In the following discussion, we use $\mathcal{L}(G_{\Lambda,\boldsymbol{\mu}})$ to denote the optimal maximum discriminator objective in \eqref{Eq: GMGAN Binary Case}. Theorem \ref{Thm: GM-GAN approximation} proves that the global solution to \eqref{Eq: GMGAN Binary Case} will result in the underlying GMM as long as $\mathbf{X}$'s projection along $\mathbf{d}$ satisfies $\sigma_d+2\sigma^2_d\le \mu_d$ given its mean $\mu_d:={\mathbf{d}}^T\boldsymbol{\mu}_{\mathbf{X}} $ and variance $\sigma^2_d:={\mathbf{d}}^T\Sigma_{\mathbf{X}}{\mathbf{d}}$ parameters. This condition, which is formally stated below, requires sufficient separability among the mixture components in the direction of vector $\mathbf{d}$ as it assumes the signal-to-noise ratio $\frac{\mu_d}{\sigma_d}$ to be greater than $1+2\sigma_d$. In our numerical experiments, we chose $\mathbf{d}$ as the principal eigenvector of empirical $\mathbb{E}[\mathbf{X}\mathbf{X}^T]$ and numerically validated that the condition holds for the experiment's GMM.
\begin{condition}\label{Condition: SNR}
For mean and covariance parameters $(\boldsymbol{\mu},\Sigma)$ and vector $\widetilde{\mathbf{d}}$, the following inequality holds for the mean's and covariance's projections along vector $\widetilde{\mathbf{d}}$:
\begin{equation}\label{Eq: SNR condition}
2\widetilde{\mathbf{d}}^T\Sigma\widetilde{\mathbf{d}}+\sqrt{\widetilde{\mathbf{d}}^T\Sigma\widetilde{\mathbf{d}}} \, \le \, \bigl\vert \boldsymbol{\mu}^T\widetilde{\mathbf{d}} \bigr\vert.
\end{equation}
\end{condition}
\begin{thm}\label{Thm: GM-GAN approximation}
Consider the minimax problem in \eqref{Eq: GMGAN Binary Case} for learning a symmetric two-component GMM $\frac{1}{2}\mathcal{N}(\boldsymbol{\mu}_{\mathbf{X}},\Sigma_{\mathbf{X}})+\frac{1}{2}\mathcal{N}(-\boldsymbol{\mu}_{\mathbf{X}},\Sigma_{\mathbf{X}})$. Suppose that $(\boldsymbol{\mu}_{\mathbf{X}},\Sigma_{\mathbf{X}})$ satisfies Condition \ref{Condition: SNR} along vector $\mathbf{d}$. Then, $(\boldsymbol{\mu},\Sigma)=(\boldsymbol{\mu}_{\mathbf{X}},\Sigma_{\mathbf{X}})$ is the only minimizer of $\mathcal{L}(G_{\Lambda,\boldsymbol{\mu}})$ satisfying Condition \ref{Condition: SNR} along $\mathbf{d}$.
\end{thm}
\begin{proof}
We defer the proof to the Appendix.
\end{proof}
Theorem \ref{Thm: GM-GAN approximation} explains that while we are constraining discriminator $D$ in \eqref{Eq: GMGAN Binary Case} to the class of softmax-based quadratic functions, the global solution to GAT-GMM's minimax problem still matches an underlying GMM with well-separable components along $\mathbf{d}$. The next theorem
indicates that the underlying $P_{\mathbf{X}}$ is the only GMM with well-separable components along $\mathbf{d}$ that is also a minimax stationary point in the GAT-GMM problem. Therefore, constraining $G$ to GMMs with well-separable components along $\mathbf{d}$ results in only one minimax stationary solution which is the underlying GMM.
\begin{thm}\label{Thm: GM-GAN Optimization}
Consider the setting of Theorem \ref{Thm: GM-GAN approximation}. Suppose that for every feasible $G_{\Lambda,\boldsymbol{\mu}}$ Condition \ref{Condition: SNR} holds for $(\boldsymbol{\mu}, \Sigma)$ along every $\widetilde{\mathbf{d}}$ in a $\frac{\rho}{\lambda}$-distance from $\mathbf{d}$, i.e., $\Vert \widetilde{\mathbf{d}} - \mathbf{d}\Vert_2\le \frac{\rho }{\lambda}$, with $\rho$ being the maximum $\mathbb{E}[\Vert G_{\Lambda,\boldsymbol{\mu}}(\mathbf{Z})\Vert_2]$ over feasible $G_{\Lambda,\boldsymbol{\mu}}$'s. Suppose $\mathbb{E}[\Vert\mathbf{X}\Vert^2_2]+\mathbb{E}[\Vert G_{\Lambda,\boldsymbol{\mu}}(\mathbf{Z})\Vert^2_2]\le\lambda$ for feasible $\Lambda,\boldsymbol{\mu}$'s. Then, $(\boldsymbol{\mu}_{\mathbf{X}},\Sigma_\mathbf{X})$ is the only stationary point in the feasible set with $\nabla_{\operatorname{vec}(\boldsymbol{\mu},\Lambda)} \mathcal{L}(G_{\Lambda,\boldsymbol{\mu}}) = \mathbf{0}$.
\end{thm}
\begin{proof}
We defer the proof to the Appendix.
\end{proof}
Finally, Theorem \ref{Thm: GM-GAN Generalization} bounds the generalization error of estimating the GAT-GMM's minimax objective and its derivatives from empirical samples. This result implies that a stationary point of the empirical objective will lead to an approximate stationary point of the underlying objective given $\mathcal{O}(d)$ samples.
\begin{thm}\label{Thm: GM-GAN Generalization}
Consider the setting of Theorem 4 with the additional constraints $\mathbf{b}_1=-\mathbf{b}_2,\, \mathbf{b}_3=-\mathbf{b}_4$, which do not change the optimal solution to \eqref{Eq: GMGAN Binary Case}. Let $\widehat{\mathcal{L}}(G_{\Lambda,\boldsymbol{\mu}})$ denote the empirical objective for $n$ i.i.d. $\mathbf{x}_i$'s sampled from $P_{\mathbf{X}}$. Let $ \frac{\partial{\mathcal{L}}(G_{\Lambda,\boldsymbol{\mu}})}{\partial \Lambda},\, \frac{\partial{\mathcal{L}}(G_{\Lambda,\boldsymbol{\mu}})}{\partial \boldsymbol{\mu}}$ denote the objective's derivative with respect to $\Lambda ,\, \boldsymbol{\mu}$. Then, for every $\delta>0$, with probability at least $1-\delta$ the following bounds hold uniformly for every $\boldsymbol{\mu},\Lambda$ such that $\Vert\boldsymbol{\mu}\boldsymbol{\mu}^T +\Lambda\Lambda^T \Vert_F\le \mathbb{E}[\Vert\mathbf{X}\Vert^2_2]$:
\begin{align}
&\big\vert \widehat{\mathcal{L}}(G_{\Lambda,\boldsymbol{\mu}})- {\mathcal{L}}(G_{\Lambda,\boldsymbol{\mu}})\big\vert \le \mathcal{O}\bigl(\sqrt{\frac{d^2\log(1/\delta) }{\lambda^2 n}}\bigr), \\
&\big\Vert \frac{\partial\widehat{\mathcal{L}}(G_{\Lambda,\boldsymbol{\mu}})}{\partial \boldsymbol{\mu}}(\boldsymbol{\mu})- \frac{\partial\mathcal{L}(G_{\Lambda,\boldsymbol{\mu}})}{\partial \boldsymbol{\mu}}(\boldsymbol{\mu})\big\Vert_{2} + \big\Vert \frac{\partial\widehat{\mathcal{L}}(G_{\Lambda,\boldsymbol{\mu}})}{\partial \Lambda}(\Lambda)- \frac{\partial{\mathcal{L}}(G_{\Lambda,\boldsymbol{\mu}})}{\partial \Lambda}(\Lambda)\big\Vert_{\sigma} \, \le \, \mathcal{O}\bigl(\sqrt{\frac{d\log(1/\delta) }{\lambda^2 n}}\bigr).\nonumber
\end{align}
\end{thm}
\begin{proof}
We defer the proof to the Appendix.
\end{proof}
\section{Numerical Experiments}
\begin{figure}[t]
\centering
\includegraphics[width=1.0\textwidth]{main_samples.png}
\caption{Samples produced from GAT-GMM, VGAN, WGAN-WC, WGAN-GP on isotropic task.}\label{fig:isotropic-samples}
\end{figure}
We considered two datasets of symmetric, 2-component GMMs. The first was a well-separated, 20-dimensional GMM with isotropic covariance. The second was a 100-dimensional GMM with a randomly rotated and scaled covariance, which is more difficult to learn due to high dimensionality and lack of axis-alignment \cite{ashtiani2018nearly}. We numerically verified for both datasets that Condition \ref{Condition: SNR} holds along the top eigenvector of the empirical $\mathbb{E}[\mathbf{X}\mathbf{X}^T]$.
For each dataset, we trained GAT-GMM using alternating gradient descent ascent. We compared GAT-GMM with the EM algorithm and the following standard neural net-based GANs: vanilla GAN (VGAN) \cite{goodfellow2014generative}, spectrally-normalized GAN (SN-GAN) \cite{miyato2018spectral}, Pac-VGAN and Pac-SNGAN \cite{lin2018pacgan}, GM-GAN \cite{ben2018gaussian}, and Wasserstein GAN with weight clipping (WGAN-WC) \cite{arjovsky2017wasserstein} and gradient penalty (WGAN-GP) \cite{gulrajani2017improved}. Full details on the datasets and grid of hyper-parameter choices, as well as additional experiments for mixtures with more than 2 components, are provided in the Appendix.
To numerically evaluate our model, we computed the negative log-likelihood of the samples produced. In addition, for GAT-GMM and EM, we computed the following \emph{GMM Objective} which is the minimum of the 2-Wasserstein costs $W_c(\mathcal{N}(\boldsymbol{\mu},\Sigma),\mathcal{N}(\hat{\boldsymbol{\mu}},\hat{\Sigma}))$ and $W_c(\mathcal{N}(\boldsymbol{\mu},\Sigma),\mathcal{N}(-\hat{\boldsymbol{\mu}},\hat{\Sigma}))$:
\begin{equation}\label{Eq: Accuracy}
\operatorname{Tr}\bigl(\Sigma+\hat{\Sigma} - 2(\Sigma^{1/2}\hat{\Sigma}\Sigma^{1/2})^{1/2}\bigr)+\min\{\|\boldsymbol{\mu}-\hat{\boldsymbol{\mu}}\|^2,\|\boldsymbol{\mu}+\hat{\boldsymbol{\mu}}\|^2\}.
\end{equation}
For the baseline GANs where we did not have access to exact $\hat{\boldsymbol{\mu}}$ and $\hat{\Sigma}$, we used the trained generator to generate $10^5$ samples, divided the samples into those falling into the positive and negative orthants, computed the empirical means $\hat{\boldsymbol{\mu}}_1,\hat{\boldsymbol{\mu}}_2$ and covariances $\hat{\Sigma}_1,\hat{\Sigma}_2$ within the orthants, and estimated the GMM Objective using:
\begin{equation}\label{Eq: NN Accuracy}
\frac{1}{2}\sum_{i=1}^2\left[\operatorname{Tr}\bigl(\Sigma+\hat{\Sigma}_i - 2(\Sigma^{1/2}\hat{\Sigma}_i\Sigma^{1/2})^{1/2}\bigr)+\min\{\|\boldsymbol{\mu}-\hat{\boldsymbol{\mu}}_i\|^2,\|\boldsymbol{\mu}+\hat{\boldsymbol{\mu}}_i\|^2\}\right].
\end{equation}
\begin{figure}[t]
\centering
\includegraphics[width=1.0\textwidth]{combined_loss.png}
\caption{Left: GMM Objective over first 4000 iterations for GAT-GMM and various linear generator (\ref{Eq: Generator_binary}), neural net discriminator GANs. Right: GMM Objective over all training iterations.}\label{fig:loss}
\end{figure}
Figure \ref{fig:isotropic-samples} plots the samples generated by the trained GAT-GMM, vanilla GAN, WGAN-WC, and WGAN-GP for the isotropic case. The other baseline GANs either performed about as well as WGAN-GP or worse than WGAN-WC and vanilla GAN. Their generated samples, as well as the samples in the rotated covariance case, are displayed in the supplementary material. We observed that the GMM learned by GAT-GMM is visually very close to the underlying GMM. While WGAN-GP was able to qualitatively learn the GMM as well, both WGAN-WC and vanilla GAN produced visibly distinguishable samples. We note that WGAN-WC and vanilla GAN displayed mode collapse for many choices of hyper-parameters.
Quantitatively, GAT-GMM achieved a GMM objective of \textbf{0.0061} and \textbf{0.862} for isotropic and rotated covariances, respectively, while EM achieved GMM objectives of \textbf{0.0062} and \textbf{0.860}. Thus, GAT-GMM resulted in numerical scores comparable to the EM's scores in those experiments. Meanwhile, the top GMM objective values obtained by baseline GANs were \textbf{0.023} and \textbf{6.081}, both achieved by WGAN-GP. Table \ref{tbl:isotropic_main} provides a table of the numerical results for some GANs, including the evaluated GMM objectives as well as negative log-likelihoods (NLL). The full table is provided in the Appendix.
In all our experiments, the standard baseline GANs were unable to approach EM's performance, indicating that obtaining EM-like performance via a minimax GAN framework is non-trivial in general. From a computational perspective, GAT-GMM ran quickly on CPUs and achieved good results very quickly with 1-1 gradient descent-ascent (Figure \ref{fig:loss}), while neural net-based GANs required more discriminator steps to train properly. To further isolate the computational benefits of our discriminator choice, we also trained the linear generator (\ref{Eq: Generator_binary}) with neural net discriminators. As shown in Figure \ref{fig:loss}, GAT-GMM training is far faster and more stable than neural net GAN training for the same generator class.
\begin{table}[b]
\centering
{\renewcommand{\arraystretch}{1.25}%
\begin{tabular}{|c|cc|cc|}
\hline
& \multicolumn{2}{c|}{Isotropic} & \multicolumn{2}{c|}{Rotated}\\ \hline
Method & GMM Objective & NLL & GMM Objective & NLL \\ \hhline{=|==|==}
GAT-GMM & \textbf{0.0061} & -5.873 & 0.862 & \textbf{54.351} \\
EM & 0.0062 & -5.966 & \textbf{0.860} & 54.968 \\
VGAN & 0.338 & 1.048 & 35.445& 180.46 \\
SN-GAN & 0.027 & -6.257 & 6.111 & 55.183 \\
WGAN-WC & 0.225 & \textbf{-7.525} & 16.906 & 64.526 \\
WGAN-GP & 0.023 & -7.094 & 6.081 & 55.656 \\
\hline
\end{tabular}}
\caption{Numerical results on the isotropic and rotated datasets.} \label{tbl:isotropic_main}
\end{table}
\newpage
\bibliographystyle{unsrtnat}
| {'timestamp': '2020-06-19T02:09:30', 'yymm': '2006', 'arxiv_id': '2006.10293', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10293'} | arxiv |
\section{Background}\label{sec:background}
\subsection{Linear DAG Model}\label{sec:sem}
A \emph{DAG model} defined on a set of random variables $X=(X_1, \dots, X_d)$ consists of (1) a DAG $G=(V(G), E(G))$ that encodes a set of conditional independence assertions among the variables, and (2) the joint distribution $P(X)$ (with density $p(x)$) that is Markov w.r.t. the DAG $G$, which factors as $p(x) = \prod_{i=1}^d p(x_i| x_{\mathsf{PA}_i^G})$, where $\mathsf{PA}_i^G= \{j \in V(G) : X_j \rightarrow X_i \in E(G)\}$ denotes the set of parents of $X_i$ in $G$. Under further conditions, these edges may have causal interpretations \citep{Pearl2009causality,Spirtes2001causation}. In this work, we focus on the \emph{linear DAG model} that can be equivalently represented by a set of linear Structural Equation Models (SEMs), in which each variable obeys the model $X_i = B_i^\mathsf{T} X + N_i$, where $B_i$ is a coefficient vector and $N_i$ is the exogenous noise variable corresponding to variable $X_i$. In matrix form, the linear DAG model reads $X = B^\mathsf{T} X + N$, where $B=[B_1| \cdots |B_d]$ is a weighted adjacency matrix and $N = (N_1, \dots, N_d)$ is a noise vector with independent elements. The structure of $G$ is defined by the nonzero coefficients in $B$, i.e., $X_j \rightarrow X_i \in E(G)$ if and only if the coefficient in $B_i$ corresponding to $X_j$ is nonzero. Given i.i.d. samples $\mathbf{x}=\left \{ x^{(k)} \right \}_{k=1}^{n}$ from the distribution $P(X)$, our goal is to infer the matrix $B$, from which we may recover the DAG $G$ (or vice versa).\footnote{With a slight abuse of notation, we may also use $G$ and $B$ to refer to a directed graph (possibly cyclic) in the rest of the paper, depending on the context.}
\subsection{The NOTEARS Method}\label{sec:notears}
Recently, \citet{Zheng2018notears} have proposed NOTEARS that formulates the problem of learning linear DAGs as a continuous optimization task, leveraging an algebraic characterization of DAGs via the trace exponential function. It adopts a \emph{regression-based} objective, i.e., the \emph{least squares} loss, with $\ell_1$ penalty and a hard DAG constraint. The constrained optimization problem is then solved using the augmented Lagrangian method \citep{Bertsekas1999nonlinear}, followed by a thresholding step on the estimated edge weights.
In practice, the hard DAG constraint requires careful fine-tuning on the augmented Lagrangian parameters \citep{Birgin2005numerical, Birgin2012boundedness, Nie2004models}. It may also encounter numerical difficulties and ill-conditioning issues as the penalty coefficient has to go to infinity to enforce acyclicity, as demonstrated empirically by \citet{Ng2020convergence}. Moreover, minimizing the least squares objective is related to but does not directly maximize the data likelihood because it does not take into account the log-determinant (LogDet) term of the likelihood (see Section \ref{sec:notears_connection}). By contrast, we develop a \emph{likelihood-based} method that directly maximizes the data likelihood, and requires only soft sparsity and DAG constraints.
\section*{Broader Impact}
The proposed method is able to estimate the graphical structure of a linear DAG model, and can be efficiently scaled up to thousands of nodes while retaining a high accuracy. DAG structure learning has been a fundamental problem in machine learning in the past decades, with applications in many areas such as biology \citep{Sachs2005causal}. Thus, we believe that our method could be applied for beneficial purposes.
Traditionally, score-based methods, such as GES \citep{Chickering2002optimal}, rely on local heuristics partly owing to the large search space of possible graphs. The formulation of continuous optimization for structure learning has changed the nature of the task, which enables the usage of well-studied gradient-based solvers and GPU acceleration, as demonstrated in Section \ref{sec:scalability}.
Nevertheless, in practice, we comment that the graphical structures estimated by our method, as well as other structure learning methods, should be treated with care. In particular, they should be verified by domain experts before putting into decision-critical real world applications (e.g., healthcare). This is because the estimated structures may contain spurious edges, or may be affected by other factors, such as confounders, latent variables, measurement errors, and selection bias.
\section{Conclusion}\label{sec:conclusion}
We investigated whether the hard DAG constraint used by \citet{Zheng2018notears} and another widely used sparsity constraint are necessary for learning linear DAGs. In particular, we studied the asymptotic role of the sparsity and DAG constraints in the general linear Gaussian case and other specific cases including the linear non-Gaussian model and linear Gaussian model with equal noise variances. We also investigated their usefulness in the finite sample regime. Our theoretical results suggest that when the optimization problem is formulated using the likelihood-based objective in place of least squares, one only has to apply soft sparsity and DAG constraints to asymptotically learn a DAG equivalent to the ground truth DAG, under mild assumptions. This removes the need for a hard DAG constraint and is easier to solve. Inspired by that, we developed a likelihood-based structure learning method with continuous unconstrained optimization, and demonstrated its effectiveness through extensive experiments in both identifiable and nonidentifiable cases. Using GPU acceleration, the resulting method can easily handle thousands of nodes while retaining a high accuracy. Future works include extending the current procedure to other score functions, such as BDe \citep{Heckerman1995learning}, decreasing the optimization time by deploying a proper early stopping criterion, devising a systematic way for thresholding, and studying the sensitivity of penalty coefficients in different settings.
\section*{Acknowledgments}
The authors would like to thank Bryon Aragam, Shengyu Zhu, and the anonymous reviewers for helpful comments and suggestions. KZ would like to acknowledge the support by the United States Air Force under Contract No. FA8650-17-C-7715.
\section{Introduction}
Learning graphical structures from data based on Directed Acyclic Graphs (DAGs) is a fundamental problem in machine learning, with applications in many areas such as biology \citep{Sachs2005causal} and healthcare \citep{Lucas2004bayesian}. It is clear that the learned graphical models may not be interpreted causally \citep{Pearl2009causality,Spirtes2001causation}. However, they provide a compact, yet flexible, way to decompose the joint distribution. Under further conditions, these graphical models may have causal interpretations or be converted to representations (e.g., Markov equivalence classes) that have causal interpretations.
Two major classes of structure learning methods are constraint- and score-based methods. Constraint-based methods, including PC \citep{Spirtes1991pc} and FCI \citep{Spirtes1995causal, Colombo2011learning}, utilize conditional independence tests to recover the Markov equivalence class under faithfulness assumption. On the other hand, score-based methods formulate the problem as optimizing a certain score function \citep{Heckerman1995learning,Chickering2002optimal,Teyssier2012ordering,Solus2017consistency}. Due to the large search space of possible graphs \citep{Chickering1996learning}, most score-based methods rely on local heuristics, such as GES \citep{Chickering2002optimal}.
Recently, \citet{Zheng2018notears} have introduced the NOTEARS method which formulates the structure learning problem as a continuous constrained optimization task, leveraging an algebraic characterization of DAGs. NOTEARS is specifically developed for linear DAGs, and has been extended to handle nonlinear cases via neural networks \citep{Klainathan2018sam, Yu19daggnn, Ng2019masked, Ng2019graph, Lachapelle2020grandag, Zheng2020learning}. Other related works include DYNOTEARS \citep{Pamfil2020dynotears} that focuses on time-series data, and \citep{Zhu2020causal} that uses reinforcement learning to find the optimal DAGs. NOTEARS and most of its extensions adopt the least squares objective, which is related to but does not directly maximize the data likelihood. Furthermore, their formulations require a hard DAG constraint which may lead to optimization difficulties (see Section \ref{sec:notears}).
In this work, we investigate whether such a hard DAG constraint and another widely used sparsity constraint are necessary for learning DAGs. Inspired by that, we develop a likelihood-based structure learning method with continuous unconstrained optimization, called \emph{Gradient-based Optimization of dag-penalized Likelihood for learning linEar dag Models} (GOLEM). Our contributions are:
\begin{itemize}[leftmargin=2.6em]
\item We compare the differences between the regression-based and likelihood-based objectives for learning linear DAGs.
\item We study the asymptotic role of the sparsity and DAG constraints in the general linear Gaussian case and other specific cases including linear non-Gaussian model and linear Gaussian model with equal noise variances. We also investigate their usefulness in the finite sample regime.
\item Based on the theoretical results, we formulate a likelihood-based score function, and show that one only has to apply soft sparsity and DAG constraints to learn a DAG equivalent to the ground truth DAG. This removes the need for a hard DAG constraint\footnote{Using constrained optimization, the hard DAG constraint strictly enforces the estimated graph to be acyclic (up to numerical precision), which is stronger than a soft constraint.}\citep{Zheng2018notears} and leads to an unconstrained optimization problem that is much easier to solve.
\item We demonstrate the effectiveness of our DAG-penalized likelihood objective through extensive experiments and an analysis on the bivariate linear Gaussian model.
\end{itemize}
The rest of the paper is organized as follows: We review the linear DAG model and NOTEARS in Section \ref{sec:background}. We then discuss the role of sparsity and DAG constraints under different settings in Section \ref{sec:asymptotic_theoretical}. Based on the theoretical study, we formulate a likelihood-based method in Section \ref{sec:likelihood_score}, and compare it to NOTEARS and the least squares objective. The experiments in Section \ref{sec:experiments} verify our theoretical study and the effectiveness of our method. Finally, we conclude our work in Section \ref{sec:conclusion}.
\section{Asymptotic Role of Sparsity and DAG Constraints}\label{sec:asymptotic_theoretical}
In this section we study the asymptotic role of the sparsity and DAG constraints for learning linear DAG models. Specifically, we aim to investigate with different model classes, whether one should consider the DAG constraint as a hard or soft one, and what exactly one benefits from the sparsity constraint. We consider a score-based structure learning procedure that optimizes the following score function w.r.t. the weighted adjacency matrix $B$ representing a directed graph:
\begin{equation}
\label{eq:scr}
\mathcal{S}(B;\mathbf{x})=\mathcal{L}(B;\mathbf{x})+R_{sparse}(B)+R_{DAG}(B),
\end{equation}
where $\mathcal{L}(B;\mathbf{x})$ is the Maximum Likelihood Estimator (MLE), $R_{sparse}(B)$ is a penalty term encouraging sparsity, i.e., having fewer edges, and $R_{DAG}(B)$ is a penalty term encouraging DAGness on $B$. The penalty coefficients can be selected via cross-validation in practice.
It is worth noting that the sparsity (or frugality) constraint has been exploited to find the DAG or its Markov equivalence class with as few edges as possible, searching in the space of DAGs or equivalence classes. In particular, permutation-based methods have been developed to find the sparsest DAG across possible permutations of the variables \citep{Solus2017consistency,Raskutti2018learning}. This type of methods may benefit from smart optimization procedures, but inevitably they involve combinatorial optimization. Different from previous work, in this paper we do not necessarily constrain the search space to be acyclic in a hard manner, but the estimated graph will be a DAG if the ground truth is acyclic.
We will describe our specific choices of the penalty functions in Section \ref{sec:likelihood_score}. Throughout the paper, we assume that the ground truth structure is a DAG. We are concerned with two different cases. One is the general linear Gaussian model (i.e., assuming nonequal noise variances), for which it is known that the underlying DAG structure is not identifiable from the data distribution only \citep{Koller09probabilistic}. In the other case, the underlying DAG model is asymptotically identifiable from the data distribution itself, with or without constraining the search space to be the class of DAGs.
\subsection{General Linear Gaussian Case} \label{sec:general_linear}
We first study the specific class of structures for which the sparsity penalty term $R_{sparse}(B)$ is sufficient for the MLE to asymptotically learn a DAG equivalent to the ground truth DAG, i.e., the DAG penalty term $R_{DAG}(B)$ is not needed. Then we show that for the general structures, adding $R_{DAG}(B)$ guarantees learning a DAG equivalent to the ground truth DAG. We first require a notion of equivalence to be able to investigate the consistency of the approach.
\citet{Ghassami2020characterizing} have introduced a notion of equivalence among directed graphs, called quasi equivalence, as follows:
For a directed graph $G$, define the distribution set of $G$, denoted by $\Theta(G)$, as the set of all precision matrices (equivalently, distributions) that can be generated by $G$ for different choices of exogenous noise variances and edge weights in $G$.
Define a \emph{distributional constraint} as any equality or inequality constraint imposed by $G$ on the entries of precision matrix $\Theta$. Also, define a \emph{hard constraint} as a distributional constraint for which the set of the values satisfying that constraint is Lebesgue measure zero over the space of the parameters involved in the constraint. The set of hard constraints of a directed graph $G$ is denoted by $H(G)$. Note that the notion of hard constraint here is different from the hard DAG constraint used by \citet{Zheng2018notears}.
\begin{definition}[Quasi Equivalence]
\label{def:q-eq}
Let $\theta_G$ be the set of linearly independent parameters needed to parameterize any distribution $\Theta\in\Theta(G)$. For two directed graphs $G_1$ and $G_2$, let $\mu$ be the Lebesgue measure defined over $\theta_{G_1}\cup\theta_{G_2}$. $G_1$ and $G_2$ are quasi equivalent if $\mu(\theta_{G_1}\cap\theta_{G_2})\ne0$.
\end{definition}
Roughly speaking, two directed graphs are quasi equivalent if the
set of distributions that they can both generate
has a nonzero Lebesgue measure. See Appendix \ref{sec:quasi_example} for an example. Definition \ref{def:q-eq} implies that if directed graphs $G_1$ and $G_2$ are quasi equivalent, they share the same hard constraints.
The following two assumptions are required for the task of structure learning from observational data.
\begin{assumption}[G-faithfulness Assumption]
\label{assump:g-faith}
A distribution $\Theta$ is generalized faithful (g-faithful) to structure $G$ if $\Theta$ satisfies a hard constraint $\kappa$ if and only if $\kappa\in H(G)$.
We say that the g-faithfulness assumption is satisfied if the generated distribution is g-faithful to the ground truth structure.
\end{assumption}
\begin{assumption}
\label{assump:e}
Let $E(G)$ be the set of edges of $G$. For a DAG $G^*$ and a directed graph $\hat{G}$, we have the following statements.\\
(a) If $|E(\hat{G})|\le|E(G^*)|$, then $H(\hat{G}) \not\subset H(G^*)$.\\
(b) If $|E(\hat{G})|<|E(G^*)|$, then $H(\hat{G})\not\subseteq H(G^*)$.
\end{assumption}
Assumption \ref{assump:g-faith} is an extension of the well-known faithfulness assumption \citep{Spirtes2001causation}. The intuition behind Assumption \ref{assump:e} is that in DAGs all the parameters can be chosen independently. Hence, each parameter introduces an independent dimension to the distribution space.
Therefore, if a DAG and another directed graph $\hat{G}$ have the same number of edges, then the distribution space of the DAG cannot be a strict subset with lower dimension of the distribution space of $\hat{G}$. Note that the assumption holds if $\hat{G}$ is also a DAG. \citet{Ghassami2020characterizing} have showed that the g-faithfulness assumption is a mild one in the sense that the Lebesgue measure of the distributions not g-faithful to the ground truth is zero, and showed that under Assumption \ref{assump:g-faith} and a condition similar to Assumption \ref{assump:e}, the underlying directed graph can be identified up to quasi equivalence and proposed an algorithm to do so.
In the following, we first consider the case that the DAG penalty term $R_{DAG}(B)$ in expression \eqref{eq:scr} is not needed. The following condition is required for this case.
\begin{assumption}[Triangle Assumption]
\label{assump:sibling}
A DAG satisfies the triangle assumption if it does not have any triangles (i.e., 3-cycles) in its skeleton.
\end{assumption}
As an example, any polytree satisfies the triangle assumption.
\begin{theorem}
\label{thm:m1}
If the underlying DAG satisfies Assumptions \ref{assump:g-faith}-\ref{assump:sibling}, a sparsity penalized MLE asymptotically returns a DAG quasi equivalent to the ground truth DAG.
\end{theorem}
If we relax the triangle assumption, the global minimizer of $\mathcal{L}(B;\mathbf{x})+R_{sparse}(B)$ can be cyclic. However, the following theorem shows that even in this case, some global minimizers are still acyclic.
\begin{theorem}
\label{thm:m2}
If the underlying DAG satisfies Assumptions \ref{assump:g-faith} and \ref{assump:e}, the output of sparsity penalized MLE asymptotically has the same number of edges as the ground truth.
\end{theorem}
This motivates us to add the DAG penalty term $R_{DAG}(B)$ to the score function \eqref{eq:scr} to prefer a DAG solution to a cyclic one with the same number of edges.
\begin{corollary}
\label{cor:dag}
If the underlying DAG satisfies Assumptions \ref{assump:g-faith} and \ref{assump:e}, a sparsity and DAG penalized MLE asymptotically returns a DAG quasi equivalent to the ground truth DAG.
\end{corollary}
The proofs of Theorems \ref{thm:m1} and \ref{thm:m2} are given in Appendix \ref{sec:proof_dag_theorems}. Corollary \ref{cor:dag} implies that, under mild assumptions, one only has to apply soft sparsity and DAG constraints to the likelihood-based objective instead of constraining the search space to be acyclic in a hard manner, and the estimated graph will be a DAG up to quasi equivalence.
\subsection{With Identifiable Linear DAG Models}\label{sec:identifiable_dag}
In a different line of research, linear DAG models may be identifiable under specific assumptions. Suppose that the ground truth is a DAG. There are two types of identifiability results for the underlying DAG structure. One does not require the constraint that the search space is the class of DAGs; a typical example is the Linear Non-Gaussian Acyclic Model (LiNGAM) \citep{Shimizu2006lingam}, where at most one of the noise terms follows Gaussian distribution. In this case, it has been shown that as the sample size goes to infinity, among all directed graphical models that are acyclic or cyclic, only the underlying graphical model, which is a DAG, can generate exactly the given data distribution, thanks to the identifiability results of the Independent Component Analysis (ICA) problem \citep{Hyvarinen2001ica}. Hence, asymptotically speaking, given observational data generated by the LiNGAM, we do not need to enforce the sparsity or DAG constraint in the estimation procedure that maximizes the data likelihood, and the estimated graphical model will converge to the ground truth DAG. However, on finite samples, one still benefits from enforcing the sparsity and DAG constraints by incorporating the corresponding penalty term: because of random estimation errors, the linear coefficients whose true values are zero may have nonzero estimated values in the maximum likelihood estimate, and the constraints help set them to zero.
By contrast, the other type of identifiable linear DAG model constrains the estimated graph to be in the class of DAGs. An example is the linear Gaussian model with equal noise variances \citep{Peters2013identifiability}. In the proof of the identifiability result \citep[Theorem~1]{Peters2013identifiability}, it shows that when the sample size goes to infinity, there is no other DAG structure that can generate the same distribution. In theory, it is unclear whether any cyclic graph is able to generate the same distribution; however, we strongly believe that in this identifiability result, one has to apply the sparsity or DAG constraint, as suggested by our empirical results (see Section \ref{sec:asymtotic_experiments}) and an analysis in the bivariate case (Proposition \ref{prop:bivariate_case}).
Note that whether one benefits from the above identifiability results depends on the form of likelihood function. If it does not take into account the additional assumptions that give rise to identifiability and relies on the general linear Gaussian model, then the analysis in Section \ref{sec:general_linear} still applies.
\section{GOLEM: A Continuous Likelihood-Based Method}\label{sec:likelihood_score}
The theoretical results in Section \ref{sec:asymptotic_theoretical} suggest that likelihood-based objective with soft sparsity and DAG constraints asymptotically returns a DAG equivalent to the ground truth DAG, under mild assumptions. In this section, we formulate a continuous likelihood-based method based on these constraints, and describe the post-processing step and computational complexity. We then compare the resulting method to NOTEARS and the least squares objective.
\subsection{Maximum Likelihood Objectives with Soft Constraints}\label{sec:likelihood_objective}
We formulate a score-based method to maximize the data likelihood of a linear Gaussian model, with a focus on continuous optimization. The joint distribution follows multivariate Gaussian distribution, which gives the following objective w.r.t. the weighted matrix $B$ representing a directed graph:
\begin{equation*}
\label{eq:likelihood_nv}
\mathcal{L}_1(B; \mathbf{x}) = \frac{1}{2}\sum_{i=1}^d\log\left (\sum_{k=1}^{n}\big(x_i^{(k)} - B_i^\mathsf{T} x^{(k)}\big)^2\right ) - \log|\det(I - B)|.
\end{equation*}
If one further assumes that the noise variances are equal (although they may be nonequal), it becomes
\begin{equation}
\label{eq:likelihood_ev}
\mathcal{L}_2(B; \mathbf{x}) = \frac{d}{2}\log\left (\sum_{i=1}^{d}\sum_{k=1}^n\big(x_i^{(k)} - B_i^\mathsf{T} x^{(k)}\big)^2\right ) - \log|\det(I - B)|.
\end{equation}
The objectives above are denoted as likelihood-NV and likelihood-EV, respectively, with derivations provided in Appendix \ref{sec:likelihood_derivation}. Note that they give rise to the BIC score \citep{Schwarz1978estimating} (excluding complexity penalty term) assuming nonequal and equal noise variances, respectively, in the linear Gaussian setting.
In principle, one should use (a function of) the number of edges to assess the structure complexity, such as our study in Section \ref{sec:general_linear} and the $\ell_0$ penalty from BIC score \citep{Chickering2002optimal, Van2013ell_0, Raskutti2018learning}. However, it is difficult to optimize such a score in practice (e.g., GES \citep{Chickering2002optimal} adopts greedy search in the discrete space). To enable efficient continuous optimization, we use the $\ell_1$ penalty for approximation. Although the $\ell_1$ penalty has been widely used in regression tasks \citep{Robert1996lasso} to find sparse precision matrices \citep{Meinshausen2006high, Friedman2008sparse}, it has been rarely used to directly penalize the likelihood function in the linear Gaussian case \citep{Aragam2015concave}. With soft $\ell_1$ and DAG constraints, the \emph{unconstrained} optimization problems of our score functions are
\begin{equation}
\label{eq:likelihood_optimization}
\min_{B\in\mathbb{R}^{d\times d}} \quad \mathcal{S}_i(B; \mathbf{x}) = \mathcal{L}_i(B; \mathbf{x}) + \lambda_1\|B\|_{1} + \lambda_2 h(B),
\end{equation}
where $i=1,2$, $\lambda_1$ and $\lambda_2$ are the penalty coefficients, $\|B\|_{1}$ is defined element-wise, and $h(B)= \Tr \big(e^{B \circ B}\big)-d$ is the characterization of DAGness proposed by \citet{Zheng2018notears}. It is possible to use the characterization suggested by \citet{Yu19daggnn}, which is left for future work. The score functions $\mathcal{S}_i(B; \mathbf{x}), i=1,2$ correspond respectively to the likelihood-NV and likelihood-EV objectives with soft sparsity and DAG constraints, which are denoted as GOLEM-NV and GOLEM-EV, respectively.
Unlike NOTEARS \citep{Zheng2018notears} that requires a hard DAG constraint, we treat it as a soft one, and the estimated graph will (asymptotically) be a DAG if the ground truth is acyclic, under mild assumptions (cf. Section \ref{sec:asymptotic_theoretical}). This leads to the unconstrained optimization problems \eqref{eq:likelihood_optimization} that are much easier to solve. Detailed comparison of our proposed method to NOTEARS is further described in Section \ref{sec:notears_connection}.
Similar to NOTEARS, the main advantage of the proposed score functions is that continuous optimization method can be applied to solve the minimization problems, such as first-order (e.g., gradient descent) or second-order (e.g., L-BFGS \citep{Byrd2003lbfgs}) method. Here we adopt the first-order method Adam \citep{Kingma2014adam} implemented in \texttt{Tensorflow} \citep{Abadi2016tensorflow} with GPU acceleration and automatic differentiation (see Appendix \ref{sec:golem_implementation} for more details). Note, however, that the optimization problems inherit the difficulties of nonconvexity, indicating that they can only be solved to stationarity. Nonetheless, the empirical results in Section \ref{sec:experiments} demonstrate that this leads to competitive performance in practice.
\paragraph{Initialization scheme.} In practice, the optimization problem of GOLEM-NV is susceptible to local solutions. To remedy this, we find that initializing it with the solution returned by GOLEM-EV dramatically helps avoid undesired solutions in our experiments.
\subsection{Post-Processing}\label{sec:post_processing}
Asymptotically speaking, the estimated graph returned by GOLEM will, under mild assumptions, be acyclic (cf. Section \ref{sec:asymptotic_theoretical}). Nevertheless, due to finite samples and nonconvexity, the local solution obtained may contain several entries near zero and may not be exactly acyclic. We therefore set a small threshold $\omega$, as in \citep{Zheng2018notears}, to remove edges with absolute weights smaller than $\omega$. The key idea is to ``round'' the numerical solution into a discrete graph, which also helps reduce false discoveries. If the thresholded graph contains cycles, we remove edges iteratively starting from the lowest absolute weights, until a DAG is obtained. In other words, one may gradually increase $\omega$ until the thresholded graph is acyclic. This heuristic is made possible by virtue of the DAG penalty term, since it pushes the cycle-inducing edges to small values.
\subsection{Computational Complexity}\label{sec:complexity}
Gradient-based optimization involves gradient evaluation in each iteration. The gradient of the LogDet term from the score functions $\mathcal{S}_i(B; \mathbf{x}), i=1,2$ is given by
$\nabla_B \log|\det(I - B)| = -(I -B)^{-\mathsf{T}}$.
This implies that $\mathcal{S}_i(W; \mathbf{x})$ and its gradient involve evaluating the LogDet and matrix inverse terms. Similar to the DAG penalty term with matrix exponential \citep{Mohy2009scaling, Zheng2018notears}, the $\mathcal O(d^3)$ algorithms of both these operations \citep{Toledo1997locality, Farebrother1988linear} are readily available in multiple numerical computing frameworks \citep{Abadi2016tensorflow, Harris2020array}. Our experiments in Section \ref{sec:scalability} demonstrate that the optimization could benefit from GPU acceleration, showing that the cubic evaluation costs are not a major concern.
\subsection{Connection with NOTEARS and Least Squares Objective}\label{sec:notears_connection}
It is instructive to compare the likelihood-EV objective \eqref{eq:likelihood_ev} to the least squares, by rewriting \eqref{eq:likelihood_ev} as
\begin{equation*}\label{eq:rewrite_likelihood_ev}
\mathcal{L}_2(B; \mathbf{x}) = \frac{d}{2}\log\ell(B; \mathbf{x}) - \log|\det(I - B)| +\frac{d}{2}\log 2n,
\end{equation*}
where $\ell(B; \mathbf{x}) = \frac{1}{2n}\sum_{i=1}^{d}\sum_{k=1}^n\big(x_i^{(k)} - B_i^\mathsf{T} x^{(k)}\big)^2$ is the least squares objective. One observes that the main difference lies in the LogDet term. Without the LogDet term, the least squares objective with $\ell_1$ penalty corresponds to a multiple-output lasso problem, which is decomposable into $d$ independent regression tasks. Thus, least squares objective tends to introduce cycles in the estimated graph (see Proposition \ref{prop:bivariate_case} for an analysis in the bivariate case). Consider two variables $X_i$ and $X_j$ that are conditionally dependent given any subset of the remaining variables, then one of them is useful in predicting the other. That is, when minimizing the least squares for one of them, the other variable will tend to have a nonzero coefficient. If one considers those coefficients as weights of the graph, then the graph will have cycles. By contrast, the likelihood-based objective has an additional LogDet term that enforces a shared structure between the regression coefficients of different variables. We have the following lemma regarding the LogDet term, with a proof provided in Appendix \ref{sec:logdet_proof}.
\begin{lemma}\label{lemma:logdet}
If a weighted matrix $B\in\mathbb{R}^{d\times d}$ represents a DAG, then
\[\log|\det(I - B)| = 0.\]
\end{lemma}
Lemma \ref{lemma:logdet} partly explains why a hard DAG constraint is needed by the least squares \citep{Zheng2018notears}: its global minimizer(s) is (are) identical to the likelihood-EV objective if the search space over $B$ is constrained to DAGs in a hard manner. However, the hard DAG constraint may lead to optimization difficulties (cf. Section \ref{sec:notears}). With a proper scoring criterion, the ground truth DAG should be its global minimizer, and thus the hard DAG constraint can be avoided. As suggested by our theoretical study, using likelihood-based objective, one may simply treat the constraint as a soft one, leading to an unconstrained optimization problem that is much easier to solve. In this case the estimated graph will be a DAG if the ground truth is acyclic, under mild assumptions. The experiments in Section \ref{sec:experiments} show that our proposed DAG-penalized likelihood objective yields better performance in most settings.
To illustrate our arguments above, we provide an example in the bivariate case. We consider the linear Gaussian model with ground truth DAG $G:X_1\rightarrow X_2$ and equal noise variances, characterized by the following weighted adjacency matrix and noise covariance matrix:
\begin{equation}\label{eq:bivariate_setup}
B_0 = \begin{bmatrix}
0 & b_0\\
0 & 0
\end{bmatrix},
\Omega = \begin{bmatrix}
\sigma^2 & 0\\
0 & \sigma^2
\end{bmatrix}, b_0 \neq 0.
\end{equation}
We have the following proposition in the asymptotic case, with a proof given in Appendix \ref{sec:bivariate_proof}.
\begin{prop}
\label{prop:bivariate_case}
Suppose $X$ follows a linear Gaussian model defined by Eq. \eqref{eq:bivariate_setup}. Then, asymptotically,
\begin{thmlist}[leftmargin=1.7em]
\vspace{-0.3em}
\item $B_0$ is the unique global minimizer of least squares objective under a hard DAG constraint, but without the DAG constraint, the least squares objective returns a cyclic graph.
\vspace{0.2em}
\item $B_0$ is the unique global minimizer of likelihood-EV objective \eqref{eq:likelihood_ev} under soft $\ell_1$ or DAG constraint.
\end{thmlist}
\end{prop}
Therefore, without the DAG constraint, the least squares method never returns a DAG, while the likelihood objective does not favor cyclic over acyclic structures. This statement is also true in general: as long as a structure, be cyclic or acyclic, can generate the same distribution as the ground truth model, it can be the output of a likelihood score asymptotically.
Furthermore, Proposition \ref{prop:bivariate_case} implies that both objectives produce asymptotically correct results in the bivariate case, under different conditions. Nevertheless, the condition required by the likelihood-EV objective (GOLEM-EV) is looser than that of the least squares (NOTEARS), as it requires only soft constraint to recover the underlying DAG instead of a hard one. This bivariate example serves as an illustration of our study in Section \ref{sec:asymptotic_theoretical} which shows that GOLEM is consistent in the general case, indicating that the likelihood-based objective is favorable over the regression-based one.
\section{Experiments}\label{sec:experiments}
We first conduct experiments with increasing sample size to verify our theoretical study (Section \ref{sec:asymtotic_experiments}). To validate the effectiveness of our proposed likelihood-based method, we compare it to several baselines in both identifiable (Section \ref{sec:results_identifiable}) and nonidentifiable (Section \ref{sec:results_non_identifiable}) cases. The baselines include FGS \citep{Ramsey2017million}, PC \citep{Spirtes1991pc, Ramsey2006adjacency}, DirectLiNGAM \citep{Shimizu2011directlingam}, NOTEARS-L1, and NOTEARS \citep{Zheng2018notears}. In Section \ref{sec:scalability}, we conduct experiments on large graphs to investigate the scalability and efficiency of the proposed method. We then provide a sensitivity analysis in Section \ref{sec:weight_scale} to analyze the robustness of different methods. Lastly, we experiment with real data (Section \ref{sec:real_data}). The implementation details of our procedure and the baselines are described in Appendices \ref{sec:golem_implementation} and \ref{sec:baseline_implementation}, respectively.
Our setup is similar to \citep{Zheng2018notears}. The ground truth DAGs are generated from one of the two graph models, \emph{Erd\"{o}s--R\'{e}nyi} (ER) or \emph{Scale Free} (SF), with different graph sizes. We sample DAGs with $kd$ edges ($k=1,2,4$) on average, denoted by ER$k$ or SF$k$. Unless otherwise stated, we construct the weighted matrix of each DAG by assigning uniformly random edge weights, and simulate $n=1000$ samples based on the linear DAG model with different noise types. The estimated graphs are evaluated using normalized Structural Hamming Distance (SHD), Structural Intervention Distance (SID) \citep{Peters2013structural}, and True Positive Rate (TPR), averaged over $12$ random simulations. We also report the normalized SHD computed over CPDAGs of estimated graphs and ground truths, denoted as SHD-C. Detailed explanation of the experiment setup and metrics can be found in Appendices \ref{sec:experiment_setup} and \ref{sec:metric}, respectively.
\subsection{Role of Sparsity and DAG Constraints}\label{sec:asymtotic_experiments}
We investigate the role of $\ell_1$ and DAG constraints in both identifiable and nonidentifiable cases, by considering the linear Gaussian model with equal (\emph{Gaussian-EV}) and nonequal (\emph{Gaussian-NV}) noise variances, respectively. For \emph{Gaussian-EV}, we experiment with the following variants: GOLEM-EV (with $\ell_1$ and DAG penalty), GOLEM-EV-L1 (with only $\ell_1$ penalty), and GOLEM-EV-Plain (without any penalty term), likewise for GOLEM-NV, GOLEM-NV-L1, and GOLEM-NV-Plain in the case of \emph{Gaussian-NV}. Experiments are conducted on $100$-node ER1 and ER4 graphs, each with sample sizes $n\in\{100, 300, 1000, 3000, 10000\}$. Here we apply only the thresholding step for post-processing.
Due to space limit, the results are shown in Appendix \ref{sec:additional_asymtotic_experiments}.
In the \emph{Gaussian-EV} case, when the sample size is large, the graphs estimated by both GOLEM-EV and GOLEM-EV-L1 are close to the ground truth DAGs with high TPR, whereas GOLEM-EV-Plain has poor results without any penalty term. Notice also that the gap between GOLEM-EV-L1 and GOLEM-EV decreases with more samples, indicating that sparsity penalty appears to be sufficient to asymptotically recover the underlying DAGs. However, this is not the case for \emph{Gaussian-NV}, as the performance of GOLEM-NV-L1 degrades without the DAG penalty term, especially for the TPR. These observations serve to corroborate our asymptotic study: (1) For the general \emph{Gaussian-NV} case, although Theorem \ref{thm:m1} states that sparsity penalty is sufficient to recover the underlying DAGs, the triangle assumption is not satisfied in this simulation. Corollary \ref{cor:dag} has mild assumptions that apply here, implying that both sparsity and DAG penalty terms are required. (2) When the noise variances are assumed to be equal, i.e., in the \emph{Gaussian-EV} case, Section \ref{sec:identifiable_dag} states that either sparsity or DAG penalty can help recover the ground truth DAGs, thanks to the identifiability results. Nevertheless, DAG penalty is still very helpful in practice, especially on smaller sample sizes and denser graphs.
Since calculating the number of cycles in the estimated graphs may be too slow, we report the value of DAG penalty term $h(B)$ in Figures \ref{fig:asymptotic_experiments_identifiable} and \ref{fig:asymptotic_experiments_non_identifiable} as an indicator of DAGness. With $\ell_1$ and DAG penalty, the estimated graphs have low values of $h(B)$ across all settings. Consistent with our study, this implies that soft sparsity and DAG constraints are useful for both asymptotic cases and finite samples by returning solutions close to DAGs in practice, despite the nonconvexity of the optimization problem.
\subsection{Numerical Results: Identifiable Cases}\label{sec:results_identifiable}
We examine the structure learning performance in the identifiable cases. In particular, we generate \{ER1, ER2, ER4, SF4\} graphs with different sizes $d\in\{10, 20, 50, 100\}$. The simulated data follows the linear DAG model with different noise types: \emph{Gaussian-EV}, \emph{Exponential}, and \emph{Gumbel}.
For better visualization, the normalized SHD and SID of recent gradient-based methods (i.e., GOLEM-NV, GOLEM-EV, NOTEARS-L1, and NOTEARS) on ER graphs are reported in Figure \ref{fig:results_identifiable_er}, while complete results can be found in Appendix \ref{sec:additional_results_identifiable}. One first observes that gradient-based methods consistently outperform the other methods. Among gradient-based methods, GOLEM-NV and GOLEM-EV have the best performance in most settings, especially on large graphs. Surprisingly, these two methods perform well even in non-Gaussian cases, i.e., \emph{Exponential} and \emph{Gumbel} noise, although they are based on Gaussian likelihood. Also, we suspect that the number of edges whose directions cannot be determined is not high, giving rise to a high accuracy of our methods even in terms of SHD of the graphs. Consistent with previous work, FGS, PC, and DirectLiNGAM are competitive on sparse graphs (ER1), but their performance degrades as the edge density increases.
\begin{figure}
\centering
\centering
\subfloat[Normalized SHD.]{
\includegraphics[width=0.48\textwidth]{figures/results_identifiable/er/results_shd.pdf}
\label{fig:results_identifiable_shd_er}
}
\subfloat[Normalized SID.]{
\includegraphics[width=0.48\textwidth]{figures/results_identifiable/er/results_sid.pdf}
\label{fig:results_identifiable_tpr_er}
}
\caption{Results in terms of normalized SHD and SID on ER graphs, with sample size $n=1000$. Lower is better. Rows: ER$k$ denotes ER graphs with $kd$ edges on average. Columns: noise types. Since each panel has a number of lines, for better visualization we do not report the standard errors.}
\label{fig:results_identifiable_er}
\vspace{-0.5em}
\end{figure}
\subsection{Numerical Results: Nonidentifiable Cases}\label{sec:results_non_identifiable}
We now conduct experiments in the nonidentifiable cases by considering the general linear Gaussian setting (i.e., \emph{Gaussian-NV}) with \{ER1, ER2, ER4\} graphs. Hereafter we compare only with NOTEARS-L1, since it is the best performing baseline in the previous experiment.
Due to limited space, the results are given in Appendix \ref{sec:additional_results_non_identifiable} with graph sizes $d\in\{10, 20, 50, 100\}$. Not surprisingly, GOLEM-NV shows significant improvement over GOLEM-EV in most settings, as the assumption of equal noise variances does not hold here. It also outperforms NOTEARS-L1 by a large margin on denser graphs, such as ER2 and ER4 graphs. Although GOLEM-EV and NOTEARS-L1 both assume equal noise variances (which do not hold here), it is interesting to observe that they excel in different settings: NOTEARS-L1 demonstrates outstanding performance on sparse graphs (ER1) but deteriorates on ER4 graphs, and vice versa for GOLEM-EV.
\subsection{Scalability and Optimization Time}\label{sec:scalability}
We compare the scalability of GOLEM-EV to NOTEARS-L1 using the linear DAG model with \emph{Gaussian-EV} noise. We simulate $n=5000$ samples on ER2 graphs with increasing sizes $d\in\{100, 200,400, \dots, 3200\}$. Due to the long optimization time, we are only able to scale NOTEARS-L1 up to $1600$ nodes. The experiments of GOLEM-EV are computed on the P3 instance hosted on Amazon Web Services with a NVIDIA V100 GPU, while NOTEARS-L1 is benchmarked using the F4 instance on Microsoft Azure with four $2.4$ GHz Intel Xeon CPU cores and $8$ GB of memory.\footnote{For NOTEARS-L1, we have experimented with more CPU cores, such as the F16 instance on Azure with sixteen CPU cores and $32$ GB of memory, but there is only minor improvement in the optimization time.}
Here we report only the normalized SHD and TPR as the computation of SHD-C and SID may be too slow on large graphs. As depicted in Figure \ref{fig:scalability}, GOLEM-EV remains competitive on large graphs, whereas the performance of NOTEARS-L1 degrades as the graph size increases, which may be ascribed to the optimization difficulties of the hard DAG constraint (cf. Section \ref{sec:notears}). The optimization time of GOLEM-EV is also much shorter (e.g., $12.4$ hours on $3200$-node graphs) owing to its parallelization on GPU, showing that the cubic evaluation costs are not a major concern. We believe that the optimization of NOTEARS-L1 could also be accelerated in a similar fashion.
\subsection{Sensitivity Analysis of Weight Scale}\label{sec:weight_scale}
We investigate the sensitivity to weight scaling as in \citep{Zheng2018notears}. We consider $50$-node ER2 graphs with \emph{Gaussian-EV} noise and edge weights sampled uniformly from $\alpha\cdot[-2, -0.5]\cup\alpha\cdot[0.5, 2]$ where $\alpha\in\{0.3, 0.4,\dots, 1.0\}$. The threshold $\omega$ is set to $0.1$ for all methods in this analysis.
The complete results are provided in Appendix \ref{sec:additional_weight_scale}. One observes that GOLEM-EV has consistently low normalized SHD and SID, indicating that our method is robust to weight scaling. By contrast, the performance of NOTEARS-L1 is unstable across different weight scales: it has low TPR on small weight scales and high SHD on large ones. A possible reason for the low TPR is that the signal-to-noise ratio decreases when the weight scales are small, whereas for large ones, NOTEARS-L1 may have multiple false discoveries with intermediate edge weights, resulting in the high SHD.
\subsection{Real Data}\label{sec:real_data}
We also compare the proposed method to NOTEARS-L1 on a real dataset that measures the expression levels of proteins and phospholipids in human cells \citep{Sachs2005causal}. This dataset is commonly used in the literature of probabilistic graphical models, with experimental annotations accepted by the biological community. Based on $d=11$ cell types and $n=853$ observational samples, the ground truth structure given by \citet{Sachs2005causal} contains $17$ edges. On this dataset, GOLEM-NV achieves the best (unnormalized) SHD $14$ with $11$ estimated edges. NOTEARS-L1 is on par with GOLEM-NV with an SHD of $15$ and $13$ total edges, while GOLEM-EV estimates $21$ edges with an SHD of $18$.
\section{An Example of Quasi Equivalence}\label{sec:quasi_example}
\begin{figure}[h]
\centering
\includegraphics[width=0.45\textwidth]{figures/qeex.pdf}
\caption{An example of quasi equivalence.}
\label{fig:qeex}
\end{figure}
Here, we provide an example of two structures that are quasi equivalent to each other.
Consider directed graphs $G_1$ and $G_2$ in Figure \ref{fig:qeex}. Since $G_1$ is a complete DAG, it can generate any precision matrices.
Consider an arbitrary precision matrix $\Theta$ generated by $G_1$.
If $\Theta$ is representable by $G_2$, then we should be able to decompose it as $\Theta = QQ^\top$, where $Q$ has the following form.
\[
Q=
\begin{bmatrix}
\sigma_1^{-1} & 0 & -\beta_{13}\sigma_3^{-1} \\
-\beta_{21}\sigma_1^{-1} & \sigma_2^{-1} & 0 \\
0 & -\beta_{32}\sigma_2^{-1} & \sigma_3^{-1}
\end{bmatrix}.
\]
Therefore, it suffices to show that we have a matrix of form
\[
\begin{bmatrix}
a & 0 & b \\
c & d & 0 \\
0 & e & f
\end{bmatrix},
\]
such that
\begin{align*}
&a^2+b^2=\Theta_{11}~~~~~ac=\Theta_{12}\\
&c^2+d^2=\Theta_{22}~~~~~bf=\Theta_{13}\\
&e^2+f^2=\Theta_{33}~~~~~de=\Theta_{23}.
\end{align*}
Then we have $\sigma_1=a^{-1}$, $\sigma_2=d^{-1}$, $\sigma_3=f^{-1}$, $\beta_{13}=-b/f$, $\beta_{21}=-c/a$, $\beta_{32}=-e/d$.
Suppose that the value of $e$ is fixed. It should satisfy the following constraint:
\[
e^2=\Theta_{33}-\frac{\Theta_{13}^2}{\Theta_{11}-\frac{\Theta_{12}^2}{\Theta_{22}-\frac{\Theta_{23}^2}{e^2}}},
\]
or equivalently,
\[
(\Theta_{11}\Theta_{22}-\Theta_{12}^2)e^4+(-\Theta_{11}\Theta_{22}\Theta_{33}-\Theta_{11}\Theta_{23}^2+\Theta_{22}\Theta_{13}^2+\Theta_{33}\Theta_{12}^2)e^2+(\Theta_{11}\Theta_{33}\Theta_{23}^2-\Theta_{13}^2\Theta_{23}^2)=0,
\]
which does not necessarily have a real root, and only for a non-measure zero subset of the distributions is satisfied.
\section{Proofs of Theorems \ref{thm:m1} and \ref{thm:m2}}\label{sec:proof_dag_theorems}
The following part is required for the proofs of both Theorems \ref{thm:m1} and \ref{thm:m2}.
Let $G^*$ and $\Theta$ be the ground truth DAG and the generated distribution (precision matrix). Let $B$ and $\Omega$ be the weighted adjacency matrix and the diagonal matrix containing exogenous noise variances, respectively. Considering weights for penalty terms such that the likelihood term dominates asymptotically, we will find a pair $(\hat{B},\hat{\Omega})$, such that $(I-\hat{B})\hat{\Omega}^{-1}(I-\hat{B})^{\mathsf{T}}=\Theta$ and denote the directed graph corresponding to $\hat{B}$ by $\hat{G}$. We have $\Theta\in\Theta(\hat{G})$, which implies that $\Theta$ contains all the distributional constraints of $\hat{G}$. Therefore, under the faithfulness assumption, we have $H(\hat{G})\subseteq H(G^*)$. Due to the sparsity penalty we have $|E(\hat{G})|\le|E(G^*)|$, otherwise the algorithm would have output $G^*$. By Assumption \ref{assump:e}, we have $H(\hat{G}) \not\subset H(G^*)$. Now, from $H(\hat{G})\subseteq H(G^*)$ and $H(\hat{G}) \not\subset H(G^*)$ we conclude that $H(\hat{G})=H(G^*)$. Therefore, $\hat{G}$ is quasi equivalent to $G^*$.
\subsubsection*{Proof of Theorem \ref{thm:m1}.}
To complete the proof of Theorem \ref{thm:m1}, we show that the output directed graph will be acyclic.
We require the notion of virtual edge for the proof:
For DAGs, under the Markov and faithfulness assumptions, a variable $X_i$ is adjacent to a variable $X_j$ if and only if $X_i$ and $X_j$ are dependent conditioned on any subset of the rest of the variables. This is not the case for cyclic directed graphs.
Two nonadjacent variables $X_i$ and $X_j$ are dependent conditioned on any subset of the rest of the variables if they have a common child $X_k$ which is an ancestor of $X_i$ or $X_j$. In this case, we say that there exists a \emph{virtual edge} between $X_i$ and $X_j$ \citep{Richardson1996polynomial}.
We provide a proof by contradiction. Suppose that $\hat{G}$ contains cycles. Suppose $C=(X_1,...,X_c,X_1)$ is a cycle that does not contain any smaller cycles on its vertices. Since $G^*$ and $\hat{G}$ should have the same adjacencies (either via a real edge or a virtual edge), $G^*$ should also have edges in the location of all the edges of $C$.
\begin{itemize}[leftmargin=2.6em]
\item If $|C|>3$, then the DAG has a v-structure, say, $X_{i-1}\rightarrow X_i\leftarrow X_{i+1}$. Therefore, there exists a subset of vertices $X_S$ such that $X_i\not\in X_S$, conditioned on which $X_{i-1}$ and $X_{i+1}$ are independent. However, this conditional independence relation is not true in $\hat{G}$. This contradicts with quasi equivalence.
\item If $|C|=3$, then $G^*$ should also have a triangle on the corresponding three vertices, which contradicts the triangle condition.
\item If $|C|=2$, then suppose $C=(X_1,X_2,X_1)$. If none of the adjacencies in $\hat{G}$ to $C$ are in-going, then $C$ can be reduced to a single edge and the resulting directed graph is equivalent to $\hat{G}$ \citep{Ghassami2020characterizing}. Hence, due to the sparsity penalty, such $C$ is not possible. If there exists an in-going edge, say from $X_p$ to one end of $C$, there will be a virtual or real edge to the other end of $C$ as well. Therefore, $X_p$, $X_1$, and $X_2$ are adjacent in $\hat{G}$ and hence in $G^*$, which contradicts the triangle condition. Also, if the edge between $X_p$ and one end of $C$ is a virtual edge, $X_p$ should have a real edge towards another cycle in $\hat{G}$, which, with the virtual edge, again forms a triangle, and hence contradicts the triangle condition.
\end{itemize}
Therefore, in all cases, quasi equivalence or the triangle assumption is violated, which is a contradiction. Therefore, $\hat{G}$ is a DAG.
\subsubsection*{Proof of Theorem \ref{thm:m2}.}
From the first part of the proof, we obtained that $H(\hat{G})\subseteq H(G^*)$.
Therefore, by the contrapositive of part (b) in Assumption \ref{assump:e} we have $|E(\hat{G})|\ge|E(G^*)|$. Now, due to the sparsity penalty we have $|E(\hat{G})|\le|E(G^*)|$. This concludes that $|E(\hat{G})|=|E(G^*)|$.
\section{Derivations of Maximum Likelihood Objectives} \label{sec:likelihood_derivation}
\subsection{General Linear Gaussian Model}\label{sec:likelihood_nv_derivation}
Let $B$ be a weighted adjacency matrix representing a directed graph (possibly cyclic) over a set of random variables $X=(X_1, \dots, X_d)$. The linear Gaussian directed graphical model is given by
\[X = B^\mathsf{T} X + N,\]
where $N =(N_1, \dots, N_d)$ contains the exogenous noise variables that are jointly Gaussian and independent. The noise vector $N$ is characterized by the covariance matrix $\Omega = \operatorname{diag}(\sigma_1^2, \dots, \sigma_d^2)$. Assuming that $I - B^\mathsf{T}$ is invertible, we rewrite the linear model as
\[X = (I-B^\mathsf{T})^{-1}N.\]
Since one can always center the data, without loss of generality, we assume that $N$, and thus $X$, are zero-mean. Therefore, we have $X\sim \mathcal{N}(0,\Sigma)$, where $\Sigma$ is the covariance matrix of the multivariate Gaussian distribution on $X$. We assume that $\Sigma$ is always invertible (i.e., the Lebesgue measure of noninvertible matrices is zero). The precision matrix $\Theta=\Sigma^{-1}$ of $X$ reads
\[\Theta = (I-B)\Omega^{-1} (I-B)^{\mathsf{T}}.\]
The log-density function of $X$ is then
\begin{flalign*}
\log p(x;B, \Omega) &= - \frac{1}{2} \log\det\Sigma - \frac{1}{2}x^\mathsf{T} \Theta x -\frac{d}{2} \log 2\pi \\
&= -\frac{1}{2} \log\det\Omega + \log|\det(I - B)| - \frac{1}{2}x^\mathsf{T} (I-B)\Omega^{-1} (I-B^\mathsf{T})x + \textrm{const} \\
&=-\frac{1}{2}\sum_{i=1}^d\log \sigma_i^2 + \log|\det(I - B)| - \frac{1}{2}\sum_{i=1}^{d}\frac{\big(x_i - B_i^\mathsf{T} x\big)^2}{\sigma_i^2} + \textrm{const},
\end{flalign*}
where $B_i\in \mathbb{R}^{d}$ denotes the $i$-th column vector of $B$.
Given i.i.d. samples $\mathbf{x}=\left \{ x^{(k)} \right \}_{k=1}^{n}$ generated from the ground truth distribution, the average log-likelihood of $X$ is given by
\begin{flalign*}
L(B, \Omega; \mathbf{x})
=-\frac{1}{2}\sum_{i=1}^d\log \sigma_i^2 + \log|\det(I - B)| - \frac{1}{2n}\sum_{i=1}^{d}\sum_{k=1}^{n}\frac{\big(x_i^{(k)} - B_i^\mathsf{T} x^{(k)}\big)^2}{\sigma_i^2}+ \textrm{const}.
\end{flalign*}
To profile out the parameter $\Omega$, solving $\frac{\partial L}{\partial \sigma_i^2}=0$ yields the estimate
\[\hat{\sigma}_i^2(B) = \frac{1}{n}\sum_{k=1}^{n}\big(x_i^{(k)} - B_i^\mathsf{T} x^{(k)}\big)^2\]
and profile likelihood
\[L\big(B, \hat{\Omega}(B); \mathbf{x}\big) = -\frac{1}{2}\sum_{i=1}^d\log \left ( \sum_{k=1}^{n}\big(x_i^{(k)} - B_i^\mathsf{T} x^{(k)}\big)^2 \right ) + \log|\det(I - B)| + \textrm{const}.\]
The goal is therefore to find the weighted adjacency matrix $B$ that maximizes the profile likelihood function $L\big(B, \hat{\Omega}(B); \mathbf{x}\big)$, as also in Appendix \ref{sec:likelihood_ev_derivation}.
\subsection{Linear Gaussian Model Assuming Equal Noise Variances}\label{sec:likelihood_ev_derivation}
If one further assumes that the noise variances are equal, i.e., $\sigma_1^2=\dots= \sigma_d^2=\sigma^2$, following similar notations and derivation in Appendix \ref{sec:likelihood_nv_derivation}, the log-density function of $X$ becomes
\[\log p(x;B, \Omega) = -\frac{d}{2}\log \sigma^2 + \log|\det(I - B)| - \frac{1}{2\sigma^2}\sum_{i=1}^{d}\big(x_i - B_i^\mathsf{T} x\big)^2 + \textrm{const},\]
with average log-likelihood
\[L(B, \Omega; \mathbf{x}) = -\frac{d}{2}\log \sigma^2 + \log|\det(I - B)| - \frac{1}{2n\sigma^2}\sum_{i=1}^{d}\sum_{k=1}^{n}\big(x_i^{(k)} - B_i^\mathsf{T} x^{(k)}\big)^2 + \textrm{const}.\]
To profile out the parameter $\Omega$, solving $\frac{\partial L}{\partial \sigma^2}=0$ yields the estimate
\[\hat{\sigma}^2(B) = \frac{1}{n}\sum_{i=1}^{d}\sum_{k=1}^{n}\big(x_i^{(k)} - B_i^\mathsf{T} x^{(k)}\big)^2\]
and profile likelihood
\[L\big(B, \hat{\Omega}(B); \mathbf{x}\big) = -\frac{d}{2}\log\left (\sum_{i=1}^d\sum_{k=1}^{n}\big(x_i^{(k)} - B_i^\mathsf{T} x^{(k)}\big)^2\right ) + \log|\det(I - B)| + \textrm{const}.\]
\section{Proof of Lemma \ref{lemma:logdet}}\label{sec:logdet_proof}
First note that a weighted matrix $B$ represents a DAG if and only if there exists a permutation matrix $P$ such that $PB P^\mathsf{T}$ is strictly lower triangular. Thus, $I - PB P^\mathsf{T}$ is lower triangular with diagonal entries equal one, indicating that $\det(I - PB P^\mathsf{T})=1$.
Since $P$ is orthogonal, we have
\[\det(I-B)= \det\big(P \left( I-B \right)P^\mathsf{T}\big)=\det(I - PB P^\mathsf{T})=1\]
and
\[\log|\det(I - B)| = 0.\]
\section{Proof of Proposition \ref{prop:bivariate_case}}\label{sec:bivariate_proof}
The following setup is required for the proof of both parts (a) and (b).
The true weighted adjacency matrix and noise covariance matrix are, respectively,
\[
B_0 = \begin{bmatrix}
0 & b_0\\
0 & 0
\end{bmatrix},
\Omega = \begin{bmatrix}
\sigma^2 & 0\\
0 & \sigma^2
\end{bmatrix}, b_0 \neq 0.
\]
Note that
\[
I - B_0 = \begin{bmatrix}
1 & -b_0\\
0 & 1
\end{bmatrix},
\left (I - B_0\right )^{-1} = \begin{bmatrix}
1 & b_0\\
0 & 1
\end{bmatrix}.
\]
In the asymptotic case, the covariance matrix of $X$ is
\[
\Sigma = (I-B_0)^{-\mathsf{T}} \Omega (I-B_0)^{-1} =
\sigma^2\begin{bmatrix}
1 & b_0 \\
b_0 & b_0^2+1
\end{bmatrix}.
\]
Let $B$ be an off-diagonal matrix defined as
\[
B(b, c) = \begin{bmatrix}
0& b \\
c & 0
\end{bmatrix}.
\]
\subsubsection*{Proof of part (a).}
Plugging $B(b,c)$ into the least squares objective yields
\begin{flalign*}
\ell(B; \Sigma) &= \frac{1}{2}\Tr\big( (I-B)^{\mathsf{T}} \Sigma (I-B) \big)\\
&= \frac{1}{2}\left( (b - b_0)^2 + (b_0 c - 1)^2 + c^2 + 1 \right)\sigma^2.
\end{flalign*}
The contour plot is visualized in Figure \ref{fig:least_square_contour}. To find stationary points, we solve the following equations:
\begin{alignat*}{2}
&\frac{\partial \ell}{\partial b}= (b-b_0)\sigma^2 = 0 \quad&&\implies b^* = b_0 \\
&\frac{\partial \ell}{\partial c}=b_0(b_0c-1)\sigma^2+c\sigma^2 = 0\quad &&\implies c^* = \frac{b_0}{b_0^2 + 1}.
\end{alignat*}
Since function $\ell(B; \Sigma)$ is convex, the stationary point $B\big(b_0, \frac{b_0}{b_0^2 + 1}\big)$ is also the global minimizer. Thus, without a DAG constraint, the least squares objective $\ell(B; \Sigma)$ returns a cyclic graph $B\big(b_0, \frac{b_0}{b_0^2 + 1}\big)$. If one applies a hard DAG constraint to enforce choosing only one of $b^*$ and $c^*$, we have
\[\ell\big(B(0, c^*); \Sigma\big) = \frac{1}{2}\left(b_0^2 + 1 + \frac{1}{b_0^2 + 1}\right)\sigma^2 > \sigma^2 = \ell\big(B(b^*, 0); \Sigma\big),\]
where the inequality follows from the AM-GM inequality and $b_0 \neq 0$. Therefore, under a hard DAG constraint, $B(b_0, 0)$ is asymptotically the unique global minimizer of least squares objective $\ell(B; \Sigma)$.
\begin{figure}
\centering
\subfloat[Least squares objective.]{
\includegraphics[width=0.36\textwidth]{figures/bivariate/least_square_contour.pdf}
\label{fig:least_square_contour}
}
\hspace{0.7em}
\subfloat[Likelihood-EV objective.]{
\includegraphics[width=0.36\textwidth]{figures/bivariate/likelihood_ev_contour.pdf}
\label{fig:likelihood_ev_contour}
}
\caption{The contour plot of different objectives in the bivariate case (with $b_0=1.5$ and $\sigma^2=1.0$). Lower is better. The black star corresponds to the ground truth DAG $B(b_0, 0)$, while the blue circle and green triangle indicate the (other) stationary point(s).}
\label{fig:bivariate_contour}
\end{figure}
\subsubsection*{Proof of part (b).}
Plugging $B(b,c)$ into the likelihood-EV objective \eqref{eq:likelihood_ev} yields (up to a constant addition)
\begin{flalign*}
\mathcal{L}_2(B; \Sigma) &= \log\Big(\Tr \big( (I-B)^{\mathsf{T}} \Sigma (I-B) \big)\Big)-\log|\det(I - B)| \\
&= \log\left((b - b_0)^2 + (b_0 c - 1)^2 + c^2 + 1\right) + \log\sigma^2 -\log|1-bc|,
\end{flalign*}
with contour plot visualized in Figure \ref{fig:likelihood_ev_contour}. To find stationary points, we solve the following equations:
\begin{flalign*}
&\frac{\partial \mathcal{L}_2}{\partial b}= \frac{2(b-b_0)}{(b - b_0)^2 + (b_0 c - 1)^2 + c^2 + 1} + \frac{c}{1-bc}=0 \\
&\frac{\partial \mathcal{L}_2}{\partial c}=\frac{2b_0(b_0 c-1)+2c}{(b - b_0)^2 + (b_0 c - 1)^2 + c^2 + 1} + \frac{b}{1-bc} = 0.
\end{flalign*}
Further algebraic manipulations yield three stationary points and their respective objective values:
\[
\begin{cases}
\,b^*=b_0 \quad\,\,,\,c^*=0 & \implies \mathcal{L}_2\big(B(b^*, c^*); \Sigma\big)=\log2 + \log\sigma^2 \\[4pt]
\,b^*=\frac{b_0^2+2}{b_0} \ ,\,c^*=\frac{2}{b_0} & \implies \mathcal{L}_2\big(B(b^*, c^*); \Sigma\big)=\log2 + \log\sigma^2 \\[4pt]
\,b^*=-\frac{2}{b_0}\,\,\,, \,c^*=\frac{2}{b_0} & \implies \mathcal{L}_2\big(B(b^*, c^*); \Sigma\big)=\log(b_0^2+2) + \log\sigma^2.
\end{cases}
\]
The second partial derivative test shows that $B(-\frac{2}{b_0}, \frac{2}{b_0})$ is a saddle point, while the other solutions $B(b_0, 0)$ and $B\big(\frac{b_0^2+2}{b_0}, \frac{2}{b_0}\big)$ are local minimizers, as also illustrated in Figure \ref{fig:likelihood_ev_contour}. With DAG penalty, the cyclic solution $B\big(\frac{b_0^2+2}{b_0}, \frac{2}{b_0}\big)$ is penalized; thus, the acyclic solution $B(b_0, 0)$ becomes the unique global minimizer of the objective $\mathcal{L}_2(B; \Sigma)$.
For $\ell_1$ penalty, we have
\[
\left \| B\left(\frac{b_0^2+2}{b_0}, \frac{2}{b_0}\right) \right \|_{1} = \left | \frac{b_0^2+2}{b_0} \right | + \left | \frac{2}{b_0} \right | = \frac{b_0^2+4}{|b_0|} > |b_0| = \left \|B(b_0, 0) \right \|_{1}.
\]
Hence, $\ell_1$ penalty encourages the desired solution $B(b_0, 0)$ and makes it asymptotically the unique global minimizer of the likelihood-EV objective $\mathcal{L}_2(B; \Sigma)$.
\section{Optimization Procedure and Implementation Details}\label{sec:golem_implementation}
We restate the continuous unconstrained optimization problems here:
\[\min_{B\in\mathbb{R}^{d\times d}} \quad \mathcal{S}_i(B; \mathbf{x}) = \mathcal{L}_i(B; \mathbf{x}) + \lambda_1\|B\|_{1} + \lambda_2 h(B),\]
where $\mathcal{L}_i(B; \mathbf{x}), i=1,2$ are the likelihood-based objectives assuming nonequal and equal noise variances, respectively, $\|B\|_{1}$ is the $\ell_1$ penalty term defined element-wise, and $h(B)=\Tr \big(e^{B \circ B}\big)-d$ is the DAG penalty term. We always set the diagonal entries of $B$ to zero to avoid self-loops.
The optimization problems are solved using the first-order method Adam \citep{Kingma2014adam} implemented in \texttt{Tensorflow} \citep{Abadi2016tensorflow} with GPU acceleration and automatic differentiation. In particular, we initialize the entries in $B$ to zero and optimize for $1\times 10^5$ iterations with learning rate $1\times 10^{-3}$. The number of iterations could be decreased by deploying a larger learning rate or proper early stopping criterion, which is left for future investigation. Note that all samples $\left \{ x^{(k)} \right \}_{k=1}^{n}$ are used to estimate the gradient. If they cannot be loaded at once into the memory, we may use stochastic optimization method by sampling minibatches for gradient estimation. Our code has been made available at \url{https://github.com/ignavier/golem}.
Unless otherwise stated, we apply a thresholding step at $\omega = 0.3$ after the optimization ends, as in \citep{Zheng2018notears}. If the thresholded graph contains cycles, we remove edges iteratively starting from the lowest absolute weights, until a DAG is obtained (cf. Section \ref{sec:post_processing}).
In practice, one should use cross-validation to select the penalty coefficients. Here our focus is not to attain the best possible accuracy with the optimal hyperparameters, but rather to empirically validate the proposed method. Therefore, we simply pick small values for them which are found to work well: $\lambda_1=2\times 10^{-3}$ and $\lambda_2=5.0$ for GOLEM-NV; $\lambda_1=2\times 10^{-2}$ and $\lambda_2=5.0$ for GOLEM-EV.
\section{Supplementary Experiment Details}
\subsection{Implementations of Baselines}\label{sec:baseline_implementation}
The implementation details of the baselines are listed below:
\begin{itemize}[leftmargin=2.6em]
\item FGS: it is implemented through the \texttt{py-causal} package \citep{Scheines1998tetrad}. We use \texttt{cg-bic-score} as it gives better performance than the \texttt{sem-bic-score}.
\item PC: we adopt the Conservative PC algorithm \citep{Ramsey2006adjacency}, implemented through the \texttt{py-causal} package \citep{Scheines1998tetrad} with Fisher Z test.
\item DirectLiNGAM: its Python implementation is available at the GitHub repository \url{https://github.com/cdt15/lingam}.
\item NOTEARS: we use the original DAG constraint with trace exponential function to be consistent with the implementation of GOLEM. We experiment with two variants with or without the $\ell_1$ penalty term, denoted as NOTEARS-L1 and NOTEARS, respectively. Regarding the choice of $\ell_1$ penalty coefficient, we find that the default choice $\lambda=0.1$ in the author's code yields better performance than that of $\lambda=0.5$ used in the paper. We therefore treat NOTEARS-L1 favorably by picking $\lambda$ to be $0.1$. Note that cycles may still exist after thresholding at $\omega=0.3$; thus, a similar post-processing step described in Section \ref{sec:post_processing} is taken to obtain DAGs. The code is available at the first author's GitHub repository \url{https://github.com/xunzheng/notears}.
\end{itemize}
In the experiments, we use default hyperparameters for these baselines unless otherwise stated.
\subsection{Experiment Setup}\label{sec:experiment_setup}
Our experiment setup is similar to \citep{Zheng2018notears}. We consider two different graph types:
\begin{itemize}[leftmargin=2.6em]
\item \emph{Erd\"{o}s--R\'{e}nyi} (ER) graphs \citep{Erdos1959random} are generated by adding edges independently with probability $\frac{2e}{d^2-d}$, where $e$ is the expected number of edges in the resulting graph. We simulate DAGs with $e$ equals $d$, $2d$, or $4d$, denoted by ER1, ER2, or ER4, respectively. We use an existing implementation through the \texttt{NetworkX} package \citep{Hagberg2008networkx}.
\item \emph{Scale Free} (SF) graphs are simulated using the Barab\'{a}si-Albert model \citep{Barabasi1999emergence}, which is based on the preferential attachment process, with nodes being added sequentially. In particular, $k$ edges are added each time between the new node and existing nodes, where $k$ is equal to $1$, $2$, or $4$, denoted by SF1, SF2, or SF4, respectively. The random DAGs are generated using the \texttt{python-igraph} package \citep{Csardi2006igraph}.
\end{itemize}
Based on the DAG sampled from one of these graph models, we assign edge weights sampled uniformly from $[-2, -0.5] \cup [0.5, 2]$ to construct the corresponding weighted adjacency matrix. The observational data $\mathbf{x}$ is then generated according to the linear DAG model (cf. Section \ref{sec:sem}) with different graph sizes and additive noise types:
\begin{itemize}[leftmargin=2.6em]
\item \emph{Gaussian-EV} (equal variances): $N_i \sim \mathcal{N}(0,1), i=1,\dots, d$.
\item \emph{Exponential}: $N_i \sim \operatorname{Exp}(1), i=1,\dots, d$.
\item \emph{Gumbel}: $N_i \sim \operatorname{Gumbel}(0, 1), i=1,\dots, d$.
\item \emph{Gaussian-NV} (nonequal variances): $N_i \sim \mathcal{N}(0,\sigma_i^2), i=1,\dots, d$, where $\sigma_i\sim\operatorname{Unif}[1, 2]$.
\end{itemize}
The first three noise models are known to be identifiable in the linear case \citep{Peters2013identifiability, Shimizu2006lingam}. Unless otherwise stated, we simulate $n=1000$ samples for each of these settings.
\subsection{Metrics}\label{sec:metric}
We evaluate the estimated graphs using four different metrics:
\begin{itemize}[leftmargin=2.6em]
\item \emph{Structural Hamming Distance} (SHD) indicates the number of edge additions, deletions, and reversals in order to transform the estimated graph into the ground truth DAG.
\item \emph{SHD-C} is similar to SHD. The difference is that both the estimated graph and ground truth are first mapped to their corresponding CPDAG before calculating the SHD. This metric evaluates the performance on recovering the Markov equivalence class. We use an implementation through the \texttt{CausalDiscoveryToolbox} package \citep{Kalainathan2020causal}.
\item \emph{Structural Intervention Distance} (SID) was introduced by \citet{Peters2013structural} in the context of causal inference. It counts the number of interventional distribution that will be falsely inferred if the estimated DAG is used to form the parent adjustment set.
\item \emph{True Positive Rate} (TPR) measures the proportion of actual positive edges that are correctly identified as such.
\end{itemize}
In our experiments, we normalize the first three metrics by dividing the number of nodes. All experiment results are averaged over $12$ random simulations.
Since FGS and PC return a CPDAG instead of a DAG, the output may contain undirected edges. Therefore, when computing SHD and TPR, we treat them favorably by considering undirected edges as true positives if the true graph has a directed edge in place of the undirected one. Furthermore, SID operates on the notion of DAG; \citet{Peters2013structural} thus proposed to report the lower and upper bounds of the SID score for CPDAG, e.g., output by FGS and PC. Here we do not report the bounds for these two methods as the computation may be too slow on large graphs.
\newpage
\section{Supplementary Experiment Results}
\subsection{Role of Sparsity and DAG Constraints}\label{sec:additional_asymtotic_experiments}
This section provides additional results on the role of $\ell_1$ and DAG constraints for Section \ref{sec:asymtotic_experiments}, as shown in Figures \ref{fig:asymptotic_experiments_identifiable} and \ref{fig:asymptotic_experiments_non_identifiable}.
\begin{figure}[!h]
\centering
\subfloat[ER1 graphs with $100$ nodes.]{
\includegraphics[width=0.82\textwidth]{figures/asymptotic/gaussian_ev/results_er1.pdf}
} \\
\subfloat[ER4 graphs with $100$ nodes.]{
\includegraphics[width=0.82\textwidth]{figures/asymptotic/gaussian_ev/results_er4.pdf}
}
\caption{Results of different sample sizes in the identifiable cases (i.e., \emph{Gaussian-EV}). Different variants are compared: GOLEM-EV (with $\ell_1$ and DAG penalty), GOLEM-EV-L1 (with only $\ell_1$ penalty), and GOLEM-EV-Plain (without any penalty term). Lower is better, except for TPR. All axes are visualized in log scale, except for TPR.}
\label{fig:asymptotic_experiments_identifiable}
\end{figure}
\begin{figure}[!h]
\centering
\subfloat[ER1 graphs with $100$ nodes.]{
\includegraphics[width=0.82\textwidth]{figures/asymptotic/gaussian_nv/results_er1.pdf}
} \\
\subfloat[ER4 graphs with $100$ nodes.]{
\includegraphics[width=0.82\textwidth]{figures/asymptotic/gaussian_nv/results_er4.pdf}
}
\caption{Results of different sample sizes in the nonidentifiable cases (i.e., \emph{Gaussian-NV}). Different variants are compared: GOLEM-NV (with $\ell_1$ and DAG penalty), GOLEM-NV-L1 (with only $\ell_1$ penalty), and GOLEM-NV-Plain (without any penalty term). Lower is better, except for TPR. All axes are visualized in log scale, except for TPR.}
\label{fig:asymptotic_experiments_non_identifiable}
\end{figure}
\newpage
\subsection{Numerical Results: Identifiable Cases}\label{sec:additional_results_identifiable}
This section provides additional results in the identifiable cases (Section \ref{sec:results_identifiable}), as shown in Figure \ref{fig:additional_results_identifiable}. For DirectLiNGAM, we report only its performance on the linear DAG model with \emph{Exponential} and \emph{Gumbel} noise, since its accuracy is much lower than the other methods on \emph{Gaussian-EV} noise.
\begin{figure}[!h]
\centering
\subfloat[Normalized SHD.]{
\includegraphics[width=0.475\textwidth]{figures/results_identifiable/all/results_shd.pdf}
}
\hspace{0.5em}
\subfloat[Normalized SHD-C.]{
\includegraphics[width=0.475\textwidth]{figures/results_identifiable/all/results_shd_cpdag.pdf}
} \\
\vspace{0.5em}
\subfloat[Normalized SID.]{
\includegraphics[width=0.475\textwidth]{figures/results_identifiable/all/results_sid.pdf}
}
\hspace{0.5em}
\subfloat[TPR.]{
\includegraphics[width=0.475\textwidth]{figures/results_identifiable/all/results_tpr.pdf}
}
\caption{Results in the identifiable cases with sample size $n=1000$. Lower is better, except for TPR (lower right). Rows: ER$k$ or SF$k$ denotes ER or SF graphs with $kd$ edges on average, respectively. Columns: noise types.}
\label{fig:additional_results_identifiable}
\end{figure}
\newpage
\subsection{Numerical Results: Nonidentifiable Cases}\label{sec:additional_results_non_identifiable}
This section provides additional results in the nonidentifiable cases (for Section \ref{sec:results_non_identifiable}), as shown in Figure \ref{fig:results_non_identifiable}.
\begin{figure}[!h]
\centering
\subfloat[ER1 graphs.]{
\includegraphics[width=1.0\textwidth]{figures/results_non_identifiable/results_er1.pdf}
}\\
\subfloat[ER2 graphs.]{
\includegraphics[width=1.0\textwidth]{figures/results_non_identifiable/results_er2.pdf}
}\\
\subfloat[ER4 graphs.]{
\includegraphics[width=1.0\textwidth]{figures/results_non_identifiable/results_er4.pdf}
}
\caption{Results in the nonidentifiable cases (i.e., \emph{Gaussian-NV}) with sample size $n=1000$. Lower is better, except for TPR. Experiments are conducted on graphs with different edge density, namely, ER1, ER2, and ER4 graphs.}
\label{fig:results_non_identifiable}
\end{figure}
\newpage
\subsection{Scalability and Optimization Time}\label{sec:additional_scalability}
This section provides additional results for investigating the scalability of different methods (Section \ref{sec:scalability}). The structure learning results and optimization time are reported in Figure \ref{fig:scalability}.
\begin{figure}[!h]
\centering
\includegraphics[width=0.82\textwidth]{figures/scalability/results.pdf}
\caption{Results of large ER2 graphs in the identifiable cases (i.e., \emph{Gaussian-EV}). The sample size is $n=5000$. Lower is better, except for TPR. Due to the long optimization time, we are only able to scale NOTEARS-L1 up to $1600$ nodes. The $x$-axes and optimization time are visualized in log scale.}
\label{fig:scalability}
\end{figure}
\subsection{Sensitivity Analysis of Weight Scale}\label{sec:additional_weight_scale}
This section provides additional results on the sensitivity analysis to weight scaling for Section \ref{sec:weight_scale}, as shown in Figure \ref{fig:weight_scale}.
\begin{figure}[!h]
\centering
\includegraphics[width=1.0\textwidth]{figures/weight_scale/results.pdf}
\caption{Results of different weight scales in the identifiable cases (i.e., \emph{Gaussian-EV}). The sample size is $n=1000$. Lower is better, except for TPR.}
\label{fig:weight_scale}
\end{figure} | {'timestamp': '2021-01-12T02:01:49', 'yymm': '2006', 'arxiv_id': '2006.10201', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10201'} | arxiv |
\subsection{Model definition}
\label{subsec:model}
We define and test clustering property following~\cite{908985}.
Let us described the model of experiment.
We assume that data space~$\mathcal{U}$ has dimension~$d$ and finite granularity,
say, a coordinate is an integer $n$-bit number.
So, $U = \{0,1,\ldots,2^n-1\}^d$.
Each point of the space corresponds to a grid cell.
A space-filling curve (below SFC for shortness) introduces a bijection~$\omega\colon U \to \{0,1,\ldots,2^{nd}-1\}$.
A \textit{query} is any subset $q\subseteq \mathcal{U}$.
Consider rectangular queries being intersections of coordinate half-spaces.
More generally (see~\cite{908985}), one can consider queries corresponding to connected simply connected domains.
\begin{remark}
Here we understand~$\mathcal{U}$ as a subset of the lattice~$\mathcal{Z} = \mathbb{Z}^d$.
We need some other identification of queries with geometrical objects
to define connected and simply connected sets correctly.
Namely, we consider the Euclidean space~$E = \mathcal{U}\otimes_\mathbb{Z}\mathbb{R}$.
Consider a closed unit cube~$C$ in~$E$.
It is a fundamental domain of the action~$\mathcal{Z} \lefttorightarrow E$.
Given a query~$q$, denote by~$C_q$ the set
\[
C_q := \bigcup_{p\in q}(p + C) \subset E
\]
that consists of shifts of the cube~$C$ by all points of the query.
We say that a query~$q$ is connected (or simply connected) if so is the interior of~$C_q$.
For instance, a two point query $q=\{x,y\}$ is connected if and only if $C_q^\circ$ is connected, i.\,e.~$x$~and~$y$
differ by~$1$ in one coordinate and coincide in all the others.
\end{remark}
\begin{definition}
A subset~$p\subseteq q$ of a query is called a \textit{cluster} with respect to a SFC~$\omega$
if it is a maximal subset such that the points (or cells) of~$p$ are numbered consequently by~$\omega$.
We denote the number of clusters in~$q$ by~$c_q(\omega)$.
\end{definition}
\begin{definition}
A \textit{clustering property} of a SFC~$\omega$ with respect to a (maybe parametric) class of queries~$\mathcal{Q}$
as the average number~$c_{\mathcal{Q}}(\omega)$ of clusters
in~$q\in \mathcal{Q}$ (or the limits/asymptotics of cluster number
as a function in the parameters if exist).
\end{definition}
Of course, there are also implicit parameters being the space granularity parameter~$n$
and the distribution over~$\mathcal{Q}$.
Usually, for fixed parameters the set~$\mathcal{Q}$ is finite, and the distribution is assumed to be uniform.
If we specify a probabilistic measure~$\mu$ on~$\mathcal{Q}$, then
\[
c_\mathcal{Q}(\omega) := \int_\mathcal{Q}c_q(\omega)d\mu.
\]
We consider the class of cubic queries~$\mathcal{Q}_\ell$ where~$\ell$ is the side length of cubes.
In~\cite{908985} there were considered parametric classes of queries of same shape parametrized by their scales.
Also, limit asymptotics of average cluster number of a shape (cubes, spheres and some others)
as a function in the scale were considered.
\subsection{Simulation results}
\label{subsec:simulation}
Our main goal is to minimize number of disk accesses.
This number depends on capacity of disk pages, model of memory access,
some particular algorithms of access, insertion and deletion.
We omit the technical details and compute average number of clusters,
or \textit{continuous runs} over a subspace representing a query region.
In~\cite{908985} the analytical results for different curves were tested on different query shapes
and an increasing range of sizes.
Note that the number of different query shapes is exponential in the dimensionality.
Consequently, for a large grid space and high dimensionality, each simulation run may require
an excessively large number of queries.
So we restrict simulations for~$d=2,3,4$.
For a given query shape and size, we do not test all the query positions but perform
a statistical simulation by random sampling of queries.
For query shapes, we choose squares and cubes.
In~\cite{908985} the asymptotic and simulation results we shown to be very close and were considered
as identical from round-off errors.
Also, results coincided for different shapes in simulations and analytic calculation with asymptotics.
So, we consider only quadratic and cubic queries due to reliability of the estimation method.
The results of the experiment are listed in Table~\ref{tab:results}.
For $d=2$ we compare average number of clusters for $10000$ random queries on $1024 \times 1024$ grid
(in~\cite{908985} for~$d=2$ the grid is the same and there were~$200$ queries
for a given combination of shape and size).
\begin{table}
\begin{tabular}{|c|rrr|}
\hline
\multicolumn{4}{|c|}{$d=2$} \\ \hline
$\ell$ & Z & Hilbert & H \\
\hline
2 & 2.62 & 2.00 & 1.99 \\
3 & 4.51 & 3.00 & 3.01 \\
4 & 6.36 & 4.01 & 3.99 \\
5 & 8.25 & 4.99 & 5.00 \\
6 & 10.23 & 6.00 & 6.00 \\
7 & 12.26 & 7.00 & 7.00 \\
8 & 14.23 & 8.03 & 8.00 \\
9 & 16.14 & 9.01 & 9.02 \\
10 & 18.00 & 9.94 & 9.97 \\
11 & 20.04 & 10.98 & 10.98 \\
12 & 22.24 & 12.07 & 12.00 \\
13 & 24.06 & 12.99 & 12.99 \\
14 & 26.04 & 14.00 & 14.00 \\
15 & 28.17 & 15.04 & 15.02 \\
\hline
\end{tabular}
\begin{tabular}{|c|rrr|}
\hline
\multicolumn{4}{|c|}{$d=3$} \\ \hline
$\ell$ & Z & Hilbert & H \\
\hline
2 & 5.34 & 4.02 & 4.00 \\
3 & 13.51 & 9.04 & 9.01 \\
4 & 25.58 & 16.08 & 16.04 \\
5 & 41.63 & 25.07 & 24.99 \\
6 & 61.62 & 36.10 & 36.03 \\
7 & 85.74 & 49.08 & 49.00 \\
8 & 113.96 & 64.38 & 64.13 \\
9 & 145.76 & 80.90 & 81.00 \\
10 & 181.04 & 99.85 & 99.75 \\
11 & 221.63 & 120.50 & 120.85 \\
12 & 267.50 & 144.72 & 144.77 \\
13 & 314.00 & 169.28 & 169.21 \\
14 & 363.72 & 195.11 & 194.73 \\
15 & 421.75 & 225.17 & 224.99 \\
\hline
\end{tabular}
\begin{tabular}{|c|rrr|}
\hline
\multicolumn{4}{|c|}{$d=4$} \\ \hline
$\ell$ & Z & Hilbert & H \\
\hline
2 & 10.74 & 7.95 & 8.05 \\
3 & 40.49 & 26.96 & 26.98 \\
4 & 102.33 & 64.39 & 64.14 \\
5 & 208.39 & 125.23 & 125.01 \\
6 & 372.55 & 216.60 & 217.18 \\
7 & 600.43 & 343.52 & 343.02 \\
8 & 911.06 & 513.73 & 512.52 \\
9 & 1312.09 & 730.78 & 729.02 \\
10 & 1810.43 & 991.12 & 995.21 \\
11 & 2440.48 & 1331.96 & 1331.06 \\
12 & 3185.88 & 1734.03 & 1728.66 \\
13 & 4080.00 & 2203.18 & 2197.00 \\
14 & 5091.67 & 2732.45 & 2726.83 \\
15 & 6329.08 & 3378.49 & 3375.01 \\ \hline
\end{tabular}
\caption{Average number of clusters in cubic queries with the cube side~$\ell$
for $d=2,3,4$.}
\label{tab:results}
\end{table}
\FloatBarrier
\subsection{Construction}
\label{subsec:construction}
This section is devoted to the construction of cyclic fractal space-filling curve
for any $d>1$ without using symmetries.
For any dimension $d$, we will traverse half-sized cells in the initial cube in the same way.
Taking a $d$-bit number k as an index in traversal (counting from $0$),
we obtain the corresponding cell coordinate bits as consecutive bits of the number
\[
g_d(k) := k\oplus \lfloor (k \mod 2^d)/2 \rfloor \mod 2^d
\]
(the symbol~$\oplus$ means bitwise sum, or, xor).
This function permutes the set~$\{0,\ldots,2^d-1\}$.
Therefore, the function~$g_d^{-1}$ is well-defined on the set~$\{0,\ldots,2^d-1\}$.
As we claimed, in the cells we do not apply any reflections or rotations to the cells and sub-cells.
For the curve construction we need only the local mutations.
For explicit computation of correspondence between indexes and cells we need to calculate
the index shifts and find all direction reversals.
\subsection{Local mutation}
\label{subsec:loc-mutation}
For convenience let us assume that grid cells are unit cubes, and the initial big cube has side length~$2^n$.
Actually, for any dimension~$d>1$ we will apply the same local mutation.
This mutation will always act on the central~$4 \times 2 \times \ldots \times 2$-parallelepiped.
\begin{lemma}
Given~$d>1$, for any~$n\geqslant 2$ the restriction of the graph composed of $2^d$
half-size cycles in the cube with side length~$2^n$ onto the central~$4\times 2 \times \ldots \times 2$-parallelepiped
form the same graph, namely, if we denote its vertices
with $\{0,1,2,3\}\times\{0,1\}^{d-1}$, then the edge set would be
\[
(\{0\}\times p, \{1\}\times p)\text{ and } (\{2\}\times p, \{3\}\times p)\text{ for all } p\in\{0,1\}^{d-1}.
\]
\end{lemma}
\begin{proof}
Assume that we have the grid of integral points in the cube~$[0,2^{n+1}-1]^d$,
and we initially have the cyclic traversals of cubes of side~$2$.
They form a grid of~$2^n$ cells.
Then we consequently apply mutations gathering cycles into cycles
traversing cells of sizes~$4, 8, \ldots, 2^{n+1}$.
Each time we consider the central $4\times 2\times \ldots \times 2$-parallelepiped
in some cell of size~$4,8,\ldots,2^{n+1}$, then
each of these parallelepipeds has even minimal first coordinate and odd minimal other coordinates.
This implies that the restrictions of initial $2^{nd}$ cycles on them
are same and coincide with the written above graph.
At the same time, these parallelepipeds have pairwise non-intersecting sets of vertices.
Therefore, mutations of previous steps of construction do not affect the final step.
\end{proof}
On Fig.~\ref{fig:figure-d2n3step1},~\ref{fig:figure-d2n3step2},~\ref{fig:figure-d2n3step3}
we see examples of mutations.
On these figures we color some black edges red.
Then we draw a number of green edges such that together the green and red edges form cycles.
After the mutation we remove red edges and color green edges black.
Note that if in the red-green cycle we contract all the red edges, then we obtain
exactly the graph corresponding to the traversal of the cube of size~$2$ and
the same dimension.
Obviously, we will see the same behavior in any dimension.
\begin{example}
\FloatBarrier
Consider the case of~$d=2$ and~$n=3$ (side length~$8$).
\begin{figure}[ht]
\centering
\includegraphics{pict-2.eps}
\qquad
\includegraphics{pict-3.eps}
\caption{Join of cycles in squares of side~$2$ into cycles in squares of side~$4$.}
\label{fig:figure-d2n3step1}
\end{figure}
\begin{figure}[ht]
\centering
\includegraphics{pict-4.eps}
\qquad
\includegraphics{pict-5.eps}
\caption{Join of cycles in squares of side~$4$ into cycles in squares of side~$8$.}
\label{fig:figure-d2n3step2}
\end{figure}
\begin{figure}[ht]
\centering
\includegraphics{pict-6.eps}
\caption{H-curve for $d=2$, $n=3$.}
\label{fig:figure-d2n3step3}
\end{figure}
On fig.\,\ref{fig:figure-d2n3step1} we join cycles of side length~$2$,
after on fig.\,\ref{fig:figure-d2n3step2} we join cycles of side~$4$,
and on fig.\,~\ref{fig:figure-d2n3step3} we see the result.
\FloatBarrier
\end{example}
\begin{definition}
We call the constructed above family of curves \textit{H-curves} for all~$d>1, n$.
Also, we will call \textit{H-curves} the limit curves for all~$d>1$.
\end{definition}
We name them this way for the form of the second iteration of plane curve.
Next iterations also looks like the letter `H', but more tangled and shaggy.
For $d \geqslant 3$ we can consider these curves as high-dimensional ``generalizations'' of letter `H'.
\begin{example}
\FloatBarrier
\begin{figure}
\centering
\includegraphics{pict-0.eps}
\qquad
\includegraphics{pict-7.eps}
\caption{Example of H-curve for $d=3,n=2$ and the central mutation.}
\label{fig:hc3,2}
\end{figure}
On fig.\,\ref{fig:hc3,2} we see the example of H-curve for~$d=3,n=2$ (side length~$4$) and how looks
the mutation in three-dimensional case.
In the higher dimensions it looks the same, but less illustrative.
\FloatBarrier
\end{example}
\begin{theorem}
For any~$n\in\mathbb{N}$ and any~$d>1$ the H-curve cyclically traverses all the unit cells.
Each move to the next cell is a move to an adjacent cell.
For any~$k<n$, for one cycle the curve one time enters and one time
leaves any of cells of grid of~$2^{dk}$-side cells,
and the traversal of these cells is~H-curve for the pair $(d,k)$.
For $n \to \infty$ we can choose infinitely decreasing sequence of cells
such that each one contains all the following,
and we obtain the sequence that converges to the continuous map~$h\colon S^1 \to [0,1]^d$.
\end{theorem}
\begin{proof}
The first part of statement is obvious by the construction of curve and by choice of the mutation.
The second part is obvious for~$k=n-1$ by the iteration of construction and for any~$k$
by induction from~$n-1$ down to~$1$.
For the third part we need to take unit cells in such a way that
\begin{itemize}
\item for increasing~$n$ the matching between smaller cells and intervals is a subdivision of matching between
larger cells and intervals;
\item end points of~$[0,1]$ are mapped to the same point.
\end{itemize}
Actually, it is enough to take the first cell of initial subdivision of each next time to take the first sub-cell,
where the cycle enters the cell.
The condition that $0$ and $1$ are mapped into the same point is obvious.
Continuity is standard and follows from the same reasons as for Hilbert and other curves.
\end{proof}
We will compare below properties of H-curve, Hilbert curve and Z-curve.
\begin{remark}
Actually, for dimension~$2$ there is only one construction method of the Hilbert.
As it was noticed in~\cite{16Curves}, for higher dimensions there are many ways to generalize the construction of
the curve to any dimension such that its restriction to~$d=2$ gives the usual plane Hilbert curve.
In~\cite{16Curves} there are $5$ ways to do this.
The commonly used version seems to be called Butz-Hilbert curve in~\cite{16Curves}.
For higher dimensions is seems that different variations of Hilbert curve would give
very close results.
At the same time, their constructions have the same complexity (computational and mathematical).
So, we will compare H-curve with the commonly used Butz-Hilbert curve.
\end{remark}
\begin{remark}
One of curves constructed in~\cite{16Curves} is called there \textit{inside-out curve}.
For $n=2$, it returns to the cell adjacent to the initial point, but for bigger~$n$ it loses continuity.
In this sense H-curve can be called an \textit{inside-out-repeat curve} as a curve moving from the center to the
perimeter in one octant, back to the center, out into another octant and so on cyclically.
\end{remark}
On fig.\,\ref{fig:d2n4} we see Z-curve, Hilbert curve and H-curve on plane.
On fig.\,\ref{fig:d3n2} we see Z-curve, Butz--Hilbert curve and H-curve in the same axes.
\begin{figure}
\centering
\includegraphics[scale=0.8]{pict-12.eps}
\quad
\includegraphics[scale=0.8]{pict-10.eps}
\quad
\includegraphics[scale=0.8]{pict-11.eps}
\caption{Z-curve, Hilbert curve, H-curve for $d=2,n=4$}
\label{fig:d2n4}
\end{figure}
\begin{figure}
\centering
\includegraphics[scale=0.8]{pict-8.eps}
\includegraphics[scale=0.8]{pict-9.eps}
\includegraphics[scale=0.8]{pict-0.eps}
\caption{Z-curve, Butz--Hilbert curve, H-curve for $d=3,n=2$}
\label{fig:d3n2}
\end{figure}
\subsection{Index shifts and direction reversals}
\label{subsec:shifts-and-reversals}
Our next goal is to describe the correspondence between a unit cell with coordinates~$\overline{a}=(a_0,\ldots,a_d)$
in $d$-dimensional cube with side length~$2^n$ and its index~$r$ in the traversal along H-curve.
Say, we \textit{encode} the point~$\overline{a}$ by the index~$r$ and~\textit{decode} the index~$r$
to the point~$\overline{a}$.
So, we want to describe two mutually inverse functions
\[
\xymatrix{
\{0,\ldots,2^n-1\}^d \ar@/_/[rr]
&&\mathbb{Z}/2^{nd}\mathbb{Z}. \ar@/_/[ll]
}
\]
We will construct the functions recursively.
To make the construction easier, let us introduce some notation.
Let us write bits of $d$-bit numbers~$a_i$ into the matrix~$n\times d$ as rows.
Denote $n$-bit numbers in the rows of transposed matrix by~$\alpha^0,\ldots,\alpha^d$.
These coordinates are also known as coordinates in \textit{Z-order}.
It is easy to pass from $(a_i)$ to $(\alpha^j)$ and back, but~$\alpha^j$ are more convenient for algorithm design.
So, we will describe functions
\[
\xymatrix{
\{0,\ldots,2^d-1\}^n \ar@/_/[rr]_-{\mathtt{encode}}
&&\mathbb{Z}/2^{nd}\mathbb{Z}. \ar@/_/[ll]_-{\mathtt{decode}}
}
\]
Geometrical sense of~$\alpha$-coordinates corresponds to the iterative construction of curve.
Each cell can be coded by~$d$ bits of coordinates.
These~$d$ bits form the number~$\alpha^j$ for $j$-th iteration.
When subdividing the cube into the grid of~$2^d$ cells, we choose one of them
which has coordinates~$(\alpha^0,\ldots,\alpha^{d-1})$.
\begin{lemma}
The central $4\times 2 \times \ldots \times 2$-parallelepiped in $d$-dimensional cube with side~$2^n$ consists of
the set of points
\[
c_\alpha = (\alpha, \overline{\alpha},\ldots, \overline{\alpha}) \text{ and }
c_\alpha' = (\alpha, \overline{\alpha},\ldots, \overline{\alpha}\oplus 1)
\]
for all~$\alpha\in\mathbb{F}_2^n$.
\end{lemma}
\begin{proof}
Denote the central cube of size~$2$ by~$C$ and the central~$4\times 2 \times \ldots \times 2$-parallelepiped by~$P$.
Each half-size cube~$\alpha$ has a unique unit cell in~$C$.
Denote it by~$c_\alpha$.
Each half-size cube~$\alpha$ has two unit cells in~$P$,~$c_\alpha$ is on of them.
Denote the other one by~$c_\alpha'$.
The index~$\alpha$ for both~$c_\alpha$ and~$c_\alpha'$ corresponds to the
first coordinate of f unit cell in~$\alpha$-coordinates.
Our goal is to find remaining~$\alpha$-coordinates of these points.
Bits of~$\alpha$ geometrically mean the choice of half-size cube in the first
subdivision operation.
To get the cell~$c_\alpha \in C$, we should take opposite coordinate choices
for each coordinate on each next iteration.
This exactly implies that all the next $\alpha$-coordinates equal~$\overline{\alpha}$.
To take~$c_\alpha'$, we should take the same sub-cells until the last subdivision.
At the last iteration we should change the first coordinate to get the adjacent
cell along the first coordinate.
This exactly means that~$c_\alpha'$ has all next coorinates equal~$\overline{\alpha}$
until the last one which equals~$\overline{\alpha}\oplus 1$.
\end{proof}
\begin{corollary}
The traversal of H-curve enters the half-size sub-cell~$\alpha$ at one of unit cells~$c_\alpha$ and~$c_\alpha'$ and
leaves at other one.
\end{corollary}
We have fixed the traversal of the central~$4\times 2 \times \ldots \times 2$-parallelepiped.
Therefore, if we know the order of traversal of the pair~$(c_\alpha,c_\alpha')$, then we know if we need to reverse
the traversal of half-size sub-cell~$\alpha$.
(As it was noted above, they are neighbors in the sub-cell traversal).
Now we want to determine when the direction of half-size sub-cube traversal is either the same or opposite
to the direction of traversal of these sub-cubes.
Suppose the direction is the same.
Then before the mutation we pass from one cell of~$\{c_\alpha,c_\alpha'\}$ to another one,
so, traversing the remaining part of the cycle traversing the sub-cube, we pass them in the opposite
order, because the first one becomes the leaving unit cell,
and other one becomes the entering unit cell for sub-cube.
Vice versa, if the direction changes, then the order remains the same.
To avoid confusion, we consider the chain part traversing the sub-cube, but not whole the cube, because in the cycle
the proposition that a cell follows other one is nonsense.
\begin{lemma}
Consider a $d$-dimensional cube of side length~$2^n$.
In the construction of H-curve the edges $(0,\ldots,0)-(1,0,\ldots,0)$ and~$(2^n-1,\ldots,2^n-1)-(2^n-2,2^d-1,\ldots,2^d-1)$
(denote them correspondingly $\overline{0}-\overline{0}'$ and $\overline{1}-\overline{1}'$)
are passed in the same direction (along the first coordinate) for~$d$ odd and in the opposite direction for~$d$ even.
\end{lemma}
\begin{proof}
The proof consists of two steps: to pass to~$n=1$ and to directly calculate for~$n=1$.
At first, we pass to~$n=1$.
Indeed, we obtain the traversal of the cube of size~$2^n$ by joining together traversals of~$2^{n-1}$ cubes
with a central mutation.
Note that the mutations does not affect the edge from/to corner vertices.
So, for~$n>1$ the proposition is the same as for~$n=1$, and we can put~$n=1$ without loss of generality.
Fix some~$d>1$.
In Z-order the representations of the vertices are the following (we write the square brackets and index~$2$ to distinguish decimal and binary numbers):
\begin{align*}
\overline{0} = [\underbrace{0\ldots0}_d]_2, \quad & \overline{0}' = [\underbrace{0\ldots0}_{d-1}1]_2, \\
\overline{1} = [\underbrace{1\ldots1}_d]_2, \quad & \overline{1}' = [\underbrace{1\ldots1}_{d-1}0]_2. \\
\end{align*}
Note that~$g(0)=[\underbrace{0\ldots0}_{d}]_2$ and~$g(1)=[\underbrace{0\ldots0}_{d-1}1]_2$.
It only remains to find~$g^{-1}(\overline{1})$ and~$g^{-1}(\overline{1}')$.
One of the following two cases holds:
\begin{itemize}
\item Let $d$ be even.
Then
\[
g^{-1}([\underbrace{1\ldots1}_{d}]_2) = 2\cdot\frac{2^d-1}{3}, \quad
g^{-1}([\underbrace{1\ldots1}_{d-1}0]_2) = 2\cdot\frac{2^d-1}{3} + 1.
\]
We see that~$\overline{1}'$ follows $\overline{1}$.
\item Let $d$ be odd.
Then
\[
g^{-1}([\underbrace{1\ldots1}_{d}]_2) = \frac{2^{d+1}-1}{3}, \quad
g^{-1}([\underbrace{1\ldots1}_{d-1}0]_2) = \frac{2^{d+1}-1}{3} - 1.
\]
We see that~$\overline{1}$ follows $\overline{1}'$.
\end{itemize}
The calculations can be easily checked directly.
This concludes the proof.
\end{proof}
\begin{corollary}
For $d$ even there are no traverse reversals.
For $d$ odd the only traverse reversal happens for~$n=2$.
\end{corollary}
\begin{proof}
As we have seen above, the direction of a bigger cubes traversal
from~$\overline{0}$ to~$\overline{0}'$
is the same as for unit cells in cubes with side length~$2$ if in the cube of side length~$2$ the traversal
of the edge $\overline{1}-\overline{1}'$ is opposite to the traversal direction
of the edge $\overline{0}-\overline{0}'$.
So, the direction for~$(n,d)$ for~$n>1$ is the same as for~$(1,d)$ for even~$d$ and opposite for odd~$d$.
Therefore, there are no any reversals for~$d$ even and the only reversal for~$d$ odd is when~$n=2$.
(For~$d$ odd and~$n>1$ the directions are opposite to the direction for~$n=1$, thus, they coincide.)
\end{proof}
\begin{theorem}
For any $d>1$ and~$n\geqslant 1$ H-curve starts the traversal of sub-cell~$\alpha$
at its unit sub-cell~$(\overline{\alpha}, \ldots, \overline{\alpha}, \overline{\alpha}\oplus p(\overline{\alpha}))$,
and the direction of traversal changes if and only if~$d$ is odd and~$n=2$.
\end{theorem}
\begin{proof}
Actually, it only remains to find which one of~$c_\alpha$ and~$c_\alpha'$ is the initial point.
Note that the function~$g$ is $\mathbb{F}_2$-linear as a function~$g\colon \mathbb{F}_2^d \to \mathbb{F}_2^d$.
Geometrically the operation~$\oplus\alpha$ corresponds to the composition of reflections along coordinate
hyperplanes corresponding to bits equal~$1$ in~$\alpha$.
Therefore, we can find only the initial point of the sub-cube corresponding to~$\alpha=[0\ldots0]_2$.
In the traversal of this sub-cube (before the mutation) $c_\alpha$ and~$c_\alpha'$ follows each other.
So, after the mutation the second one becomes the entering unit cell of a sub-cube, and first one becomes the leaving unit cell.
From the reasoning above it follows that for~$d$ even the entering point is~$\overline{1}$ and for~$d$ odd
the entering point is~$\overline{1}'$.
Restoring generality of~$\alpha$ and due~$\mathbb{F}_2$-linearity, we can rewrite the initial point of sub-cube~$\alpha$
with the parity function~$p$ as the point~$(\overline{\alpha}, \ldots, \overline{\alpha}, \overline{\alpha}\oplus p(\overline{\alpha}))$ in Z-order.
\end{proof}
\subsection{Algorithmic construction}
\label{subsec:alg}
Here we briefly describe algorithms of two functions:
\begin{itemize}
\item[\texttt{encode}] which maps $d$-dimensional array of cell coordinates in the cube $\{0,\ldots,2^n-1\}^d$ to the index,
\item[\texttt{decode}] performing the inverse function.
\end{itemize}
Here index means the number of cell in the traversal.
It can be considered as an arbitrary integer number or a number in $\{0,\ldots,2^{nd}-1\}$ due to $2^{nd}$-periodicity.
For convenience, we will evaluate coordinates in \textit{Z-order}: instead of $d$ $n$-bit numbers we consider
$n$ $d$-bits numbers composed of corresponding bits of coordinates.
If we write down $d$ $n$-bit numbers as rows of bit matrix, then the corresponding $n$ $d$-bit numbers in Z-order
become rows of the transposed matrix.
Denote the coordinates of the cell with index~$r$ by~$(a_0,\ldots,a_{d-1})$.
Denote the corresponding Z-order numbers by~$(\alpha^0,\ldots,\alpha^{n-1})$.
Denote~$g_n(k) = (k \mod 2^n)\oplus (\lfloor k/2 \rfloor \mod 2^{n-1})$.
Note that~$g_n$ is a bijection on the set~$\{0,\ldots,2^n-1\}$, so~$g_n^{-1}$ is well-defined on this set.
Denote by~$p(x)$ the \textit{parity} of~$x$, i.\,e. $1$ if the number of odd bits in~$x$ is odd and~$0$ otherwise.
\subsubsection{Encode}
Given dimension~$d$, depth~$n$, numbers $\overline{\alpha}=(\alpha^0,\ldots,\alpha^{n-1})$,
we calculate the index~$r = \mathtt{encode}(d, n, \overline{\alpha})$ as follows.
\begin{itemize}
\item Put~$r_0 = g_d^{-1}(\alpha_0)$.
\item Put~$r = \mathtt{encode}(d,n-1,(\alpha^1,\ldots,\alpha^{n-1}))$.
\item Put~$r' = \mathtt{encode}(d, n-1, (e,\ldots,e\oplus p(e)))$, where~$e = (-1-r_0)\mod 2^d$ (bitwise complement).
\item Return~$r_0\cdot 2^{d(n-1)} + (r - r' \mod 2^{d(n-1)})$.
\end{itemize}
\subsubsection{Decode}
Given dimension~$d$, depth~$n$, and index~$r$ we
calculate~$\overline{\alpha}=(\alpha^0,\ldots,\alpha^{n-1})$
with the function~$\mathtt{decode}(d, n, r, i=0)$ ($i$ is the argument with the default value~$0$)
as follows.
\begin{itemize}
\item If~$i \geqslant n$, the function returns~$\overline{\alpha}=(\alpha^0,\ldots,\alpha^{n-1})$.
\item Put $\alpha_i = g(\rho_i)$, where~$\rho_i = \lfloor r / 2^{d(n-1-i)} \rfloor$.
\item Put~$r' = \mathtt{encode}(d, n-1, (e,\ldots,e\oplus p(e)))$, where~$e = (-1-r_0)\mod 2^d$ (bitwise complement).
\item Put $r'' = r - r' \mod 2^{d(n-1)}$.
\item $\mathtt{decode}(d, n-1, r'', i + 1)$.
\end{itemize}
\subsubsection{Tail recursion}
Here we see that each of \texttt{decode} and \texttt{encode} call two of these functions for smaller~$d$.
But one of these calls is a call to get the index of a corner of an~$(n,d)$-cube or an adjacent cell by the first coordinate.
In practice, we should keep more points than the number of corners of~$(n',d)$-cubes for~$n' < n$.
So they can be precomputed and stored (or lazily evaluated on demand), so the first call will require only~$O(1)$ operations asymptotically.
This improvement makes~\texttt{decode} and~\texttt{encode} tail recursive.
Of course, we can choose initial point other way (for example, put into correspondence the zero index
to the point with zero coordinates), but then we should apply the same additional corrections for mutations.
In the chosen way we always remove the edges with the same indexes.
So, actually, there is no significant difference.
With precomputed corner indexes and implementation of tail recursions as loops on~\texttt{C},
the profiling results of \texttt{encode} and~\texttt{decode} functions for pair~$(n,d)=(7,7)$
for a million calls are the following (see~Table~\ref{tab:profiling}).
\FloatBarrier
\begin{table}
\begin{tabular}{|l|r|} \hline
function & average time spent with function descendents, ms/call \\ \hline \hline
\texttt{encode\_h} & $0.08$ \\
\texttt{decode\_h} & $0.06$ \\
\texttt{encode\_Hilbert} & $0.31$ \\
\texttt{decode\_Hilbert} & $0.47$ \\ \hline
\end{tabular}
\caption{Profiling results}
\label{tab:profiling}
\end{table}
\FloatBarrier
So, we can see that H-curve computes significantly faster than the Hilbert curve.
\section*{Introduction}
\label{sec:intro}
\input{introduction}
\section{Constructions of curves}
\label{sec:constructions}
\input{constructions-of-curves}
\section{H-curve}
\label{sec:hcurve}
\input{h-curve}
\section{Clustering property}
\label{sec:clustering_property}
\input{clustering-property}
\section{Conclusion}
\label{sec:conclusion}
In this paper we introduced a new way to construct cyclic space-filling curves.
A particular simple family of curves is created (we call them H-curves).
This family has a very close clustering property to Hilbert curves.
At the same time, their construction is simpler and significantly faster.
So, for a number of applications H-curves may be preferable than Hilbert curves.
| {'timestamp': '2020-06-19T02:09:12', 'yymm': '2006', 'arxiv_id': '2006.10286', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10286'} | arxiv |
\section{Introduction}
\blfootnote{The work was supported by by European Union’s Horizon 2020 project No. 864702 - ATCO2 (Automatic collection and processing of voice data from air-traffic communications), which is a part of Clean Sky Joint Undertaking. The work was also partially supported by SESAR EC project HAAWAII (Highly automated air-traffic controller workstations with artificial intelligence integration). Karel Vesely was also supported by Czech National Science Foundation (GACR) project ``NEUREM3" No. 19-26934X.}
The communication methods between pilots and Air-Traffic Controllers (ATCos) have remained almost unchanged for many decades, where the ATCo's main task is to transfer spoken guidance to pilots during all flight phases (e.g. approach, landing or taxi) and at the same time providing safety, reliability and efficiency. This task has shown to be extremely stressful and highly voice demanding because of the impact a small mistake can make. Several attempts towards increasing the confidence and reducing the workload of pilot-controller communication have been pursued in the past, including experiments with Automatic Speech Recognition (ASR). Initially, due to budget and scarcity of computing power, previous work targeted isolated word recognition, or `voice activity detection' but currently most of the works performs ASR on nearly real time. Military applications were one of the first attempts involving engines for command-related ASR; Beek et al.~\cite{beek1977} contrast the main ASR techniques with its relevance to military applications such as speaker verification, commands recognition and system control of aircraft. They remarked that pilot-ATCo communications have a very limited word set -vocabulary-, speaker-dependent issues and environmental noises that need to be addressed to produce a sufficiently-reliable system. Initially, the integration of ASR technologies in ATCo started in the late 80s' with Hamel et al. report~\cite{hamel1989}; but lately, ASR technologies has been successfully deployed on ATC training simulators. For example, Matrouf et al.~\cite{matrouf1990adapting} proposed a user-friendly and robust system to train ATCos based on hierarchical frames and history of dialogues -context-dependent-. Similarly, DLR~\cite{matrouf1990adapting}, MITRE~\cite{tarakan2008automated} and more recently UPM-AENA~\cite{ferreiros2012speech} under the INVOCA project proposed akin training systems.
One of the current limitations in developing highly-accurate ASR engines for ATCo communications is the lack of available databases; likewise, generate the transcriptions of such data is extremely costly. Typically a raw ATCo-pilot voice communication recording of one hour -including silences- requires between eight to ten man-hours of transcription effort~\cite{cordero2012automated} (mainly as it requires highly trained participants, often active or retired ATCos). Afterwards, usually only 10 to 15 minutes speech segments of ATCo is obtained from 1h recording (after removing silence segments). Hence, it would take approximately one man-week work to get an hour of ATCos without silences~\cite{ferreiros2012speech, cordero2012automated}.
Currently, several researchers~\cite{holone2015possibilities} and the International Civil Aviation Organization (ICAO) determined that the air-traffic is expected to grow about 3 to 6 percent yearly at least until 2025. Consequently, it has been seen a huge investment of the European Union (EU) to address the ATCos workload and development of ASR engines for field pilot-ATCos communication, but not only for training purposes. Three recent projects financed by the EU on the scope of ASR for ATCo communications are MALORCA\footnote{MAchine Learning Of speech Recognition models for Controller Assistance, http://www.malorca-project.de/wp/}, ATCO2\footnote{AuTomatic COllection and processing of voice data from Air-Traffic COmmunications, https://www.atco2.org/} and HAAWAII\footnote{Highly Automated Air traffic controller Workstations with Artificial Intelligence Integration}. MALORCA project (together with AcListant\footnote{Active Listening Assistant, www.AcListant.de}) demonstrated that ASR tools can reduce ATCos workload~\cite{helmke2016reducing} and increase the efficiency~\cite{helmke2017increasing}, where also it addressed the lack of transcribed air traffic speech data using semi-supervised training (similar to other ASR related tasks such as speech recognition applied for under-resourced languages~\cite{Imseng_ICASSP_2014,Khonglah_ICASSP2020_2020}) to decrease Word Error Rates (WER) and command error rates~\cite{kleinert2018semi,srinivasamurthy2017semi}. We set as baseline word error rates the results from~\cite{kleinert2018semi,srinivasamurthy2017semi} for two proposed train/test sets. ATCO2 ongoing project aims at developing a unique platform to collect, organize and pre-process air-traffic speech data from air space available either directly through publicly accessible radio frequency channels (such as LiveATC~\cite{liveatc2020}), or indirectly from ANSPs. One of the current challenges of ASR engines for ATCo communications is the changing ATCos accent and vocabularies across different airports; hence, ATCO2 will develop a robust methodology capable of minimize their impact on the system. In this work, we present the first results based on six ATC in-domain databases which, to the authors' knowledge, is the first time that such quantity of command-related databases (spanning more than 170 hours) have been used during the training phase. First, we explore transfer learning from a Deep Neural Network (DNN) system trained on an Out-Of-Domain (OOD) corpus, then we contrast the results with the state-of-the-art ASR chain recipes (from Kaldi's toolkit~\cite{povey2011kaldi}) such as TDNNF and CNN+TDNNF. Secondly, given the high likelihood of Out-Of-Vocabulary (OOV) words due to the intrinsic changing behaviour of the air-space, we tested Byte-Pair Encoding (BPE) based system, which stands as a technique capable of recognise OOV words.
Even though obtaining a full ATCo-pilot communication system goes far beyond of only ASR tasks, we convey in this study a benchmark of experiments going from transfer learning (from an OOD corpus) and adaptation with partial or complete in-domain command-related databases to BPE algorithms and end-to-end TDNNF models. Additionally, this study does not plan to describe in detail intrinsic characteristics of the ATCos communication such as noise (e.g. cockpit noise), speaker's accent, ontology or transcription procedure; but rather, we show technical details and results about ASR in the ATM area. In Section 2 we define the corpus and data preparation used in the proposed benchmark experiments. Section 3 reviews the experimental setup such as lexicon, language and acoustic modelling. Then, Section 4 presents the main results. Finally, Section 5 concludes the paper and proposes the roadmap that ASR systems for ATCo communications should head.
\section{Data Preparation}
Diverse studies conclude that almost 80\% of all pilot radio messages contain at least one error and 30\% of the incidents are accounted by miss-communications (and up to 50\% in the terminal manoeuvring area)~\cite{geacuar2010reducing}. Therefore, ASR stands as a adequate solution, which cannot afford to be trained and tested `on-the-fly' in real operational environment, but it is required to build the best possible system before its deployment. With this intention, we use the state-of-the-art ASR engines that are based on deep neural networks like Time-Delay Neural Networks (TDNN) and Convolutional Neural Network (CNN). These models are known as `data-hungry' algorithms; in fact, state-of-the-art ASR systems need to be trained on large amount of data to achieve and acceptable operational performance. Sadly, there is a lack of such databases in the ATM world. One of our main contribution is to solve this problem employing partly-in-domain or `command-related' databases, which retain similar phraseology and structure.
\subsection{Command-related databases}
One concern that has delayed the development of a unified ASR framework for ATM globally --or at least at country level-- is the vast accent's variability between ATCos from non-English speaking countries. Often, ATCos working in the same country but at different airports may have different accents (e.g. Switzerland). There is also a large variability in dictionary used across airports, as different call-signs, commands, or parameters (e.g. waypoints) are present. Therefore, an un-adapted ASR system will provide significantly worse performance due to unseen accents, OOV words, different recording procedures, parameters or even ontology's variability across different air navigation service providers (ANSPs). Table~\ref{tab:databases} conveys six databases that posses close similarities to ATCo's speech data, accounting to nearly 180 hours (train and test sets). The phraseology and vocabularies are similar across the databases but the speakers' accent is domain-dependent. We also measured the impact of transfer learning of DNN models trained on out-of-domain databases (i.e. Librispeech and Commonvoice, see Table~\ref{tab:databases}) as part of the proposed benchmark. Another pilot-ATCos communication concern are the errors due to OOV words and phonetic di-similarities (e.g. ``hold in position`` and ``holding position", or, ``climb to two thousand" and ``climb two two thousand"). Hence, the ICAO has created a standard phraseology to reduce these errors during the communications; Helmke et al.~\cite{helmke2018ontology} propose a new ontology to transcribe these ATCo-pilots communications.
\begin{table}[t!]
\caption{Out-of-domain and command-related databases used for transfer-learning (pre-training) and adaptation of TDNNF and CNN+TDNNF models.}
\label{tab:databases}
\centering
\begin{tabular}{ l c p{2.5cm} c }
\toprule
\multicolumn{4}{c}{\textbf{Command-related databases}} \\
\midrule
\multicolumn{1}{c}{\textbf{Database}} & \multicolumn{1}{c}{\textbf{Hours}} &
\multicolumn{1}{c}{\textbf{Accents}} & \multicolumn{1}{c}{\textbf{Ref}} \\
\midrule
MALORCA & 13 & German and Czech & \cite{kleinert2018semi,srinivasamurthy2017semi} \\
LDC ATCC & 72.5 & American English & \cite{LDC_ATCC} \\
HIWIRE & 28.3 & \raggedright French, Greek, Italian and Spanish & \cite{HIWIRE} \\
ATCOSIM & 10.67 & \raggedright German, Swiss German \& French & \cite{ATCOSIM} \\
UWB ATCC & 20.6 & Czech & \cite{PILSEN_ATC} \\
AIRBUS & 45 & French & \cite{AIRBUS} \\
\midrule
\multicolumn{4}{c}{\textbf{Out-of-domain databases}} \\
\midrule
Librispeech & 960 & Diverse English & \cite{panayotov2015librispeech} \\
Commonvoice & 500 & English subset & \cite{ardila2019common} \\
\bottomrule
\end{tabular}
\end{table}
\subsection{Out-of-domain databases}
As part of the proposed benchmark, we measured the impact of transfer learning to address the lack of in-domain databases. The idea is to pre-train models with well-known out-of-domain databases such as Librispeech~\cite{panayotov2015librispeech} (960 hours) and Commonvoice~\cite{ardila2019common} (500 hours English subset) and then adapt the pre-trained models using in-domain data. The final out-of-domain train set contains nearly 1500 hours of speech data (see Table~\ref{tab:databases}).
\begin{table}[t!]
\caption{ATC in-domain training and test sets.}
\label{tab:split_db}
\centering
\begin{tabular}{ p{1.1cm} c p{4cm}}
\toprule
\multicolumn{3}{c}{\textbf{Train data-sets}} \\
\midrule
\multicolumn{1}{c}{\textbf{Name}} & \multicolumn{1}{c}{\textbf{Hours}} &
\multicolumn{1}{c}{\textbf{Description}} \\
\midrule
Train1 & 38.7 & Atcosim (train) + Malorca (Vienna+Prague) + UWB ATCC \\
Train2 & 137.7 & Airbus + ATCC USA + Hiwire \\
Tr1+Tr2 & 176.4 & Train1 + Train2 \\
OOD set & $\sim$1500 & Out-of-domain set: Librispeech + Commonvoice \\
\toprule
\multicolumn{3}{c}{\textbf{Test data-sets}} \\
\midrule
Atcosim & 2.5 & 20\% of Atcosim train set \\
Prague & 2.2 & From Malorca set \\
Vienna & 1.9 & From Malorca set \\
Airbus & 1 & From Airbus set \\
\bottomrule
\end{tabular}
\end{table}
\subsection{Databases split}
In order to measure the impact of amount of data, we merged six command-related databases in three training sets as shown in Table~\ref{tab:split_db}. In case of ATCOSIM, we split the database (by speakers) in a 80/20 ratio (i.e. we used 80\% of data as train/validation and the remaining 20\% as test set). In case of MALORCA database, it comprises two ATC approaches (collected from two ANSPs), Vienna and Prague. The remaining databases were collected, processed and released from different projects; we redirect the reader to their references. In fact, Airbus held in 2018 a challenge~\cite{AIRBUS} related to ASR and callsign detection (CSD) of ATCos speech segments; Pellegrini et al.~\cite{pellegrini2019airbus} convey the results of the top 5 teams. It is important to mention that we don't compare our results with theirs because the evaluation set (5 hours) was not released by Airbus; nevertheless, we created from the train data a test set of 350 utterances (1 hour of speech data). The proposed acoustic models are evaluated on four different test sets, where features such as ATCo accent, spoken commands, airport's origin and quantity of training data vary. There are no specific reasons behind the split methodology and the datasets sizes from Table~\ref{tab:split_db}.
\section{Experimental Setup}
\subsection{Lexicon}
The word-list for lexicon was assembled from the transcripts of all the ATCo audio databases (i.e. Tr1+Tr2, see Table \ref{tab:split_db}) and from some other publicly available resources (i.e. lists with names of airlines, airports, ICAO alphabet, etc.). The pronunciations were synthesized with Phonetisaurus~\cite{phonetisaurus}. The G2P (grapheme-to-phoneme) model was trained on Librispeech lexicon, and we inherited its set of phonemes. Likewise, the `spelled' acronyms were auto-detected, and we create their pronunciations separately.
\subsection{Language Modelling}
We train N-gram language models using SRI-LM~\cite{srilm} on the transcripts of the training set Tr1+Tr2 (see Table~\ref{tab:split_db}). We use a tri-gram for the initial decoding and a four-gram model for re-scoring. In our results (Table~\ref{tab:results}) `LM-3' stands for the tri-gram and `LM-4' for the four-gram model. We additionally trained a six-gram LM identified as `LM-6', only for the BPE setup.
\subsection{Experimental Setup}
All experiments are conducted using the Kaldi speech recognition toolkit~\cite{povey2011kaldi}. We report results on two state--of-the-art DNN-based acoustic architectures. We train Factorized TDNN or TDNNF~\cite{povey2018semi} with $\sim$1500 hours of OOD speech (see Table~\ref{tab:databases}) and then we adapt the resulting model with three ATC command-related data-sets (see Subsection~\ref{subs:conv}). Afterwards, we perform flat-start CNN+TDNNF training without any kind of transfer learning or adaptation; the idea behind this is to measure quantitatively whether the amount/accent of training data helps to reduce WERs. We use the standard chain LF-MMI based Kaldi's recipe for both architectures, which includes 3-fold speed perturbation and one third frame sub-sampling.
\subsection{Conventional LF-MMI Training}
\label{subs:conv}
Conventional LF-MMI training of TDNNF models still relies on a HMM-GMM model to build both the alignments and lattices needed during training. The HMM-GMM models are trained with only the out-of-domain databases i.e. Librispeech + Commonvoice. We followed the standard Kaldi's recipe which requires 100-dimensional i-vector features, 3-fold speed perturbation, and lattices for LF-MMI training supervision, obtained from the training sets. The TDNNF system trained on the out-of-domain training set ($\sim$1500 hours) is tagged as `TDNNF-B'. To measure the impact of the amount of training data on performance in the target domain, we train once with and once without transfer learning on the three different ATC train sets presented in Table~\ref{tab:split_db}. Models trained with transfer learning have `TF' in the name (e.g. TDNN-TF-B). The systems without transfer learning simply are denoted according to their architectures (i.e. TDNNF, CNN+TDNNF or TDNNF-BPE).
\subsection{Byte-Pair Encoding}
\label{subs:bpe}
As part of the benchmark experiments, we use Byte-Pair Encoding (BPE)~\cite{SennrichBPE} on the training transcripts to create a (subword) vocabulary to use for language and acoustic modeling. BPE is a compression algorithm which transforms whole words into `units' of sub-strings, allowing the representation of an open vocabulary where new words can be easily introduced in the lexicons and LMs. There have been several studies using BPE for ASR systems~\cite{BPEDrexler2019, BPEZeyer2018, BPEZeng2019}, we believe there is an especially strong case for ATC communications, as it relies mostly on simple commands and call-signs, but at the same time contains a relatively high amount of foreign proper nouns, which could be missing in a word-based model. For BPE training we limited the number of merges (sub-words) to 2000. We used the original implementation from~\cite{SennrichBPE}. We use a character-based sub-word lexicon which means to get a pronunciation for a word we split the word up into its characters, and then use the most common characters instead of phones.
\begin{table*}[th!]
\caption{DNN benchmarks with different training methodologies and amount of in-domain and out-of-domain training data. TDNNF-B is our proposed base model trained on Librispeech and Commonvoice. TDNNF-TF-B uses TDNNF-B for initialization (acting as transfer learned model) and then is adapted on the corresponding dataset seen in the table. TDNNF-BPE is a byte-pair encoding system based on 2k sub-word units and a 6-gram LM developed using Tr1+Tr2 train set. CNN+TDNNF is composed of six convolutional layers coupled with nine TDNNF layers at the top (trained on the displayed dataset on the same row).}
\label{tab:results}
\centering
\begin{tabular}{p{1.9cm} c c c c c c c c c c}
\toprule
\multirow{3}{*}{\textbf{System}} & \multirow{3}{*}{\textbf{Train Set}} & \multirow{3}{*}{\textbf{Params}} &
\multicolumn{8}{c}{\textbf{Word Error Rates (WER) \% - (test sets)}} \\
\cline{4-11}
&&& \multicolumn{2}{c}{\textbf{Vienna}} & \multicolumn{2}{c}{\textbf{Prague}}
& \multicolumn{2}{c}{\textbf{Airbus}} & \multicolumn{2}{c}{\textbf{Atcosim}} \\
&&& LM-3 & LM-4 & LM-3 & LM-4 & LM-3 & LM-4 & LM-3 & LM-4 \\
\midrule
TDNNF-B & OOD set & 23.1M & 95.8 & 95.8 & 47.6 & 43.3 & 80.6 & 77.5 & 67.5 & 63.4 \\
\midrule
\multirow{3}{1in}{TDNNF-TF-B} & Train1 &
\multirow{3}{*}{20.8M} & 7.6 & 7.1 & 9.1 & 9.0 & 53.6 & 51.4 & 7.5 & 7.3\\
& Train2 && 30.2 & 26.2 & 19.3 & 17.8 & 14.9 & 14.6 & 23.9 & 20.5\\
& Tr1+Tr2 && 7.5 & 6.9 & 8.6 & 8.4 & 15.2 & 14.7 & 5.9 & 6.0\\
\midrule
\multirow{3}{1in}{TDNNF} & Train1 &
\multirow{3}{*}{20.8M} & 8.1 & 7.5 & 8.9 & 8.7 & 67.8 & 66.7 & 8.5 & 8.1\\
& Train2 && 33.2 & 30.2 & 20.1 & 18.8 & 14.6 & 14.5 & 23.4 & 19.6\\
& Tr1+Tr2 && \textbf{7.1} & \textbf{6.6} & 8.1 & 7.9 & \textbf{14.6} &
\textbf{14.4} & 5.3 & 5.2 \\
\midrule
CNN+TDNNF & Tr1+Tr2 & 14.3M & 7.1 & 6.7 & 8.1 & 7.9 & 15.1 & 14.7 &
\textbf{5.0} & \textbf{5.1} \\
&&& \multicolumn{2}{c}{LM-6} & \multicolumn{2}{c}{LM-6} &
\multicolumn{2}{c}{LM-6} & \multicolumn{2}{c}{LM-6} \\
\cline{4-11}
TDNNF-BPE & Tr1+Tr2 & 20.8M & \multicolumn{2}{c}{7.6} & \multicolumn{2}{c}{\textbf{5.1}} &
\multicolumn{2}{c}{15.1} & \multicolumn{2}{c}{7.2} \\
\bottomrule
\end{tabular}
\end{table*}
\section{Results and Discussion}
\label{sec:results}
The results (Table~\ref{tab:results}) are split into four blocks. First, TDNNF-B is trained on an OOD set consisting of 1500 hours. This is our base model to perform transfer learning. Second, TDNNF-B model is adapted to the different ATC datasets (using TDNNF-B as initialization) i.e. Train1, Train2 and Tr1+Tr2. Third, we compare WERs for TDNNFs without transfer learning. Finally, we present results on a CNN+TDNNF chain model and TDNNF trained with BPE units. We kept the same hyper-parameters across all the experiments in order to make fair comparisons between models. The base model performs poorly on the ATC data. This is not surprising as Librispeech and Commonvoice are both read speech with mostly clear audio. The ATC data is more noisy, the speakers talk much quicker, and the accents are stronger. Despite the significant difference in domains, the pretraining still helps when the target dataset is not too large, as can be seen when comparing the first two rows of the TDNNF-TF-B and the TDNNF models in Table~\ref{tab:results} (trained on Train1 or Train2). Note the sometimes large differences in performance of the models trained on either Train1 or Train2 can be explained by whether the accent(s) in the test set were also present in the training set. Once the target domain dataset becomes large enough, we do not see the benefit of pretraining (see the last row of the TDNNF-TF-B and the TDNNF models). The last block of experiments provides a broader cover of different DNN architectures and techniques on our proposed ASR benchmark for ATC communications. There is no clear winner. The CNN+TDNNF system yielded a new baseline of 5\% WER for Atcosim, showing a relative improvement on WERs of 16.7\% and 3.9\% when compared to TDNNF-TF-B and TDNNF. The best model for Vienna dataset was TDNNF trained on Tr1+Tr2 and scored with a 4-gram LM, whereas for Prague it was TDNNF with 6-gram and lexicon based on BPE. Compared to previous experiments on MALORCA~\cite{kleinert2018semi,srinivasamurthy2017semi}, our approach yields 29.8\% and 37.9\% relative WER improvement for Vienna and Prague.
We further investigated why the BPE model does significantly better on the Prague test set, and found that the difference in performance is entirely explained by reduced deletions (five times more deletions in TDNNF and CNN+TDNNF than TDNNF-BPE system). The word-based model is obviously not able to recognize OOV words, which is the primary reason for the deletion errors. The OOV rates on Prague, Vienna, Airbus and Atcosim test sets are 3.3\%, 1.1\%, 0.0\% and 0.1\%. This shows that the BPE system is capable of recognizing OOVs and thereby improving performance; although, it does come at a cost since the BPE models also perform significantly worse on some test sets. Further investigation is required to understand the differences in performance between word and sub-word (BPE) based systems. We noticed that the BPE based model performs better on foreign words (even when the word-based model includes these words in its lexicon). We attributed it to the character-based lexicon system, which generalizes better to foreign languages which are not closely related to English. The Atcosim baseline WER is presented in~\cite{holone2016n}, schiving 8.5\% absolute WER when performing n-best list re-ranking using syntactic knowledge. In our case, we obtain first 63.4\% WER with TDNNF-B and an improvement to 8.1\% absolute WER when training only on Train1 set. An additional 10\% relative WER improvement can be obtained if employing transfer learning (i.e. TDNNF-TF-B + Train1), reaching 7.3\% absolute WER. An additional 28\% relative WER improvement is achieved when training TDNNF on Tr1+Tr2, which is a bigger train set. Finally, with the intention to explore different DNN architectures we were able to further reduce the absolute WER to 5.0\% when using a CNN+TDNNF system trained on Tr1+Tr2, accounting to 3.8\% relative improvement from TDNNF.
Finally, we are currently exploring new hybrid frameworks for acoustic modeling --of ATCo data-- such as Pkwrap~\cite{pkwrap20}. Pkwrap~\footnote{https://github.com/idiap/pkwrap} is a simple wrapper that is useful to train acoustic models in PyTorch using Kaldi's LF-MMI training framework.
\section{Conclusions}
This work introduce state-of-the-art DNN architectures to the area of ASR for air-traffic communications. We tested several DNN architectures, amount of training data and transfer learning across the given experiments in order to reasonably compare their performance. To the author's knowledge, this is the first study employing six air-traffic command-related databases spanning more than 176 hours of speech data that are strongly related in both, phraseology and structure to ATCos-pilots communications, therefore dealing with the burden of lack of databases that many previous studies have quoted. Specifically, we have shown that using in-domain ATC databases, even if not from the same country/airport, the system is capable to yield a 29.8\% and 37.9\% relative WER improvement for Vienna and Prague approaches. Also, we reported new baselines for Vienna, Prague and Atcosim test sets. In general, our proposed ASR engine for ATCo speech achieves an averaged WER of 7.75\% across four test sets with different accent; the given results suggest that systems trained on cross-accent data helps in the overall system's performance, rather than limiting the amount of data to single-accent datasets. Finally, one of the main outcomes of this research was the results on byte-pair encoding with Prague approach, reaching 5.0\% WER. We advise that future research should further explore BPE units for ATC.
\bibliographystyle{IEEEtran}
| {'timestamp': '2020-08-14T02:09:06', 'yymm': '2006', 'arxiv_id': '2006.10304', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10304'} | arxiv |
\section{Introduction}
Semi-supervised learning is a long-standing problem in machine learning.
Many semi-supervised learning algorithms rely on the geometry of the data induced by both labeled and unlabeled data points~\cite{chapelle2006semi}.
Since this geometry can be naturally represented by a graph whose nodes are data points and edges represent relations between data points, graph-based semi-supervised learning has been extensively studied for decades~\cite{zhu2003semi, zhou2004learning, belkin2006manifold, yang2016revisiting, kipf2016semi}.
In this paper, we focus on the problem of semi-supervised node classification on graphs.
Graph Neural Networks (GNNs) have achieved remarkable progress in this field recently~\cite{ zhou2018graph, wu2020comprehensive, zhang2020deep}.
In particular, graph convolutions~\cite{kipf2016semi, gilmer2017neural} have received great attention due to its flexibility and good performances.
Underlying these methods is a neighborhood aggregation that forms a new representation of a node by aggregating features of itself and its neighbors.
The neighborhood aggregation is essentially a type of Laplacian smoothing~\cite{li2018deeper}, i.e., making the features of neighboring nodes similar, which makes the subsequent classification task easier.
Built on this, several methods have developed the weighted aggregation using attention mechanisms~\cite{velivckovic2017graph, thekumparampil2018attention, zhang2018gaan} where the attention weights are determined by the features of each neighboring node pair.
However, one of the fundamental weaknesses with neighborhood aggregation methods is the lack of ability to capture long-range dependencies caused by over-smoothing~\cite{chen2019measuring}.
When stacking multiple layers to expand their range, the diameter of the smoothed area grows large, and eventually, the node representations in the entire graph become indistinguishable.
Although there have been miscellaneous efforts to overcome this issue~\cite{xu2018representation, abu2019mixhop, wu2019simplifying}, the range of these methods is still limited.
Therefore, it is desirable to have the ability to propagate the label information over long-range, especially for large graphs or under sparsely labeled settings.
Recently, diffusion-based methods~\cite{klicpera2018predict, jiang2019data, klicpera2019diffusion} have demonstrated the capability of capturing long-range dependencies without leading to over-smoothing.
These methods utilize graph diffusion as an alternative to neighborhood aggregation.
Graph diffusion is a Markov process which spreads the information from the node to the adjacent nodes at each time step~\cite{masuda2017random}.
Theoretically, $K$-steps of feature diffusion means that features of up to $K$-hop neighbors are aggregated to each node.
This aggregation-by-diffusion scheme allows the model to achieve a larger range without changing the neural network, whereas in the neighborhood aggregation scheme expanding the range would require additional layers.
However, a major limitation of these methods is that they only utilize the graph structure with a transition matrix of diffusion determined by the graph adjacency matrix.
Since edges in real graphs are often noisy~\cite{khan2018uncertain} and could contain additional information,
there exist discrepancies between node labels and the graph structure~\cite{chen2019measuring}, i.e., some nodes may have more inter-class neighbors.
Thus, the aggregation scheme determined solely by the graph structure may lead to corrupted representations due to the inter-class connections.
To address the aforementioned limitation, we propose Class-Attentive Diffusion (CAD), a novel stochastic process that strengthens attention to intra-class nodes and attenuates attention to inter-class nodes by considering both the node features and the graph structure.
The proposed CAD attentively aggregates nodes probably of the same class among K-hop neighbors so that the feature representations of the same class become similar.
Then, we further propose a novel adaptive update scheme that assigns proper reflection ratios of the CAD result for each node depending on the local class-context.
If a node has many inter-class neighbors, our adaptation scheme puts more weights on the node's original feature than the aggregated feature by CAD and vice versa.
In this work, we call the overall scheme as \textit{\textbf{Ada}ptive aggregation with \textbf{CAD}} (AdaCAD).
Built on AdaCAD, we construct a simple model called \textit{Class-Attentive Diffusion Network} (CAD-Net).
Through extensive experiments, we validate the proposed method and show that AdaCAD enables the model to embed more favorable feature representations for better class separation.
Our CAD-Net significantly outperforms the state-of-the-art methods on 7 benchmark datasets from 3 different graph domains.
\section{Related Work}
\label{RelatedWork}
\subsection{Graph Neural Networks}
In recent literature on GNNs, there are two mainstreams: spectral-based methods and spatial-based methods.
The spectral-based methods~\cite{bruna2013spectral, henaff2015deep, defferrard2016convolutional, kipf2016semi} developed graph convolutions in the spectral domain using the graph Fourier transform.
However, these methods do not scale well with large graphs due to the computational burden.
The spatial-based methods~\cite{niepert2016learning, gilmer2017neural, hamilton2017inductive, velivckovic2017graph, monti2017geometric}, on the other hand, defined convolution-like operations directly on the graph based on the neighborhood aggregation.
The spatial-based methods, in particular, GCN~\cite{kipf2016semi}, MPNN~\cite{gilmer2017neural}, and SAGE~\cite{hamilton2017inductive} have received considerable attention due to its efficiency and superior performance.
Built on the neighborhood aggregation scheme, numerous variants have been proposed.
In the following, we categorize recent methods into three groups based on what they leverage to improve the model.
(\romannumeral 1)
\textit{Extended Aggregation}.
Mixhop~\cite{abu2019mixhop} concatenates aggregated features from neighbors at different hops before each layer,
while in JK~\cite{xu2018representation}, skip connections are exploited to \textit{jump} knowledge to the last layer.
In SGC~\cite{wu2019simplifying}, multi-layers of GCN~\cite{kipf2016semi} are simplified into a single layer using the $K$-th power of an adjacency matrix, which means that the aggregation extends to the $K$-hop neighbor.
These methods use an extended neighborhood for aggregation.
However, the range of these methods is still limited, attributed to the low number of layers used.
(\romannumeral 2)
\textit{Feature Attention}.
Attention-based method such as GAT~\cite{velivckovic2017graph}, AGNN~\cite{thekumparampil2018attention}, and GaAN~\cite{zhang2018gaan}
have utilized attention mechanisms to develop weighted aggregation where the weighting coefficients are determined by the features of each neighboring node pair.
However, the aggregation of these methods is still limited to 1-hop neighbor.
Meanwhile, Graph U-Nets~\cite{gao2019graph} proposed graph pooling and unpooling operations based on feature attention and then, developed an encoder-decoder architecture in analogy to U-Net~\cite{ronneberger2015u}.
However, the pooling operation proposed in their method does not take the graph structure into account but only depends on the node features~\cite{lee2019self}.
(\romannumeral 3)
\textit{Graph Diffusion}.
Recently, there have been several attempts utilizing graph diffusion.
These methods aggregate features by propagation over nodes using
random walks~\cite{atwood2016diffusion, ying2018graph, ma2019pan},
Personalized PageRank (PPR)~\cite{klicpera2018predict},
Heat Kernel (HK)~\cite{xu2019graph},
and regularized Laplacian smoothing-based diffusion methods~\cite{jiang2019data}.
Meanwhile, GDC~\cite{klicpera2019diffusion} utilizes generalized graph diffusion (e.g. PPR and HK) to generate a new graph, then use this new graph instead of the original graph to improve performance.
However, all of the aforementioned methods do not take node features into account in their diffusion.
\subsection{Random Walks on Graph}
Random walks have been extensively studied in classical graph learning; see~\cite{lovasz1993random, masuda2017random}
for an overview of existing methods.
In particular, random walks were used in the field of unsupervised node embedding~\cite{perozzi2014deepwalk, grover2016node2vec, tsitsulin2018verse, abu2018watch}.
Unlike these methods, the proposed method aims to embed a more favorable node representation for semi-supervised classification.
To achieve this, the proposed diffusion is class-attentive by considering the node features as well as the graph structure, while in those methods, it only depends on the graph adjacency matrix.
In~\cite{wu2012learning, wu2013analyzing}, Partially Absorbing Random Walk (PARW), a second-order Markov chain with partial absorption at each state, was proposed for semi-supervised learning.
Co- \& Self-training~\cite{li2018deeper} utilized PARW for label propagation, presenting learning techniques that add highly confident predictions to the training set.
However, the state distribution of PARWs is also determined solely by the graph structure.
Recently, several methods~\cite{lee2018graph, akujuobi2019collaborative, akujuobi2020recurrent} adopted reinforcement learning that aims to learn a policy that attentively selects the next node in the RW process.
However, unlike the proposed method, their attention does not explicitly utilize class similarity since they employed additional modules to learn the policy.
\section{Proposed Method}
\subsection{Problem Setup}
Formally, the problem of semi-supervised node classification considers a graph $G = (\mathcal{V}, \mathcal{E}, X)$ where $\mathcal{V} = \{v_i\}_{i=1}^{N}$ is the set of $N$ nodes, $\mathcal{E}$ denotes the edges between nodes,
and $X \in \mathbb{R}^{N \times D}$ is a given feature matrix, i.e., $x_i$, $i$-th row of $X$, is $D$-dimensional feature vector of the node $v_i$.
Since edge attributes may not be given, we consider unweighted version of the graph represented by an adjacency matrix $A = [a_{ij}] \in \mathbb{R}^{N \times N}$ where $a_{ij} = 1$ if $\mathcal{E}(i,j) \neq 0$ and $a_{ij} = 0$ otherwise.
We denote the given label set as $Y_L$ associated with the labeled node set $\mathcal{V}_L$, i.e., $y_i \in Y_L$ be an one-hot vector indicating one of $C$ classes for $v_i$.
We focus on the transductive setting~\cite{yang2016revisiting} which aims to infer the labels of the remaining unlabeled nodes based on $(X, A, Y_L)$.
In general, the model for semi-supervised node classification can be expressed as
\begin{equation}
\label{eq:overview}
Z = f_{\theta}(X, A) \quad \text{and} \quad \hat{y}_i = g_\phi(z_i)\enskip (i = 1, 2, \cdots, N)
\end{equation}
where $f_{\theta}$ is a feature embedding network to embed the feature representations $Z$ from $(X, A)$, and $g_\phi$ is a node classifier predicting $\hat{y}_i$ from $z_i$, $i$-th row of $Z$.
The feature embedding network $f_{\theta}$ is realized by GNNs in recent literature.
The process of GNN can be decomposed into two steps: feature transformation and feature aggregation
where the former stands for a non-linear transformation of node features and the latter refers to the process of forming new representations via aggregating proximal node features.
In this paper, we focus on the process of feature aggregation.
More specifically, we aim to design an aggregation scheme which can be applied right before the classifier from Eq. (\ref{eq:overview}) to embed more favorable feature representations for class separation.
To this end, we first propose a novel Class-Attentive Diffusion (CAD), which attentively aggregates nodes probably of the same class among K-hop neighbors so that the representations of the same class become similar (see Section~\ref{sec:CAD}).
Given $Z \in \mathbb{R}^{N \times F}$, CAD produces new feature representations $Z^{\mathrm{(CAD)}} \in \mathbb{R}^{N \times F}$ as follows,
\begin{equation}
\label{eq:defCAD}
Z^{\mathrm{(CAD)}} \leftarrow \mathrm{CAD}(Z, A, \{g_{\phi}(z_i)\}_{i=1}^{N}).
\end{equation}
Note that the node features ($Z$), the graph structure ($A$), and the class information ($g_{\phi}$) are jointly utilized.
Then, we further propose \textbf{Ada}ptive aggregation with \textbf{CAD} (AdaCAD) that leverages different reflection ratios of the diffusion result for each node depending on the local class-context (see Section~\ref{sec:AdaCAD}).
That is, AdaCAD produces the final feature representations $Z^{\mathrm{(AdaCAD)}} \in \mathbb{R}^{N \times F}$ as follows,
\begin{equation}
\label{eq:defAdaCAD}
Z^{\mathrm{(AdaCAD)}} \leftarrow \mathrm{AdaCAD}(Z, Z^{\mathrm{(CAD)}}, \Gamma)
\end{equation}
where $\Gamma$ assigns proper weights between $Z$ and $Z^{\mathrm{(CAD)}}$ for each node.
Built on AdaCAD, we construct a simple model called \textit{Class-Attentive Diffusion Network} in Section~\ref{sec:CAD-Net}.
\subsection{Class-Attentive Diffusion}
\label{sec:CAD}
In this section we present a novel stochastic process called Class-Attentive Diffusion (CAD), which combines the advantages of both the attention mechanism and the diffusion process.
The proposed CAD consists of $N$ Class-Attentive Random Walks (CARWs) starting at each node in the graph.
For clarity, we first explain how a single CARW is defined.
Suppose a CARW that starts from the node $v_i$.
The walker determines the next node among the neighbor by comparing the class likelihood given the node features, i.e., comparing $\mathbf{p}_i = p(y_i|z_i)$ and $\mathbf{p}_j = p(y_j|z_j)$ for $j \in \mathcal{N}(i)$.
Our design objective is that the more similar $\mathbf{p}_i$ and $\mathbf{p}_j$, the more likely the walker moves from $v_i$ to $v_j$.
To this end, we define the transition probability from $v_i$ to $v_j$ as
\begin{equation}
\label{eq:transition}
T_{ij} = \mathrm{softmax}_{j \in \mathcal{N}(i)}(\mathbf{p}_i^T \mathbf{p}_j).
\end{equation}
Note that, $\mathbf{p}_i$ is a categorical distribution of which $c$-th element $\mathbf{p}_i(c)$ is the probability of node $i$ belongs to class $c$.
Thus, the cosine distance between $\mathbf{p}_i$ and $\mathbf{p}_j$ (i.e., $\mathbf{p}_i^T\mathbf{p}_j$) can be one possible solution for measuring the similarity between them.
However, the true class likelihood $\mathbf{p}_i$ is intractable.
Instead, we approximate the true distribution by exploiting the classifier $g_{\phi}$ in Eq. (\ref{eq:overview})
where the probability of each class is inferred by $g_{\phi}$ based on the node feature $z_i$.
That is,
\begin{equation}
\label{eq:self-guided}
\mathbf{p}_i \approx p(\hat{y}_i | z_i) = g_\phi(z_i).
\end{equation}
As the learning progresses, the transition matrix in Eq. (\ref{eq:transition}) gradually becomes more class-attentive by means of $g_{\phi}$.
This is the key difference from the recent diffusion-based methods, APPNP~\cite{klicpera2018predict}, GDEN~\cite{jiang2019data}, and GDC~\cite{klicpera2019diffusion},
where the transition matrix is determined solely by the adjacency matrix.
Let a row vector $\pi_{i}^{(t)} \in \mathbb{R}^{N}$ be the state distribution of the CARW after $t$ steps.
This can be naturally derived by a Markov chain, i.e., $\pi_{i}^{(t+1)} = \pi_{i}^{(t)} T$,
where the initial state distribution $\pi_{i}^{(0)}$ be a one hot vector indicating the starting node $v_i$.
Then, this can be naturally extended to CAD
where $\bm{\Pi}^{(K)} \in \mathbb{R}^{N \times N}$ be the state distribution matrix after $K$-steps of CAD with entries $\bm{\Pi}^{(K)}(i,j) = \pi_{i}^{(K)}(j)$.
Now, we can define a new aggregation method with $K$-steps of CAD,
which forms a new feature representation of the node $v_i$ as follows,
\begin{equation}
\label{eq:CAD}
z_i^{\mathrm{(CAD)}} = \sum_{j}\pi_{i}^{(K)}(j)\cdot z_j.
\end{equation}
Note that $\pi_{i}^{(K)}(j)$ is zero for $v_j$ beyond $K$-hop from $v_i$.
Hence, $\pi_{i}^{(K)}(j)$ naturally reflects the class similarity as it grows with the similarity between $\mathbf{p}_i$ and $\mathbf{p}_j$.
That is, $z_i^{\mathrm{(CAD)}}$ is essentially an attentive aggregation of $K$-hop neighbors where CAD strengthens attention to intra-class nodes and attenuates attention to inter-class nodes.
\subsection{Adaptive Aggregation with CAD}
\label{sec:AdaCAD}
In this section, we present Adaptive aggregation with CAD (AdaCAD).
We start by introducing our motivation.
In real graphs, some nodes may be connected to nodes of various classes, or even worse, nodes of the same class may not even exist in their neighbors.
Intuitively, in these cases, aggregated features from neighbors may lead to corrupted representations due to the inter-class connections.
Therefore, it should be needed to adaptively adjust the degree of aggregation for each node depending on its local class-context.
Motivated by this, we define AdaCAD to form a new feature representation of the node $v_i$ as follows,
\begin{equation}
\label{eq:AdaCAD}
z_i^{\mathrm{(AdaCAD)}} = (1-\gamma_i) \cdot z_i + \gamma_i \cdot z_i^{\mathrm{(CAD)}}.
\end{equation}
Here, $\gamma_{i} \in [0, 1]$ controls the trade-off between its own node feature $z_i$ and the aggregated feature $z_i^{\mathrm{(CAD)}}$ from Eq. (\ref{eq:CAD}) by considering the local class-context of $v_i$.
For the node with neighbors of the same class, $\gamma_i$ should be a large value to accelerate proper smoothing.
In the opposite situation, $\gamma_i$ should be adjusted to a small value to preserve its original feature and avoid undesired smoothing.
To this end, we define a control variable $c_i$ as
\begin{equation}
c_i = \frac{1}{\mathrm{deg}(i)}\sum_{j \in \mathcal{N}(i)}g_{\phi}(z_i)^{T} g_{\phi}(z_j)
\end{equation}
where $\mathrm{deg}(i)$ is the degree of $v_i$ and $g_{\phi}$ is the aforementioned classifier.
Then, the range of $c_i$ would be $0 \leq c_i \leq 1$.
The meaning of $c_i$ is that the more nodes of the same class in the neighborhood, the greater the value of $c_i$ and vice versa.
Therefore, we set up an adaptive formula for $\gamma_i$ as
\begin{equation}
\gamma_i = (1-\beta)c_i + \beta \gamma_{u}
\end{equation}
where $\gamma_u=1$ is the upper bound of $\gamma_i$ to keep $0 \leq \gamma_i \leq 1$ for interpolation of each node feature and the diffusion result.
Note that $\gamma_i$ divides $c_i$ and $\gamma_u$ internally in the ratio of $\beta : (1-\beta)$
where $\beta \in [0, 1]$ controls the sensitivity of how much $\gamma_i$ will be adjusted according to $c_i$.
Since different graphs exhibit different neighborhood structures~\cite{klicpera2018predict}, the sensitivity $\beta$ is determined empirically for each dataset.
Now, we conclude the section with the overall formula of the proposed AdaCAD in a matrix form.
By letting $\bm{\Gamma} = \text{diag}(\gamma_1, \gamma_2, \cdots, \gamma_N)$ and combining Eq. (\ref{eq:CAD}) and (\ref{eq:AdaCAD}) together,
the entire aggregation scheme of AdaCAD can be expressed as follows,
\begin{equation}
\label{eq:matrixform}
Z^{\mathrm{(AdaCAD)}} = (\mathbf{I} - \bm{\Gamma})\cdot Z + \bm{\Gamma} \cdot \bm{\Pi}^{(K)} \cdot Z
\end{equation}
where $\bm{\Pi}^{(K)}$ is the state distribution matrix after $K$-steps of CAD.
Note that AdaCAD does not require additional learning parameters since we utilize the classifier $g_{\phi}$.
\subsection{Class-Attentive Diffusion Network}
\label{sec:CAD-Net}
Built on AdaCAD, we construct \textit{Class-Attentive Diffusion Network} (CAD-Net) for semi-supervised classification.
CAD-Net consists of the feature embedding network $f_{\theta}$ followed by AdaCAD and the classifier $g_{\phi}$ as defined in Eq. (\ref{eq:overview}), (\ref{eq:defAdaCAD}) and (\ref{eq:matrixform}).
More specifically, we realize $f_{\theta}$ with 2-layers of MLP for simplicity, as the process of feature aggregation can be sufficiently performed in AdaCAD,
and $g_{\phi}$ is realized by the softmax function, i.e., $\hat{y_i} = g_{\phi}(z_i) = \mathrm{softmax}(z_i)$ as in other literature~\cite{kipf2016semi, wu2019simplifying, jiang2019data}, and thus the dimension of $z_i$ is set to the number of classes.
The whole network parameters can then be trained in an end-to-end manner by minimizing the cross-entropy loss function $\mathcal{L}_{\mathrm{sup}}$ over all labeled nodes.
By minimizing the cross-entropy between the label $y_i$
and the prediction $\hat{y_i}$ for all $y_i \in Y_L$, the model can be learned to enhance the element of $z_i$ that corresponds to the index indicating the class of $y_i$, which facilitates the class separation.
In addition to $\mathcal{L}_{\mathrm{sup}}$, we consider another regularization objective.
As defined in Eq. (\ref{eq:transition}) and (\ref{eq:self-guided}), the transition matrix of CAD is determined by $\mathbf{p}_{i}$
where the initial distribution $\mathbf{p}_{i}$ for each node should generally be close to a one-hot vector such that the resulting transition matrix becomes more class-attentive.
Thus, we regularize the entropy of $\mathbf{p}_{i}$ by minimizing $\mathcal{L}_{\mathrm{ent}} = \sum_{i=1}^{N} H(\mathbf{p}_{i})$ where $H$ denotes the entropy function.
During training, $\mathcal{L}_{\mathrm{sup}}$ and $\mathcal{L}_{\mathrm{ent}}$ are jointly minimized by using Adam optimizer~\cite{kingma2014adam}.
We report the detailed implementation in Appendix A.\footnote{\url{https://github.com/ljin0429/CAD-Net}}
\section{Experiments}
\input{tables/dataset.tex}
\subsection{Datasets}
We conducted experiments on 7 benchmark datasets from 3 different graph domains:
\textit{Citation Networks} (CiteSeer, Cora, and PubMed),
\textit{Recommendation Networks} (Amazon Computers and Amazon Photo),
and \textit{Co-authorship Networks} (Coauthor CS and Coauthor Physics).
\textbf{CiteSeer}, \textbf{Cora}, and \textbf{PubMed} are citation networks where each node represents a document and each edge represents a citation link.
Node features are bag-of-words descriptors of the documents, and class labels are given by the document's fields of study.
\textbf{Amazon Computers} and \textbf{Amazon Photo} are segments of Amazon co-purchase graph.
Here, each node represents a product and each edge indicates that two goods are frequently bought together.
Node features are bag-of-words descriptors which encode the product reviews, and class labels are given by the product category.
\textbf{Coauthor CS} and \textbf{Coauthor Physics} are co-authorship networks based on MS Academic Graph where each node represents an author and an edge is connected if they have co-authored a paper.
Node features represent paper keywords for each author's papers, and class labels indicate the most active fields of study for each author.
Table~\ref{dataset-table} summarizes the dataset statistics.
\input{figures/4-figure-hidden.tex}
\subsection{Experimental Setup}
For citation networks, we followed the standard benchmark setting suggested in~\cite{yang2016revisiting}.
We evaluated on the same train/validation/test split, which uses 20 nodes per class for train, 500 nodes for validation, and 1000 nodes for test.
For the credibility of the results, we report the average accuracy (\%) with the standard deviation evaluated on 100 independent runs.
For recommendation and co-authorship networks, we closely followed the experimental setup in~\cite{chen2019measuring}.
We used 20 nodes per class for train, 30 nodes per class for validation, and the rest nodes for test.
We randomly split the nodes and report the average accuracy (\%) with the standard deviation evaluated on 100 random splits.
We compared the proposed method with the following 12 state-of-the-art methods:
\textbf{Cheby}~\cite{defferrard2016convolutional},
\textbf{GCN}~\cite{kipf2016semi},
\textbf{SAGE}~\cite{hamilton2017inductive},
\textbf{JK}~\cite{xu2018representation},
\textbf{MixHop}~\cite{abu2019mixhop},
\textbf{SGC}~\cite{wu2019simplifying},
\textbf{AGNN}~\cite{thekumparampil2018attention},
\textbf{GAT}~\cite{velivckovic2017graph},
\textbf{Graph U-Nets}~\cite{gao2019graph},
\textbf{APPNP}~\cite{klicpera2018predict},
\textbf{GDC}~\cite{klicpera2019diffusion},
and \textbf{GDEN}~\cite{jiang2019data}.
In all experiments, the publicly released codes were employed.
\subsection{Model Analysis}
In this section, we provide comprehensive analysis of the proposed method on CiteSeer, Cora, and PubMed
as they are the most widely used benchmark datasets in the literature.
\subsubsection{Influence of AdaCAD.}
To verify the effectiveness of AdaCAD, we compared AggCAD with 7 different aggregation methods.
For a fair comparison, only AdaCAD is replaced with the same CAD-Net architecture.
Firstly, we consider 4 diffusion methods including Random Walks (RW), symmetric Normalized Adjacency matrix (symNA), Personalized PageRank (PPR)~\cite{page1999pagerank}, and Heat Kernel (HK)~\cite{kondor2002diffusion}.
For RW and symNA, the transition matrix is defined as $D^{-1}A$ and $D^{-\frac{1}{2}}AD^{-\frac{1}{2}}$ respectively, and we proceed $K$-steps of feature diffusion according to their transition matrix.
For PPR and HK, the closed-form solution of the diffusion state distribution is used as in~\cite{klicpera2019diffusion}.
Secondly, we consider 2 attentive diffusion variants.
To the best of our knowledge, CAD is the first attempt that incorporates the feature attention and the diffusion process.
Therefore, we construct GAT+RW and TF+RW based on GAT~\cite{velivckovic2017graph} and Transformer~\cite{vaswani2017attention} respectively.
In GAT+RW, the transition is defined by the attention value computed by GAT, and we proceed $K$-steps of feature diffusion according to it.
Likewise, in TF+RW, the transition is defined by Transformer-style attention, i.e., $T_{ij} = \mathrm{softmax}_{j}(f_{\mathrm{Q}}(z_i)^T f_{\mathrm{K}}(z_j))$.
Lastly, we consider the model that only uses CAD for aggregation.
Table~\ref{diffusion-variants} shows the overall comparisons with the aforementioned variants.
Compared to RW, sym, PPR, and HK, which only utilize the graph structure, our variants (CAD-only and AggCAD) show superior results.
The better performance comes from the proposed class-attentive transition matrix both utilizing node features and the graph structure.
While GAT+RW and TF+RW can utilize both node features and the graph structure, the performances are not sufficient, which demonstrate the effectiveness of our design of class-attentive diffusion.
Lastly, AdaCAD shows better performance than only using CAD.
By means of $\Gamma$ in AdaCAD, the model prevents undesired mixing from inter-class neighbors, which provides additional performance gains to CAD.
\input{tables/diffusion_variants.tex}
\input{figures/4-figure-label.tex}
\input{figures/4-figure-range.tex}
\subsubsection{Influence of Hidden Units.}
Unlike attention-based methods (AGNN and GAT), the proposed CAD can be self-guided by the classifier without the need for additional parameters for attention.
Thus, the total number of parameters can be implemented in the same way as the vanilla GCN.
To validate the effectiveness of AdaCAD, we evaluated the performance across the different numbers of hidden units in the feature embedding network $f_{\theta}$, and compared the results with GCN and APPNP which have the same number of parameters.
As shown in Figure~\ref{fig:hidden}, CAD-Net shows robust performance with respect to the number of hidden units.
Further, for all experiments, we can observe that CAD-Net significantly outperforms GCN and APPNP with the same number of parameters.
This demonstrates that the superior performance of CAD-Net is attributed to the proposed AdaCAD, not the power of the feature embedding network.
\subsubsection{Influence of $\bm{\beta}$.}
We also analyzed the influence of the hyperparameter $\beta$ which controls the sensitivity of how much $\gamma$ will be adjusted.
Due to the space limit, we attach the results to Appendix B.4.
While the optimum differs slightly for each dataset, we consistently found that any $\beta \in [0.65, 0.95]$ achieves the state-of-the-art performances.
\subsubsection{Different Label Rates.}
We then explored how the number of training nodes per class impacts the accuracy of the models.
The ability to maintain robust performance even under very sparsely labeled settings is important.
We compared the performances when the number of labeled nodes per class is changed to 20, 15, 10, and 5.
The overall results are presented in Figure~\ref{fig:label}.
CAD-Net shows robust and superior performance even under the very sparsely labeled setting and outperforms all other methods.
Note that, the diffusion-based methods (APPNP and GDC) do not show satisfactory results despite their wide range.
This is because these methods only utilize the graph structure.
In contrast, the proposed method aggregates nodes from a wide range and the importance of each node reflects both node features and the graph structure, which contributes to the superior performances of CAD-Net.
Especially, the superiority of CAD-Net is more obvious in PubMed which is a large dataset.
This further demonstrates the effectiveness of the proposed method.
\input{tables/result_table_onlyAcc.tex}
\subsubsection{Different Ranges.}
Figure~\ref{fig:range} shows influence of the different ranges.
As expected, the neighborhood aggregation methods degrade performance with increasing layers.
While the diffusion-based methods maintain the performance with increasing ranges, CAD-Net shows superior performance for all ranges.
Also, as in the previous experiment, the superiority of CAD-Net is particularly evident in PubMed, which suggests that the proposed method is able to accommodate larger graphs or sparsely labeled settings.
\input{tables/result_random_splits.tex}
\subsection{Comparison with State-of-the-art Methods}
\subsubsection{Evaluation on Benchmark Datasets.}
Table~\ref{result-table} shows the overall results under standard benchmark settings.
In all experiments, the proposed CAD-Net shows superior performance to other methods.
We also provide statistical analysis of the results in Appendix B.6, demonstrating that CAD-Net achieves statistically significant improvements.
The better performance of CAD-Net comes from the proposed adaptive aggregation scheme based on the class-attentive diffusion both utilizing node features and the graph structure in the transition matrix.
In addition, we provide further comparisons with the latest methods~\cite{liu2020towards, chen2020simple, hassani2020contrastive, zhu2020bilinear, zhang2020adaptive} and our CAD-Net still achieves state-of-the-art performance (see Appendix B.7).
\subsubsection{Computational Complexity.}
In terms of memory requirement, CAD-Net is as efficient as APPNP with the same number of parameters (see Figure~\ref{fig:hidden}).
Only one forward operation is additionally required to obtain our class-attentive transition probability.
To further validate the computational efficiency of CAD-Net, we compared the average training time per epoch (ms) measured on a single Nvidia GTX 1080 Ti machine.
As expected, we confirmed that CAD-Net is on par with APPNP and much faster than GAT.
The detailed results are provided in Appendix B.8.
\subsubsection{Random Splits.}
Recently, \cite{shchur2018pitfalls} pointed out that the data split (train, validation, test) has a significant influence on the performance.
Therefore, we further evaluated average accuracy computed over 100 \textit{Random} splits where the splits are \textit{randomly} drawn with 20 nodes per class for train, 500 nodes for validation, and 1000 nodes for test.
As shown in Table~\ref{random-splits}, CAD-Net shows robust and superior performance regardless of the data splits.
\section{Conclusion}
In this paper, we propose Adaptive aggregation with Class-Attentive Diffusion (AdaCAD), a new aggregation scheme for semi-supervised classification on graphs.
The main benefits of the proposed AdaCAD are three aspects.
(\romannumeral 1)
AdaCAD attentively aggregates nodes probably of the same class among $K$-hop neighbors employing a novel Class-Attentive Diffusion (CAD).
Unlike the existing diffusion methods, both the node features and the graph structure are leveraged in CAD with the design of the class-attentive transition matrix which utilizes the classifier.
(\romannumeral 2)
For each node, AdaCAD adjusts the reflection ratio of the diffusion result differently depending on the local class-context, which prevents undesired mixing from inter-class neighbors.
(\romannumeral 3)
AdaCAD is computationally efficient and does not require additional learning parameters since the class-attentive transition probability is defined by the classifier.
Extensive experimental results demonstrate the validity of AdaCAD and Class-Attentive Diffusion Network (CAD-Net), our simple model based on AdaCAD, achieves state-of-the-art performances by a large margin on seven benchmark datasets.
\section{Implementation}
In this section, we present the detailed implementation of CAD-Net.
We used PyTorch Geometric~\cite{Fey/Lenssen/2019} for implementation.
Table~\ref{implementation} summarizes a full list of hyperparameters of CAD-Net used in the experiments.
For all datasets, 2-layers of MLP with the number of hidden units of 64 was used for $f_{\theta}$.
We used the leaky ReLU activation and dropout for the whole network.
In Table~\ref{implementation}, \textit{leak-slope} denotes the negative slope of the leaky ReLU and $p_{\rm{drop}}$ denotes the drop probability in dropout.
The number of diffusion steps $K$ and the sensitivity $\beta$ were determined empirically.
Note that, unlike other methods, the proposed method explicitly interpolates the node's original feature (see Eq. (\ref{eq:AdaCAD}) of the manuscript) so that the self-loop is not necessary.
We used the graphs with self-loops for CiteSeer, Cora, and Amazon Photo datasets because their graphs contain a number of isolated regions where only few nodes are connected.
For training, we used Adam optimizer~\cite{kingma2014adam} with full-batch.
During training, we dropped the learning rate (lr) to 1/2 of its previous value every 100 epochs (CiteSeer and PubMed) and 50 epochs (Cora).
For a fair comparison to other methods, we did not use the lr drop strategy for Amazon and Coauthor datasets.
We used $L_2$ regularization on the learnable parameters (weight decay).
In addition, $\lambda_{\mathrm{ent}}$ denotes the weighting parameter for our entropy regularization loss term $\mathcal{L}_{\mathrm{ent}}$.
As in other works~\cite{kipf2016semi, wu2019simplifying, klicpera2019diffusion},
we used early stopping with a window size reported in Table~\ref{implementation}.
If the early stop cell is empty, we trained the model without early stopping.
Our code is available at \url{https://github.com/ljin0429/CAD-Net}.
\input{appendix/implementation.tex}
\section{Experiments}
In this section, we provide further details of the experimental setup that were not presented in the manuscript due to the space limit.
Moreover, we also present additional experiments and investigations on what happens inside AdaCAD.
\subsection{Datasets}
All datasets used in the experiments are included in PyTorch Geometric~\cite{Fey/Lenssen/2019}.
Following PyTorch Geometric, we pre-processed the datasets by removing self-loops and duplicated edges from the graphs and used these pre-processed versions of the graphs for all experiments.
We reported the dataset statistics in Table~\ref{dataset-table} of the manuscript.
\subsection{Learning Process}
Figure~\ref{fig:loss} shows the cross-entropy loss on validation set of CiteSeer across different epochs.
We compare the learning curve of CAD-Net with RW model described in Section 4.3 of the manuscript.
Since the classifier is not trained at the beginning, the transition is almost uniformly random to all neighboring nodes.
Thus, there is no difference from RW at the beginning.
As the classifier is trained by the given labeled nodes, the class prediction becomes more accurate.
Therefore, the transition of CAD becomes gradually class-attentive as the learning progresses, which leads to better predictive accuracy of CAD-Net.
As shown in Figure~\ref{fig:loss}, CAD-Net obtains obviously lower cross-entropy loss values at convergence.
\input{appendix/4-figure-loss.tex}
\subsection{Entropy Regularization}
The proposed CAD-Net is trained to jointly minimize the cross-entropy loss $\mathcal{L}_{\mathrm{sup}}$ for given labeled nodes and entropy regularization loss $\mathcal{L}_{\mathrm{ent}}$ (see Section 3.4 of the manuscript).
In this section, we analyzed the effect of the entropy regularization term $\mathcal{L}_{\mathrm{ent}}$.
For comparision, we trained CAD-Net only with the cross-entropy loss $\mathcal{L}_{\mathrm{sup}}$, and then evaluated the performance.
We confirmed that the average accuracies (with std) are 72.1\% (0.6), 83.6\% (0.4), and 81.7\% (0.3), for CiteSeer, Cora, and PubMed, respectively.
Without the entropy regularization, there is slight performance degradation since the high entropy of $\mathbf{p}_{i}$ gives a less class-attentive transition matrix.
\subsection{Influence of $\bm{\beta}$}
Figure~\ref{fig:beta} shows the effect of the hyperparameter $\beta$ which controls the sensitivity of how much $\gamma$ will be adjusted.
The blue line indicates the mean accuracy with different $\beta$ and the shaded area indicates the standard deviation computed over 100 independent runs.
The black dashed line indicates the existing state-of-the-art performance.
While the optimum value for $\beta$ differs slightly for each dataset, we can observe that any $\beta \in [0.65, 0.95]$ achieve the state-of-the-art performances.
Note that setting $\beta=1$ leads to $\gamma_i = 1$, which corresponds to CAD-only (blue dashed line) that only uses CAD without the adaptive aggregation in AdaCAD.
The CAD-only model achieves state-of-the-art performance for all datasets, demonstrating that the proposed CAD is effective.
We further confirm that a proper $\beta$ leads to additional performance gain (red dashed line) for all datasets.
That is, by means of $\gamma$, the model can adjust the reflection ratio of the diffusion to prevent corrupted representations from inter-class neighbors, which leads to better performance.
Figure~\ref{fig:histogram} illustrates the distribution of the resulting $\gamma$ for entire nodes where $\gamma_i$ for each node varies reflecting the node's local class context.
\input{appendix/4-figure-beta}
\input{appendix/4-figure-histogram}
\pagebreak
\subsection{Influence of Incorrect Predictions}
The proposed CAD-Net utilizes the classifier's output to define a class-attentive transition matrix.
One would concern that CAD-Net might have a tendency to reinforce early incorrect decisions.
If the classifier makes an incorrect decision in the first place, the transition probability is poorly defined and can eventually prejudice the classification results.
However, the proposed method is hardly degenerated by the wrong predictions.
In a situation that the classifier makes an incorrect decision, the resulting prediction mostly has ambiguous likelihood distribution, i.e., $p_i$ has high entropy.
In such cases, the transition probability becomes low, reducing the attention to that node.
Therefore, our method is generally not overconfident with wrong predictions, which prevents the reinforcement of incorrect decisions.
\vspace{+1mm}
\subsection{Statistical Analysis}
For all experiments in the manuscript, we reported the average accuracy (\%) with the standard deviation evaluated on 100 independent runs for the credibility of the results.
To further demonstrate that the performance improvements of CAD-Net are statistically significant, we first investigated $p$-values of paired $t$-tests compared with the second-best model.
Besides, to ensure the statistical robustness of our experimental results, we calculated confidence intervals via bootstrapping.
More specifically, we compared 95\% Bootstrap Confidence Intervals for the reported accuracies of the second-best model (BCI-2b) and those of ours (BCI-ours).
Table~\ref{stats_analysis} summarizes the results, demonstrating that CAD-Net achieves statistically robust and significant improvements for all experiments.
\input{appendix/stats_analysis.tex}
\subsection{Comparison with 2020 Methods}
As requested by the reviewer, we further compared with the following five major methods published in 2020 that share the same experimental settings as ours;
\begin{itemize}
\item DAGNN~\cite{liu2020towards}: \textit{Towards Deeper Graph Neural Networks} [KDD’20]
\item GCNII~\cite{chen2020simple}: \textit{Simple and Deep Graph Convolutional Networks} [ICML’20]
\item CMVRL~\cite{hassani2020contrastive}: \textit{Contrastive Multi-View Representation Learning on Graphs} [ICML’20]
\item BGNN~\cite{zhu2020bilinear}: \textit{Bilinear Graph Neural Network with Neighbor Interactions} [IJCAI’20]
\item ADSF~\cite{zhang2020adaptive}: \textit{Adaptive Structural Fingerprints for Graph Attention Networks} [ICLR’20]
\end{itemize}
\vspace{+1mm}
\noindent
DAGNN~\cite{liu2020towards} and GCNII~\cite{chen2020simple} addressed the over-smoothing issue and presented very deep architectures (more than 50 layers).
CMVRL~\cite{hassani2020contrastive} introduced a self-supervised approach by contrasting structural views of graphs.
BGNN~\cite{zhu2020bilinear} proposed a bilinear graph convolution operation which augments the weighted sum with pairwise interactions of neighboring nodes.
ADSF~\cite{zhang2020adaptive} injected structural information into GAT, but, the range of the model is limited to 2-hop neighbors.
Table~\ref{res2020} summarizes the results.
We report the numbers from their papers.
Even compared with very recent methods including deeper architectures such as DAGNN and GCNII, our CAD-Net still achieves state-of-the-art performance on CiteSeer and PubMed.
\input{appendix/res_2020methods}
\subsection{Computational Complexity}
Note that the proposed AdaCAD does not require additional learning parameters since we utilize the classifier $g_{\phi}$.
Also, AdaCAD preserves the graph's sparsity and never needs to construct an $\mathbb{R}^{N \times N}$ matrix.
Instead, the second term in Eq. (\ref{eq:matrixform}) of the manuscript can be implemented by $K$ iterations of message passing as in~\cite{klicpera2018predict}.
Only one forward operation is additionally required to obtain our class-attentive transition probability.
To quantitatively measure the efficiency, we evaluated the average training time per epoch (ms) measured on a single Nvidia GTX 1080 Ti machine.
Table~\ref{complexity} summarizes the results.
As expected, CAD-Net is on par with APPNP and much faster than GAT, which validates the computational efficiency of the proposed method.
Note that GDC requires the inverse of $\mathbb{R}^{N \times N}$ matrix, which is computationally burden and raises singular error on Coauthor CS.
\input{appendix/complexity.tex}
\subsection{Different Label Rates}
In this section we present the detailed experimental setup and results in tabular form for Figure~\ref{fig:label} of the manuscript.
From the given training set by the benchmark setting~\cite{yang2016revisiting} where 20 nodes per class are labeled, we randomly reduced the number of labeled nodes per class to 15, 10, and 5.
Table~\ref{res-label-citeseer}, \ref{res-label-cora}, and \ref{res-label-pubmed} show detailed results illustrated in Figure~\ref{fig:label} of the manuscript.
\subsection{Different Ranges}
In this section we present the detailed experimental setup and results in tabular form for Figure~\ref{fig:range} of the manuscript.
For Cheby, we used $K$-th order of Chebyshev polynomials to achieve the range of $K$.
For GCN, SAGE, JK, and GAT, we added additional layers before the last layer to achieve the desired range, whereas, for SGC, AGNN, APPNP, and the proposed CAD-Net, we simply increased the propagation steps.
Table~\ref{res-range-citeseer}, \ref{res-range-cora}, and \ref{res-range-pubmed} show the detailed results illustrated in Figure~\ref{fig:range} of the manuscript.
\clearpage
\input{appendix/res_label_CiteSeer}
\input{appendix/res_label_Cora}
\input{appendix/res_label_PubMed}
\clearpage
\input{appendix/res_range_CiteSeer}
\input{appendix/res_range_Cora}
\input{appendix/res_range_PubMed}
\section*{Acknowledgment}
This research was supported by the IITP (Institute for Information \& Communication Technology Promotion) grant funded by the MSIT (Ministry of Science and ICT, Korea): [2017-0-00306, Outdoor Surveillance Robots] and [IITP-2020-2020-0-01789, ITRC(Information Technology Research Center) support program].
\section*{Ethics Statement}
Graphs accommodate many potential real-world applications such as social networks and web pages.
Our research is a study of neural networks applicable in the graph domain.
Therefore, our research can be an important basis for graph-based applications to be applied in real life in the future.
Besides, a large amount of cost is required to acquire high quality of labeled data.
The problem of semi-supervised learning, which we focus on, can secure robust performance with a small number of labeled data, thus contributing to lowering the threshold of solving industrial or social problems using machine learning at a low cost.
| {'timestamp': '2021-01-01T02:19:08', 'yymm': '2006', 'arxiv_id': '2006.10222', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10222'} | arxiv |
\section{Introduction}
\label{sec:introduction}
Dialogue evaluation is an unsolved challenge in current human-machine interaction research. This is particularly true for open-domain conversation, where compared to task-oriented dialogue (i.e., restaurant reservations), we do not have a finite set of entities and intents, and speakers' goals are not defined a priori.
In this work, we address the problem of dialogue evaluation from the perspective of dialogue \textit{coherence} and how this concept can be formalized and evaluated. Our approach could be applied to both task-oriented and non-task-oriented dialogue.
Coherence in language, i.e., the property which determines that a given text is a logical and consistent whole rather than a random collection of sentences, is a complex multifaced concept which has been defined in different ways and to which several factors contribute \cite{redeker2000coherence}, e.g., rhetorical structure \cite{hobbs1979coherence}, topics discussed, and grounding \cite{traum1994computational}.
While much recent work has focused on coherence for response generation \cite{serban2016generative,li2016diversity, yi2019towards}, we argue that there is still much to be understood regarding the mechanisms and substructures that affect human perception of dialogue coherence. In our approach, in particular, we are interested in studying the patterns of distribution of entities and Dialogue Acts (DAs), in regards to dialogue coherence.
Approaches to coherence based on entities have been studied extensively by the Natural Language Processing literature \cite{joshi1979centered,grosz1995centering}, especially in text (e.g., news, summaries).
Coherence evaluation tasks proposed by this literature \cite{barzilay2008modeling} have the advantage of using weakly supervised training methodologies, but mainly considering documents as-a-whole, rather than evaluating coherence at the utterance level. The dialogue literature \cite{sacks1995lectures,schegloff1968sequencing}, on the other hand, has focused mainly on coherence in connection to DAs, a generalized version of intents in dialogue (e.g., \textit{yes-no-question, acknowledgement}). Recent work \cite{cervone2018coherence}, in particular, showed the importance of both DAs and entities information for coherence modeling in dialogue. However, even in this case dialogue coherence was rated for entire dialogues rather than studying turn coherence structures.
In this work, we investigate underlying conversation turn substructures in terms of DA and entity transitions to predict turn-by-turn coherence in dialogue.
We start by annotating a corpus of spoken open-domain conversations with turn coherence ratings, the Switchboard Coherence corpus (SWBD-Coh)\footnote{The Switchboard Coherence corpus is available for download at: \url{https://github.com/alecervi/switchboard-coherence-corpus}}, and perform an analysis of the human perception of coherence in regards to DAs and entities. A multiple regression analysis shows the importance of both types of information for human rating of coherence.
Secondly, we present novel neural models for turn coherence rating that combine DAs and entities and propose to train them using response selection, a weakly supervised methodology. While previous work on response selection \cite{lowe2017training,yoshino2019dialog} is mainly based on using the entire text as input, we deliberately choose to use only entities and DAs as input to our models, in order to investigate entities and DAs as a signal for turn coherence.
Finally, we test our models on the SWBD-Coh dataset to evaluate their ability to predict turn coherence scores \footnote{The code for the models presented in this work can be found at: \url{https://github.com/alecervi/turn-coherence-rating}}.
The main contributions of this work are:
\begin{itemize}[noitemsep]
\item creating the Switchboard Coherence corpus, a novel human-annotated resource with turn coherence ratings in non-task-oriented open-domain spoken conversation;
\item investigating human perception of coherence in spoken conversation in relation to entities and DAs and their combination;
\item proposing novel neural coherence models for dialogue relying on entities and DAs;
\item exploring response selection as a training task for turn coherence rating in dialogue.
\end{itemize}
\section{Related work}
\label{sec:related}
\textbf{Coherence evaluation in text}
Coherence models trained with weakly supervised methodologies were first proposed for text with applications to the news domain and summarization \cite{barzilay2008modeling}. These models rely on the entity grid, a model that converts the entities (Noun Phrases) mentioned in the text to a sentence-by-sentence document representation in the form of a grid.
The tasks on which coherence models in this line of research are usually evaluated are \textit{sentence ordering} \cite{barzilay2008modeling}, i.e., ranking original documents as more coherent than the same documents with the order of all sentences randomly permuted, and \textit{insertion}, i.e., ranking original documents as more coherent than documents with only one sentence randomly misplaced.
These tasks are still considered standard to this day and found wide applications, especially for text \cite{farag2018neural,clark2018neural}. Recent models proposed for these tasks are based on Convolutional Neural Networks \cite{nguyen2017neural}, also applied to thread reconstruction \cite{joty2018coherence}, while the current State-of-the-art is based on a combination of bidirectional Long Short-Term Memory encoders and convolution-pooling layers \cite{moon2019unified}.
These tasks, however, consider documents as-a-whole and rely mainly on entities information. \\
\textbf{Coherence evaluation in dialogue}
Models for dialogue coherence evaluation have mainly been explored using supervised approaches, i.e., training on corpora with human annotations for coherence, mostly at the turn level \cite{higashinaka2014evaluating,gandhe2016semi,venkateshevaluating, lowe2016evaluation, yi2019towards}.
Different approaches tried to apply the standard coherence tasks to conversational domains such as dialogue and threads, but mainly considering the evaluation of dialogues as-a-whole \cite{purandare2008analyzing,elsner2011disentangling,cervone2018coherence, vakulenko2018measuring,joty2018coherence,mesgar2019neural, zhou2019hierarchical}.
In particular, \citet{cervone2018coherence} found that discrimination might be over-simplistic for dialogue coherence evaluation when considering Dialogue Act (DA) information.
In this work, we propose a novel framework to model entities and DAs information for turn coherence prediction using a weakly supervised training methodology. Furthermore, our focus is on predicting coherence of single turns rather than entire dialogues. \\
\textbf{Response Selection}
As a task, response selection has become a standard \cite{lowe2017training,yoshino2019dialog, kumar2019practical} for training both task-oriented and non-task-oriented retrieval-based dialogue models. The task proved to be useful for evaluating models in task-oriented (Ubuntu), social media threads (Twitter Corpus), and movie dialogues (SubTle Corpus) \cite{lowe2016evaluation}.
Recently the task has also been proposed for pre-training models for task-oriented dialogue \cite{henderson-etal-2019-training} and for Dialogue Act tagging \cite{mehri2019pretraining}.
In this work, we investigate response selection as a task for training coherence rating models for spoken dialogue. Additionally, while response selection models are usually based on the entire text as input \cite{lowe2017training}, we rely solely on entities and DAs information, in order to investigate their effect on turn coherence perception.
\section{Methodology}
In this work, we are interested in the relation between Dialogue Acts (DAs) and entities and how they can be modelled to train automatic predictors of next turn coherence in non-task-based dialogue.
Our hypothesis is that both entities and DAs are useful to predict the coherence of the next turn.
In order to verify such hypothesis, we first perform an analysis of entities and DAs patterns of distribution in the Switchboard Coherence (SWBD-Coh) corpus, a novel dataset of human-human telephone conversations from Switchboard annotated with human coherence ratings per turn.
Secondly, we hypothesize that we can model entities and DAs to predict next turn coherence ratings.
Rather than using supervised data for coherence prediction, we use a weakly supervised training methodology, i.e. training on the task of response selection (which proved useful for other dialogue tasks \cite{henderson-etal-2019-training}) and testing on coherence ratings.
In response selection given a \textit{context}, i.e. the history of the dialogue up to the current turn, and a \textit{list of next turn candidates}, models are asked to rank candidates according to their appropriateness with the previous dialogue history.
The positive training samples for this task are automatically generated by randomly selecting a given turn in a dialogue, and considering this turn as a positive (coherent) example with the current history of the conversation (the context).
Negative samples are generated by selecting other random dialogue turns, assuming that they will mostly be not appropriate as the next turn in the dialogue.
In particular, we investigate two methodologies to generate negative samples from the training data automatically:\\
\textbf{Internal swap}: a random turn is selected from a subsequent part of the same conversation. We assume this task to be harder for coherence evaluation since typically conversations do not have radical topic shifts. \\
\textbf{External swap}: a random turn is selected from other conversations. We assume this task to be easier given the probable shifts in topic.
In our first set of experiments, we thus train our models on response selection.
One of the possible shortcomings of the data generation procedure used in response selection, however, is the amount of false negatives.
Although it is assumed that the majority of negative samples generated with this methodology will not be appropriate for the context, there could still be cases in which they are.
In order to verify the performance of our models based on DAs and entities to predict real human coherence judgments, in our second set of experiments models are tested on SWBD-Coh. Analogously to response selection, in turn coherence rating models need to rank next turn candidates given the history of the dialogue. In this case, however, the ranking is not binary but is rather based on a graded coherence rating given by humans for next turn candidates (for further details on the SWBD-Coh corpus see Section \ref{sec:data}).
\begin{figure*}[ht]
\includegraphics[width=\textwidth]{NextTurnCohInput11.png}
\caption{A source \textbf{dialogue} (at the center of the figure) is transformed into a \textbf{grid representation} (left) and into a \textbf{linearized representation} (right). In the grid representation, entities and Dialogue Acts (DAs) are transformed into feature vectors and can then be concatenated. Our linearized representation, i.e. the input to our neural models, shows 3 different possibilities: one where we only consider entity features at the turn level (top-left), another one which considers only DA features (top-right), and a joined one where DAs and entities are combined (bottom).}
\label{fig:input}
\vspace{-0.1cm}
\end{figure*}
\section{Data}
\label{sec:data}
\begin{table}
\centering
\scalebox{0.95}{
\begin{tabularx}{\columnwidth}{llll}
\hline
& \textbf{Train} & \textbf{Dev} & \textbf{Test} \\
\hline
No. source dialogues & 740 & 184 & 231 \\
No. insertion points & 7400 & 1840 & 2310 \\
No. pos/neg pairs & 66600 & 16560 & 20790 \\
\hline
\end{tabularx}
}
\caption{Train, development and test data size for response selection for both Internal and External Swap.}
\label{tbl:datatrain}
\end{table}
The dataset chosen for our experiments is the Switchboard Dialogue Act corpus \cite{stolcke2000dialogue} (SWBD-DA), a subset of Switchboard annotated with DA information. The Switchboard corpus is a collection of human--human dyadic telephone conversations where speakers were asked to discuss a given topic.
This dataset was chosen both to ensure comparability with previous work on dialogue coherence and because it is open-domain. Also, this corpus has DA annotations. Interestingly, SWBD-DA is a real-world (transcribed) spoken corpus, so we have sudden topic changes, overlap speech, disfluencies and other typical characteristics of spoken interaction. Since our goal was to study coherence in a real-world spoken dialogue setting, rather than removing these features as errors, we considered them an integral part of spoken conversations and did not remove them.
\paragraph{Response Selection}
Source dialogues are split into train, validation, and test sets (see Table \ref{tbl:datatrain}) using the same distribution as \citet{cervone2018coherence}.
For each dialogue, we randomly choose ten insertion points. Each insertion point is composed by a context (dialogue history up to that point) and the original turn following that context (regarded as positive).
In order to have 10 next turn candidates, for each insertion point 9 adversarial turns (regarded as negatives) are then randomly selected either from subsequent parts of the dialogue, i.e. Internal Swap (IS), or from other dialogues, i.e. External Swap (ES), within the same data subset, so that for example external adversarial turns for training are only taken from other source dialogues in the training set.
\paragraph{Switchboard Coherence corpus}
The dataset for turn coherence rating, the Switchboard Coherence corpus (SWBD-Coh), was created using as source dialogues the ones from SWBD-DA which are in the testset of \citet{cervone2018coherence}. The data were annotated using Amazon Mechanical Turk (AMT). 1000 insertion points were randomly selected, following the constraints that the context (dialogue history up to the original turn) could be between 1 and 10 turns length.
Since in this task we want to evaluate the coherence of a given turn with the previous dialogue history, 1 turn of context was the minimum required. We set the maximum length to 10 turns to reduce annotation time.
For each insertion point, six adversarial turns were randomly selected, besides the original one (3 using the IS methodology, 3 using the ES one) for a total of 7 turn candidates. Overall the SWBD-Coh dataset is thus composed of 7000 pairs (1000 contexts $\times$ 7 turns).
\\
Each context and turns pair was annotated by 5 AMT workers with coherence ratings. More specifically, for each dialogue workers were presented with the dialogue history up to the insertion point and the next turn candidates (randomly shuffled). Workers were asked to rate on a scale of 1 (not coherent), 2 (not sure it fits) to 3 (coherent) how much each response makes sense as the next natural turn in the dialogue. All workers (37) who annotated the dataset were first evaluated on a common subset of 5 dialogues where they had an average Weighted Kappa agreement with quadratic weights with two gold (internal) annotators of $\kappa=0.659$ (min: 0.425, max: 0.809, STD: 0.101) and among each other an average leave-one-out correlation of $\rho=0.78$ (i.e. correlating the scores of each worker with mean scores of all other workers who annotated the same data), following the approach used in other coherence rating datasets \citep{barzilay2008modeling, lapata2006automatic}. \footnote{More details about our data collection procedure are available in Appendix \ref{sec:appendixDataCollection}.}
Scores for each candidate turn were then averaged across all annotators. Original turns were regarded on average as more coherent ($\mu=2.6$, SD$=0.5$) than adversarial turns, while turns generated with IS were considered more coherent ($\mu=1.8$, SD$=0.7$) than the ones generated via ES ($\mu=1.4$, SD$=0.6$).
\section{Data analysis}
\label{sec:data_analysis}
In this section, we analyse the Switchboard Coherence (SWBD-Coh) dataset in regards to the distribution of Dialogue Acts (DAs) and entities. In particular, we are interested in analysing which features might affect human judgement of coherence of a given next turn candidate. For entities, we analyse two features: the number of entities mentioned in the next turn candidate that overlap with entities introduced in the context and the number of novel entities introduced in the turn. Additionally, we create a binary feature for each DA type that registers the presence of that DA in the turn candidate.
We use multiple regression analysis to verify how these different features correlate with human coherence ratings. Table \ref{tbl:dataAnalysisMCC}, reports the Multiple Correlation Coefficient (MCC) of regression models using R squared and Adjusted R squared \cite{theil1961economic}, adjusted for the bias from the number of predictors compared to the sample size.
The results of our analysis indicate that the best MCC, 0.41 when calculated with the Adjusted R squared, is achieved when combining all features, both from entities and DAs.
Moreover, in the lower part of Table \ref{tbl:dataAnalysisMCC} we report some of the features that proved to be the most relevant for predicting human coherence ratings.
In general, it seems that while the entities overlapping the previous context seems to affect positively human coherence judgements, the DAs that most affect ratings do so in a negative way and seem to be mostly contentful DAs, such as \textit{statement-opinion}, rather than DAs which typically present no entities, such as \textit{acknowledge}. Our interpretation is that, in cases when there are no overlapping entities with the context, these DAs might signal explicit examples of incoherence by introducing unrelated entities.
\begin{table}
\centering
\setlength{\tabcolsep}{2.5pt}
\scalebox{0.95}{
\begin{tabularx}{\columnwidth}{lll}
\hline
& \heading{\textbf{MCC$R^{2}$}} & \heading{\textbf{MCC$AR^{2}$}} \\
\hline
Entities & \heading{0.27} & \heading{0.26} \\
DAs & \heading{0.34} & \heading{0.29} \\
All (Entities + DAs) & \heading{\textbf{0.45}} & \heading{\textbf{0.41}} \\
\hline\hline
\textit{Relevant features in All} & \heading{\textit{Coeff.}} & \heading{\textit{Sign.}} \\
\hline
Overlapping entities & \heading{0.26} & \heading{**} \\
DA: decl. yes-no-question & \heading{-0.48} & \heading{*} \\
DA: statement-opinion & \heading{-0.31} & \heading{**} \\
DA: statement-non-opinion & \heading{-0.30} & \heading{**} \\
DA: acknowledge & \heading{0.27} & \heading{**} \\
\hline
\end{tabularx}
}
\caption{Multiple Correlation Coefficients (MCC) from R squared ($R^{2}$) and Adjusted R squared ($AR^{2}$) of different multiple regression models that predict human coherence ratings for candidate turns given a dialogue context (turn coherence rating task) on the Switchboard Coherence corpus. Additionally, we report coefficients and significance (where * denotes $.05\geq$$p$$\geq.01$ and ** $p<.01$) of some relevant features for the best-performing model (All).}
\label{tbl:dataAnalysisMCC}
\end{table}
\section{Models}
We model dialogue coherence by focusing on two features that have been closely associated to coherence in previous literature: the entities mentioned and the speakers' intents, modelled as Dialogue Acts (DAs), in a conversation.
Our models explore both the respective roles of entities and DAs and their combination to predict dialogue coherence.
We investigate both standard coherence models based on Support Vector Machines (SVM) and propose novel neural ones.
\subsection{SVM models}
The entity grid model \cite{barzilay2008modeling} relies on the assumption that transitions from one syntactic role to another of the same entities across different sentences of a text indicate local coherence patterns. This assumption is formalized by representing a text (in our case, a dialogue) as a grid, as shown in Figure \ref{fig:input}. For each turn of the dialogue we extract the entities, i.e. Noun Phrases (NPs), and their respective grammatical roles, i.e. whether the entity in that turn is subject ($S$), direct object ($O$), neither ($X$), or it is not present ($-$).
Each row of the grid represents a turn in the dialogue, while each column represents one entity (in Figure \ref{fig:input}, for example, the first turn of speaker A is represented by the first row of the grid $O--$). Using this representation, we can derive feature vectors to be used as input for Machine Learning models by extracting probabilities of all role transitions for each column.
More formally, the coherence score of a dialogue $D$ in the entity grid approach can be modelled as a probability distribution over transition sequences for each entity $e$ from one grammatical role $r$ to another for all turns $t$ up to a given history $h$ (see Eq. 4 in \citet{lapata2005automatic}):
\begin{equation}
\small
p_{cohEnt}(D) \approx \frac{1}{m\cdot n} \prod_{e=1}^{m}\prod_{t=1}^{n}
p(r_{t,e}|r_{(t-h),e}...r_{(t-1),e})
\end{equation}
The probabilities for each column (entity) are normalized by the column length $n$ (number of turns in the dialogue) and the ones for the entire dialogue by the number of rows $m$ (number of entities in the dialogue). In this way, we obtain the feature vectors shown in Figure \ref{fig:input} where each possible roles transition of a predefined length (e.g. $O-$) is associated with a probability. These feature vectors are then given as input to a Support Vector Machine (SVM) in the original model.
Following \citet{cervone2018coherence}, we can use the same approach to construct similar feature vectors for DAs information:
\begin{equation}
\small
p_{cohDA}(D) \approx \frac{1}{n} \prod_{i=1}^{n}p(d_{i}|d_{(i-h)}...d_{(i-1)})
\end{equation}
Here the coherence score of a dialogue is given by the probability of the entire sequence of DAs ($d$) for the whole dialogue, normalized by column length ($n$), i.e. the number of DAs for each turn.
The joint model, the one combining entity and DA information, concatenates feature vectors obtained from both. While other ways of combining DA and entities have been explored in \citet{cervone2018coherence}, the authors report that practically a concatenation resulted in the best performances across all tasks, probably due to data sparsity issues.
Indeed among the limitations of the entity grid, there is data sparsity: for example for an entity appearing only in the last turn of a dialogue we need to add a column to the grid which will be mostly containing ``empty'' $--$ transitions (see \textit{friends} in Figure \ref{fig:input}).
Another problem of this approach is the fact that the model is not lexicalized since we only keep role transitions when computing the feature vectors for the entities. Furthermore, the model makes the simplifying assumption that columns, thus entities, are independent from each other.
\subsection{Neural models}
Our neural coherence models for dialogue are based on bidirectional Gated Recurrent Units (biGRU).
While other neural coherence models \cite{nguyen2017neural,joty2018coherence} rely directly on the grid representation from \citet{barzilay2008modeling}, we explore a novel way to encode the dialogue structure.
The input to our biGRUs is a sequential representation of the dialogue.
\subsubsection{Sequential input representation}
We linearize the structure of a dialogue composed by entities, DAs and turns into flat representations for our neural models, as in Figure \ref{fig:input}. These representations can then be mapped to an embedding layer and joined via concatenation.
We consider three cases: (i) the case in which we model entity features; (ii) the one in which we consider DAs information; (iii) the one in which we combine both.
\paragraph{Entities encodings}
In our approach, entities are Noun Phrases, as in the entity grid approach.
For each dialogue, we consider the sequence of entities ordered according to their appearance in the conversation (see Figure \ref{fig:input}).
Entities are represented either by their grammatical roles \textit{ent\textsubscript{\textit{role}}} in the dialogue (using the same role vocabulary $V_{r}$ of the original grid), their corresponding words \textit{ent\textsubscript{\textit{word}}} (from a vocabulary $V_{w}$), or by both.
Another feature which can be added to this representation is the \textit{turn} (whether A or B is talking).
This feature could be useful to encode the dyadic structure of the dialogue and how this might be related to entity mentions. In order to better encode the boundaries of speaker turns, turns are mapped to the IOB2 format (where the Outside token is removed because naturally never used for turns), for a resulting turn vocabulary $V_{t}$ size of 4 tags (2 speakers x 2 IOB tags used). Special tokens ($<$no\_ent$>$) are added to both $V_{w}$ and $V_{r}$ for cases in which turns do not present any entities.
\paragraph{DAs encodings}
In case we consider only \textit{DAs} features, our input representation becomes a sequence of DAs for the whole dialogue history so far, drawn from a vocabulary $V_{d}$. Also, in this case, \textit{turn} features can be added to mark the turn-wise structure of the DA sequence, using the same vocabulary $V_{t}$ previously described.
\paragraph{Entities + DAs encodings}
We combine entities and DAs by considering the sequence of entities in order of their appearance within each DA and encoding DAs into IOB2 format, as previously done for turn features. In this setting, thus, the vocabulary $V_{d}$ has double the size, compared to the setting where we consider only DAs. Analogously to previous settings, turn features can be added to encode turn boundaries.
It can be noticed how our representation is less sparse compared to both the original grid \cite{barzilay2008modeling} and recently proposed models \cite{nguyen2017neural}, which take as input grid columns directly. Furthermore, compared to the original grid, our representation is lexicalized.
\subsubsection{Architecture}
\begin{figure}[ht]
\includegraphics[width=6.9cm]{biGRUArch.png}
\caption{Our proposed architecture based on bidirectional GRUs with input entity word embedding (\textit{ent\textsubscript{\textit{word}}}) and grammatical role (\textit{ent\textsubscript{\textit{role}}}), Dialogue Act (\textit{DA}) and speaker \textit{turn} features.}
\label{fig:architecture}
\end{figure}
The architecture of our models is shown in Figure \ref{fig:architecture}.
In the first layer of the network each input feature (\textit{ent\textsubscript{\textit{role}}}, \textit{ent\textsubscript{\textit{word}}}, \textit{DA}, \textit{turn}) is mapped to a $d$-dimensional dense vector by looking up into their respective embedding matrix $\textbf{E}$, one per feature type. All features vectors obtained can then be combined using concatenation.
This vector is then recursively passed to the bidirectional GRU layers and then to a mean pooling layer. Finally, the output is passed through a feed-forward neural network with one hidden layer and ReLU as non-linearity.
Our models are trained using a Margin-ranking loss with a margin of 0.5 using the following equation:
\begin{equation}
\textup{loss}(x,y) = \textup{max}(0, -y*(x1-x2) + \textup{margin})
\end{equation}
where $x1$ and $x2$ are respectively the original dialogue and the adversarial one and $y=1$.
In this way, the model is asked to rank the original dialogue higher (more coherent) than the adversarial one.
The model is trained by Stochastic Gradient Descent, using the Adam update rule \cite{DBLP:journals/corr/KingmaB14}.
\section{Experimental set-up}
\label{sec:expsetup}
\textbf{Preprocessing} Entities, i.e. Noun Phrases (NPs), and their syntactic roles were extracted and preprocessed with \citet{cervone2018coherence}'s pipeline \footnote{\url{https://github.com/alecervi/Coherence-models-for-dialogue}}. Following the original entity grid formulation \cite{barzilay2008modeling}, only NPs heads were kept. The DAs are taken from annotations on SWBD-DA (using the standard reduction to 42 tags compared to the DAMSL ones).
\paragraph{Evaluation}
For evaluating response selection, we use pairwise Accuracy, the metric used in standard coherence tasks, which evaluates the ability of the model to rank original turns higher than each adversarial one. However, this metric is not indicative of the global ranking of all candidate turns for a given context. For this reason, we add two ranking metrics to evaluate our models: Mean Reciprocal Rank (MRR), which evaluates the average of reciprocal ranks of all candidate turns for a context, and Recall at One (R@1) and Two (R@2), also used in previous work on response selection \cite{lowe2017training,zhou2018multi} to assess the ability of the model to rank original turns respectively within the first or second rank among all candidates. \\
Compared to response selection, where we have a binary choice between coherent and negative turns, in turn coherence rating, we have a set of candidate turns each associated to a coherence score. In this case, we use Accuracy, MRR, R@1 and Normalized Discounted Cumulative Gain (nDCG) to evaluate our models. Accuracy was computed only for cases in which the rating of the turn was not identical across two candidate turns. MRR and R@1 were computed dynamically, that is considering the turn with the highest score within that particular context as the best one in the rank.
The nDCG metric \cite{jarvelin2002cumulated} assesses the gain of a candidate according to its rank among all candidates. Compared to previous metrics, nDCG allows taking into account the relevance (in our case, the coherence score) of candidates.
For all metrics considered, if our models predicts the same score for two candidates, we always assume models made a mistake, i.e. among candidates with the same predicted score positive examples are ranked after the negative ones.
\begin{table*}
\setlength{\tabcolsep}{5pt}
\centering
\scalebox{0.94}{
\begin{tabularx}{\textwidth}{lrrrr|rrrr}
\cline{2-9}
& \multicolumn{4}{c}{\textbf{Internal Swap}}
& \multicolumn{4}{c}{\textbf{External Swap}}
\\
\cline{2-9}
& \textbf{Acc.}
& \textbf{MRR}
& \textbf{R@1}
& \textbf{R@2}
& \textbf{Acc.}
& \textbf{MRR}
& \textbf{R@1}
& \textbf{R@2}\\
\hline
Random
& 50.0 & 0.293 & 0.099 & 0.198
& 50.0 & 0.293 & 0.099 & 0.198 \\
\hline
\hline
SVM ent\textsubscript{\textit{role}} (Entity Grid)
& 36.6 & 0.260 & 0.103 & 0.178
& 39.5 & 0.246 & 0.096 & 0.126 \\
SVM DA \cite{cervone2018coherence}
& 60.6 & 0.398 & 0.206 & 0.335
& 61.3 & 0.403 & 0.212 & 0.346 \\
SVM ent\textsubscript{\textit{role}} + DA \cite{cervone2018coherence}
& 62.7 & 0.417 & 0.222 & 0.365
& 64.3 & 0.437 & 0.251 & 0.380 \\
\hline
\hline
biGRU ent\textsubscript{\textit{role}}
& 41.8 & 0.294 & 0.120 & 0.217
& 45.5 & 0.293 & 0.117 & 0.210 \\
biGRU ent\textsubscript{\textit{role}} + turn
& 43.3 & 0.295 & 0.120 & 0.214 %
& 45.9 & 0.293 & 0.115 & 0.211 \\
biGRU ent\textsubscript{\textit{word}}
& 47.8 & 0.324 & 0.151 & 0.252 %
& 56.4 & 0.397 & 0.236 & 0.337 \\
biGRU ent\textsubscript{\textit{word}} + turn
& 49.0 & 0.331 & 0.162 & 0.255 %
& 56.9 & 0.400 & 0.241 & 0.341 \\
biGRU ent\textsubscript{\textit{role}} + ent\textsubscript{\textit{word}} + turn
& 48.6 & 0.327 & 0.156 & 0.253 %
& 56.1 & 0.394 & 0.232 & 0.338 \\
\hline
biGRU DA
& 72.4 & 0.484 & 0.276 & 0.443 %
& 72.6 & 0.486 & 0.278 & 0.447 \\
biGRU DA + turn
& 74.0 & 0.501 & 0.297 & 0.464 %
& 74.1 & 0.508 & 0.305 & 0.475 \\
\hline
biGRU ent\textsubscript{\textit{word}} + DA + turn
& \textbf{75.1} & 0.520 & \textbf{0.321} & 0.484 %
& \textbf{77.3} & \textbf{0.550} & \textbf{0.355} & \textbf{0.530} \\
biGRU all
& 75.0 & \textbf{0.521} & \textbf{0.321} & \textbf{0.489} %
& 77.2 & 0.549 & 0.354 & 0.529 \\
\hline
\end{tabularx}
}
\caption{Average (5 runs) of Accuracy (Acc.), Mean Reciprocal Rank (MRR) and Recall at one (R@1) and two (R@2) for response selection using both data generation methodologies (Internal and External Swap) on Switchboard.
}
\label{tbl:pred}
\end{table*}
\paragraph{Models' settings}
Grid models, based on SVMs, were trained with default parameters using SVM\textsuperscript{light} preference kernel \cite{joachims2002optimizing}) as in the original model \cite{barzilay2008modeling}.
For saliency, i.e. the possibility of filtering entities according to their frequency, and transitions length we follow the default original grid parameters (saliency:1, transitions length:2).
For neural models, implemented in Pytorch \cite{paszke2019pytorch}, parameters were kept the same across all models to ensure comparability. The learning rate was set to 0.0005, batch size to 32, with two hidden biGRU layers of size 512.
Embedding sizes for all features were set to 50--dimensions, except for word embeddings which had dimension 300. Models run for a maximum of 30 epochs with early stopping, based on the best MRR score on the development set.
\section{Results}
\label{sec:results}
\begin{table}
\setlength{\tabcolsep}{1.9pt}
\scalebox{0.92}{
\begin{tabularx}{\columnwidth}{lrrrrrr}
\cline{2-6}
& \textbf{Train}
& \textbf{Acc.}
& \textbf{MRR}
& \textbf{R@1}
& \textbf{nDCG}
\\
\cline{1-6}
Random &
& 50.0 & 0.479 & 0.234 & 0.645 \\
\cline{1-6}
biGRU & IS
& 42.7 & 0.395 & 0.174 & 0.621 \\
ent\textsubscript{\textit{word}} + turn & ES
& 50.4 & 0.444 & 0.229 & 0.679 \\
\cline{1-6}
biGRU & IS
& 56.0 & 0.553 & 0.326 & 0.717 \\
DA + turn & ES
& 56.0 & 0.558 & 0.337 & 0.725 \\
\cline{1-6}
biGRU & IS
& 58.5 & 0.575 & 0.358 & 0.738 \\
ent\textsubscript{\textit{word}} + DA + turn & ES
& \textbf{61.1} & \textbf{0.583} & \textbf{0.369} & \textbf{0.760} \\
\cline{1-6}
\end{tabularx}
}
\caption{Average (5 runs) of Accuracy (Acc.), Mean Reciprocal Rank (MRR), Recall at one (R@1) and Normalized Discounted Cumulative Gain (nDCG) for turn coherence rating for models trained using either Internal (IS) or External Swap (ES) on the Switchboard Coherence corpus.}
\label{tbl:humanresult}
\end{table}
In this section, we report the results of our models for response selection. The best performing models on response selection are then evaluated on the turn coherence rating task using the Switchboard Coherence (SWBD-Coh) corpus as testset. For both tasks we compare our models to a random baseline. All reported results for neural models are averaged across 5 runs with different seeds.
\paragraph{Response selection}
The results for response selection are reported in Table \ref{tbl:pred}.
Neural models seem to capture better turn-level coherence compared to classic grid SVM-based approaches. In both data generation methodologies, Internal (IS) and External Swap (ES), SVM coherence models are outperformed by neural ones for all metrics considered.
As expected, entity features (ent\textsubscript{\textit{role}}, ent\textsubscript{\textit{word}}) play a more prominent role in ES compared to IS.
In both cases, entity features seem to be better captured by neural models relying on our proposed input representation.
When considering lexical information (ent\textsubscript{\textit{word}}), however, ent\textsubscript{\textit{role}} features seem less relevant. This might be due to the fact that spoken dialogue has usually less complex syntactic structures compared to written text. Furthermore, parsers are usually trained on written text, and thus might be more error-prone when applied to dialogue where there are disfluencies, sudden changes of topics, etc.
We notice that DAs alone (without entity information) play an important role in both IS and ES.
Turn features capturing speaker information seem helpful for both DAs and entities.
\\
In general, the combination of DAs and entities gives the best results both in SVM and neural models for both tasks, with the best performing one being the model combining ent\textsubscript{\textit{word}}, DA and turn features and without ent\textsubscript{\textit{role}}.
Additionally, if we compare the IS setting to ES in terms of best MRR, Accuracy and Recall, the former seems more difficult. This confirms our expectations that IS might be an harder task for coherence
\paragraph{Turn coherence rating}
A selection of best performing models for entities, DAs and their combination were tested on the SWBD-Coh dataset. Table \ref{tbl:humanresult} shows models' results under both training conditions, i.e. either using IS or ES data.
The lowest performing model seems to be the one based solely on entity features (ent\textsubscript{\textit{word}} $+$ turn), while models combining DA with entities information (ent\textsubscript{\textit{word}} $+$ DA $+$ turn) are the best performing ones. Additionally, models trained on ES data perform better than those trained on IS across all conditions.
\section{Conclusions}
\label{sec:conclusions}
In this work, we investigate how entities and Dialogue Acts (DAs) are related to human perception of turn coherence in dialogue. In order to do so, we create a novel dataset, the Switchboard Coherence (SWBD-Coh) corpus, of transcribed open-domain spoken dialogues annotated with turn coherence ratings. A statistical analysis of the corpus confirms how both entities and DAs affect human judgements of turn coherence in dialogue, especially when combined.
Motivated by these findings, we experiment with different models relying on entities and DAs to automatically predict turn coherence, i.e. standard coherence models and novel neural ones. In particular, we propose a less sparse alternative, compared to the entity grid, to encode entities and DAs information.
Rather than using data annotated explicitly for the task, i.e. coherence prediction, we explore two response selection methodologies for training.
We find that our newly proposed architecture outperforms standard ones in response selection.
Finally, we test our models on the SWBD-Coh corpus in order to evaluate their ability to predict real human turn coherence ratings. Crucially, we find that the combination of DAs and entities gives the best performances.
For the future work, it would be interesting to investigate how to apply large pretrained models to our task, such as BERT \cite{devlin2019bert}. While pretrained models have recently been successfully explored for text-based response selection \cite{kim2019eighth, henderson2019training}, integrating them with our proposed input representation is not a straightforward task since such models typically rely on the whole textual context, while our models do not.
While there is still much to understand regarding turn coherence in dialogue, we believe our work could be a first step towards uncovering the relation between DAs and entities in open-domain spoken dialogue. Moreover, we believe that the SWBD-Coh corpus could become a useful resource for the community to study coherence in open-domain spoken dialogue.
\section*{Acknowledgments}
The research leading to these results has received funding from the European Union – H2020 Programme under grant agreement 826266: COADAPT.
| {'timestamp': '2020-06-19T02:04:02', 'yymm': '2006', 'arxiv_id': '2006.10157', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10157'} | arxiv |
\section{Advanced Pretext Tasks on Graphs}\label{sec:ssladvanced}
Based on our analysis from Section~\ref{sec:sslstudy}, constructing a self-supervised pretext task that helps the downstream task from only structure or attribute information is not always able to find additional improvement, since such information could have already been partially maintained by GCN. Thus, given that there can be different downstream tasks and associated information (e.g., a small set of labeled nodes), we can directly exploit the task specific self-supervised information referred as {\it SelfTask} in this work. In particular, we will develop various pretext tasks of {\it SelfTask} that extend the idea to maintain regular task equivalence defined over the set of class labels.
\subsection{SelfTask: Distance2Labeled}
We first investigate modifying one of the best performing global structure pretext tasks, {\it Distance2Cluster} to take into consideration information from the labeled nodes. To incorporate label information with graph structure information, we propose to predict the distance vector from each node to the labeled nodes (i.e., $\mathcal{V}_L$) as the SSL task. For class $c_j\in\{1,...,K\}$ and unlabeled node $v_i\in \mathcal{V}_U$, we calculate the average, minimum and maximum shortest path length from $v_i$ to all labeled nodes in class $c_i$. Thus, the distance vector for $v_i$ can be denoted as ${\bf d}_i\in\mathbb{R}^{3K}$. Formally, the SSL objective can be formulated as a multiple regression problem as follows,
\begin{equation}
\mathcal{L}_{self}( {\theta}^{\prime}, {\bf A}, {\bf X}, \mathcal{D}_U) = \frac{1}{\vert{\mathcal{D}_U}\vert}\sum_{ v_i \in \mathcal{D}_U} \|f_{\theta^{\prime}}(\mathcal{G})_{v_i} - {\bf d}_{i}\|^2.
\end{equation}
This formulation can be seen as a way of strengthening the global structure pretext, but mostly focused on leveraging the task specific information of labeled nodes.
\subsection{SelfTask: ContextLabel}
In Section~\ref{sec:sslstudy}, we analyzed the types of similarity that GNNs are naturally positioned to maintain and how our basic pretext tasks are able to further improve them, namely those based on structure and attributes. This led to our definition of regular task equivalence, which if maintained would imply that nodes who have neighbors with similar labels should themselves be similar in the embedding space. However, in the node classification task this would require us to have labels for our neighbors so that we can harness this new concept of similarity in self-supervised pretext tasks. However, labels often are sparse for the task of node classification. Therefore, we propose to use a similarity based function. It can utilize structure, attributes, and the current labeled nodes to construct a neighbor label distribution context vector ${\bf \bar{y}}_i$ for each node as follows,
\begin{align}
f_s({\bf A}, {\bf X}, \mathcal{D}_L, \mathcal{V}_U) \rightarrow \{ {\bf \bar{y}}_i | v_i \in \mathcal{V}_U\},
\end{align}
More specifically, we define the context of node $v_i$ as all nodes within its $k$-hop neighbors where the $c$-th element of the label distribution vector can be defined as,
\begin{equation}
\label{eq:contextlabel}
{\bf \bar{y}}_{ic} = \frac{|\mathcal{N}_{\mathcal{V}_L}(v_i,c)| + |\mathcal{N}_{\mathcal{V}_U}(v_i,c)|}{|\mathcal{N}_{\mathcal{V}_L}(v_i)| + |\mathcal{N}_{\mathcal{V}_U}(v_i)|}, c={1\ldots{}K},
\end{equation}
where $\mathcal{N}_{\mathcal{V}_U}(v_i)$ denotes the neighborhood set from $\mathcal{V}_U$ of node $v_i$, $\mathcal{N}_{\mathcal{V}_U}(v_i,c)$ then denotes only those in the neighborhood set having been assigned class $c$
(with similar definitions for $\mathcal{V}_L$ neighborhood sets), and $\mathcal{D}_U=(\mathcal{V}_U, \{ {\bf \bar{y}}_i | v_i \in \mathcal{V}_U\} )$.
Furthermore, the objective function for this pretext task based on the concept of regular task equivalence can then be formulated as,
\begin{equation}
\label{eq:contextobj}
\mathcal{L}_{self}( {\theta}^{\prime}, {\bf A}, {\bf X}, \mathcal{D}_U) = \frac{1}{\vert{\mathcal{D}_U}\vert}\sum_{ v_i \in \mathcal{D}_U} \|f_{\theta^{\prime}}(\mathcal{G})_{v_i} - {\bf \bar{y}}_{i}\|^2.
\end{equation}
Several methods can be selected for extending the label information to all unlabeled nodes for $f_s$. One way is to use a method based on structure equivalence where we elect to use Label Propagation (LP)~\cite{zhu2003semi} since it only uses {\bf A} (although others like shortest path could be extended here as used in {\it Distance2Label}). Another way is using both structure equivalence and attribute equivalence where we use the Iterative Classification Algorithm (ICA)~\cite{sen2008collective} that utilizes both {\bf A} and {\bf X}. The neighbor label distribution context vectors $\{{\bf \bar{y}}_i | v_i \in \mathcal{V}_U\} $ could be noisy due to the inclusion of weak labels
produced by $f_s$ (e.g., when using LP or ICA). Next we introduce two methods to improve {\it ContextLabel}.
\subsection{SelfTask: EnsembleLabel}
There are various ways to define the similarity based function $f_s$ such as LP and ICA. Thus, one possible way to improve {\it ContextLabel} is to ensemble various functions $f_s$. If we let the class probabilities for a node $v_i$ to be $\sigma_{LP}(v_i)$ and $\sigma_{ICA}(v_i)$, respectively when using LP and ICA inside $f_s$, then we can combine them to select $\bar{y}_i$ as,
\begin{equation}
\bar{y}_i=\operatorname{argmax}_{c} \sigma_{LP}(v_i) + \sigma_{ICA}(v_i), \quad c=1 \ldots K
\end{equation}
We can use the ensembled $\bar{y}$ for constructing context label distribution like Eq.~(\ref{eq:contextlabel}) and following the pretext objective defined in Eq.~(\ref{eq:contextobj}).
\subsection{SelfTask: CorrectedLabel}
We design {\it CorrectedLabel} as an alternative pretext task to enhance {\it ContextLabel} by iteratively improving the context vectors. More specifically, we take the approach of iteratively training the GNN and correcting the labels ${\bf \hat{y}}_{i}$ similar to the iterative training in \cite{han2019deep-noisy} using training and correction phases. In the training phase, we use the corrected label to build the corrected context label distribution vector for unlabeled nodes similar to Eq.~(\ref{eq:contextlabel}).
We use $\mathcal{\hat{D}}_U=(\mathcal{V}_U,\{ {\bf \hat{y}}_i | v_i \in \mathcal{V}_U\})$ to denote the unlabeled data samples with its corrected context label distribution in addition to $\mathcal{D}_U=(\mathcal{V}_U,\{ {\bf \bar{y}}_i | v_i \in \mathcal{V}_U\})$ for the SSL task.
Then GNN $f_\theta$ is trained on both the original (e.g., ${\bf \bar{y}}_{i}$) and corrected (e.g., ${\bf \hat{y}}_{i}$) context distributions where the loss can be formulated as,
\vspace{-1ex}
\begin{footnotesize}
\begin{align}
\mathcal{L}_{self}\left(\theta^{\prime}, \mathbf{A}, \mathbf{X}, \mathcal{D}_{U}, \hat{\mathcal{D}}_{U}\right) &= \frac{1}{\vert{\mathcal{D}_U}\vert}\sum_{ v_i \in \mathcal{D}_U} \|f_{\theta^{\prime}}(\mathcal{G})_{v_i} - {\bf \bar{y}}_{i}\|^2 \\
&+ \alpha \Bigg( \frac{1}{\vert{\mathcal{D}_U}\vert}\sum_{ v_i \in \mathcal{D}_U} \|f_{\theta^{\prime}}(\mathcal{G})_{v_i} - {\bf \hat{y}}_{i}\|^2 \Bigg), \nonumber
\end{align}
\end{footnotesize}
\noindent where the first and second terms are to fit the original and corrected context distributions respectively, and $\alpha$ controls the contribution from the corrected context distributions.
In the label correction phase, we employ the trained GCN to select $p$ class prototypes ${\bf Z_c}=\{{\bf z}_{c1},\dots,{\bf z}_{cp}\}$ (represented as deep features) for each category $c$, which are used to generate the corrected label. More specifically, we first randomly sample $m$ nodes in the same class to calculate their pair-wise similarity matrix ${\bf S}$ where ${\bf S}_{ij}$ is the cosine similarity between two nodes based on their embeddings. Then we define density $\rho_i$ for each node as,
\begin{equation}
\rho_{i}=\sum_{j=1}^{m} \operatorname{sign}\left({\bf S}_{i j}-S_{c}\right),
\end{equation}
where $S_c$ is a constant value (which we selected as the value ranked in top 40\% in ${\bf S}$ as suggested in~\cite{han2019deep-noisy}) and $\operatorname{sign}(x) = 1, 0,$ or $-1$ if $x >0, =0$, or $<0$, respectively. According to the formulation, a smaller $\rho$ indicates that the node is less similar to other nodes in the same class. The nodes with inconsistent labels are usually isolated from others while nodes with correct labels should be close to each other. Hence, we select the nodes with top-$p$ largest $\rho$ values as the class prototypes. Then we calculate the corrected label $\hat{y}_i\in \{1,\dots, K\}$ for node $v_i \in \hat{\mathcal{V}}_U$ as,
\begin{equation}
\hat{y}_i=\operatorname{argmax}_{c} \frac{1}{p} \sum_{l=1}^{p} \cos \left(f_{\theta^{\prime}}(\mathcal{G})_{v_i}, {\bf z}_{cl}\right), c=1 \ldots K,
\end{equation}
where $\cos(\cdot,\cdot)$ is used to denote the cosine similarity between two samples. In other words, we use the average similarity between $v_i$ and $p$ prototypes to represent the similarity between $v_i$ and the corresponding class, and then assign the class $c$ having the largest similarity to $v_i$. By iterating the two phases, the GNN can gradually learn corrected labels (e.g., $\hat{y}_i$).
\section*{Broader Impact}
\toreword{Authors are required to include a statement of the broader impact of their work, including its ethical aspects and future societal consequences.
Authors should discuss both positive and negative outcomes, if any. For instance, authors should discuss a)
who may benefit from this research, b) who may be put at disadvantage from this research, c) what are the consequences of failure of the system, and d) whether the task/method leverages
biases in the data. If authors believe this is not applicable to them, authors can simply state this.
Use unnumbered first level headings for this section, which should go at the end of the paper. {\bf Note that this section does not count towards the eight pages of content that are allowed.}}
\section{Conclusion}\label{sec:conclusion}
Applying self-supervised learning to GNNs is a cutting-edge research topic with great potential. To facilitate this line of research, we have carefully studied SSL in GNNs for the task of node classification. We first introduce various basic SSL pretext tasks for graphs and present detailed empirical study to understand when and why SSL works for GNNs and which strategy can better work with GNNs. Next, based on our insights, we propose a new direction \textit{SelfTask} to build advanced pretext tasks which further exploit task-specific self-supervised information. Extensive experiments on real-world datasets demonstrate that our advanced method achieves state-of-the-art performance. Future work can be done on exploring new pretext tasks and applying the proposed SSL strategies in pre-training graph neural networks.
\section{Experiments}\label{sec:experiments}
In this section, we evaluate the effectiveness of the proposed SelfTask pretext tasks presented in Section~\ref{sec:ssladvanced}. Before presenting our experimental results and observations, we first introduce the experimental settings.
\subsection{Experimental Settings}
To validate the proposed approaches, we conduct experiments on four benchmark datasets, including Cora, Citeseer and Pubmed~\cite{kipf2016semi} shown in Table~\ref{tab:data}, and Reddit~\cite{hamilton2017inductive}. More specifically, Reddit has 232,965 nodes, 57,307,946 edges, 210 classes, 5,414 node features and training/validation/test node split as 152,410/23,699/55,334, respectively. We note that all experiments are performed in the transductive setting.
We adopt 2-layer GCN as the backbone for node classification model, with hidden units of 128, $L_2$ regularization $5e{-4}$, dropout rate $0.5$ and learning rate $0.01$. For the SSL loss, we take out the hidden representations from the first layer of GCN and feed them through a linear layer to solve SSL pretext task. We utilize the strategy of jointing training to integrate SSL with GCNs. The weighting parameter $\lambda$ for joint training is searched from $\{1, 5, 10, 50, 100, 500\}$. The parameter $\alpha$ of {\it CorrectedLabel} is searched from $\{0.5, 0.8, 1, 1.2, 1.5\}$. For \textit{ContextLabel}, \textit{EnsembleLabel}, and \textit{CorrectedLabel}, the neighborhood range $k$ is set to 2 for Cora, Citeseer and Pubmed, and 1 for Reddit. All the experiments are repeated 10 times and we report the average accuracy with standard deviation. The hyper-parameters of all the models are tuned based on the loss and accuracy on the validation set. In addition to the vanilla 2-layer GCN~\cite{kipf2016semi}, we also include two recent SSL methods on graph neural networks as baselines -- (1) \textbf{Self-Training}~\cite{li2018deeper-selftrain}: it first trains a graph neural network and adds the most confident predictions of unlabeled data to the label set as pseudo-labels for later training; and (2) \textbf{M3S}~\cite{sun2019m3s}: it repeatedly assigns pseudo-labels and trains on augmented labeled set for $K$ times where it employs DeepCluster~\cite{caron2018deepcluster} and Self-Training to perform self-checking based on the generated pseudo-labels.
\begin{table*}[t]
\renewcommand{\arraystretch}{0.95}
\setlength{\tabcolsep}{4.5pt}
\centering
\caption{Node classification performance accuracy (\%) of integrating SSL into GNNs.}
\label{tab:performance}
\begin{threeparttable}
\begin{tabular}{ccccc}
\toprule
\textbf{Model} & \textbf{Cora} & \textbf{Citeseer} & \textbf{Pubmed} & \textbf{Reddit} \\ \midrule
\textbf{GCN} & $81.32 \pm 0.33$ & $71.53 \pm 0.27$ & $79.28 \pm 0.44$ & $94.99 \pm 0.04$ \\
\textbf{Self-Training} & $81.29 \pm 0.33$ & $72.21 \pm 0.53$ & $79.35 \pm 0.62$ & $95.00 \pm 0.03$ \\
\textbf{M3S} & $81.59 \pm 0.41$ & $71.72 \pm 0.36$ & $79.50 \pm 0.76$ & $95.18\pm0.02$ \\
\midrule
\textbf{SelfTask-Distance2Labeled}\footnote{} & $\mathbf{83.39} \pm 0.40$ & $71.64 \pm 0.28$ & $79.51 \pm 0.32$ & - \\
\textbf{SelTask-ContextLabel-LP} & $82.20 \pm 0.29$ & $71.90 \pm 0.20$ & $80.07 \pm 0.18$ & $95.32 \pm 0.02$ \\
\textbf{SelfTask-ContextLabel-ICA} & $82.76 \pm 0.46$ & $72.59 \pm 0.45$ & $82.31 \pm 0.14$ & $95.21 \pm 0.08$ \\ \midrule
\textbf{SelfTask-EnsembleLabel} & $82.85 \pm 0.51$ & $72.48 \pm 0.28$ & $81.31 \pm 0.16$ & $95.29 \pm 0.02$ \\
\textbf{SelfTask-CorrectedLabel-LP} & $82.63 \pm 0.33$ & $72.30 \pm 0.53$ & $80.16 \pm 0.30$ & $\mathbf{95.33} \pm 0.02$ \\
\textbf{SelfTask-CorrectedLabel-ICA} & $83.28 \pm 0.36$ & $\mathbf{73.04} \pm 0.35$ & $\mathbf{82.60} \pm 0.32$ & $95.25 \pm 0.09$ \\
\bottomrule
\end{tabular}
\begin{tablenotes}
\item[1] \textit{SelfTask-Distance2Labeled} is not scalable on the Reddit dataset where the labeled/unlabeled data is huge, since as defined it requires calculating the shortest path length distance from labeled data to unlabeled data.
\end{tablenotes}
\end{threeparttable}
\vspace{-0.2in}
\end{table*}
\subsection{Performance Comparison}
The node classification performance is demonstrated in Table~\ref{tab:performance}. We first note that most of pretext tasks of SelfTask outperform existing SSL methods, i.e., Self-Training and M3S. This observation not only demonstrates the effectiveness of SelfTask but also indicates that the deep insights from the preliminary analysis have tremendous potentials to inspire new pretext tasks on graphs. We observe that the pretext tasks based on \textit{ContextLabel} consistently improve GCN across all datasets by a large margin. For instance, \textit{SelfTask-ContextLabel-ICA} improves GCN by $1.4\%$, $1.1\%$ and $3.0\%$ on Cora, Citeseer and Pubmed datasets respectively, achieving the state-of-the-art performance. By contrast, most of the basic SSL tasks can only improve on one dataset or achieve small improvement, which demonstrates the importance of task specific information in constructing stronger pretext tasks. Moreover, label correction consistently boosts the performance of \textit{SelfTask} on all datasets while label ensemble can only boost \textit{SelfTask-ContextLabel-LP} for most of the time. This observation indicates that label correction can better extend label information to unlabeled nodes than ensemble. However, label correction is much less inefficient as it will optimize the process of correcting labels for unlabeled nodes. Hence, in practice, we need to balance the computational efficiency and predictive accuracy when choosing the best strategy.
\subsection{Fewer Labeled Samples}
The proposed SelfTask pretext tasks depends on the label information. In this subsection, we examine if SelfTask can still work when having a very limited number labeled samples. We randomly sampled 5 or 10 nodes per class for training and the same number of nodes for validation. All remaining labeled nodes are used testing. We repeated this process for 10 times and compare our best model, denoted as \textit{SelfTask} with GCN and M3S. Since the performance of Self-Training is always worse than that of M3S, we do not include its performance. The results are shown in Figure~\ref{fig:few-label}. As we can see from the figure, the performance of GCN drops rapidly with the decrease of labeled samples. However, \textit{SelfTask} achieves even greater improvement when the labeled samples are fewer and consistently outperforms the state-of-the-art baselines. Especially under the setting of 5 samples per class on Citeseer dataset, our proposed model improves GCN by a large margin of $7.2\%$. These observations suggest that SelfTask can be applied to the scenarios when labels are very sparse.
\begin{figure}[t]
\centering
\includegraphics[width=0.8\linewidth]{image/performance-few-labels-big.pdf}
\vskip -0.5ex
\caption{Accuracy performance with limited labeled nodes.}
\label{fig:few-label}
\end{figure}
\subsection{Parameter Analysis}
In this subsection, we explore the sensitivity of hyper-parameters for the best model, \textit{SelfTask-CorrectedLabel-ICA}. Here we alter the value of $\lambda$ and $\alpha$ to see the changes of the model in terms of test accuracy. More concretely, we vary $\lambda$ in the range of $\{0, 0.1, 0.5, 1, 5, 10, 50, 100\}$ and $\alpha$ from $0$ to $2.5$ with an interval of $0.25$. We only report the results on the Cora dataset since similar patterns are observed in other datasets. The accuracy change in terms of $\lambda$ is illustrated in Figure~\ref{fig:param-lambda}. We can see the performance of our model first increases with the increase of $\lambda$. This result supports that incorporating SSL can boost the performance of GNNs. However, when $\lambda$ is large, the performance reduces due to the overfitting on the SSL task. Figure~\ref{fig:param-alpha} shows the impact of $\alpha$. Employing label correction ($\alpha>0$) outperforms not using it ($\alpha=0$), which suggests the effectiveness of label correction.
\begin{figure}[tb]%
\centering
\subfloat[$\lambda$]{{\includegraphics[width=0.48\linewidth]{image/lambda.pdf} }\label{fig:param-lambda}}%
\subfloat[$\alpha$]{{\includegraphics[width=0.48\linewidth]{image/alpha.pdf} }\label{fig:param-alpha}}%
\qquad
\caption{Parameter analysis on Cora.}
\label{fig:param}
\vskip -0.5em
\label{fig:ablation}%
\end{figure}
\section{Basic Pretext Tasks on Graphs}\label{sec:sslinfo}
In this section, we present various types of self-supervised pretext tasks on graphs. More specifically, we investigate defining pretext tasks based upon self-supervised information from: (A) the underlying graph structure information (i.e., $\mathbf{A}$); or (B) node feature/attribute information (i.e., $\mathbf{X}$). These two directions are the most natural sources of information to develop self-supervised information for the unlabeled nodes. As there can be a variety of potential pretext tasks for graphs, we first provide detailed justifications for each of the self-supervised pretext tasks and present the details of representative methods in both (A) and (B). Thereafter, in Section~\ref{sec:ssladvanced} we present more advanced pretext tasks built upon deep insights from an empirical study in Section~\ref{sec:sslstudy}.
\subsection{Structure Information}
The first natural choice for extracting self-supervised information in the graph domain is the inherent structure behind the data. This is because unlike the image and text domains, in graphs our data instances are related (i.e., the nodes are linked together). Thus, one main direction is to construct self-supervision information for the unlabeled nodes based on their local structure information, or how they relate to the rest of the graph. In other words, the structure information for establishing self-supervised pretext tasks can be categorized into either local or global structure information.
\subsubsection{Local Structure Information}
From the local perspective of developing self-supervised information, it can either come from the node itself, or from the structural relationship that node has in its local surrounding neighborhood. In addition, the pretext task can be defined on a single node, or can be developed in a pairwise/contrastive way that involves combining/comparing the information from more than one node. Next, we present two representative examples of local structure based SSL pretext tasks considering these different aspects.
\begin{itemize}[leftmargin=*]
\item \textbf{NodeProperty}. In this task, we aim to predict the property for each node in the graph such as their degree, local node importance, and local clustering coefficient. The goal of this pretext task is to (further) encourage the GNN to learn local structure information in addition to the specific task that is being optimized. In this work, we use node degree as a representative local node property for self-supervision while leaving other node properties (or the combination) as one future work. More formally, we let $d_i = \sum_{j=1}^N{\mathbf{A}_{ij}}$ denote the degree of $v_i$ and construct the associated loss of the self-supervised pretext task as
\begin{align}
\mathcal{L}_{self}( {\theta}^{\prime}, {\bf A}, {\bf X}, \mathcal{D}_U)= \frac{1}{\vert\mathcal{D}_{U}\vert}\sum_{v_i \in \mathcal{D}_{U}} (f_{\theta^{\prime}}(\mathcal{G})_{v_i} - d_{i})^2,
\end{align}
where $\theta^{\prime}$ is used to denote the parameters of a graph neural network model $f_{\theta^{\prime}}$, $\mathcal{D}_{U}$ represents the set of unlabeled nodes and associated pretext task labels in the graph, and $f_{\theta^{\prime}}(\mathcal{G})_{v_i}$ is used to denote the the predicted local node property for node $v_i$ (which in this case is the predicted node degree). The intuition of constructing self-supervised pretext tasks related to the local node property is to ultimately guide the features (i.e., node representations) from the GNN to preserve this information. This relies on the assumption that such node property information is related to the specific task of interest.
\item \textbf{EdgeMask.}
For the edge mask task, we seek to develop the self-supervision based not only on an individual node itself, but instead pairwise, based on the connections between two nodes in the graph. In particular, we first randomly mask some edges and then the model is asked to reconstruct the masked edges. More specifically, we first mask $m_e$ edges denoted as the set $\mathcal{M}_e \subset \mathcal{E}$ and also sample the set $\overline{\mathcal{M}}_e = \{(v_i,v_j)| v_i, v_j \in \mathcal{V} \text{ and } (v_i, v_j) \notin \mathcal{E}\}$ of node pairs of equal size (i.e., $|\overline{\mathcal{M}}_e| = |\mathcal{M}_e| = m_e$). Then, the SSL pretext task here is to predict whether or not there exists a link between a given node pair. More formally, we construct the associated loss as
\begin{align}
\mathcal{L}_{self}&( {\theta}^{\prime}, {\bf A}, {\bf X}, \mathcal{D}_U) = \\ \nonumber
& \frac{1}{\vert\mathcal{M}_e\vert}\sum_{(v_i,v_j) \in \mathcal{M}_e} \ell\left( f_{w}(\vert f_{\theta^{\prime}}(\mathcal{G})_{v_i} - f_{\theta^{\prime}}(\mathcal{G})_{v_j}\vert), 1\right) \\ \nonumber
+ & \frac{1}{\vert\overline{\mathcal{M}}_e\vert}\sum_{(v_i,v_j) \in \overline{\mathcal{M}}_e} \ell\left( f_{w}(\vert f_{\theta^{\prime}}(\mathcal{G})_{v_i} - f_{\theta^{\prime}}(\mathcal{G})_{v_j}\vert), 0\right),
\end{align}
where $f_{\theta^{\prime}}(\mathcal{G})_{v_i}$ denotes the embedding of node $v_i$, $\ell(\cdot, \cdot)$ is the cross entropy loss, $f_{w}$ linearly maps to 1-dimension, and the class of having a link between $v_i$ and $v_j$ is indicated by 1 and 0 otherwise. In summary, this method is expected to help GNN learn information about local connectivity.
\end{itemize}
\subsubsection{Global Structure Information}
Global self-supervision information for a given node is not only based on the node itself or limited to its immediate local neighborhood, but also taking a bird's-eye view of the position of the node in the graph. Similar to the local perspective, we also propose two representative SSL pretext tasks where one is based upon a global pairwise comparison between two nodes and the other is from how a single node is globally positioned in the graph.
\begin{itemize}[leftmargin=*]
\item \textbf{PairwiseDistance.} The {\it EdgeMask} pretext task is from a local structure perspective based on masking and trying to recover/predict local edges in the graph. We further develop the {\it PairwiseDistance} where we aim to guide the graph neural network to maintain global topology information through a pairwise comparison. In other words, the pretext task is designed to be able to distinguish/predict the distance between different node pairs. We note that distance can be measured in a variety of ways, such as being in the same connected component/cluster or not, personalized PageRank or other global link prediction methods that calculate node similarity~\cite{liben2007link}, etc. In this work, similar to global context prediction in~\cite{peng2020self}, we elect to use the shortest path length as a measure of the distance between nodes. More specifically, we first calculate the pairwise node shortest path length $p_{ij}$ for all node pairs $\{(v_i,v_j)| v_i, v_j \in \mathcal{V}\}$ and further group the lengths into four categories -- $p_{ij}=1, p_{ij}=2, p_{ij}=3$, and $p_{ij}\geq4$. The reasons of selecting four bins for the path length between two nodes is that the GNN should be able to correctly judge the distance between two nodes to some extent, but if we were to include more classes it would: 1) require more calculations to discover all the actual pairwise distances (if greater than 4); and 2) potentially overfit to some of the longer pairwise distances in the graph, which become quite noisy as compared to the shorter path lengths. In addition, since using all node pairs in the objective would be computationally expensive during the training process, in practice, we randomly sample a certain amount of node pairs $\mathcal{S}$
used for self-supervision during each epoch. The SSL loss can then be formulated as a multi-class classification problem as follows,
\begin{align}
\mathcal{L}_{self}&( {\theta}^{\prime}, {\bf A}, {\bf X}, \mathcal{D}_U) = \\ \nonumber
& \frac{1}{\vert\mathcal{S}\vert}\sum_{(v_i,v_j) \in \mathcal{S}} \ell\left( f_{w}(\vert f_{\theta^{\prime}}(\mathcal{G})_{v_i} - f_{\theta^{\prime}}(\mathcal{G})_{v_j}\vert), C_{p_{ij}} \right) \nonumber
\end{align}
where $C_{p_{ij}}$ is the corresponding distance category of $p_{ij}$, $\ell(\cdot,\cdot)$ denotes the cross entropy loss, and $f_{w}$ linearly maps to 1-dimension,. Note that we leave other pairwise distance measures and other settings for the shortest path distance as future work.
\item \textbf{Distance2Clusters.} Although \textit{PairwiseDistance} applies a sampling strategy to reduce time complexity, it is still very time-consuming since we need to calculate pairwise distance for all node pairs. Instead, we derive a new SSL pretext task exploring global structure information by predicting the distance (again in terms of shortest path length) from the unlabeled nodes to predefined graph clusters. This will force the representations to learn a global positioning vector of each of the nodes. In other words, rather than a node predicting the distance pairwise to an arbitrary other node in the graph, instead, we establish a fixed set of anchor/center nodes associated with graph clusters and then each node will predict its distance to this set of anchor nodes. Concretely, we first partitioning the graph to get $k$ clusters $\{C_1,C_2,...,C_k\}$ by applying the METIS graph partitioning algorithm~\cite{karypis1998fast-metis}, since it is commonly used in the literature. Inside each cluster $C_j$, we assign the node with the highest degree to be the center of the corresponding cluster, denoted as $c_{j}$. Then, we can efficiently create a cluster distance vector ${\bf d}_i\in{\mathbb{R}^{k}}$ for node $v_i$ where the $j$-th element of ${\bf d}_i$ is the distance from $v_i$ to the center of $C_j$. The SSL goal of {\it Distance2Clusters} is thus to predict this distance vector and the optimization problem can be formulated as a multiple regression problem as,
\begin{equation}
\mathcal{L}_{self}( {\theta}^{\prime}, {\bf A}, {\bf X}, \mathcal{D}_U) = \frac{1}{\vert{\mathcal{D}_U}\vert}\sum_{ v_i \in \mathcal{D}_U} \|f_{\theta^{\prime}}(\mathcal{G})_{v_i} - {\bf d}_{i}\|^2.
\end{equation}
\end{itemize}
\subsection{Attribute Information}
In this subsection, we focus on attribute information as the second natural choice for establishing a self-supervised pretext task. Here the key point behind attribute information is to help guide the GNN in a way to ensure certain aspects of node/neighborhood attribute information is encoded in the node embeddings after a self-supervised attribute-based pretext. Next, we design two attribute based pretext tasks.
\begin{itemize}[leftmargin=*]
\item \textbf{AttributeMask.} This task is similar to \textit{EdgeMask} but we hope GNN can learn more attribute information via SSL.
Thus, we randomly mask (i.e., set equal to zero) the features of $m_a$ nodes $\mathcal{M}_a \subset \mathcal{V}$ where $\vert\mathcal{M}_a\vert$=$m_a$, and then ask the self-supervised component to reconstruct these features. More formally,
\begin{align}
\mathcal{L}_{self}&( {\theta}^{\prime}, {\bf A}, {\bf X}, \mathcal{D}_U) = \frac{1}{\vert{\mathcal{M}_a}\vert}\sum_{ v_i \in \mathcal{M}_a} \|f_{\theta^{\prime}}(\mathcal{G})_{v_i} - {\bf x}_{i}\|^2 \nonumber
\end{align}
However, the features in most real-world datasets are often high-dimensional and sparse. Hence, in practice we first employ Principle Component Analysis (PCA) to obtain reduced dense features before applying AttributeMask.
\item \textbf{PairwiseAttrSim.} As compared to data samples in other domains such as an image, in graph structured data the aggregation process is actually merging the features from multiple instances to discover the learned representation. Thus, given two nodes that have similar attributes, their learned representations are not necessarily similar (as compared to e.g., two exact images will obtain the same representation in typical deep learning models). More generally, the similarity two nodes have in the input feature space is not guaranteed in the learned representations due to the GNN aggregating features from the two nodes local neighborhoods. This can create a double-edged sword as although we wish to utilize the local neighborhood in a GNN to enhance the node feature transformation, we still wish to somewhat maintain the notion of data instance similarity and not allow a node's neighborhood to drastically change their attribute signature. Thus, we establish the attribute-based SSL pretext task of node attribute similarity. Due to the majority of the pairwise similarity being near zero, we develop the following pair sampling strategy. First, we let $\mathcal{T}_s$ and $\mathcal{T}_d$ denote the sets of node pairs having the highest similarity and dissimilarity, respectively, which we more formally define as,
\vspace{-2ex}
\begin{small}
\begin{align}
&\mathcal{T}_s = \{(v_i, v_j)| s_{ij} \text{ in top-K of } \{s_{ik}\}^N_{k=1}\setminus\{s_{ii}\}, \forall v_i \in \mathcal{V}_U \} \nonumber \\
&\mathcal{T}_d = \{(v_i, v_j)| s_{ij} \text{ in bottom-K of } \{s_{ik}\}^N_{k=1}\setminus\{s_{ii}\}, \forall v_i \in \mathcal{V}_U \} \nonumber
\end{align}
\end{small}
\vspace{-2ex}
where $s_{ij}$ measures the node feature similarity between $v_i$ and $v_j$ (according to cosine similarity) and $K$ is the number of top/bottom pairs selected for each node. Now, we can formalize the regression problem as follows,
\begin{align}
\mathcal{L}_{self}&( {\theta}^{\prime}, {\bf A}, {\bf X}, \mathcal{D}_U) = \\ \nonumber
& \frac{1}{\vert\mathcal{T}\vert}\sum_{(v_i,v_j) \in \mathcal{T}} \| f_{w} (\vert f_{\theta^{\prime}}(\mathcal{G})_{v_i} - f_{\theta^{\prime}}(\mathcal{G})_{v_j}\vert) - {s_{ij}} \|^2. \nonumber
\end{align}
where $\mathcal{T}=\mathcal{T}_s \cup \mathcal{T}_d$ and $f_{w}$ linearly maps to 1-dimension.
\end{itemize}
\section{Preliminary Analysis}\label{sec:sslstudy}
In the last section, we discussed basic self-supervised pretext tasks from both structure and attribute information. In this section, we present two strategies to merge these pretext tasks into GNNs, i.e., joint training and two-stage training, and then empirically analyze the impacts of the pretext tasks on GNNs.
\begin{figure}[t]
\centering
\includegraphics[width=0.9\linewidth]{image/joint-leanring-frame.pdf}
\caption{An overview of SSL in GNNs using joint training.}
\label{fig:joint_training}
\end{figure}
\subsection{Joint Training}
A natural idea to employ self-supervised learning for graph neural networks is to jointly train the corresponding losses. In other words, we aim to optimize the self-supervised loss (i.e., $\mathcal{L}_{self}$) and supervised loss (i.e., $\mathcal{L}_{task}$) simultaneously.
An overview of joint training is shown in Figure~\ref{fig:joint_training}. Essentially this can be separated into two stages: 1) feature extraction process; and 2) adaptation processes for both the downstream and self-supervised pretext tasks. The first step is a feature extraction process that is applied on the input graph, which can be various graph convolutional layers. Based on the extracted features, two adaptation processes are applied to the downstream task and self-supervised pretext task, respectively. Note that the adaptation layers can be graph convolutional layers or linear layers (which we later discuss in the experiment setup). Afterwards we jointly optimize the losses from both self-supervised and downstream task components.
As introduced in Section~\ref{sec:problem}, we denoted the prediction of a node $v_i$ as $f_\theta( \mathcal{G})_{v_i}$, where $f_\theta$ represented our graph neural network model. As demonstrated in Figure~\ref{fig:joint_training}, we separate the GNN into both a feature extractor and an adapter for the downstream classification task. Correspondingly, we split the parameter $\theta$ as $\theta =\{\theta_z,\theta_y\}$. Then, we
use $f_{\theta_z}(\mathcal{G}) \rightarrow \mathbf{Z}$ to denote the feature extractor component of $f_\theta$ where $\mathbf{Z}\in \mathbb{R}^{N \times d}$ and $\mathbf{z}_i=f_{\theta_z}(\mathcal{G})_{v_i}$ represents the embedding of node $v_i$. Furthermore, we utilize $f_{\theta_y}(\mathbf{z}_i) \rightarrow \hat{y}_i$ to denote the adapter/classifier component of $f_\theta$ that maps the embedding $\mathbf{z}_i$ of a node $v_i$ to the predicted class $\hat{y}_i$. In addition, the self-supervised pretext task can be formulated to utilize the same feature extractor $f_{\theta_z}$ and an additional adapter $f_{\theta_s}$. Thus, the overall objective can be defined as follows,
\begin{equation}
\min _{\theta,\theta^{\prime}} \mathcal{L}_{task}\left(\theta, \mathbf{A}, \mathbf{X}, \mathcal{D}_{L}\right) + \lambda\mathcal{L}_{self}\left(\theta^{\prime}, \mathbf{A}, \mathbf{X}, \mathcal{D}_{U}\right),
\end{equation}
where $\theta^{\prime} =\{\theta_z,\theta_s\}$ and $\lambda$ is the hyperparameter to control the contribution of self-supervision.
\begin{figure}[t]
\centering
\includegraphics[width=0.9\linewidth]{image/two-stage-frame.pdf}
\caption{An overview of SSL in GNNs using two-stage training.}
\label{fig:two-stage_training}
\end{figure}
\subsection{Two-stage Training}
\label{sec:two-stage}
Two common strategies to utilize features learned via self-supervision in computer vision include applying the self-supervised model as an initialization for fine-tuning~\cite{zhai2019s4l, noroozi2018boosting} and training a linear classifier over the learned features~\cite{kolesnikov2019revisiting,doersch2015unsupervised}. These strategies motivate us a two-stage training method to integrate SSL into GNNs. This method consists of the following two stages: 1) Pre-training on the self-supervised pretext task; and 2) Fine-tuning on the downstream task.
An overview of the two-stage training method is given in Figure~\ref{fig:two-stage_training}. Similar to the joint training, the self-supervised model consists of a feature extraction module $f_{\theta_z}(\mathcal{G})$ and an adaptation module $f_{\theta_s}(\mathcal{G}))$, which are optimized by itself independent of the downstream task. Then, after the self-supervised model is fully trained, we begin to train the downstream task model. More specifically, the downstream task model also has an adaptation module $f_{\theta_y}(\mathcal{G})$, but its feature extraction module shares parameters with that of the self-supervised model $f_{\theta_z}(\mathcal{G})$. As seen in the figure, we first pre-train the self-supervised model for the pretext task, and then use the self-supervised model's feature extraction module as the initialization of that of the downstream task. After initializing $\theta_z$, we can either fix it or fine tune it for the downstream task.
\subsection{Empirical Study}
In this subsection, we conduct extensive experiments based on the basic pretext tasks to understand {\it what} SSL information works for GNNs, {\it which} strategies can better integrate SSL for GNNs, and further analyze {\it why} SSL is able to improve GNNs. Following the setting in GCN~\cite{kipf2016semi}, we conduct experiments on the public data splits of three widely used benchmark datasets: Cora, Citeseer, and Pubmed. The dataset statistics can be found in Table~\ref{tab:data}. We used Adam optimizer with learning rate 0.01, $L_2$ regularization 5e-4, dropout rate 0.5, 128 hidden units across all self-supervised information and GCN, and top-K = bottom-K = 3. Then parameters tuned on validation accuracy are: $\lambda$ in range of $\{0, 0.001, 0.01, 0.1, 1, 5, 10, 50, 100, 500, 1000\}$, $m_e$ and $m_a$ in \{10\%, 20\%\} the size of $|V|$.
\begin{table}[t]
\centering
\setlength{\tabcolsep}{2pt}
\renewcommand{\arraystretch}{0.95}
\caption{Dataset statistics.}
\begin{tabular}{lcccccc}
\toprule
\textbf{Dataset} & \textbf{Nodes} & \textbf{Edges} & \textbf{Classes} & \textbf{Features} &\textbf{Training/Validation/Test} \\
\midrule Cora & 2,708 & 5,429 & 7 & 1,433 & 140/500/1000\\
Citeseer & 3,327 & 4,732 & 6 & 3,703 & 120/500/1000 \\
Pubmed & 19,717 & 44,338 & 3 & 500 & 60/500/1000\\
\bottomrule
\end{tabular}
\label{tab:data}
\end{table}
{\bf Strategies for Two-stage Training.} For two-stage training, after initializing the feature extractor, we can either fix it or fine tune it for node classification. We studied various architectures for both pretrained and node classification models with the results demonstrated in Table~\ref{tab:arc-choice}. Note that in the table, (1) ``2GC+1Linear" denotes that we use {\it two} graph convolutional layers for feature extraction and {\it one} linear layer for the adaptation; (2) ``2GC" means {\it one} graph convolutional layers for feature extraction and {\it another} graph convolutional layer for the adaptation; (3) for the column of ``Finetune Strategy", ``Fix" and ``Tune all" correspond to the aforementioned two strategies and we also report the performance of node classification without pretraining from SSL as the third strategy; and (4) all the experiments are conducted with the \textit{PairwiseDistance} task. In most cases, the strategy of ``Tune all" achieves the best performance. Thus, we choose this strategy when using two-stage training. We also note that the configuration of one graph convolutional layer for feature extraction, one graph convolutional layer for the adaptation of node classification and one linear layer for the adaptation of pretext task works very well for all three strategies. Therefore, we select this configuration for the remaining experiments unless stated otherwise.
\begin{table}[t]
\centering
\renewcommand{\arraystretch}{0.9}
\caption{ Two-stage training strategies on Cora.}
\begin{tabular}{@{}cccc@{}}
\toprule
\begin{tabular}{@{}c@{}} \textbf{SSL}\\ \textbf{Pretrained} \\ \textbf{Model}\end{tabular} & \begin{tabular}{@{}c@{}} \textbf{Node} \\ \textbf{Classification} \\ \textbf{Model}\end{tabular} & \textbf{\begin{tabular}[c]{@{}l@{}}Finetune Strategy\\ \end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}Test Accuracy\\ (\%) \end{tabular}} \\ \midrule
2GC+1Linear & 2GC+1Linear & Fix & 73.53 \\
2GC+1Linear & 2GC+1Linear & Tune all & 80.55 \\
- & 2GC+1Linear & - & 78.63 \\ \midrule
2GC+1Linear & 3GC & Fix & 74.69 \\
2GC+1Linear & 3GC & Tune all & 82.49 \\
- & 3GC & - & 80.88 \\ \midrule
1GC+1Linear & 1GC+1Linear & Fix & 80.75 \\
1GC+1Linear & 1GC+1Linear & Tune all & 79.79 \\
- & 1GC+1Linear & - & 78.75 \\ \midrule
1GC+1Linear & 2GC & Fix & 81.04 \\
1GC+1Linear & 2GC & Tune all & 82.39 \\
- & 2GC & - & 81.32 \\ \bottomrule
\end{tabular}
\label{tab:arc-choice}
\end{table}
{\bf SSL for GNNs.} Following the aforementioned experimental settings, we evaluate six basic pretext tasks in Section~\ref{sec:sslinfo} with joint and two-stage training strategies and the results are shown in Table~\ref{tab:analysis-performance}.
{\it Joint Training vs. Two-stage Training.} We observe that although the two-stage training is able to improve the vanilla GCN model, the joint training outperforms the two-stage training in most settings. This observation from the graph domain is consistent with that from image self-supervised semi-supervised learning~\cite{zhai2019s4l}. In addition, the joint training strategy is less complicated as compared to the fine-tuning strategy. More specifically, joint training only requires the tuning of a single hyperparameter $\lambda$ as compared to significant efforts for the two-stage training due to the high sensitivity in the two-stage training as shown in Table~\ref{tab:arc-choice}. Thus, our empirical analysis suggests that joint training is a better strategy to integrate SSL with GNNs than the two-stage training.
{\it What SSL Works for GNNs.} From Table~\ref{tab:analysis-performance}, we can first observe that the best performance is always achieved by one including an SSL pretext task. In other words, our empirical analysis clearly shows that utilizing self-supervised information in graph neural networks is a promising direction for further improving the performance of deep learning on graph-structured data. Furthermore, we observe a wide range of utility for the various self-supervised pretext tasks for improving node classification. First, we notice that across all datasets, the best performing method is a pretext task developed from global structure information. Another thing to note is that we determine the quality of \textit{AttributeMask} in comparison to GCN-PCA, since they both first utilize PCA as a preprocessing step to reduce the dimension of the node features/attributes. Then, under further analysis on the results in Table~\ref{tab:analysis-performance}, we find that the pretext tasks of \textit{NodeProperty}, \textit{EdgeMask} and \textit{AttributeMask} cannot boost the original GCN since the performance difference is always smaller than $0.3\%$. By contrast, global self-supervision including \textit{PairwiseDistance}, \textit{Distance2Cluster}, and \textit{PairwiseAttrSim} successfully improves the performance (e.g., over $2\%$ improvement on the Cora dataset). Thus, self-supervised information from both the structure and attributes have potentials; while for the structure information, the global pretext tasks are likely to provide much more significant improvements compared to the local ones.
\begin{table}[t]
\setlength{\tabcolsep}{2pt}
\centering
\caption{Performance evaluation of using SSL for GNNs.}
\label{tab:analysis-performance}
\begin{tabular}{c|ccc|ccc}
\toprule
\multirow{2}{1cm}{\textbf{Model}} & \multicolumn{3}{c}{\textbf{\begin{tabular}[c]{@{}c@{}}Joint Training \end{tabular}}} & \multicolumn{3}{|c}{\textbf{\begin{tabular}[c]{@{}c@{}}Two-stage Training \end{tabular}}} \\ \cmidrule(r){2-4} \cmidrule(r){5-7}
& \textbf{Cora} & \textbf{Citeseer} & \textbf{Pubmed} & \textbf{Cora} & \textbf{Citeseer} & \textbf{Pubmed} \\ \hline
\textbf{GCN} & 81.32 & {71.53} & 79.28 & 81.32 & {71.53} & 79.28 \\
\textbf{GCN-DroppedGraph} & 81.03 & {71.29} & 79.28 & 81.03 & {71.29} & 79.26 \\
\textbf{GCN-PCA} & 81.74 & {70.38} & 78.83 & 81.74 & {70.38} & 78.83 \\ \hline
\textbf{NodeProperty} & 81.94 & 71.60 & 79.44 & 81.59 & 71.69 & 79.24 \\
\textbf{EdgeMask} & 81.69 & 71.51 & 78.90 & 81.44 & 71.57 & 79.33 \\ \hline
\textbf{PairwiseNodeDistance} & 83.11 & {71.90} & {80.05} & {82.39} & {72.02} & {79.57} \\
\textbf{Distance2Cluster} & {83.55} & 71.44 & 79.88 & 81.80 & 71.55 & 79.51 \\ \hline
\textbf{AttributeMask} & 81.47 & 70.57 & 78.88 & 81.31 & 70.40 & 78.72 \\
\textbf{PairwiseAttrSim} & 83.05 & 71.67 & 79.45 & 81.57& 71.74 & 79.42 \\
\bottomrule
\end{tabular}
\end{table}
\begin{figure}[t]
\centering
\renewcommand{\arraystretch}{0.95}
\vspace{-2.5ex}
\includegraphics[width=0.7\linewidth]{image/diff.pdf}
\vspace{-1ex}
\caption{Classification accuracy difference on three SSL pretext tasks between GCN node representations and original node features. Positive value indicates the classifier trained with GCN node representations can achieve higher accuracy than that with original features, and vice versa.}
\label{fig:diff}
\vskip -1.75ex
\end{figure}
{\it Why SSL Works for GNNs.} We have found that using some self-supervision like global structure and pairwise attribute information can perform well while others not. Thus, the natural question is why they work or why they are unable to improve. As we mentioned before, GCN for node classification is naturally semi-supervised that has explored the unlabeled nodes. Therefore, one possible reason why some self-supervision cannot help could be that GCN can already learn such information itself. If this is the case, then training on additional self-supervised pretext task could perhaps not further boost the performance. To verify this assumption, we train logistic regression classifiers on the original node features and nodes representations from GCN (without self-supervised learning) to predict on the pretext task. The intuition is if GCN can learn one type of self-supervision, the nodes representations from GCN should have preserved such information; thus they should perform better on the corresponding pretext task than the original node features. The performance difference is shown in Fig~\ref{fig:diff}. We choose three representative pretext tasks \textit{EdgeMask}, \textit{NodeProperty} and \textit{PairwiseDistance} to illustrate since similar patterns can be observed in other cases. From the figure we can observe that GCN node representation consistently outperforms original features for \textit{NodeProperty} task by a large margin, indicating that GCN can learn such local structure information. Hence, \textit{NodeProperty} cannot bring in further improvement for its corresponding self-supervised GCN. Similar observations can be made on \textit{EdgeMask} task for Cora and Citeseer. The reason why the performance difference for \textit{EdgeMask} on Pubmed is small could be that the original features of Pubmed are very representative for local connectivity, since original features can achieve over 80\% accuracy on the \textit{EdgeMask} task. On the contrary, the performance difference on \textit{PariwiseDisance} task is rather small across three datasets. This observation suggests that GCN is unable to naturally learn the global structure information and employing pairwise node distance prediction as the SSL task can help boost its performance for the downstream task.
\textbf{Insights on SSL for GNNs.} One of the most fundamental properties in graphs is the study of graph similarity, which is to describe how similar two nodes are in a graph. There are two most popular approaches to measure this similarity including structural equivalence and regular equivalence~\cite{newman2018networks}. More specifically, one way of defining similarity in regards to structural equivalence in a graph is that two nodes are structurally equivalent if their local neighborhoods significantly overlap. In comparison, regular equivalent nodes are those that, while not necessarily having the same neighbors, have neighbors who themselves are similar~\cite{borgatti1992notions}. Now, given these definitions, we discuss and characterize to what extent GCN is able to naturally maintain these types of similarity when mapping from the input space to the embedding space, and then how these are correlated to the observations we have made with different self-supervised pretext tasks.
First, given that GCN works by aggregating features from a node's local neighborhood, if two nodes have a significant overlap in their neighbors (as defined in structural equivalence), then it would be expected that their embeddings should somehow maintain this notion of similarity. Second, we let neighbor similarity in regular equivalence be defined in terms of their attribute similarity, then even if two nodes do not share the same neighbors, if their neighbors are similar, this will result in the learned embeddings of the two nodes maintaining this notion of regular attribute equivalence.
Furthermore, we can observe our proposed self-supervised pretext tasks built on structure information (e.g., {\it PairwiseNodeDistance}) can be described in helping to maintain this notion of structural equivalence in the embeddings. For example, if the embeddings are encouraged to encode how similar two nodes are in terms of their distance (as done in {\it PairwiseNodeDistance}), then this is related to maintaining structural similarity as many node similarity measures are defined based on the idea of path length between two nodes. For the self-supervised pretext tasks based on attribute information, if we define the concept of attribute equivalence being two vertices that share many of the same attributes/features (as structural share many neighbors). Then, given this definition of attribute equivalence, we can observe that indeed self-supervised pretext tasks based on attribute information such as {\it PairwiseAttrSim} are actually looking to explicitly maintain this notion of similarity from the input to the embedding space.
With these insights and our empirical observations, we are able to design more pretext tasks. In this work, we aim to try a new direction beyond the structure and attribute information where we want to take into consideration the specific downstream task. In particular, we want to extend the concept of regular equivalence being defined with similarity on the level of structure or attributes to instead the level of task by introducing {\it regular task equivalence} where node similarity is now defined specific to the task. Since our downstream task is node classification, beyond the structure and attribute information (i.e., ${\bf A}$ and ${\bf X}$, respectively), we additionally have the label information for some of the nodes (i.e., those in $\mathcal{D}_L$). Thus, in the next section, we will discuss advanced self-supervised methods that are built with the intuition of adapting the notion of regular equivalence beyond having neighbors with similar attributes, to instead having neighbors with similar node labels (or regular task equivalence). More specifically, the general idea is that if every node constructs a pretext vector based on information in regards to the labels from their neighborhood, then two nodes having similar (or dissimilar) vectors, we would encourage to be similar (or dissimilar) in the embedding space. {\it The significance of this new attempt is that if the concept of regular task equivalence can work, it will open new doors to design more advanced pretext tasks based on the concept of equivalence from each individual resource or their combinations. }
\section{Introduction}
In recent years, deep learning has achieved superior performance across numerous domains; but it requires costly annotations of huge amounts of data~\cite{kolesnikov2019revisiting}. Hence, self-supervised learning (SSL) has been introduced in both the image~\cite{kolesnikov2019revisiting,doersch2015unsupervised, caron2018deepcluster} and text~\cite{le2014word2vec,devlin2018bert} domains to alleviate the need of large labeled data by deriving labels for the significantly more unlabeled data. More specifically, SSL often first designs a domain specific pretext task to assign labels for data instances and then trains the deep model on the pretext task to learn better representations due to the inclusion of unlabeled samples in the training process.
As the generalization of deep learning to the graph domain, graph neural networks (GNNs) have been proven to be powerful in graph representation learning. As a result, GNNs have facilitated various computational tasks on graphs such as node classification and graph classification~\cite{wu2019comprehensive-survey,kipf2016semi,hamilton2017inductive,gat}. In this work, we focus on advancing GNNs for node classification where GNNs leverage both labeled and unlabeled nodes on a graph to jointly learn node representations and a classifier that can predict the labels of unlabeled nodes on the graph. On the one hand, GNNs are inherently semi-supervised where unlabeled data has been coherently integrated. On the other hand, GNNs mainly utilize unlabeled nodes by simply aggregating their features that cannot thoroughly take advantage of the abundant information~\cite{sun2019m3s}. Thus, to fully exploit the unlabeled nodes for GNNs, SSL can be naturally harnessed for providing additional supervision.
Graph-structured data is often more complex than other domains (e.g., image and text). In addition to node attributes, graphs present complicated structure information. For example, the topology of an image is a fixed grid and text is a simple sequence, while graphs are not restricted to these rigid structures. Furthermore, unlike images and text where the entire structure is a single data sample, each node in a graph is an individual instance and has its own associated attributes and topological structures. The complexity of graph-structured data does not stop here. In the text and image domain, data samples are often under the assumption of being {\it i.i.d.} (independent and identically distributed). However, in the graph domain, instances (or nodes) are inherently linked and dependent of each other. Therefore, the complex nature of graph-structured data determines that it is very challenging to directly adopt self-supervised learning developed in other domains to graphs. While introducing tremendous challenges, the complexity of graphs is a double-edged sword that also presents unprecedented opportunities. In particular, the complexity provides rich information that enables us to design pretext tasks from various perspectives. Similar to the image and text domains, we can focus on individual nodes such as node features and node topological properties. Moreover, unlike the image and text domains, nodes are dependent in a graph, and thus we are able to investigate new aspects such as dependence on node pairs or even a set of nodes. In addition, multiple information resources including node attributes, structure information, and label information of labeled nodes are available in a graph and their interactions and combinations provide unprecedented opportunities for us to design advanced self-supervised pretext tasks. Very recently, there are only a few attempts to adapt SSL from the image domain in training graph neural networks~\cite{sun2019m3s,peng2020self}. Therefore, the research of self-supervised learning on graphs is still at the initial stage and more systematical and dedicated efforts are pressingly needed.
In this paper, we embrace the challenges and opportunities to study self-supervised learning in graph neural networks for node classification with two major goals. First, we want to deepen our understandings on self-supervised learning on graphs. Specifically, there are a variety of potential pretext tasks for graphs; hence it is important to gain insights on {\it when} and {\it why} SSL works for GNNs and {\it which} strategy can better integrate SSL for GNNs. Second, we target on inspiring new directions of SSL on graphs according to our understandings. Particularly, we want to investigate {\it how} these insights can motivate more sophisticated approaches to design pretext tasks. To achieve the first goal, we design basic types of pretext tasks directly based on attribute and structural information. We make several crucial findings about SSL on graphs via deep analysis on their impact on the GNN performance. These findings allow us to propose a new direction \textit{SelfTask} to design more advanced pretext tasks that are empirically demonstrated to achieve state-of-the-art performance on various graph datasets.
\section{Problem Statement}\label{sec:problem}
We use $\mathcal{G}=({\bf\mathcal{V}},{\bf\mathcal{E}}, {\bf X})$ to denote a graph where $\mathcal{V}=\{v_1, v_2, ..., v_N\}$ is the set of $N$ nodes, $\mathcal{E}$ is the set of edges describing the relations between nodes and ${\bf X} = [{\bf x}_1,{\bf x}_2,\ldots,{\bf x}_N]$ is the node feature matrix where ${\bf x}_i$ denotes the node features of $v_i$. The graph structure information can also be represented by an adjacency matrix $\mathbf{A} \in [0,1]^{N \times N}$ where $\mathbf{A}_{ij}=1$ indicates there exists a link between nodes $v_i$ and $v_j$, otherwise $\mathbf{A}_{ij}=0$. Hence, a graph can also be denoted as $\mathcal{G}=({\bf A},{\bf X})$.
In this paper, we focus on the semi-supervised node classification setting where only a subset of nodes $\mathcal{V}_{L}$ are associated with corresponding labels $\mathcal{Y}_L$. We denote the labeled data as $\mathcal{D}_L=(\mathcal{V}_{L},\mathcal{Y}_L)$ and unlabeled data as $\mathcal{D}_{U}$. Let $f_\theta: \mathcal{V}_L\rightarrow\mathcal{Y}_L$ be a
graph neural network that maps the nodes to the set of labels such that the graph neural network can infer the labels of unlabeled data. Thus, the objective function for the semi-supervised node classification task can be formulated as minimizing the loss $\mathcal{L}_{task}$, or more specifically as
\begin{equation}
\min _{\theta} \mathcal{L}_{task}( {\theta}, {\bf A}, {\bf X}, \mathcal{D}_L)=\sum_{(v_i, y_i) \in \mathcal{D}_{L}} \ell\left(f_{\theta}(\mathcal{G})_{v_i}, y_{i}\right),
\end{equation}
where $\theta$ is used to denote the parameters of $f_\theta$, $f_\theta( \mathcal{G})_{v_i}$ is the prediction of node $v_i$ and $\ell(\cdot, \cdot)$ denotes the loss function used to measure the difference between the predicted and true labels (e.g., cross entropy).
With the aforementioned notations and definitions, there could be multiple settings of SSL for GNN, but in this work we formally define the problem of self-supervised learning for graph neural networks under the task of node classification as:
\vskip 0.5em
\textbf{Problem 1.} \textit{Given a dataset in the graph domain represented as a graph $\mathcal{G}=({\bf A, X})$ with paired labeled data $\mathcal{D}_L=(\mathcal{V}_{L},\mathcal{Y}_L)$, we aim to construct a self-supervised pretext task with a corresponding loss $\mathcal{L}_{self}$ that can be integrated with the task specific loss $\mathcal{L}_{task}$ to learn a graph neural network $f_\theta$ that can better generalize on the unlabeled data.}
\section{Related Work}\label{sec:relatedwork}
In this section, we introduce the related work including self-supervised learning and graph neural networks.
\subsection{Self-supervised Learning}
SSL is a novel learning framework that generates additional supervised signals to train deep learning models through carefully designed pretext tasks. SSL has been proven to effectively alleviate the problem of lack of labeled training data~\cite{kolesnikov2019revisiting}. In the image domain, various self-supervised learning techniques have been developed for learning high-level image representations. Doersch et al.~\cite{doersch2015unsupervised} first proposed to predict the relative locations of image patches. Following this line of research, Noroozi et al.~\cite{noroozi2016unsupervised} designed a pretext task called Jigsaw Puzzle. More types of pretext tasks have also been investigated, such as image rotation~\cite{gidaris2018rotation}, image clustering~\cite{caron2018deepcluster}, image inpainting~\cite{pathak2016context}, image colorization~\cite{zhang2016colorful} and motion segmentation prediction~\cite{pathak2017learning}. In the domain of graphs, there are a few works incorporating SSL. Sun et al.~\cite{sun2019m3s} utilized the clustering assignments of node embeddings as guidance to update the graph neural networks. Peng et al.~\cite{peng2020self} proposed to use the global context of nodes as the supervisory signals to learn node embeddings.
\subsection{Graph Neural Networks}
GNNs can be roughly categorized into spectral methods and spatial methods. Spectral methods were initially developed based on spectral theory~\cite{bruna2013spectral,defferrard2016convolutional,kipf2016semi}.
Bruna et al.~\cite{bruna2013spectral} first extended the notion of convolution to non-grid structures. Afterward, a simplified version of spectral GNNs called ChebNet~\cite{defferrard2016convolutional} was developed. Next, GCN is proposed by Kipf et al.~\cite{kipf2016semi}, where Chebnet is further simplified based on its first-order approximation. Later, Wu et al.~\cite{wu2019simplifying} proposed Simple Graph Convolution (SGC) to simplify GCN by removing nonlinearities and collapsing weight matrices. Spatial methods consider the topological structure of the graph, and aggregate the information of nodes according to local information~\cite{hamilton2017inductive,gat}.
Hamilton et al.~\cite{hamilton2017inductive} proposed an inductive learning method called GraphSAGE for large-scale networks. Veličković et al.~\cite{gat} proposed graph attention network (GAT), which includes an attention mechanism to graph convolutions. Further, Rong et al.~\cite{rong2019truly} developed deep graph convolution network by applying DropEdge mechanism to randomly drop edges during training. For a thorough review, please refer to recent surveys~\cite{wu2020comprehensive,zhou2018graph}.
| {'timestamp': '2020-06-19T02:03:22', 'yymm': '2006', 'arxiv_id': '2006.10141', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10141'} | arxiv |
\section{Dataset}
\label{sec:datasets}
We collected the dataset CARLA-SA using the CARLA Urban Driving Simulator~\citep{Dosovitskiy17}. The simulator has been designed to generate images from the point of view of vehicles for autonomous driving, whereas, to study the scene adaptation problem, we need to collect images of the same scene from different fixed points of view.
We achieve this by placing the vehicle which collects the images at predefined locations in the virtual city.
To obtain different views of the same scene, for each vehicle we set up multiple cameras at different altitudes, pitch, yaw and roll angles. The vehicle collecting the images does not move during the simulations, while other vehicles and pedestrians are free to move in the scene.
Using this procedure, we collected three episodes in three different scene contexts of the virtual city, which we refer to as ``Scene 1'', ``Scene 2'' and ``Scene 3''.
Each scene has been captured by two different points of view presenting scene overlap, which we refer to as ``View $A$'' and ``View $B$''. The two views differ by an angle of 10\textdegree of pitch and by an angle of 10\textdegree of yaw. Therefore, the dataset consists of $6$ image subsets denoted as ``XY'', where $X$ represent the view and $Y$ represents the scene characterizing the subset (e.g., $A1$, $B2$, etc.). \figurename~\ref{fig:dataset} reports some examples from the $6$ subsets. Each subset is split into a training and a test set. Specifically, for each subset, we randomly pick $60\%$ of the data from training, $20\%$ for validation and $20\%$ for testing.
The dataset contains $5,000$ frames acquired at $1\ fps$ for each scene-view pair, for a total of $30,000$ frames in the whole dataset.
Each image has been collected at the resolution of $800 \times 600$ pixels.
The time of the day and weather has been generated randomly. For each image, the simulator also produces a ground truth semantic segmentation map which associates each pixel of the scene to one of $13$ classes: \textit{buildings}, \textit{fences}, \textit{pedestrians}, \textit{poles}, \textit{road-lines}, \textit{roads}, \textit{sidewalks}, \textit{vegetation}, \textit{vehicles}, \textit{walls}, \textit{traffic signs}, \textit{other}, and \textit{unlabeled}.
This dataset allows to consider two types of source-target domain pairs: 1) ``point of view adaptation'' pairs, composed by two subsets from the same scene context but with different views (e.g., $A1-B1$, $A2-B2$, etc. in \figurename~\ref{fig:dataset}), 2) ``scene adaptation'' pairs, composed by two subsets belonging to different scene contexts (e.g., $A1-A2$, $A2-A3$, etc. in \figurename~\ref{fig:dataset}).
\section{Introduction}
\label{sec:intro}
Semantic segmentation allows to classify each pixel of an image according to the object it belongs to in the scene.
This task is often the first step in scene understanding and is important in many industrial scenarios including video surveillance and traffic analysis~\citep{raymond2001traffic,Battiato2018208,ravi2016semantic}.
In recent years, deep learning allowed to push forward the performance of semantic segmentation methods~\citep{badrinarayanan2015segnet2,long2015fully,zhao2017pyramid,7913730}.
However, such approaches generally require to be trained on large quantities of domain-specific labeled data in order to achieve reasonable performance.
In practice, deploying a semantic segmentation system often involves collecting domain-specific data and fine-tuning an existing semantic segmentation algorithm pre-trained on large quantities of domain-agnostic data.
Moreover, this fine-tuning process (including the collection and labeling of new data) needs to be repeated whenever the target domain changes significantly, e.g., when an existing camera is moved or a new one is introduced in the camera network, due to the different scene layouts induced by the different viewpoints.
The significant effort required to collect and label domain-specific data can slow down the deployment of industrial systems based on semantic segmentation algorithms and prevent them from scaling up.
In this paper, we consider a scene adaptation scenario in which a fixed camera is employed to monitor a urban area. When the system is set up, domain-specific data is collected and labeled.
An existing algorithm is hence fine-tuned to perform the semantic segmentation of the scene.
In real scenarios, the system is often extended by adding a new camera looking at the same scene from a different point of view or by adding a camera looking at a different scene characterized by the same semantic classes (e.g. a different urban area).
After the installation of the new cameras, the existing algorithms need to be adapted to the new views or scenes.
The proposed scene adaptation problem is illustrated in
\figurename~\ref{fig:scene_adaptation}.
The adaptation procedure in such contexts is generally achieved collecting and labeling additional data from the two cameras in order to fine-tune the algorithms in a purely supervised way.
However, as observed in previous work~\citep{DBLP:journals/corr/TzengHSD17,DBLP:journals/corr/abs-1802-10349,DBLP:journals/corr/abs-1711-06969}, the amount of effort required to collect and label domain-specific data to perform fine-tuning can be reduced using domain adaptation techniques (i.e., trying to bypass the three steps of data collection, labeling and fine-tuning).
\begin{figure}[t!]
\centering
\includegraphics[width=1\linewidth]{images/new_scene.jpg}
\caption[]{The proposed scene adaptation scenario\footnotemark. A camera $S$ (dark yellow) is installed to monitor a urban space. This initial set up requires the collection and labeling of
domain-specific data to optimize an existing semantic segmentation algorithm to the considered task. The system can be extended by adding a camera which
observes the same scene from a different point of view $S'$ (blue) or by adding a new camera which observes a different scene $S''$ (red). In both cases, the existing semantic segmentation algorithms
need to be adapted to the new views.}
\label{fig:scene_adaptation}
\end{figure}
\footnotetext{Underneath photo by Felix Steininger on Unsplash.}
We frame the considered scene adaptation task as a Domain Adaptation problem in which labeled images collected using the already installed camera belong to the source domain, whereas unlabeled images collected using the new camera belong to the target domain.
We observe that no datasets comprising real images from different cameras looking at the same/similar scenes are available to support our investigation.
This is mainly due to the challenges arising when collecting real data in these settings.
To overcome these issues and provide a first set of data useful to investigate the proposed problem, we collect and publicly release a novel dataset of urban scenes using the CARLA Urban Driving Simulator~\citep{Dosovitskiy17}.
The collected dataset comprises images generated in $3$ scene contexts from $6$ different views ($2$ views per context).
As a first step towards addressing the proposed task, we contribute a method which leverages Adversarial Learning~\citep{goodfellow2014generative} to perform scene adaptation.
The proposed approach takes advantage only of existing \textit{labeled} data from the source domain and newly collected \textit{unlabeled} images from the target domain.
We enforce that the input images can be reconstructed from the produced segmentation maps, while the realness of the reconstructions is imposed through adversarial learning.
The reconstructive criterion allows to define a supervised loss for the unlabeled data and acts as a regularizer which encourages the network to learn view invariant representations for small scene elements such as traffic signs and fences.
While the proposed approach is conceptually simple, we show that it significantly outperforms a pipeline including the geometric warp of the input images, which suggests that it is appropriate to consider the problem as a domain adaptation task. We hope that the proposed approach may serve as a useful baseline for other works.
The method is independent from the specific semantic segmentation network employed and can be regarded to as a general training procedure which allows generalization to unseen views.
Experiments show that the proposed approach achieves state of the art performance, surpassing baselines and previous domain adaptation techniques.
The contributions of this work are as follows: 1) we introduce the problem of scene-based domain adaptation for semantic segmentation algorithms; 2) we propose CARLA-SA (Carla-Scene Adaption), a dataset of urban scenes to study the considered domain adaptation problem; 3) we contribute SceneAdapt, a method to perform scene adaptation using adversarial learning, which is shown to outperform baseline and state-of-the-art approaches.
This work extends our previous investigation~\citep{dimauro18} introducing a clearer introduction of the proposed method, additional comparisons with state of the art approaches and baselines, as well as an ablation study discussing the impact of each component on the final performance.
Moreover, with this paper we publicly release both the collected dataset and the code of the proposed method\footnote{\url{http://iplab.dmi.unict.it/SceneAdapt/}.}.
\section{Conclusion}
\label{sec:conclusions}
We have investigated the problem of scene-based domain adaptation for semantic segmentation by defining
two adaptation scenarios: point of view adaptation and scene adaptation.
To this aim, we collected a dataset of urban scenes and proposed a novel architecture to perform scene and point of view semantic segmentation adaptation using adversarial learning.
Experiments show that the proposed method greatly reduces
over-fitting in both point of view and scene adaptation and outperforms baselines and
other state-of-the-art methods. Future work can be devoted to combining explicit geometric priors (as in the case of the WARP baseline), with the adversarial framework adopted by the proposed method.
in the case of point of view adaptation.
\bibliographystyle{apalike}
\section{SceneAdapt Method}
\label{sec:method}
\begin{figure}[th!]
\centering
\includegraphics[width=1\linewidth]{images/model.pdf}
\caption{The proposed SceneAdapt architecture to train semantic segmentation networks for scene-based domain adaptation. During the training phase all networks are used employed (green ``Training'' dashed box), whereas only the part highlighted in blue is used for inference (blue ``Inference'' dashed box).}
\label{fig:model}
\vspace{-4mm}
\end{figure}
We propose SceneAdapt, a method to train a semantic segmentation network using labeled images from the source domain and only unlabeled images from the target domain. %
Indeed, at test time only the semantic segmentation module is needed to predict segmentation masks from images coming to both domains.
\subsection{Proposed Training Architecture}
\figurename~\ref{fig:model} illustrates the proposed training architecture, which consists of a the semantic network to be trained (\textit{F}), a generative network (\textit{G}), and a discriminator network (\textit{D}). The semantic network \textit{F} predicts semantic segmentation masks for images belonging to both the source and target domains. The ground truth segmentation masks of the source domain can be used to provide direct supervision to \textit{F} through a semantic segmentation loss. Direct supervision to \textit{F} cannot be provided for the target domain, where ground truth segmentation masks are not available. Therefore, we use the generator \textit{G} to reconstruct the input images from the generated ground segmentation masks and impose that the reconstructed images should be indistinguishable from the original ones.
This encourages the semantic segmentation network \textit{F} to encode details useful for the reconstruction in the produced segmentation masks (e.g., small objects such as traffic lights and cars), which are generally lost in cross-domain testing.
The reconstruction requirement is enforced using a reconstruction loss between original and generated images and an adversarial loss which makes use of a discriminator \textit{D} to improve the performance of the generator \textit{G} in an adversarial fashion. %
\textbf{Semantic Segmentation Component}
\textit{F} is responsible for predicting a segmentation mask for each input image, regardless of the related domain.
In our experiments, we implement this module using the PSPNet architecture proposed by~\cite{zhao2017pyramid}, which is a state of art model. The network is implemented using a pre-trained ResNet backbone~\cite{he2016deep}. We would like to note that, in principle, any semantic segmentation network trainable end-to-end through gradient descent can be used to implement \textit{F}.
\textbf{Generator Component}
\textit{G} is used to reconstruct the input images from the segmentation masks generated using \textit{F}. Specifically, the network \textit{G} takes over the pixel-wise class scores produced by the semantic segmentation network \textit{F} and generates an RGB image of the same dimensions as the input image. We implement the generator component using the architecture proposed by~\cite{johnson2016perceptual}, as implemented in~\cite{CycleGAN2017}.
\textbf{Discriminator Component}
\textit{D} allows to train the system using adversarial learning. Specifically, the discriminator is trained to distinguish between the input images and the generated ones, whereas the \textit{F} and \textit{G} components are joinlty trained to ``fool'' the discriminator, as proposed in~\cite{goodfellow2014generative}.
\textit{D} is implemented considering the PatchGANs architecture used in~\citep{isola2017image, li2016precomputed, ledig2016photo}. The network operates on $70 \times 70$ overlapping image patches. This patch-level discriminator architecture has fewer parameters than a full-image discriminator and can be applied to arbitrarily-sized images in a fully convolutional fashion as described in~\cite{isola2017image}.
\subsection{Loss Functions}
\label{loss}
The overall architecture illustrated in~\figurename~\ref{fig:model} is trained using a composite loss which encourages the network to produce good semantic segmentation masks for both domains. Specifically, the loss combines a semantic segmentation loss, a reconstruction loss and an adversarial loss. %
\textbf{Semantic Segmentation Loss\hspace{2mm}}
This loss is used to provide direct supervision to \textit{F}, when it is trained with images from the source domain.
The loss is computed as the pixel-wise cross entropy between the inferred probability mask and the ground truth mask.
Note that this loss can be applied only to image-label pairs of the source domain, since no ground truth segmentation masks are available for images of the target domain.
Specifically, let $x$ be an image from the source domain $S$, let $F(x)$ be the set of scores produced by the semantic segmentation network, and let $\mathcal{S}(F(x))$ be the softmax of $F(X)$, computed along the class scores independently for each pixel.
Let $y$ be the ground truth segmentation mask associated to $x$, which indicates that a pixel $i$ belongs to class $y_{i}$.
We define the semantic segmentation loss as follows:
\begin{align}
\mathcal{L}_{Sem}(F) = \mathbb{E}_{x \sim p_S(x)} [ - \sum_{i} log(\mathcal{S}(F(x))_{i,{y_i}})],
\end{align}
where $p_S$ denotes the distribution of the data of the source domain, $i$ iterates over the pixels of the training image $x$, $\mathcal{S}$ denotes the softmax function, and $\mathcal{S}(F(x))_{i,{y_i}}$ denotes the probability predicted for class $y_i$ and pixel $i$.
\textbf{Reconstruction Loss\hspace{2mm}}
As done in~\cite{CycleGAN2017}, we use an $L_1$ loss to enforce the correct reconstruction of the input images starting from the pixel-wise class scores produced by the semantic segmentation network (before Softmax).
This loss is calculated for all the input-reconstructed image pairs of both the source and target domains.
The reconstruction loss is defined as follows:
\begin{align}
\mathcal{L}_{Rec}(G, F) = \mathbb{E}_{x \sim p_{ST}(x)} [||G(F(x)) - x||_1],
\end{align}
where $p_{ST}$ denotes the distribution of data belonging to both source and target domains, and $||\cdot||_1$ denotes the L1 norm. This loss is used to provide indirect supervision to the semantic network \textit{F} also for the unlabeled images belonging to the target domain, encouraging it to include in the segmentation mask domain-specific details useful for reconstruction.
\textbf{Adversarial Loss \hspace{2mm}} This loss allows to improve the performance of \textit{F} and \textit{G} in an adversarial fashion. Specifically, it forces the generator \textit{G} to produce better reconstructions and overcome the common limitations of regression-based losses for reconstruction purposes~\citep{mathieu2015deep}.
The loss is applied to images generated for both the source and target domain and is defined as follows:
\begin{align}
\mathcal{L}_{GAN}(G, F, D)=\mathbb{E}_{x \sim p_{ST}(x)} [log (D(x))] + \\ \mathbb{E}_{x \sim p_{ST}(x)} [log (1 - D(G(F(x))))].
\end{align}
\textbf{Overall Loss\hspace{2mm}} The overall loss used to optimize the whole training architecture is defined as the sum of the three losses discussed in previous sections:
\begin{align}
\mathcal{L}(G, F, D) =\mathcal{L}_{Sem}(F) + \mathcal{L}_{Rec}(G, F)+ \mathcal{L}_{GAN}(G, F, D).
\end{align}
\section{Related Work}
\label{sec:related}
\textbf{Semantic Segmentation\hspace{2mm}} Many recent works have proposed semantic segmentation algorithms based on deep learning. Among the most notable recent approaches, \cite{long2015fully} proposed fully convolutional networks, which are obtained by adapting existing CNNs for classification to produce dense image segmentation masks.
\cite{badrinarayanan2015segnet2} presented SegNet, a semantic segmentation approach based on an encoder-decoder architecture.
\cite{7913730} combined artrous convolution and artrous spatial pyramid pooling (ASPP) to segment objects at multiple scales, thus capturing both objects and image context.
\cite{DBLP:journals/corr/ZhaoQSSJ17} proposed a cascade network to achieve real-time semantic segmentation.
\cite{zhao2017pyramid} introduced PSPNet, which comprises a novel pyramid pooling module to leverage global contextual information.
The scene-adaptation approach presented in this paper can integrate any semantic segmentation method which is trainable end-to-end. In our experiments, we will consider the state-of-the-art PSPNet architecture.
\textbf{Adversarial learning\hspace{2mm}} The proposed approach leverages the paradigm of adversarial learning, originally introduced with Generative Adversarial Networks (GANs) by~\cite{goodfellow2014generative}.
In particular, our work is related to the investigations of~\cite{isola2017image,CycleGAN2017}, who addressed the problem of image translation using GANs. The image translation problem assumes the presence of two different domains $X$ and $Y$. The goal of image translation is to learn a function $F : X \rightarrow Y$ which maps an input $x \in X$ to an output $\hat{y}$ which is indistinguishable from the elements sampled from $Y$.
\textbf{Domain Adaptation for Semantic Segmentation\hspace{2mm}} The use of domain adaptation techniques for semantic segmentation has also been investigated in past works. \cite{hoffman2016fcns}, proposed a semantic segmentation network to perform global domain alignment with fully convolutional domain adversarial learning.
In a subsequent work,~\cite{hoffman2017cycada} proposed to adapt representations at the pixel-level and at the feature-level with cycle-consistency without requiring aligned pairs. This model has been applied to different visual recognition and prediction settings, including the semantic segmentation of road scenes. \cite{DBLP:journals/corr/abs-1711-06969} designed a domain adaptation method for semantic segmentation composed by an embedding network, a pixel-wise classifier, a generator network and a discriminator network.
\cite{DBLP:journals/corr/abs-1802-10349} employed a multi-level adversarial network to perform output space domain adaptation at different feature levels. The algorithm consists of two modules: a segmentation network and a discriminator operating at different levels of the network.
Some works address the domain gap created by the device used to capture the data~\cite{yang2019pass}
for instance addressed the domain gap between pinhole and omnidirectional perspectives, whereas~\cite{xiang2020boosting}
addressed semantic segmentation based on a dual-camera system with different perspectives and overlapped views. \cite{romera2019bridging},
focused on the domain gap due to the moment of the day in which a given a scene has been captured.
Our method leverages some of the intuitions presented in these prior works, framing the investigation in the context of the proposed scene-adaptation task.
\section{Experimental Settings and Results}
\label{sec:settings}
We compare the proposed method with respect to the following baselines and state of the art domain adaptation techniques:
\textbf{No Adaptation (NA)\hspace{2mm}} This baseline is obtained training PSPNet, on the source domain and testing it on the target domain, without adaptation;
\textbf{Fine Tuning (FT)\hspace{2mm}} This is a strong baseline, obtained performing the fine-tuning procedure, i.e., training PSPNet on the target domain using ground truth annotations. It should be noted that, since this strong baseline uses the ground truth annotations, it is reported for reference only.
\textbf{Geometric Warp (WARP)\hspace{2mm}} This baseline tries to model the domain gap through geometrical considerations. In particular, it assumes that an affine transformation $\mathcal{H}$ between the source and target scenes exists and is known. Hence, we test this baseline only in the case of point of view adaptation, where a geometrical correspondence between the scenes can be established.
At training time, all images from the source domain are warped using $\mathcal{H}$ in order to match the geometry of the target domain.
The same transformation is applied to the ground truth segmentation masks with nearest neighbor interpolation to recover the class of missing points.
A PSPNet model is hence trained on the warped images.
The network is tested directly on the target domain images, where no warp operation is needed.
It should be noted that, as the source images need to be mapped to a higher resolution in order to preserve the scale of the objects appearing in the scene, this baseline is computationally expensive to train.
\textbf{ASEGNET\hspace{2mm}} A domain adaptation approach proposed by~\cite{DBLP:journals/corr/abs-1802-10349}. We use the official implementation provided by the authors for the experiments;
\textbf{LSD\hspace{2mm}} A domain adaptation method proposed by~\cite{DBLP:journals/corr/abs-1711-06969}. This method is composed by
an encoder with a bottleneck, a decoder, and a semantic decoder. The encoder maps the input image to a spatial embedding space. The first decoder reconstructs the image form the embedded input, whereas the semantic decoder infers the semantic segmentation mask from the embedded input. Note that the main difference between the proposed LSD and the proposed method, is that we do not consider an embedded space. In contrast, we enforce that the produced semantic segmentation masks are sufficient to reconstruct the input. This is equivalent to considering a highly semantic embedding space induced by the softmax predictions. We use the official implementation provided by the authors for the experiments.
We perform two sets of experiments to assess the performance of the proposed method in the contexts of point of view adaptation and general scene adaptation.
In the first set of experiments (point of view adaptation), the source and target domains are related to images acquired in the same scene from different points of view.
In the second set of experiments (general scene adaptation), source and target domains are related to images acquired in different, non-overlapping scenes.
All algorithms have been trained till convergence.
The weights of the best epoch (according to the validation set) are selected for the evaluation.
For the baselines (i.e. NA and FT) and our method, we use PSPNet with Resnet-101 as backbone and we optimize using Stochastic Gradient Descent (SGD) with momentum equal to~$0.9$, initial learning rate equal to~$0.007$, weight decay equal to~$(1 - i/3750)^{0.9}$ (where~$i$ is the current iteration, and $3750$ is the total number of iterations) and batch size equal to~$8$.
The proposed method is optimized using the Adam optimizer, with initial learning rate equal to~$0.0002$ and batch size equal to~$1$.
LSD~\citep{DBLP:journals/corr/abs-1711-06969} is trained using SGD with momentum equal to $0.9$, initial learning equal to~$1.0 \cdot 10^{-5}$ and weight decay coefficient equal to $0.0005$.
ASEGNET~\citep{DBLP:journals/corr/abs-1802-10349} is trained using SGD with momentum $0.9$, initial learning equal to~$2.5 \cdot 10^{-4}$ and weight decay coefficient equal to $0.0005$. All the results have been evaluated using per-class accuracy ($c_{acc}$) and mean intersection over union ($m_{iou}$) as defined in~\cite{long2015fully}.
\subsection{Comparison with the state of the art}
\tablename~\ref{table:view} reports the point of view adaptation results\footnote{The results are averaged over the following source-target image pairs: $A1-B1$, $A2-B2$, $A3-B3$, $B1-A1$, $B2-A2$, $B3-A3$.}. Best per-row results are highlighted in bold numbers in the table. The cases in which the best method outperforms the \textit{FT} strong baseline are underlined.
The table reports the average results, as well as the breakdown according to the different classes.
\begin{table}[t]
\tiny
\centering
\caption{Point of view adaptation results.}
\label{table:view}
\begin{tabular}{c|c|c|c|c||c}
\multicolumn{6}{c}{\textbf{PER-CLASS ACCURACY}} \\ \hline
& \textbf{NA} & \textbf{ASEGNET} & \textbf{LSD} & \textbf{SceneAdapt} & \textbf{\textit{FT}} \\ \hline
\textbf{Average} & 0.53 & 0.52 & 0.59 & \textbf{\underline{0.72}} & \textit{0.69} \\ \hline
\textbf{Unlabeled} & 0.27 & 0.80 & 0.74 & \textbf{0.90} & \textit{0.96} \\
\textbf{Buildings} & \textbf{0.96} & 0.93 & 0.53 & 0.95 & \textit{0.98} \\
\textbf{Fences} & 0.28 & 0.36 & \textbf{\underline{0.58}} & 0.55 & \textit{0.50} \\
\textbf{Other} & 0.29 & 0.32 & 0.56 & \textbf{\underline{0.60}} & \textit{0.46} \\
\textbf{Pedestrians} & 0.21 & 0.04 & 0.11 & \textbf{\underline{0.53}} & \textit{0.21} \\
\textbf{Poles} & 0.05 & 0.08 & \textbf{\underline{0.44}} & 0.25 & \textit{0.22} \\
\textbf{Road-lines} & 0.36 & 0.38 & \textbf{\underline{0.55}} & 0.48 & \textit{0.44} \\
\textbf{Roads} & \textbf{0.96} & 0.88 & 0.59 & 0.93 & \textit{0.98} \\
\textbf{Sidewalks} & \textbf{0.97} & 0.88 & 0.73 & 0.93 & \textit{0.98} \\
\textbf{Vegetation} & \textbf{\underline{0.89}} & 0.72 & 0.77 & 0.82 & \textit{0.85} \\
\textbf{Vehicles} & 0.66 & 0.48 & 0.45 & \textbf{\underline{0.94}} & \textit{0.84} \\
\textbf{Walls} & 0.75 & 0.83 & \textbf{\underline{0.88}} & 0.82 & \textit{0.88} \\
\textbf{T. Signs} & 0.20 & 0.13 & \textbf{\underline{0.78}} & 0.68 & \textit{0.73} \\ \hline
\multicolumn{6}{c}{\textbf{MEAN INTERSECTION OVER UNION}} \\ \hline
\textbf{Average} & 0.32 & 0.37 & 0.34 & \textbf{0.57} & \textit{0.64} \\ \hline
\textbf{Unlabeled} & 0.26 & 0.75 & 0.48 & \textbf{0.85} & \textit{0.91} \\
\textbf{Buildings} & 0.74 & 0.87 & 0.49 & \textbf{0.93} & \textit{0.98} \\
\textbf{Fences} & 0.13 & 0.15 & 0.33 & \textbf{0.42} & \textit{0.42} \\
\textbf{Other} & 0.22 & 0.10 & 0.25 & \textbf{\underline{0.50}} & \textit{0.42} \\
\textbf{Pedestrians} & 0.09 & 0.03 & 0.09 & \textbf{0.13} & \textit{0.19} \\
\textbf{Poles} & 0.04 & 0.02 & 0.17 & \textbf{\underline{0.20}} & \textit{0.17} \\
\textbf{Road-lines} & 0.20 & 0.03 & 0.10 & \textbf{\underline{0.36}} & \textit{0.34} \\
\textbf{Roads} & 0.55 & 0.82 & 0.41 & \textbf{0.86} & \textit{0.95} \\
\textbf{Sidewalks} & 0.76 & 0.66 & 0.48 & \textbf{0.88} & \textit{0.92} \\
\textbf{Vegetation} & 0.52 & 0.49 & 0.64 & \textbf{0.71} & \textit{0.74} \\
\textbf{Vehicles} & 0.23 & \textbf{0.37} & 0.33 & 0.26 & \textit{0.78} \\
\textbf{Walls} & 0.28 & 0.52 & 0.31 & \textbf{0.71} & \textit{0.83} \\
\textbf{T. Signs} & 0.16 & 0.03 & 0.39 & \textbf{0.63} & \textit{0.70} \\ \hline
\end{tabular}
\vspace{-4mm}
\end{table}
\begin{table}[t]
\centering
\caption{Results of the WARP baseline for the $A1$-$B1$ pair.} \tiny
\label{table:affine}
\begin{tabular}{ccc}
& \textbf{Per Class Accuracy} & \textbf{MIoU}\\ \hline
NA & 0.47 & 0.43 \\
WARP & 0.58 & 0.46 \\
SceneAdapt & \underline{\textbf{0.75}} & \textbf{0.62} \\ \hline
\textit{FT} & \textit{0.72} & \textit{0.66} \\ \hline
\end{tabular}
\end{table}
The proposed method outperforms with a good margin all competitors (in average) considering both per-class accuracy and mean intersection over union. Interestingly, while the strong baseline \textit{FT} reports in general the best results, the proposed method outperforms \textit{FT} for some classes such as ``Fences'', ``Pedestrians'', ``Vehicles'' and ``T. Signs''.
This suggests that a) the proposed training architecture benefits from joint domain training, as compared to training only with data coming from one domain (as in FT) and b) the proposed method can effectively prevent over-fitting improving the segmentation of small objects.
Similar gains can be observed for the mean intersection over union measure.
\tablename~\ref{table:affine} compares the performance of the WARP baseline with respect to \textit{NA}, \textit{FT} and the proposed method. Please note that, since the WARP baseline is very computationally expensive, we perform these experiments only on the \textit{A1-B1} pair. It is worth noting that beside being very computationally expensive to train, the WARP baseline only allows to obtain minor improvements \textit{NA}, reaching sub-optimal performance with respect to the proposed approach. This suggests that, while a geometric prior can be helpful, the proposed framework implicitly allows to learn some of the differences in the scene layouts arising from different points of view.
\begin{table}[t]
\tiny
\centering
\caption{Scene adaptation results.}
\label{table:episode}
\begin{tabular}{c|c|c|c|c||c}
\multicolumn{6}{c}{\textbf{PER-CLASS ACCURACY}} \\ \hline
& \textbf{NA} & \textbf{ASEGNET} & \textbf{LSD} & \textbf{SceneAdapt} & \textbf{\textit{FT}} \\ \hline
\textbf{Average} & 0.27 & \textbf{0.37} & 0.32 & 0.34 & \textit{0.68} \\ \hline
\textbf{Unlabeled} & 0.53 & 0.54 & 0.39 & \textbf{\underline{0.69}} & \textit{0.23} \\
\textbf{Buildings} & 0.09 & 0.18 & 0.17 & \textbf{0.25} & \textit{0.99} \\
\textbf{Fences} & 0.07 & 0.03 & \textbf{0.25} & 0.01 & \textit{0.52} \\
\textbf{Other} & 0.02 & \textbf{0.07} & 0.02 & 0.00 & \textit{0.70} \\
\textbf{Pedestrians} & 0.05 & 0.01 & 0.03 & \textbf{0.13} & \textit{0.38} \\
\textbf{Poles} & 0.03 & 0.11 & \textbf{0.25} & 0.03 & \textit{0.25} \\
\textbf{Road-lines} & 0.13 & \textbf{\underline{0.66}} & 0.49 & 0.52 & \textit{0.43} \\
\textbf{Roads} & \textbf{0.84} & 0.78 & 0.75 & 0.77 & \textit{0.99} \\
\textbf{Sidewalks} & 0.67 & \textbf{0.69} & 0.67 & 0.50 & \textit{0.98} \\
\textbf{Vegetation} & 0.41 & 0.22 & 0.39 & \textbf{0.49} & \textit{0.94} \\
\textbf{Vehicles} & 0.61 & 0.57 & 0.35 & \textbf{0.81} & \textit{0.89} \\
\textbf{Walls} & \textbf{0.00} & \textbf{0.00} & \textbf{0.00} & \textbf{0.00} & \textit{0.94} \\
\textbf{T. Signs} & 0.04 & \textbf{\underline{0.99}} & 0.73 & 0.18 & \textit{0.65} \\ \hline
\multicolumn{6}{c}{\textbf{MEAN INTERSECTION OVER UNION}} \\ \hline
\textbf{Average} & 0.19 & 0.18 & 0.20 & \textbf{0.22} & \textit{0.47} \\ \hline
\textbf{Unlabeled} & 0.30 & 0.46 & 0.17 & \textbf{\underline{0.50}} & \textit{0.22} \\
\textbf{Buildings} & 0.07 & 0.09 & 0.25 & \textbf{0.25} & \textit{ 0.90} \\
\textbf{Fences} & \textbf{0.06} & 0.01 & 0.02 & 0.01 & \textit{0.21} \\
\textbf{Other} & \textbf{0.02} & 0.01 & 0.01 & 0.00 & \textit{0.40} \\
\textbf{Pedestrians} & \textbf{0.03} & 0.01 & \textbf{0.03} & 0.02 & \textit{0.15} \\
\textbf{Poles} & 0.01 & 0.01 & \textbf{0.08} & 0.02 & \textit{0.25} \\
\textbf{Road-lines} & 0.13 & 0.07 & 0.27 & \textbf{\underline{0.40}} & \textit{0.33} \\
\textbf{Roads} & 0.62 & \textbf{0.71} & 0.65 & 0.59 & \textit{0.88} \\
\textbf{Sidewalks} & \textbf{0.45} & 0.44 & 0.40 & 0.43 & \textit{0.88} \\
\textbf{Vegetation} & 0.28 & 0.10 & 0.23 & \textbf{0.33} & \textit{0.54} \\
\textbf{Vehicles} & 0.40 & \textbf{0.48} & 0.25 & 0.21 & \textit{0.71} \\
\textbf{Walls} & \textbf{0.00} & \textbf{0.00} & \textbf{0.00} & \textbf{0.00} & \textit{0.71} \\
\textbf{T. Signs} & 0.04 & 0.00 & \textbf{\underline{0.31}} & 0.16 & \textit{0.07} \\ \hline
\end{tabular}
\vspace{-4mm}
\end{table}
\tablename~\ref{table:episode} reports the scene adaptation results\footnote{These results are averaged over the following source-target image pairs: $A1-A2$, $A1-A3$, $A2-A1$, $A2-A3$, $A3-A1$, $A3-A2$.}.
The proposed method outperforms all competitors in the case of mean intersection over union and achieves state-of-the-art results in the case of per-class accuracy. The results highlight that general scene adaptation is
much more difficult than point of view adaptation. Specifically, the proposed method tends to achieve sub-optimal results as compared to the \textit{FT} strong baseline. This suggests that, due to the radical change
of the image layout due to the very different scenes, the proposed method is not always able to accurately segment small objects such as ``pedestrians'' and ``traffic lines'', albeit it generally improves over the NA baseline.
A closer comparison between the LSD method and the proposed approach suggests that using the embedding space induced by the softmax predictions as done by our method is beneficial in the view adaptation scenario for almost all classes with respect to the mean intersection over union measure. In the scene adaptation scenario, our embedding works better with larger classes such as ``vegetation''.
\begin{figure}[h!]
\hspace{0.02\linewidth}
\begin{minipage}{0.7\linewidth}
\tiny
\begin{tabular}{cc|c}
& \multicolumn{2}{c}{\includegraphics[width=\textwidth]{images/legend}} \\
\raisebox{4\normalbaselineskip}[0pt][0pt]{\rotatebox[origin=c]{90}{\textit{Source}}} &
\includegraphics[width=0.49\textwidth]{images/results-e17/image_01500.png} &
\includegraphics[width=0.49\textwidth]{images/results-e88-e17/image_00855.png} \\
\raisebox{4\normalbaselineskip}[0pt][0pt]{\rotatebox[origin=c]{90}{\textit{Target}}} &
\includegraphics[width=0.49\textwidth]{images/results-e17/image_01500_real.png} &
\includegraphics[width=0.49\textwidth]{images/results-e88-e17/image_00855_real.png} \\
\raisebox{4\normalbaselineskip}[0pt][0pt]{\rotatebox[origin=c]{90}{\textit{NA}}} &
\includegraphics[width=0.49\textwidth]{images/results-e17/image_01500_baseline.png} &
\includegraphics[width=0.49\textwidth]{images/results-e88-e17/image_00855_baseline.png} \\
\raisebox{4\normalbaselineskip}[0pt][0pt]{\rotatebox[origin=c]{90}{\textit{ASEGNET}}} &
\includegraphics[width=0.49\textwidth]{images/results-e17/image_01500_ada.png} &
\includegraphics[width=0.49\textwidth]{images/results-e88-e17/image_00855_ada.png} \\
\raisebox{4\normalbaselineskip}[0pt][0pt]{\rotatebox[origin=c]{90}{\textit{LSD}}} &
\includegraphics[width=0.49\textwidth]{images/results-e17/image_01500_lsd.png} &
\includegraphics[width=0.49\textwidth]{images/results-e88-e17/image_00855_lsd.png} \\
\raisebox{4\normalbaselineskip}[0pt][0pt]{\rotatebox[origin=c]{90}{\textit{SceneAdapt}}} &
\includegraphics[width=0.49\textwidth]{images/results-e17/image_01500_gan.png} &
\includegraphics[width=0.49\textwidth]{images/results-e88-e17/image_00855_gan.png} \\
\raisebox{4\normalbaselineskip}[0pt][0pt]{\rotatebox[origin=c]{90}{\textit{FT}}} &
\includegraphics[width=0.49\textwidth]{images/results-e17/image_01500_upper.png} &
\includegraphics[width=0.49\textwidth]{images/results-e88-e17/image_00855_upper.png} \\
\raisebox{4\normalbaselineskip}[0pt][0pt]{\rotatebox[origin=c]{90}{\textit{GT}}} &
\includegraphics[width=0.49\textwidth]{images/results-e17/image_01500_mask.png} &
\includegraphics[width=0.49\textwidth]{images/results-e88-e17/image_00855_mask.png} \\
& \multicolumn{1}{c|}{\normalsize (a)} & \multicolumn{1}{c}{\normalsize (b)}
\end{tabular}
\end{minipage}
\caption{Qualitative comparisons of the considered method on the view adaptation (a) and scene adaptation (b) tasks.}
\label{figure:results:view}
\vspace{-5mm}
\end{figure}
\figurename~\ref{figure:results:view} reports some qualitative examples of the compared methods on the tasks of view and scene adaptation.
\begin{table*}[th!]
\scriptsize
\centering
\caption{Results of the ablation study.}
\label{table:ablation}
\begin{tabular}{cccc}
\textbf{Loss} & \textbf{Adaptation} & $\mathbf{c_{acc}}$ & $\mathbf{m_{iou}}$\\ \hline
$\mathcal{L}_{SemS}(F) + \mathcal{L}_{Rec}(G, F)$ & point of view & \textbf{0.77} & \textbf{0.67} \\
$\mathcal{L}_{SemS}(F) + \mathcal{L}_{GAN}(G, F, D)$ & point of view & 0.71 & 0.55 \\
$\mathcal{L}_{SemS}(F) + \mathcal{L}_{Rec}(G, F) + \mathcal{L}_{GAN}(G, F, D)$ & point of view & 0.75 & 0.62 \\ \hline
$\mathcal{L}_{SemS}(F) + \mathcal{L}_{Rec}(G, F)$ & scene & 0.33 & 0.20 \\
$\mathcal{L}_{SemS}(F) + \mathcal{L}_{GAN}(G, F, D)$ & scene & 0.38 & \textbf{0.24} \\
$\mathcal{L}_{SemS}(F) + \mathcal{L}_{Rec}(G, F) + \mathcal{L}_{GAN}(G, F, D)$ & scene & \textbf{0.39} & \textbf{0.24} \\ \hline
\end{tabular}
\vspace{-4mm}
\end{table*}
\subsection{Ablation study}
To assess the contribution of the reconstruction and adversarial losses described in Section~\ref{loss},
we tested three versions of the proposed method on the $A1-B1$ pair for view adaptation and on the $A1-A2$ pair for scene adaptation.
Each considered version of the proposed method is trained using different combinations of loss functions as it is shown in \tablename~\ref{table:ablation}.
From the results, it can be observed that dropping the adversarial term in the loss function allows to obtain a boost of $+2\%$ in per-class accuracy and $+5\%$
in mean intersection over union, whereas dropping the reconstruction term yields worse results. Conversely, for general scene adaptation, the L1 reconstruction term has
marginal importance, while combining both reconstruction and adversarial losses leads to the best results.
These observations suggest that the L1 term can impose a strong geometric prior, which is useful in the case of point of view adaptation, where the scenes present similar, yet distinct,
layouts. When geometric layouts are more diverse, as in the case of scene adaptation, the adversarial term is more beneficial and can overcome the
``regression-to-the-mean'' effect which could be induced by the L1 loss.
We also assessed if the proposed method allows to improve segmentation results on the source domain thanks to the additional unlabeled images coming from the target domain seen during the training phase.
To assess generalization in the case of point of view adaptation, we trained the proposed method on the training sets of the source-target pair $A1-B1$ and tested it on the test set of $A1$ (the source domain).
\tablename~\ref{table:source_domain} compares the results with respect to the NA baseline. As can be noted, the proposed method allows to improve performance on the source domain in all cases.
This suggests a regularizing effect induced by the use of unlabeled images from the target domain. \tablename~\ref{table:source_domain_2} further compares the proposed SceneAdapt method with respect to the NA baseline reporting per-class measures. Interestingly, most of the improvement is obtained with respect to classes denoting small scene elements, such as ``fences'' (from $0.4/0.31$ to $0.63/0.44$ - Per-class Acc./Mean IoU) and ``pedestrians'' (from $0.16/0.15$ to $0.41/0.27$), which are the most sensitive to the changes of points of view. This suggests that the proposed approach successfully encourages the semantic segmentation network to focus on task-relevant details.
\begin{table*}[th!]
\setlength{\tabcolsep}{0.2em}
\scriptsize
\centering
\caption{Improvement on the source domain.}
\label{table:source_domain}
\begin{tabular}{cccccc}
\textbf{Source} & \textbf{Target} & \textbf{Adaptation} & \textbf{Method} & \textbf{Measure} & \textbf{Test Results} \\
\hline
$A1$ & - & - & No Adaptation & Per Class Accuracy & $0.70$ \\
$A1$ & - & - & No Adaptation & Mean IoU & $0.64$ \\ \hline
$A1$ & $B1$ & point of view & SceneAdapt & Per Class Accuracy & $0.74$ \\
$A1$ & $B1$ & point of view & SceneAdapt & Mean IoU & $0.65$ \\ \hline
$A1$ & $A2$ & scene & SceneAdapt & Per Class Accuracy & $0.75$ \\
$A1$ & $A2$ & scene & SceneAdapt & Mean IoU & $0.66$ \\ \hline
\end{tabular}
\vspace{-4mm}
\end{table*}
\begin{table}[t]
\tiny
\centering
\caption{Results on the source domain for point of view adaptation.}
\label{table:source_domain_2}
\begin{tabular}{c|c|c|c|c}
& \multicolumn{2}{c|}{\textbf{PER-CLASS ACC.}} & \multicolumn{2}{c}{\textbf{MEAN IoU}} \\ \hline
& \textbf{NA} & \textbf{SceneAdapt} & \textbf{NA} & \textbf{SceneAdapt} \\ \hline
\textbf{Average} & 0.69 & \textbf{0.76} & \textbf{0.64} & \textbf{0.64} \\ \hline
\textbf{Unlabeled} & 0.77 & \textbf{0.79} & \textbf{0.70} & \textbf{0.70} \\
\textbf{Buildings} & \textbf{0.98} & 0.97 & \textbf{0.97} & 0.84 \\
\textbf{Fences} & 0.40 & \textbf{0.63} & 0.31 & \textbf{0.44} \\
\textbf{Other} & 0.65 & \textbf{0.83} & 0.50 & \textbf{0.68} \\
\textbf{Pedestrians}& 0.16 & \textbf{0.41} & 0.15 & \textbf{0.27} \\
\textbf{Poles} & 0.15 & \textbf{0.45} & 0.14 & \textbf{0.32} \\
\textbf{Road-lines} & 0.43 & \textbf{0.67} & 0.39 & \textbf{0.52} \\
\textbf{Roads} & \textbf{0.99} & 0.92 & \textbf{0.97} & 0.88 \\
\textbf{Sidewalks} & \textbf{0.97} & 0.85 & \textbf{0.93} & 0.73 \\
\textbf{Vegetation} & \textbf{0.94} & 0.90 & \textbf{0.78} & 0.77 \\
\textbf{Vehicles} & \textbf{0.88} & 0.83 & \textbf{0.84} & 0.73 \\
\textbf{Walls} & \textbf{0.96} & 0.73 & \textbf{0.90} & 0.69 \\
\textbf{T. Signs} & 0.76 & \textbf{0.93} & \textbf{0.74} & 0.76 \\ \hline
\end{tabular}
\vspace{-4mm}
\end{table}
| {'timestamp': '2020-06-19T02:12:39', 'yymm': '2006', 'arxiv_id': '2006.10386', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10386'} | arxiv |
\section{Minimizers to the convex-type TV have sparse support}
\label{sec:tv}
In this section we will first focus on understanding the solutions of the regularised interpolation problem (\ref{eq:ermmeasure}), for potential functions $V$ of the form $V(\boldsymbol{\theta}) = |c| w(a,b)$ for a given regularization weight $w$. As discussed so far, this problem is motivated by the case $w = \sqrt{\|a\|^2+b^2}$, corresponding to variation-norm learning \cite{bach2017breaking} (and which, as seen in \cite{ongie_function_2019} is also related to a Tikhonov-type regularization). Another example is the implicit regularization scheme discussed in section \ref{sec:noise}.
By the rescaling trick (see the discussion in section \ref{sec:equivalent_relu}) it suffices to consider the case where $w(a,b)$ is homogeneous of degree $1$ in the sense that for $\lambda > 0$ we have $w(\lambda a, \lambda b) = \lambda w (a,b)$. These weights can never be strictly convex (a desirable quantity when looking for uniqueness or sparsity of limits) because homogeneous functions are never strictly convex: $w(2a,2b) = \frac 1 2 (w(a,b)+ w(3a,3b))$. This obstruction, however, appears only from the \emph{parameter} perspective but not from the \emph{neuron} perspective, because proportional parameters also represent proportional neurons. This is a motivation for the \emph{effective convexity} definition in section \ref{sec:equivalent_relu}.
Lemma \ref{lem:noise_convexity} in section \ref{sec:equivalent_relu} shows that the implicit regularization term that appeared in \cite{blanc_implicit_2019} is also effectively strictly convex. The fact that the TV norm is effectively strictly convex is a direct consequence of Minkowski's inequality.
The definition of \emph{effective} strict convexity motivates an analog definition of sparsity on lifted measures:
\begin{defn}
\label{def:effsupp}
A lifted measure $\mu(a,b,c)$ is effectively supported on $n$ points if the support of $\mu$ is contained on the union of at most $n$ half-planes of the form:
\begin{equation}
H_{a,b} = \{(\beta a, \beta b, c), c\in \mathbb R,\beta \in\mathbb R_{\ge 0}\}
\end{equation}
\end{defn}
If a lifted measure is effectively supported on $n$ points, then (by construction) there is a lifted measure supported on exactly $n$ points that represents the same function. With this definition in hand we are ready to state the main result of this section (see Figure 1 for an illustration motivating the theorem):
\begin{thm}
\label{thm:weight_implies_sparsity}
Let $w(a,b)$ be a 1-homogeneous effectively strictly convex regularization weight and $V(\boldsymbol{\theta}) = |c| w(a,b)$ the associated potential. Then the solutions of the problem (\ref{eq:ermmeasure}) are all effectively supported on a finite number of points. The number of points in the solution is bounded by $O(n)^{O(d)}$.
\end{thm}
The proof of the theorem has two steps. In the first step we will split the parameter space $(a,b)$ into cells where the parameters interact in a particularly nice way. This cell decomposition is reminiscent of the ``open sectors" described in \cite{maennel_gradient_2018}\footnote{The cells defined in this work are the closure of the open sectors defined by Maennel et. al.}. The second step is to use the effective strict convexity result to show that, on each of those cells, optimizing measures are supported on at most one point.
\paragraph{Cell decomposition of the parameter space}
Fix a dataset $\mathcal{D}=\{\boldsymbol{x}_i\}_{i=1}^n$, with $\boldsymbol{x}_i \in \mathbb R^{d}$. This will split the parameter space of $\theta$ into a finite amount of convex cones $C_1, \dots C_S$ that we will call cells, such that two neurons belong to the same cell iff they are active on the same datapoints. We will consider closed cells, and therefore there will be overlap at the boundary of the cells. By interpreting each datapoint with is dual hyperplane, there is a one-to-one correspondence between these cells and the resulting hyperplane arrangement, thus $S \simeq n^d$ in generic datasets.
A key property of the cells is that the map $\theta=(a,b)\mapsto \sigma(\theta, \boldsymbol{x})=(a^\top \boldsymbol{x} +b)_+$ is linear when restricted to a single cell. From the convexity, the cone property, and the restricted linearity property, one can extract the following result:
\begin{lemma}[Discrete version]
\label{lem:didi}
If two parameters $ (a,b),(a',b')$ belong to the same cell, then for all the datapoints $\boldsymbol{x}_i$ it holds that
\begin{equation}
\label{eq:effective_linearity}
( a^\top \boldsymbol{x}_i + b)_++((a')^\top \boldsymbol{x}_i + b')_+ = ((a+a')^\top \boldsymbol{x}_i+(b+b'))_+~.
\end{equation}
\end{lemma}
Using induction, plus standard limiting arguments this lemma can be upgraded to the measure-valued case:
\addtocounter{thm}{-1}
\begin{lemma}[Continuous version]
If two measures $\mu(a,b,c),\mu'(a,b,c)$ are supported on the same cell $C$, then
\begin{equation}
\langle \phi_{\boldsymbol{x}_i}, \mu \rangle = \langle \phi_{\boldsymbol{x}_i}, \mu' \rangle
\end{equation}
for all data points $\boldsymbol{x}_i$ whenever the moment estimates hold:
\begin{equation}
\label{eq:moment_estimates}
\begin{cases}
\int_{C} c a\,d\mu(a,b,c) = \int_{C} c a\,d\mu'(a,b,c) & (\text{moment estimate for }a)\\
\int_{C} cb\,d\mu(a,b,c) = \int_{C} c b\,d\mu'(a,b,c) & (\text{moment estimate for }b)\\
\end{cases}
\end{equation}
\end{lemma}
\paragraph{Effective convexity - measure case.} \todo{He canviat aquest a paragraf x consistencia OK}
Now we want to show that the effective convexity concentrates the mass on each cell. We will first study measures that are already concentrated on a single cell, and then patch the result.
A first step is that effective convexity for $w(a,b)$ induces a similar notion effective convexity on $|c|w(a,b)$:
\begin{lemma}
[Lifting of the effective convexity]
Let $w(a,b)$ be a 1-homogeneous effectively strictly convex regularization weight. Let $(a,b,c), (a',b',c')$, and $\lambda \in (0,1)$. Then
\begin{equation}
|\lambda c + (1-\lambda) c'|w(\lambda a+(1-\lambda) a', \lambda b+(1-\lambda) b') = \lambda |c|w(a,b)+(1-\lambda)|c'|w(a',b')
\end{equation}
if and only if there exist constants $\alpha,\beta \in \mathbb R^+$ such that $(a,b,c) = (\alpha a,\alpha b,\beta c)$.
\end{lemma}
In other words, the only scenario where there is no strict convexity is when testing on parameters that represent neurons proportional to each other, since the condition $(a,b,c) = (\alpha a,\alpha b,\beta c)$ is equivalent to saying that the two ReLU neurons share the same hyperplane.
Convex functions have a unique minimizer, and, in the same way we bootsrapped the discrete, single-variable information into its continuous counterpart in Lemma \ref{lem:didi}, we can see that:
\begin{lemma}
\label{lem:one_point_per_cell}
Let $w(a,b)$ be a 1-homogeneous effectively strictly convex regularization weight, and fix a data cell.
Amongst all the measures $\nu(a,b)$ which are supported on the fixed cell and have the same moment estimates (eq \eqref{eq:moment_estimates}), the minimizers of $L_{w}(\nu)$ are effectively supported on one point.
\end{lemma}
\todo{He descommmentat aquesta linea, crec que si no queda molt sec, no?}Lemma \ref{lem:one_point_per_cell} is the key ingredient for the proof of Theorem \ref{thm:weight_implies_sparsity}:\begin{proof}[Proof of Theorem \ref{thm:weight_implies_sparsity}]
We can write our measure $\mu = \sum_{i \in \text{Cells}} \mu_i$ where each $\mu_i$ is supported on the closure of a cell. By the previous results, on each cell the associated measure $\mu_i$ has to be supported at at most one point.
\end{proof}
\begin{figure}
\centering
\begin{minipage}[t]{.3\textwidth}
\includegraphics[width=\textwidth]{Parts/IMG/cells_a.png}
\footnotesize
Figure 1.a: \textbf{Data-space perspective:} Each ReLu separates the data space into two half-spaces, the active half-space and the non-active. Given a subset $\mathcal{D'} \subseteq \mathcal D$ of datapoints (in orange) there is at most one ReLu active at all points of $\mathcal D'$ but non-active in all points in $\mathcal D\setminus\mathcal D'$.
\end{minipage}
\hspace{.02\textwidth}
\begin{minipage}[t]{.3\textwidth}
\includegraphics[width=\textwidth]{Parts/IMG/cells_b.png}
\footnotesize
Figure 1.b: \textbf{Parameter-space perspective:} Each data-point induces a hyperplane on the parameter space: the set of ReLu parameters that have the datapoint at the hinge. There is at most one neuron (in red) on each cell generated by these hyperplanes (See 1.c).
\end{minipage}
\hspace{.02\textwidth}
\begin{minipage}[t]{.3\textwidth}
\includegraphics[width=\textwidth]{Parts/IMG/cells_c.png}
\footnotesize
Figure 1.c: \textbf{Single-cell optimizers:} If a cell has more than one neuron on a cell, substituting all the neurons on the cell by a neuron in the center of mass will not affect the predictions on the data, but will give a gain on the regularizer.
\end{minipage}
\vspace{-.1in}
\end{figure}
\paragraph{Recovering Discrete Minimisers by Projecting into the Sphere: }
Since the constrained optimization problem (\ref{eq:ermmeasure}) is defined over probability measures in the lifted space $\Theta$, there is a price to pay to recover discrete minimizers, what we called `effective' support in definition \ref{def:effsupp}. In the TV case, this aspect disappears as one looks at the equivalent problem in the space $\mathcal{M}(\mathbb{S}^d)$, as shown in the following corollary:
\begin{cor}
\label{cor:radonversion}
Let
\begin{equation}
\label{eq:ermradon}
\min_{\nu \in \mathcal{M}(\mathbb{S}^d)} \| \nu \|_{\mathrm{TV}} ~s.t.~\int_{\mathbb{S}^d} \sigma(\langle \tilde{\boldsymbol{x}}_i, {\theta} \rangle) d\nu(\theta) = y_i ~\text{ for } i=1\dots n~.
\end{equation}
Then the solutions of (\ref{eq:ermradon}) are all supported on a finite number of points, of the same cardinality as in Theorem \ref{thm:support_is_unique}.
\end{cor}
\paragraph{Unicity of Supports Across all minimisers:}
We have so far proven that solutions to the constrained minimization have a single mass point at each cell. However, a strictly stronger result holds:
\begin{thm}
\label{thm:support_is_unique}
Let $C$ be a cell. Let $\mu, \mu'$ be zero-errror minimizers of $L_{\text{reg}}$ with non-zero support on $C$. Then both $\mu$ and $\mu'$ are effectively supported in the same single point in $C$.
\end{thm}
\begin{proof}[Proof sketch]
By contradiction, let $\mu, \mu'$ have different (effective) support on the same cell. By strict convexity the average of $\mu$ and $\mu'$ would also be a minimizer supported in two points in $C$, but that would contradict Lemma \ref{lem:one_point_per_cell}.
\end{proof}
\paragraph{Penalized minimization problem:}
In a parallel fashion to the problem presented in this section, one can study the \emph{penalized} version (\ref{eq:penform}). All the sparsity results in this section (Theorems \ref{thm:weight_implies_sparsity}, \ref{thm:support_is_unique} and Corollary \ref{cor:radonversion} in particular, but also suitable variations of the intermediate lemmas) transfer to the convex case for arbitrary $\lambda>0$, as explained in the appendix:
\begin{cor}
\label{cor:penresult}
Under the same assumptions of Theorem \ref{thm:support_is_unique} and for any $\lambda>0$, all minimisers of $\mathcal{L}_\lambda(\mu)$ are effectively supported on a finite number of points. For the corresponding problem expressed in the projected $\mathrm{P}(\mu) \in \mathcal{M}(\mathbb{S}^d)$, all minimisers are supported on a finite number of points.
\end{cor}
\paragraph{Implicit versus TV regularisation: } We can make the following observations on the relationship between the two forms of regularisation:
\begin{itemize}
\item The implicit regularization is translation invariant while TV regularization is not. One could remove the bias ($b$) dependence on TV (and consider $V(a,b,c) = |c|\|a\|$, but in this case theorems \ref{thm:weight_implies_sparsity}, \ref{thm:support_is_unique} become false). This is not a draw-back for all applications (for example in image processing, since translation corresponds to a color change).
\item Implicit regularization is (in principle) more costly to compute, especially whenever the number datapoints is large.
\end{itemize}
\paragraph{From discrete solutions to sparse solutions:}
Corollary \ref{cor:radonversion} and Theorem \ref{thm:support_is_unique} allow us to turn the original infinite-dimensional problem into a $S$-dimensional linear problem with linear constraints, where the only free parameters are the the amount of (signed) \emph{mass} that is given to each cell. Recall that $S$ corresponds to the number of cells of the hyperplane arrangement determined by the datapoints in the projective space.
Focusing on the TV case, let
$\nu = \sum_{s=1}^S z_s \delta_{\theta_s} \in \mathcal{M}(\mathbb{S}^d)$
be a minimiser of (\ref{eq:ermradon}). Observe that as a consequence
of Theorem \ref{thm:support_is_unique}, the locations $\theta_1 \dots \theta_S$ are shared across every minimiser (but unknown a priori).
Its coefficients $z=(z_1\dots z_S)$ are thus solutions of the linear program
\begin{equation}
\label{eq:finitedim}
\min \| z \|_1 ~s.t.~\mathcal{A}z = y~,
\end{equation}
where $\mathcal{A} \in \mathbb{R}^{n \times S}$ is the matrix $\mathcal{A}_{i,s} = (\langle \tilde{\boldsymbol{x}}_i, \theta_s \rangle)_+$.
From the Representer theorem, we know that there exists a solution $z^*$ of (\ref{eq:finitedim}) of support $\| z^* \|_0 \leq n \ll S$, and in the generic case this solution is the sparsest one, ie $z^*$ solves the $\ell_0$ minimisation counterpart of (\ref{eq:finitedim}).
A natural question is thus to understand under what conditions on the data the $\ell_1$ and $\ell_0$ problems share the same minimisers. This is an instance of Compressed Sensing, which could be analysed by studying properties of the sensing matrix $\mathcal{A}$ such as the RIP (leveraging random datasets) or the Nullspace property. This question has been also recently studied in \cite{ergen2020convex}. This is out of the scope of the present work and is left for future research.
\paragraph{Consequences for Gradient-Descent Optimization:}
With abuse of notation, let
\begin{equation}
\mathcal{L}(\nu) = \frac{1}{n} \sum_{i=1}^n \left| \int_{\mathbb{S}^d} \sigma(\langle \tilde{\boldsymbol{x}}_i, \theta\rangle ) d\nu(\theta) - y_i \right|^2 + \lambda \| \nu \|_{\mathrm{TV}}
\end{equation}
be the penalized form of the regularised problem, expressed in terms of the Radon measure in $\mathbb{S}^d$. The ability of gradient-descent to minimise such problems was recently studied in \cite{chizat2019sparse}, leading to a positive result under cetain assumptions, notably that minimisers are discrete and `feel' a positive curvature around their support.
The local convexity analysis that resulted in the discrete characterisation of solutions for this penalised problem (Lemma \ref{lem:one_point_per_cell}) brings precisely this geometric property around minimisers, suggesting
a favorable case for gradient-descent on sufficiently overparametrised (but finite) shallow ReLU networks. However, we note that (i) our ReLU setup does not have appropriate smoothness to directly apply the results from \cite{chizat2019sparse}, and (ii) the finite-particle guarantees would still be at best exponential in the dimension. We leave these considerations for future work.
\section{Proof of Proposition \ref{lem:noise_convexity}}
\begin{prop}
\label{lem:noise_convexity0}
For any set of variables $\{\boldsymbol{x}_i\}_{i=1}^n$ the associated weight $w_b(a,b):= \sqrt{ \mathbb{E}_{\mathcal{D}}[ (a^\top\boldsymbol{x}+b)_+^2] }$ is convex in $(a,b)$. Moreover, if the neuron with parameters $(a,b)$ is at the bulk of the dataset, the weight $w(a,b)$ is effectively strictly convex in a neighbourhood of $(a,b)$.
\end{prop}
\begin{proof}
Convexity follows from the fact that $l^2$ average of convex functions is convex:
\begin{align}
\left \|\left( \left(\frac{a+a'}2\right)^\top \boldsymbol{x}_j +\frac{b+b'}2\right)_+ \right \|_{l^2(j)}
\le &
\left \|\frac 1 2 (a^\top \boldsymbol{x}_j+b)_+ + \frac 1 2 ((a')^\top \boldsymbol{x}_j+b')_+ \right \|_{l^2(j)}
\\\le &
\frac 1 2
\| (a^\top \boldsymbol{x}_j+b)_+ \|_{l^2(j)}
+
\frac 1 2
\| ((a')^\top \boldsymbol{x}_j+b')_+ \|_{l^2(j)} \nonumber
\end{align}
Where the first line folows from the convexity of the ReLu. Strict convexity follows similarly: Local injectivity implies that, unless $(a,b)$ is proportional to $(a',b')$ the vector $[(a^\top \boldsymbol{x}_j + b)_+]_{j=1}^n$ is not proportional to the vector $[((a')^\top \boldsymbol{x}_j + b')_+]_{j=1}^n$. In that case by (sharp) Minkowski inequality, the inequality has to be strict.
\end{proof}
\section{Introduction}
Supervised Learning in high-dimensions remains an active research area, in part due to a confluence of several challenges, including approximation, computational and statistical, where the curse of dimensionality needs to be simultaneously avoided.
Linear learning based on RKHS theory suffers in the high-dimensional regime due its lack of approximation power, which motivates the study of non-linear learning methods. Amongst them, arguably the simplest is given by single hidden-layer neural networks, trained with some form of gradient descent scheme. Despite its simplicity relative to its deep counterparts, learning with shallow neural networks is still not fully understood from a theoretical standpoint, specifically with regards to giving positive results that explain their advantage over linear learning methods on realistic settings.
An important theme in recent analysis of neural networks is overparametrisation. By letting the number of neurons grow to infinity, one can obtain optimization, approximation and generalization guarantees beyond the linear learning regime \cite{chizat2020implicit, mei2018mean, rotskoff2018parameters}, at the expense of computational efficiency. In this context, a key goal is to exhibit the right combination of neural architecture and learning algorithm that preserves the guarantees of infinitely-wide neural networks with polynomially-sized networks.
We note that our study is only tangentially related to the so-called \emph{double-descent} phenomena recently reported in those same models \cite{belkin_reconciling_2019,belkin_two_2019,mei2019generalization}, since we include regularisation from the onset.
Regularisation can take two flavors: implicit (by injecting noise) or explicit (by adding a term in the empirical loss function).
They are a key device to give statistical guarantees of generalisation, and in this work we study their potential computational benefit in the overparametrised regime.
The mean-field regime of overparametrised shallow networks defines solutions in terms of measures over parameters. A natural form of explicit regularisation is then given by the variation-norm \cite{bach2017breaking}, which penalises an continous-equivalent of an $L^1$ norm over weights, and is equivalent to the path-norm \cite{neyshabur_norm-based_2015} and the Barron norm \cite{ma2019barron}, as well as the popular `weight-decay' for homogeneous activations such as the ones we consider here.
Injecting noise into gradient descent dynamics is another classic form of implicit regularization, under appropriate ergodicity conditions that enable the forgetting of initial conditions. In this work, and inspired by \cite{blanc_implicit_2019}, we focus on a specific form of noise, namely noise added into the training labels. The authors interpreted the noisy gradient dynamics as an approximate Orstein-Uhlenbeck process that `walks' around the manifold of solutions with zero training error (which has positive dimension due to overparametrisation), and `locks' in solutions that minimise a certain implicit regulariser, given by the average squared norm of the network gradients over the data. They leveraged such implicit regularisation to explain the `simple' structure of solutions on specific cases, such as univariate inputs or a single datapoint.
We encapsulate these two regularisation instances into a general family of regularisers that, combined with mild assumptions on the activation function, produce optimisation problems over the space of probability measures that can only be minimised if the measure has sparse support (Theorem \ref{thm:weight_implies_sparsity}). This gives a novel perspective on the overparametrised regime under these forms of regularisation, that connects it to a finite-dimensional linear program, and whereby the infinitude of parameters required to give optimization guarantees might be relaxed to a finite (albeit possibly exponentially large in dimension) quantity.
\section{Conclusions}
In this work, we have studied the structure of the minimisers in overparametrised shallow RelU networks under a broad umbrella of implicit and explicit regularisation strategies, including the popular weight decay and noisy gradient dynamics through label noise. Our main result leverages the underlying convexity generated by the regularisation to show that the resulting learning objectives only admit sparse minimisers, irrespective of the amount of overparametrisation.
This fact effectively maps the task of learning in variation-norm ReLU spaces (which are infinite-dimensional) into a finite-dimensional linear program. However, such linear program is determined by the hyperplane arrangement generated by the finite dataset after dualization -- and thus of size exponential in dimension. As such, it does not directly solve the computational barrier present in the mean-field formulations of sparse measure optimization \cite{chizat2019sparse}, which is unavoidable in certain data regimes under the general SQ-model \cite{klivans2020}.
As future work, it would be interesting to further explore the connections with the recent `memorization' constructions of \cite{bubeck2020network}, and to study favorable conditions on the datapoints that could break the exponential size of the linear program.
\section{Implicit Regularisation by Label Noise}
\label{sec:noise}
The goal of this section is to establish a link between a type of noise-induced regularisation phenomena established in \cite[Theorem 2]{blanc_implicit_2019} and the variation-norm spaces defined in section 3.1.
\subsection{Results in Blanc. et. al.}
Blanc et al. \cite{blanc_implicit_2019} propose Algorithm \ref{alg:noisy_sgd} for training a neural network on a data-set $(\boldsymbol{x}_i, y_i)_{i=1}^{n}$.
The algorithm is an SGD-type algorithm with a small, independent perturbation on each label $y_i$ sampled independently on each gradient step.
Denote by ${\mathcal{D}}=(\boldsymbol{x}_1, \dots \boldsymbol{x}_n)$ the input data and let ${\mathbb E}_{{\mathcal{D}}}$ denote the empirical average over the observed $n$ datapoints.
Let $\vec \boldsymbol{\theta}=(\boldsymbol{\theta}_1, \dots, \boldsymbol{\theta}_m)$.
The main result therein \cite[Theorem 2]{blanc_implicit_2019} states that, for large times (depending, amongst others, on the noise size and the number of parameters), the solution concentrates at local minimizers (amongst the zero-error solutions) of the \emph{effective regularization loss}:
\begin{equation}
\label{eq:blancminimizer}
\Lambda(\vec \boldsymbol{\theta}, \mathcal{D}):= {\mathbb E}_{{\mathcal{D}}} \left [\sum_{j} |\nabla_{\boldsymbol{\theta}_j}f(\boldsymbol{x},\vec\boldsymbol{\theta})|^2\right] \propto \frac 1 m \sum_{j} {\mathbb E}_{{\mathcal{D}}} \left [|\nabla_{\boldsymbol{\theta}_j}\phi(\boldsymbol{\theta}_j,\boldsymbol{x})|^2\right]~.
\end{equation}
The RHS of \eqref{eq:blancminimizer} is now an integral over the counting measure $\mu = \frac 1 m \sum_{j=1}^m \delta_{\boldsymbol{\theta}_j}$, and therefore,
\begin{equation}
\label{eq:loss_4.1}
\Lambda(\vec \boldsymbol{\theta}, \mathcal{D}) \propto \int {\mathbb E}_{{\mathcal{D}}} \left [|\nabla_{\boldsymbol{\theta}_i}\phi(\boldsymbol{\theta}_i,\boldsymbol{x})|^2\right] d\mu(\boldsymbol{\theta}) := \int \widetilde{V}_b(\boldsymbol{\theta}) d\mu(\boldsymbol{\theta})~.
\end{equation}
\begin{algorithm}[tb]
\caption{SGD with noise on the labels}
\label{alg:noisy_sgd}
\begin{algorithmic}
\State {\bfseries Parameters:} Noise size $\eta$, step size $\epsilon$, noise distribution $\rho$
\State {\bfseries Input:} Data $(\boldsymbol{x}_i,y_i)_{i=1}^n$, Initial parameters $\theta_0$
\Repeat
\State {Choose a random data point $(\boldsymbol{x}_{i_t}, y_{i_t})$}
\State {Generate noise $r \sim \rho$}
\State $\tilde y_{i_t} := y_{i_t} + \eta r$
\State $ \boldsymbol{\theta}_{t+1} = \boldsymbol{\theta}_t - \epsilon \nabla_{\boldsymbol{\theta}} [(f(\boldsymbol{x}_{i_t};\boldsymbol{\theta})-\tilde y_{i_t})^2] $
\Until{Convergence}
\end{algorithmic}
\end{algorithm}
\subsection{An equivalent formulation in the ReLU case}
\label{sec:equivalent_relu}
As we have seen in the previous section, the training algorithm with label noise minimizes $\langle \tilde{V}_b, \mu \rangle$.
In the ReLU case we can explicitly write:
\begin{equation}
\widetilde{V}_b(a,b,c) = {\mathbb E}_{{\mathcal{D}}} \left[\frac{|c^2|(a^\top \boldsymbol{x}+b)^2_+}{c^2}+(1+|\boldsymbol{x}|^2) c^2 \chi_{(a^\top \boldsymbol{x}+b)\ge 0}\right ]~.
\end{equation}
The key realization is that in order to minimize the value of $\ref{eq:loss_4.1}$, the algorithm will \textit{exploit} the degeneracy $(a,b,c) \sim (\lambda a,\lambda b,\lambda^{-1} c)$ for $\lambda>0$. In other words, we may substitute $\widetilde{V}_b$ for
$V_b(a,b,c) = \min_{\lambda > 0} \widetilde{V}_b (\lambda a,\lambda b,\lambda^{-1} c)$
without effectively changing the problem. A straightforward computation shows that $V_b(a,b,c)$ is equal to:
\begin{equation}
V_b(a,b,c) = |c|\sqrt{ {\mathbb E}_{\mathcal D} [ (a^\top \boldsymbol{x}+b)_+^2] } := |c|w_{b}(a,b)~.
\end{equation}
There are two crucial properties of the potential function $V_b$.
First, that it is invariant under the $\lambda$ degeneracy described above: If we have a measure $\mu$ and modify it with the method above to obtain $\tilde \mu$, both of them will have the same loss. The second is that the function $w$ is convex, and, as long as the neurons can `see' enough of the dataset, essentially convex. To make this precise, we start with two definitions:
\begin{defn}
A neuron with parameters $(a,b)$ is \emph{at the bulk of the dataset} $\mathcal{D}=(\boldsymbol{x}_1, \dots, \boldsymbol{x}_n)$ whenever the map $(a,b) \mapsto ((a\cdot \boldsymbol{x}_1+b)_+, (a\cdot \boldsymbol{x}_2+b)_+, \dots (a\cdot \boldsymbol{x}_n+b)_+ )$ is locally injective.
\end{defn}
\begin{defn}
A weight $w(a,b)$ that is 1-homogeneous in $(a,b)$ is \emph{effectively strictly convex} if whenever
\begin{equation}
w(\lambda a+(1-\lambda) a', \lambda b+(1-\lambda) b') = \lambda w(a,b)+(1-\lambda)w(a',b')
\end{equation}
holds for some parameters $a,a',b,b'$ and $\lambda\in(0,1)$, the parameters $(a,b)$ and $(a',b')$ are proportional to each other.
\end{defn}
With these definitions in hand, we can state the main result of this section, a convexity result for the regularization loss (see the Appendix for a proof):
\begin{prop}
\label{lem:noise_convexity}
For any set of variables $\{\boldsymbol{x}_i\}_{i=1}^n$ the associated weight
$
w_b(a,b):= \sqrt{ \mathbb{E}_{\mathcal{D}}[ (a^\top\boldsymbol{x}+b)_+^2] }
$ is convex in $(a,b)$. Moreover, if the neuron with parameters $(a,b)$ is at the bulk of the dataset, the weight $w(a,b)$ is effectively strictly convex in a neighbourhood of $(a,b)$.
\end{prop}
We will show next how such convexity structure in the potential function can be leveraged to characterise minimisers of (\ref{eq:ermmeasure}) and (\ref{eq:penform}).
\section{Preliminaries}
\subsection{Shallow Neural Networks and Variation-Norm Spaces}
We consider a shallow neural network with hidden-layer-width $m$ as the following function:
\begin{equation}
\label{eq:basic}
f(\boldsymbol{x}; \boldsymbol{\theta}_1\dots \boldsymbol{\theta}_m) := \frac{1}{m} \sum_{j=1}^m \phi(\boldsymbol{\theta}_j, \boldsymbol{x}),
\end{equation}
where $\boldsymbol{x} \in \Omega \subseteq \mathbb{R}^d$ is the feature of the input data, $\phi(\boldsymbol{\theta}, \boldsymbol{x}) = c \sigma(a^\top \boldsymbol{x} + b)$ is the \emph{neuron} constructed from an activation function $\sigma$, and $\boldsymbol{\theta}_j = (c_j, \theta_j) \in \mathbb{R} \times \mathbb{R}^{d+1}:= \Theta$ with $\theta=( a, b )$ are the parameters for the $j$-th neuron.
As observed by several authors \cite{mei2018mean,chizat2018global, rotskoff2018parameters, sirignano2018dgm}, such a neural network can be equivalently represented in terms of a probability measure over $\Theta$ as $f_{\mu^{(m)}}$, where
\begin{equation}
f_\mu(\boldsymbol{x}) := \int_\Theta \phi(\boldsymbol{\theta}, \boldsymbol{x}) \mu(d\boldsymbol{\theta})~,
\end{equation}
and $\mu^{(m)}$ is the empirical measure of the parameters $\{ \boldsymbol{\theta}_j \}_{j=1}^m$:
$\mu^{(m)} = \frac{1}{m} \sum_{j=1}^m \delta_{\boldsymbol{\theta}_j}~.$
Let us denote by $\mathcal{P}(\Theta)$ the space of probability measures over $\Theta$. In the following, we write $\langle \chi, \mu \rangle := \int_\Theta \chi(\boldsymbol{\theta}) \mu(d\boldsymbol{\theta})$ for a Borel-measurable test function $\chi$ \todo{Borel regularity ens val no? Després demanarem convexity pero so far-- de fet, utilitzem aquesta notació at all?} and $\phi_{\boldsymbol{x}}:=\phi(\cdot, \boldsymbol{x})$.
Let $V: \Theta \to \mathbb{R}^+$ be a non-negative potential function satisfying $\inf_{\alpha, c} V(\alpha a, \alpha b, c) > 0$.
The set of functions representable as (\ref{eq:basic}) defines a metric space $\mathcal{F}_V$ with norm
\begin{equation}
\label{eq:bli}
\| f \|_{V} := \inf \left\{ \int_{\Theta} V(\boldsymbol{\theta}) \mu(d\boldsymbol{\theta});~ f(\boldsymbol{x}) = \int_\Theta \phi(\boldsymbol{\theta}, \boldsymbol{x}) \mu(d\boldsymbol{\theta})\,. \right\}~.
\end{equation}
When $V(\boldsymbol{\theta}) = |c| \| \theta \| $, the resulting space is
the so-called \emph{variation-norm space} $\mathcal{F}_1$ \cite{bach2017breaking}.
One can verify \cite{ma2019barron} that $V(\boldsymbol{\theta}) = |c|^q (\|\theta \| )^q$ gives the same functional characterisation for any $q \geq 1$. Moreover, if $\phi$ is 2-homogeneous w.r.t. $\boldsymbol{\theta}$ (such as the ReLU $\sigma(t)=\max(0,t)$) \footnote{$\phi(t\boldsymbol{\theta}, \boldsymbol{x}) = t^2 \phi(\boldsymbol{\theta}, \boldsymbol{x})$}, then one can also verify that $V(\boldsymbol{\theta}) = \| \boldsymbol{\theta}\|^2$ also defines the same space \footnote{By first projecting the measure to the unit sphere $\| \theta\|=1$ and then lifting again as a point mass in the $c$-direction, and using the fact that $\mu$ has mass $1$; see \cite{ma2019barron}, Theorem 1.}. Such apparent flexibility is a consequence of the fact that $\mu$, the underlying object parametrising the integral representation (\ref{eq:bli}), is in fact a \emph{lifted} version of a more `fundamental' object $\nu=\mathrm{P}(\mu) \in \mathcal{M}(\mathbb{S}^d)$, the space of signed Radon measures over the unit $(d+1)$-dimensional sphere
\todo{replace unit sphere by the projective space? the fundamental object here are the space of $d$-dimensional hyperplanes}\todo{Jaume: No: el signe importa per a les ReLu, a diferència de al projecitu.}. The measures $\mu$ and $\nu$ are related via the projection
\begin{equation}
\int_{\mathbb{S}^d} \chi(\tilde{\theta}) d\nu(\tilde{\theta}) = \int_{\Theta} c \| \theta \| \chi\left(\frac{\theta}{\|\theta\|}\right) d\mu(\boldsymbol{\theta})
\end{equation}
for all continuous test functions $\chi: \mathbb{S}^d \to \mathbb{R}$. One can verify \cite{chizat2019sparse} that for the previous choice of potential $V$, one has
$\|f \|_V = \inf \{ \| \nu\|_{\mathrm{TV}};\, f(\boldsymbol{x}) = \int_{\mathbb{S}^d} \sigma(\langle \tilde{\theta}, \tilde{\boldsymbol{x}} \rangle) d\nu(\tilde{\theta}) \}$, where $\tilde{\boldsymbol{x}}=(\boldsymbol{x},1)$ and $\| \nu \|_{\mathrm{TV}}$ is the \emph{Total-Variation} norm of $\nu$ \cite{bach2017breaking}.
This variation-norm space contains any RKHS whose kernel is generated as an expectation over features $k(\boldsymbol{x}, \boldsymbol{x}') = \int_\Theta \phi(\boldsymbol{\theta},\boldsymbol{x}) \phi(\boldsymbol{\theta},\boldsymbol{x}') \mu_0(d\boldsymbol{\theta})$ with a base measure $\mu_0$, but it provides crucial advantages over these RKHS at approximating certain non-smooth, high-dimensional functions having some `hidden' low-dimensional structure \cite{bach2017breaking}. This motivates the study of overparametrised shallow networks with the scaling as in (\ref{eq:basic}), as opposed to the NTK scaling \cite{jacot2018neural} in $1/\sqrt{m}$.
As we will see in Section \ref{sec:noise}, other $\mathcal{F}_V$ spaces arise naturally when training overparametrised neural networks with noisy dynamics, corresponding to different choice of potential function. In the following, we are going to focus on the ReLU case where $\sigma(t) = (t)_+ = \max(0,t)$.
\subsection{Empirical Risk Minimization and Representer Theorem}
Given samples $\{ (\boldsymbol{x}_i, y_i) \in \Omega \times \mathbb{R} \}_{i=1\dots n}$ for a regression task, learning in $\mathcal{F}_1$ in the \emph{interpolant} regime (corresponding to overparametrised models) amounts to the following problem
\begin{equation}
\label{eq:erm}
\min_{ f \in \mathcal{F}_V} \| f\|_V ~~s.t. ~~f(\boldsymbol{x}_i) = y_i ~\text{ for } i=1\dots n~.
\end{equation}
This problem can be equivalently expressed as an optimization problem in $\mathcal{P}(\Theta)$:
\begin{equation}
\label{eq:ermmeasure}
\min_{ \mu \in \mathcal{P}(\Theta)} \langle V, \mu \rangle ~s.t. ~ \langle \phi_{\boldsymbol{x}_i}, \mu \rangle = y_i\,,i=1\dots n~.
\end{equation}
Even though $\mathcal{F}_1$ is not a RKHS, its convex structure also provides a Representer Theorem \cite{zuho1948, fisher1975spline, bach2017breaking, boyer2019representer}: the extreme points of the solution set of (\ref{eq:ermmeasure}) consist of point masses $\sum_{j=1}^r c_j \delta_{\boldsymbol{\theta}_j}$ of support $r$ at most $n$. In other words, there exist minimisers of the variation norm that require at most $n$ neurons to interpolate the data. However, in contrast with the RKHS representer theorem, these neurons are not explicit in terms of the datapoints, and cannot be directly characterised from (\ref{eq:ermmeasure}) since this problem generally lacks unicity.
In practice, (\ref{eq:ermmeasure}) is typically solved in the penalised form, by introducing the explicit regularised empirical loss
\begin{equation}
\label{eq:penform}
\mathcal{L}_\lambda(\mu) = \frac{1}{n} \sum_{i=1}^n \ell( \langle \phi_{\boldsymbol{x}_i},\mu \rangle, y_i) + \lambda \langle V, \mu \rangle~,
\end{equation}
where $\ell$ is convex w.r.t. its first argument, e.g. $\ell(x,y) = \frac{1}{2}|x-y|^2$ and $\lambda$ controls the regularisation strength, so (\ref{eq:ermmeasure}) can be obtained as the limit $\lambda \to 0^+$ in (\ref{eq:penform}).
\subsection{Training Overparametrised Neural Networks and Wasserstein Gradient Flows}
Notice that for empirical measures $\mu^{(m)}$ corresponding to a $m$-width shallow network, the loss $\mathcal{L}(\mu^{(m)})$ is precisely the loss
\begin{equation}
\label{eq:penform2}
{L}(\boldsymbol{\theta}_1, \dots, \boldsymbol{\theta}_m) =\frac{1}{n}\sum_i \ell(f(\boldsymbol{x}_i;\boldsymbol{\theta}_1,\dots, \boldsymbol{\theta}_m), y_i) + \frac{\lambda}{m}\sum_{j=1}^m V(\boldsymbol{\theta}_j)~,
\end{equation}
with respect to the parameters $\{ \boldsymbol{\theta}_j \}_{j \leq m}$.
In that case, the regularisation term corresponds to \emph{weight decay} for $V(\boldsymbol{\theta})=\|\boldsymbol{\theta}\|^2$, and the so-called \emph{path norm} \cite{neyshabur_norm-based_2015} for $V(\boldsymbol{\theta})=|c| \| \theta \|$. As also argued in \cite{neyshabur2014search},
these two regularisation terms capture the same implicit bias in the functional space.
Performing gradient descent on $L$ with respect to $\{\boldsymbol{\theta}_j\}_j$ induces gradient dynamics on the functional $\mathcal{L}$ over $\mathcal{P}(\Theta)$, with respect to the Wasserstein metric \cite{mei2018mean,chizat2018global, rotskoff2018parameters, sirignano2018dgm},
thus mapping an Euclidean non-convex problem (\ref{eq:penform2}) to a non-Euclidean convex one (\ref{eq:penform}).
The gradient dynamics of overparametrised neural networks in the infinite-width limit can thus be analysed as the mean-field limit of such Wasserstein Gradient flows, leading to global convergence for problems such as (\ref{eq:penform}) under appropriate homogeneity assumptions for $\phi$ \cite{chizat2018global, chizat2019sparse}. However, such convergence results are qualitative and only hold in the limit of $m \to \infty$ without extra structure in the minimisers of $\mathcal{L}(\mu)$ such as being point masses -- precisely the structure that our main results from Section \ref{sec:tv} provide.
\subsection{Implicit Regularization}
A popular alternative to the explicit variation-norm regularisation is to rely on the particular choice of optimization scheme to provide an implicit regularisation effect. While gradient descent enjoys powerful implicit regularisation for logistic regression \cite{soudry2018implicit, chizat2020implicit} by favoring max-margin solutions, and for linear least-squares regression by choosing solutions of minimal $\ell_2$ norm, the situation for non-linear least-squares is less clear.
Indeed, in those cases, the dynamics do not typically forget the initial conditions, making them very sensitive to initialisation and producing substantial qualitative changes, as illustrated by the lazy dynamics \cite{chizat2018note}. A powerful alternative is thus given by algorithms that inject noise into the dynamics, such as SGD or Langevin Dynamics.
The latter was studied in the framework of overparametrised shallow networks in \cite{mei2018mean}.
This dynamics leads to an associated cost of the form:
\begin{equation}
\min_\mu \frac{1}{n} \sum_{i=1}^n \ell( \langle \phi_{\boldsymbol{x}_i},\mu \rangle, y_i) - \lambda \mathcal{H}(\mu)~,
\end{equation}
where $\mathcal{H}$ is the relative entropy of $\mu$. Minimizers to this functional have a smooth density that is solution to the associated elliptic Euler-Lagrange problem.
They are therefore not sparse due to the entropic regularisation.
An alternative to Langevin Dynamics and SGD was recently studied in \cite{blanc_implicit_2019}, consisting of adding noise into the targets $y_i$ rather than the parameters. As already hinted in \cite{blanc_implicit_2019}, the resulting dynamics capture an implicit bias corresponding to a $V$-space for a \emph{data-dependent} potential function $V$.
\section{Additional Proofs}
\paragraph{Proof of Proposition 3.3.}
\begin{proof}
Convexity follows from the fact that $l^2$ average of convex functions is convex:
\begin{align}
\left \|\left( \left(\frac{a+a'}2\right)^\top \boldsymbol{x}_j +\frac{b+b'}2\right)_+ \right \|_{l^2(j)}
\le &
\left \|\frac 1 2 (a^\top \boldsymbol{x}_j+b)_+ + \frac 1 2 ((a')^\top \boldsymbol{x}_j+b')_+ \right \|_{l^2(j)}
\\\le &
\frac 1 2
\| (a^\top \boldsymbol{x}_j+b)_+ \|_{l^2(j)}
+
\frac 1 2
\| ((a')^\top \boldsymbol{x}_j+b')_+ \|_{l^2(j)} \nonumber
\end{align}
Where the first line folows from the convexity of the ReLu. Strict convexity follows similarly: Local injectivity implies that, unless $(a,b)$ is proportional to $(a',b')$ the vector $[(a^\top \boldsymbol{x}_j + b)_+]_{j=1}^n$ is not proportional to the vector $[((a')^\top \boldsymbol{x}_j + b')_+]_{j=1}^n$. In that case by (sharp) Minkowski inequality, the inequality has to be strict.
\end{proof}
\paragraph{Proof of Lemma 4.3 (Discrete version)}
\begin{proof}
Let $x_i$ be a data-point. If $(a,b)$ and $(a',b')$ belong to the same cell, there are two options: \\
Both $(ax_i+b)\le 0$ and $(a'x_i+b) \le 0$. In this case, $0 = (ax_i+b)_+ + (a'x_i+b')_+ = ((a+a')x_i+b+b')$.\\
Both $(ax_i+b)\ge 0$ and $(a'x_i+b) \ge 0$. In this case, we have $(ax_i+b)_+ + (a'x_i+b')_+ = (ax_i+b)+(ax_i+b) = ((a+a')x_i+(b+b'))=((a+a')x_i+(b+b'))$
\end{proof}
\paragraph{Proof of Lemma 4.3 (Continuous version)}
\begin{proof}
Let $x_i$ be a data-point. As in the discrete case, we have two options. In the trivial case, the datapoint is inactive in the cell, in the sense that for all $(a,b,c)$ in the cell, $c(a x_i +b)_+=0$. In this case the equality is always true. In the non-zero (linear) case, all neurons in the cell are active. In this case we may omit the ReLu itself, and the equality we need to show is:
\begin{equation}
\int c (a x_i + b) d\mu = \int c (a x_i + b) d\mu'
\end{equation}
by linearity of the integral this is equivalent to
\begin{equation}
x_i \cdot \int c a d\mu + \int cb d\mu= x_i \cdot \int c a d\mu' + \int cb d\mu'
\end{equation}
and now the result follows directly from the hypothesis.
\end{proof}
\paragraph{Proof of Lemma 4.4}
\begin{lemma}
Let $(a,b,c), (a’,b’,c’)$ belong to the same cell and not represent the same neuron, let $\mu = \frac 1 2 (\delta_{a,b,c}+\delta_{a’,b’,c’})$. Then there is a probability measure $\mu’$ concentrated at a single point $(\alpha, \beta,\gamma)$ such that estimates (\ref{eq:moment_estimates}) hold for $\mu,\mu’$ but $\langle V, \mu\rangle < \langle V, \mu’\rangle $. \footnote{There is a typo in the statement of lemma 4.4 in the main text in how the interpolation in the lifted space is performed; it has been addressed here.}
\end{lemma}
\begin{proof}
Assume without loss of generality that $c,c'$ have the same sign (since otherwise we can transfer mass from one neuron to the other).
Since $(a,b,c)$ and $(a',b',c')$ do not represent the same neuron,
by the effective strict convexity of $w$ we have
\begin{equation}
\label{eq:mim}
w( \lambda a + (1-\lambda) a', \lambda b + (1-\lambda)b') < \lambda w(a,b) + (1-\lambda)w(a',b')
\end{equation}
for any $\lambda \in (0,1)$.
Pick $\lambda = \frac{|c|}{|c|+|c'|} $.
Then we easily verify that $(\alpha, \beta) = \lambda (a,b) + (1-\lambda)(a',b')$ and $\gamma = c + c'$ verify the moment estimates, and
$2|\gamma|w(\alpha,\beta) < |c| w(a,b) + |c'| w(a',b')$ by (\ref{eq:mim}).
\end{proof}
\paragraph{Proof of Lemma 4.5}
\begin{proof}
Assume minimizers exist, as otherwise the result is vacuously true.
Given a minmizer $\tilde \nu$ there is a measure $\nu_0 = \delta_{(a_\nu,b_{\nu},c_\nu)}$ that has the same mass and first moment as $\tilde\nu$, but is concentrated at a single point $(\alpha,\beta,\pm1)$ (the center of mass). By convexity, this $\nu_0$ has to be a minimizer of the loss amongst all functions with the same first moment estimate (by Jensen) so it suffices to show that $\nu_0$ is effectively unique. This is a consequence of effective convexity: If $\nu'$ is another minimizer, $\nu'$ has to be supported on parameters that represent the same parameter as $\nu_0$, because otherwise we can build an even better measure:
Let
$$\phi(a,b,c):=
\left(\frac 1 2 (\alpha + |c|a),\frac 1 2 (\beta + |c|b), \pm 1\right)
$$
Then, for any given measure $\mu$ with the same moment estimates as $\nu_0$, $\phi_*\mu$ has the same moment estimates as $\mu$ and $\nu_0$, but unless $\mu$ is effectively supported at the same point as $\nu_0$, it must be (by strict convexity) that
\begin{equation}
\langle w,\nu_0\rangle > \langle w, \phi_*\mu \rangle
\end{equation}
which contradicts the hypothesis that $\nu_0$ is a minimizer.
\end{proof}
\paragraph{Proof of Theorem 4.7}
\begin{proof}
Let $\nu,\nu'$ be two minimizing measures. By convexity, $\frac 1 2 (\nu, \nu')$ must also be a minimizing sequence. Lemma \ref{lem:one_point_per_cell} guarantees then that $\frac 1 2 (\nu, \nu')$ will be supported in at most one point per cell. Therefore, if $\nu,\nu'$ had support on the same cell, it must be exactly on the same point.
\end{proof}
\paragraph{Proof of Corollary 4.8}
\begin{proof}
Let $\mu$ be a minimizer to the penalized problem
\begin{equation}
\min_{\nu \in \mathcal P} \langle |c|w(a,b), \nu(a,b,c)\rangle + L(\{|f_\nu(x_i)-y_i|\}_{i=1}^n)
\end{equation}
for some similarity loss function $L$. Then $\mu$ must also be the minimizer to the following \text{restricted problem} (note that this is not the traditional penalized-constrained duality):
\begin{equation}
\label{eq:fake_problem}
\min_{\nu \in \mathcal P, f_\nu(x_i) = f_\mu(x_i)} \langle |c|w(a,b), \nu(a,b,c)\rangle + L(\{|f_\nu(x_i)-y_i|\}_{i=1}^n)
\end{equation}
this is because a minimizer must remain a minimizer if we further constrain the feasible set.
This is again the constrained problem in equation \eqref{eq:erm}, using $f_\mu(x_i)$ instead of $y_i$. In this case Theorem \ref{thm:weight_implies_sparsity} states that solutions to this problem must be sparse.
\end{proof}
\section*{Broader Impact}
\bibliographystyle{alpha}
| {'timestamp': '2020-06-19T02:07:10', 'yymm': '2006', 'arxiv_id': '2006.10225', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10225'} | arxiv |
\section*{Acknowledgments}
\vspace{-0.1in}
We would like to thank Takami Sato, Ningfei Wang, Ziwen Wan, Shinan Liu, Alex Veidenbaum, Gene Tsudik, Marco Levorato, Ardalan Amiri Sani, Joshua Garcia, Yu Stephanie Sun,
the anonymous reviewers, and our shepherd, Yongdae Kim, for providing valuable feedback on our work. This research was supported in part by the National Science Foundation under grants CNS-1850533 and CNS-1929771.
\section{Calculation of Required Deviations in Attack Goals and Distances to Lane Line}\label{appendix:goal_deviations}
The required deviations under off-road and wrong-way attacks are calculated based on common widths of the AV, lane, and the road shoulder. These values differ in local and highway settings. Fig.~\ref{fig:std_measurements} shows the width measurements we used in the calculation. For the AV width, we use the width (including mirrors) of the Baidu Apollo's reference car, Lincoln MKZ~\cite{mkz_spec}. For the lane widths and shoulder widths, we refer to the design guidelines~\cite{road_shoulder_width} published by the US Department of Transportation Federal Highway Administration. For off-road attack, we use the deviation when the AV goes \textit{beyond} the road shoulder from the center of the lane as the required deviation, which is calculated using $\frac{L-C}{2}+S = 0.895m$~(local) and $1.945m$~(highway), where $L$ is the lane width, $C$ is the car width, and $S$ is the road shoulder width. For wrong-way attack, we define the required deviation as the AV completely invades the neighbor lane, and it is calculated with $\frac{L}{2}+\frac{C}{2} = 2.405m$~(local) and $2.855m$~(highway). We calculate the deviation of \textit{touching the lane line} using $\frac{L-C}{2}$, which is $0.295m$ on local roads and $0.745m$ on the highway.
\begin{figure}[tbh]
\begin{minipage}[tbh]{0.47\linewidth}
\centering
\includegraphics[width=.95\columnwidth]{./figs/car_lane_shoulder.pdf}
\caption{Common AV, traffic lane, and road shoulder widths used in this paper.}
\label{fig:std_measurements}
\end{minipage}
\hspace{0.01\linewidth}
\begin{minipage}[tbh]{0.50\linewidth }
\centering
\includegraphics[width=.95\columnwidth]{./figs/touch_lane_line.pdf}
\caption{Visualization of the lateral deviation 0.45 meters on local and highway roads.}
\label{fig:visualize_safe_threshold}
\end{minipage}
\vspace{-0.15in}
\end{figure}
\section{Convert Steering to Lateral Position and Heading Rate Changes}\label{appendix:steer_to_position}
Fig.~\ref{fig:steer_to_position} shows the mathematical conversion from the steering angle to physical world lateral position change. The position change can be calculated as $\delta_{\text{pos}} = vt\sin(\frac{\theta}{\phi})$, where $v$ is the velocity, $t$ is the cycle time of the controller, $\theta$ is the steering angle, and $\phi$ is the steering ratio, which is a constant describing the ratio of the turning angle of the steering wheel to that of the vehicle wheel.
The steering angle can be directly converted to heading rate change using $\delta_{\omega} = \theta/\phi t$, where $\delta_{\omega}$ is the yaw (\textit{i}.\textit{e}., heading) rate change.
\begin{figure}[tbp]
\centering
\includegraphics[width=.65\columnwidth]{./figs/demo_lidar_modeling.pdf}
\vspace{-0.05in}
\ncaption{Conversion from the steering wheel angle to lateral position change.}
\label{fig:steer_to_position}
\vspace{-0.15in}
\end{figure}
\begin{figure}[tbp]
\centering
\includegraphics[width=.95\columnwidth]{./figs/profiling/min_profile_succ_rate_and_threshold.pdf}
\ncaption{Profiling results when using different (a) minimum profiling success rates, and (b) safe profiling thresholds.}
\label{fig:min_profile_succ_rate_and_threshold}
\end{figure}
\section{#1}}
\newcommand{\nsubsection}[1]{\subsection{#1}}
\newcommand{\nsubsubsection}[1]{\subsubsection{#1}}
\else
\newcommand{\ncaption}[1]{\caption{#1}}
\newcommand{\nsection}[1]{\vspace{-0.25cm}\section{#1}\vspace{-0.15cm}}
\newcommand{\nsubsection}[1]{\vspace{-0.4cm}\subsection{#1}\vspace{-0.1cm}}
\newcommand{\nsubsubsection}[1]{\vspace{-0.2cm}\subsubsection{#1}\vspace{-0.1cm}}
\fi
\urlstyle{rm}
\usepackage{enumitem}
\begin{document}
\date{}
\title{\Large \bf Drift with Devil: Security of Multi-Sensor Fusion based Localization in High-Level Autonomous Driving under GPS Spoofing \\
\large (Extended Version)}
\author{
{\rm Junjie Shen}\\
UC Irvine\\
[email protected]
\and
{\rm Jun Yeon Won}\\
UC Irvine\\
[email protected]
\and
{\rm Zeyuan Chen}\\
UC Irvine\\
[email protected]
\and
{\rm Qi Alfred Chen}\\
UC Irvine\\
[email protected]
}
\maketitle
\input{abstract}
\input{intro}
\input{background}
\input{threat_model}
\input{security_analysis}
\input{attack_design}
\input{evaluation}
\input{practical_attack}
\input{offline_profile}
\input{discussion}
\input{related_work}
\input{conclusion}
\input{acknowledgement}
\bibliographystyle{ieeetr}
{
\footnotesize
| {'timestamp': '2020-08-13T02:22:37', 'yymm': '2006', 'arxiv_id': '2006.10318', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10318'} | arxiv |
\subsubsection*{\bibname}}
\newcommand{\florence}[1]{\textcolor{red}{\textit{F: #1}}}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{url}
\usepackage{booktabs}
\usepackage{amsfonts}
\usepackage{graphicx}
\usepackage{nicefrac}
\usepackage{microtype}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{mathrsfs}
\usepackage{bm,bbm}
\usepackage{mathtools}
\usepackage{subcaption}
\usepackage{algpseudocode,algorithm,algorithmicx}
\usepackage{array, adjustbox}
\usepackage{caption}
\usepackage{hyperref}
\usepackage{cleveref}
\usepackage{mathrsfs}
\hypersetup{
colorlinks,
linkcolor={blue},
citecolor={blue},
urlcolor={blue}
}
\newcommand*\DNA{\textsc{dna}}
\newcommand*\Let[2]{\State #1 $\gets$ #2}
\newcommand{\mathcal{W}}{\mathcal{W}}
\newcommand{\mathcal{S}}{\mathcal{S}}
\newcommand{\mathcal{S}_n}{\mathcal{S}_n}
\newcommand{\hat{\mu}_n}{\hat{\mu}_n}
\newcommand{\hat{\nu}_m}{\hat{\nu}_m}
\newcommand{\mathcal{U}}{\mathcal{U}}
\newcommand{\mathbf{P}}{\mathbf{P}}
\newcommand{\mathbf{C}}{\mathbf{C}}
\newcommand{\mathcal{A}}{\mathcal{A}}
\newcommand{\mathbf{a}}{\mathbf{a}}
\newcommand{\mathbf{b}}{\mathbf{b}}
\newcommand{\mathcal{O}}{\mathcal{O}}
\newcommand{\mathcal{D}}{\mathcal{D}}
\newcommand{\mathcal{W}_{\text{MoM}}}{\mathcal{W}_{\text{MoM}}}
\newcommand{\mathcal{W}_{\text{MoU-diag}}}{\mathcal{W}_{\text{MoU-diag}}}
\newcommand{\mathcal{W}_{\text{MoU-diag}}}{\mathcal{W}_{\text{MoU-diag}}}
\newcommand{\mathcal{W}_{\text{MoU}}}{\mathcal{W}_{\text{MoU}}}
\newcommand{\widetilde{\mathcal{W}}_{\text{MoM}}}{\widetilde{\mathcal{W}}_{\text{MoM}}}
\newcommand{\widetilde{\mathcal{W}}_{\text{MoU-diag}}}{\widetilde{\mathcal{W}}_{\text{MoU-diag}}}
\newcommand{\widetilde{\mathcal{W}}_{\text{MoU}}}{\widetilde{\mathcal{W}}_{\text{MoU}}}
\newcommand{\widetilde{\mathcal{W}}_{\text{MoU-diag}}}{\widetilde{\mathcal{W}}_{\text{MoU-diag}}}
\newcommand{\widetilde{\mathcal{W}}}{\widetilde{\mathcal{W}}}
\newcommand{\tau_{\mathbf{X}}}{\tau_{\mathbf{X}}}
\newcommand{\tau_{\mathbf{Y}}}{\tau_{\mathbf{Y}}}
\newcommand{K_{\mathbf{X}}}{K_{\mathbf{X}}}
\newcommand{K_{\mathbf{Y}}}{K_{\mathbf{Y}}}
\newcommand{B_{\mathbf{X}}}{B_{\mathbf{X}}}
\newcommand{B_{\mathbf{Y}}}{B_{\mathbf{Y}}}
\newcommand{\mathbf{X}}{\mathbf{X}}
\newcommand{\mathcal{B}^{\X}}{\mathcal{B}^{\mathbf{X}}}
\newcommand{n_{\bmO}^{\X}}{n_{\mathcal{O}}^{\mathbf{X}}}
\newcommand{\mathbf{Y}}{\mathbf{Y}}
\newcommand{\mathcal{B}^{\Y}}{\mathcal{B}^{\mathbf{Y}}}
\newcommand{n_{\bmO}^{\Y}}{n_{\mathcal{O}}^{\mathbf{Y}}}
\newcommand{\mathcal{K}}{\mathcal{K}}
\algrenewcommand\algorithmicrequire{\textbf{Precondition:}}
\algrenewcommand\algorithmicensure{\textbf{Postcondition:}}
\newtheorem{theorem}{Theorem}
\newtheorem{definition}[theorem]{Definition}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{lemme}[theorem]{Lemma}
\newtheorem{remark}[theorem]{Remark}
\newtheorem{assumption}[theorem]{Assumption}
\newcommand{\Pavlo}[1]{{\color{green}P: #1}}
\newcommand{\Guillaume}[1]{{\color{red}G: #1}}
\begin{document}
\runningauthor{Guillaume Staerman, Pierre Laforgue, Pavlo Mozharovskyi, Florence d'Alch\'{e}-Buc}
\twocolumn[
\aistatstitle{When OT meets MoM: Robust estimation of Wasserstein Distance}
\aistatsauthor{Guillaume Staerman \And Pierre Laforgue \And Pavlo Mozharovskyi \And Florence d'Alch\'{e}-Buc }
\aistatsaddress{ LTCI, T\'{e}l\'{e}com Paris, Institut Polytechnique de Paris } ]
\begin{abstract}
Issued from Optimal Transport, the Wasserstein distance has gained importance in Machine Learning due to its appealing geometrical properties and the increasing availability of efficient approximations.
It owes its recent ubiquity in generative modelling and variational inference to its ability to cope with distributions having non overlapping support.
In this work, we consider the problem of estimating the Wasserstein distance between two probability distributions when observations are polluted by outliers. To that end, we investigate how to leverage a Medians of Means (MoM) approach to provide robust estimates.
Exploiting the dual Kantorovitch formulation of the Wasserstein distance, we introduce and discuss novel MoM-based robust estimators whose consistency is studied under a data contamination model and for which convergence rates are provided. Beyond computational issues, the choice of the partition size, \textit{i.e.,} the unique parameter of theses robust estimators, is investigated in numerical experiments. Furthermore, these MoM estimators make Wasserstein Generative Adversarial Network (WGAN) robust to outliers, as witnessed by an empirical study on two benchmarks CIFAR10 and Fashion MNIST.
\end{abstract}
\section{Introduction}
Computing distances between probability distributions has become a central question in numerous modern Machine Learning applications, ranging from generative modeling to clustering.
Optimal Transport (OT) \citep{Villani,Santambrogio} offers an appealing and insightful tool to solve this problem, building upon the Wasserstein distance.
Given two probability distributions, the latter is defined in terms of the solution to the Monge-Kantorovich optimal mass transportation problem.
Interestingly, it relies on a ground distance between points to build a distance between probability distributions \citep{Peyre}. For that reason, the Wasserstein distance stands out from the divergences usually exploited in generative modeling, like the f-divergences \citep{csiszar,nguyen2009}, by its ability to take into account the underlying geometry of the space, capturing the difference between probability distributions even when they have non-overlapping supports. This appealing property has been successfully exploited in Generative Adversarial Networks (GANs) \citep{goodfellow,arjovsky2017,gulrajani2017improved}, as well as in Variational Autoencoders (VAEs) \citep{bousquetetal17}, where the Wasserstein distance can advantageously replace an f-divergence as the loss function.
Many other applications \citep{courty2017,flamary18,genevay18} rely on the entropic-regularized approximations introduced by \cite{cuturi13}, which has considerably alleviated the inherent computational complexity of the Wasserstein distance in the discrete case, by drawing on the Sinkhorn-Knopp algorithm. A common feature to almost all these works is that the Wasserstein distance is estimated from finite samples. While this problem has long been theoretically studied under the i.i.d. assumption \citep{dudley1969,bassetti2006,weed2019}, it has never been tackled through the lens of robustness to outliers, a crucial issue in Reliable Machine Learning. Indeed, data is nowadays collected at a large scale in unmastered acquisition conditions, and through a large variety of devices and platforms. The resulting datasets often present undesirable influential observations, whether they are errors or rare observations. The presence of corrupted data may heavily damage the quality of estimators, calling for dedicated methods such as JS/TV-GANs \citep{gao2018robust} in the particular case of robust shift-parameter estimation, Robust Divergences in variational inference \citep{futami}, or more general tools from robust statistics \citep{Huber2009}.
The aim of this work is to propose outliers-robust estimators of the Wasserstein distance, and illustrate their application in generative modeling. To that end, we explore how to combine a Median-of-Means approach with Optimal Transport. The Median-of-Means (MoM) is a robust mean estimator firstly introduced in complexity theory during the 1980s \cite{nemirovsky1983problem,jerrum1986random,alon1999space}.
Following the seminal deviation study by \cite{catoni2012challenging}, MoM has lately witnessed a surge of interest, mainly due to its attractive sub-gaussian behavior, under the sole assumption that the underlying distribution has finite variance \citep{devroye2016sub}. Originally devoted to scalar random variables, MoM has notably been extended to random vectors \citep{minsker2015geometric,hsu2016loss,lugosi2017sub} and $U$-statistics \citep{joly2016robust,laforgue2019medians}. As a natural alternative to the empirical mean, MoM has become the cornerstone of several robust learning procedures in heavy-tailed situations, including bandits \citep{bubeck2013bandits} and MoM-tournaments \citep{lugosi2019risk}. A more recent line of work now focuses on MoM's ability to deal with outliers. Aside from concentration results in a contaminated context \cite{depersin2019robust,papier2}, it has yielded promising applications in robust mean embedding \citep{monk}, and the more general MoM-minimization framework \citep{lecue2018robust}.
In this paper, we introduce and study outliers-robust estimators of the Wasserstein distance based on the MoM methodology. Our contribution is threefold:
\begin{itemize}
\item Focusing on the Kantorovich-Rubinstein duality \citep{kantorovich1958}, we present three novel MoM-based estimators, leveraging in particular Medians of $U$-statistics (MoU). In the realistic setting of contaminated data, we show their strong consistency, and provide non-asymptotic bounds as well.
\item We propose a dedicated algorithm to compute these three estimators in practice. Applied on a parametric family of Lipschitz functions, \textit{e.g.} neural networks with clipped weights, it performs a MoM/MoU gradient descent algorithm. A sensitivity analysis of the unique parameter of these estimators is also provided throught numerical experiments on toy datasets.
\item We robustify WGANs (w.r.t. outliers) using a MoM-based estimator as loss function. We show the benefits of this approach through convincing numerical results on two contaminated well known benchmarks: CIFAR10 and Fashion MNIST.
\end{itemize}
\section{Background and preliminaries} \label{Back}
Before introducing the problem to be addressed, we recall some key notions about the Wasserstein distance and the Medians-of-Means estimator. Let $\mathcal{X}$ and $\mathcal{Y}$ be subsets of $\mathbb{R}^d$, for some $d \in \mathbb{N}^*$. We denote by $\mathcal{M}^1_+(\mathcal{X})$ the space of all probability measures on $\mathcal{X}$, and consider two distributions $\mu$ and $\nu$ from $\mathcal{M}^1_+(\mathcal{X})$ and $\mathcal{M}^1_+(\mathcal{Y})$. For any $K \in \mathbb{N}^*$, the median of $\{z_1, \ldots, z_K\} \in \mathbb{R}^K$ is denoted by $\underset{1 \le k \le K}{\text{med}}\{z_k\}$.
\subsection{Wasserstein Distance}
Given $p \in [1, \infty)$, the Wasserstein distance of order $p$ between two arbitrary measures $\mu$ and $\nu$ is defined through the resolution of the Monge-Kantorovitch mass transportation problem \citep{Villani,Peyre}:
\begin{equation}\label{OT-primal}
\mathcal{W}_p(\mu, \nu)= \underset{ \pi~\in~\mathcal{U}(\mu,\nu)}{\min} \left( \int_{\mathcal{X} \times \mathcal{Y}} \| x - y\|^p d\pi(x\times y) \right)^{1/p}\ ,
\end{equation}
where $\mathcal{U}(\mu,\nu)= \{ \pi \in \mathcal{M}^1_+(\mathcal{X} \times \mathcal{Y}): \; \; \int \pi(x,y)dy =\mu(x) ;\int \pi(x,y) dx=\nu(y) \}$ is the set of joint probability distributions with marginals $\mu$ and $\nu$. In the remainder of this paper, we focus on the Wasserstein of order 1, $\mathcal{W}_1$, omitting the subscript $1$ for notation simplicity.
By the dual Kantorovich-Rubinstein formulation \cite{kantorovich1958}, with $\mathcal{B}_L$ the unit ball of the Lipschitz functions space, a useful rewriting of the $1$-Wasserstein distance is:
\begin{equation}\label{OT-dual}
\mathcal{W}(\mu,\nu)=\underset{\phi \in \mathcal{B}_L}{\sup} \; \; \mathbb{E}_\mu \left[\phi(X)\right]-\mathbb{E}_\nu \left[\phi(Y)\right].
\end{equation}
Of particular interest is the problem of estimating the Wasserstein distance between $\mu$ and $\nu$ given a finite number of observations.
The usual assumption is to rely upon two samples $\mathbf{X}=\{X_1, \ldots, X_n\}$ and $ \mathbf{Y}=\{Y_1, \ldots, Y_m\}$, composed of i.i.d. realizations drawn respectively from $\mu$ and $\nu$.
The corresponding empirical distributions denoted by $\hat{\mu}_n = (1/n) \sum_{i=1}^n \delta_{X_i}$, and $\hat{\nu}_m= (1/m) \sum_{j=1}^m \delta_{Y_j}$.
The natural questions are then: \textit{how to compute the estimator $\mathcal{W}(\hat{\mu}_n,\hat{\nu}_m)$, and does it converge towards $\mathcal{W}(\mu,\nu)$?}
In the dual formulation \eqref{OT-dual}, computing $\mathcal{W}(\hat{\mu}_n, \hat{\nu}_m)$ is equivalent to replace the expectations with empirical means.
The unit ball of Lipschitz functions can be replaced with a parameterized family of Lipschitz functions, more amenable for learning when $\mathcal{W}(\hat{\mu}_n, \hat{\nu}_m)$ is used as a loss function, see \textit{e.g.} Wasserstein GANs \cite{arjovsky2017}.
From the theoretical side, a substantial number of works have studied the convergence of $\mathcal{W}(\hat{\mu}_n, \hat{\nu}_m)$ under the i.i.d. setting described above. Statistical rates of convergence of the original OT problem are known to be slow rates with respect to the dimension $d$ of the input space, \textit{i.e.} they are of order $O(n^{-1/d})$ \citep{dudley1969,bassetti2006,weed2019,boissard2011,FG15}.
\subsection{Median-of-Means}\label{s:intro_MoM}
Given an i.i.d. sample $\mathbf{X} = \{ X_1, \ldots, X_n\}$ drawn from $\mu$, the Median-of-Means (MoM) is an estimator of $\mathbb{E}_\mu[X]$ built as follows. First, choose $K_{\mathbf{X}} \le n$, and partition $\{1,\ldots, n \}$ into $K_{\mathbf{X}}$ disjoint blocks $\mathcal{B}_1^{\mathbf{X}}, \ldots, \mathcal{B}_{K_{\mathbf{X}}}^{\mathbf{X}}$ of size $B_{\mathbf{X}} = n / K_{\mathbf{X}}$. If $n$ cannot be divided by $K_{\mathbf{X}}$, some observations may be removed. Then, empirical means are computed on each of the $K_{\mathbf{X}}$ blocks. The estimator returned is finally the median of the empirical means thus computed. For a function $\Phi\colon \mathcal{X} \rightarrow \mathbb{R}$, the MoM estimator of $\mathbb{E}_\mu[\Phi(X)]$ is then formally given by:
\begin{equation}\label{eq:MoM}
\text{MoM}_{\mathbf{X}}[\Phi]=\underset{1\leq k\leq K_{\mathbf{X}}}{\text{med}} \Bigl\{ \frac{1}{B_{\mathbf{X}}}\sum_{i \in \mathcal{B}_k^{\mathbf{X}}} \Phi(X_i) \Bigr\}.
\end{equation}
This estimator provides an attractive alternative to the sample mean $\overline{\Phi}_{\mathbf{X}}= (1/n)\sum_{i=1}^n \Phi(X_i)$ for robust learning. Indeed, it has been shown to (i) exhibit a sub-Gaussian behavior under only a finite variance assumption, making it particularly suited to heavy-tailed distributions, and (ii) be non-sensitive to outliers.
MoM also nicely adapts to multisample $U$-statistics of arbitrary degrees \citep{Lee90}. Indeed, assume that one is interested in estimating $\mathbb{E}_{\mu \otimes \nu}[h(X, Y)]$, for some kernel $h \colon \mathcal{X} \times \mathcal{Y} \rightarrow \mathbb{R}$. Given the samples $\mathbf{X} = \{ X_1, \ldots, X_n\}$ and $\mathbf{Y} = \{ Y_1, \ldots, Y_m\}$, a natural idea then consists in partitioning both $\{1,\ldots, n \}$ and $\{1,\ldots, m \}$ into $\mathcal{B}_1^{\mathbf{X}}, \ldots, \mathcal{B}_{K_{\mathbf{X}}}^{\mathbf{X}}$ and $\mathcal{B}_1^{\mathbf{Y}}, \ldots, \mathcal{B}_{K_{\mathbf{Y}}}^{\mathbf{Y}}$ respectively, with $K_{\mathbf{Y}} \le m$, and $B_{\mathbf{Y}} = m / K_{\mathbf{Y}}$. One may then compute $U$-statistics on each pair of blocks $(k, l)$ for $k \le K_{\mathbf{X}}$ and $l \le K_{\mathbf{Y}}$, and return the median of the $K_{\mathbf{X}}\times K_{\mathbf{Y}}$ $U$-statistics. However, this construction introduces dependence between the base estimators, making the theoretical study more difficult. An alternative then consists in choosing $K_{\mathbf{X}} = K_{\mathbf{Y}} = K$, and considering only the diagonal blocks (see Figure \ref{fig:mou_diag}). These two estimators are referred to as (diagonal) Median-of-$U$-statistics (MoU), and using $\mathcal{B}_{k,l}^{\mathbf{XY}}$ to denote the block of tuples $(X_i,Y_j)$ such that $X_i \in \mathcal{B}_k^{\mathbf{X}}$ and $Y_j \in \mathcal{B}_l^{\mathbf{Y}}$, they are formally given by:
\begin{align*}
\text{MoU}_{\mathbf{XY}}[h] &=\underset{\substack{1\leq k\leq K_{\mathbf{X}}\\1\leq l\leq K_{\mathbf{Y}} }}{\text{med}} \Bigl\{ \frac{1}{B_{\mathbf{X}}B_{\mathbf{Y}}} \underset{(i,j) \in \mathcal{B}_{k,l}^{\mathbf{XY}} }{\sum} h(X_i, Y_j) \Bigr\},\\[0.2cm]
\text{MoU}^\text{diag}_{\mathbf{XY}}[h] &=\underset{1\leq k\leq K}{\text{med}} \Bigl\{ \frac{1}{B_{\mathbf{X}}B_{\mathbf{Y}}} \underset{(i,j) \in \mathcal{B}_{k,k}^{\mathbf{XY}} }{\sum} h(X_i, Y_j) \Bigr\}.
\end{align*}
\iffalse
\subsection{Goal of this work}\label{s:intro_pb}
This work aims at building novel estimators of $\mathcal{W}(\mu,\nu)$ that are robust to outliers. In order to assess robustness, we place ourselves in the realistic $\mathcal{O} \cup \mathcal{I}$ framework, see \textit{e.g.} \cite{Huber2009,lecue2017robust}, devoted to data contamination. In this setting, the i.i.d. assumption is relaxed, and the following assumption is instead adopted.
\begin{assumption}\label{ass:contamination}
Sample $\mathbf{X}$ is polluted with $n_{\mathcal{O}}^{\mathbf{X}} < n/2$ (possibly adversarial) outliers. The remaining $n - n_{\mathcal{O}}^{\mathbf{X}}$ points are informative data, or \emph{inliers}, independently distributed according to $\mu$. A similar assumption is made on $\mathbf{Y}$, which is supposed to contain $m_{\mathcal{O}}^{\mathbf{Y}} < m/2$ arbitrary outliers, and $m - m_{\mathcal{O}}^{\mathbf{Y}}$ inliers drawn from $\nu$. Inliers are assumed to lie in a compact set $\mathcal{K} \subset \mathbb{R}^d$. In contrast, no assumption is made on the outliers, that may not be bounded. The proportions of outliers in samples $\mathbf{X}$ and $\mathbf{Y}$ are denoted by $\tau_{\mathbf{X}}= n_{\mathcal{O}}^{\mathbf{X}} / n$ and $\tau_{\mathbf{Y}}=m_{\mathcal{O}}^{\mathbf{Y}}/ m$ respectively.
\end{assumption}
In the following, we investigate how MoM estimators can be leveraged to define and analyze new estimators of the Wasserstein distance when the observed samples $\mathbf{X}$ and $\mathbf{Y}$ are contaminated according to Assumption~\ref{ass:contamination}.
\fi
\section{When Wasserstein meets MoM}
\label{MoM}
In this section, we investigate how MoM estimators can be leveraged to define and analyze new estimators of $\mathcal{W}(\mu,\nu)$ that exhibit strong theoretical guarantees in presence of outliers.
In order to assess robustness, we place ourselves in the realistic $\mathcal{O} \cup \mathcal{I}$ framework, see \textit{e.g.} \cite{Huber2009,lecue2017robust}, devoted to data contamination.
In this setting, the i.i.d. assumption is relaxed, and the following assumption is instead adopted.
\begin{assumption}\label{ass:contamination}
Sample $\mathbf{X}$ is polluted with $n_{\mathcal{O}} < n/2$ (possibly adversarial) outliers. The remaining $n - n_{\mathcal{O}}$ points are informative data, or \emph{inliers}, independently distributed according to $\mu$. A similar assumption is made on $\mathbf{Y}$, which is supposed to contain $m_{\mathcal{O}} < m/2$ arbitrary outliers, and $m - m_{\mathcal{O}}$ inliers drawn from $\nu$. Inliers are assumed to lie in a compact set $\mathcal{K} \subset \mathbb{R}^d$. In contrast, no assumption is made on the outliers, that may not be bounded. The proportions of outliers in samples $\mathbf{X}$ and $\mathbf{Y}$ are denoted by $\tau_{\mathbf{X}}= n_{\mathcal{O}} / n$ and $\tau_{\mathbf{Y}}=m_{\mathcal{O}} / m$ respectively.
\end{assumption}
\subsection{MoM and MoU-based estimators}
\label{sec:estimators}
Starting from the expression of the dual expression \eqref{OT-dual}, we observe that it can be considered with a two-fold perspective. The first one consists in considering the Wasserstein distance as the supremum of the difference between two expected values. The second one, obtained by linearity of the expectation, rather regards $\mathcal{W}(\mu, \nu)$ as the supremum of single expected values, but taken with respect to the tuple $(X, Y)$, and associated to the kernel: $h_\phi\colon (X, Y) \mapsto \phi(X) - \phi(Y)$.
Although quite elementary at first sight, this two-fold perspective gains complexity when applied to the empirical distributions $\hat{\mu}_n$ and $\hat{\nu}_m$.
Indeed, following the first perspective, the natural estimator obtained is the supremum of the differences between two empirical averages, while the second one leads to the supremum of $2$-samples $U$-statistics of degrees $(1, 1)$ and kernels $h_{\phi}$.
So far, both points of view are strictly equivalent by linearity of the expectation and the empirical mean.
However, this equivalence breaks down as soon as non-linearities are introduced, through MoM-like estimators for instance.
We therefore introduce three distinct estimators of $\mathcal{W}(\mu, \nu)$, that differ upon which estimator of Section \ref{s:intro_MoM} is used.
\begin{definition}\label{def:estimators}
We define the Median-of-Means and the Median-of-$U$-statistics estimators of the $1$-Wasserstein distance as follows:
\begin{align*}
\mathcal{W}_\mathrm{MoM}(\hat{\mu}_n, \hat{\nu}_m) &= \sup_{\phi \in \mathcal{B}_L} \{ \mathrm{MoM}_{\mathbf{X}}[\phi] - \mathrm{MoM}_{\mathbf{Y}}[\phi] \},\\[0.2cm
\mathcal{W}_\mathrm{MoU}(\hat{\mu}_n, \hat{\nu}_m) &= \sup_{\phi \in \mathcal{B}_L} \{ \mathrm{MoU}_{\mathbf{XY}}[h_\phi] \},\\[0.2cm
\mathcal{W}_\mathrm{MoU-diag}(\hat{\mu}_n, \hat{\nu}_m) &= \sup_{\phi \in \mathcal{B}_L} \{ \mathrm{MoU}^\mathrm{diag}_{\mathbf{XY}}[h_\phi] \}
\end{align*}
\end{definition}
While $\mathcal{W}_{\text{MoM}}$ relies on the difference between individual median blocks, $\mathcal{W}_{\text{MoU-diag}}$ considers the median over all possible combinations of blocks between $\mathbf{X}$ and $\mathbf{Y}$.
As an intermediate step, $\mathcal{W}_{\text{MoU-diag}}$ looks after diagonal blocks only.
The latter formulation is used in \cite{monk} to derive robust mean embedding and Maximum Mean Discrepancy estimators.
The theoretical analysis is made simpler by the independence between the blocks, but the estimator suffers from an increased variance due to the important loss of information, see Figure \ref{fig:mou_diag} and \cite{joly2016robust}.
It should be noticed however that $\mathcal{W}_{\text{MoU-diag}}$ enjoys a much lower computational cost in practice.
One elegant way to combine both benefits, \textit{i.e.} small loss of information and low computational cost, is to consider randomized blocks \cite{laforgue2019medians}.
Instead of partitioning the dataset, this method builds blocks by sampling them independently through simple Sampling Without Rejection (SWoR).
One consequence is the possibility for the randomized blocks to overlap (see $\mathscr{B}^{\mathbf{X}}_1$, $\mathscr{B}^{\mathbf{X}}_2$, $\mathscr{B}^{\mathbf{X}}_3$ in Figure \ref{fig:mom_morm}), making the estimator's concentration analysis more difficult.
Nevertheless, guarantees similar to that of MoM have been established (up to constants), and the extension to $2$-sample $U$-statistics built on randomized blocks allows for a better exploration of the grid than through $\mathrm{MoU}^\text{diag}$, see Figure \ref{fig:mou_rand}.
However, despite the possibility to reach every part of the grid, the exploration scheme illustrated in Figure \ref{fig:mou_rand} have a fixed structure (\textit{e.g.} always $3$ cells per column, $4$ cells per row).
The \emph{totally free} alternative, as depicted in Figure \ref{fig:mou_incomp}, consists in sampling directly from the pairs of observations, which generates incomplete $U$-statistics.
If no theoretical guarantees have been established for this extension due to the complex replication setting between blocks, it still benefits from good empirical results \cite{laforgue2019medians}, consistent with the grid covering it allows.
Another important question to be addressed is: \textit{how to handle the non-differentiability introduced by the median operator?}
Indeed, the Wasserstein distance often acts as a loss function, \textit{e.g.} in generative modeling (VAEs, GANs), and optimizing through a MoM/MoU-based criterion then becomes crucial.
One answer is to uses a MoM-gradient descent algorithm \citep{lecue2018robust}.
It consists in performing a mini-batch gradient step based on the median block.
In order to avoid local minima, authors propose shuffle the partition at each step of the descent, leading to the minimization of an expected MoM loss (w.r.t. the shuffling) that is more stable.
Notice that this method goes beyond random partitions, and easily adapts to the randomized extensions discussed above.
\begin{figure*}[!t]
\centering
\begin{subfigure}{.35\textwidth}
\centering
\includegraphics[width=0.65\textwidth]{mom.pdf}\\[0.3cm]
\includegraphics[width=0.65\textwidth]{morm.pdf}\\[0.4cm]
\caption{1D standard and randomized MoM}
\label{fig:mom_morm}
\end{subfigure}
\hfill
\begin{subfigure}{.3\textwidth}
\centering
\includegraphics[width=0.65\textwidth]{ustat.pdf}
\caption{$\mathrm{MoU}_\mathbf{XY}$}
\label{fig:mou}
\end{subfigure}
\hfill
\begin{subfigure}{.3\textwidth}
\centering
\includegraphics[width=0.65\textwidth]{ustat_diag.pdf}
\caption{$\mathrm{MoU}^\text{diag}_\mathbf{XY}$}
\label{fig:mou_diag}
\end{subfigure}\\[0.4cm]
\begin{subfigure}{.35\textwidth}
\centering
\vspace{-0.3cm}
\includegraphics[width=0.55\textwidth]{constraints.pdf}\\[-0.25cm]
\caption{Admitted proportion of outliers}
\label{fig:outliers}
\end{subfigure}
\hfill
\begin{subfigure}{.3\textwidth}
\centering
\includegraphics[width=0.65\textwidth]{ustat_rand.pdf}
\caption{MoU based on randomized blocks}
\label{fig:mou_rand}
\end{subfigure}
\hfill
\begin{subfigure}{.3\textwidth}
\centering
\includegraphics[width=0.65\textwidth]{ustat_incomp.pdf}
\caption{MoU based on randomized pairs}
\label{fig:mou_incomp}
\end{subfigure}
\caption{Sampling strategies to build MoM and MoU, as well as admitted proportion of outliers.}
\label{fig:blocks}
\end{figure*}
\subsection{Theoretical guarantees}\label{TG}
We now establish the statistical guarantees satisfied by the estimators introduced in Definition \ref{def:estimators} under Assumption \ref{ass:contamination}.
First notice that if $\hat{\mu}_\text{MoM}$ denotes with a language abuse the \emph{measure} such that for all application $\phi\colon \mathbb{R}^d \rightarrow \mathbb{R}$ it holds $\mathbb{E}_{\hat{\mu}_\text{MoM}}\left[\phi\right] = \text{MoM}_{\mathbf{X}}[\phi]$, it is direct to see that $\mathcal{W}_\text{MoM}(\hat{\mu}_n, \hat{\nu}_m) = \mathcal{W}(\hat{\mu}_\text{MoM}, \hat{\nu}_\text{MoM})$.
Then, it holds $\mathcal{W}_\text{MoM}(\hat{\mu}_n, \hat{\nu}_m) - \mathcal{W}(\mu, \nu) \le \mathcal{W}(\mu, \hat{\mu}_\text{MoM}) + \mathcal{W}(\hat{\nu}_\text{MoM}, \nu)$, and one may only focus on the theoretical guarantees of the right-hand side terms.
Before stating our main results, we need an additional assumption on the numbers of outliers $n_{\mathcal{O}}$ and $m_{\mathcal{O}}$, which are assumed to grow sub-linearly with respect to $n$ and $m$.
\begin{assumption}\label{ass:nO}
There exist $C_{\mathcal{O}} \geq 1$ and $0 \leq \alpha_{\mathcal{O}} <1 $ such that $n_{\mathcal{O}} \le C_{\mathcal{O}}^2~n^{\alpha_{\mathcal{O}}}$ and $m_{\mathcal{O}} \le C_{\mathcal{O}}^2~m^{\alpha_{\mathcal{O}}}$.
\end{assumption}
We start by an asymptotic result establishing the strong consistency of estimators in Definition \ref{def:estimators}.
It highlights the different outlier configurations allowed through conditions on the proportions of outliers $\tau_\mathbf{X}$ and $\tau_\mathbf{Y}$.
\begin{proposition}\label{prop:consistency}
Suppose that samples $\mathbf{X}$ and $\mathbf{Y}$ satisfy Assumptions \ref{ass:contamination} and \ref{ass:nO}.
Then, choosing $K_{\mathbf{X}} = \lceil \sqrt{2\tau_\mathbf{X}}~n \rceil$, it holds:\vspace{-0.1cm}
$$
\mathcal{W}(\hat{\mu}_\mathrm{MoM}, \mu) \overset{a.s}{\longrightarrow} 0.
$$
If moreover $\tilde{\tau} \coloneqq \tau_\mathbf{X} + \tau_\mathbf{Y} - \tau_\mathbf{X}\tau_\mathbf{Y} < 1/2$, then choosing $K_{\mathbf{X}} = \lceil \sqrt{2\tilde{\tau}}~n \rceil$ and $K_{\mathbf{Y}} = \lceil \sqrt{2\tilde{\tau}}~m \rceil$, it holds:
$$
\big \vert \mathcal{W}_{\mathrm{MoU}}(\hat{\mu}_n, \hat{\nu}_m) - \mathcal{W}(\mu, \nu) \big \vert \overset{a.s}{\longrightarrow} 0.
$$
If finally $\tau_\mathbf{X} + \tau_\mathbf{Y} < 1/2$ and $n=m$, then choosing $K_{\mathbf{X}} = K_{\mathbf{Y}} = \lceil \sqrt{2(\tau_\mathbf{X} + \tau_\mathbf{Y})}~n \rceil$, it holds:
$$
\big \vert \mathcal{W}_{\mathrm{MoU-diag}}(\hat{\mu}_n, \hat{\nu}_m) - \mathcal{W}(\mu, \nu) \big \vert \overset{a.s}{\longrightarrow} 0.
$$
\end{proposition}
The key argument in the proof of Proposition \ref{prop:consistency} consists in converting the convergence of the different estimators into the convergences of blocks containing no outliers.
Numbers of blocks $K_{\mathbf{X}}$ and $K_{\mathbf{Y}}$ are chosen such that (i)~such blocks are always in majority, and (ii) their sizes $n/K_{\mathbf{X}}$ and $m/K_{\mathbf{Y}}$ go to infinity as $n$ and $m$ go to infinity.
Any other choice of $K_{\mathbf{X}}$ and $K_{\mathbf{Y}}$ that satisfies this two conditions also ensures convergence.
If the outliers proportions are unknown, building $K_{\mathbf{X}}$ and $K_{\mathbf{Y}}$ from upper bounds of $\tau_\mathbf{X}$ and $\tau_\mathbf{Y}$ thus does not impact Proposition \ref{prop:consistency}.
The conditions on $K_{\mathbf{X}}$ and $K_{\mathbf{Y}}$ also constrain the proportions of outliers admitted, as illustrated in Figure \ref{fig:outliers}.
The assumption $n=m$ for $\mathcal{W}_{\mathrm{MoU-diag}}$ is necessary to be able to build a majority of sane blocks.
Our next proposition now investigates the nonasymptotic behavior of the proposed estimators.
\begin{proposition}\label{prop:appli_dev}
Suppose that samples $\mathbf{X}$ and $\mathbf{Y}$ satisfy Assumption \ref{ass:contamination}, and define $\Gamma\colon \tau \mapsto \sqrt{1 + \sqrt{2\tau}} / \sqrt{1 - 2\tau}$.
Then, for all $\delta \in ]0, \exp(-4n\sqrt{2\tau_{\mathbf{X}}})]$, choosing $K_{\mathbf{X}}=\lceil \sqrt{2\tau_{\mathbf{X}}}~n\rceil$, it holds with probability at least $1 - \delta$:
\begin{equation*}
\mathcal{W}(\hat{\mu}_\mathrm{MoM}, \mu) \le \frac{C_1(\tau_{\mathbf{X}})}{n^{1/(d+2)}} + C_2(\tau_{\mathbf{X}}) \sqrt{\frac{\log(1/\delta)}{n}},
\end{equation*}
with $C_1(\tau) = 2 + C_L C_2(\tau)$, $C_2(\tau) = 4~\mathrm{diam}(\mathcal{K})~\Gamma(\tau)$, and $C_L$ a universal constant depending only on $\mathcal{B}_L$.
If furthermore $\tau_{\mathbf{X}} + \tau_{\mathbf{Y}} < 1/2$ and $n=m$, then for all $\delta \in ]0, \exp(-4n\sqrt{2(\tau_{\mathbf{X}} + \tau_{\mathbf{Y}})})]$, choosing $K_{\mathbf{X}} = K_{\mathbf{Y}} = \lceil \sqrt{2(\tau_{\mathbf{X}}+\tau_{\mathbf{Y}})}~n\rceil$, it holds with probability at least $1 - \delta$:
\begin{gather*}
\Big| \mathcal{W}_\mathrm{MoU-diag}(\hat{\mu}_n, \hat{\nu}_m) - \mathcal{W}(\mu, \nu)\Big|\hspace{3cm}\\
\hspace{1cm}\le \frac{2C_1(\tau_{\mathbf{X}} + \tau_{\mathbf{Y}})}{n^{1/(d+2)}} + 2C_2(\tau_{\mathbf{X}} + \tau_{\mathbf{Y}}) \sqrt{\frac{\log(1/\delta)}{n}}.
\end{gather*}
\end{proposition}
The proof derives from concentration results established in \cite{papier2}, combined with a generic chaining argument.
It should be noticed that constant $C_2(\tau_\mathbf{X})$ explodes as $\tau_{\mathbf{X}}$ goes to $1/2$, which is expected: the more outliers, the more difficult it is to estimate $\mathcal{W}(\mu, \nu)$.
We also stress that the dependence in $1/\sqrt{1 - 2\tau_{\mathbf{X}}}$ is better than the $1/(1 - 2\tau_{\mathbf{X}})^{3/2}$ term exhibited in \cite{monk}.
Integrating the deviation probabilities of Proposition \ref{prop:appli_dev} and using Assumption \ref{ass:nO}, we finally obtain our main theorem, that provides a nonasymptotic control on the expected value of our estimators deviations from $\mathcal{W}(\mu, \nu)$.
\begin{theorem}\label{thm:expectation}
Suppose that samples $\mathbf{X}$ and $\mathbf{Y}$ satisfy Assumptions \ref{ass:contamination} and \ref{ass:nO}, and recall the notation used in Proposition \ref{prop:appli_dev}.
Let $\beta \in [0, 1]$, then for all $n$ such that $n^{\frac{1}{d+2} + \frac{1 - \beta}{2}} \ge C_1(\tau_{\mathbf{X}})/(2C_2(\tau_{\mathbf{X}})(2\tau_{\mathbf{X}})^\frac{1}{4})$, it holds:
\begin{equation*}
\mathbb{E}\left[\mathcal{W}(\hat{\mu}_\mathrm{MoM}, \mu)\right] ~\le~ \frac{\kappa_1(\tau_{\mathbf{X}})}{n^{1/(d+2)}} + \frac{\kappa_2(\tau_{\mathbf{X}})}{n^{(\beta- \alpha_{\mathcal{O}})/2}} + \frac{\kappa_3(\tau_{\mathbf{X}})}{n^{\beta/2}},
\end{equation*}
with $\kappa_1(\tau) = C_1(\tau)$, $\kappa_2(\tau) =2C_{\mathcal{O}}C_2(\tau)(2/\tau)^{1/4}$, and $\kappa_3(\tau) = \sqrt{\pi}C_2(\tau)/2$.
Of course, the above bound only makes sense if $\beta > \alpha_{\mathcal{O}}$.
In particular, if $\alpha_\mathcal{O} \le d / (d+2)$, setting $\beta=1$ gives that for all $n$ such that $n^{\frac{1}{d+2}} \ge C_1(\tau_{\mathbf{X}})/(2C_2(\tau_{\mathbf{X}})(2\tau_{\mathbf{X}})^\frac{1}{4})$, with the notation $\kappa = \kappa_1 + \kappa_2 + \kappa_3$, it holds:
\begin{equation*}
\mathbb{E}\left[\mathcal{W}(\hat{\mu}_\mathrm{MoM}, \mu)\right] ~\le~ \kappa(\tau_{\mathbf{X}})~n^{-1/(d+2)}.
\end{equation*}
If furthermore $\tau_{\mathbf{X}} + \tau_{\mathbf{Y}} < 1/2$ and $n=m$, then for all $n$ s.t. $n^{\frac{1}{d+2}} \ge C_1(\tau_{\mathbf{X}} + \tau_{\mathbf{Y}})/(2C_2(\tau_{\mathbf{X}} + \tau_{\mathbf{Y}})(2(\tau_{\mathbf{X}} + \tau_{\mathbf{Y}}))^\frac{1}{4})$, with the notation $\kappa' = 2\kappa_1 + 2\sqrt{2}\kappa_2 + 2\kappa_3$, it holds:
\begin{align*}
\mathbb{E}\big|\mathcal{W}_\mathrm{MoU-diag}(\hat{\mu}_n, \hat{\nu}_m) -& \mathcal{W}(\mu, \nu)\big|\\
&\le~ \kappa'(\tau_{\mathbf{X}} + \tau_{\mathbf{Y}})~n^{-1/(d+2)}.
\end{align*}\vspace{-0.88cm}
\end{theorem}
Theorem \ref{thm:expectation} highlights that the estimators proposed in Definition \ref{def:estimators} remarkably resist to the presence of outliers in the training datasets.
The price to pay is a slightly slower rate of order $O(n^{-1/(d+2)})$, that becomes equivalent in high dimension -- the usual setting of Optimal Transport -- to the standard $O(n^{-1/d})$ rate.
Interestingly, the dependence in the outliers growing rate $\alpha_\mathcal{O}$ is made explicit, and is in line with expectations (see below).
Unfortunately, the dependency between the blocks makes the nonasymptotic analysis harder for $\mathcal{W}_{\text{MoU}} $ and the computationally cheap randomized extensions discussed in Section \ref{sec:estimators}.
This theoretical challenge is left for future work.
We stress that there is no \emph{median-of-means miracle}.
If the number of blocks allows to cancel the outliers impact, the statistical performance then scales with the block size, \textit{i.e.} as $1/\sqrt{B_\mathbf{X}} = \sqrt{K_{\mathbf{X}}/n}$.
Since $K_{\mathbf{X}}$ is roughly $2 n_{\mathcal{O}}$, this means a $\sqrt{n_{\mathcal{O}}/n}$ rate.
So if one allows $n_{\mathcal{O}}$ to grow proportionally to $n$, the bound becomes vacuous.
To get guarantees improving with $n$, we thus need $n_{\mathcal{O}}$ to scale as $n^{\alpha_{\mathcal{O}}}$, for some $\alpha_{\mathcal{O}} < 1$, and the resulting rate is $n^{(1 - \alpha_{\mathcal{O}})/2}$, as found in Theorem \ref{thm:expectation}.
We finally point out that the condition on $n$ ensures $\mathcal{W}(\hat{\mu}_\mathrm{MoM}, \mu) \ge C_1(\tau_{\mathbf{X}})/n^{1/(d+2)} - C_2(\tau_{\mathbf{X}})\sqrt{\log(1/\delta)/n^\beta}$, as the right hand side is negative while $\mathcal{W}(\hat{\mu}_\mathrm{MoM}, \mu)$ is positive by construction.
A less stringent condition might be derived, using \textit{e.g.} the nature of the functions in $\mathcal{B}_L$.
\begin{remark}\label{rmk:other_IPMs}
The unique property of the Wasserstein distance we used, compared to other Integral Probability Metrics (IPMs) \cite{Bharath2012}, is the way to bound the entropy of the unit ball of Lipschitz functions. The present analysis can thus be extended in a direct fashion to any other IPM that has finite entropy.
\end{remark}
\section{MoM-based estimators in practice}\label{num}
In this section, we first propose a novel algorithm to approximate the MoM/MoU-based estimators using neural networks and provide an empirical study of its behaviour on two toy datasets. Then, we show how to robustify Wasserstein-GANs and present MoMWGAN, a MoM-based variant of GAN, which is evaluated on two well-known image benchmarks.
\subsection{Approximation algorithm}
As show in Section ~\ref{MoM}, MoM/MoU-based estimation of the Wasserstein distance offers a robust alternative to the classical empirical estimator of $\mathcal{W}$. Indeed, the empirical estimator of $\mathcal{W}$ would not converge towards the target in the $\mathcal{O} \cup \mathcal{I}$ framework. The proposed estimators are consistent and have convergence rates of order $O(n^{-1/(d+2)})$ with the $\mathcal{O} \cup \mathcal{I}$ framework.These convergence rates are similar, when $d$ is not too small, to those of the empirical estimator of $\mathcal{W}$ in a non-contaminated setting. Nevertheless, the question of computing these estimators raises two major difficulties: (i) the optimization over the unit ball of Lipschitz functions is intractable, which is a difficulty common to the approximation of the standard Wasserstein distance, and (ii) the non-differentiability of the median-based loss. The first issue is well known of the practioners of the Wasserstein distance who usually prefer to rely on its primal definition with an entropy-based regularization \cite{cuturi13}. However, learning algorithms devoted to Wasserstein GANs overcome this by weight clipping \citep{arjovsky2017} or gradient penalization \citep{gulrajani2017improved} to impose to the GAN a Lipchitz constraint. Similarly we propose here to limit $\Phi$ to be a neural network with similar constraints on weights to ensure its $M$-Lipschitzianity. This enables to approximate the Wasserstein distance up to a (unknown) multiplicative coefficient $M$
To overpass (ii), one can adopt MoM/MoU gradient descent. Exploited in the context of robust classification \citep{lecue2018robust}, using MoM/MoU gradient descent has been proved to be equivalent to minimize the expectation over the sampling strategy of blocks of $\mathcal{W}_{\text{MoM}},\mathcal{W}_{\text{MoU-diag}}$ and $\mathcal{W}_{\text{MoU}}$.
Combining these techniques, we design novel algorithms to compute approximations of the proposed estimators: $\widetilde{\mathcal{W}}_{\text{MoM}}$ (see Algorithm \ref{algo::algo_WMOM}), $\widetilde{\mathcal{W}}_{\text{MoU-diag}}$ and $\widetilde{\mathcal{W}}_{\text{MoU}}$ (see the Supplementary Material).
\begin{algorithm}[!h]
\caption{Approximation of $\mathcal{W}_{\mathrm{MoM}}(\mathbf{X},\mathbf{Y})$. }
\textit{Initialization:} $\eta$, the learning rate. $c$, the clipping parameter. $w_0$, the initial weights. $K_{\mathbf{X}}, K_{\mathbf{Y}}$ the number of blocks for $\mathbf{X}$ and $\mathbf{Y}$.
\begin{algorithmic}[1]
\For{$t=0,\ldots,n_{\text{iter}}$}
\State Sample $K_{\mathbf{X}}$ disjoint blocks $\mathcal{B}_1^{\mathbf{X}}, \ldots,\mathcal{B}_{K_{\mathbf{X}}}^{\mathbf{X}}$ and $K_{\mathbf{Y}}$ disjoint blocks $\mathcal{B}_1^{\mathbf{Y}}, \ldots,\mathcal{B}_{K_{\mathbf{Y}}}^{\mathbf{Y}}$ from a sampling scheme
\State Find both median blocks $\mathcal{B}_{med}^{\mathbf{X}}$ and $\mathcal{B}_{med}^{\mathbf{Y}}$
\State \vspace*{-0.2cm} \small{\begin{align*} G_{w} \leftarrow & \bigl\lfloor K_{\mathbf{X}} / n \bigr\rfloor\hspace*{-0.25cm} \underset{i \in \mathcal{B}_{med}^{\mathbf{X}}}{\sum}\hspace*{-0.2cm} \nabla _{w} \phi_w(X_i)\hspace*{-0.1cm} -\hspace*{-0.1cm} \bigl\lfloorK_{\mathbf{Y}} / m \bigr\rfloor \hspace*{-0.25cm} \underset{j \in \mathcal{B}_{med}^{\mathbf{Y}}}{\sum} \hspace*{-0.2cm} \nabla _{w} \phi_w(Y_j))
\end{align*} }
\State ~7.1~$w \leftarrow w + \eta \times \text{RMSProp}(w, G_w)$
\State ~7.2~ $w \leftarrow \text{clip}(w, -c,c)$
\EndFor \\
\textbf{Output}: $w,\; \widetilde{\mathcal{W}}_{\text{MoM}}, \; \phi_w$.
\end{algorithmic}
\label{algo::algo_WMOM}
\end{algorithm}
\subsection{Empirical study}
We denote $I_2$ the identity matrix of dimension $2$ and $\mathbf{v}$, the vector $(v,v)^\top$ with $v \in \mathbb{R}$.
\paragraph{Toy datasets.}
Two simulated datasets in 2D space with different kinds of anomalies are used in the experiments. The random vectors $X_1$ and $X_2$ are chosen to be distributed according a mixture of a standard Gaussian distribution and an "anomaly" distribution, respectively $\mathcal{A}_1$ and $\mathcal{A}_2$ defined as follows. $\mathcal{A}_1$ is the uniform distribution $\mathcal{U}[\mathbf{-50}, \mathbf{50}]$ that mimics \textit{isolated outliers} while $\mathcal{A}_2$ is the standard Cauchy distribution shifted by 25, defined to mimic \textit{aggregate outliers} (see \textit{e.g.} \cite{Chandola}). The random vector $Y $ is Gaussian with $Y\sim \mathcal{N}(\mathbf{5},I_2)$,
Datasets $\mathcal{D}_1=(\mathbf{X}_1,\mathbf{Y})$ and $\mathcal{D}_2=(\mathbf{X}_2,\mathbf{Y})$ contain 500 independent and identical copies of $(X_1,Y)$, $(X_2,Y)$ respectively, with the same proportion of outliers $\tau_X$.
\paragraph{Evaluation metrics.}
The Lipchitz constant $M$ being unknown and highly depending of the clipping parameter choice, it wouldn't be appropriate to compare the true 1-Wasserstein value, equal to $\sqrt{50}$, with $\widetilde{\mathcal{W}}_{\text{MoM}}, \widetilde{\mathcal{W}}_{\text{MoU-diag}}$ and $\widetilde{\mathcal{W}}_{\text{MoU}}$. Therefore, we propose to compare $\widetilde{\mathcal{W}}_{\text{MoM}}$, $\widetilde{\mathcal{W}}_{\text{MoU-diag}}$ and $\widetilde{\mathcal{W}}_{\text{MoU}}$ to $\widetilde{\mathcal{W}}$, the 1-Wasserstein distance approximated by Algorithm \ref{algo::algo_WMOM}, when MoM is not used, \textit{e.g. } $K_{\mathbf{X}}=K_{\mathbf{Y}}=1$, by measuring the absolute error between them.
\paragraph{Influence of $K_{\mathbf{X}},K_{\mathbf{Y}}$.}
The numbers of blocks, $K_{\mathbf{X}}$ and $K_{\mathbf{Y}}$, are crucial parameters for computation. They define the trade-off between the robustness of the estimator and computational burden. However the theory does not give enough insights about their value: the necessary assumption for the consistency is only that they should be greater than $2\tau_X n$ (see Section \ref{TG}). An empirical study of the influence of their values on the behavior of the approximations of $\mathcal{W}_{\text{MoM}}, \mathcal{W}_{\text{MoU-diag}}$ and $\mathcal{W}_{\text{MoU}}$ is therefore much useful. For sake of simplicity, we set $K_{\mathbf{X}}=K_{\mathbf{Y}}$ in the subsequent experiments.
In a first experiment, we explore the ability of \cref{algo::algo_WMOM} and variants described in the supplements to override outliers according to the values of $K_{\mathbf{X}}$ and with different rates of outliers $\tau_{\mathbf{X}}$. The approximations $\widetilde{\mathcal{W}}_{\text{MoM}}$,$\widetilde{\mathcal{W}}_{\text{MoU-diag}}$ and $\widetilde{\mathcal{W}}_{\text{MoU}}$ are computed using a simple multi-layer perceptrons with one hidden layer and MoM gradient descent over several $\tau_{\mathbf{X}}$ and $K_{\mathbf{X}}$ on both datasets. The experiment is repeated 20 times with various seeds. Mean results are displayed. Figure ~\ref{fig:error} represents absolute deviations between the 1-Wasserstein distance approximated with a MLP when $\tau_{\mathbf{X}}=0$ and $\widetilde{\mathcal{W}}_{\text{MoU-diag}}$ with various anomalies settings and different values of $K_X$. The reader is invited to refer to Section B of the supplements to see similar results for $\widetilde{\mathcal{W}}_{\text{MoU}}$ and $\widetilde{\mathcal{W}}_{\text{MoM}}$). Shaded areas, in Figure ~\ref{fig:error} represent 25\%-75\% quantiles over the 20 repetitions. On both datasets, we observe that the approximation algorithm succeeds to provide an estimation of $\mathcal{W}_{\text{MoU-diag}}$, able to override outliers with different $\tau_{\mathbf{X}}$ while $K_{\mathbf{X}}$ is high enough. From Section \ref{TG}, we know that $K_{\mathbf{X}}$ needs to be higher than $2 \tau_{\mathbf{X}} n$ to have theoretical guarantees. Experiments show that in practice, this condition is not necessary in every situations. For example, when $\tau_{\mathbf{X}}=0.1$ (\textit{i.e.} 50 anomalies) in Figure ~\ref{fig:error} (left), only 70 blocks are needed to override outliers. The reason is that hypothesis makes things work in the worst case, \textit{i.e.}, when each outlier is isolated in one block which lead to have $\tau_{\mathbf{X}} n$ contaminated blocks. This is rarely the case in practice, several blocks can be contaminated by many outliers and this is why fewer blocks are needed.
\begin{figure}[!h]
\includegraphics[height=.13\textheight, trim=1cm .0cm 0cm 0cm,clip=true]{MoU_approx.pdf}
\caption{$\widetilde{\mathcal{W}}_{\text{MoU-diag}}$ over $K_{\mathbf{X}}$ for different anomalies proportion $\tau_{\mathbf{X}}$ on $\mathcal{D}_1$ (left) and $\mathcal{D}_2$ (right).}
\label{fig:error}
\end{figure}
In a second experiment illustrated by Figure ~\ref{fig:CV_K}, we study the convergence of the approximation algorithm with and without anomalies for different values of $K_{\mathbf{X}}$ on $\mathcal{D}_1$. To get a fair comparison between the different settings of the algorithm, we compare the predicted values across the "learning" epoch. Here during one epoch, the algorithm has made a gradient pass over the whole dataset, which means that one epoch corresponds one iteration of the approximation algorithm if $K_{\mathbf{X}}=1$ (no MoM estimation), and to $K_{\mathbf{X}}$ iterations, in the other cases. In both cases (with or without anomalies), the higher $K_{\mathbf{X}}$ is, the faster the approximation algorithm converges. Without surprise, the MoM approach benefits from the same properties than a mini-batch approach. When there is no anomalies, the distance values reached after convergence are close to the "true" value (obtained with the plain estimator when $K_{\mathbf{X}}=1$), especially when $K_{\mathbf{X}}$ is lower. This means that the MoM-based algorithm can be used routinely instead of the plain estimator. With 5\% of anomalies, one can see that distance values reached after convergence get closer to the target as $K_{\mathbf{X}}$ grows.
\begin{figure}[!h]
\includegraphics[height=.13\textheight, trim=1cm .0cm 0cm 0cm,clip=true]{CV_MoU_double.pdf}
\caption{Convergence of $\widetilde{\mathcal{W}}_{\text{MoU-diag}}$ without anomalies (left) and with 5\% anomalies (right) for different $K_{\mathbf{X}}$.}
\label{fig:CV_K}
\end{figure}
\subsection{Application to robust Wasserstein GANs}\label{MoMalgo}
In this part, we introduce a robust modification of WGANs, named MoMWGAN, using one of the three proposed estimators in Section \ref{MoM}.
\begin{figure*}[!h]
\begin{center}
\setlength{\tabcolsep}{2em}
{\renewcommand{\arraystretch}{2}
\begin{tabular}{cccc}
\multicolumn{2}{c}{WGAN}& \multicolumn{2}{c}{MoMWGAN} \\
\includegraphics[trim=2cm 0 .5cm 0, scale=0.35]{Colombo1_300k.png}&
\includegraphics[trim=3.2cm 0 .5cm 0, scale=0.35]{Staerman1_200k.png}
&
\includegraphics[trim=3.2cm 0 .5cm 0,scale=0.35]{Colombo3.png}&
\includegraphics[trim=3.2cm 0 .5cm 0,scale=0.35]{Staerman3.png}
\\
\end{tabular}}
\end{center}
\caption{Generated samples from trained WGAN and MoMWGAN on CIFAR10 and Fashion MNIST datasets.}\label{images}
\end{figure*}
The behaviour of likelihood-free generative modeling such as Generative Adversarial Networks in the presence of outliers, \textit{i.e.}, with heavy-tails distributions or contaminated data, has been poorly investigated up to very recently. At our knowledge, the unique reference is \citep{gao2018robust}.
In particular, \citet{gao2018robust} have studied theoretically and empirically the robustness of f-GAN in the special case of mean estimation for elliptical distributions. In contrast, we illustrate here the theoretical results of \cref{MoM} by applying a MoM approach to robustify WassersteinGAN and show on two real-world image benchmarks how this new variant of GAN behaves when learned with contaminated data.
\noindent \textbf{Reminder on GAN:}
Let us briefly recall the GAN principle. A GAN learns a function $g_{\theta}:\mathcal{Z} \rightarrow \mathcal{X}$ such that samples generate by $g_{\theta}(z) \sim P_{\theta}$, taking as input a sample $z$ (from some reference measure $\xi$, often Gaussian) in a latent space $ \mathcal{Z}$, are close to those of the true distribution $P_r$ of data.
Wasserstein GANs \citep{arjovsky2017,gulrajani2017improved} use the 1-Wasserstein Distance under its Kantorovich-Rubinstein dual formula as the loss function. Instead of maximizing over the unit ball of Lipschitz functions, one uses a parametric family of M-Lipschitz functions under the form of neural net with clipped weights $w$ \citep{arjovsky2017}. Following up the theoretical analysis of Section \ref{MoM}, we introduce a MoM-based WGAN (MoMWGAN) model, combining the $\mathcal{W}_{\text{MoM}}$ estimator studied in \ref{MoM} and WGAN's framework.
Following the weight clipping approach, MoMWGAN boils down to the problem:
\begin{equation*}\label{eq:MoMWGAN-loss}
\underset{ \theta }{\min } \; \;\underset{w}{\max } \; \; \Bigl\{ \text{MoM}_{\mathbf{X}} [f_w] - \frac{1}{m} \sum_{j=1}^{m} f_w(g_{\theta}(Z_j)), ~ k\leq K_{\mathbf{X}}\Bigr\}
\end{equation*}
Note that the MoM procedure is chosen to be only applied on the observed contaminated sample. It is not clear in which way the sample drawn from the currently learned density is polluted and thus defining the number of blocks would be an issue.
Optimization in WGAN is usually performed by taking mini-batches to reduce the computational load. In the same spirit, we apply MoM inside contaminated mini-batches as described in Algorithm \ref{MWGAN}. To get the outliers-robust property observed in the numerical experiments, we pay the price of finding the median block at each step by evaluating the loss which significantly increases the computational complexity.
\begin{algorithm}[H]
\caption{MoMWGAN}
\textit{Initialization:} $\eta$, the learning rate. $c$, the clipping parameter. $b$, the batch size. $n_c$, the number of critic iterations per generator iteration, $K_{\mathbf{X}}$ the number of blocks. $w_0,\theta_0$ the initial critic/generator's parameters.
\begin{algorithmic}[1]
\While{$\theta$ has not converged}
\For{$t=0,\ldots,n_c$}
\State Sample $\{X_i \}_{i=1}^b \sim P_r$ to get $\mathbf{X}_t$ and sample $\{z_i \}_{i=1}^b \sim \xi$ to get $\mathbf{Z}_t$
\vspace*{0.1cm}
\State Updating $w$ with step 2-6 of Algorithm \ref{algo::algo_WMOM} with $\mathbf{X}=\mathbf{X}_t$ and $\mathbf{Y}=g_{\theta}(\mathbf{Z}_t)$
\EndFor
\vspace*{0.1cm}
\State Sample $\{ Z_j \}_{j=1}^b \sim \xi$
\vspace*{0.1cm}
\State ~$g_{\theta} \leftarrow - \nabla_{\theta} \frac{1}{b} \sum_{j=1}^{b} f_w(g_{\theta}(Z_j))$
\State ~$\theta \leftarrow \theta - \eta \times \text{RMSProp}(\theta, g_{\theta})$
\vspace*{0.1cm}
\EndWhile
\end{algorithmic}
\label{MWGAN}
\end{algorithm}
\paragraph{Numerical experiments}
To test the robustness of MoMWGAN we contaminated two well-known image datasets, CIFAR10 and Fashion MNIST, with two anomalies settings. \textit{Noise} based-anomalies are added to CIFAR10, \textit{i.e.}, images with random intensity pixels drawn from a uniform law. For Fashion MNIST, the five first classes are considered as "informative data" while the sixth (Sandal) contains the anomalies. In both settings,
WGAN and MoMWGAN are trained on the training samples contaminated in a uniform fashion with a proportion of 1.5\% of outliers in both datasets. Both models use standard parameters of WGAN. $K_{\mathbf{X}}=4$ blocks have been used by MoMWGAN in both experiments. To assess performance of the resulting GANs, we generated 50000 generated images using each model (WGAN and MoMGAN) and measured the Fr\'echet Inception Distance (FID) \citep{Heusel} between the generated examples in both cases and the (real) test sample.
Table 1 shows that MoMWGAN improves upon WGAN in terms of outliers-robustness. Furthermore, some generated images are represented in Figure \ref{images}. One can see that outliers do not affect MoMWGAN generated samples while WGAN reproduce noise on contaminated CIFAR10 dataset. For Fashion MNIST, one may see that fewer images are degraded with MoMWGAN generator.
\setlength{\tabcolsep}{0.5em}
{\renewcommand{\arraystretch}{1}
\begin{tabular}{ccc}
&WGAN& MoMWGAN\\
\hline
Polluted CIFAR10 & 57 & 55.9 \\
Polluted Fashion MNIST & 13.8 & 13.2 \\ \hline
\end{tabular}}
\captionof{table}{FID on polluted datasets.}
\section{Conclusion and perspectives} \label{conclusion}
In this paper, we have introduced three robust estimators of the Wasserstein distance based on MoM methodology.
We have shown asymptotic and non-asymptotic results in the context of polluted data, \textit{i.e.} the $\mathcal{O}\cup \mathcal{I}$ framework. Surpassing computational issues, we have designed an algorithm to compute, in a efficient way, these estimators. Numerical experiments have highlighted the behavior of these estimators over their unique tuning parameter.
Finally, we proposed to robustify WGANs using one of the introduced estimators and have shown its benefits on convincing numerical results.
The theoretically well-founded MoM approaches to robustify the Wasserstein distance open the door to numerous applications beyond WGAN, including variational generative modeling. The promising MoMGAN deserves more attention and future work will concern the analysis of the estimator it provides.
\section*{ Acknowlegments}
The authors thank Pierre Colombo for his helpful remarks. This work has been funded by BPI France in the context of the PSPC Project Expresso (2017-2021).
\bibliographystyle{unsrtnat}
| {'timestamp': '2022-02-21T02:22:07', 'yymm': '2006', 'arxiv_id': '2006.10325', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10325'} | arxiv |
\section{Introduction}
Congressional redistricting, which refers to the practice of redrawing
congressional district lines following the constitutionally mandated
decennial Census, is of major political consequence in the United
States. Redistricting reshapes geographic boundaries and those changes
can have substantial impacts on representation and governance in the
American political system. As a fundamentally political process,
redistricting has also been manipulated to fulfill partisan ends, and
recent debates have raised possible reforms to lessen the role of
politicians and the influence of political motives in determining the
boundaries of these political communities.
Starting in the 1960s, scholars began proposing simulation-based
approaches to make the redistricting process more transparent,
objective, and unbiased \citep[early proposals
include][]{vick:61,weav:hess:63,nage:65,hess:etal:65}. While this
research agenda lay dormant for some time, recent advances in
computing capability and methodologies, along with the increasing
availability of granular data about voters and elections, has led to a
resurgence in proposals, implementations, and applications of
simulation methods to applied redistricting problems
\citep[e.g.][]{ciri:darl:orou:00,mcca:pool:rose:09,altm:mcdo:11,chen:rodd:13,fifi:etal:14, fifi:etal:20,matt:vaug:14,liu:tamc:wang:16,hers:ravi:matt:17,chik:frie:pegd:17,magl:mose:18,cart:etal:19,defo:duchi:solo:19}.
Furthermore, simulation methods for redistricting play an increasingly
important role in court cases challenging redistricting plans. In
2019, simulation evidence was introduced and accepted in redistricting
cases in North Carolina, Ohio, and Michigan.\footnote{Declaration of Dr. Jonathan C. Mattingly, Common Cause v. Lewis (2019); Testimony of Dr. Jowei Chen, Common Cause v. Lewis (2019); Testimony of Dr. Pegden, Common Cause v. Lewis (2019); Expert Report of Jonathan Mattingly on the North Carolina State Legislature, Rucho v. Common Cause (2019);
Expert Report of Jowei Chen, Rucho v. Common Cause (2019); Amicus
Brief of Mathematicians, Law Professors, and Students in Support of
Appellees and Affirmance, Rucho v. Common Cause (2019); Brief of
Amici Curaiae Professors Wesley Pegden, Jonathan Rodden, and Samuel
S.-H. Wang in Support of Appellees, Rucho v Common Cause (2019);
Intervenor’s Memo, Ohio A. Philip Randolph Inst. et al. v. Larry
Householder (2019); Expert Report of Jowei Chen, League of Women
Voters of Michigan v. Benson (2019).} In the few years prior,
simulation methods were presented to courts in North Carolina, and
Missouri.\footnote{Expert Report of Jowei Chen, Raleigh Wake Citizens
Assoc v. Wake County Board of Elections (2016); Expert Report of
Jowei Chen, City of Greensboro v. Guilford County Board of Elections
(2015); Supplemental Report of Jonathan Rodden and Jowei Chen:
Assessment of Plaintiffs Redistricting Proposals, Missouri State
Conference of the NAACP v. Ferguson-Florissant School District
(2017).} Given these recent court cases challenging redistricting in
state and federal courts, simulation methods are expected to become an
even more influential source of evidence for legal challenges to
redistricting plans across many states after the upcoming decennial
Census in 2020.
These simulation methods are designed to yield a representative sample
of redistricting plans that satisfy statutory guidelines and
requirements such as contiguity, population parity, and
compactness.\footnote{The outlier detection method proposed by
\citet{chik:frie:pegd:17} is a statistical test and its goal is not
uniform sampling. However, the proposed enumeration method can
still be useful for assessing its empirical
performance.\label{fn:chika}} Then, a proposed redistricting plan
can be considered gerrymandered if it constitutes an outlier relative
to this sample according to a partisan fairness measure
\citep[see][for a discussion of various measures]{katz:king:rose:19}.
Simulation methods are particularly useful because enumeration of all
possible redistricting plans in a state is often computationally
infeasible. For example, even partitioning cells of an $8 \times 8$
checkerboard into two connected components generates over
$1.2 \times 10^{11}$ unique partitions (see
\url{https://oeis.org/A068416}). Unfortunately, most redistricting
problems are of much greater scale.\footnote{While statutory
guidelines and requirements such as district contiguity, population
parity, and compactness reduce the number of partitions
dramatically, the resulting problem currently remains out-of-reach
of full enumeration methods.} Therefore, to compare an implemented
redistricting plan against a set of other candidate plans, researchers
and policy makers must resort to simulation methods.
Despite the widespread use of redistricting simulation methods in
court cases, insufficient efforts have been made to examine whether or
not they actually yield a representative sample of all possible
redistricting plans in practice.\footnote{For an exception, see e.g.,
\citet{cart:etal:19}, Jonathan C. Mattingly. ``Rebuttal of
Defendant's Expert Reports for {\it Common Cause v. Lewis}.''
Andrew Chin, Gregory Herschlag, and Jonathan C. Mattingly. ``The
Signature of Gerrymandering in {\it Rucho v. Common Cause},
pp. 1261--1262.} Instead, some assume that the existing simulation
methods work as intended. For example, in his amicus brief to the
Supreme Court for {\it Rucho et al. v. Common Cause}, Eric Lander
declares,\footnote{Brief for Amicus Curiae Eric S. Lander In Support
of Appellees, p. 4, {\it Rucho et al. v. Common Cause},
No. 18-422. March 7, 2019, page 4.}
\begin{quote}
With modern computer technology, it is now straightforward to
generate a large collection of redistricting plans that are
representative of all possible plans that meet the State’s declared
goals (e.g., compactness and contiguity)
\end{quote}
And yet, if there exists no scientific evidence that these simulation
methods can actually yield a representative sample of valid
redistricting plans, we cannot rule out the possibility that the
comparison of a particular plan against sampled plans yields
misleading conclusions about gerrymandering.
We argue that the empirical validation of simulation methods is
essential for the credibility of academic scholarship and expert
testimony in court. We apply the recently developed computational
method of \citet{Kawahara2017}, \texttt{enumpart}, that efficiently enumerates
all possible redistricting plans and obtains an independent uniform
sample from this population (Section~\ref{sec:methods}). The
algorithm uses a compact data structure, called the zero-suppressed
binary decision diagram (ZDD) \citep{Minato1993}. In the
aforementioned 8 $\times$ 8 checkerboard problem, explicitly storing
every partition would require more than 1 terabyte of storage. In
contrast, the ZDD needs only 1.5 megabytes.
To facilitate empirical validation studies by other researchers, we
will make the code that implements the algorithm publicly available
and incorporate it as part of an open-source \textsf{R}\ software package for
redistricting, \textsf{redist}\ \citep{fifi:tarr:imai:15}.
We begin by showing that the \texttt{enumpart}{} algorithm scales to a state
with a couple of hundred geographical units, yielding realistic
validation data sets (Section~\ref{sec:scalability}). We then test
the empirical performance of existing simulation methods in two ways
(Section~\ref{sec:validation}). First, we randomly sample many
submaps of various sizes from actual state shapefiles so that we
average over idiosyncratic features of each map about geography and
distribution of voters. For each sampled small map, we conduct a
statistical test of the distributional equality between sampled and
enumerated maps under various population parity constraints. If the
simulation methods yield a representative sample of valid
redistricting plans, then the distribution of the resulting $p$-values
should be uniform. Second, we exploit the fact that even for a medium
size redistricting problem, the \texttt{enumpart}{} algorithm can
independently and uniformly sample from the population of all valid
redistricting plans. We then compare the resulting representative
sample with the sample obtained using existing simulation methods.
This second approach is applied to the actual redistricting problem in
Iowa with 99 counties and a 250-precinct subset map from Florida, both
of which are too computationally intensive for enumeration.
The overall conclusion of our empirical validation studies is that
Markov chain Monte Carlo (MCMC) methods \citep[e.g.,][]{fifi:etal:14,
fifi:etal:20, matt:vaug:14,cart:etal:19} substantially outperform
so-called random-seed-and-grow (RSG) algorithms
\citep[e.g.,][]{ciri:darl:orou:00,chen:rodd:13}. These are two types
of simulation methods that are most widely used in practice. Although
the currently available MCMC methods are far from perfect and have
much room for improvement, it is clear that the RSG algorithms are
unreliable. Of course, showing that MCMC methods work reasonably well
on these particular validation data sets does not necessarily imply
that they will also perform well on other data sets especially larger
scale redistricting problems. Rather, failing these validation tests
on small and medium-scale redistricting problems provides evidence
that RSG methods are most likely to perform poorly when applied to
other larger states.
To the best of our knowledge, the only publicly available validation
data set for redistricting is the 25 precinct map obtained from
Florida, for which \citet{fifi:etal:14, fifi:etal:20} enumerated all
possible redistricting maps for two or three contiguous districts.
Other researchers have used this validation data or enumeration method
to evaluate their own algorithms
\citep[e.g.,][]{magl:mose:18,cart:etal:19}. However, this data set is
small and represents only a particular set of precincts representing a
specific political geography, and may not be representative of other
redistricting problems. For example, as noted by \citet{magl:mose:18},
this data set is not particularly balanced --- only eight partitions
fall within standard levels of population parity ($\pm 1.5\%$), and
most fall above $10\%$. Our new validation data sets are much larger
and hence provide unique opportunities to conduct a more realistic
empirical evaluation of simulation methods.
\section{The Methodology}
\label{sec:methods}
In this section, we describe the enumeration and sampling methods used
in our empirical validation studies. Our methods are based on the
\texttt{enumpart}{} algorithm originally developed by \cite{Kawahara2017} who
showed how to enumerate all possible redistricting plans and store
them using a compact data structure, called a zero-suppressed binary
decision diagram (ZDD) \citep{Minato1993}. We also show how the
\texttt{enumpart}{} algorithm can be used to independently and uniformly
sample from the population of contiguous redistricting plans.
\subsection{The Setup}
Following the literature \citep[see
e.g.,][]{altm:97,mehr:john:nemh:98,fifi:etal:14}, we formulate
redistricting as a graph-partitioning problem. Given a map of a
state, each precinct (or any other geographical units used for
redistricting) is represented by a vertex, whereas the existence of an
edge between two vertices implies that they are geographically
contiguous to one another. Formally, let $G = (V, E)$ represent a
graph with the vertex set $V=\{v_1,\ldots,v_n\}$ and the edge set
$E=\{e_1,\ldots,e_m\}$. We consider redistricting of a state into a
total of $p$ districts where all precincts of each district are
connected. This is equivalent to partitioning a graph $G$ into $p$
connected components $\{V_1, V_2,\ldots, V_p\}$ such that every vertex
in $V$ belongs to exactly one connected component, i.e.,
$V_1 \cup \cdots \cup V_p = V$, $V_k \cap V_{k^\prime} = \emptyset$
for any $k \ne k^\prime$ and all the vertices in $V_k$ are connected.
We use the fact that a $p$-graph partition can alternatively be
represented as an edge set $S$. That is, by removing certain edges
from $E$, we can partition $G$ into $p$ connected components.
Formally, for each connected component $V_k$, we define an induced
subgraph $(V_k, S(V_k))$ as a graph whose edge set consists of all
edges whose two endpoints (i.e., the two vertices directly connected
by the edge) belong to $V_k$. Then, the $p$-graph partition can be
defined as the union of these induced subgraphs, i.e.,
$\mathcal{P} = \bigcup_{k=1}^p S(V_k)$ where
$S(V_k) \cap S(V_{k^\prime}) = \emptyset$ for any $k \ne k^\prime$.
Our initial task is to enumerate \emph{all} possible $p$-graph
partitions of $G$.
\begin{figure}[t]
\begin{subfigure}[b]{0.33\textwidth}\centering
\begin{tikzpicture}[scale=.65]
\LARGE
\draw (0,0) --(0,4) -- (8,4) -- (8,0) -- (0,0);
\draw (2,2) -- (4,2);
\draw (2,0) -- (2,4);
\draw (4,0) -- (4,4);
\draw (6,0) -- (6,4);
\draw (4,1.5) -- (6,1.5);
\draw (4,2.5) -- (6,2.5);
\draw (1,2) node {$v_1$};
\draw (3,3) node {$v_2$};
\draw (3,1) node {$v_3$};
\draw (5,3.25) node {$v_4$};
\draw (5,.75) node {$v_5$};
\draw (7,2) node {$v_6$};
\filldraw[draw=black, fill=gray](4,1.5) rectangle (6,2.5);
\end{tikzpicture}
\caption{Original map} \label{subfig:map}
\end{subfigure}
\begin{subfigure}[b]{0.33\textwidth}\centering
\begin{tikzpicture}
\large
\fill (0,1) circle (3pt) {};
\fill (1,0) circle (3pt) {};
\fill (1,2) circle (3pt) {};
\fill (2,0) circle (3pt) {};
\fill (2,2) circle (3pt) {};
\fill (3,1) circle (3pt) {};
\draw (0,1) node[left] {$v_1$} --
(1,2) node[above] {$v_2$} --
(2,2) node[above] {$v_4$} --
(3,1) node[right] {$v_6$} --
(2,0) node[below] {$v_5$} --
(1,0) node[below] {$v_3$} --
(0,1)
\draw (1,0) -- (1,2);
\draw (.5,1.5) node[above left] {$e_1$};
\draw (.5,.5) node[below left] {$e_2$};
\draw (1.1,1) node[left] {$e_3$};
\draw (1.5,2) node[below] {$e_4$};
\draw (1.5,0) node[above] {$e_5$};
\draw (2.5,1.5) node[above right] {$e_6$};
\draw (2.5,.5) node[below right] {$e_7$};
\end{tikzpicture}
\caption{Graph representation} \label{subfig:graph}
\end{subfigure}
\begin{subfigure}[b]{0.33\textwidth}\centering
\begin{tikzpicture}
\large
\fill (0,1) circle (3pt) {};
\fill (1,0) circle (3pt) {};
\fill (1,2) circle (3pt) {};
\fill (2,0) circle (3pt) {};
\fill (2,2) circle (3pt) {};
\fill (3,1) circle (3pt) {};
\draw (0,1) node[left] (v1) {$v_1$} -- (1,0) node[below] (v3) {$v_3$};
\draw (1,2) node[above] (v2) {$v_2$} --
(2,2) node[above] (v4) {$v_4$} --
(3,1) node[right] (v6) {$v_6$} --
(2,0) node[below] (v5) {$v_5$};
\draw (.5,.5) node[below left] {$e_2$};
\draw (1.5,2) node[below] {$e_4$};
\draw (2.5,1.5) node[above right] {$e_6$};
\draw (2.5,.5) node[below right] {$e_7$};
\end{tikzpicture}
\caption{Induced subgraph} \label{subfig:subgraph}
\end{subfigure}
\spacingset{1}
\vspace{-.25in}
\caption{A Running Redistricting Example. We consider dividing a
state with six geographical units into two districts. The
original map is shown in the left panel where the shaded area is
uninhabited. The middle panel shows its graph representation,
whereas the right panel shows an example of redistricting map
represented by an induced subgraph, which consists of a subset of
edges.} \label{fig:example}
\end{figure}
Figure~\ref{subfig:map} presents the running example used throughout
this section to illustrate our methodology. In this hypothetical
state, we have a total of 6 precincts, represented as vertices
$\{v_1,v_2,\ldots,v_6\}$, which we hope to divide into 2 districts,
$\{V_1,V_2\}$. A grey area is uninhabited (e.g., lake). This map can
be represented as a graph of Figure~\ref{subfig:graph} where two
contiguous vertices share an edge. Consider a redistricting map with
$V_1 = \{v_1, v_3\}$ and $V_2 = \{v_2, v_4, v_5, v_6\}$. As shown in
Figure~\ref{subfig:subgraph}, this redistricting map can be
represented by an induced subgraph after removing three edges, i.e.,
$\{e_1, e_3, e_5\}$. Thus, we can represent each district as an
induced subgraph, which is a set of edges, i.e., $S(V_1) = \{e_2\}$ or
$S(V_2) = \{e_4, e_6, e_7\}$.
\subsection{Graph Partitions and Zero-suppressed Binary Decision Diagram (ZDD)}
\begin{figure}[t]\centering
\begin{tikzpicture}
\node at (7.5, 14) [circle,draw] (11) {$e_1$};
\node at (6, 12) [circle,draw] (21) {$e_2$};
\node at (9, 12) [circle,draw] (22) {$e_2$};
\node at (4.5, 10) [circle,draw] (31) {$e_3$};
\node at (7.5, 10) [circle,draw] (32) {$e_3$};
\node at (10.5, 10) [circle,draw] (33) {$e_3$};
\node at (3, 8) [circle,draw] (41) {$e_4$};
\node at (6, 8) [circle,draw] (42) {$e_4$};
\node at (9, 8) [circle,draw] (43) {$e_4$};
\node at (12, 8) [circle,draw] (44) {$e_4$};
\node at (0, 6) [circle,draw] (51) {$e_5$};
\node at (3, 6) [circle,draw] (52) {$e_5$};
\node at (6, 6) [circle,draw] (53) {$e_5$};
\node at (9, 6) [circle,draw] (54) {$e_5$};
\node at (12, 6) [circle,draw] (55) {$e_5$};
\node at (15, 6) [circle,draw] (56) {$e_5$};
\node at (0,4) [circle,draw] (61) {$e_6$};
\node at (3,4) [circle,draw] (62) {$e_6$};
\node at (6,4) [circle,draw] (63) {$e_6$};
\node at (9,4) [circle,draw] (64) {$e_6$};
\node at (12,4) [circle,draw] (65) {$e_6$};
\node at (15,4) [circle,draw] (66) {$e_6$};
\node at (0,2) [circle,draw](71) {$e_7$};
\node at (3,2) [circle,draw](72) {$e_7$};
\node at (6,2) [circle,draw](73) {$e_7$};
\node at (9,2) [circle,draw](74) {$e_7$};
\node at (12,2) [circle,draw](75) {$e_7$};
\node at (15,2) [circle,draw](76) {$e_7$};
\node at (6,0) [rectangle,draw] (81) {$0$};
\node at (9,0) [rectangle,draw] (82) {$1$};
\draw [thick, ->] (11) edge (22) (22) edge (33) (33) edge (44) (44) edge (56) (56) edge (66) (66) edge (76) (76) edge (81) (32) edge (81)
(55) edge (65) (65) edge (75) (31) edge (42) (42) edge (53) (53) edge (63) (63) edge (73) (73) edge (82) (41) edge (52) (52) edge (62) (62) edge (72) (72) edge (81) (51) edge (61) (61) edge (71) (71) edge (81) (54) edge (64) (75) edge (81);
\draw [very thick,dashed, ->]
(21) edge (31) (22) edge (32)
(31) edge (41) (33) edge (81)
(41) edge (51) (42) edge (52) (43) edge (54) (44) edge (55)
(51) edge (81) (52) edge (61) (53) edge (62) (54) edge (61) (56) edge (65)
(62) edge (71) (63) edge (72) (64) edge (71) (65) edge (74) (66) edge (75) (73) edge (81) (74) edge (81) (75) edge (82);
\draw [thick, blue, ->] (21) edge (32) (43) edge (55) (64) edge (74) (74) edge (82);
\draw [very thick,dashed, ->,blue](11) edge (21) (32) edge (43) (55) edge (64);
\node (76A) at (14.85,1.77) [] {};
\node (72A) at (2.9,1.7) [] {};
\node (71A) at (.1,1.8) [] {};
\node (61A) at (.01, 3.7) [] {};
\draw [very thick, dashed, ->] (76A) edge (81)
(71A) edge (81) (61A) edge (81) (72A) edge (81);
\end{tikzpicture}
\spacingset{1}
\caption{Zero-suppressed Binary Decision Diagram (ZDD) for the Running
Example of Figure~\ref{subfig:graph}. The blue path corresponds to
the redistricting map represented by the induced subgraph in
Figure~\ref{subfig:subgraph}. } \label{fig:zdd}
\end{figure}
A major challenge for enumerating redistricting maps is memory
management because the total number of possible maps increases
exponentially. We use the Zero-suppressed Binary Decision Diagram
(ZDD), which uses a compact data structure to efficiently represent a
family of sets \citep{Minato1993}. We first discuss how the ZDD can
represent a family of graph partitions before explaining how we
construct the ZDD from a given graph.
The ZDD that corresponds to the running example of
Figure~\ref{fig:example} is given in Figure~\ref{fig:zdd}. A ZDD is a
directed acyclic graph. As is clear from the figure, each edge of the
original graph corresponds to possibly multiple nodes of a ZDD. To
avoid confusing terminology, we use a ``node'' rather than a
``vertex'' to refer to a unit of ZDD, which represents an edge of the
original graph. Similarly, we call an edge of the ZDD an ``arc'' to
distinguish it from an edge of the original graph. There are three
special nodes in a ZDD. The {\it root node}, labeled as $e_1$ in our
example, has no incoming arc but, like other nodes, represents one of
the edges in the original graph. We will discuss later how we label
nodes. ZDD also has two types of {\it terminal nodes} without an
outgoing arc, called 0-terminal and 1-terminal nodes and represented
by $\boxed{0}$ and $\boxed{1}$, respectively. Unlike other nodes,
these terminal nodes do not correspond to any edge in the original
graph. Finally, each non-terminal node, including the root node, has
exactly two outgoing arcs, {\it 0-arc} (dashed arrow) and {\it 1-arc}
(solid arrow).
Given a ZDD, we can represent a graph partition as the set of edges that
belong to a directed path from the root node to 1-terminal node and
have an outgoing 1-arc. For example, the path highlighted by blue,
$e_1 \dashrightarrow e_2 \longrightarrow e_3 \dashrightarrow e_4
\longrightarrow e_5 \dashrightarrow e_6 \longrightarrow e_7
\longrightarrow \boxed{1}$, represents the edge set $\{e_2, e_4, e_6, e_7\}$,
which corresponds to the 2-graph partition shown in
Figure~\ref{subfig:subgraph}. Indeed, there is one to one
correspondence between a graph partition and a path of a ZDD.
\subsection{Construction of the ZDD}
How should we construct a ZDD for a $p$-graph partition from a given
graph? We use the frontier-based search algorithm proposed by
\cite{Kawahara2017}. The algorithm grows a tree starting with the
root node in a specific manner. We first discuss how to construct a
ZDD given $m$ labeled edges, $\{e_1,\ldots, e_m\}$, where $e_1$
represents the root node. We then explain how we merge nodes to reduce
the size of the resulting ZDD and how we label edges given a graph to
be partitioned so that the computation is efficient.
\subsubsection{The Preliminaries}
Starting with the root node $i=1$, we first create one outgoing 0-arc
and one outgoing 1-arc from the corresponding node $e_i$ to the next
node $e_{i+1}$. To ensure that each enumerated partitioning has
exactly $p$ connected components, we store the number of
\emph{determined connected components} as the {\tt dcc} variable for
each ZDD node. Consider a directed path
$e_1 \longrightarrow e_2 \dashrightarrow e_3 \dashrightarrow e_4
\dashrightarrow e_5$. In this example, $e_1$ is retained whereas
edges $\{e_2,e_3,e_4\}$ are not. We know that the two vertices,
$\{v_1, v_2\}$, together form one district, regardless of whether or
not $e_5$ is retained. Then, we say that a connected component is
determined and set {\tt dcc} to 1 for $e_5$. If {\tt dcc} exceeds
$p$, then we create an arc into the 0-terminal node rather than create
an arc into the next node since there is no longer a prospect of
constructing a valid partition. Similarly, when creating an arc out
of the final node, $e_m$, we point the arc into the 0-terminal node if
{\tt dcc} is less than $p$, which represents the total number of
partitions. Finally, if the number of remaining edges exceeds
$p-{\tt dcc}$, we stop growing the path by creating an outgoing arc
into the 0-terminal node.
How do we find out when another connected component is determined so
that ${\tt dcc}$ needs to be increased? To do this, we need two new
variables. First, for each vertex $v_i$, we store the \emph{connected
component number}, denoted by $\mathtt{comp}[v_i]$, indicating the
connected component to which $v_i$ belongs. Thus, two vertices, $v_i$ and
$v_{i^\prime}$, share an identical connected component number if and
only if they belong to the same connected component, i.e.,
$\mathtt{comp}[v_i]=\mathtt{comp}[v_{i^\prime}]$.
We initialize the connected component number as
${\tt comp}[v_i] \leftarrow i$ for $i=1,2,\ldots,n$ where $n$ is the
number of vertices in the original graph. Suppose that we process and
retain an edge incident to two vertices $v_i$ and $v_{i^\prime}$ for
$i \ne i^\prime$ by creating an outgoing 1-arc. Then, we set
${\tt comp}[v_j] \leftarrow \max\{{\tt comp}[v_i], {\tt
comp}[v_{i^\prime}]\}$ for any vertex $v_j$ whose current connected
component number is given by
${\tt comp}[v_j] = \min\{{\tt comp}[v_i], {\tt comp}[v_{i^\prime}]\}$.
This operation ensures that all vertices that are connected to $v_i$
or $v_{i^\prime}$ have the same connected component number (larger of
the two original numbers).
\subsubsection{The Frontier-based Search}
\label{subsubsec:frontier}
Next, we define the {\it frontier} of a graph, which changes as we
process each edge and grow a tree. Suppose that we have created a
directed path by processing the nodes from $e_1$ up to $e_{\ell}$
where $\ell = 2, 3, \ldots,m-1$. For each $\ell=1,2,\ldots,m-1$, the
$\ell$th frontier $F_\ell$ represents the set of vertices of the
original graph that are incident to both a processed edge (i.e., at
least one of $e_1, e_2, \ldots, e_{\ell}$) and an unprocessed edge
(i.e., at least one of $e_{\ell+1}, e_{\ell+2}, \ldots, e_m$). Note
that we define $F_0 = F_m = \emptyset$ and that the set of processed
edges includes the one currently being processed. Thus, for a given
graph, the frontier only depends on which edge is being processed but
does not hinge on how edges have been or will be processed. That is,
the same frontier results for each node regardless of paths.
The frontier can be used to check whether a connected component is
determined. Specifically, suppose there exists a vertex $v$ that
belongs to the previous frontier but is not part of the current one,
i.e., $v \in F_{\ell-1}$ and $v \not\in F_\ell$. Then, if there is no
other vertex in $F_\ell$ that has the same connected component number
as $v$ (that is, no vertex in $F_\ell$ is connected to $v$), there
will not be another vertex in subsequent frontiers, i.e.,
$F_{\ell+1},\ldots, F_m$, that are connected to $v$. Thus, under this
condition, the connected component ${\tt comp}[v]$ is determined, and
we increment $\mathtt{dcc}$ by one.
\begin{figure}[!t]
\vspace{-.5in}
\begin{subfigure}[b]{.33\textwidth}\centering
\begin{tikzpicture}\large
\fill (0,1) circle (3pt) {};
\fill (1,0) circle (3pt) {};
\fill (1,2) circle (3pt) {};
\fill (2,0) circle (3pt) {};
\fill (2,2) circle (3pt) {};
\fill (3,1) circle (3pt) {};
\draw (0,1) node[left] {$1$};
\draw (1,2) node[above left] {$2$};
\draw(1,0) node[below left] {$3$};
\draw (2,2) node[above right] {$4$};
\draw (2,0) node[below right] {$5$};
\draw(3,1) node[right] {$6$};
\draw [dashed] (0,1) edge (1,2);
\draw [dotted] (1,2) edge (2,2) (1,0) edge (0,1) (2,2) edge (3,1) (3,1) edge (2,0)
(1,0) edge (1,2) (1,0) edge (2,0);
\draw (.5,1.5) node[above left] {$e_1$};
\draw (.5,.5) node[below left] {$e_2$};
\draw (1.1,1) node[left] {$e_3$};
\draw (1.5,2) node[below] {$e_4$};
\draw (1.5,0) node[above] {$e_5$};
\draw (2.5,1.5) node[above right] {$e_6$};
\draw (2.5,.5) node[below right] {$e_7$};
\draw [rounded corners=6pt, rotate around={315:(0,1)}, blue](-.2,.8) rectangle (.2,2.6);
\draw (1,2.5) node[above, blue] {$F_1$};
\end{tikzpicture}
\caption{Process edge $e_1$; ${\tt dcc}=0$} \label{subfig:edge1}
\end{subfigure}%
\begin{subfigure}[b]{.33\textwidth}\centering
\begin{tikzpicture}[label distance=25mm]\large
\fill (0,1) circle (3pt) {};
\fill (1,0) circle (3pt) {};
\fill (1,2) circle (3pt) {};
\fill (2,0) circle (3pt) {};
\fill (2,2) circle (3pt) {};
\fill (3,1) circle (3pt) {};
\draw (0,1) node[left] {$3$};
\draw (1,2) node[above left] {$2$};
\draw(1,0) node[below left] {$3$};
\draw (2,2) node[above right] {$4$};
\draw (2,0) node[below right] {$5$};
\draw(3,1) node[right] {$6$};
\draw [dashed] (0,1) edge (1,2);
\draw [ultra thick] (0,1) edge (1,0);
\draw [dotted] (1,2) edge (2,2) (2,2) edge (3,1) (3,1) edge (2,0) (1,0) edge (1,2) (1,0) edge (2,0);
\draw [rounded corners=6pt, blue](.8,-.2) rectangle (1.2,2.2);
\draw (1,2.5) node[above, blue] {$F_2$};
\draw (.5,1.5) node[above left] {$e_1$};
\draw (.5,.5) node[below left] {$e_2$};
\draw (1.1,1) node[left] {$e_3$};
\draw (1.5,2) node[below] {$e_4$};
\draw (1.5,0) node[above] {$e_5$};
\draw (2.5,1.5) node[above right] {$e_6$};
\draw (2.5,.5) node[below right] {$e_7$};
\end{tikzpicture}
\caption{Process edge $e_2$; ${\tt dcc}=0$} \label{subfig:edge2}
\end{subfigure}%
\begin{subfigure}[b]{.33\textwidth}\centering
\begin{tikzpicture}\large
\fill (0,1) circle (3pt) {};
\fill (1,0) circle (3pt) {};
\fill (1,2) circle (3pt) {};
\fill (2,0) circle (3pt) {};
\fill (2,2) circle (3pt) {};
\fill (3,1) circle (3pt) {};
\draw (0,1) node[left] {$3$};
\draw (1,2) node[above left] {$2$};
\draw(1,0) node[below left] {$3$};
\draw (2,2) node[above right] {$4$};
\draw (2,0) node[below right] {$5$};
\draw(3,1) node[right] {$6$};
\draw [dashed] (0,1) edge (1,2) (1,0) edge (1,2);
\draw [ultra thick] (0,1) edge (1,0);
\draw [dotted] (1,2) edge (2,2) (2,2) edge (3,1) (3,1) edge (2,0) (1,0) edge (2,0);
\draw [rounded corners=6pt, blue](.8,-.2) rectangle (1.2,2.2);
\draw (1,2.5) node[above, blue] {$F_3$};
\draw (.5,1.5) node[above left] {$e_1$};
\draw (.5,.5) node[below left] {$e_2$};
\draw (1.1,1) node[left] {$e_3$};
\draw (1.5,2) node[below] {$e_4$};
\draw (1.5,0) node[above] {$e_5$};
\draw (2.5,1.5) node[above right] {$e_6$};
\draw (2.5,.5) node[below right] {$e_7$};
\end{tikzpicture}
\caption{Process edge $e_3$; ${\tt dcc}=0$} \label{subfig:edge3}
\end{subfigure}
\begin{subfigure}[b]{.33\textwidth}\centering
\begin{tikzpicture}\large
\fill (0,1) circle (3pt) {};
\fill (1,0) circle (3pt) {};
\fill (1,2) circle (3pt) {};
\fill (2,0) circle (3pt) {};
\fill (2,2) circle (3pt) {};
\fill (3,1) circle (3pt) {};
\draw (0,1) node[left] {$3$};
\draw (1,2) node[above left] {$4$};
\draw(1,0) node[below left] {$3$};
\draw (2,2) node[above right] {$4$};
\draw (2,0) node[below right] {$5$};
\draw(3,1) node[right] {$6$};
\draw [dashed] (0,1) edge (1,2) (1,0) edge (1,2);
\draw [ultra thick] (0,1) edge (1,0) (1,2) edge (2,2);
\draw [dotted] (2,2) edge (3,1) (3,1) edge (2,0) (1,0) edge (2,0);
\draw [rounded corners =6pt, blue,rotate around={333:(1,0)}](.8,-.2) rectangle (1.2,2.4);
\draw (2,2.5) node[above, blue] {$F_4$};
\draw (.5,1.5) node[above left] {$e_1$};
\draw (.5,.5) node[below left] {$e_2$};
\draw (1.1,1) node[left] {$e_3$};
\draw (1.5,2) node[below] {$e_4$};
\draw (1.5,0) node[above] {$e_5$};
\draw (2.5,1.5) node[above right] {$e_6$};
\draw (2.5,.5) node[below right] {$e_7$};
\end{tikzpicture}
\caption{Process edge $e_4$; ${\tt dcc}=0$} \label{subfig:edge4}
\end{subfigure}%
\begin{subfigure}[b]{.33\textwidth}\centering
\begin{tikzpicture}\large
\fill (0,1) circle (3pt) {};
\fill (1,0) circle (3pt) {};
\fill (1,2) circle (3pt) {};
\fill (2,0) circle (3pt) {};
\fill (2,2) circle (3pt) {};
\fill (3,1) circle (3pt) {};
\draw (0,1) node[left] {$3$};
\draw (1,2) node[above left] {$4$};
\draw(1,0) node[below left] {$3$};
\draw (2,2) node[above right] {$4$};
\draw (2,0) node[below right] {$5$};
\draw(3,1) node[right] {$6$};
\draw [dashed] (0,1) edge (1,2) (1,0) edge (1,2) (1,0) edge (2,0);
\draw [ultra thick] (0,1) edge (1,0) (1,2) edge (2,2);
\draw [dotted] (2,2) edge (3,1) (3,1) edge (2,0) ;
\draw [rounded corners =6pt, blue] (1.8,-.2) rectangle (2.2,2.2);
\draw (2,2.5) node[above, blue] {$F_5$};
\draw (.5,1.5) node[above left] {$e_1$};
\draw (.5,.5) node[below left] {$e_2$};
\draw (1.1,1) node[left] {$e_3$};
\draw (1.5,2) node[below] {$e_4$};
\draw (1.5,0) node[above] {$e_5$};
\draw (2.5,1.5) node[above right] {$e_6$};
\draw (2.5,.5) node[below right] {$e_7$};
\end{tikzpicture}
\caption{Process edge $e_5$; ${\tt dcc}=1$} \label{subfig:edge5}
\end{subfigure}%
\begin{subfigure}[b]{.33\textwidth}\centering
\begin{tikzpicture}\large
\fill (0,1) circle (3pt) {};
\fill (1,0) circle (3pt) {};
\fill (1,2) circle (3pt) {};
\fill (2,0) circle (3pt) {};
\fill (2,2) circle (3pt) {};
\fill (3,1) circle (3pt) {};
\draw (0,1) node[left] {$3$};
\draw (1,2) node[above left] {$6$};
\draw(1,0) node[below left] {$3$};
\draw (2,2) node[above right] {$6$};
\draw (2,0) node[below right] {$5$};
\draw(3,1) node[right] {$6$};
\draw [dashed] (0,1) edge (1,2) (1,0) edge (1,2) (1,0) edge (2,0);
\draw [ultra thick] (0,1) edge (1,0) (1,2) edge (2,2) (2,2) edge (3,1);
\draw [dotted] (3,1) edge (2,0) ;
\draw [rounded corners =6pt, rotate around={315:(2,0)}, blue](1.8,-.2) rectangle (2.2,1.59);
\draw (3.5,1.5) node[right,blue] {$F_6$};
\draw (.5,1.5) node[above left] {$e_1$};
\draw (.5,.5) node[below left] {$e_2$};
\draw (1.1,1) node[left] {$e_3$};
\draw (1.5,2) node[below] {$e_4$};
\draw (1.5,0) node[above] {$e_5$};
\draw (2.5,1.5) node[above right] {$e_6$};
\draw (2.5,.5) node[below right] {$e_7$};
\draw (2,2.5) node[above, white] {$F_4$};
\draw (-.5,1) node[left, white] {$F_4$};
\end{tikzpicture}
\caption{Process edge $e_6$; ${\tt dcc}=1$} \label{subfig:edge6}
\end{subfigure}
\spacingset{1}
\caption{Calculation of the Frontier, the Connected Component
Number, and the Determined Connected Components. This
illustrative example is based on the redistricting problem shown
in Figure~\ref{fig:example}. A positive integer placed next to
each vertex represents the connected component number, whereas the
vertices grouped by the solid blue line represent a frontier. A
connected component is determined when processing edge $e_5$.
} \label{fig:frontier}
\end{figure}
Figure~\ref{fig:frontier} gives an example of computing the connected
component number, constructing the frontier, and updating the
determined connected components, based on the redistricting problem
shown in Figure~\ref{fig:example}. In each graph, a positive integer
placed next to a vertex represents its connected component number,
whereas the vertices grouped by the solid line represent a frontier. For
example, when processing edge $e_5$ (see Figure~\ref{subfig:edge5}),
we have $F_4 = \{ v_3, v_4 \}$ and $F_5 = \{v_4, v_5 \}$. Since there
is no vertex in $F_5$ that shares the same connected component number
as $v_3$ (which is 1), we can determine the first connected component
and increment ${\tt dcc}$ by one.
Finally, when processing the last edge $e_m$ represented by node
$n^\ast$, if two vertices incident to the edge belong to the same
connected component number, then the 0-arc from node $n^\ast$ points
to the 0-terminal node whereas the destination of the 1-arc is the
1-terminal node unless {\tt dcc} $\neq p$. If they have different
connected component numbers, the 0-arc of node $n^\ast$ goes to the
1-terminal node whereas the destination of its 1-arc is the 1-terminal
node so long as {\tt dcc} $= p$ and the induced subgraph condition
described in the next paragraph is satisfied (otherwise, it is the
0-terminal node).
Throughout the process of building a ZDD, we must make sure that every
path actually corresponds to an induced subgraph, which is defined as
a subset of nodes and all arcs connecting pairs of such nodes. We
call this the induced subgraph condition. Consider a path,
$e_1 \longrightarrow e_2 \longrightarrow e_3$. Since three vertices,
$\{v_1, v_2, v_3\}$, are connected, we must retain edge $e_3$ because
its two incident vertices, $v_2$ and $v_3$, are connected. Thus, we
have
$e_1 \longrightarrow e_2 \longrightarrow e_3 \dashrightarrow
\boxed{0}$. Similarly, consider a path,
$e_1 \longrightarrow e_2 \dashrightarrow e_3$. We cannot retain $e_3$
because $e_2$, which is incident to $v_1$ and $v_3$, is not retained.
This yields
$e_1 \longrightarrow e_2 \dashrightarrow e_3 \longrightarrow
\boxed{0}$.
To impose the induced subgraph condition, we introduce the
\emph{forbidden pair set} for each node. Once we decide not to use an
edge that connects two distinct components, the two components must
not be connected any more. Otherwise, the new component generated by
connecting the two components has an unused edge, violating the
induced subgraph condition. Therefore, if we determine that an edge
$\{v, v'\}$ is not used, the addition of
$\{{\tt comp}[v], {\tt comp}[v']\}$ to the forbidden pair set reminds
us that the components ${\tt comp}[v]$ and ${\tt comp}[v']$ must not
be connected. That is, if we use an edge $\{u, u'\}$ and the
forbidden pair set contains $\{{\tt comp}[u], {\tt comp}[u']\}$, the
path will be sent to the 0-terminal. In the above example, if we pass
through $e_1 \longrightarrow e_2 \dashrightarrow e_3$, $\{2, 3\}$ is
added to the forbidden pair set, where $2$ is the component number of
$\{v_1, v_2\}$ and $3$ is that of $\{v_3\}$. Then, since retaining
$e_3$ violates the induced subgraph condition, we have
$e_1 \longrightarrow e_2 \dashrightarrow e_3 \longrightarrow
\boxed{0}$.
\subsubsection{Node Merge}
\label{subsubsec:nodemerge}
The above operation implies that when processing $e_\ell$, the only
required information is the connectivity of vertices in $F_{\ell-1}$.
We can reduce the size of the ZDD by exploiting this fact. First, we
can avoid repeating the same computation by merging multiple nodes if
the connected component numbers of all vertices in $F_{\ell-1}$ and
the number of determined connected components ${\tt dcc}$ are
identical. This is a key property of the ZDD, which allows us to
efficiently enumerate all possible redistricting plans by merging many
different paths. Second, we only need to examine the connectivity of
vertices within a frontier in order to decide whether or not any
connected component is determined. Thus, we adjust the connected
component number so that it equals the maximum vertex number in the
frontier. That is, if some vertices in the frontier share the same
connected component number, we change it to the maximum vertex index
among those vertices. For example, in Figure~\ref{subfig:edge2}, we
set ${\tt comp}[v_2]=2$ and ${\tt comp}[v_3]=3$. We need not worry
about how the renumbering of ${\tt comp}[v_3]$ affects the value of
${\tt comp}[v_1]$ because $v_1 \notin F_2$. This operation results in
merging of additional nodes, reducing the overall size of the ZDD.
\begin{figure}[t]\centering
\vspace{-.25in}
\begin{subfigure}[b]{.5\textwidth}\centering
\begin{tikzpicture}[label distance=25mm]\large
\fill (0,1) circle (3pt) {};
\fill (1,0) circle (3pt) {};
\fill (1,2) circle (3pt) {};
\fill (2,0) circle (3pt) {};
\fill (2,2) circle (3pt) {};
\fill (3,1) circle (3pt) {};
\draw (1,2) node[above left] {$2$};
\draw(1,0) node[below left] {$3$};
\draw (2,2) node[above right] {$4$};
\draw (2,0) node[below right] {$5$};
\draw(3,1) node[right] {$6$};
\draw [ultra thick] (0,1) edge (1,2);
\draw [dashed] (0,1) edge (1,0);
\draw [dotted] (1,2) edge (2,2) (2,2) edge (3,1) (3,1) edge (2,0) (1,0) edge (1,2) (1,0) edge (2,0);
\draw [rounded corners=6pt, blue](.8,-.2) rectangle (1.2,2.2);
\draw (1,2.5) node[above, blue] {$F_2$};
\draw (.5,1.5) node[above left] {$e_1$};
\draw (.5,.5) node[below left] {$e_2$};
\draw (1.1,1) node[left] {$e_3$};
\draw (1.5,2) node[below] {$e_4$};
\draw (1.5,0) node[above] {$e_5$};
\draw (2.5,1.5) node[above right] {$e_6$};
\draw (2.5,.5) node[below right] {$e_7$};
\end{tikzpicture}
\caption{Path $e_1 \longrightarrow e_2 \dashrightarrow e_3$} \label{subfig:merge1}
\end{subfigure}%
\begin{subfigure}[b]{.5\textwidth}\centering
\begin{tikzpicture}[label distance=25mm]\large
\fill (0,1) circle (3pt) {};
\fill (1,0) circle (3pt) {};
\fill (1,2) circle (3pt) {};
\fill (2,0) circle (3pt) {};
\fill (2,2) circle (3pt) {};
\fill (3,1) circle (3pt) {};
\draw (1,2) node[above left] {$2$};
\draw(1,0) node[below left] {$3$};
\draw (2,2) node[above right] {$4$};
\draw (2,0) node[below right] {$5$};
\draw(3,1) node[right] {$6$};
\draw [dashed] (0,1) edge (1,2);
\draw [ultra thick] (0,1) edge (1,0);
\draw [dotted] (1,2) edge (2,2) (2,2) edge (3,1) (3,1) edge (2,0) (1,0) edge (1,2) (1,0) edge (2,0);
\draw [rounded corners=6pt, blue](.8,-.2) rectangle (1.2,2.2);
\draw (1,2.5) node[above, blue] {$F_2$};
\draw (.5,1.5) node[above left] {$e_1$};
\draw (.5,.5) node[below left] {$e_2$};
\draw (1.1,1) node[left] {$e_3$};
\draw (1.5,2) node[below] {$e_4$};
\draw (1.5,0) node[above] {$e_5$};
\draw (2.5,1.5) node[above right] {$e_6$};
\draw (2.5,.5) node[below right] {$e_7$};
\end{tikzpicture}
\caption{Path $e_1 \dashrightarrow e_2 \longrightarrow e_3$} \label{subfig:merge2}
\end{subfigure}
\spacingset{1} \vspace{-.2in}
\caption{An Example of Node Merging. As shown in
Figure~\ref{fig:zdd}, these two paths merge at $e_3$ because the
connected component numbers in $F_2$ are identical and the number of
determined connected components is zero.} \label{fig:merge}
\end{figure}
Figure~\ref{fig:merge} gives an example of such a merge.
Figure~\ref{subfig:merge1} corresponds to the path,
$e_1 \longrightarrow e_2 \dashrightarrow e_3$ whereas
Figure~\ref{subfig:merge2} represents the path,
$e_1 \dashrightarrow e_2 \longrightarrow e_3$. As shown in
Figure~\ref{fig:zdd}, these two paths are merged at $e_3$ because
the connected component numbers in their frontier $F_2$ are identical and both have the same number of
determined connected component, i.e., ${\tt dcc}=0$. Note that in
Figure~\ref{subfig:merge2} the connected component number is
normalized within the frontier $F_2$ such that
the connected component number of $v_2$ is the maximum vertex index, i.e., 2,
and that of $v_3$ is 3.
Node merging plays a key role in scaling up the enumeration algorithm.
Although we can construct the ZDD that only enumerates graph
partitions by storing the sum of population values into each node
\citep[see Section~4 of][]{Kawahara2017}, this prevents nodes from
being merged, dramatically reducing the scalability of the enumeration
algorithm. Therefore, we do not take this approach here.
\subsubsection{Edge Ordering}
How should we label the edges of the original graph? The
amount of computation depends on the number of nodes
in the ZDD. Recall that two nodes are merged if the stored values such as {\tt comp} and {\tt dcc}
are identical. Since a ZDD node stores
the {\tt comp} value for each vertex in the frontier,
the number of unique stored values grows exponentially as
the frontier size increases (see Section 3.1 in \cite{Kawahara2017} for the detailed analysis).
Therefore, we wish to label the edges of a graph such that
the maximum size of the frontier is minimized. We take a heuristic
approach here. Specifically, we first choose two vertices $s, t$ such
that the shortest distance between $s$ and $t$ is as large as possible
across all vertex pairs. We use the Floyd-Warshall algorithm, which
can find the shortest paths between all vertex pairs in $\mathcal{O}(|V|^3)$ where $|V|$ is the
number of vertices of a graph. Next, we compute the minimum $s$-$t$
vertex graph cut, which is the minimum set of vertices whose removal
generates two or more connected components. To do this, we use a
max-flow based algorithm, and arbitrarily order the resulting
connected components. Finally, we recursively apply this procedure to
each connected component until the resulting connected components are
sufficiently small (e.g., 5 edges), at which point they are ordered in
an arbitrary fashion.
\begin{figure}[t]\centering
\begin{tikzpicture}
\node at (0,1) [circle,draw,scale=.5,fill=black] (bv1) {};
\node at (1,2) [circle,draw,scale=.5,fill=black] (bv2) {};
\node at (1,0) [circle,draw,scale=.5,fill=black] (bv3) {};
\node at (1.9,1.1) [circle,draw,scale=.5,fill=black] (bv4) {};
\node at (2,1) [circle,draw,scale = .5,fill=black] (bv5) {};
\draw (bv1) edge (bv2) (bv1) edge (bv3) (bv3) edge (bv2) (bv4) edge (bv2) (bv3) edge (bv5);
\draw (bv1.west) node[left] {$s=v_1$} (bv2.north) node[above] {$v_2$} (bv3.south) node[below] {$v_3$} (bv4.north) node[above] {$v_4$} (bv5.south) node[below] {$v_5$}
(bv5.east) node[right,align=left] {new $t$};
\node at (3,4) [circle, draw,scale=.5,fill=black] (av1) {};
\node at (4,5) [circle, draw,scale=.5,fill=black] (av2) {};
\node at (4,3) [circle, draw,scale=.5,fill=black] (av3) {};
\node at (6,5) [circle, draw,scale=.5,fill=black] (av4) {};
\node at (6,3) [circle, draw,scale=.5,fill=black] (av5) {};
\node at (7,4) [circle, draw,scale=.5,fill=black] (av6) {};
\draw (av1) edge (av2) (av1) edge (av3) (av2) edge (av3) (av2) edge (av4) (av3) edge (av5) (av5) edge (av6) (av4) edge (av6);
\draw (av1.west) node[left] {$s=v_1$} (av2.north) node[above] {$v_2$} (av3.south) node[below] {$v_3$} (av4.north) node[above] {$v_4$} (av5.south) node[below] {$v_5$} (av6.east) node[right] {$t=v_6$};
\node at (7.9,1.1) [circle, draw,scale=.5,fill=black] (cv4) {};
\node at (8,1) [circle, draw,scale=.5,fill=black] (cv5) {};
\node at (9,1) [circle, draw,scale=.5,fill=black] (cv6) {};
\draw (cv4) edge (cv6) (cv5) edge (cv6);
\draw (cv4.north) node[above] {$v_4$} (cv5.south) node[below] {$v_5$} (cv6.east) node[right] {$t=v_6$} (cv5.west) node[left] {new $s$};
\draw [->] (3,3) -- (2,2);
\draw [->] (7,3) -- (8,2);
\node at (3,5) {$E_1$};
\node at (7,5) {$E_2$};
\draw [dashed] (6,4) ellipse (.5 and 2);
\end{tikzpicture}
\spacingset{1}
\caption{An Example of Edge Ordering by Vertex Cuts. To order
edges, we choose two vertices with the maximum shortest distance
and call them $s$ and $t$. We then use minimum vertex cut,
indicated by the dashed oval, to create two or more connected
components, which are arbitrarily ordered. The same procedure
is then applied to each connected component until the resulting
connected components are sufficiently small. } \label{fig:ordering}
\end{figure}
Figure~\ref{fig:ordering} illustrates this process. In this example,
a pair, $s = v_1$ and $t = v_6$, gives the maximum shortest
distance. Given this choice, there are four minimum $s$-$t$ graph cuts
whose size is 2, i.e.,
$\{v_2, v_3\}, \{v_2, v_5\}, \{v_3, v_4\}, \{v_4, v_5\}$. We
arbitrarily select one of them and call it $S$. Suppose we set
$S=\{v_4, v_5\}$. Then, this yields two connected components, i.e.,
$C_1= \{v_1,v_2,v_3\}$ and $C_2= \{v_6\}$. For each connected
component $C_i$, let $E_i$ represent the set of edges in $C_i$ and
between $C_i$ and $S$. In the current example,
$E_1=\{\{v_1, v_2\}, \{v_1, v_3\}, \{v_2, v_3\}, \{v_2, v_4\}, \{v_3,
v_5\}\}$ and $E_2=\{\{v_4, v_6\}, \{v_5, v_7\}\}$. We order these
edge sets so that all the edges $E_1$ will be placed before those of
$E_2$. To continue this process recursively, we combine all the
vertices in $S$ into a single vertex and let this new vertex be $t$ in
$E_1$ and $s$ in $E_2$. Now, we can apply the same procedure
separately to $E_1$ and $E_2$: computing the minimum $s$-$t$ vertex
cut and splitting the graph into two (or more) components.
The reason why we expect the above edge ordering procedure to produce
a small frontier is that each vertex cut in the process equals one of
the frontiers of the corresponding ZDD. In our example, the first
vertex cut $S$ is equal to $F_5 = \{v_4, v_5\}$. Since we choose
minimum vertex cuts in each step, we expect the input graph with the
edge order obtained through this procedure to have small frontiers.
\subsection{Enumeration and Independent Uniform Sampling}
\label{subsec:enumind}
It can be shown that every path from the root node to the 1-terminal
node in the resulting ZDD has a one-to-one correspondence to a
$p$-graph partition. This is because each $p$-graph partition can be
uniquely represented by the union of induced subgraphs, which in turn
corresponds to a unique path from the root node to the 1-terminal
node. The complexity of the \texttt{enumpart}{} algorithm is generally
difficult to characterize, but \citet{Kawahara2017} analyzes it in the
case of planar graphs. Thus, once we obtain the ZDD as described
above, we can quickly enumerate all the paths from the root node to
the 1-terminal node. Specifically, we start with the 1-terminal node
and then proceed upwards to the root node, yielding a unique graph
partition.
In addition to enumeration, we can also uniformly and independently
random sample $p$-graph partitions \citep{Knuth2011}. First, for each
node $\nu$ of the ZDD, we compute the number of paths to the
1-terminal node. Let $c(\nu)$ be the number of such paths, and
$\nu_0$ and $\nu_1$ be the nodes pointed by the 0-arc and 1-arc of
$\nu$, respectively. Clearly, we have $c(\nu) = c(\nu_0) + c(\nu_1)$.
The values of $c$ for the 0-terminal and 1-terminal nodes are 0 and 1,
respectively. As done for enumeration, we compute and store the value
of $c$ for each node by moving upwards from the terminal node to the
root node. Finally, we conduct random sampling by starting with the
root node and choosing node $\nu_1$ with probability
$c(\nu_1)/\{c(\nu_0)+c(\nu_1)\}$ until we reach the 1-terminal node.
Since the probability of reaching the 0-terminal node is zero, we will
always arrive at the 1-terminal node, implying that we obtain a path
corresponding to a $p$-graph partition. Repeating this procedure will
yield the desired number of uniformly and independently sampled
$p$-graph partitions.
The reason why this procedure samples redistricting maps uniformly is
that a path from the root node to the $1$-terminal node corresponds to
a unique $p$-graph partition. Since each node $\nu$ stores the number
of paths from the node to the $1$-terminal node as $c(\nu)$, the
sampling procedure uniformly and randomly selects one path among
$c(v_1)$ paths where $v_1$ is the root node.
\section{Empirical Scalability Analysis}
\label{sec:scalability}
This section analyzes the scalability of the \texttt{enumpart}{} algorithm
described above, and shows that the algorithm scales to enumerate
partitions of maps many times larger than existing enumeration
procedures. We analyze the algorithm's scalability in terms of runtime
and memory usage, and show how the memory usage of \texttt{enumpart}{} is
closely tied to the frontier of the corresponding ZDD as explained in
the previous section.
To make this empirical analysis realistic, we use independently
constructed and contiguous subsets of the 2008 New Hampshire precinct
map for maps ranging between 40 precincts and 200 precincts,
increasing by 40, i.e., $\{40, 80, 120, 160, 200\}$. The original New
Hampshire map consists of 327 precincts, which are divided into two
congressional districts. To generate an independent contiguous subset
of the map, we first randomly sample a precinct, and add its adjacent
precincts to a queue. We then repeatedly sample additional precincts
from the queue to be added to the subset map, and add the neighbors of
the sampled precincts to the queue, until the map reaches the
specified size. We repeat this process until the subsetted map reaches
a pre-specified size.
We consider partitioning each of these maps into two, five, or ten
districts and apply \texttt{enumpart}{} to each case. We then compute the
time and memory usage of generating a ZDD for each application. For
each precinct size and number of districts, we repeat the above
sampling procedure 25 times, producing 25 independent and contiguous
subsets of the New Hampshire map. All trials were run on a Linux
computing cluster with 530 nodes and 48 Intel Cascade Lake cores per
node, where each node has 180GB of RAM. Note that we do not save the
results of enumeration to disk as doing so for every trial is
computationally too expensive. This means that we cannot conduct an
in-depth analysis of the characteristics of all enumerated maps.
\begin{figure}[!t]
\centering \vspace{-.25in} \spacingset{1}
\begin{center}
\includegraphics[scale=.55]{figs/scalability_analysis.pdf}
\end{center}
\vspace{-.2in}
\caption{The Scalability of the \texttt{enumpart}{} Algorithm on
Subsets of the New Hampshire Precinct Map. This figure shows
the runtime scalability of the \texttt{enumpart}{} algorithm for
building the ZDD on random contiguous subsets of the New
Hampshire precinct map. Crosses indicate maps where the ZDD
was successfully built within the RAM limit of 180GB. In
contrast, open circles represent maps where the algorithm
ran out of memory. For the left and middle columns, the
results are jittered horizontally with a width of 20 for the
clarity of presentation (The actual evaluation points on the
horizontal axis are 40, 80, 120, 160, and 200). The left
column shows how total runtime increases with the number of
units in the underlying map, while the center column shows
how the total RAM usage increases with the number of units
in the underlying map. Lastly, the right-hand column shows
that memory usage is primarily a function of the maximum
frontier size of the ZDD. We show results for 2-district
partitions (top row), five-district partitions (middle row),
and 10-district partitions (bottom
row).} \label{fg:scalability-analysis}
\end{figure}
Figure~\ref{fg:scalability-analysis} shows the results of our
scalability analysis. The top row shows scalability results for
generating a ZDD for partitions of the map into two districts, while
the middle row shows the results with five districts and the bottom
row shows results with ten districts. Each dot represents a run of our
algorithm on a subset of the New Hampshire map. Crosses represent
trials where the ZDD successfully built using under the 180GB RAM
limit. In contrast, open circles show trials that were unable to
build the ZDD with the same RAM limit. Note that for the left and
middle columns, the results are jittered horizontally with a width of
20 for the clarity of presentation.
The left-hand and center columns show how the \texttt{enumpart}{} algorithm
scales in terms of runtime and memory usage, respectively, as the
number of precincts in the underlying map increases. For small maps
ranging from 25 precincts to 80 precincts, runtime and memory usage
are for the most part negligible. The ZDD for two-district,
five-district, and ten-district partitions for these small maps can be
constructed in nearly all cases in under two minutes, and using less
than one gigabyte of RAM. As the number of precincts in the map starts
to increase, so do the runtime and memory usage requirements. For maps
of 200 precincts, over 90\% of the tested maps hit the 180GB memory
limit before building the complete ZDD. For all map sizes, we also
note that the runtime and memory usage requirements for building the
ZDD do not appear to depend much on the number of districts that the
map is being partitioned into.
What drives these patterns in scalability? While the number of units
in the underlying map predicts both runtime and memory usage, there is
still a great deal of variability even conditional on the number of
precincts in the map. In the right-hand column, we show that the
memory usage requirements for building the ZDD are closely tied to the
maximum frontier size of the underlying map, as defined in
Section~\ref{subsubsec:frontier}. While the memory usage is minimal
so long as the maximum frontier size of the graph is under 11, memory
usage increases quickly once the maximum frontier size grows beyond
that. This suggests that improved routines for reducing the size of a
map's frontier can allow for the enumeration of increasingly large
maps.
\section{Empirical Validation Studies}
\label{sec:validation}
In this section, we introduce a set of new validation tests and
datasets that can be used to evaluate the performance of redistricting
simulation methods. We focus on the two most popular types of
simulation methods that are implemented as part of the open-source
software package \textsf{redist}{} \citep{fifi:tarr:imai:15}: one based on the
Markov chain Monte Carlo (MCMC) algorithm \citep{fifi:etal:14,fifi:etal:20,
matt:vaug:14} and the other based on the random-seed-and-grow (RSG)
algorithm \citep{ciri:darl:orou:00,chen:rodd:13}. Below, we conduct
empirical validation studies both through full enumeration and
independent uniform sampling.
\subsection{Validation through Enumeration}
We conduct two types of validation tests using enumeration. We first
use the \texttt{enumpart}{} algorithm to enumerate all possible redistricting
plans using a map with 70 precincts, which is much larger than the
existing validation map with 25 precincts analyzed in
\citet{fifi:etal:14,fifi:etal:20}. We then compare the sampled
redistricting plans obtained from simulation methods against the
ground truth based on the enumerated plans. The second approach is
based on many smaller maps with 25 precincts. We then assess the
overall performance of simulation methods across these many maps
rather than focusing on a specific map.
\subsubsection{A New 70-precinct Validation Map}
\label{subsubsec:70map}
\begin{figure}[!t]
\centering \vspace{-.5in} \spacingset{1}
\begin{center}
\includegraphics[scale=.66]{figs/map_descriptives_70precinct.pdf}
\end{center}
\vspace{-.25in}
\caption{A New 70-Precinct Validation Map and the Histogram of
Redistricting Plans under Various Population Parity and Compactness
Constraints. The underlying data is a 70-precinct contiguous
subset of the Florida precinct map, for which the
\texttt{enumpart}{} algorithm enumerated every 44,082,156 partitions
of the map into two contiguous districts. In the
histograms, each bar represents the number of redistricting
plans that fall within a 1 percentage point range of a
certain population parity, i.e.,
$[0, 0.01), [0.01, 0.02), ..., [0.19, 0.20)$. The 25th
(75th) percentile compactness constraint is
defined as the set of plans that are more compact than the
25th (75th) percentile of maps within the full enumeration
of all plans for the 70-precinct map, using the Relative
Proximity Index to measure compactness. The annotations
reflect the exact number of plans which meet the
constraints. For example, when no compactness constraint is
applied, there are 3,678,453 valid plans when applying a 5\%
population parity constraint, and 717,060 valid plans when
applying a 1\% population parity constraint. Under the
strictest constraints, the 1\% population parity constraint
and 75th percentile compactness constraint, there are
271,240 valid plans.} \label{fg:new-70prec-map}
\end{figure}
The top left plot of Figure~\ref{fg:new-70prec-map} introduces a new
validation map with 70 precincts and their population, which is a
subset of the 2008 Florida precinct map consisting of 6,688 precincts
with 25 districts. We use the \texttt{enumpart}{} algorithm to enumerate every
partition of this map into two districts, which took approximately 8
hours on a MacBook Pro laptop with 16GB RAM and 2.8 GHz Intel i7
processors. Nearly all of this time was spent writing the partitions
to disk --- building the ZDD for this map took under half a second.
The histograms of the figure shows the number of redistricting plans
that satisfy the deviation from population parity up to 20
percentage points (by one percentage point increments, i.e.,
$[0, 0.01), [0.01, 0.02), ..., [0.19, 0.2)$). The deviation from
population parity is defined as,
\begin{equation}
\max_{1 \le k \le p} \frac{|P_k-\overline{P}|}{\overline{P}}
\end{equation}
where $P_k$ represents the population of the $k$th district,
$\overline{P}=\sum_{k =1}^p P_{k}/p$, and $p$ is the total number of
districts. When partitioning this map into two districts, there exist a total of 44,082,156 possible
redistricting plans if we only impose the contiguity requirement.
As shown in the upper right plot, out of these, over 700,000 plans are
within a 1\% population parity constraint. As we relax the population
parity constraint, the cumulative number of valid redistricting plans
gradually increases, reaching over 3 and 7 million plans for the 5\%
and 10\% population parity constraints, respectively. Thus, this
validation map represents a more realistic redistricting problem than
the validation map analyzed in \citet{fifi:etal:14,fifi:etal:20}. That
dataset, which enumerates all 117,688 partitions of a 25-precinct
subset of the Florida map into three districts, includes only 8 plans
within 1\% of population parity, and 927 plans within 10\% of
population parity.
In addition to the population parity, we also consider compactness
constraints. Although there exist a large number of different
compactness measures, for the sake of illustration, we use the
Relative Proximity Index (RPI) proposed by \citet{fry:hold:2011}. The
RPI for a given plan $\pi_s$ in the valid set of redistricting plans
$\boldsymbol\pi$ is defined as,
\begin{equation}
{\rm RPI} (\pi_s) \ = \
\frac{\sum_{k=1}^{p} \sum_{i \in V_k}\sum_{j \in V_k}
P_iP_jD_{ij}^2}{\argmin_{\pi_s \in \boldsymbol\pi}\sum_{k=1}^{p} \sum_{i \in
V_k}\sum_{j \in V_k} P_iP_jD_{ij}^2} \label{eq:RPI}
\end{equation}
where $P_i$ corresponds to the population for precinct $i$ assigned to
district $k$, and $D_{ij}$ corresponds to the distance between
precincts $i$ and $j$ assigned to district $k$. Thus, a plan with a
lower RPI is more compact.
We consider two compactness thresholds based on the RPI values: 25th
and 75th percentiles, which equal 1.76 and 1.44, respectively. As
shown in the bottom left histogram of Figure~\ref{fg:new-70prec-map},
the 25th percentile constraint does little beyond the population
constraint. The number of valid plans that satisfy a 5\%
population parity threshold remains identical even after imposing this
compactness constraint. However, the 75th percentile compactness
constraint dramatically reduces the number of valid plans as seen in
the bottom right histogram. For example, it reduces the total number
of plans that meet the 1\% population parity threshold by more than 70
percent.
\begin{figure}[!t]
\centering \vspace{-.5in} \spacingset{1}
\begin{center}
\includegraphics[scale=.825]{figs/largemap_enum_all_compact_validation.pdf}
\end{center}
\vspace{-.25in}
\caption{A Validation Study Enumerating all Partitions of a
70-Precinct Map into Two Districts. The underlying data is
the 70-precinct contiguous subset introduced in the left
plot of Figure~\ref{fg:new-70prec-map}. Unlike the
random-seed-and-grow (RSG) method (red dashed lines), the
Markov chain Monte Carlo (MCMC) method (solid black line) is
able to approximate the target distribution. The 25th
percentile (75th percentile) Compactness Constraint is
defined as the set of plans that are more compact than the
25th (75th) percentile of maps within the full enumeration
of all plans for the 70-precinct map, using the Relative
Proximity Index to measure compactness.} \label{fg:enumeration-validation-largemap}
\end{figure}
Figure~\ref{fg:enumeration-validation-largemap} shows the performance
of the MCMC and RSG simulation methods using the new 70-precinct
validation map \citep[see Algorithms~1~and~3 of][respectively, for the
details of implementation]{fifi:etal:14,fifi:etal:20}. The solid grey
density shows the true distribution of the Republican dissimilarity
index \citep{mass:dent:88} on the validation map, which is defined as
\begin{equation}
D \ = \ \frac{1}{2}\sum_{k=1}^{p}\frac{P_k}{P} \cdot \frac{| R_k - R|}{R(1-R)} \label{eq:dissimilarity}
\end{equation}
where $k$ indexes districts in a state, $P_k$ is the population of
district $k$, $R_k$ is the share of district $k$ that voted for the
Republican presidential candidate in 2008, $P$ is the total population
in the state, and $R$ is the voteshare for the Republican presidential
candidate across all districts.
The red dashed lines show the distribution of the Republican
dissimilarity index of the RSG algorithm. Solid black lines show the
distribution of the Republican dissimilarity index on plans drawn by
the MCMC algorithm. In cases where we impose a population parity
target, we specify a target distribution of plans using the Gibbs
distribution where plans closer to population parity are more likely
to be sampled by the algorithm \citep[see][for
details]{fifi:etal:14,fifi:etal:20}.
Similarly, when a compactness constraint is imposed, we specify a
target Gibbs distribution such that more compact plans are sampled.
Note that in typical redistricting applications, we would not know the
denominator of equation~\eqref{eq:RPI}. \citet{fry:hold:2011} derive
a power-diagram approach to finding a plan that approximately
minimizes the denominator. Since we have enumerated all possible plans
in the current setting, we simply use the true minimum value. However,
this has no impact on the performance of the algorithm, since it is
absorbed into the normalizing constant of the target distribution.
Specifically, we use the following target
Gibbs distribution,
\begin{equation}
f_\beta(\pi_s) \ = \ \frac{1}{z(\beta)}\exp\left\{-\sum_{k =
1}^{p}(\beta_p\psi_k^p + \beta_c\psi_k^c)\right\},
\end{equation}
where
\begin{align}
\psi_k^p & \ = \ \frac{|P_k - \overline{P}|}{\overline{P}} \quad {\rm
and} \quad
\psi_k^c \ = \ \frac{\sum_{i \in V_k}\sum_{j \in V_k} P_iP_jD_{ij}^2}{\argmin_{\pi_s \in \boldsymbol\pi}\sum_{k=1}^{p} \sum_{i \in V_k}\sum_{j \in V_k} P_iP_jD_{ij}^2}. \nonumber
\end{align}
In this formulation, the strength of each constraint is governed by
separate temperature parameters $\beta_p$ (for population parity) and
$\beta_c$ (for compactness), where higher temperatures increase the
likelihood that plans closer to the population parity or compactness
target will be sampled. Once the algorithm is run, we discard sampled
plans that fail to meet the target population and compactness
constraints, and then reweight and resample the remaining plans so
that they approximate a uniform sample from the population of all
plans satisfying the constraints. After some initial tuning, we
selected $\beta_p = 10$ for the 5\% equal population constraint, and
$\beta_p = 50$ for the 1\% equal population constraint. We selected
$\beta_c = .001$ for the 25th percentile compactness constraint and
$\beta_c = .01$ for the 75th percentile compactness constraint. When
the population or compactness constraints are not applied, we set
their corresponding temperature parameter to 0.
The RSG algorithm was run for 1,000,000 independent draws for each
population constraint, while the MCMC algorithms were run for 250,000
iterations using 8 chains for each pair of constraints. Starting plans
for each MCMC chain were independently selected using the RSG
algorithm. The Gelman-Rubin diagnostic \cite{gelm:rubi:92}, a standard
diagnostic tool for MCMC methods based on multiple chains, suggests
that all MCMC chains had converged after at most 30,000 iterations.
Unfortunately, the RSG algorithm does not come with such a diagnostic
and hence we simply run it until it yields the same number of draws as
the MCMC algorithms for the sake of comparison.
It is clear that on this test map, the RSG algorithm is unable to
obtain a representative sample of the target distribution, at any
level of population parity or compactness. This finding is consistent with the fact
that the RSG algorithm is a heuristic algorithm with no theoretical
guarantees and no specified target distribution. In contrast, the MCMC
algorithm is able to approximate the target distribution, across all
levels of population parity and compactness tested.
\subsubsection{Many Small Validation Maps}
A potential criticism of the previous validation study is that it is
based on a single map. This means that even though it is of much
larger size than the previously available validation map, the results
may depend on the idiosyncratic geographical and other features of
this particular validation map. To address this, we conduct another
study based on many small validation maps. Specifically, we use our
algorithm to enumerate all possible redistricting plans for each of
200 independent 25-precinct subsets of the 2008 Florida map. We then
evaluate the performance of simulation methods for each validation
map. Since we do not tune the temperature parameter of the MCMC
algorithm for each simulated map unlike what one would do in practice,
this yields a simulation setting that poses a significant challenge
for the MCMC algorithm.
To assess the overall performance across these validation maps, we use
the Kolmogorov-Smirnov (KS) statistic to test the distributional
equality of the Republican dissimilarity index between the enumerated
plans and the simulated plans. To increase the independence across
simulated plans, we run the MCMC and RSG algorithms for 5 million
iterations each on every map and then thinning by 500 (i.e., taking
every 500th posterior draw). Without thinning, there is a significant
amount of autocorrelation across draws, with the autocorrelation
typically ranging between 0.75 and 0.85 between adjacent draws and
between 0.30 and 0.60 for draws separated by 5 iterations. In
contrast, when thinning the Markov chain by 500, the autocorrelation
between adjacent draws falls to under 0.05. When thinning the Markov
chain by 1000, the results are approximately the same, as seen in
Figure~\ref{fg:enumeration-validation-qq-1000}.
Although this does not make simulated draws completely independent of
one another, we compute the $p$-value under the assumption of
two independently and identically distributed samples. If the simulation
methods are successful and the independence assumption holds, then we
should find that the distribution of $p$-values across 200 small
validation maps should be approximately uniform. After some initial
tuning, we set the temperature parameter of the MCMC algorithm such
that $\beta_p = 1$ for the 20\% equal population constraint, and
$\beta_p = 5$ for the 10\% equal population constraint. These values
are used throughout the simulations. In other words, unlike what one
would do in practice, no data-specific tuning is performed, leading to
a setting that is not favorable to the MCMC algorithm. After running
the simulations, we again discard plans falling outside of the
specified parity threshold and then reweight and resample the
remaining plans to approximate a uniform draw from the target
distribution of plans satisfying the specified parity constraint. We
then calculate the KS test $p$-value by comparing the reweighted and
resampled set of plans against the true distribution.
\begin{figure}[!t]
\centering \vspace{-.5in} \spacingset{1}
\begin{center}
\includegraphics[scale=.825]{figs/qq_test.pdf}
\end{center}
\vspace{-.25in}
\caption{Quantile-Quantile Plot of $p$-values based on the
Kolmogorov-Smirnov (KS) Tests of Distributional Equality
between the Enumerated and Simulated Plans across 200
Validation Maps and under Different Population Parity
Constraints. Each dot represents the $p$-value from a KS
test comparing the empirical distribution of the Republican
dissimilarity index from the simulated and enumerated
redistricting plans. Under independent and uniform
sampling, we expect the dots to fall on the 45-degree
line. The MCMC algorithm (black dots), although imperfect,
significantly outperforms the RSG algorithm (red crosses). See Figure \ref{fg:enumeration-validation-qq-1000} in the appendix for discussion of thinning values.} \label{fg:enumeration-validation-qq}
\end{figure}
Figure~\ref{fg:enumeration-validation-qq} shows the results of this
validation study. The left plot shows how the MCMC (black dots) and
RSG (red crosses) algorithms perform when not applying any population
parity constraint. Each dot corresponds to the $p$-value of the KS
test for a separate 25-precinct map. Under the assumption of
independent sampled plans, if a simulation algorithm is successfully
approximating the target distribution, these dots should fall roughly
on the 45 degree line.
It is clear from this validation test that the RSG algorithm
consistently fails to obtain a representative sample of the target
distribution. That the red dots are concentrated near the bottom of
the graph indicates that the KS p-value for the RSG algorithm is near
zero for nearly every map tested. When population parity constraints
of 20\% and 10\% are applied, the RSG algorithm continues to perform
poorly compared to the MCMC algorithm. By using a soft constraint
based on the Gibbs distribution, we allow the Markov chain to traverse
from one valid plan to another through intermediate plans that may not
satisfy the desired parity constraint. We find that although
imperfect, the MCMC algorithm works much better than RSG algorithm.
\subsection{Validation through Independent Uniform Sampling}
Next, we conduct larger-scale validation studies by leveraging the
fact that the \texttt{enumpart}{} algorithm can independently and uniformly
sample from the population of all possible redistricting plans. This
feature allows us to scale up our validation studies further by
avoiding for larger maps the computationally intensive task of writing
to the hard disk all possible redistricting plans, which exponentially
increases as the map size gets larger. We independently and uniformly
sample a large number of redistricting plans and compare them against
the samples obtained from simulation methods. Below, we present two
validation studies. The first study uses the actual Congressional
district maps from Iowa, where by law redistricting is done using 99
counties. The second study is based on a new 250-precinct validation
map obtained from the Florida map.
\subsubsection{The Iowa Congressional District Map}
We first analyze a new validation dataset constructed on the
redistricting map from the state of Iowa. In Iowa, redistricting is
conducted using a total of 99 counties instead of census blocks to
piece together districts, in order to avoid splitting county
boundaries in line with the Iowa State Constitution.\footnote{Article
3, Section 37 of the Iowa State Constitution states ``When a
congressional, senatorial or representative district shall be
composed of two or more counties, it shall not be entirely separated
by any county belonging to another district; and no county shall be
divided in forming a congressional, senatorial, or representative
district.''} As a result, the Iowa redistricting problem is more
manageable than other states.
\begin{figure}[!t]
\centering \vspace{-.25in} \spacingset{1}
\begin{center}
\includegraphics[scale=.66]{figs/map_descriptives_ia.pdf}
\end{center}
\vspace{-.25in}
\caption{Iowa's 2016 Congressional Districts and the Histogram
of a Random Sample of Redistricting Plans under Various
Population Parity Constraints. The underlying data is the
Iowa county map, for which the \texttt{enumpart}{} algorithm
generated an independent and uniform random sample of 500
million partitions of the map into four contiguous
districts. In the histogram, each bar represents the number
of redistricting plans that fall within the 1 percentage
point range of a certain population parity, i.e.,
$[0, 0.01), [0.01, 0.02), ..., [0.19, 0.20)$. There are
36,131 valid plans when applying a 5\% population parity
constraint, and only 300 valid plans when applying a 1\%
population parity constraint.} \label{fg:new-ia-map}
\end{figure}
The left plot of Figure~\ref{fg:new-ia-map} shows the Iowa map, where the shading indicates the population of each county. In 2016,
Republicans won three districts while Democrats won one district,
while in 2018, Democrats won three districts and the Republicans held
only one. We use the \texttt{enumpart}{} algorithm to independently and
uniformly sample 500 million contiguous partitions of this map into
four districts. This number is minuscule relative to the total number
of valid partitions of the map into four districts, of which there are
approximately $10^{24}$, but still is more than enough to use it as
the target distribution. We note that while it took around 36 hours to
sample 500 million partitions on the aforementioned cluster computer
using significant parallelization, building the ZDD for this map took
less than half a second on our MacBook Pro laptop mentioned earlier.
Nearly all of the runtime of the enumeration was spent writing the
solutions to harddisk.
The histogram in Figure~\ref{fg:new-ia-map} shows the share of the
sampled redistricting plans that satisfy the deviation from population
parity up to 20 percentage points. Of the 500 million plans we have
randomly sampled, only 300, or less than 0.00006\%, satisfy a 1\%
population parity constraint, illustrating the sheer scale of the
redistricting problem and how much the population equality constraint
alone shrinks the total solution space of valid redistricting plans.
There are 36,131 plans, or less than 0.001\%, satisfying a 5\%
population parity constraint, which is still a minuscule share
compared to the total number of enumerated plans.
\begin{figure}[!t]
\centering \spacingset{1}
\begin{center}
\includegraphics[scale=.825]{figs/ia_enumerate_validation.pdf}
\end{center}
\vspace{-.25in}
\caption{A Validation Study, Uniformly Sampling from the
Population of all Partitions of the Iowa Map into Four
Districts. The underlying data is Iowa's county map in the
left plot of Figure~\ref{fg:new-ia-map}, which is
partitioned into four congressional districts. As in the
previous validation exercises, the Markov chain Monte Carlo
(MCMC) method (solid black line) is able to approximate the
independently and uniformly sampled target distribution,
while the random-seed-and-grow (RSG) method (red dashed
line) performs poorly.} \label{fg:enumeration-validation-ia}
\end{figure}
Figure~\ref{fg:enumeration-validation-ia} shows the performance of the
MCMC and RSG simulation methods on the state-sized redistricting
problem for Iowa. The solid grey density shows the distribution of the
Republican dissimilarity index based on the independently and
uniformly sampled set of 500 million redistricting plans. The red
dashed lines show the distribution of the Republican dissimilarity
index on plans sampled by the RSG algorithm, while the solid black
lines shows the distribution for plans sampled by the MCMC
algorithm. As in the previous validation exercise, where we impose 5\%
and 1\% population parity constraints, we specify a target
distribution of plans using the Gibbs distribution. Here, we set the
temperature parameter $\beta_p = 25$ for the 5\% parity constraint, and
$\beta_p = 50$ for the 1\% parity constraint, which we selected after
initial tuning. After discarding plans not satisfying the constraint
and then reweighting, we ended up with 629,729 plans for the 5\%
parity constraint, and 93,046 plans for the 1\% parity constraint. The
RSG algorithm was run for 2 million independent draws, while the MCMC
algorithms were run for 250,000 iterations and initializing 8 chains
for each algorithm. The chains were run without a burn-in period, and
the Gelman-Rubin diagnostic suggested that the Markov chains had
converged after at most 30,000 iterations.
As with the previous validation test, the MCMC algorithm outperforms
the RSG algorithm across all levels of the population parity
constraint. When no equal population constraint is applied or a 5\%
population parity constraint is applied, the MCMC algorithm samples
from the target distribution nearly perfectly. Even with the 1\%
parity map, where there are only 300 valid plans in the target
distribution, the MCMC algorithm approximates the target distribution
reasonably well, missing by only slightly in portions of the
distribution. In contrast, at all levels of population parity, the RSG
algorithm is unable to draw a representative sample of plans from the
target distribution.
\subsubsection{A New 250-Precinct Validation Map}
Next, we present the results of validation tests that use a new,
250-precinct validation map, which is constructed from a contiguous
subset of the 2008 Florida precinct map. As with the previous
validation exercise, we use the \texttt{enumpart}{} algorithm to independently
and uniformly sample 100 million partitions of this map into two
districts. This is still a minuscule number of plans relative to about
$5 \times 10^{39}$ possible partitions of this map into two
districts. However, given the ability of the \texttt{enumpart}{} algorithm to
uniformly and independently sample plans using the ZDD, we are able to
approximate an accurate target distribution arbitrarily well.
\begin{figure}[!t]
\centering \vspace{-.25in} \spacingset{1}
\begin{center}
\hspace{-.5in}\includegraphics[scale=.66]{figs/map_descriptives_250precinct.pdf}
\end{center}
\vspace{-.25in}
\caption{A New 250-Precinct Validation Map and the Histogram
of Redistricting Plans under Various Population Parity
Constraints. The underlying data is a 250-precinct
contiguous subset of the Florida precinct map, for which the
\texttt{enumpart}{} algorithm generated an independent and uniform
random sample of 100 million partitions of the map into two
contiguous districts. In the histogram, each bar represents
the number of redistricting plans that fall within the 1
percentage point range of a certain population parity, i.e.,
$[0, 0.01), [0.01, 0.02), ..., [0.19, 0.20)$. There are
10,082,542 valid plans when applying a 5\% population parity
constraint, and 1,953,736 valid plans when applying a 1\%
population parity constraint.} \label{fg:new-250prec-map}
\end{figure}
The left plot of Figure~\ref{fg:new-250prec-map} shows the validation
map, where the shading indicates the population of each of the
precincts. Unlike the Iowa map, this map has geographical units of
various sizes. This validation map also has a slightly larger frontier
size (maximum frontier of 14) than that of the Iowa map (maximum
frontier of 11), making it more likely to run out of memory due to the
size of ZDD and thereby also increasing computational time. The
histogram on the right gives the distribution of population parity
distance among the sampled plans, through 20\% parity. Of the sampled
plans, 1.95\% (1.95 million plans) satisfy the 1\% population parity
constraint, while 21.8\% of the sampled plans (21.8 million plans)
satisfy the 10\% population parity constraint.
We sample 4 million plans for each population parity level using the
MCMC and RSG algorithms. For the MCMC algorithm, we initialized 8
chains running for 500,000 iterations each, and where a population
parity constraint is imposed, we specify the target distribution of
plans using the Gibbs distribution. We set the temperature parameter
$\beta_p = 25$ for sampling plans within 5\% of parity, and $\beta_p = 50$
when sampling plans within 1\% of parity. After discarding invalid
plans and reweighting, these parameter settings yielded 3,088,086
plans satisfying the 5\% parity constraint, and 1,881,043 plans
satisfying the 1\% parity constraint. All eight chains were run
without burn-in, and the Gelman-Rubin convergence diagnostic suggested
the chains had converged after approximately 75,000 iterations.
\begin{figure}[!t]
\centering \spacingset{1}
\begin{center}
\includegraphics[scale=.825]{figs/largemap_enumerate_sample_validation.pdf}
\end{center}
\vspace{-.25in}
\caption{A Validation Study Enumerating all Partitions of a
250-Precinct Map into Two Districts. The underlying data is
the 250-precinct contiguous subset introduced in the left
plot of Figure~\ref{fg:new-250prec-map}. As in the previous
validation exercises, the Markov chain Monte Carlo (MCMC)
method (solid black line) is able to approximate the target
distribution based on the independent and uniform sampling,
while the random-seed-and-grow (RSG) method (red dashed
line) performs
poorly.} \label{fg:enumeration-validation-250prec}
\end{figure}
Results for the validation test using the 250-precinct validation map
are shown in Figure~\ref{fg:enumeration-validation-250prec}. As with
the previous validation exercise, the solid grey density shows the
target distribution of the Republican dissimilarity index on the 100
million plans sampled by the \texttt{enumpart}{} algorithm, while the red
dashed lines show the distribution of the Republican dissimilarity
index for the RSG algorithm. Finally, the solid black lines show the
distribution of the Republican dissimilarity index for the MCMC
algorithm. Across all levels of population parity, including the 1\%
constraint, the MCMC algorithm is able to successfully sample from the
target distribution and return a representative sample of
redistricting plans. In contrast, where no population parity
constraint is applied or where a 5\% parity constraint is applied, the
RSG algorithm is not able to sample from the target distribution with
any accuracy. While it performs somewhat better on the 1\% constraint,
it is still biased towards plans with higher values on the
dissimilarity index, and fails to capture the bimodality of the target
distribution.
\section{Concluding Remarks}
More than a half century after scholars began to consider automated
redistricting, legislatures and courts are increasingly relying on
computational methods to generate redistricting plans and determine
their legality. Unfortunately, despite the growing popularity of
simulation methods in the recent redistricting cases, there exists
little empirical evidence that these methods can in practice generate
a representative sample of all possible redistricting maps under the
statutory guidelines and requirements.
We believe that the scientific community has an obligation to
empirically validate the accuracy of these methods. In this paper, we
show how to conduct empirical validation studies by utilizing a
recently developed computational method that enables the enumeration
and independent uniform sampling of all possible redistricting plans
for maps with a couple of hundred geographical units. We make these
validation maps publicly available, and implement our methodology as
part of an open source software package, \textsf{redist}. These resources
should facilitate researchers' efforts to evaluate the performance of
existing and new methods in realistic settings.
Indeed, much work remains to be done in order to understand the
conditions under which a specific simulation method do and does not
perform well. A real-world redistricting process is complex.
Distinct geographical features and diverse legal requirements play
important roles in each state. It is yet far from clear how these
factors interact with different simulation methods. Future work
should address these issues using the data from various states.
It is also important to further improve the capabilities of the
\texttt{enumpart}{} algorithm and of the MCMC algorithm. The maximum frontier
size of our largest validation maps, which predicts the computational
difficulty for the \texttt{enumpart}{} algorithm, is 14, which is far less
than that of other states. For example, the maximum frontier size for
New Hampshire (2 districts, 327 precincts) and Wisconsin (8 districts,
6895 precincts) are 21 and 84, respectively. These are much more
challenging redistricting problems than the validation studies
presented in this paper.
As the 2020 Census passes, lawsuits challenging proposed redistricting
plans will inevitably be brought to court, and simulation evidence
will be used to challenge and defend those plans. Thus, it is
necessary that the empirical performance of these methods be
rigorously evaluated. This paper introduces what we hope will be the
first of many future complementary validation tests used to ensure
that this evidence is of the highest possible quality according to the
scientific standards.
| {'timestamp': '2020-06-19T02:03:43', 'yymm': '2006', 'arxiv_id': '2006.10148', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10148'} | arxiv |
\section{Introduction \& Related Work}
\label{sec:intro}
We consider the bi-criteria shortest-path problem, an extension to the classical (single-criteria) shortest-path problem where we are given a graph $G = (V,E)$ and each edge has two cost functions.
Here, we are required to compute paths that balance between the two cost functions.
The well-studied problem~\cite{CP07} has numerous applications. For example, given a road network, the two cost functions can represent travel times and distances and we may need to consider the set of paths that allow to balance between these costs.
Other applications include
planning of power-transmission lines~\cite{bachmann2018multi}
and
planning how to transport hazardous material in order to balance between minimizing the travel distance and the risk of exposure
for residents~\cite{bronfman2015maximin}.
There usually is no path minimizing all cost functions simultaneously.
Thus, we typically consider the set of paths where no path is strictly better then the others for both cost functions, a set called the \myemph{Pareto-optimal frontier}.
Unfortunately, the problem is {\small {{NP}}\xspace}-hard~\cite{S87} as the cardinality of the size of the Pareto-optimal frontier may be exponential in $|V|$~\cite{Ehrgott05,breugem2017analysis} and even
determining whether a path belongs to the Pareto-optimal frontier is {\small {{NP}}\xspace}-hard~\cite{PY00}.
Existing methods either try to
efficiently compute the Pareto-optimal frontier
or to
relax the problem and only compute an approximation of this set.
\paragraph{Efficient computation of the Pareto-optimal frontier.}
To efficiently compute the Pareto-optimal frontier, adaptations of the celebrated \algname{A$^*$} algorithm~\cite{HNR68} were suggested.
Stewart et al.~\cite{stewart1991multiobjective} introduced
Multi-Objective A* (\algname{MOA$^*$}) which is a multiobjective extension of $\algname{A}^*$.
The most notable difference between \algname{MOA$^*$} and $\algname{A}^*$ is in maintaining the Pareto-optimal frontier to intermediate vertices. This requires to check if a path~$\pi$ is \myemph{dominated} by another path~$\tilde{\pi}$. Namely, if both of~$\tilde{\pi}$'s costs are smaller than~$\pi$'s costs.
As these dominance checks are repeatedly performed, the time complexity of the checks play a crucial role for the efficiency of such bi-criteria shortest-path algorithms.
\algname{MOA$^*$} was later revised~\cite{de2005new,mandow2010multiobjective,pulido2015dimensionality} with the most efficient variation, termed bi-Objective \algname{A$^*$} (\algname{BOA$^*$})~\cite{UYBZSK20} allowing to compute these operations in $O(1)$ time when a consistent heuristic is used.\footnote{A heuristic function is said to be consistent if its estimate is always less than or equal to the estimated distance from any neighbouring vertex to the goal, plus the cost of reaching that neighbour.}
\paragraph{Approximating the Pareto-optimal frontier.}
Initial methods in computing an approximation of the Pareto-optimal frontier were directed towards devising a Fully Polynomial Time Approximation Scheme\footnote{An FPTAS is an approximation scheme whose time complexity is polynomial in the input size and also polynomial in $1/\ensuremath{\varepsilon}\xspace$ where~$\ensuremath{\varepsilon}\xspace$ is the approximation factor.} (FPTAS)~\cite{V01}.
Warburton~\cite{W87} proposed a method for finding an approximate Pareto-optimal solution to the problem for any degree of accuracy using scaling and rounding techniques.
Perny and Spanjaard~\cite{perny2008near} presented another FPTAS given that a finite upper bound $L$ on the numbers of arcs of all solution-paths in the Pareto-frontier is known.
This requirement was later relaxed~\cite{TZ09,breugem2017analysis} by partitioning the space of solutions into cells according to the approximation factor and, roughly speaking, taking only one solution in each grid cell.
Unfortunately, the running times of FPTASs are typically polynomials of high degree, and hence they may be slower than exact approaches when applied to relatively-small instances and running them on graphs with even a moderate number of nodes (e.g., $\approx 10,000$) is often impractical~\cite{breugem2017analysis}.
A different approach to compute a subset of the Pareto-optimal frontier is to find all extreme supported non-dominated points (i.e., the extreme points on the convex hull of the Pareto-optimal set)~\cite{sedeno2015dijkstra}.
Taking a different approach Legriel et al.~\cite{LLCM10} suggest a method based on satisfiability/constraint solvers.
Alternatively, a simple variation of \algname{MOA$^*$}, termed \algname{MOA$^*_\ensuremath{\varepsilon}\xspace$} allows to compute an approximation of the Pareto-optimal frontier by pruning intermediate paths that are approximately dominated by already-computed solutions~\cite{perny2008near}. However, as we will see, this allows to prune only a small subset of paths that may be pruned.
Finally, recent work~\cite{BC20} conducts a comprehensive computational study with an emphasis on multiple criteria.
Similar to the aforementioned FPTASs, their framework still partitions the space prior to running the algorithm.
\paragraph{Key contribution.}
To summarize, exact methods compute a solution set whose size is often exponential in the size of the input.
While one would expect that approximation algorithms will allow to dramatically speed up computation times, in practice their running times are often slower than exact solutions for FPTAS's because they partition the space of solutions into cells according to the approximation factor in advance.
Alternative methods only prune paths that are approximately dominated by already-computed solutions.
Our key insight is that we can efficiently partition the space of solutions into cells during the algorithm's execution (and not a-priori). This allows us to efficiently and effectively prune away intermediate solutions in order to obtain an approximation of the Pareto-optimal frontier for any given approximation factor $\ensuremath{\varepsilon}\xspace$ (this will be formalized in Sec.~\ref{sec:pdf}).
This is achieved by running a best-first search on \myemph{path pairs} and not individual paths. Such path pairs represent a subset of the Pareto-optimal frontier such that any solution in this subset is approximately dominated by the two paths.
Using concepts that draw inspiration from a recent search algorithm from the robotics literature~\cite{FuKSA19},
we propose Path-Pair \algname{A$^*$} (\algname{PP-A$^*$}).
\algname{PP-A$^*$} dramatically reduces the computational complexity of the best-first search by merging path pairs while still ensuring that an approximation of the Pareto-optimal frontier is obtained for any desired approximation.
For example, on a roadmap of roughly 1.5 million vertices, \algname{PP-A$^*$} approximates the Pareto-optimal frontier within a factor of $1\%$ in roughly 13 seconds on average on a commodity laptop.
We compared our approach with an adaptation of \algname{BOA$^*$}~\cite{UYBZSK20}, the state-of-the-art algorithm for computing exact solutions to the bi-criteria shortest-path problem, which we term \algname{BOA$^*_\eps$}. \algname{BOA$^*_\eps$} computes near-optimal solutions by using the approach suggested in~\cite{perny2008near}.
Our experiments show that as the problem becomes harder, the speedup that \algname{PP-A$^*$} may offer becomes more pronounced.
Specifically, on the aforementioned roadmap and using an approximation factor of $10\%$, we obtain
a speedup on the average running time of more than $\times 19$
and a maximal speedup of over~$\times 25$.
\section{Problem Definition}
\label{sec:pdf}
Let $G = (V,E)$ be a graph,
$c_1 : E \rightarrow \mathbb{R}$ and
$c_2 : E \rightarrow \mathbb{R}$ be two cost functions defined over the graph edges.
A path $\pi = v_1, \ldots v_k$ is a sequence of vertices where consecutive vertices are connected by an edge.
We extend the two cost functions to paths as follows:
$$
c_1(\pi) = \sum_{i=1}^{k-1} c_1(v_i, v_{i+1})
\hspace{2mm}
\text{ and }
\hspace{2mm}
c_2(\pi) = \sum_{i=1}^{k-1} c_2(v_i, v_{i+1}).
$$
Unless stated otherwise,
all paths start at the same specific vertex ${\ensuremath{v_{\rm{start}}}\xspace}$
and $\pi_u$ will denote a path to vertex $u$.
\begin{defn}[Dominance]
Let $\pi_u$ and $\tilde{\pi}_u$ be two paths to vertex $u$.
We say that $\pi_u$ \myemph{weakly dominates}~$\tilde{\pi}_u$ if
(i)~$c_1(\pi_u) \leq c_1(\tilde{\pi}_u)$ and
(ii)~$c_2(\pi_u) \leq c_2(\tilde{\pi}_u)$.
We say that~$\pi_u$ \myemph{strictly dominates}~$\tilde{\pi}_u$ if
(i)~$\pi_u$ {weakly dominates}~$\tilde{\pi}_u$ and
(ii)~$c_1(\pi_u) < c_1(\tilde{\pi}_u)$ or~$c_2(\pi_u) < c_2(\tilde{\pi}_u)$.
\end{defn}
\begin{defn}[Approximate dominance]
Let $\pi_u$ and $\tilde{\pi}_u$ be two paths to vertex $u$
and
let $\ensuremath{\varepsilon}\xspace_1 \geq 0$ and $\ensuremath{\varepsilon}\xspace_2 \geq 0$ be two real values.
We say that $\pi_u$ \myemph{$(\ensuremath{\varepsilon}\xspace_1,\ensuremath{\varepsilon}\xspace_2)$-dominates}~$\tilde{\pi}_u$ if
(i)~$c_1(\pi_u) \leq (1 + \ensuremath{\varepsilon}\xspace_1) \cdot c_1(\tilde{\pi}_u)$ and
(ii)~$c_2(\pi_u) \leq (1 + \ensuremath{\varepsilon}\xspace_2) \cdot c_2(\tilde{\pi}_u)$.
When $\ensuremath{\varepsilon}\xspace_1 = \ensuremath{\varepsilon}\xspace_2$, we will sometimes say that $\pi_u$ \myemph{$(\ensuremath{\varepsilon}\xspace_1)$-dominates}~$\tilde{\pi}_u$ and call $\ensuremath{\varepsilon}\xspace_1$ the \myemph{approximation factor}.
\end{defn}
\begin{defn}[(approximate) Pareto-optimal frontier]
The~\myemph{Pareto-optimal frontier} $\Pi_{u}$ of a vertex $u$ is a set of paths connecting ${\ensuremath{v_{\rm{start}}}\xspace}$ and~$u$ such that
(i)~no path in $\Pi_{u}$ is strictly dominated by any other path from ${\ensuremath{v_{\rm{start}}}\xspace}$ to $u$
and
(ii)~every path from ${\ensuremath{v_{\rm{start}}}\xspace}$ to $u$ is weakly dominated by a path in $\Pi_{u}$.
Similarly, for $\ensuremath{\varepsilon}\xspace_1 \geq 0$ and $\ensuremath{\varepsilon}\xspace_2 \geq 0$ the \myemph{approximate Pareto-optimal frontier}\footnote{Our definition of an approximate Pareto-optimal frontier slightly differs from existing definitions~\cite{breugem2017analysis} which do not require that the approximate Pareto frontier is a subset of the Pareto-optimal frontier.} $\Pi_{u}(\ensuremath{\varepsilon}\xspace_1,\ensuremath{\varepsilon}\xspace_2) \subseteq \Pi_u$ is a subset of $u$'s Pareto frontier such that every path in $\Pi_{u}$ is $(\ensuremath{\varepsilon}\xspace_1,\ensuremath{\varepsilon}\xspace_2)$-dominated by a path in $\Pi_{u}(\ensuremath{\varepsilon}\xspace_1,\ensuremath{\varepsilon}\xspace_2)$.
\end{defn}
\noindent
For brevity we will use the terms
(approximate) Pareto frontier
to refer to the
(approximate) Pareto-optimal frontier.
For a visualization of these notions, see Fig.~\ref{fig:dominance}.
\begin{figure}[tb]
\centering
\includegraphics[height=4.5cm]{Pareto2}
\caption{(approximate) Dominance and (approximate) Pareto frontier. Given start and target vertices, we consider each path $\pi_u$ as a 2D point $(c_1(\pi_u), c_2(\pi_u))$ according to the two cost functions (points and squares).
The set of all possible paths dominated and approximately dominated by path $\pi_u$ are depicted in blue and green, respectively (for $\varepsilon_1 = \varepsilon_2 = 1$). The Pareto frontier $\Pi_u$ is the set of all black points that collectively dominate all other possible paths (squares in grey region).
Finally, an approximate Pareto frontier $\Pi_u(1,1) = \{\pi_u, \tilde{\pi}_u \}$ is depicted by the two purple circles.}
\label{fig:dominance}
\end{figure}
We are now ready to formally define our search problems.
\begin{prob}[Bi-criteria shortest path]
\label{prob:1}
Let $G$ be a graph,
$c_1, c_2 : E \rightarrow \mathbb{R}$ two cost functions
and
${\ensuremath{v_{\rm{start}}}\xspace}$ and~${\ensuremath{v_{\rm{goal}}}\xspace}$ be start and goal vertices, respectively.
The \myemph{bi-criteria shortest path} problem calls for computing the Pareto frontier $\Pi_{{\ensuremath{v_{\rm{goal}}}\xspace}}$.
\end{prob}
\begin{prob}[Bi-criteria approximate shortest path]
\label{prob:2}
Let $G$ be a graph,
$c_1, c_2 : E \rightarrow \mathbb{R}$ two cost functions
and
${\ensuremath{v_{\rm{start}}}\xspace}$ and~${\ensuremath{v_{\rm{goal}}}\xspace}$ be start and goal vertices, respectively.
Given~$\ensuremath{\varepsilon}\xspace_1 \geq 0$ and $\ensuremath{\varepsilon}\xspace_2 \geq 0$, the \myemph{bi-criteria approximate shortest path} problem calls for computing an approximate Pareto frontier~$\Pi_{{\ensuremath{v_{\rm{goal}}}\xspace}}(\ensuremath{\varepsilon}\xspace_1, \ensuremath{\varepsilon}\xspace_2)$.
\end{prob}
\section{Algorithmic Background}
\label{sec:background}
In this section we describe two approaches to solve the bi-criteria shortest-path problem (Problem~\ref{prob:1}).
With the risk of being tedious, we start with a brief review of best-first search algorithms as both state-of-the-art bi-criteria shortest path algorithms, as well as ours, rely heavily on this algorithmic framework.
We note that the description of best-first search we present here can be optimized but this version will allow us to better explain the more advanced algorithms.
A best-first search algorithm (Alg.~\ref{alg:astar}) computes a shortest path from ${\ensuremath{v_{\rm{start}}}\xspace}$ to ${\ensuremath{v_{\rm{goal}}}\xspace}$ by maintaining a priority queue, called an OPEN list, that contains all the nodes that have not been expanded yet (line~\ref{alg:astar-line1}).
Each node is associated with a path $\pi_u$ from ${\ensuremath{v_{\rm{start}}}\xspace}$ to some vertex $u\in V$ (by a slight abuse of notation we will use paths and nodes interchangeability which will simplify algorithm's descriptions in the next sections).
This queue is ordered according to some cost function called the $f$-value of the node.
For example, in Dijkstra and \algname{A$^*$}, this is the computed cost from~${\ensuremath{v_{\rm{start}}}\xspace}$ (also called its $g$-value) and the computed cost from~${\ensuremath{v_{\rm{start}}}\xspace}$ added to the heuristic estimate to reach~${\ensuremath{v_{\rm{goal}}}\xspace}$, respectively.
At each iteration (lines~\ref{alg:astar-line3}-\ref{alg:astar-line13}),
the algorithm extracts the most-promising node from OPEN (line~\ref{alg:astar-line3}),
checks if it has the potential to be a better solution than any found so far (line~\ref{alg:astar-line4}).
If this is the case and we reached ${\ensuremath{v_{\rm{goal}}}\xspace}$, the solution set is updated (in single-criteria shortest path, once a solution is found, the search can be terminated).
If not, we extend the path represented by this node to each of it's neighbors (line~\ref{alg:astar-line10}).
Again, we check if it has the potential to be a better solution than any found so far (line~\ref{alg:astar-line11}).
If this is the case, it is added to the OPEN list.
Different single-criteria search algorithms such as Dijkstra, \algname{A$^*$}, \algname{A$^*_\eps$} as well as bi-criteria search algorithms such \algname{BOA$^*$} fall under this framework.
They differ with how OPEN is ordered and how the different functions (highlighted in Alg.~\ref{alg:astar}) are implemented.
\begin{algorithm}[t!]
\textbf{Input: ($G = (V,E), {\ensuremath{v_{\rm{start}}}\xspace}, {\ensuremath{v_{\rm{goal}}}\xspace}, \ldots$)}
\begin{algorithmic}[1]
\State {${\rm OPEN}\gets$ new node $\pi_{{\ensuremath{v_{\rm{start}}}\xspace}}$}
\label{alg:astar-line1}
\vspace{1mm}
\While{${\rm{OPEN}} \neq \emptyset$}
\State $\pi_u \gets$ \rm{OPEN{}.\func{extract\_min}}()
\label{alg:astar-line3}
\If {\func{is\_dominated}($\pi_u$) \label{alg:astar-line4}}
\State {\textbf{continue}}
\EndIf
\vspace{1mm}
\If {$u={\ensuremath{v_{\rm{goal}}}\xspace}$} \Comment{reached goal}
\State {\func{merge\_to\_solutions}($\pi_u$, solutions)}
\State {\textbf{continue}}
\EndIf
\vspace{1mm}
\For{$e=(u,v) \in$ {neighbors}($u, G$)}
\State $\pi_v \gets$ \func{extend}($\pi_u, e$)
\label{alg:astar-line10}
\If {\func{is\_dominated}($\pi_v $) \label{alg:astar-line11} }
\State {\textbf{continue}}
\EndIf
\vspace{1mm}
\State {\func{insert}($\pi_v , \rm{OPEN}$)}
\label{alg:astar-line13}
\EndFor
\EndWhile
\State{\textbf{return} all extreme paths in solutions}
\end{algorithmic}
\caption{Best First Search}
\label{alg:astar}
\end{algorithm}
\paragraph*{Bi-Objective \algname{A$^*$} (\algname{BOA$^*$})}
To efficiently solve Problem~\ref{prob:1},
bi-Objective \algname{A$^*$} (\algname{BOA$^*$}) runs a best-first search.
The algorithm is endowed with two heuristic functions $h_1, h_2$ estimating the cost to reach ${\ensuremath{v_{\rm{goal}}}\xspace}$ from any vertex
according to~$c_1$ and $c_2$, respectively.
Here, we assume that these heuristic functions are admissible and consistent.
This is key as the efficiency of \algname{BOA$^*$} relies on this assumption.
Given a node $\pi_u$, we define
$g_i(\pi_u)$ to be the computed distance according to $c_i$.
It can be easily shown that in best-first search algorithms $g_i := c_i(\pi_u)$.
Additionally, we define
$f_i(\pi_u) := g_i(\pi_u) + h_i(\pi_u)$.
Although the cost and the $g$-value of a path can be used interchangeably, we will use the former to describe general properties of paths and the latter to describe algorithm operations.
Nodes in OPEN are ordered lexicographically according to $(f_1, f_2)$ which concludes the description of how \func{extract\_min} and \func{insert} (lines~\ref{alg:astar-line3} and~\ref{alg:astar-line13}, respectively) are implemented.
Domination checks, which are typically time-consuming in bi-criteria search algorithms are implemented in $O(1)$ per node by maintaining for each vertex $u \in V$ the minimal cost to reach $u$ according to $c_2$ computed so far.
This value is maintained in a map $g_2^{\rm min}: V \rightarrow \mathbb{R}$ which is initialized to~$\infty$ for each vertex.
This allows to implement the function
\func{is\_dominated} for a node $\pi_u$ by testing
if
\begin{equation}
\label{eq:d00}
g_2(\pi_u) \geq g_2^{\rm min}(u)
\text{ or }
f_2(\pi_u) \geq g_2^{\rm min}({\ensuremath{v_{\rm{goal}}}\xspace}).
\end{equation}
The first test checks if the node is dominated by an already-extended node and replaces the CLOSED list typically used in \algname{A$^*$}-like algorithms.
The second test checks if the node has the potential to reach the goal with a solution whose cost is not dominated by any existing solution.
Finally, the function \func{merge\_to\_solutions} simply adds a newly-found solution to the solution set.
\paragraph{Computing the approximate Pareto frontier}
Perny and Spanjaard~\cite{perny2008near} suggest to compute an approximate Pareto frontier by endowing the algorithm with an approximation factor $\ensuremath{\varepsilon}\xspace$.
When a node is popped from OPEN, we test if its $f$-value is $\ensuremath{\varepsilon}\xspace$-dominated by any solution that was already computed.
While this algorithm was presented before \algname{BOA$^*$} and hence uses computationally-complex dominance checks, we can easily use this approach to adapt \algname{BOA$^*$} to compute an approximate Pareto frontier.
This is done by replacing the dominance check in Eq.~\ref{eq:d00} with the test
\begin{equation}
\label{eq:d0}
g_2(\pi_u) \geq g_2^{\rm min}(v) \text{ or }
(1 + \ensuremath{\varepsilon}\xspace) \cdot f_2(\pi_u) \geq g_2^{\rm min}({\ensuremath{v_{\rm{goal}}}\xspace}).
\end{equation}
We call this algorithm \algname{BOA$^*_\eps$}.
\section{Algorithmic Framework}
\subsection{Preliminaries}
Recall that (single-criteria) shortest-path algorithms such as \algname{A$^*$} find a solution by computing the shortest path to all nodes that have the potential to be on the shortest path to the goal (namely, whose $f$-value is less than the current estimate of the cost to reach ${\ensuremath{v_{\rm{goal}}}\xspace}$).
Similarly, bi-criteria search algorithms typically compute for each node the subset of the Pareto frontier that has the potential to be in~$\Pi_{{\ensuremath{v_{\rm{goal}}}\xspace}}$.
Now, near-optimal (single-criteria) shortest-path algorithms such as \algname{A$^*_\eps$}~\cite{pearl1982studies} attempt to speed up this process by only \myemph{approximating} the shortest path to intermediate nodes.
Similarly, we suggest to construct only an approximate Pareto frontier for intermediate nodes which, in turn, will allow to dramatically reduce computation times.
Looking at Fig.~\ref{fig:dominance}, one may suggest to run an \algname{A$^*$}-like search and if a path $\pi_u$ on the Pareto frontier $\Pi_{u}$ of $u$ is approximately dominated by another path $\tilde{\pi}_u \in \Pi_{u}$, then discard~$\pi_u$. Unfortunately, this does not account for paths in~$\Pi_{u}$ that may have been approximately dominated by $\pi_u$ and hence discarded in previous iterations of the search.
Existing methods use very conservative bounds to prune intermediate paths. For example, as stated in Sec.~\ref{sec:intro}, if a bound $L$ on the length of the longest path exists, we can use this strategy by replacing $(1 + \ensuremath{\varepsilon}\xspace)$ with $(1 + \ensuremath{\varepsilon}\xspace)^{1/L}$ to account for error propagation~\cite{perny2008near}.
\begin{figure}[tb]
\centering
\includegraphics[height=4.5cm]{ppf}
\caption{The partial Pareto frontier of two paths $\pi_u^{\texttt{tl}}$ and~$\pi_u^{\texttt{br}}$ is the set of all paths (blue dots) on the Pareto frontier (blue and black dots) between these paths.
Lemma~\ref{lem:ppf-dom} implies that any path represented by a blue dot is approximately dominated by $\pi_u^{\texttt{tl}}$ and $\pi_u^{\texttt{br}}$ for $
\ensuremath{\varepsilon}\xspace_1 =
\frac{c_1(\pi_u^{\texttt{br}}) - c_1(\pi_u^{\texttt{tl}})}{c_1(\pi_u^{\texttt{tl}})}
$
and
$
\ensuremath{\varepsilon}\xspace_2 =
\frac{c_2(\pi_u^{\texttt{tl}}) - c_2(\pi_u^{\texttt{br}})}{c_2(\pi_u^{\texttt{br}})}
$.}
\label{fig:ppf}
\end{figure}
In contrast, we suggest a simple-yet-effective method to prune away approximately-dominated solutions using the notion of a partial Pareto frontier which we now define.
\begin{defn}[Partial Pareto frontier {\small \ensuremath{\rm{PPF}}\xspace}]
Let $\pi_u^{\texttt{tl}}, \pi_u^{\texttt{br}} \in \Pi_{u}$ be two paths on the Pareto frontier of vertex $u$ such that $c_1(\pi_u^{\texttt{tl}}) < c_1 (\pi_u^{\texttt{br}})$
(here, \texttt{tl} and \texttt{br} are shorthands for ``top left'' and ``bottom right'' for reasons which will soon be clear).
Their \myemph{partial Pareto frontier}
${\small \ensuremath{\rm{PPF}}\xspace}_{u}^{\pi_u^{\texttt{tl}}, \pi_u^{\texttt{br}}} \subseteq \Pi_{u}$ is a subset of a Pareto frontier such that
if
$\pi_u \in \Pi_{u}$ and
$c_1(\pi_u^{\texttt{tl}}) < c_1 ({\pi}_u) < c_1 (\pi_u^{\texttt{br}})$
then
${\pi}_u \in {\small \ensuremath{\rm{PPF}}\xspace}_{u}^{\pi_u^{\texttt{tl}}, \pi_u^{\texttt{br}}}$. The paths
$\pi_u^{\texttt{tl}}, \pi_u^{\texttt{br}}$ are called the \myemph{extreme} paths of ${\small \ensuremath{\rm{PPF}}\xspace}_{u}^{\pi_u^{\texttt{tl}}, \pi_u^{\texttt{br}}}$
For a visualization, see Fig.~\ref{fig:ppf}.
\end{defn}
\begin{defn}[Bounded {\small \ensuremath{\rm{PPF}}\xspace}]
A {partial Pareto frontier}
${\small \ensuremath{\rm{PPF}}\xspace}_{u}^{\pi_u^{\texttt{tl}}, \pi_u^{\texttt{br}}} \subseteq \Pi_{u}$ is
\myemph{$(\ensuremath{\varepsilon}\xspace_1, \ensuremath{\varepsilon}\xspace_2)$-bounded}
if
$$
\ensuremath{\varepsilon}\xspace_1 \geq \frac{c_1(\pi_u^{\texttt{br}}) - c_1(\pi_u^{\texttt{tl}})}{c_1(\pi_u^{\texttt{tl}})}
\text{ and }
\ensuremath{\varepsilon}\xspace_2 \geq \frac{c_2(\pi_u^{\texttt{tl}}) - c_2(\pi_u^{\texttt{br}})}{c_2(\pi_u^{\texttt{br}})}.
$$
\end{defn}
\begin{lem}
\label{lem:ppf-dom}
If ${\small \ensuremath{\rm{PPF}}\xspace}_{u}^{\pi_u^{\texttt{tl}}, \pi_u^{\texttt{br}}}$
is an $(\ensuremath{\varepsilon}\xspace_1, \ensuremath{\varepsilon}\xspace_2)$-bounded partial Pareto frontier
then any path in ${\small \ensuremath{\rm{PPF}}\xspace}_{u}^{\pi_u^{\texttt{tl}}, \pi_u^{\texttt{br}}}$ is
$(\ensuremath{\varepsilon}\xspace_1, \ensuremath{\varepsilon}\xspace_2)$-dominated by both $\pi_u^{\texttt{tl}}$ and $\pi_u^{\texttt{br}}$.
\end{lem}
\begin{proof}
Let $\pi_u \in {\small \ensuremath{\rm{PPF}}\xspace}_{u}^{\pi_u^{\texttt{tl}}, \pi_u^{\texttt{br}}}$.
By definition, we have that
$c_1(\pi_u^{\texttt{tl}}) < c_1 (\pi_u)$
and that
$\ensuremath{\varepsilon}\xspace_1 \geq \frac{c_1(\pi_u^{\texttt{br}}) - c_1(\pi_u^{\texttt{tl}})}{c_1(\pi_u^{\texttt{tl}})}$.
Thus,
$$
c_1(\pi_u^{\texttt{br}}) \leq (1 + \ensuremath{\varepsilon}\xspace_1) \cdot c_1(\pi_u^{\texttt{tl}})
< (1 + \ensuremath{\varepsilon}\xspace_1) \cdot c_1(\pi_u).
$$
As $c_2(\pi_u^{\texttt{br}}) < c_2(\pi_u)$, we have that $\pi_u^{\texttt{br}}$ approximately dominates $\pi_u$.
Similarly,
by definition, we have that
$c_2 (\pi_u) > c_2 (\pi_u^{\texttt{br}})$
and that
$\ensuremath{\varepsilon}\xspace_2 \geq \frac{c_2(\pi_u^{\texttt{tl}}) - c_2(\pi_u^{\texttt{br}})}{c_2(\pi_u^{\texttt{br}})}$.
Thus,
$$
c_2(\pi_u^{\texttt{tl}}) \leq (1 + \ensuremath{\varepsilon}\xspace_2) \cdot c_1(\pi_u^{\texttt{br}})
< (1 + \ensuremath{\varepsilon}\xspace_2) \cdot c_1(\pi_u).
$$
As $c_1(\pi_u^{\texttt{tl}}) < c_1(\pi_u)$, we have that $\pi_u^{\texttt{tl}}$ approximately dominates $\pi_u$.
\end{proof}
\subsection{Algorithmic description}
\begin{figure*}[t]%
\centering
\subfloat[]{
\label{fig:extend}
\includegraphics[height=5cm]{extend2}
}
\qquad
\subfloat[]{
\label{fig:merge}
\includegraphics[height=5cm]{merge2}
}
\caption{Operations on path pairs.
\protect \subref{fig:extend}~Extend operation.
The path pair $(\pi_u^{\texttt{tl}}, \pi_u^{\texttt{br}})$ (blue) is extended by edge $e = (u,v)$ to obtain the path pair $(\pi_v^{\texttt{tl}}, \pi_v^{\texttt{br}})$ (green).
\protect \subref{fig:merge}~Merge operation. Two examples of merging the path pair $(\pi_u^{\texttt{tl}}, \pi_u^{\texttt{br}})$ (blue) with the path pair $(\tilde{\pi}_u^{\texttt{tl}}, \tilde{\pi}_u^{\texttt{br}})$ (green) to obtain the path pair $(\hat{\pi}_u^{\texttt{tl}}, \hat{\pi}_u^{\texttt{br}})$ (purple).
}
\label{fig:operations}
\end{figure*}
In contrast to standard search algorithms which incrementally construct shortest paths from ${\ensuremath{v_{\rm{start}}}\xspace}$ to the graph vertices, our algorithm will incrementally construct $(\ensuremath{\varepsilon}\xspace_1, \ensuremath{\varepsilon}\xspace_2)$-bounded partial Pareto frontiers.
Lemma~\ref{lem:ppf-dom} suggests a method to efficiently represent and maintain these frontiers for any approximation factors $\ensuremath{\varepsilon}\xspace_1$ and $\ensuremath{\varepsilon}\xspace_2$.
Specifically, for a vertex $u$, \algname{PP-A$^*$} will maintain \myemph{path pairs} corresponding to the extreme paths in partial Pareto frontiers.
For each path pair $(\pi_u^{\texttt{tl}}, \pi_u^{\texttt{br}})$
we have that
$c_1 (\pi_u^{\texttt{tl}}) \leq c_1(\pi_u^{\texttt{br}})$
and
$c_2 (\pi_u^{\texttt{tl}}) \geq c_2(\pi_u^{\texttt{br}})$.
Before we explain how path pairs will be used let us define operations on path pairs:
The first operation we consider is \myemph{extending} a
path pair $(\pi_u^{\texttt{tl}}, \pi_u^{\texttt{br}})$ by an edge $e = (u, v)$, which simply corresponds to extending
both $\pi_u^{\texttt{tl}}$ and $\pi_u^{\texttt{br}}$ by~$e$.
The second operation we consider is \myemph{merging} two
path pairs $(\pi_u^{\texttt{tl}}, \pi_u^{\texttt{br}})$ and $(\tilde{\pi}_u^{\texttt{tl}}, \tilde{\pi}_u^{\texttt{br}})$.
This operation constructs a new path pair $(\hat{\pi}_u^{\texttt{tl}}, \hat{\pi}_u^{\texttt{br}})$ such that
\begin{equation*}
\hat{\pi}_u^{\texttt{tl}} =
\begin{cases}
\pi_u^{\texttt{tl}} &~\text{if } c_1(\pi_u^{\texttt{tl}}) \leq c_1(\tilde{\pi}_u^{\texttt{tl}}) \\
\tilde{\pi}_u^{\texttt{tl}} &~\text{if } c_1(\tilde{\pi_u}^{\texttt{tl}}) < c_1(\pi_u^{\texttt{tl}}),
\end{cases}
\end{equation*}
and
\begin{equation*}
\hat{\pi}_u^{\texttt{br}} =
\begin{cases}
\pi_u^{\texttt{br}} &~\text{if } c_2(\pi_u^{\texttt{br}}) \leq c_2(\tilde{\pi}_u^{\texttt{br}}) \\
\tilde{\pi}_u^{\texttt{br}} &~\text{if } c_2(\tilde{\pi_u}^{\texttt{br}}) < c_2(\pi_u^{\texttt{br}}).
\end{cases}
\end{equation*}
For a visualization, see Fig.~\ref{fig:operations}.
We are finally ready to describe \algname{PP-A$^*$}, our algorithm for bi-criteria approximate shortest-path computation (Problem~\ref{prob:2}).
We run a best-first search similar to Alg.~\ref{alg:astar} but nodes are path pairs.
We start with the trivial path pair $({\ensuremath{v_{\rm{start}}}\xspace}, {\ensuremath{v_{\rm{start}}}\xspace})$ and describe our algorithm by detailing the different functions highlighted in Alg.~\ref{alg:astar}.
For each function, we describe what needs to be performed and how this can be efficiently implemented when consistent heuristics are used (see Sec.~\ref{sec:background}).
Finally, the pseudocode of the algorithm is provided in Alg.~\ref{alg:is} with the efficient implementations provided in Alg.~\ref{alg:is_dominated}-\ref{alg:merge-IS}.
\begin{algorithm}[t!]
\textbf{Input: ($G = (V,E), {\ensuremath{v_{\rm{start}}}\xspace}, {\ensuremath{v_{\rm{goal}}}\xspace}, c_1, c_2, h_1, h_2, \ensuremath{\varepsilon}\xspace_1, \ensuremath{\varepsilon}\xspace_2$)}
\begin{algorithmic}[1]
\State {solutions\_pp$\gets \emptyset$}
\Comment{path pairs }
\State {${\rm OPEN}\gets$ new path pair $({\ensuremath{v_{\rm{start}}}\xspace}, {\ensuremath{v_{\rm{start}}}\xspace})$}
\vspace{1mm}
\While{${\rm{OPEN}} \neq \emptyset$}
\State $(\pi_u^{\texttt{tl}}, \pi_u^{\texttt{br}}) \gets$ \rm{OPEN{}.\func{extract\_min}}()
\If {\func{is\_dominated\_\algname{PP-A$^*$}}($\pi_u^{\texttt{tl}}, \pi_u^{\texttt{br}}$)}
\State {\textbf{continue}}
\EndIf
\vspace{1mm}
\If {$u={\ensuremath{v_{\rm{goal}}}\xspace}$} \Comment{reached goal}
\State {\func{merge\_to\_solutions\_\algname{PP-A$^*$}}($\pi_u^{\texttt{tl}}, \pi_u^{\texttt{br}}$, solutions\_pp)}
\State {\textbf{continue}}
\EndIf
\vspace{1mm}
\For{$e=(u,v) \in$ {neighbors}($s(n), G$)}
\State $\left(\pi_v^{\texttt{tl}}, \pi_v^{\texttt{br}}\right) \gets$ \func{extend\_\algname{PP-A$^*$}}($(\pi_u^{\texttt{tl}}, \pi_u^{\texttt{br}}), e$)
\If {\func{is\_dominated\_\algname{PP-A$^*$}}($\pi_v^{\texttt{tl}}, \pi_v^{\texttt{br}}$)}
\State {\textbf{continue}}
\EndIf
\vspace{1mm}
\State {\func{insert\_\algname{PP-A$^*$}}($(\pi_v^{\texttt{tl}}, \pi_v^{\texttt{br}}), \rm{OPEN}$)}
\EndFor
\EndWhile
\State{solutions$\gets \emptyset$}
\For{$(\pi_{\ensuremath{v_{\rm{goal}}}\xspace}^{\texttt{tl}}, \pi_{\ensuremath{v_{\rm{goal}}}\xspace}^{\texttt{br}}) \in$ solutions\_pp}
\State solutions $\gets$ solutions $\cup\{ \pi_{\ensuremath{v_{\rm{goal}}}\xspace}^{\texttt{tl}} \}$
\EndFor
\State{\textbf{return} solutions}
\end{algorithmic}
\caption{\algname{PP-A$^*$}}
\label{alg:is}
\end{algorithm}
\paragraph{Ordering nodes in OPEN:}
Recall that a node is a path pair
$(\pi_u^{\texttt{tl}}, \pi_u^{\texttt{br}})$ and that each path $\pi$ has two $f$ values which correspond to the two cost functions and the two heuristic functions.
Nodes are ordered lexicographically according to
\begin{equation}
\label{eq:lexi}
\large(
f_1(\pi_u^{\texttt{tl}}),
f_2(\pi_u^{\texttt{br}})
\large).
\end{equation}
\paragraph{Domination checks:}
Recall that there are two types of domination checks that we wish to perform
(i)~checking if a node is dominated by a node that was already expanded
and
(ii)~checking if a node has the potential to reach the goal with a solution whose cost is not dominated by any existing solution.
In our setting a path pair
$\rm{PP}_u$
is dominated by another path pair
$\tilde{\rm{PP}}_u$
if the
partial Pareto frontier represented by $\rm{PP}_u$
is contained in the
partial Pareto frontier represented by $\tilde{\rm{PP}}_u$ (see Fig.~\ref{fig:ppf-dominates}).
We can efficiently test if
$\rm{PP}_u = (\pi_u^{\texttt{tl}}, \pi_u^{\texttt{br}})$
is dominated by any path to $u$ found so far, by checking if
\begin{equation}
\label{eq:d1}
g_2({\pi}_u^{\texttt{br}})
\geq
g_2^{\rm min}(u).
\end{equation}
This only holds when using the assumption that our heuristic functions are admissible and consistent and using the way we order our OPEN list.
\begin{figure}[tb]
\centering
\includegraphics[height=5cm]{ppf-dominates}
\caption{Testing dominance of partial Pareto frontiers using path pairs.
The partial Pareto frontier $\Pi_u^{\pi_u^{\texttt{tl}}, \pi_u^{\texttt{br}}}$
is contained in
the partial Pareto frontier $\Pi_u^{\tilde{\pi}_u^{\texttt{tl}}, \tilde{\pi}_u^{\texttt{br}}}$.
Thus, the region represented by
${\pi}_u^{\texttt{tl}}, {\pi}_u^{\texttt{br}}$
is contained in the region represented by
$\tilde{\pi}_u^{\texttt{tl}}, \tilde{\pi}_u^{\texttt{br}}$.
%
}
\label{fig:ppf-dominates}
\end{figure}
We now continue to describe how we test if a path pair has the potential to reach the goal with a solution whose cost is not dominated by any existing solution.
Given a path pair
$\rm{PP}_u = (\pi_u^{\texttt{tl}}, \pi_u^{\texttt{br}})$
a lower bound on the partial Pareto frontier at ${\ensuremath{v_{\rm{goal}}}\xspace}$ that can be attained via $\rm{PP}_u$ is obtained by adding the heuristic values to the costs of the two paths in $\rm{PP}_u$.
Namely,
we consider two paths $\pi_{{\ensuremath{v_{\rm{goal}}}\xspace}}^{\texttt{tl}}, \pi_{{\ensuremath{v_{\rm{goal}}}\xspace}}^{\texttt{br}}$ such that
$
c_i(\pi_{{\ensuremath{v_{\rm{goal}}}\xspace}}^{\texttt{tl}}):= c_i(\pi_u^{\texttt{tl}}) + h_i(u)
$
and
$
c_i(\pi_{{\ensuremath{v_{\rm{goal}}}\xspace}}^{\texttt{br}}):= c_i(\pi_u^{\texttt{br}}) + h_i(u)
$.
Note that these paths may not be attainable and are a lower bound on the partial Pareto frontier that can be obtained via~$\rm{PP}_u$.
Now, if the partial Pareto frontier
${\small \ensuremath{\rm{PPF}}\xspace}_{{\ensuremath{v_{\rm{goal}}}\xspace}}^{\pi_{{\ensuremath{v_{\rm{goal}}}\xspace}}^{\texttt{tl}}, \pi_{{\ensuremath{v_{\rm{goal}}}\xspace}}^{\texttt{br}}}$
is contained in the union of the currently-computed partial Pareto frontiers at ${\ensuremath{v_{\rm{goal}}}\xspace}$, then $\rm{PP}_u$ is dominated.
Similar to the previous dominance check, this can be efficiently implemented by testing if
\begin{equation}
\label{eq:d2}
(1 + \ensuremath{\varepsilon}\xspace_2) \cdot (f_2(\pi_u^{\texttt{br}})) \geq g_2^{\rm min}({\ensuremath{v_{\rm{goal}}}\xspace}).
\end{equation}
\paragraph{Inserting nodes in OPEN:}
Recall that we want to use the notion of path pairs to represent a partial Pareto frontier.
Key to the efficiency of our algorithm is to have every partial Pareto frontier as large as possible under the constraint that they are all $(\ensuremath{\varepsilon}\xspace_1, \ensuremath{\varepsilon}\xspace_2)$-bounded.
Thus, when coming to insert a path pair
$\rm{PP}_u$
into the OPEN list,
we check if there exists a path pair
$\rm{\tilde{PP}}_u$ such that
$\rm{PP}_u$ and $\rm{\tilde{PP}}_u$ can be merged and the resultant path pair is still $(\ensuremath{\varepsilon}\xspace_1, \ensuremath{\varepsilon}\xspace_2)$-bounded.
If this is the case, we remove $\rm{\tilde{PP}}_u$ and replace it with the merged path pair.
\paragraph{Merging solutions:}
Since we want to minimize the number of path pairs representing $\Pi_{\ensuremath{v_{\rm{goal}}}\xspace}(\ensuremath{\varepsilon}\xspace_1, \ensuremath{\varepsilon}\xspace_2)$ we suggest an optimization that operates similarly to node insertions.
When a new path pair $\rm{PP}_{\ensuremath{v_{\rm{goal}}}\xspace}$ representing a partial Pareto frontier at ${\ensuremath{v_{\rm{goal}}}\xspace}$ is obtained, we test if there exists a path pair in the solution set
$\rm{\tilde{PP}}_{\ensuremath{v_{\rm{goal}}}\xspace}$ such that
$\rm{PP}_u$ and $\rm{\tilde{PP}}_{\ensuremath{v_{\rm{goal}}}\xspace}$ can be merged and the resultant path pair is still $(\ensuremath{\varepsilon}\xspace_1, \ensuremath{\varepsilon}\xspace_2)$-bounded.
If this is the case, we remove $\rm{\tilde{PP}}_{\ensuremath{v_{\rm{goal}}}\xspace}$ and replace it with the merged path pair.
\paragraph{Returning solutions:}
Recall that our algorithm stores solutions as path pairs and not individual paths.
To return an approximate Pareto frontier, we simply return one path in each path pair.
Here, we arbitrarily choose to return $\pi_{\ensuremath{v_{\rm{goal}}}\xspace}^{\texttt{tl}}$ for each path pair $(\pi_{\ensuremath{v_{\rm{goal}}}\xspace}^{\texttt{tl}}, \pi_{\ensuremath{v_{\rm{goal}}}\xspace}^{\texttt{br}})$.
\begin{algorithm}[t!]
\textbf{Input:} ($\rm{PP}_u = (\pi_u^{\texttt{tl}}, \pi_u^{\texttt{br}})$)
\begin{algorithmic}[1]
\If{$(1 + \ensuremath{\varepsilon}\xspace_2) \cdot f_2(\pi_u^{\texttt{br}}) \geq g_2^{\rm min}
({\ensuremath{v_{\rm{goal}}}\xspace})$}
\State{\textbf{return} \texttt{true}}
\Comment{dominated by solution}
\EndIf
\If{$g_2({\pi}_u^{\texttt{br}})\geq g_2^{\rm min}(u)$}
\State{\textbf{return} \texttt{true}}
\Comment{dominated by existing path pair}
\EndIf
\State{\textbf{return} \texttt{false}}
\end{algorithmic}
\caption{is\_dominated\_\algname{PP-A$^*$}}
\label{alg:is_dominated}
\end{algorithm}
\begin{algorithm}[t!]
\textbf{Input:} ($\rm{PP}_u = (\pi_u^{\texttt{tl}}, \pi_u^{\texttt{br}}) , e = (u,v)$)
\begin{algorithmic}[1]
\State{$\pi_v^{\texttt{tl}} \gets $\func{extend}($\pi_u^{\texttt{tl}}$)}
\State{$\pi_v^{\texttt{br}} \gets $\func{extend}($\pi_u^{\texttt{br}}$)}
\State{\textbf{return} $(\pi_v^{\texttt{tl}}, \pi_v^{\texttt{br}})$}
\end{algorithmic}
\caption{extend\_\algname{PP-A$^*$}}
\label{alg:extendIS}
\end{algorithm}
\begin{algorithm}[t!]
\textbf{Input:} ($\rm{PP}_v$, OPEN)
\begin{algorithmic}[1]
\For{\textbf{each} path pair $\rm{\tilde{PP}}_v \in$ OPEN}
\State $\rm{PP}_v^{\rm merged} \gets $ merge($\rm{\tilde{PP}}_v, \rm{{PP}}_v $)
\If {$\rm{PP}_v^{\rm merged}$.is\_bounded($\ensuremath{\varepsilon}\xspace_1, \ensuremath{\varepsilon}\xspace_2$)}
\State OPEN.remove($\rm{\tilde{PP}}_v$)
\Comment{remove existing path pair}
\State OPEN.\func{insert}($\rm{PP}_v^{\rm merged}$)
\State \textbf{return}
\EndIf
\EndFor
\State OPEN.\func{insert}($\rm{PP}_v$)
\State{\textbf{return}}
\end{algorithmic}
\caption{insert\_\algname{PP-A$^*$}}
\label{alg:insertIS}
\end{algorithm}
\begin{algorithm}[t!]
\textbf{Input:} ($\rm{PP}_{{\ensuremath{v_{\rm{goal}}}\xspace}}$, solutions\_pp)
\begin{algorithmic}[1]
\For{\textbf{each} path pair $\rm{\tilde{PP}}_{{\ensuremath{v_{\rm{goal}}}\xspace}} \in$ solutions\_pp}
\State $\rm{PP}_{{\ensuremath{v_{\rm{goal}}}\xspace}}^{\rm merged} \gets $ merge($\rm{\tilde{PP}}_{{\ensuremath{v_{\rm{goal}}}\xspace}}, \rm{{PP}}_v $)
\If {$\rm{PP}_{{\ensuremath{v_{\rm{goal}}}\xspace}}^{\rm merged}$.is\_bounded($\ensuremath{\varepsilon}\xspace_1, \ensuremath{\varepsilon}\xspace_2$)}
\State solutions\_pp.remove($\rm{\tilde{PP}}_{{\ensuremath{v_{\rm{goal}}}\xspace}}$)
\State solutions\_pp.insert($\rm{PP}_{{\ensuremath{v_{\rm{goal}}}\xspace}}^{\rm merged}$)
\State \textbf{return}
\EndIf
\EndFor
\State solutions\_pp.insert($\rm{PP}_{{\ensuremath{v_{\rm{goal}}}\xspace}}$)
\State{\textbf{return}}
\end{algorithmic}
\caption{merge\_to\_solutions\_\algname{PP-A$^*$}}
\label{alg:merge-IS}
\end{algorithm}
\subsection{Analysis}
To show that \algname{PP-A$^*$} indeed computes an approximate Pareto frontier using the domination checks suggested in Eq.~\ref{eq:d1} and~\ref{eq:d2}, it will be useful to introduce the notion of a path pair's \myemph{apex} which represents a (possibly non-existent) path that dominates all paths represented by the path pair.
\begin{defn}
Let $\rm{PP}_u = (\pi_u^{\texttt{tl}}, \pi_u^{\texttt{br}})$ be a path pair.
Its apex is a two-dimensional point
$\ensuremath{\mathcal{A}}\xspace_u =
(
c_1(\pi_u^{\texttt{tl}}),
c_2(\pi_u^{\texttt{br}}
)$.
The $f$-value of the apex is
$(
c_1(\pi_u^{\texttt{tl}}) + h_1(u),
c_2(\pi_u^{\texttt{br}} + h_2(u)
)$
\end{defn}
If we (conceptually) replace each path pair used by \algname{PP-A$^*$} with its corresponding apex, we obtain an algorithm that is very similar to \algname{BOA$^*_\eps$}.
%
Specifically, both algorithms
(i)~order nodes / apexes in the OPEN list lexicographically,
(ii)~update $g_2^{\rm {min}}(u)$ for each vertex $u$ when a node / apex is popped if $g_2 < g_2^{\rm {min}}(u)$ where~$g_2$ is the $c_2$-cost of the node / apex
and
(iii)~prune a node / apex using the same condition (notice that Eq.~\ref{eq:d0} is identical to Eq~\ref{eq:d1} and~\ref{eq:d2}).
The main difference is that \algname{PP-A$^*$} also merges path pairs.
This turns the search tree into a directed acyclic graph (DAG).
Now we can easily adapt several Lemmas described in~\cite{UYBZSK20}\footnote{When adapting the Lemmas used in~\cite{UYBZSK20}, we mention the corresponding Lemma number. Furthermore, to ease a reader interested in comparing the Lemmas and the corresponding proofs, when possible, we use the same notation and even the same words. This was done after obtaining permission from the authors in~\cite{UYBZSK20}.}:
\begin{lem}[Corresponding to Lemma~1 in~\cite{UYBZSK20}]
\label{lem:1}
After extending an apex, the new apex has $f_1$- and $f_2$-values that are no smaller than the $f_1$- and $f_2$-values, respectively, of the generating apex.
\end{lem}
The proof is identical to Lemma~1 in~\cite{UYBZSK20}.
However, it is important to note that an apex can also be created by merging two existing apexes. Here, it is not clear which is the ``parent'' apex and the Lemma does not necessarily hold.
However, we can state the following straightforward obsrevation:
\begin{observation}
\label{obs:1}
Let $\ensuremath{\mathcal{A}}\xspace_u^{\rm merged}$ by the apex resulting from a merge operation between $\ensuremath{\mathcal{A}}\xspace_u^1$ and $\ensuremath{\mathcal{A}}\xspace_u^2$.
Then, the $f_1$- and $f_2$-values of $\ensuremath{\mathcal{A}}\xspace_u^{\rm merged}$ cannot be smaller than the $f_1$- and $f_2$-values of both of $\ensuremath{\mathcal{A}}\xspace_u^1$ and $\ensuremath{\mathcal{A}}\xspace_u^2$.
Specifically,
$$
f_1(\ensuremath{\mathcal{A}}\xspace_u^{\rm merged}) = \min (f_1(\ensuremath{\mathcal{A}}\xspace_u^1),f_1( \ensuremath{\mathcal{A}}\xspace_u^2)),
$$
and
$$
f_2(\ensuremath{\mathcal{A}}\xspace_u^{\rm merged}) = \min (f_2(\ensuremath{\mathcal{A}}\xspace_u^1), f_2(\ensuremath{\mathcal{A}}\xspace_u^2)).
$$
\end{observation}
\begin{lem}[Corresponding to Lemma~2 in~\cite{UYBZSK20}]
\label{lem:2}
The sequences of extracted and expanded apexes have monotonically non-decreasing $f_1$-values.
\end{lem}
\begin{proof}
An apex extracted by \algname{PP-A$^*$} from the OPEN list has the smallest $f_1$-value among of all apexes in the Open list.
Since generated apexes that are
added to the Open list have $f_1$-values that are no smaller than those of their expanded parent apexes (Lemma~\ref{lem:1}) and an apex resulting from a merge operation cannot have an $f_1$-value smaller than the $f_1$- value of both of the merged apexes (Obs~\ref{obs:1}), the sequence of extracted apexes has monotonically non-decreasing $f_1$-values.
\end{proof}
\begin{lem}[Corresponding to Lemma~3 in~\cite{UYBZSK20}]
\label{lem:3}
The sequences of extracted apexes with the same state has strictly monotonically decreasing $f_2$-values.
\end{lem}
The proof is identical to Lemma~3 in~\cite{UYBZSK20}.
\begin{lem}[Corresponding to Lemma~6 in~\cite{UYBZSK20}]
\label{lem:6}
If
apex $\ensuremath{\mathcal{A}}\xspace_u^1$
is weakly dominated by
apex $\ensuremath{\mathcal{A}}\xspace_u^2$,
then each apex at ${\ensuremath{v_{\rm{goal}}}\xspace}$ in
the subtree of the search tree rooted at $\ensuremath{\mathcal{A}}\xspace_u^1$
(when no merge operations are performed in the subtree) is weakly
dominated by an apex at ${\ensuremath{v_{\rm{goal}}}\xspace}$ in the DAG rooted
at $\ensuremath{\mathcal{A}}\xspace_u^2$
(even when merge operations are performed).
\end{lem}
\begin{proof}
Since apex $\ensuremath{\mathcal{A}}\xspace_u^1$
is weakly dominated by
apex $\ensuremath{\mathcal{A}}\xspace_u^2$,
$g_1(\ensuremath{\mathcal{A}}\xspace_u^1) \leq g_1(\ensuremath{\mathcal{A}}\xspace_u^2)$
(here, given apex $\ensuremath{\mathcal{A}}\xspace = (p_1,p_2)$ we define $g_i(\ensuremath{\mathcal{A}}\xspace): = p_i$ corresponding to the $g$-value of nodes in standard \algname{A$^*$}-like algorithms).
Assume that $\ensuremath{\mathcal{A}}\xspace_{{\ensuremath{v_{\rm{goal}}}\xspace}}^3$ is an apex at the goal in the subtree of the search tree rooted at~$\ensuremath{\mathcal{A}}\xspace_u^1$ (when no merge operations are performed).
Let the sequence of vertices of the apexes along a branch of the search tree from the root apex to $\ensuremath{\mathcal{A}}\xspace_u^1$ be
$u_1, \ldots u_i$
(with $u_1 = {\ensuremath{v_{\rm{start}}}\xspace}$ and $u_i = u$).
Similarly, let the sequence of vertices of the apexes along a branch of the DAG from the root apex to $\ensuremath{\mathcal{A}}\xspace_u^2$ be
$u_1', \ldots u_j'$
(with $u_1' = {\ensuremath{v_{\rm{start}}}\xspace}$ and $u_j' = u$).
Finally, let the sequence of vertices of the apexes along a branch of the search tree from $\ensuremath{\mathcal{A}}\xspace_u^1$ to $\ensuremath{\mathcal{A}}\xspace_{{\ensuremath{v_{\rm{goal}}}\xspace}}^3$ be
$\pi = u_i, \ldots u_k$
(with $u_k = {\ensuremath{v_{\rm{goal}}}\xspace}$).
Then, there is an apex $\ensuremath{\mathcal{A}}\xspace_{{\ensuremath{v_{\rm{goal}}}\xspace}}^4$ at the goal in the DAG rooted at apex $\ensuremath{\mathcal{A}}\xspace_u^2$ such that the sequence of vertices of the apexes along a branch of the DAG from
the root apex to~$\ensuremath{\mathcal{A}}\xspace_{{\ensuremath{v_{\rm{goal}}}\xspace}}^4$ is
$u_1', \ldots u_j', u_{i+1}, \ldots ,u_k$.
Since
$g_1(\ensuremath{\mathcal{A}}\xspace_u^1) \leq g_1(\ensuremath{\mathcal{A}}\xspace_u^2)$, it follows that
\begin{align*}
g_1(\ensuremath{\mathcal{A}}\xspace_{{\ensuremath{v_{\rm{goal}}}\xspace}}^4)
~= &~
g_1(\ensuremath{\mathcal{A}}\xspace_u^2)+c_1(\pi) \\
~\leq &~
g_1(\ensuremath{\mathcal{A}}\xspace_u^1) + c_1(\pi) \\
~= &~ g_1(\ensuremath{\mathcal{A}}\xspace_{{\ensuremath{v_{\rm{goal}}}\xspace}}^3).
\end{align*}
Thus,
$g_1(\ensuremath{\mathcal{A}}\xspace_{{\ensuremath{v_{\rm{goal}}}\xspace}}^4) \leq g_1(\ensuremath{\mathcal{A}}\xspace_{{\ensuremath{v_{\rm{goal}}}\xspace}}^3)$.
Following similar lines yields that
$g_2(\ensuremath{\mathcal{A}}\xspace_{{\ensuremath{v_{\rm{goal}}}\xspace}}^4) \leq g_2(\ensuremath{\mathcal{A}}\xspace_{{\ensuremath{v_{\rm{goal}}}\xspace}}^3)$.
Thus, $\ensuremath{\mathcal{A}}\xspace_{{\ensuremath{v_{\rm{goal}}}\xspace}}^4$ weakly dominates $\ensuremath{\mathcal{A}}\xspace_{{\ensuremath{v_{\rm{goal}}}\xspace}}^3$.
\end{proof}
The following Lemma concludes the building blocks we will need to prove that \algname{PP-A$^*$} computes an approximate Pareto frontier. However, it can be easily adapted to show that \algname{BOA$^*$} also computes an approximate Pareto frontier.
\begin{lem}[Corresponding to Lemma~7 in~\cite{UYBZSK20}]
\label{lem:7}
When \algname{PP-A$^*$} prunes an apex $\ensuremath{\mathcal{A}}\xspace_u^1$ at state $u$ and this prevents it in the future from adding an apex $\ensuremath{\mathcal{A}}\xspace_{{\ensuremath{v_{\rm{goal}}}\xspace}}^2$ (at the goal state) to the solution set, then it can still add in the future an apex (with the goal state) that approximately dominates apex $\ensuremath{\mathcal{A}}\xspace_{{\ensuremath{v_{\rm{goal}}}\xspace}}^2$.
\end{lem}
\begin{proof}
We prove the statement by induction on the number of pruned apexes so far, including apex $\ensuremath{\mathcal{A}}\xspace_u^1$. If the
number of pruned apexes is zero, then the lemma trivially
holds. Now assume that the number of pruned apexes is $n+1$ and the lemma holds for $n \geq 0$. We distinguish three cases:
\begin{itemize}
\item[\textbf{C1}]
\label{case:1}
\algname{PP-A$^*$} prunes apex $\ensuremath{\mathcal{A}}\xspace_u^1$ on line~5 because of the first
pruning condition (Eq.~\ref{eq:d1}):
Then, \algname{PP-A$^*$} has expanded an apex~$\ensuremath{\mathcal{A}}\xspace_u^4$ at state $u$ previously such that
$g_2^{\rm {min}}(u) = g_2(\ensuremath{\mathcal{A}}\xspace_u^4)$
since otherwise
$g_2^{\rm {min}}(u) = \infty$
and the pruning condition could not hold.
Combining both (in)equalities yields
$g_2(\ensuremath{\mathcal{A}}\xspace_u^1) \geq g_2(\ensuremath{\mathcal{A}}\xspace_u^4)$.
Since
$f_1(\ensuremath{\mathcal{A}}\xspace_u^1) \geq f_1(\ensuremath{\mathcal{A}}\xspace_u^4)$
(Lemma~\ref{lem:2}),
\begin{align*}
g_1(\ensuremath{\mathcal{A}}\xspace_{u}^1) + h_1(u)
~= &~
f_1(\ensuremath{\mathcal{A}}\xspace_u^1) \\
~\geq &
f_1(\ensuremath{\mathcal{A}}\xspace_u^4) \\
~= &~
g_1(\ensuremath{\mathcal{A}}\xspace_{u}^4) + h_1(u).
\end{align*}
Thus
$g_1(\ensuremath{\mathcal{A}}\xspace_{u}^1) \geq g_1(\ensuremath{\mathcal{A}}\xspace_{u}^4)$.
Combining both inequalities yields that apex $\ensuremath{\mathcal{A}}\xspace_{u}^1$ is weakly dominated by apex $\ensuremath{\mathcal{A}}\xspace_{u}^4$ and thus each apex at ${\ensuremath{v_{\rm{goal}}}\xspace}$ in the subtree rooted at $\ensuremath{\mathcal{A}}\xspace_{u}^1$, including~$\ensuremath{\mathcal{A}}\xspace_{{\ensuremath{v_{\rm{goal}}}\xspace}}^2$, is weakly dominated (and hence approximately dominated) by an apex $\ensuremath{\mathcal{A}}\xspace_{{\ensuremath{v_{\rm{goal}}}\xspace}}^5$ in the subtree rooted at apex $\ensuremath{\mathcal{A}}\xspace_{u}^4$ (Lemma~\ref{lem:6}).
In case \algname{PP-A$^*$} has pruned an apex that prevents it in the future from adding apex $\ensuremath{\mathcal{A}}\xspace_{u}^5$ to the solution set, then it can still add in the future an apex
(at the goal state) that approximately dominates~$\ensuremath{\mathcal{A}}\xspace_{u}^5$ and thus also apex $\ensuremath{\mathcal{A}}\xspace_{u}^2$ (induction assumption).
\item[\textbf{C2}]
\label{case:2}
\algname{PP-A$^*$} prunes apex $\ensuremath{\mathcal{A}}\xspace_u^1$ on line~5 because of the second
pruning condition (Eq.~\ref{eq:d2}):
Then, \algname{PP-A$^*$} has expanded an apex $\ensuremath{\mathcal{A}}\xspace_{{\ensuremath{v_{\rm{goal}}}\xspace}}^4$ with the goal state previously such that
$g_2^{\rm {min}}({\ensuremath{v_{\rm{goal}}}\xspace}) = g_2(\ensuremath{\mathcal{A}}\xspace_{{\ensuremath{v_{\rm{goal}}}\xspace}}^4)$
since otherwise
$g_2^{\rm {min}}({\ensuremath{v_{\rm{goal}}}\xspace}) = \infty$
and the pruning condition could not hold.
Combining both (in)equalities yields that
$(1 + \ensuremath{\varepsilon}\xspace_2) \cdot f_2(\ensuremath{\mathcal{A}}\xspace_u^1) \geq g_2(\ensuremath{\mathcal{A}}\xspace_{{\ensuremath{v_{\rm{goal}}}\xspace}}^4)$.
Since $\ensuremath{\mathcal{A}}\xspace_u^1$ is an ancestor of $\ensuremath{\mathcal{A}}\xspace_{{\ensuremath{v_{\rm{goal}}}\xspace}}^2$ in the search tree,
$f_2(\ensuremath{\mathcal{A}}\xspace_{{\ensuremath{v_{\rm{goal}}}\xspace}}^2) \geq f_2(\ensuremath{\mathcal{A}}\xspace_u^1)$ (Lemma~\ref{lem:1}).
Combining both inequalities yields
$g_2(\ensuremath{\mathcal{A}}\xspace_{{\ensuremath{v_{\rm{goal}}}\xspace}}^2) = f_2(\ensuremath{\mathcal{A}}\xspace_{{\ensuremath{v_{\rm{goal}}}\xspace}}^2) \geq g_2(\ensuremath{\mathcal{A}}\xspace_{{\ensuremath{v_{\rm{goal}}}\xspace}}^4) / (1 + \ensuremath{\varepsilon}\xspace_2)$.
Since $\ensuremath{\mathcal{A}}\xspace_{u}^1$ is an ancestor of $\ensuremath{\mathcal{A}}\xspace_{{\ensuremath{v_{\rm{goal}}}\xspace}}^2$ in the search tree,
$g_1(\ensuremath{\mathcal{A}}\xspace_{{\ensuremath{v_{\rm{goal}}}\xspace}}^1) = f_1(\ensuremath{\mathcal{A}}\xspace_{{\ensuremath{v_{\rm{goal}}}\xspace}}^2) \geq f_1(\ensuremath{\mathcal{A}}\xspace_u^1)$ (Lemma~\ref{lem:1}).
Since $f_1(\ensuremath{\mathcal{A}}\xspace_u^1) \geq f_1(\ensuremath{\mathcal{A}}\xspace_{{\ensuremath{v_{\rm{goal}}}\xspace}}^4)$ (Lemma~\ref{lem:2}), it follows that
$g_1(\ensuremath{\mathcal{A}}\xspace_{{\ensuremath{v_{\rm{goal}}}\xspace}}^2) \geq f_1(\ensuremath{\mathcal{A}}\xspace_u^1) \geq f_1(\ensuremath{\mathcal{A}}\xspace_{{\ensuremath{v_{\rm{goal}}}\xspace}}^4) = g_1(\ensuremath{\mathcal{A}}\xspace_{{\ensuremath{v_{\rm{goal}}}\xspace}}^4)$.
Combining
$g_1(\ensuremath{\mathcal{A}}\xspace_{{\ensuremath{v_{\rm{goal}}}\xspace}}^2) \geq g_1(\ensuremath{\mathcal{A}}\xspace_{{\ensuremath{v_{\rm{goal}}}\xspace}}^4)$
and
$g_2(\ensuremath{\mathcal{A}}\xspace_{{\ensuremath{v_{\rm{goal}}}\xspace}}^2) \geq g_2(\ensuremath{\mathcal{A}}\xspace_{{\ensuremath{v_{\rm{goal}}}\xspace}}^4) / (1 + \ensuremath{\varepsilon}\xspace_2)$.
yields that
$\ensuremath{\mathcal{A}}\xspace_{{\ensuremath{v_{\rm{goal}}}\xspace}}^2$
is approximately dominated by
$\ensuremath{\mathcal{A}}\xspace_{{\ensuremath{v_{\rm{goal}}}\xspace}}^4$.
In case \algname{PP-A$^*$} has pruned an apex that prevents it in the future from adding $\ensuremath{\mathcal{A}}\xspace_{{\ensuremath{v_{\rm{goal}}}\xspace}}^4$ to the solution set, then it can still add in the future an apex that approximately dominates $\ensuremath{\mathcal{A}}\xspace_{{\ensuremath{v_{\rm{goal}}}\xspace}}^4$ and thus also $\ensuremath{\mathcal{A}}\xspace_{{\ensuremath{v_{\rm{goal}}}\xspace}}^2$(induction assumption).
\item[\textbf{C3}]
\algname{PP-A$^*$} prunes apex $\ensuremath{\mathcal{A}}\xspace_u^1$ on line~12 because of either the first or the second pruning condition (Eq.~\ref{eq:d1} or~\ref{eq:d2}):
The proofs of Case~\textbf{C1} or Case~\textbf{C2}, respectively, apply unchanged except that
$f_1(\ensuremath{\mathcal{A}}\xspace_u^1) \geq f_1(\ensuremath{\mathcal{A}}\xspace_{{\ensuremath{v_{\rm{goal}}}\xspace}}^4)$
now holds for a different reason.
Let $\ensuremath{\mathcal{A}}\xspace_v^3$ be the apex that \algname{PP-A$^*$} expands when it executes Line 12.
Combining
$f_1(\ensuremath{\mathcal{A}}\xspace_u^1) \geq f_1(\ensuremath{\mathcal{A}}\xspace_v^3)$ (Lemma~\ref{lem:1}) and $f_1(\ensuremath{\mathcal{A}}\xspace_v^3) \geq f_1(\ensuremath{\mathcal{A}}\xspace_{{\ensuremath{v_{\rm{goal}}}\xspace}}^4)$ (Lemma~\ref{lem:2}) yields
$f_1(\ensuremath{\mathcal{A}}\xspace_u^1) \geq f1(\ensuremath{\mathcal{A}}\xspace_{{\ensuremath{v_{\rm{goal}}}\xspace}}^4)$.
\end{itemize}
\end{proof}
Lemma~\ref{lem:7} states that all solutions in the partial Pareto frontier captured by a path pair that was pruned by \algname{PP-A$^*$} are approximately dominated by an apex of a path pair that was used as a solution.
Combining this with the fact that all path pairs are $(\ensuremath{\varepsilon}\xspace_1, \ensuremath{\varepsilon}\xspace_2)$-bounded by constructed we obtain the following Corollary.
\begin{cor}
Given a Bi-criteria approximate shortest path (Problem~\ref{prob:2}), \algname{PP-A$^*$} returns an approximate Pareto frontier.
\end{cor}
\ignore{
To show that \algname{PP-A$^*$} indeed computes a approximate Pareto frontier we start by stating the following simple-yet-important observations:
\begin{observation}
\label{obs:pp-valid}
If
$\rm{PP}_u $ is a path pair generated by \algname{PP-A$^*$} (either by extending an existing path pair or by merging two existing path pairs)
then $\rm{PP}_u$ is $(\ensuremath{\varepsilon}\xspace_1, \ensuremath{\varepsilon}\xspace_2)$-bounded.
\end{observation}
\begin{observation}
\label{obs:ppa-valid}
If \algname{PP-A$^*$} prunes a path pair $\rm{PP}_u $ such that any path that is approximately dominated by the $\rm{PP}_u $ is is a path pair generated by \algname{PP-A$^*$} (either by extending an existing path pair or by merging two existing path pairs)
then $\rm{PP}_u$ is $(\ensuremath{\varepsilon}\xspace_1, \ensuremath{\varepsilon}\xspace_2)$-bounded.
\end{observation}
To show that we indeed can use the $O(1)$ dominance test suggested by Hernandez et al. we can use exactly the same reasoning.
Specifically, Hernandez et al. show that (LX and TY refers to Lemma X and Theorem Y in~\cite{UYBZSK20}, respectively).
\begin{itemize}
\item[L1] Each generated node $n$ has $f_1$- and $f_2$-values that are no smaller than the $f_1$- and $f_2$-values-values, respectively, of its parent node $p$.
\item[L2] The sequences of extracted nodes and of expanded nodes have monotonically non-decreasing $f_1$-values.
\item[L3] The sequence of expanded nodes with the same state has strictly monotonically decreasing $f_2$-values.
\item[L4] The sequence of expanded nodes with the same state has strictly monotonically increasing $f_1$-values.
\item[L5] Expanded nodes with the same state do not weakly dominate each other.
\item[L6] If node $n_1$ with state $u$ is weakly dominated by node $n_2$ with state $u$, then each node with the goal state in the subtree of the search tree rooted at node $n_1$ is weakly dominated by a node with the goal state in the subtree rooted at node $n_2$.
\item[L7] When \algname{BOA$^*$} prunes a node $n_1$ with state $u$ and this prevents it in the future from adding a node $n_2$ (with the goal state) to the solution set, then it can still add in the future a node (with the goal state) that weakly dominates node~$n_2$.
\item[T2] \algname{BOA$^*$} computes a cost-unique Pareto-optimal solution set.
\end{itemize}
Each of the above Lemmas and Theorem can be easily adapted to our setting where we order nodes in the open list according to Eq.~\ref{eq:lexi}.
Before we do this, we mention this simple-yet-important property of path pairs:
\begin{prop}
\label{prop:pp}
Let
$\rm{PP}_u = (\pi_u^{\texttt{tl}}, \pi_u^{\texttt{br}})$ be a path pair then
$$f_1(\pi_u^{\texttt{tl}}) \leq f_1(\pi_u^{\texttt{br}})$$
and
$$f_2(\pi_u^{\texttt{tl}}) \geq f_2(\pi_u^{\texttt{br}}).$$
In addition, $\pi_u^{\texttt{tl}}$ \myemph{cannot} strictly dominate $\pi_u^{\texttt{br}}$.
\end{prop}
We are now ready to describe the adapted Lemmas:
\begin{lem}[Corresponding to Lemma~1 in~\cite{UYBZSK20}]
\label{lem:1}
Each path in each generated path pair \rm{PP} has $f_1$- and $f_2$-values that are no smaller than the $f_1$- and $f_2$-values-values, respectively, of their respective parents in the path pair that generated \rm{PP}.
\end{lem}
\begin{proof}
Let
$\rm{PP}_v = (\pi_v^{\texttt{tl}}, \pi_v^{\texttt{br}})$ be a path pair generated by extending the path pair
$\rm{PP}_u = (\pi_u^{\texttt{tl}}, \pi_u^{\texttt{br}})$.
Since the $h-$ values are consistent,
$$
c_1(\pi_u^{\texttt{tl}},
\pi_v^{\texttt{tl}})
+
h_1(\pi_v^{\texttt{tl}})
\geq
h_1(\pi_u^{\texttt{tl}}).
$$
Thus,
\begin{align*}
f_1( \pi_v^{\texttt{tl}})
~= &~
c_1(\pi_v^{\texttt{tl}}) + h_1(\pi_v^{\texttt{tl}}) \\
~= &~
c_1(\pi_u^{\texttt{tl}}) +
c_1(\pi_u^{\texttt{tl}},
\pi_v^{\texttt{tl}})
+
h_1(\pi_v^{\texttt{tl}}) \\
~\geq &~
c_1(\pi_u^{\texttt{tl}}) +
h_1(\pi_u^{\texttt{tl}}) \\
~= &~
f_1( \pi_u^{\texttt{tl}})
\end{align*}
A similar proof holds for yields that
$f_1( \pi_v^{\texttt{br}}) \geq f_1( \pi_u^{\texttt{br}})$,
$f_2( \pi_v^{\texttt{tl}}) \geq f_2( \pi_u^{\texttt{tl}})$,
and that
$f_2( \pi_v^{\texttt{br}}) \geq f_2( \pi_u^{\texttt{br}})$.
\end{proof}
\begin{lem}[Corresponding to Lemma~2 in~\cite{UYBZSK20}]
\label{lem:2}
The sequences of extracted path pairs and of expanded path pairs have monotonically non-decreasing $f_1$-values of their top-left paths.
\end{lem}
\begin{proof}
\algname{PP-A$^*$} extracts the path pair from the Open list according to Eq.~\ref{eq:lexi}.
Thus, an extracted path pair has the smallest $f_1$-value of its top-left path
of all nodes in the Open list.
Since generated path pairs that are
added to the Open list have $f_1$-values that are no smaller than those of their expanded parent nodes (Lemma~\ref{lem:1}), the sequence of extracted nodes has monotonically non-decreasing $f_1$-values of their top-left path.
\end{proof}
\begin{lem}[Corresponding to Lemma~3 in~\cite{UYBZSK20}]
\label{lem:3}
The sequences of extracted path pairs with the same state has strictly monotonically decreasing $f_2$-values of their bottom-right paths.
\end{lem}
\begin{proof}
Assume for a proof by contradiction that
\algname{PP-A$^*$} expands path pair
$\rm{PP}_u = (\pi_u^{\texttt{tl}}, \pi_u^{\texttt{br}})$
before path pair
$\tilde{\rm{PP}}_u = (\tilde{\pi}_u^{\texttt{tl}}, \tilde{\pi}_u^{\texttt{br}})$, that it expands no path pair with state $u$ after $\rm{PP}_u$ and before $\tilde{\rm{PP}}_u$,
and that
$f_2(\pi_u^{\texttt{br}}) \leq f_2(\tilde{\pi}_u^{\texttt{br}})$.
Then,
$$
c_2(\pi_u^{\texttt{br}}) + h_2(u) = f_2(\pi_u^{\texttt{br}})
\leq
f_2(\tilde{\pi}_u^{\texttt{br}}) = c_2(\tilde{\pi}_u^{\texttt{br}}) + h_2(u).
$$
Thus,
$c_2(\pi_u^{\texttt{br}}) \leq c_2(\tilde{\pi}_u^{\texttt{br}})$.
After $\rm{PP}_u$ is expanded and before
$\tilde{\rm{PP}}_u$ is expanded, $g_2^{\rm{min}}(u) = c_2(\pi_u^{\texttt{br}})$.
Combining both (in)equalities yields that
$g_2^{\rm{min}}(u) \leq c_2(\pi_u^{\texttt{br}})$ which means that $\tilde{\rm{PP}}_u$ is not expanded, contradicting the assumption.
\end{proof}
\begin{lem}[Corresponding to Lemma~4 in~\cite{UYBZSK20}]
\label{lem:4}
The sequences of extracted path pairs with the same state has strictly monotonically increasing $f_1$-values of their top-left paths.
\end{lem}
\begin{proof}
Since the sequence of expanded path pairs has
monotonically non-decreasing $f_1$-values of their top left path (Lemma~\ref{lem:2}), the sequence of expanded path pairs with the same state also has monotonically non-decreasing $f_1$-values of their top left path.
Assume for a proof by contradiction that \algname{PP-A$^*$} expands path pair $\rm{PP}_u = (\pi_u^{\texttt{tl}}, \pi_u^{\texttt{br}})$
before path pair
$\tilde{\rm{PP}}_u = (\tilde{\pi}_u^{\texttt{tl}}, \tilde{\pi}_u^{\texttt{br}})$, that it expands no path pair with state $u$ after $\rm{PP}_u$ and before $\tilde{\rm{PP}}_u$, and that
$f_1(\pi_u^{\texttt{tl}}) = f_1(\tilde{\pi}_u^{\texttt{tl}})$.
We distinguish two cases:
\begin{itemize}
\item[\textbf{C1}]
Path pair $\tilde{\rm{PP}}_u$ is in the Open list when \algname{PP-A$^*$} expands path pair ${\rm{PP}}_u$:
In this case ${\rm{PP}}_u$ and $\tilde{\rm{PP}}_u$ would be merged (such a merge is always valid regardless of the values of $\ensuremath{\varepsilon}\xspace_1$ and $\ensuremath{\varepsilon}\xspace_2$) which contradicts the fact that $\tilde{\rm{PP}}_u$ was expanded.
\item[\textbf{C2}]
Path pair $\tilde{\rm{PP}}_u$ is not in the Open list when \algname{PP-A$^*$} expands path pair ${\rm{PP}}_u$:
\algname{PP-A$^*$} generates $\tilde{\rm{PP}}_u$ after it expands ${\rm{PP}}_u$. Thus, there is a node ${\rm{PP}}_v$ in the Open list when \algname{PP-A$^*$} expands ${\rm{PP}}_u$ that is expanded after
${\rm{PP}}_u$ and before $\tilde{\rm{PP}}_u$ and becomes an ancestor node of $\tilde{\rm{PP}}_u$ in the search tree.
Since the sequence of expanded path pairs has monotonically nondecreasing $f_1$-values of their top-left paths (Lemma~\ref{lem:2}) and $f_1(\pi_u^{\texttt{tl}}) = f_1(\tilde{\pi}_u^{\texttt{tl}})$, we have that
$$f_1(\pi_u^{\texttt{tl}}) = f_1(\tilde{\pi}_u^{\texttt{tl}})= f_1({\pi}_v^{\texttt{tl}}).$$
When \algname{PP-A$^*$} expands node $\tilde{\rm{PP}}_u$, the path pair has the lexicographically smallest value of all nodes in the Open list.
Since
$f_1(\pi_u^{\texttt{tl}}) = f_1(\pi_v^{\texttt{tl}})$, it follows that
$f_1(\pi_u^{\texttt{br}}) \leq f_1(\pi_v^{\texttt{br}})$.
Again, we distinguish two cases
\begin{itemize}
\item[\textbf{C2.1}] $f_1(\pi_u^{\texttt{br}}) = f_1(\pi_v^{\texttt{br}})$:
Since path pairs are ordered according to Eq.~\ref{eq:lexi}. we have that either
(i)~$f_2(\pi_u^{\texttt{tl}}) < f_2(\pi_v^{\texttt{tl}})$
or that
(ii)~$f_2(\pi_u^{\texttt{tl}}) = f_2(\pi_v^{\texttt{tl}})$.
If $f_2(\pi_u^{\texttt{tl}}) < f_2(\pi_v^{\texttt{tl}})$ then
If $f_2(\pi_u^{\texttt{tl}}) = f_2(\pi_v^{\texttt{tl}})$ then $f_2(\pi_u^{\texttt{br}}) \leq f_2(\pi_v^{\texttt{br}})$.
Since each path in each path pair has an $f_2$-value that is no smaller than the $f_2$ values of its ancestor (Lemma~\ref{lem:1}),
$f_2(\pi_v^{\texttt{br}}) \leq f_2(\tilde{\pi}_u^{\texttt{br}})$.
Combining both inequalities yields $f_2(\pi_u^{\texttt{br}})\leq f_2(\tilde{\pi}_u^{\texttt{br}})$, which contradicts Lemma~\ref{lem:3}.
\item[\textbf{C2.2}] $f_1(\pi_u^{\texttt{br}}) < f_1(\pi_v^{\texttt{br}})$:
\end{itemize}
\end{itemize}
\end{proof}
\begin{thm}
Let $G$ be a graph,
$c_1, c_2 : E \rightarrow \mathbb{R}$ two cost functions
and
${\ensuremath{v_{\rm{start}}}\xspace}$ and~${\ensuremath{v_{\rm{goal}}}\xspace}$ be start and goal vertices, respectively.
Given~$\ensuremath{\varepsilon}\xspace_1 \geq 0$ and $\ensuremath{\varepsilon}\xspace_2 \geq 0$
\algname{PP-A$^*$} computes an approximate Pareto frontier~$\Pi_{{\ensuremath{v_{\rm{goal}}}\xspace}}(\ensuremath{\varepsilon}\xspace_1, \ensuremath{\varepsilon}\xspace_2)$.
\end{thm}
\begin{proof}
Let $\pi_{{\ensuremath{v_{\rm{goal}}}\xspace}} \in \Pi_{{\ensuremath{v_{\rm{goal}}}\xspace}}$ be a solution and let
\end{proof}
\begin{lem}
\label{lem:x}
Let
$\rm{PP}_u = (\pi_u^{\texttt{tl}}, \pi_u^{\texttt{br}})$
be a path pair that
is pruned by the optimized dominance checks (Alg.~\ref{alg:is_dominated}).
Any path that was not added
Let $\pi$ be a solution that was not
then any path in the partial Paerto frontier
${\small \ensuremath{\rm{PPF}}\xspace}_{u}^{\pi_u^{\texttt{tl}}, \pi_u^{\texttt{br}}}$
is approximately dominated by an extreme path of a path pair in OPEN or in the set of solutions.
\end{lem}
\begin{proof}
We prove the Lemma by induction over the number of path pairs pruned.
When no path pair is pruned the Lemma trivially holds. Now assume that the number of pruned nodes is $n+1$ and that the Lemma holds for $n \geq 0$.
\end{proof}
}
\section{Evaluation}
\paragraph{Experimental setup.}
To evaluate our approach we compare it to \algname{BOA$^*_\eps$} as \algname{BOA$^*$}
was recently shown to dramatically outperform other state-of-the-art algorithms for bi-criteria shortest path~\cite{UYBZSK20}.
All experiments were run on an
1.8GHz Intel(R) Core(TM) i7-8565U CPU
Windows 10 machine with 16GB of RAM.
All algorithm implementations were in C\raise.08ex\hbox{\tt ++}\xspace.\footnote{Our code is publicly available at \url{https://github.com/CRL-Technion/path-pair-graph-search}.}
We use road maps from the 9'th DIMACS Implementation Challenge: Shortest Path\footnote{\url{http://users.diag.uniroma1.it/challenge9/download.shtml}.}.
The cost components represent travel distances ($c_1$)
and times ($c_2$). The heuristic values are the exact travel distances and times to the goal state, computed with Dijkstra’s
algorithm. Since all algorithms use the same heuristic values, heuristic-computation times are omitted.
\begin{table}[t]
\input{tbl_NY}
\input{tbl_BAY}
\input{tbl_COL}
\input{tbl_FLA}
\caption{Average number of solutions ($n_{\rm{sol}}$) and runtime (in ms) comparing \algname{BOA$^*_\eps$} and \algname{PP-A$^*$} on 50 random queries sampled for four different roadmaps for different approximation factors.}
\label{tbl:res}
\end{table}
\begin{figure*}[t]%
\centering
\subfloat[]{
\label{fig:NE1}
\includegraphics[height=3.7cm]{NE_n_eps}
}
\hspace*{-10mm}
\subfloat[]{
\label{fig:NE2}
\includegraphics[height=3.7cm]{NE_t_eps}
}
\hspace*{-10mm}
\subfloat[]{
\label{fig:NE4}
\includegraphics[height=3.7cm]{NE_t_geom_eps}
} \hspace*{-10mm}
\subfloat[]{
\label{fig:NE3}
\includegraphics[height=3.7cm]{NE_s_eps}
}%
\caption{North East (NE) plots.
\protect \subref{fig:NE1}
The average number of expanded nodes ($n_{\rm{exp}}$).
\protect \subref{fig:NE2} and
\protect \subref{fig:NE4}
the time (arithmetic-mean and geometric mean, respectively) for both algorithms as a function of the approximation factor.
Notice the logarithmic scale in the $y$-axis for the first three plots.
\protect \subref{fig:NE3}
The average speedup of \algname{PP-A$^*$} when compared to \algname{BOA$^*_\eps$} as a function of the approximation factor.
Error bars denote one standard error (error bars in~\protect \subref{fig:NE1} through \protect \subref{fig:NE4} are not visible due to the logarithmic scale).
}
\label{fig:NE}
\end{figure*}
\paragraph{General comparison.}Similar to the experiments of Hernandez et al~\cite{UYBZSK20} we start by comparing the algorithms for four different roadmaps containing between roughly $250K$ and $1M$ vertices.
Table~\ref{tbl:res} summarizes the number of solutions in the approximate Pareto frontier and average, minimum and maximum running times of the two algorithms using the following values\footnote{While \algname{PP-A$^*$} allows a user to specify two approximation factors corresponding to the two cost functions, this is not the case for \algname{BOA$^*$}. Thus, in all experiments we use a single approximation factor $\varepsilon$ and set $\varepsilon_1 = \varepsilon_2 = \varepsilon$.}
$\varepsilon \in \{ 0, 0.01, 0.025, 0.05, 0.1\}$.
Here, approximation values of zero and $0.01$ correspond to computing the entire Pareto frontier and approximating it using a value of~$1\%$, respectively.
When computing the entire Pareto frontier \algname{BOA$^*$} is roughly three times faster than \algname{PP-A$^*$} on average.
This is to be expected as \algname{PP-A$^*$} stores for each element in the priority queue two paths and requires more computationally-demanding operations.
As the approximation factor is increased, the average running time of \algname{PP-A$^*$} drops faster, when compared to \algname{BOA$^*_\eps$} and we observe a significant average speedup.
Interestingly, when looking at the minimal running time, \algname{BOA$^*_\eps$} significantly outperforms \algname{PP-A$^*$}. This is because in such settings the approximate Pareto frontier contains one solution, which \algname{BOA$^*_\eps$} is able to compute very fast. Other nodes are approximately dominated by this solution and the algorithm can terminate very quickly.
\algname{PP-A$^*$}, on the other hand, still performs merge operations which incur a computational overhead.
When looking at the maximal running time, we can see an opposite trend where \algname{PP-A$^*$} outperforms \algname{BOA$^*_\eps$} by a large factor.
\paragraph{Pinpointing the performance differences between \algname{PP-A$^*$} and \algname{BOA$^*_\eps$}.}
The first set of results suggest that as the problem becomes harder, the speedup that \algname{PP-A$^*$} may offer becomes more pronounced.
We empirically quantify this claim by moving to a larger map called the North East (NE) map which contains 1,524,453 states and 3,897,636 edges where we obtain even larger speedups (see Table~\ref{tbl:res-NE}).
\begin{table}[t]
\input{tbl_NE}
\caption{Runtime (in seconds) comparing \algname{BOA$^*$} and \algname{PP-A$^*$} on 50 random queries sampled for the NE map.}
\label{tbl:res-NE}
\end{table}
We plot the number of nodes expanded (which typically is proportional to the running time of \algname{A$^*$}-like algorithms) of each algorithm as a function of the approximation factor (see, Fig.~\ref{fig:NE1}.
Here we used $\varepsilon \in \{ 0, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1\}$.
Additionally, we plot both the arithmetic mean (Fig.~\ref{fig:NE2})
as well as the
geometric mean (Fig.~\ref{fig:NE4})
of each algorithm as a function of the approximation factor.\footnote{We used both arithmetic and geometric mean as the arithmetic mean can be misleading skewing the mean towards the results on larger instances. Together, both means better capture the results. }
We observe that the number of nodes expanded monotonically decreases when the approximation factor is increased for both algorithms. This is because additional nodes may be pruned which in turn, prunes all nodes in their subtree.
It is important to discuss \emph{how} these nodes are pruned: Recall that \algname{BOA$^*_\eps$} prunes nodes according to Eq.~\ref{eq:d0}.
Thus, increasing the approximation factor only allows to prune more nodes according to the already-computed solutions and not according to the paths computed to intermediate nodes.
In contrast, \algname{PP-A$^*$} prunes nodes according to Eq.~\ref{eq:d1} and~\ref{eq:d2}. Thus, in addition to more path pairs being merged, increasing the approximation allows to prune more path pairs according to the already-computed solutions as well as the path pairs computed to intermediate vertices.
Thus, for relatively-small approximation factors that are greater than zero (in our setting, $0 < \varepsilon < 0.5$, we see that \algname{BOA$^*$} expands a significantly higher number of nodes than \algname{PP-A$^*$} which explains the speedups we observed.
However, for large approximation factors, there is typically only one solution in the approximate Pareto frontier. This solution, which is found quickly by \algname{BOA$^*_\eps$},
allows to prune almost all other paths which results in \algname{BOA$^*_\eps$} running much faster than \algname{PP-A$^*$}.
This trend is visualized in Fig.~\ref{fig:NE3}.
\section{Future Research}
\subsection{Bidirectional search}
We presented \algname{PP-A$^*$} as a unidirectional search algorithm, however a common approach to speed up search algorithms is to perform two simultaneous searches: a forward search from ${\ensuremath{v_{\rm{start}}}\xspace}$ to ${\ensuremath{v_{\rm{goal}}}\xspace}$ and a backward search from ${\ensuremath{v_{\rm{goal}}}\xspace}$ to~${\ensuremath{v_{\rm{start}}}\xspace}$~\cite{pohl1971bi}.
Thus, an immediate task for future research is to suggest a bidirectional extension of \algname{PP-A$^*$}. Here we can build upon recent progress in bi-directional search algorithms for bi-criteria shortest-path problems~\cite{sedeno2019biobjective}.
\subsection{Beyond two optimization criteria}
We presented \algname{PP-A$^*$} as a search algorithm for two optimization criteria, however the same concepts can be used for multi-criteria optimization problems. Unfortunately, it is not clear how to perform operations such as dominance checks efficiently since the methods presented for \algname{BOA$^*$} do not extend to such settings.
\section*{Acknowledgements}
We wish to thank
Carlos Hernandez, William Yeoh, Jorge Baier and Sven Koenig for insightful discussions regarding BOA*
and Ariel Felner for comments on early drafts of this paper.
In addition, we thank the anonymous reviewers of the ICAPS 2020 Workshop on Heuristics and Search for Domain-independent Planning (HSDIP 2020) for insightful comments on an early version of this paper.
Finally, this research was partially supported by grants No. 102583, 2028142 from the Isaeli Ministry of Science \& Technology (MOST), and by grant No. 1018193 from the United States-Israel Binational Science Foundation (BSF).
| {'timestamp': '2021-03-08T02:12:18', 'yymm': '2006', 'arxiv_id': '2006.10302', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10302'} | arxiv |
\section{Introduction}\label{sec:introduction}
Professional photographers generally invest time post-processing the appearance of the sky, as it significantly affects how humans perceive the photograph's time of day, and the relative appearance of the non-sky foreground of the scene.
Photographers will often manually segment the sky and use that segmentation to adjust the sky's brightness, contrast, color, and noise properties. This editing is particularly necessary in night-time scenes, wherein the camera receives little light and therefore produces images with significant noise. Noise in the sky can look particularly unattractive and noticeable because the sky is typically textureless.
Additionally, night-time scenes may contain a foreground that is illuminated by a nearby light source, while the sky is illuminated by scattered sunlight or by distant terrestrial lights reflected off of clouds. This means that the standard practice of using a single illuminant estimate for white balance~\cite{barron2017fast} is physically incorrect, and results in an unnatural tint of either the sky or of the foreground. This motivates our use of sky segmentation for performing spatially-varying white balance, which ameliorates this issue.
\begin{figure*}[!t]
\centering
\includegraphics[width=\textwidth]{figures/ntrie_Intro_system_v3.pdf}
\caption{Our method for sky-aware processing and examples. (a) We first create a dataset for sky segmentation and train a neural network to predict an alpha map of the sky. Next, we optimize the network architecture using the approach of MorphNet \cite{gordon2018morphnet}. The network is then integrated into a camera pipeline which runs inference in low resolution. Next, we run a variation of guided upsampling, to obtain a high-resolution mask. Last, we perform editing such as tonemapping, contrast enhancement, noise reduction and spatially varying auto white balance to improve the appearance of the sky and the entire image. (b) and (c) show images captured in low light, without and with sky-aware processing. (d) Zoomed-in regions of the original images (green) and sky-processed images (magenta).}
\label{fig:system_diagram}
\end{figure*}
We address the task of semantically segmenting the sky using machine learning. Because of the inherent difficulty of manually annotating a pixel-level alpha for a high-detailed sky mask, we propose an algorithmic approach for transforming approximate binary segmentation masks into accurate alpha mattes, and use this approach to improve the training data for training our model.
Our goal is to produce the sky-optimized images with a latency below one second on a mobile device with limited memory and compute resources. These constraints prohibit the use of large models, and therefore, we use the approach of MorphNet \cite{gordon2018morphnet} to shrink the model size while retaining high segmentation accuracy.
To reduce the latency and memory overhead of sky segmentation inference we reduce the size of the input image. This approach results in an output mask that is also at a reduced resolution compared to the original image. To enable high-quality image editing, this low-resolution mask is upsampled in an edge-ware way. With this high-resolution sky mask, we are able to apply various effects to the full-resolution image. Correctly performing automatic noise reduction and white balancing require an awareness of various scene properties, such as the noise level, exposure time, and illumination color, which we address in this paper.
In this work, we propose a method for semantic sky segmentation and editing that can be done on mobile devices as part of the camera pipeline. The overall framework of our approach is illustrated in \fig{fig:system_diagram}. Our contributions are:
\begin{enumerate}
\item A method for refining the coarse sky segmentation masks of existing datasets into accurate alpha masks. We performed a user study to evaluate the quality of the refined masks and show quantitative results on the ADE20K dataset~\cite{zhou2017scene}.
\item A method for creating accurate sky alpha masks at high resolution, using a neural network and weighted guided upsampling.
\item A series of sky editing effects that can be achieved using the high-resolution sky masks: sky darkening, contrast enhancement, noise reduction, and auto white balance, which automatically improve the appearance of photographs, especially those captured in low light.
\item A modification to Fast Fourier Color Constancy (FFCC) \cite{barron2017fast} to achieve spatially varying auto white balance.
\item A complete computational photography system for performing sky segmentation and optimization on a mobile device in under half a second.
\end{enumerate}
\section{Related Work}
In this section, we review prior work on sky-aware image processing. Prior work on mask refinement strategies is discussed in \sect{sec:wgf}.
Tao \etal \cite{tao2009skyfinder} created an interactive search system for skies with certain attributes and demonstrated its use for editing the appearance of skies. Owing to an interest in automatically segmenting the skies for a wide variety of applications, Mihail \etal \cite{mihail2016sky} created a dataset for evaluating sky segmentation in various conditions, and reviewed methods for sky segmentation.
Place \etal \cite{la2019segmenting} built on their prior work and evaluated the performance of a neural network, RefineNet \cite{lin2016refinenet}, for the segmentation task.
Tsai \etal \cite{tsai2016sky} used a refined sky mask to replace the sky in a photograph to give it a more interesting appearance. They utilize a fully convolutional network \cite{long2015fully} for scene parsing, followed by sky refinement with a two-class conditional random field.
In addition to segmenting and replacing the skies, Tsai \etal created a method for automatically selecting suitable sky-replacement candidates based on semantic features, and render these skies onto the target image using a per-pixel transfer process.
Unlike that work, we are not aiming to completely replace the appearance of the sky, instead, we are interested in improving the appearance of the image while producing an image that is closer to what was perceived during capture.
This is achieved by applying spatially varying white balance, noise reduction and tonemapping.
The method described by \cite{tsai2016sky} was not optimized for processing on mobile devices, for example, scene parsing alone takes 12 seconds on a desktop GPU, however \cite{halperin2019clear} proposed a sky replacement algorithm for video which can achieve nearly real-time performance on mobile devices. \cite{halperin2019clear} use a relatively small segmentation network and do not incorporate a refinement step in their performance measurements. Their results are visually pleasing for video, but are not shown for higher resolution (12 megapixel) photographs.
\section{Proposed Method}
\input{03_1_mask_refinement}
\input{03_2_dataset_creation}
\input{03_3_model_architecture}
\input{03_4_sky_effects}
\subsection{Mask refinement}
\label{sec:wgf}
In this section we describe a guided-filter-based mask refinement method, which is used twice by our approach: First, for creating an accurate sky segmentation dataset, without tedious pixel-level manual annotations, and second, for refining the inferred low resolution sky mask, prior to using it for photo editing. An outline of this procedure can be seen in Figure~\ref{fig:wgf}.
\paragraph{The modified guided filter}
\label{sec:modified_guided_filter}
\newcommand{\ldlsolve}[2]{\operatorname{solve\_image\_ldl3}(#1, #2)}
\newcommand{\outerprod}[2]{#1 \otimes #2}
\newcommand{I}{I}
\newcommand{\inputim}{P}
\newcommand{C}{C}
\newcommand{s}{s}
\newcommand{\wdownsample}[1]{\operatorname{weighted\_downsample}\left(#1, C, s\right)} %
\newcommand{\upsample}[1]{\operatorname{smooth\_upsample}\left(#1, s\right)} %
\newcommand{\downsampled}[1]{#1_{\downarrow}}
\newcommand{\upsampled}[1]{#1_{\downarrow\uparrow}}
\newcommand{\epsilon_{\ell}}{\epsilon_{\ell}}
\newcommand{\epsilon_{c}}{\epsilon_{c}}
\newcommand{\downsampled{\Sigma}}{\downsampled{\Sigma}}
\newcommand{\downsampled{\sigma}}{\downsampled{\sigma}}
\newcommand{\downsampled{A}}{\downsampled{A}}
\newcommand{\downsampled{b}}{\downsampled{b}}
\newcommand{A}{A}
\newcommand{b}{b}
\newcommand{Y}{Y}
\begin{figure}[b!]
\includegraphics[width=\linewidth]{figures/weighted_guided_filter.pdf}
\caption{The input to our mask refinement process is an input RGB image (a) and a coarse binary sky mask (b), shown here with nearest-neighbor upsampling. Applying our confidence map function (c) to the mask values produces a per-pixel confidence (d), which is used as input to our modified guided filter (with $s=64$) to produce the edge-aware alpha matte in (e). Using a non-weighted guided filter produces mattes with less separation between the foreground and the sky (f), and using a small spatial kernel ($s=16$) produces an inaccurate mask (g), for example, the mask does not accurately segment the cables of the bridge.}
\label{fig:wgf}.
\end{figure}
The guided filter~\cite{he2010guided} is a classic technique for edge-aware filtering, which generally exhibits improved performance and speed compared to the related techniques of anisotropic~\cite{Perona90scale} or bilateral~\cite{Tomasi1998, paris2009bilateral} filtering and joint bilateral upsampling \cite{kopf2007joint}.
The guided filter has been shown to be a closed-form partial solution to the matting Laplacian~\cite{levin2007closed}, which motivates our use of it here for producing alpha mattes from sky masks.
The guided filter works by approximating the input image to be filtered (in our case, an alpha mask) as a locally affine function of the reference image (in our case, an RGB image). This is done by solving a linear least squares problem at each pixel in the image.
In this work we present several modifications to the guided filter, which have several advantages over the traditional formulation, as listed below. The full algorithm appears in \sect{sec:modified_guided_filter}.
\begin{compactenum}
\item Our filter takes as input a per-pixel confidence map, and accordingly solves a \emph{weighted} least squares system at every pixel. This allows our filter to process masks where some values are missing, which is critical for creating high resolution alpha-masks efficiently.
\item We use a (weighted) bilinear downsample to compute the local expectations that are required for the guided filter computation and a smooth upsampling procedure to produce smooth artifact-free outputs (see \sect{sec:modified_guided_filter}) for more details).
\item Owing to our use of downsampling, the linear solver at the core of the guided filter, only needs to be evaluated on $n/s^2$ pixels, where $n$ is the number of pixels and $s$ is our downsampling factor. This approach resembles the "fast guided filter" \cite{he2010guided}.
\item We use an LDL-decomposition based solver to solve the set of linear systems. This produces more stable outputs than the conventional approach of explicitly inverting a matrix, and is faster than the approach of invoking a direct linear solver.
\item We parameterize the regularization in the (weighted) least squares solver within our filter as independent smoothness terms on the luma and chroma of the reference image, which gives us finer control over the output of the filter.
\end{compactenum}
\paragraph{Confidence calibration}
\label{sec:confidence_calibration}
The choice of the confidence map used by our modified guided filter is critical to the quality of our edge-aware smooth sky masks.
We use different approaches for computing this confidence for the two uses of mask refinement: one for pre-processing our training data, and one for post-processing the output of our neural network.
When pre-processing our training data, we use a confidence trimap, where a value of $c_{\mathit{det}}$ indicates certainty and is used for pixels which were manually annotated. $c_{\mathit{inpaint}}$ is for pixels inpainted as skies by the density estimation algorithm (described in \sect{sec:dataset_annotations}). $c_{\mathit{undet}}$ indicates uncertainty of the mask values and is assigned to pixels which were not annotated nor inpainted.
When post-processing the inferred sky mask from our neural network within our camera pipeline, we must adopt a different approach, as we do not have ground-truth user annotations.
Our model emits a continuous per-pixel probability, where low values correspond to ``not sky'', high values (closer to $1$) correspond to ``sky'', and intermediate values indicate uncertainty.
Accordingly, we define our per-pixel confidence measure $C_i$ a as a function of each per-pixel probability $p_i$:
\begin{align}
C_i &= \left\{
\begin{array}{lll}
\max\left(\epsilon, \operatorname{bias}\left(\frac{\ell - p_i}{\ell}, b \right) \right) & \mbox{if } p_i < \ell \\
\max\left(\epsilon,\operatorname{bias}\left(\frac{p_i - h}{1 - h}, b\right) \right) & \mbox{if } p_i > h \\
\epsilon & \mbox{o.w.}
\end{array}
\right. \\
\operatorname{bias}(x; b) &= \frac{x}{(\sfrac{1}{b} - 2)(1 - x) + 1} \label{eq:bias}
\end{align}
Where $\ell=0.3$, $h=0.5$, $b=0.8$, $\epsilon=0.01$, and $\operatorname{bias}(\cdot)$ is Schlick's bias curve \cite{Schlick:1994:FAP:180895.180931}.
This function is visualized in \fig{fig:wgf}c.
This confidence is not symmetric with respect to $p_i=0.5$, and therefore encodes a preference towards the sky label, which is done so as to ensure that sky pixels are not ignored by our filter.
\paragraph{Choosing the guided filter downsampling factor}
The choice of the downsampling factor used by the filter has a significant impact on both the guided filter's speed and spatial support.
The downsampling factor used when creating our training dataset is relatively small ($s=8$), because the image is annotated at full resolution and the initial annotations and subsequent inpainting produce good predictions except around rough edges.
In this case, the guided filter just serves to smooth the boundaries of the mask according to the reference image.
Because this step is performed before training and not on-device, the slower speed caused by this small spatial support is not problematic.
However, when we apply our guided filter variant to the output of our neural network within our camera pipeline, we use a larger downsampling factor ($s=64$). This significantly accelerates inference, and also results in improved mask quality: Because the sky mask is inferred at low resolution, small regions of the sky may not be detected as such (e.g.\, in between leaves of trees). To obtain correct sky-mask values in these regions, we need the spatial support of the filter to be large enough to allow the signal from these correctly detected sky regions to propagate to those regions where detection failed. As shown in \fig{fig:wgf}g, using a small spatial kernel negatively affects the quality of our output.
\subsection{Dataset creation}
\label{sec:dataset}
Creating an accurate sky segmentation dataset is challenging because semantic segmentation datasets rely on manual annotations provided by humans. The ground-truth masks in common segmentation datasets are often coarse and inaccurate: the shape of the sky may be poorly approximated by a small number of control points, or may omit ``holes'' in other objects through which the sky is visible.
As a result, semantic segmentation models trained on these datasets do not produce accurate enough outputs to be used for our image enhancement task.
Indeed, even using the ground-truth sky mask provided by these datasets is generally not sufficient for our task, as we will demonstrate.
It is unrealistic to rely on human annotators to produce the high degree of quality we require for our task, especially at the scale required for training modern deep neural networks. Furthermore, in order to correctly compute the sky mask in the presence of translucent objects, we require that our training data indicate the partial transparency of the foreground. Therefore, the masks should not be a per-pixel binary mask, but should instead be continuous.
In this section, we describe how we create a diverse dataset for sky segmentation in which the annotated masks are highly detailed and include continuous alpha values. In \sect{sec:comparison_dataset_refined_not_refined}, we show how dataset refinement improves the results of the segmentation model. All of the results in the paper were produced by a model trained on our dataset, unless mentioned otherwise.
\paragraph{Obtaining images for the dataset}
The images in our dataset were independently collected and include a variety of scenes, with different times of day (daytime, nighttime, sunrise, sunset), different weather conditions (clear, cloudy, foggy), challenging compositions (the sky can be seen behind trees, bridges, sculptures), reflective objects (reflective buildings and water), and astrophotography images. We have found that when a sky segmentation model is trained mostly on images with skies, it sometimes incorrectly classifies other uniform objects as being sky, such as indoor walls. We therefore used Google Images to mine for images which are similar to our false positives and added them to the training dataset. In total, our dataset includes $\sim$120,000 images.
\paragraph{Refined and Inpainted Annotations}
\label{sec:dataset_annotations}
Here we show a method for efficiently creating an accurate continuous-value alpha mask of the sky. We start with coarse manual annotations dividing the image into three sections: ``sky'', ``not sky'' and ``undetermined''. The annotations were made by human annotators who clicked to create polygons of the three different sections. The ``sky'' section includes skies and objects in the skies, such as clouds, the moon and stars. The ``not sky'' section was annotated such that it does not include any skies or partially transparent foregrounds. The mined negative images of uniform sky-like surfaces are of indoor scenes and are therefore globally annotated as ``not sky''. The ``undetermined'' label is used for any pixel that is not annotated by the previous two labels, such as boundaries between trees and the sky (\fig{fig:de}b). This region may contain both ``sky'' and ``not sky'' pixels that would be impractical to manually annotate, or that contain transparency and therefore require a non-binary alpha value. These ``undetermined'' areas are inpainted by using density estimation \cite{parzen1962estimation}, as described below.
Density estimation uses the distribution of RGB values of the annotated ``sky'' pixels to inpaint the pixels in the ``undetermined'' section. Here we take advantage of the limited variability of RGB values in the skies. We calculate the probability that each ``undetermined'' pixel belongs to the ``sky'' pixels using \eq{eq:de}.
All ``undetermined'' pixels with a probability $p_i$ greater than a threshold $p_c=0.6$ are re-labeled as being ``sky'', while those with probabilities below that threshold are re-labeled as ``not sky'' and assigned a low confidence of $c_{\mathit{undet}}$ (as described in \sect{sec:confidence_calibration}). We then apply our modified weighted guided filter to the mask.
\begin{figure}
\centering
\includegraphics[width=\linewidth]{figures/ntrie_de_gf.pdf}
\captionsetup{justification=raggedright,singlelinecheck=false}
\caption{Our method for annotating the sky segmentation dataset. (a) An RGB input image. (b) Rough partial annotations, created manually. Blue and red represent the ``sky'' and the ``not sky'' sections, respectively, and the ``undetermined'' section is not marked. (c) The manual annotations of (b) following the weighted guided filter refinement process without inpainting. In this case all the undetermined pixels are labeled as ``not sky'' and are given confidence values of $c_{\mathit{undet}}=0.5$. (d) The manual annotations following density estimation inpainting. The mask is binary. (e) The mask of (d) following refinement with the weighted guided filter. This mask is detailed and includes continuous values, as can be seen in the zoomed-in crops in (f).}
\label{fig:de}
\end{figure}
\subsection{Model architecture}
\label{sec:fluidnets}
At the core of our model is a UNet~\cite{ronneberger2015unet} neural network that takes as input an RGB image and predicts as output the per-pixel likelihood that each pixel is the sky. The specific model we build upon is a three-stage UNet model that was previously used for portrait segmentation on mobile devices \cite{wadhwa2018synthetic}.
To optimize the performance of the network and reduce its size we used the MorphNet method~\cite{gordon2018morphnet}. MorphNet balances the model's loss and its resource constraints, in terms of model size, to discover architectures that are more efficient. It does that by relaxing the discrete model parameterization into a continuous formulation that allows for the model structure to be learned jointly along with its weights during training. We follow the previously-described 2-step approach of first shrinking and then expanding the model. Our criteria during meta-optimization was to improve the evaluation metric while reducing the size of the model. Following this optimization step, we obtain a model that is more accurate (the ${IoU}_{0.5}$ increases from 0.9186 to 0.9237) and 27\% smaller (see \sect{sec:model_optimization} for more detail). Next, we quantize all model weights from 32-bit to 16-bit floating point, which further reduces the model size by half with a negligible quality gap. The final size of our model is 3.7 MB.
\subsection{Sky optimization}
\label{sec:sky_optimization}
Low light photography presents specific challenges which, if not addressed, degrades the appearance of the skies. Specifically, low light images often have a low signal-to-noise ratio, multiple illumination sources, and a high dynamic range, which may cause the skies to appear too noisy and have an unnatural color. Additionally, a side-effect of brightening the foreground in low-light photographs is over brightening the skies and creating a night-into-day effect. Therefore, it is beneficial to separately tune tone, noise reduction and color for the skies, which ultimately improves the image quality of the entire photograph.
\paragraph{Sky darkening and contrast enhancement}
Tonemapping is a technique used in image processing to map one set of colors or brightness values to another. We use a tonemapping curve to darken the skies in low light images. We apply tonemapping on the V channel following HSV decomposition~\cite{smith1978color}. The shape of our tonemapping curve is a bias curve, $\operatorname{bias}(v;b_{\mathit{d}})$, as shown in \eq{eq:bias} and \fig{fig:sky_effects}a. In $\operatorname{bias}(v;b_{\mathit{d}})$, $v$ is the pixel value, which after the HSV decomposition is in a range of $[0,1]$, and $b_{\mathit{d}}$ is a parameter that controls the amount of darkening. When $b_{\mathit{d}}=0.5$, the output of the tonemapping curve is identical to its input (dashed line in \fig{fig:sky_effects}a). As $b_{\mathit{d}}$ decreases, the output decreases in the mid-range, meaning that the skies become darker. In order to automatically choose the ``right'' tone of the sky, the parameter $b_{\mathit{d}}$, which indicates the amount in which the sky will be darkened, is calibrated per image as a function of the sky brightness and the brightness of the scene. The ``right'' amount of darkening is highly subjective, as we are aiming to reproduce the \textit{feel} of the scene as it was captured. To achieve this, we tagged hundreds of photos at various conditions. We binned and averaged these tags to learn a 2-dimensional look-up table that maps the brightness of the scene and the sky to the amount of sky darkening, as represented by $b_{\mathit{d}}$.
A subsequent tonemapping curve is used to enhance the contrast of images with certain characteristics. Specifically, contrast enhancement is targeted towards astrophotography and is designed to boost the appearance of stars and other celestial objects, such as the Milky Way. The contrast enhancement curve, shown in \fig{fig:sky_effects}c and \eq{eq:contrast}, also takes as input the pixel value $v_i$. It leaves the very low-brightness pixels unchanged and uses a bias curve to enhance the contrast of the mid-brightness pixels:
\begin{align}
v_o &= \left\{
\begin{array}{lll}
v_i & \mbox{if } v_i < t_{\mathit{c}} \\
(1-t_{\mathit{c}})\operatorname{bias}\left(\frac{v_i - t_{\mathit{c}}}{1-t_{\mathit{c}}};b_{\mathit{c}}\right) + t_{\mathit{c}} & \mbox{if } v_i \geq t_{\mathit{c}} \\
\end{array}
\right.
\label{eq:contrast}
\end{align}
The parameters $b_{\mathit{c}}$ and $t_{\mathit{c}}$ indicate the intensity and the range of contrast enhancement. We calibrate $b_{\mathit{c}}$ as a function of the exposure time and the noise in the image, in order to avoid enhancing the contrast of noise.
We labeled tens of photos and performed binning and averaging of the tags to determine a 2-dimensional mapping from the exposure time and signal-to-noise to $b_{\mathit{c}}$. The threshold, $t_{\mathit{c}}$, determines the range of pixels which remain unchanged and pixels which will be contrast-enhanced. We have empirically found that a value of $t_{\mathit{c}}=0.085$ yields a pleasing contrast enhancement of the stars and the Milky Way. After tonemapping, the resulting pixel values and the original pixels values are alpha blended using the sky mask as the weight.
\paragraph{Sky denoising}
The appearance of the sky tends to be much more regular and predictable in terms of its image content compared to other parts of the scene. This allows us to tune a denoising algorithm for the sky that more aggressively removes noise from smooth regions, while preserving high-frequency details such as stars and mid-frequency details such as clouds. We do this by tuning the frequency response of the spatial luma denoising algorithm of \cite{liba2019handheld}, which uses a pyramid based bilateral denoise algorithm with four levels. In order to optimize noise reduction for the skies, we increase the amount of denoising at the two higher levels (low resolution noise) up to $2.5\times$. We only slightly increase the denoising strength, up to $5\%$, in the two lowest levels (highest resolution). The amount in which we increase the denoising strength in the skies is a function of the signal-to-noise ratio of the image and was calibrated by labeling tens of low-light images. We use the sky mask to indicate where to use these modified denoising parameters, and in the foreground we use the same denoising parameters as in \cite{liba2019handheld}. We combine the separately denoised foreground and sky using an adjusted sky mask as an alpha in a weighted average. In order to protect the details in the foreground, we adjust the sky mask by clamping to $0$ the mask values below a threshold, $t_d=0.8$, and scaling the remaining mask values between $0$ and $1$. \fig{fig:sky_effects}e shows an example in which noise reduction increases in the sky while the foreground and the high-frequency stars remain unchanged. Additional examples and a comparison to an end-to-end neural network \cite{chen2018learning} are in \sect{sec:sky_denoise_L2SITD}.
\begin{figure}
\includegraphics[width=\linewidth]{figures/nitre_sky_effects.pdf}
\caption{Sky tonemapping and denoise. (a) The tonemapping curve we used to darken the sky to reduce the night-into-day effect of low-light imaging. The curvature is determined by a $b_{\mathit{d}}$ which we calibrate according to the brightness of the sky and the scene. (b) Examples of original (left) and sky-darkened images (right). Notice that only the sky brightness is changed while the foreground remains the same. (c) The tonemapping curve used for contrast enhancement. (d) A photograph of the Milky Way before (left) and after sky contrast enhancement (right). (e) The sky mask allows us to tune the denoising algorithm to improve the appearance of the sky without affecting details in the foreground. The mid-frequency noise blotches are removed while the high resolution details of the stars are retained. Readers are encouraged to zoom-in to see the difference in noise characteristics.}
\label{fig:sky_effects}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{figures/ntire_Sky_AWB.pdf}
\caption{(a-c) Conventional white balance algorithms assume a single global illuminant color, but in night-time photographs, often the sky is lit differently than the foreground. Prioritizing the foreground produces a natural looking face but a magenta sky (a), while prioritizing the sky corrects the background but makes the subject look blue (b). With sky segmentation we are able to estimate two distinct white balance gains, which are applied according to our estimated sky mask (c). (d) A system diagram of our spatially varying auto white balance system, based on FFCC \cite{barron2017fast}. Using the sky mask, we provide additional log-chroma histograms and log-brightness estimates to FFCC that isolate the color distribution of the sky. This FFCC sky model is trained separately on the dataset that optimizes the color of the sky, and we additionally train the standard model of \cite{barron2017fast} to take the entire image as input and optimize for the color of the foreground. The final rendition blends the sky and the foreground with their separate white balance gains according to our predicted sky mask to result in a spatially-varying white balance. }
\label{fig:sky_awb}
\end{figure}
\paragraph{Dual auto white balance}
A conventional image processing pipeline is often constrained by the assumption of a single global white balance: pipelines assume that all pixels are lit by one single illuminant, and attempt to estimate and remove that one illuminant.
This can produce suboptimal results in scenes with mixed illuminants, which is often the case for images of the night sky, which is far in the background and is often illuminated differently from the foreground.
We observe that conventional global white balance algorithms often prioritize the color fidelity of the foreground over background, which can compromise image quality for the sky region. \fig{fig:sky_awb}a demonstrates the global white balance of \cite{barron2017fast,liba2019handheld}, which prioritizes the color of the person over the color of the sky, thereby causing the sky to look magenta. If this global white balance algorithm were to instead produce the gains that correct for the color of the sky and apply those gains globally, as shown in \fig{fig:sky_awb}b, the subject's skin would appear unnaturally blue. By using sky segmentation, we are able to produce two distinct white balance estimates, which we can use to separately correct the colors of the foreground and of the sky, as shown in \fig{fig:sky_awb}c.
Our dual white balance algorithm is built upon the Fast Fourier Color Constancy (FFCC) model \cite{barron2017fast} using a modified loss function for low-light images \cite{liba2019handheld}. Unlike past work, we calculate two distinct auto white balance (AWB) gains: one for the foreground, and one for the background, using the sky mask.
This is done by modifying FFCC to allow it to reason about the chroma distribution of the sky independently from the foreground during training (\fig{fig:sky_awb}d), which results in two models: one for the entire scene and another just for the sky. These two models were trained on two datasets, one that was tagged to optimize the colors of the entire scene, prioritizing people and foreground objects, and another that was tagged to optimize only the color of the sky. The input for training the former model is the entire image, while the input for training the sky model includes both the entire image and a version of the image in which only the sky is visible. These two models, and the sky mask, are then used in the camera pipeline to separately calculate the white balance gains for the entire scene and for the sky. We apply the white balance gains to the image using the sky mask estimated by our model as the alpha in a weighted average, resulting in a final composition where the foreground and sky have been independently white balanced.
\section{Experimental Results}
\label{sec:results}
\label{sec:comparison_dataset_refined_not_refined}
Here we show how the refinement of the annotated masks in the training dataset improves the sky masks inferred by the segmentation model, and that the quality of the mask can be further improved by weighted guided upsampling. In order to do this, we first establish, with a user study, that non-refined annotations can be qualitatively improved by refinement, and specifically by the process that we developed and describe in \sect{sec:dataset}. These results, which generally demonstrate the significance of dataset refinement, are shown on a public dataset, ADE20K \cite{zhou2017scene}, and a baseline UNet model, for the purpose of reproducibility.
\begin{table*}
\centering
\resizebox{\linewidth}{!}{
\begin{tabular}{rl|ccccccccc}
Training Data & Algorithm & $\operatorname{mIOU_{0.5}}\uparrow$ & $\operatorname{BL}\downarrow$ & $\operatorname{MCR_{0.5}}\downarrow$ &
$\operatorname{RMSE}\downarrow$ &
$\operatorname{MAE}\downarrow$ &
$\operatorname{JSD}\downarrow$ \\
\hline
ADE20K & UNet + Bilinear Upsampling & 0.926 & 0.0530 & 0.0151 & 0.0986 & 0.0174 & .00753 \\
ADE20K+GF & UNet + Bilinear Upsampling & 0.920 & 0.0511 & 0.0162 & 0.1051 & 0.0186 & .00843 \\
ADE20K+DE+GF & UNet + Bilinear Upsampling & \textbf{0.936} & 0.0498 & \textbf{0.0131} & \textbf{0.0910} & \textbf{0.0154} & \textbf{.00645} \\
ADE20K & UNet + Guided Filter Upsampling & 0.933 & 0.0476 & 0.0137 & 0.0999 & 0.0258 & .00993 \\
ADE20K+GF & UNet + Guided Filter Upsampling & 0.922 & 0.0482 & 0.0159 & 0.1081 & 0.0270 & .01092 \\
ADE20K+DE+GF & UNet + Guided Filter Upsampling & 0.935 & \textbf{0.0465} & 0.0134 & 0.0972 & 0.0250 & .00948 \\
\end{tabular}
}
\captionsetup{justification=raggedright,singlelinecheck=false}
\caption{Evaluation of the various models with ADE20K+DE+GF as the ground-truth.}
\label{tab:results_model_comparison}
\end{table*}
\subsection{Establishing a refined sky-segmentation dataset}
The ADE20K dataset \cite{zhou2017scene} has binary mask annotations for various labels, including ``sky''. We refine this dataset with two different methods: 1) using the guided filter only (ADE20K+GF), and 2) using density estimation inpainting and the guided filter (ADE20K+DE+GF). Additional details, such as the steps for creating these datasets and example images, are in \sect{sec:dataset_refinement}.
To empirically determine which sky masks are more accurate, we conducted a user study in which the users were asked to choose their preferred mask from a pair of masks from either the raw ADE20k dataset, ADE20K+GF or ADE20K+DE+GF. To show the accuracy of the masks, we apply a sky darkening algorithm that blends a black image with the original image according to the sky mask. The 21 participants of the study preferred the masks of ADE20K+DE+GF in 82.6\% of the cases, when compared to raw ADE20K (more details on the results of the user study are in \sect{sec:user_study_results}). Therefore, we conclude that the masks refined by our DE+GF algorithm are more accurate than the raw ADE20K annotations, and we will evaluate sky segmentation using the refined masks as the ground truth in the next section.
Note that current public sky segmentation datasets consist of binary masks. As shown by our user study, binary masks produce worse image quality when used for sky-aware effects. Therefore, the results of an evaluation on these binary datasets would not be a meaningful indicator for our intended task.
\subsection{Model evaluation}
After establishing that the ADE20K+DE+GF dataset is more accurate compared to the raw annotations, we proceed by evaluating models trained on differently refined datasets on this new ground truth. We trained three neural networks, all with a three-stage UNet architecture, on 1) the raw ADE20K dataset, 2) the ADE20K+DE+GF dataset described above, and 3) the ADE20K dataset refined using the guided filter without inpainting (ADE20K+GF). To mimic the processing of the camera pipeline, we downsample the input images and ground truth masks during training to a resolution of $256\times256$. Evaluation is performed at full resolution, after upsampling by either a bilinear algorithm or our weighted guided filter algorithm.
The evaluation metrics, which are described in \sect{sec:evaluation_metrics}, are: the mean intersection-over-union (mIOU), misclassification rate (MCR), root mean square error (RMSE), mean absolute error (MAE), boundary loss (BL), and Jensen-Shannon Divergence (JSD). The results of the evaluation are in \tab{tab:results_model_comparison} and show that the model that was trained on the refined masks (DE+GF) performs better compared to the models trained on the raw masks or the masks refined only by the guided filter (GF, without DE inpainting). Even following guided filter upsampling, training on the refined dataset is beneficial, meaning that both refinement processes are needed to produce optimal results and that guided filter upsampling cannot entirely correct imperfect masks. Perhaps surprisingly, the evaluation metrics are better in most cases for the bilinear upsampled masks. This could be attributed to the fact that upsampling and refinement are not a part of our training pipeline. That said, when looking at the full resolution images, the masks upsampled using the guided filter have more detail and seem to better represent the image (\fig{fig:model_comparison}). Importantly, guided filter upsampling performs better on the BL metric, therefore, it appears that the BL metric correlates with perceptual quality better than the other metrics.
\begin{figure}
\includegraphics[width=\linewidth]{figures/ntrie_benefits_of_refined_dataset.pdf}
\caption{Sky masks of the image shown on the left, computed with models that were trained on different datasets: raw ADE20K, ADE20K+GF, and ADE20K+DE+GF. The masks are inferred at low resolution ($256\times256$) and then upsampled by either bilinear upsampling or our modified weighted guided filter upsampling. This example demonstrates that the masks produced by the model that was trained on the refined ADE20K+DE+GF are more accurate compared to the other masks, even after guided filter upsampling. This observation correlates well with \tab{tab:results_model_comparison}. We observe that guided filter upsampling produces more detailed masks compared to bilinear upsampling, even though this quality is not manifested by most of the evaluation metrics.}
\label{fig:model_comparison}
\end{figure}
\subsection{Implementation details and performance}
We integrated sky segmentation and processing into a camera pipeline which is implemented on Android and relies on the Camera2 API. The sky mask is inferred on an RGB image which was downsampled to a resolution of $256\times256$. The computation of the segmentation mask is implemented on a mobile GPU and requires ~50 ms. The inferred mask is upsampled using our modified weighted guided filter to a quarter resolution of the image ($1024\times768$). This step was implemented in Halide \cite{ragankelley:halide:2012} and has a latency of 190 ms. Tonemapping and the white balance gains are applied at the quarter resolution and have a latency of ~47 ms. The mask is bilinearly upsampled to full resolution ($4032\times3024$) for sky denoising. The latency for bilinear upsampling and image composition, used for denoising, is 160 ms. Example results are shown in \fig{fig:system_diagram} and \sect{sec:additional_examples}.
\section{Conclusions}
\label{sec:conclusions}
We have presented a method for creating accurate sky masks and using them to adjust the appearance of the sky.
We have shown that refinement is beneficial for creating a dataset for training a segmentation model and for upsampling the mask following inference by that model. The sky mask enables us to edit the skies within the camera pipeline in under half of a second on a mobile device. The edits are particularly beneficial in low light imaging, when the color of the sky is affected by the global white balance and when noise is significant. A variation of our sky optimization system was launched on Google Pixel smartphones as part of “Night Sight”.
\section{Acknowledgements}
\label{sec:acknowledgements}
The algorithms presented in this paper are a result of an ongoing collaboration between several teams in Google Research. From Gcam we particularly thank Marc Levoy, Kiran Murthy, Michael Milne, and Andrew Radin; from the Mobile-Vision team, we thank Emily Manoogian, Nicole Maffeo, Tomer Meron, Weijun Wang and Andrew Howard; from the Luma team, Sungjoon Choi.
\section{The modified guided filter algorithm}
\label{sec:modified_guided_filter}
In this section we describe our modified guided-filter-based mask refinement method. Pseudo code for our modified guided filter is as follows:
\begin{align}
\hline
\operatorname{modified\_guided\_filter}(I, \inputim, C, s, \epsilon_{\ell}, \epsilon_{c}): \span \quad\quad\quad\quad\quad\quad\quad\quad \nonumber\\
\quad\downsampled{I} &= \wdownsample{I} \nonumber\\
\quad\downsampled{\inputim} &= \wdownsample{\inputim} \nonumber\\
\quad\downsampled{\Sigma} &= \wdownsample{\outerprod{I}{I}} - \outerprod{\downsampled{I}}{\downsampled{I}} \nonumber\\
\quad\downsampled{\sigma} &= \wdownsample{I \circ \inputim} - \downsampled{I} \circ \downsampled{\inputim} \nonumber\\
\quad\downsampled{\Sigma} &= \downsampled{\Sigma} + \begin{bmatrix}
\epsilon_{\ell}^2 & & \\
& \epsilon_{c}^2 & \\
& & \epsilon_{c}^2 \\
\end{bmatrix} \nonumber\\
\quad\downsampled{A} &= \ldlsolve{\downsampled{\Sigma}}{\downsampled{\sigma}} \nonumber\\
\quad\downsampled{b} &= \downsampled{\inputim} - \downsampled{A} \cdot \downsampled{I} \nonumber\\
\quadA &= \upsample{\downsampled{A}} \nonumber\\
\quadb &= \upsample{\downsampled{b}} \nonumber\\
\quadY &= A \cdot I + b \\
\hline \nonumber
\end{align}
Inputs to the filter are: a 3-channel reference image $I$ (assumed to be in YUV),
the quantities to be filtered, $\inputim$ (in our case, the sky mask), a confidence map $C$,
and hyperparameters: $s$, the downsampling factor, and $\epsilon_{\ell}$, and $\epsilon_{c}$, the regularization factors for the luma and chroma, respectively.
The output of the filter is $Y$, a mask that resembles $\inputim$ where $C$ is large, and adheres to the edges in $I$.
Regarding notation, $\circ$ is the Hadamard product (where 1-channel images are ``broadcasted'' to match the dimensions of images with more channels), and $\cdot$ is a dot product (Hadamard product that is then summed over channels).
The outer product of two images $A = \outerprod{X}{Y}$ is defined as taking two 3-channel images $X$ and $Y$ and producing a 6-channel image $A$ representing the upper-triangular portion of the outer product of each pixel of $X$ and $Y$:
\begin{align}
A_{1,1} = X_{1} \circ Y_{1}, \quad
A_{1,2} = X_{1} \circ Y_{2}, \quad
A_{1,3} &= X_{1} \circ Y_{3} \nonumber \\
A_{2,2} = X_{2} \circ Y_{2}, \quad
A_{2,3} &= X_{2} \circ Y_{3} \nonumber \\
A_{3,3} &= X_{3} \circ Y_{3}
\label{eq:outer3}
\end{align}
Our weighted downsample, $\operatorname{weighted\_ds}$, is simply a standard bilinear downsample operator applied using homogeneous coordinates:
\begin{equation}
\wdownsample{X} = \frac{\operatorname{ds}(X \circ C, s)}{\operatorname{ds}(C, s)}
\end{equation}
where division is element-wise, and $\operatorname{ds}(\cdot, s)$ is bilinear downsampling according to a spatial bandwidth $s$. $\upsample{\cdot}$ is the smooth upsampling procedure, described next. $\ldlsolve{A}{b}$ is an LDL-decomposition based linear solver designed to operate on 3-channel images, from \cite{Valentin2018}. For completeness, this algorithm is reproduced below.
The traditional guided filter uses a box filter to compute local expectations of various quantities. Because the box filter is applied twice, and because the convolution of two box filters is a triangle-shaped ("tent") filter, the output of the traditional guided filter tends to contain triangle-shaped artifacts. Though there exist fast techniques for applying smoother blur kernels than box filters~\cite{Young1995RecursiveIO}, these techniques are still significantly more expensive than box filters, and do not reduce the number of linear systems to be solved.
In our algorithm, smooth upsampling is achieved by applying the triangle-shaped convolution kernels consecutively (in our case, in 3 steps), which effectively changes the shape of the interpolation kernel to be smoother, and significantly reduces upsampling artifacts. For example, for a downsampling factor $s=64$, instead of upsampling with a single kernel with a support of 64 $\times$ 64, we use triangle kernels with a support of 4 $\times$ 4 three times, one after the other. We chose this method of linear upsampling rather than a more advanced method owing to its separability and efficient implementation. The effect of this smooth upsampling can be seen in \fig{fig:wgf_tent}.
\begin{figure}[b!]
\includegraphics[width=\linewidth]{figures/weighted_guided_filter_smooth_upsample.pdf}
\caption{Using bilinear upsampling within a guided filter (GF) results in noticeable triangle-shaped artifacts (c, e), while our three-step upsampling results avoids such artifacts (d, e).}
\label{fig:wgf_tent}
\end{figure}
Note that our modified guided filter formulation degrades naturally to the traditional formulation of the guided filter if 1) $\wdownsample{\cdot}$ and $\upsample{\cdot}$ are both replaced with a box filter, 2) the reference image $I$ is RGB and $\epsilon_{\ell}=\epsilon_{c}$, and 3) $\ldlsolve{\cdot}{\cdot}$ is replaced with matrix inversion and a matrix multiply.
Our approach of accelerating part of the guided filter through the use of spatial downsampling is superficially similar with the ``fast guided filter'' \cite{He015}, which also yields an acceleration from $\mathcal{O}(n)$ to $\mathcal{O}(n/s^2)$ for an intermediate step of the filter. This is accomplished by simply subsampling the input mask before computing the affine filter coefficients, which are then applied to the full resolution mask. Though fast, this approach ignores the vast majority of the input mask, and thereby assumes that the input to the filter is very smooth and regular. This does not hold in our use case: for example, if we had a single high-confidence pixel surrounded by many low-confidence pixels, we would require a guarantee that this single pixel's value would propagate to all nearby low-confidence pixels in the output, and a subsampling approach will not guarantee this (and worse, will cause the output of the model to vary significantly depending on whether or not the single high-confidence pixel happens to lie at one of the few spatial locations that is subsampled). In contrast, our approach ignores none of the input mask, is completely deterministic, and still yields the same asymptotic acceleration of the filter's internal linear solver step.
\subsection{LDL-decomposition based linear solver}
In the refinement algorithm, $\ldlsolve{A}{b}$ is an LDL-decomposition based linear solver designed to operate on 3-channel images, from \cite{Valentin2018}. For completeness, we reproduce that algorithm here:
\begin{align}
\hline
\ldlsolve{A}{b}: \span\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad \nonumber\\
\quad d_1 &= A_{1,1}\nonumber\\
\quad L_{1,2} &= A_{1,2} / d_1\nonumber\\
\quad d_2 &= A_{2,2} - L_{1,2} \circ A_{1,2}\nonumber\\
\quad L_{1,3} &= A_{1,3} / d_1\nonumber\\
\quad L_{2,3} &= (A_{2,3} - L_{1,3} \circ A_{1,2}) / d_2\nonumber\\
\quad d_3 &= A_{3,3} - L_{1,3} \circ A_{1,3} - L_{2,3} \circ L_{2,3} \circ d_2\nonumber\\
\quad y_1 &= b_1\nonumber\\
\quad y_2 &= b_2 - L_{1,2} \circ y_1\nonumber\\
\quad y_3 &= b_3 - L_{1,3} \circ y_1 - L_{2,3} \circ y_2\nonumber\\
\quad x_3 &= y_3 / d_3\nonumber\\
\quad x_2 &= y_2 / d_2 - L_{2,3} \circ x_3\nonumber\\
\quad x_1 &= y_1 / d_1 - L_{1,2} \circ x_2 - L_{1,3} \circ x_3 \\
\hline \nonumber
\end{align}
Where the inputs to this function are a 6-channel image $A$ and a 3-channel image $b$, with channels in $A$ corresponding to the upper triangular part of a $3 \times 3$ matrix.
The output of this function is a 3-channel image $x$ where for each pixel $i$ in the input linear system, $x(i) = A(i) \backslash b(i)$ using an LDL decomposition.
\section{Density estimation algorithm}
\label{sec:density_estimation_algorithm}
The density estimation algorithm is used to inpaint unlabeled pixels and partially automate the process of annotating sky masks. The probability that an unlabeled pixel belongs to the ``sky'' pixels is described in \eq{eq:de}, in which $i$ indicates an ``undetermined'' pixel and $j$ indicates a ``sky'' pixel:
\begin{align}
p_i &= \frac{1}{|\{ \mathrm{sky} \}|} \sum_{j \in \{ \mathrm{sky} \}} K\left(I_i,I_j \right)
\label{eq:de} \\
K(I_i, I_j) &= \frac{1}{\left(2 \pi \sigma^2\right)^{3/2}} \exp\left(-{\frac {\sum_c (I_i^{c} - I_j^{c})^2}{2\sigma^2 }}\right)
\end{align}
$K(\cdot)$ is a multivariate Gaussian kernel with a Euclidean distance between the RGB values of pixels, assuming a diagonal covariance matrix ($c$ indicates the color channel). We use $\sigma=0.01$ as the kernel's standard deviation.
In practice, to reduce computation time we sample $1024$ sky pixels uniformly at random to compute these probabilities.
\section{Model optimization}
\label{sec:model_optimization}
Table~\ref{tab:model_architecture} shows a comparison of the size, latency, and IoU scores of the original model and of the two MorphNet steps. At the end of model optimization we arrive at a model that is more accurate and 27\% smaller.
\begin{table}
\centering
\begin{tabular}{lccc}
& Original & MorphNet & MorphNet\\
& UNet & Shrink & Expand\\
\toprule
Model Size (MB) & 5.1 & 1.7 & 3.7 \\
${IoU}_{0.5}\uparrow$ & 0.9186 & 0.8895 & \textbf{0.9237} \\
Size Reduction & & 66\% & 27\% \\
\bottomrule
\end{tabular}
\captionsetup{justification=raggedright,singlelinecheck=false}
\caption{The model performance before and after optimization with MorphNet and weight quantization to float-16. Inference latency is measured on a $256 \times 256$ image on a mobile CPU (Qualcomm Snapdragon 845) with $4$ threads. Evaluation is performed on our internal dataset, and therefore these results cannot be directly compared with those in Table 1 of the main paper.}
\label{tab:model_architecture}
\end{table}
\section{Sky denoise and comparison to CNN}
\label{sec:sky_denoise_L2SITD}
In this section we show an example of sky-aware noise reduction in a low-light image and compare it to an end-to-end convolutional neural network (CNN) \cite{chen2018learning} that produces a low-light image from a single raw frame. In \fig{fig:noise_reduction_l2sitd}a-c, our system is able to reduce the noise in the skies while preserving the details of the stars and the tree.
\fig{fig:noise_reduction_l2sitd}d-e shows a comparison of our result to the result produced by the CNN of \cite{chen2018learning}. In this comparison, we used a raw frame captured with a similar camera model as was used for training the network in~\cite{chen2018learning} (Sony $\alpha$7S II). Because our white balancing algorithm was not calibrated for the Sony camera, and since color variation can affect the perception of details, we used Photoshop's automatic tool to color-match our results to the results produced by the CNN (as detailed in \cite{liba2019handheld}). Although the sky in the image produced by the CNN has less fine-grained noise compared to our result, our result has less low frequency noise in the skies and preserves more details of the foreground.
\begin{figure}
\includegraphics[width=\linewidth]{figures/sky_denoise_l2sitd_v3.pdf}
\caption{Comparison between a low-light image, with and without sky-aware processing, and the end-to-end trained CNN described in \cite{chen2018learning}. A raw frame was captured with a Sony $\alpha$7S II, the same camera that was used to train the CNN, with an exposure time of 0.1 s. a) The original result. b) The result in (a) with sky-aware processing. (c) Zoomed-in regions of the original image (green) and sky-processed image (magenta). d) The result from the CNN. e) Zoomed-in regions of our result (cyan) and the result of the CNN (orange).}
\label{fig:noise_reduction_l2sitd}
\end{figure}
\section{Refining the annotations of the ADE20K dataset}
\label{sec:dataset_refinement}
In the Experimental Results Section, we chose the ADE20K dataset \cite{zhou2017scene} as our baseline dataset. We selected all the images that have the ``sky'' label and added to them $10\%$ random images without the skies. We do this for both the validations and training parts of the dataset so that in total we have 9187 images from the training set and 885 images from the validation set. We then refine this dataset with two different methods: 1) using the guided filter only (annotated as ADE20K+GF), and 2) using density estimation and the guided filter (annotated as ADE20K+DE+GF).
Creating ADE20K+GF is straightforward: we input the annotated raw masks and the ADE20K images into the weighted guided filter algorithm (described in Section 3.1) with a confidence map of ones in each pixel. The parameters of the guided filter are $s=48$ and, $\epsilon_{\ell} =\epsilon_{c}=0.01$. In order to create ADE20K+DE+GF we had to create a heuristic for the ``undetermined'' label, in which we would apply inpainting using the density estimation algorithm described in Section 3.2.3. We used the following method: a) Run a Laplacian edge filter on the raw ADE20K sky masks to find the sky boundaries; b) Dilate the boundaries with an ellipse kernel with a radius of 4 pixels to generate the ``undetermined'' label; c) Add areas labeled as trees in ADE20K to our ``undertermined'' region. We do this because often the sky can be seen through tree branches and we have found that inpainting the entire tree to be more accurate than using raw annotations. Then, we inpaint the ``undetermined'' region using density estimation. For these experiments, we used a probability threshold of $p_c=0.97$. We then create the confidence map with values: $c_{\mathit{det}} = 0.8$ (for the ``sky'' and ``not sky'' original raw labels), $c_{\mathit{inpaint}} = 0.6$ is for pixels inpainted as skies and $c_{\mathit{undet}} = 0.4$ for the remaining pixels. Finally, we apply the weighted guided filter, with parameters: $s=16$ and, $\epsilon_{\ell} =\epsilon_{c}=0.01$, and inputs: the inpainted annotations, the new confidence maps, and the original ADE20K images. Following the guided filter, in order to drive the intermediate mask values towards the edges of the range: $0$ and $1$, we applied sharpening to the mask, using \eq{eq:sigmoid_postprocessing}.
\begin{equation}
\label{eq:sigmoid_postprocessing}
S(x) = \frac{h(t_s(x-1/2)) - h(-t_s/2)}{h(t_s/2) - h(-t_s/2)}
\end{equation}
In which $x$ is the value of the sky mask, normalized to a range of $[0,1]$, $h(x) = 1/(1 + exp(-x))$ is the sigmoid function, and $t_s$ is the sharpness factor. We found that a sharpness factor, $t_s=15$ produces visually accurate masks.
\section{User study results}
\label{sec:user_study_results}
The goal of the user study is to show that raw binary annotations, demonstrated here using the ADE20K dataset \cite{zhou2017scene}, are too rough for computational photography applications. Because refined masks are more suitable for sky editing, a quantitative evaluation of mask accuracy should be performed using refined annotations as the ground-truth. The subjects were asked to rate which masks are more accurate: the raw annotations, the annotations refined only with the guided filter (GF) and the annotations refined with both density estimation and guided filter (DE+GF). Example images are shown in \fig{fig:dataset_refinement_comparison}. The annotations were evaluated one pair at a time. The images for the study were 100 randomly picked images with skies from the ADE20K validation set. We had 21 participants take the study. The results are in \tab{tab:user_study_results}. From the results we see that the users preferred masks refined with both DE and GF over only GF and any refinement was preferred over the raw annotations.
\begin{table}
\centering
\resizebox{\linewidth}{!}{
\begin{tabular}{lccc}
& Raw & GF & DE+GF\\
\toprule
Raw versus GF & 629 (30\%)& 1471 (70\%)& \\
Raw versus DE+GF & 365 (17.4\%) & & 1735 (82.6\%) \\
GF versus DE+GF & & 476 (22.7\%) & 1624 (77.3\%) \\
Total & 994 (15.8\%) & 1947 (30.9\%) & 3359 (53.3\%) \\
\bottomrule
\end{tabular}
}
\captionsetup{justification=raggedright,singlelinecheck=false}
\caption{The results of a user study comparing raw ground truth sky masks and refined sky masks from the ADE20K dataset.}
\label{tab:user_study_results}
\end{table}
\begin{figure}
\includegraphics[width=\linewidth]{figures/refined_dataset_examples.pdf}
\caption{Example images from the user study. In these images, the sky was darkened using either the original sky mask annotation of the ADE20K dataset or refined sky annotations. The user study evaluated the user's preference for images (b), (c), or (d). Sky darkening was applied to emphasize the shape of the sky mask, and is not an indication of our proposed darkening scheme which is described in Section 3.4 of the main paper}.
\label{fig:dataset_refinement_comparison}
\end{figure}
\section{Evaluation metrics}
\label{sec:evaluation_metrics}
Here we define the segmentation evaluation metrics used in our experiments. We use two metrics that take as input the binarized versions (at 0.5) of our ground-truth alpha mattes and of our predictions: mean intersection-over-union (mIOU) and misclassification rate (MCR):
\begin{align}
\operatorname{mIOU_{0.5}} &= \sum{\frac{TP}{TP+FP+FN}} \nonumber \\
\operatorname{MCR_{0.5}} &= \sum{\frac{FP+FN}{M}}
\label{eq:binary_metrics}
\end{align}
where TP, FP and FN are the true positive, false positive, and false negative, respectively, and M is the number of pixels.
We also present a series of non-binarized error metrics: root mean square error (RMSE), mean absolute error (MAE), boundary loss (BL), and Jensen-Shannon Divergence (JSD):
\begin{align}
\operatorname{RMSE}(X, Y) &= \sqrt{\frac{1}{M} \sum_i (X_i - Y_i)^2} \nonumber \\
\operatorname{MAE}(X, Y) &= \frac{1}{M} \sum_i \left| X_i - Y_i \right| \nonumber \\
\operatorname{BL}(X, Y) &= \sqrt{\frac{1}{M}\sum_i (\nabla X_i - \nabla Y_i )^2 \nonumber} \\
\operatorname{JSD}(X\parallel Y) &= \frac{1}{M} \sum_i \bigg( \frac{1}{2} \operatorname{KL} \left(X_i \parallel \frac{X_i+Y_i}{2} \right) + \nonumber \\
& \hphantom{= \frac{1}{M} \sum_i \bigg( } \, \frac{1}{2} \operatorname{KL}\left(Y_i \parallel \frac{X_i+Y_i}{2} \right) \bigg)
\label{eq:continous_metrics}
\end{align}
Where $X$ and $Y$ are the predicted and true alpha mattes, $\nabla$ indicates the spatial gradient of an image, and $\operatorname{KL}(\cdot)$ is the KL divergence between two Bernoulli distributions (the true and predicted alpha matte at each pixel).
\begin{figure}
\includegraphics[width=\linewidth]{figures/step_by_step_results_main_v2.pdf}
\caption{The sky effects we propose, applied in sequence. Note that these effects are independent and do not rely on one another. a) The original image. b) Sky-specific noise reduction. c) Tonemapping applied to darken the sky. d) sky-inferred auto white balance gains applied according to the sky mask.}
\label{fig:sky_optimization_comparison}
\end{figure}
\begin{figure*}[t!]
\centering
\includegraphics[width=\textwidth]{figures/ntire_step_by_step_results_gallery_v2.pdf}
\caption{The sky affects applied one after the other. a) The inferred sky mask. b) The upsampled and refined mask, using our modified weighted guided filter. c) The original image, without sky effects. d) Sky-specific noise reduction is applied to the sky. The readers are encouraged to zoom-in to see the difference in noise characteristics. e) Tonemapping is applied to darken the sky. f) The sky-inferred auto white balance gains are applied to the sky pixels.}
\label{fig:sup_step_by_step_results}
\end{figure*}
\section{Examples of the sky effects}
\label{sec:additional_examples}
The effects shown in \fig{fig:sky_optimization_comparison} and \fig{fig:sup_step_by_step_results} demonstrate the sky-aware processing steps performed by our pipeline. As shown in these figures, our procedure is able to accurately segment the sky and automatically improve its appearance for a variety of scenes. The effects are relatively subtle, as we have calibrated them to maintain the reliability of the scene and only alleviate the challenges of low-light imaging, without changing the image too much or potentially introducing new artifacts.
| {'timestamp': '2020-06-19T02:04:47', 'yymm': '2006', 'arxiv_id': '2006.10172', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10172'} | arxiv |
\section{Introduction}\label{sec:introduction}
In this article, we present a new project of real-time visualisation of music performance. It is part of a broad objective, by the first author and especially within the context of his \emph{MIRAGE} project\footnote{\url{https://www.uio.no/ritmo/english/projects/mirage}}, to design tools to make music more easy to understand and more engaging, especially for non-expert listeners.
The presented project is focused on a String Quartet interpretation of the last piece of \emph{The Art of Fugue} by Johann Sebastian Bach. In order to provide a very rich musicological visualisation of the piece, we decided to prepare the analysis in advance and to synchronise the live performance with the help of score-following technologies.
The paper is organised as follows. Section \ref{previous} gives a brief overview of previous works, including ours. Section \ref{philo} formalises the underlying principles founding our proposed approach. Section \ref{scenario} describes what the visualisation is about, concretely. Section \ref{technical} details the underlying technical aspects and especially the score-following approach.
In the following, a distinction needs to be made between pitch tra\emph{ck}ing (detecting pitch height from audio, frame by frame, as described in Section \ref{tracking}) and pitch tra\emph{c}ing (drawing the pitch line in the visualisation, as described in Section \ref{tracing}).
\section{Previous Works in Music Visualisation} \label{previous}
\subsection{Brief State of the Art}
There is a very large number of approaches that have been proposed for video visualisation of music as it evolves along time. For instance, there has been discussion about the application of music-colour synaesthetic mappings in live ensemble performance \cite{Ng}. A system architecture has been proposed to build real-time music visualisations rapidly, with the view to provide a sense of musical experience to the users \cite{Nanayakkara}.
\subsection{Our Previous Works in Music Visualisation}
This interest in music visualisation stems from the first author's work in audio and music feature extraction and especially the design of \emph{MIRtoolbox} \cite{mirtoolbox}. This toolbox was initially conceived with the initial aim to better understand the affective and emotional impact of music \cite{eerola}. First video visualisations were made in 2012\footnote{\url{https://www.youtube.com/watch?v=H_SpFh2SPmg}}, so far focusing on timbral and dynamical aspects of audio recordings. Another visualisation\footnote{\url{https://www.youtube.com/watch?v=8S7LyEkzWGE}} was aimed at highlighting audio and musical features contributing to emotions dynamically expressed by music \cite{power}. Recently, we designed a new type of visualisation with transformation of video shootings based on audio analysis, and applied to the production of a music
video\footnote{\url{https://www.youtube.com/watch?v=L1FaxT74hTk}}.
\section{General Philosophy} \label{philo}
This visualisation project is guided by a few general desiderata, presented below, that may look incompatible at first sight, due to conflicting constraints. An additional principle addresses this conundrum.
\subsection{Desiderata}
\subsubsection{Accessible and Self-Explanatory} \label{accessible}
The visuals should be understandable by a largest public. Hence no music expertise should be required. In particular, music score representations should not be displayed. The visuals should also be self-explanatory. No verbal or text explanation should be necessary for the viewers to grasp the logic.
\subsubsection{Expressive while Thrifty} \label{minimal}
The visuals should be as impactful as possible while at the same time being minimalist with regard to the use of visual strategies. For instance, there is no need to use colors, forms or textures if they are not motivated by a particular need to convey a particular musical characteristic.
\subsubsection{Conveying the Richness of Music} \label{richness}
One aspiration is to offer a visual equivalent of the way listeners --- and especially experienced music lovers --- perceive, grasp and appreciate music through their ears. Music is generally a rich experience consisting of a flow of events appearing together or successively and building rich interactions. Listeners are immersed by this flow of information, inciting to participate and move with the music. One objective is to convey this experience visually.
\subsection{Addressing Conflicts in the Desiderata}
\subsubsection{A Visual Complexity Assimilable Gradually} \label{gradually}
Clearly, describing the whole musical experience visually may lead to a very complex representation that might be unfathomable at first sight. Although complex stimuli might appeal to the spectators' interest, in order to correctly address desideratum \ref{accessible}, there should be a guiding thread within the flow of stimuli that the spectator can rely on to progressively grasp what is happening and discover little by little the logic of the whole visualisation.
\section{Visualisation scenario} \label{scenario}
The proposed scenario exploits the particular characteristics of string quartet fugues , where each of the four instruments plays a monody and where the subtle changes in pitch, dynamics and timbre play an important role. In a fugue, a \emph{subject} --- a musical theme --- is introduced at the beginning in imitation --- i.e., repeated successively on each voice at different registers --- and reappears frequently in the course of the composition. The particular piece under study, \emph{Contrapunctus XIV}, is actually structured into three sections, each introducing a new subject.
\subsection{Polyphonic Pitch Tra\emph{c}ing} \label{tracing}
Each instrument plays a single monodic line where successive notes are clearly separated. The slow tempo and the rare use of small rhythmic values such as sixteenth notes also contribute to the clarity of the melodic lines, and to a focus on pitch, dynamic and timbral shaping of each successive notes. As such, it seemed relevant to simply display pitch curves, resulting directly from the temporal tracking of the fundamental frequency. The pitch curves are progressively drawn from left ro right as time goes by. Each instrument generates its own pitch curve.
\subsubsection{Rhythm Quantisation} \label{quantisation}
As we will see in Section \ref{paradigmatic}, the pitch curves will be superposed so that similar motives could be compared. For that reason, in order to allow their temporal alignments, the horizontal axis directing the pitch curves needs to be temporally quantised, in the sense that it should be graduated in rhythmic values, as indicated in the score. The rhythmic quantisation of the live performance is made possible thanks to score following capabilities, described in section \ref{follower}.
The fact that the tempo is not constant --- and actually fluctuates a lot throughout the piece --- raises a technical issue: How to progressively draw a pitch curve along this quantised axis if there is uncertainty concerning the quantised position of each successive instant?
For each note, a hypothetical tempo --- i.e. a duration in seconds for that note --- is inferred. In one strategy, $S_1$, the tempo is assumed to be constant, and the hypothetical tempo is identified with the tempo related to the previous note.
Another strategy, not considered here, would consist in measuring the tempo variation throughout the piece for different performances of the same musicians and use it as a guide for the tempo change expectation. If the tempo changes are guessed correctly, they would first appear in the visualisation, and it would look as if the performers follow the visuals, and in the other case, the behavior of the visualisation might appear random, which might be undesirable.
Let $t$ be the performance time and $x$ the time axis in the visualisation. Let's consider a note starting at time $t_i$ and ending at time $t_{i+1}$, corresponding to the metrical positions located in abscissae $x_i$ and $x_{i+1}$ . Let's suppose that the chosen tempo for the visualisation is such that the note is expected to end at time $t'_{i+1}$. Three cases need to be considered:
\begin{itemize}
\item If the expected tempo is exact --- i.e., $t'_{i+1} = t_{i+1}$ ---, the curve is drawn in a simple way, by using the simple mapping $m_t$ defined, for $t \in [t_i, t_{i+1}]$ as
\begin{equation} \label{defaultdrawing}
m_t: \theta \in [t_i, t] \mapsto x_i + \frac{\theta - t_i}{t'_{i+1} - t_i} (x_{i+1} - x_i),
\end{equation}
which means that the part of the curve already drawn does not modify along time afterwards. It remains constant afterward, i.e., for $t \geq t_{i+1}$,
\begin{equation} \label{enddrawing}
m'_t: \theta \in [t_i, t_{i+1}] \mapsto x_i + \frac{\theta - t_i}{t_{i+1} - t_i} (x_{i+1} - x_i),
\end{equation}
\item If the actual tempo is slower --- i.e., $t'_{i+1} < t_{i+1}$ ---, the curve is drawn in the same way until reaching the expected end of note $t'_{i+1}$, so equation \ref{defaultdrawing} is valid for $t \in [t_i, t'_{i+1}]$. On the other hand, once point $x_{i+1}$ has been reached, the mapping $m_t$ for $t \in [t'_{i+1}, t_{i+1}]$ becomes
\begin{equation} \label{correctdrawing}
m''_t: \theta \in [t_i, t] \mapsto x_i + \frac{\theta - t_i}{t - t_i} (x_{i+1} - x_i),
\end{equation}
which means that curve is compressed to accommodate the rest of the note in the same visual space. Once time $t_{i+1}$ is reached, the mapping stabilises to equation \ref{enddrawing}.
\item If on the contrary the actual tempo is faster --- i.e., $t'_{i+1} > t_{i+1}$ ---, the curve is drawn in the same way until reaching the unexpected end of note $t_{i+1}$, so equation \ref{defaultdrawing} is valid for $t \in [t_i, t_{i+1}[$. But as soon as the note is ended, the mapping is corrected and from that point the mapping switches to equation \ref{enddrawing}. For the sake of clarity following desideratum \ref{accessible} and in order to avoid emphasizing excessively this disruption, an abrupt change in the graphical representation should be avoided, and the transition between mappings $m_t$ and $m'_t$ is shown progressively, in accordance with ``fluid'' design principles.
\end{itemize}
\subsubsection{Pitch Height Ordering} \label{pitch}
The disposition of pitch curves on the Y-axis is less of a problem, as a simple conversion of frequencies on a logarithmic scale gives an adequate representation. Besides, accurately representing the relative location in pitch of each instrument enables to convey the registral differences. Moreover, the rare cases of swapping of register order between voices (the second violin crossing for instance the first violin and playing the highest pitch for a few notes) can be immediately noticed in the visualisation. By associating a different color with each instrument (for instance red for cello, black for alto, blue for the second violin and orange for the first violin), this makes this rare disruption in the natural ordering in pitch more noticeable.
Vibrato, portamento and any other form of pitch deviation related to performance are directly exhibited by the pitch curve, and additional treatment to make them accessible to the viewers do not seem necessary in our case.
The actual set of pitch heights used as implicit reference for the pitch space defines both diatonic and chromatic scales. This would lead in theory to a graduation of the pitch axis through a large set of horizontal lines. Following desiderata \ref{accessible}, the display of the whole diatonic or chromatic scale is avoided. Only pitches that are actualized are indicated with horizontal lines. The tonal structuration of this set of lines is further discussed in section \ref{tonal}.
\subsubsection{Dynamics and Timbre}
Amplitude for each pitch curve is represented by controlling the width of the curve. Timbral aspects will also be depicted in future works.
\subsection{Dynamic Paradigmatic Analysis} \label{paradigmatic}
So far the position of the pitch curves on the time axis (as discussed in section \ref{quantisation}) was expressed with respect to the metrical grid given by the notated music. It was implicitly assumed that the X-axis in the visualisation represented the overall temporal evolution of the piece of music from beginning to end.
Yet such strategy would only show how the music sounds like at each individual instant, without any structured reference with what has been played, apart from the mere display of the left part of the curve before the given time. Music listening is a lot about inferring associations from what we are currently hearing and we previously heard. This leads to the inference of a structural understanding of the piece, and in particular of a thematic and motivic lexicon, where music sequences of various sizes are considered as repetitions of themes and motives. Following desideratum \ref{richness}, this structural information should be depicted in the visualisation.
One solution commonly used in music analysis is to add annotations on top of the score --- or in our case, the pitch curve ---, such as boxes around sequences of notes that are repeated. Boxes would be distinguished with respect to color, width, line style, etc., in order to denotate particular theme or motive.
Figure \ref{paragfig} gives an idea of the type of motivic structure that can be found in the beginning of \emph{Contrapunctus XIV}.
\begin{figure*}[t]
\centering
\includegraphics[width=1.5\columnwidth]{paradigmatic}
\caption{Motivic analysis of the beginning of \emph{Contrapunctus XIV}. The first subject is shown in red and its corresponding countersubject in blue. \label{paragfig}}
\end{figure*}
The problem with that formalisation is that it makes the visualisation more complicated, more technical, and would demand a lot of additional attention from the spectators, which would contradict desideratum \ref{minimal}. In particular, they would need to find by themselves the position in the score (or the overall set of pitch lines) of each type of boxes, which would quickly become tedious. Besides, it does not seem feasible to display the whole pitch curve on one single screen.
A fruitful solution to this problem can be found in the notion of paradigmatic analysis. It was initially a method designed by Levi-Strauss in order to structure texts, and it has then been introduced in music analysis by Nicolas Ruwet \cite{Ruwet} (cf. an example in Figure \ref{geisslerlied}), and used extensively in music semiotics \cite{Nattiez}. The idea is simply to align vertically musical sequences that share a same motivic or thematic identity. By compiling the successive occurrences one below each other, the whole score can be read from left to right and from top to bottom.
\begin{figure}[t]
\centering
\includegraphics[width=\columnwidth]{ruwet}
\caption{Paradigmatic analysis of a \emph{Geisslerlied} \cite{Ruwet}.\label{geisslerlied}}
\end{figure}
We partly follow this strategy by cutting the pitch lines into segments and aligning those corresponding to repetitions of a same motif or theme vertically. Contrary to the paradigmatic analysis, however, we do not use the vertical axis as a way to distribute the sequences over time, because the Y-axis is already used for representing the whole 4-voice polyphony.
Since our visualisation is dynamic, evolving over time, we do not need to care about the readability of the whole representation once everything is drawn, but only about the understandability of the dynamic progression of the visualisation. As such, it is not a problem to superpose the repetitions of a same pattern one on top of each other. If they are transposed (which is generally the case in fugues), the corresponding vertical translation will be clearly shown. Besides, the music operation of inversion (very typical to fugues as well) will lead to the vertical inversion of particular occurrences as well.
Since the pitch curves are not drawn simply from left to right anymore but may appear at any place in the screen, the part of the curve being extended at a given time should be clearly visible. For that purpose, we use the parameter of line width to also control the recency of each part of the pitch curves. The part of the curve most recently appears thicker while the older sections become thinner and thinner.
Besides, the rightmost point of the pitch curve corresponding to the current instant is highlighted with a clearly visible pointer, which has the color related to the instrument, as mentioned in section \ref{pitch}.
Figure \ref{screenshots} presents the progressive construction of the para\-digmatic visualisation of the beginning of \emph{Contrapunctus XIV}. The first 5 bars correspond to the first subject, while the rest of the excerpt corresponds to its counter-subject. Only the first occurrence of the counter-subject is shown here. We notice that the successive 1-bar repetition in the bass line in bars 8---9 and 9---10 (purple box in figure \ref{paragfig}) is folded, the second occurrence on top of the first one. Similarly, for the tenor part, bar 12 is an extra bar extending further bar 11, and is therefore folded in the visualisation.
\begin{figure*}[t]
\centering
\includegraphics[width=\columnwidth]{screenshot}
\includegraphics[width=\columnwidth]{screenshot2}
\includegraphics[width=\columnwidth]{screenshot3}
\includegraphics[width=\columnwidth]{screenshot4}
\includegraphics[width=\columnwidth]{screenshot5}
\includegraphics[width=\columnwidth]{screenshot6}
\caption{Screenshots of the current version of the visualisation showing various moments at the beginning of \emph{Contrapunctus XIV}.
On the top right of each image is added the circular tonal representation, with the main triad D-F-A.
Successively from top to down, left to right: end of bars 7, 8, middle of bar 9, end of bar 10 and middle and end of bar 12.
\label{screenshots}}
\end{figure*}
\subsection{Tonal Analysis} \label{tonal}
Concerning the tonal dimension of the music, it is necessary to highlight hierarchies between pitches. As the key of the piece is D minor, it seems reasonable to highlight the main triad D-F-A, which is shown in the visualisation in the form of a horizontal grid. All the lines corresponding to a same pitch class are displayed with a same color (for instance\footnote{Examples of colors are indicated in this paper. They will be tweaked so as to optimise the clarity of the representation and the hierarchy of importance.}, red for D, cyan for F and green for A). Only lines corresponding to pitches that have been actually played are shown, so they progressively ``light up'' as the music goes.
Attentive spectators will notice that while many entries of the fugue's first subject go from D (red) to A (green) and back to D, other entries go from A to D and back to A, which has a slight shorter ambitus (fourth instead of fifth, shown respectively by the red and black lines in Figure \ref{screenshots}.). The visualisation thus explicitly reveals the dichotomy between \emph{subject} and \emph{answer} in a fugue.
To make explicit the concept of pitch classes, which plays an important role in tonal analysis, as we will discuss in the next paragraphs, a circular representation of pitch classes is shown in addition to the pitch curve representation. This is illustrated in Figure \ref{screenshots}\footnote{The tonal visualization has not been implemented yet, and is therefore manually superimposed onto the screenshots.}. When the pitch classes D, A and F successively appear at the very beginning of the fugue, they appear at the same time in the circle, using the same color code as previously defined. Here also, this core triad defining the main key of the piece will remain displayed during the whole piece.
One core characteristic of tonality is that the music can be considered as a succession of triads (simple triads or seventh chords). These successive triads are shown as triangles on the circle. Only the current triad is shown. Seventh chords are shown with a triangle representing the main triad, plus a second little triangle between the fifth, seventh and root, as shown in Figure \ref{screenshots}, panels 1, 2 and 4.
For any given triad, if the root does not belong to the D-F-A triad, it is indicated in orange both in the circle and as a horizontal line. Same for the fifth but with a distinction: it is shown in dark green if it is a perfect fifth, and grey in the other cases (not illustrated in the figure). The colors is also used for the side of the triangle linking the root and the fifth. Similar principles are used for the third, but with a distinction between major and minor thirds. Similar principles are defined for the seventh degree.
As soon as the triad has been replaced by a subsequent one, the previous triad is not displayed anymore, neither in the circle, nor as horizontal lines.
The last concept of importance that is visualised is the descending fifth transition, so important in tonal music for its role in cadences but more generally in the ``circle of progression''. Descending-fifth transitions are shown through an actual rotation of the triangle in the circle. At the same time, pitch classes that remain constant through the transition are highlighted as such, while voice leading movements are shown through translations, leading tone going one degree up and the seventh one degree down. Finally, when the descending fifth corresponds to a cadence, arriving to an important tonic chord, the rotation ends with a slightly flamboyant animation.
These tonal considerations will surely appear very arcane at first sight for a non-expert spectator. Following principle \ref{gradually}, these more complex consideration should be displayed in a rather unobtrusive way, available to curious viewers who already understand the rest of the visualisation.
\subsection{General Structure of the Piece}
\emph{Contrapunctus XIV}, is a fugue with three different subjects, defining three successive parts, each starting when the corresponding subject first appears. It should be noted that when the second, or third, subject appears, the previous one(s) can still occur from time to time.
At the beginning, the cello ($c$) plays the first subject $A$ alone, which is displayed on the leftmost part of the screen. Then the alto ($a$) plays the second entry ($A_2$) of $A$ while $c$ plays the countersubject of $A$. It should be noted that in this fugue the countersubjects are not exact repetitions of each other, but can be rather characterised as looser passages structured by specific motivic cells.
Hence these countersubjects are not represented as single curves but as a succession of segments related to the different motivic cells. For instance in this first countersubject, related to $A_1$, there is a successive repetition of a small pattern with transposition, which is shown on the right of panel 4 of Figure \ref{screenshots}.
The first section continues similarly with the successive entries $A_i$ of $A$ while the other voices continue their entries and develop new motivic materials. All entries of subjects remain visible (while still being progressively dimmed as indicated in section \ref{paradigmatic}). On the contrary, to simplify the visualisation, some of the entries' continuations and developments completely fade away after some point if they are not deeply related to parts that will appear later in the piece.
The first entry by the second violon ($v_2$) of the second subject $B$ appears, at measure 114, as one of the many developments within the dense network related to subject A. But as $v_2$ continues its long entry solo, it progressively occupies the middle part of the screen, and all the material related to $A$ fades away, so that this new $B$ entry suddenly becomes alone.
It should be noted that $B$ is far longer than the other two subjects, but includes internal motivic repetitions, which are represented as such, through vertical superposition of small lines.
Then the first violin ($v_1$) plays $B_2$ while $v_2$ plays the countersubject of $B_1$, and so on. Then at measure 149, $c$ plays a new entry of $A$ (leading to a progressive visual reactivation of the network of lines related to $A$) while $v_1$ plays
an entry of $B$ and so on.
There are also rare cases of multiple-voice patterns, where several voices play a pattern that is repeated several times successively. This is a rare case where several pitch curves are superposed not because of their thematic identity but because of their simultaneity.
At measure 193, the third subject $C$ is introduced by $a$. This theme, displayed on the right part of the screen, is known as the ``BACH'' theme as it starts with B$\flat$, A, C and B$\natural$. So those letters are displayed next to the pitch curve (as well as on the pitch class circle), which also gives some dramatic effect to the visual.
In measure 233, $v_2$ plays a final entry of $B$ while $c$ starts a final entry of $A$. These two final entries are particularly highlighted in the visualisation. On measure 239, $v_2$ and $c$ end abruptly, while $a$ continues a short imitation of the ending of $B$ by $v_2$ for just one more measure, and everything stops abruptly, as the composition of the piece is unfinished.
The whole visualisation then fades away with only the four letters B A C H remaining.
\section{Technical Solution} \label{technical}
The data-flow diagram of the proposed solution developed for this project is shown in Figure \ref{architecture}.
\begin{figure*}[t]
\centering
\includegraphics[width=1.7\columnwidth]{architecture}
\caption{Overall architecture of the proposed solution.\label{architecture}}
\end{figure*}
Each of the four instruments is captured using one of four DPA 4060 close-up microphones. The audio is digitized and mixed into a single 4-channel audio stream using a Behringer UMC404HD audio interface (to be confirmed), which is plugged via USB to a MacBook Pro.
The software part is integrated into a single Mac app developed in Swift. Each of the four channel is fed to a Pitch Tracking module, which sends information about pitch, amplitude and timbre for each successive frame in each instrument to the Visualisation module. In parallel, the four-channel audio stream is also summed into one mono channel and fed to the Score Following module, which sends information about the current position in the score to the Visualisation module as well.
\subsection{Pitch Tra\emph{ck}ing} \label{tracking}
The audio signal is decomposed into successive frames of length 50 ms and of hop 25 ms. For each successive audio frame, pitch has been so far estimated by computing the autocorrelation function. To speed up the computation, autocorrelation function is computed using Fast Fourier Transform (FFT), using the vDSP library of Apple's \emph{Accelerate} framework. The frequency corresponding to the global maximum of the autocorrelation function is selected as the fundamental frequency.
In the first prototype, the analysis is carried out on synthesized rendering of MIDI files. Future works will focus on the particular characteristics of string instruments. Mechanisms will also be developed to avoid incorrect pitch detection due to leakage between instruments.
Other signal processing processes are under consideration to extract timbral descriptions of the sound.
\subsection{Score Following} \label{follower}
Score following refers to the task and technologies for aligning performances of musical pieces to their score in real-time~\cite{Mueller:2015,Arzt:2016}.
The \emph{dynamic time warping} (DTW) algorithm is the method of choice for performing audio-to-audio alignments \cite{Gadermaier:2019}.
DTW is a general dynamic programming technique for finding the best alignment between two sequences of observations.
For the system presented in this paper, we use the \emph{on-line time warping} (OLTW) algorithm~\cite{Dixon:2005,Arzt:2016}.
This algorithm adapts DTW to be used in real-time scenarios by computing the alignment incrementally.
We perform audio-to-score alignment by (manually) annotating a live recording of \emph{Contrapunctus XIV} performed by DSQ, which we will refer to in the following as the \emph{reference}.
For this recording, the positions of the beats were annotated using Sonic Visualiser\footnote{\url{https://sonicvisualiser.org}} by two annotators with 10+ years of formal musical education.
These beat annotations are then averaged across annotators.
As spectral features to compute the input and reference sequences we used the modified MFCC features described in \cite{Gadermaier:2019}.
These features have been successful in aligning opera in real time~\cite{Brazier:submitted}.
The score follower works as follows:
\begin{enumerate}
\item \textit{Before the beginning of the performance}: Extract spectral features for the annotated reference recording and set the current position of the score follower to 0.
\item \textit{During the performance}:
\begin{enumerate}
\item Mix the the individual tracks into a single (mono) track.
\item For each new audio frame from the mixed input stream, compute the spectral features.
\item Update the current position of the score follower using OLTW.
\end{enumerate}
\end{enumerate}
\iffalse
To assess the accuracy of the score follower, the recording of \emph{Contrapunctus XIV} was time-stretched without pitch shifting\footnote{ Using the pyrubberband library: \url{https://github.com/bmcfee/pyrubberband}.} to be $\{0.25, 0.75, 1.25, 1.5, 2\}$ its length.
Results are found in Table \ref{tab:alignment}.
Python code for the real-time score follower is available online\footnote{\url{link_to_repo.git}}.
\fi
\subsection{Visualizer}
The module draws the pitch curves --- and their transformations based on amplitude and timbre --- related to each instrument into successive segments, and places them in the screen to form the paradigmatic analysis, as discussed in section \ref{paradigmatic}. Under the pitch curves are also displayed horizontal lines corresponding to important pitch levels related to the tonal analysis, as explained in section \ref{tonal}. The module also draws the tonal circle and the successions of triads and seventh chords. It also displays some particular events such as the pitches B A C H and the particular emphasis on the last entry of subjects $A$ and $B$.
Before the real-time process, the paradigmatic analysis is loaded into a particular data structure, containing for each voice (i.e., each instrument) the list of successive segments.
Each segment is represented by a triplet $(t_1, t_2, x_1)$, where:
\begin{itemize}
\item $t_1$ and $t_2$ are the time positions of the start and end of the segment, expressed as positions in the score, and
\item $x_1$ is the abscissa of the start of the segment in the visual representation.
\end{itemize}{}
The tonal analysis is loaded into another data structure, containing the list of successive chords, with also indications of the falls of fifths. Another list indicates when each horizontal lines corresponding to a pitch from the main triad D, F and A lights up.
\subsection{Control Interface}
A user's interface is also being designed to allow external control of the system. This will enable to control a number of parameters before and during the concert, related in particular to the amplitude of the input signals or the tuning. This will also allow to manually assign the position in the score in case of problems with the score following or of unplanned performance issues from the musicians' side.
\section{Future Works}
The system is currently under development.
The visualisation will be premiered at a Danish String Quartet concert, which had to be been postponed to May 22, 2021, at the Concert Hall of the Royal Danish Academy of Music in Frederiksberg. This leaves a comfortable amount of time to improve the visualisation, in particular related to pitch tracking, and to improve clarity, richness and aesthetic appeal.
The audience will be invited to fill out a questionnaire, to evaluate the fulfillment of desideratum \ref{accessible}, i.e., that the visualisation should be accessible and self-explanatory to a largest public. The visualisation will also be published online, with a corresponding online questionnaire.
In future works, we plan to generalise the system to broader musical contexts, through the integration of polyphony, of various musical forms. We plan also to integrate a polyphonic pitch tracker that would not require the use of multi-channel instrument pickups, but simply a single mono or stereo pickup. The score following might be used as a guiding point for the pitch tracking.
The musicological analysis, here the paradigmatic and tonal analyses, are for the moment performed manually. In longer term we plan to integrate our systems of automated motivic and structural analysis. By integrating also automated transcription systems, the whole process could be carried out without the need of a score and therefore of a score follower.
\begin{acknowledgments}
This work was partially supported by the Research Council of Norway through its Centers of Excellence scheme, project number 262762 and the MIRAGE project, grant number 287152; the European Research Council (ERC) under the European Union’s Horizon 2020 research and innovation programme under grant agreement No. 670035 (project ``Con Espressione"); and the Marie Sk\l{}odowsa-Curie grant agreement number 765068, MIP-Frontiers.
This visualisation project is part of a larger project, the MusicLab5 Copenhagen 2020 event, under the initiative of Simon H{\o}ffding, which has been postponed to 2021. We would like to warmly thank the musicians of the Danish String Quartet and Simon H{\o}ffding for offering us this fantastic opportunity to carry out this project.
The score in Figure \ref{paragfig} was initially typset by Tim Knigge, and made available through the Mutopia project\footnote{\url{http://www.mutopia.org}.}.
\end{acknowledgments}
| {'timestamp': '2020-06-19T02:04:30', 'yymm': '2006', 'arxiv_id': '2006.10168', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10168'} | arxiv |
\section{Introduction}
The estimation of nonlinear dynamical systems with continuous states and inputs is generally based on data collection procedures inspired by the study of optimal input design for linear dynamical systems \cite{schoukens2019nonlinear}.
Unfortunately, these data collection methods are not guaranteed to enable the estimation of nonlinear systems. To resolve this issue, studies of system identification either assume the available data is informative enough for estimation \cite{hong2008model, ljung1987system, schoukens2019nonlinear} or consider systems for which i.i.d. random inputs produce informative data \cite{bahmani2019convex, foster2020learning, oymak2018stochastic,sattar2020non}.
However, as we will see, there are many nonlinear dynamical systems that cannot be estimated without a judicious choice of inputs.
Inspired by experimental design and active learning, we present a data collection scheme that is guaranteed to enable system identification in finite time. Our method applies to dynamical systems whose transitions depend linearly on a known feature embedding of state-input pairs. This class of models can capture many types of systems and is used widely in system identification \cite{hong2008model,ljung1987system}. For example, \citet{ng2006autonomous} used such a model to estimate the dynamics of a helicopter and \citet{brunton2016discovering} showed that sparse linear regression of polynomial and trigonometric feature embeddings can be used to fit models of the chaotic Lorentz system and of a fluid shedding behind an obstacle. These models can be parametrized as follows:
\begin{align}
\label{eq:system}
\vb x_{t + 1} = A_\star \phi(\vb x_t, \vb u_t) + \vb w_t,
\end{align}
where $\vb x_t$ and $\vb u_t$ are the state and input of the system at time $t$, and $\vb w_t$ is stochastic noise. The feature map $\phi$ is assumed known and the goal is to estimate $A_\star$ from one trajectory by choosing a good sequence of inputs. The input $\vb u_t$ is allowed to depend on the history of states $\{\vb x_j\}_{j = 0}^t$ and is independent of $\vb w_t$.
The class of systems \eqref{eq:system} contains any linear system, with fully observed states, when the features include the states and inputs of the system. Moreover, any piecewise affine (PWA) system can be expressed using \eqref{eq:system} if the support of its pieces is known. First introduced by \citet{sontag1981nonlinear} as an approximation of nonlinear systems, PWA systems are a popular model of hybrid systems \cite{borrelli2017predictive,camacho2010model,heemels2001equivalence} and have been successfully used in a wide range of applications \cite{borrelli2006mpc,geyer2008hybrid,han2017feedback,marcucci2017approximate,sadraddini2019sampling,yordanov2011temporal}.
While linear dynamical systems can be estimated from one trajectory produced by i.i.d. random inputs \cite{simchowitz2018learning}, the following example shows that this is not possible for PWA systems.
\begin{example}
\label{ex:intro}
Let us consider the feature map $\phi : \mathbb{R}^d \times \mathbb{R}^d \to \mathbb{R}^{3d}$ defined by:
\begin{align*}
\phi(\vb x, \vb u) = \begin{bmatrix}
\vb x \cdot \mathds{1}\{\norm{\vb x} \leq \frac{3}{2}\} \\
\vb x \cdot \mathds{1}\{\norm{\vb x} > \frac{3}{2}\}\\
\vb u \cdot \mathds{1}\{\norm{\vb u} \leq 1\}\}
\end{bmatrix},
\end{align*}
where $\mathds{1}\{\cdot\}$ is the indicator function and the multiplication with $\vb x$ is coordinatewise.
We assume there is no process noise and let $A_\star = \begin{bmatrix} \frac{1}{2} I_d & A_2 & I_d \end{bmatrix}$ for some $d \times d$ matrix $A_2$ and the $d \times d$ identity matrix $I_d$. Also, we assume $\vb x_0 = 0$.
Then, since the inputs to the system can have magnitude at most $1$, the state of the system can have magnitude larger than $3/2$ only if consecutive inputs point in the same direction. However, the probability that two or more random vectors, uniformly distributed on the unit sphere, point in the same direction is exponentially small in the dimension $d$. Therefore, if we used random inputs, we would have to wait for a long time in order to reach a state with magnitude larger than $3/2$.
On the other hand, if we chose a sequence of inputs $\vb u_t = \vb u$ for a fixed unit vector $\vb u$, we would be guaranteed to reach a state with norm larger than $3/2$ in a couple of steps. Hence, despite the input constraint, we would be able to reach the region $\norm{\vb x} > 3/2$ with a good choice of inputs. \exend
\end{example}
Therefore, the estimation of \eqref{eq:system} requires a judicious choice of inputs. To address this challenge we propose a method based on trajectory planning. At a high level, our method repeats the following three steps:
\begin{itemize}
\item Given past observations and an estimate $\widehat{A}$, our method plans a reference trajectory from the current state of the system to a high uncertainty region of the feature space.
\item Then, our method attempts to track the reference trajectory using $\widehat{A}$.
\item Finally, using all data collected so far, our method re-estimates $\widehat{A}$.
\end{itemize}
The ability to find reference trajectories from a given state to a desired goal set is related to the notion of controllability, a standard notion in control theory. A system is called \emph{controllable} if it is possible to take the system from any state to any other state in a finite number of steps by using an appropriate sequence of inputs. In our case, a system is considered more controllable the bigger we can make the inner product between the system's features and goal directions in feature space. The number of time steps required to obtain a large inner product is called \emph{planning horizon}.
The controllability of the system and the planning horizon are system dependent properties that influence our ability to estimate the system. Intuitively, the more controllable a system is, the easier it is to collect the data we need to estimate it. The following informal version of our main result clarifies this relationship.
\begin{thm*}[Informal]
Our method chooses actions $\vb u_t$ such that with high probability the ordinary least squares (OLS) estimate $\widehat{A} \in \arg \min_{A} \sum_{t = 0}^{T - 1} \norm{A \phi (\vb x_t, \vb u_t) - \vb x_{t + 1}}^2$ satisfies
\begin{align*}
\norm{\widehat{A} - A_\star} \leq \frac{\text{size of the noise}}{\text{controllability of the system}} \sqrt{\frac{\text{dimension} \times \text{planning horizon}}{\text{number of data points}}}.
\end{align*}
\end{thm*}
This statistical rate is akin to that of standard supervised linear regression, but it has an additional dependence on the controllability of the system and the planning horizon. To better understand why these two terms appear, recall that our method uses $\widehat{A}$, an estimate of $A_\star$, to plan and track reference trajectories. Therefore, the tracking step is not guaranteed to reach the desired region of the feature space. The main insight of our analysis is that when trajectory tracking fails, we are still guaranteed to collect at least one informative data point per reference trajectory. Therefore, in the worst case, the effective size of the data collected by our method is equal to the total number of data points collected over the planning horizon.
In the next section we present our mathematical assumptions and in Section~\ref{sec:main} we discuss our method and main result. Section~\ref{sec:ols} includes a general result about linear regression of dependent data derived from prior work. Then, in Section~\ref{sec:proof} we present in detail the proof of our main result.
There is a long line of work studying system identification, which we discuss in Section~\ref{sec:related}. Finally, Section~\ref{sec:takeaways} contains takeaways and open problems.
\textbf{Notation:} The norm $\norm{\cdot}$ is the Euclidean norm whenever it is applied to vectors and is the spectral norm whenever it is applied to matrices. We use $c_1$, $c_2$, $c_3$, \ldots to denote different universal constants. Also, $\ensuremath{\mathbb{S}}^{p - 1}$ is the unit sphere in $\mathbb{R}^p$ and $\mathbb{B}^p_r$ is the ball in $\mathbb{R}^p$ centered at the origin and of radius $r$.
The symbol $\square$ is used to indicate the end of an example or of a proof.
\section{Assumptions}
To guarantee the estimation of \eqref{eq:system} we must make several assumptions about the true system we are trying to identify. We denote the dimensions of the states and inputs by $d$ and $p$ respectively. The feature map $\phi$ maps state-action pairs to feature vectors in $\mathbb{R}^k$.
The main challenge in the estimation of \eqref{eq:system} is choosing inputs $\vb u_t$ so that the minimal singular value of the design matrix is $\Omega(\sqrt{T})$, where $T$ is the length of the trajectory collected from the system. To reliably achieve this we must assume the feature map $\phi$ has some degree of smoothness. Without a smoothness assumption the noise term $\vb w_t$ at time $t$ might affect the feature vector $\phi(\vb x_{t + 1}, \vb u_{t + 1})$ at time $t + 1$ in arbitrary ways, regardless of the choice of input at time $t$.
\begin{assumption}
\label{as:lip}
The map $\phi \colon \mathbb{R}^d \times \mathbb{B}^p_{r_u} \to \mathbb{R}^k$ is $L$-Lipschitz\footnote{Since $\phi$ is continuous and since $\vb u$ lies in a compact set, we know that any continuous function of $\phi(\vb x, \vb u)$ achieves its maximum and minimum with respect to $\vb u$. This is the only reason we assume the inputs to the system are bounded. Alternatively, we could let the inputs be unbounded and work with approximate maximizers and minimizers.}.
\end{assumption}
In order to use known techniques for the analysis of online linear least squares \cite{abbasi2011online, dani2008stochastic,rusmevichientong2010linearly, simchowitz2018learning} we also assume that the feature map $\phi$ is bounded. For some classes of systems (e.g. certain linear systems) this condition can be removed \cite{simchowitz2018learning}.
\begin{assumption}
\label{as:bounded}
There exists $b_\phi > 0$ such that $\norm{\phi(\vb x, \vb u)} \leq b_\phi$ for all $\vb x \in \mathbb{R}^d$ and $\vb u \in \mathbb{B}_{r_u}$.
\end{assumption}
This assumption implies that the states of the system \eqref{eq:system} are bounded, a consequence which can be limiting in some applications. To address this issue we could work with the system
\begin{align}
\label{eq:delta_system}
\vb x_{t + 1} = A_\star \phi(\vb x_t, \vb u_t) + \vb x_t + \vb w_t
\end{align}
instead. In this case, $\phi$ being bounded implies that the increments $\vb x_{t + 1} - \vb x_t$ are bounded, allowing the states to grow in magnitude. However, formulation \eqref{eq:delta_system} complicates the exposition so we choose to focus on \eqref{eq:system}.
As mentioned in the introduction, our method relies on trajectory planning and tracking to determine the inputs to the system. Suppose we would like to track a reference trajectory $\{(\vb x_t^R, \vb u_t^R)\}_{t \geq 0}$ that satisfies $\vb x_{t + 1}^R = A_\star \phi(\vb x_t^R, \vb u_t^R)$. In other words, we wish to choose inputs $\vb u_t$ to ensure that the tracking error $\| \vb x_t - \vb x_t^R\|$ is small. Simply choosing $\vb u_t = \vb u_t^R$ does not work even when the initial states $\vb x_0$ and $\vb x_0^R$ are equal because the true system \eqref{eq:system} experiences process noise.
To ensure that tracking is possible we assume that there always exists an input to the true system that can keep the tracking error small.
There are multiple ways to formalize such an assumption. We make the following choice.
\begin{assumption}
\label{as:control}
There exist positive constants $\gamma$ and $b_u$ such that for any $\vb x, \vb x^\prime \in \mathbb{R}^d$ and any $\vb u^\prime \in \mathbb{B}^p_{b_u}$ we have
\begin{align}
\label{eq:control_as}
\min_{\vb u \in \mathbb{B}^p_{r_u}}\norm{ A_\star \left(\phi(\vb x, \vb u) - \phi(\vb x^\prime, \vb u^\prime) \right) }\leq \gamma \norm{ \vb x - \vb x^\prime}.
\end{align}
Moreover, if $\norm{\vb u^\prime} \leq b_u / 2$, there exists $\vb u$, with $\norm{\vb u} \leq b_u$, that satisfies \eqref{eq:control_as}.
\end{assumption}
Therefore, if we wish to track a reference trajectory $\{(\vb x_t^R, \vb u_t^R)\}_{t \geq 0}$ that satisfies $\vb x_{t + 1} = A_\star \phi(\vb x_t, \vb u_t)$, Assumption~\ref{as:control} guarantees the existence of an input $\vb u_t \in \mathbb{B}^p_{b_u}$ such that
\begin{align*}
\norm{\vb x_{t + 1} - \vb x_{t + 1}^R} &= \norm{A_\star \phi(\vb x_t, \vb u_t) + \vb w_t - A_\star \phi(\vb x_t^R, \vb u_t^R)} \\
&\leq \gamma \norm{\vb x_t - \vb x_t^R} + \norm{\vb w_t}.
\end{align*}
In other words, Assumption~\ref{as:control} allows us to find an input $\vb u_t$ such that the tracking error $\norm{\vb x_{t+1} - \vb x_{t + 1}^R}$ is upper bounded in terms of noise $\vb w_t$ and the tracking error at time $t$. By induction, Assumption~\ref{as:control} guarantees the existence of inputs to the system such that
\begin{align*}
\norm{\vb x_H - \vb x_H^R} \leq \max_{t = 0, \ldots, H - 1} \norm{\vb w_t} (1 + \gamma + \ldots + \gamma^{H - 1}) + \gamma^H \norm{\vb x_0 - \vb x_0^R}.
\end{align*}
Hence, when $\gamma < 1$ we can choose a sequence of inputs such that the state $\vb x_H$ at time $H$ is close to $\vb x_{H}^R$, as long as the process noise is well behaved.
Note that in Assumption~\ref{as:control} we allow $\gamma \geq 1$. However, we pay a price when $\gamma$ is large. The larger $\gamma$ is the more stringent the next assumptions become. Finally, we note that the parameter $b_u$ appearing in Assumption~\ref{as:control} makes it easier for systems to satisfy the assumption than requiring that \eqref{eq:control_as} holds for all $\vb u^\prime$.
To estimate \eqref{eq:system} we must collect measurements of state transitions from feature vectors that point in different directions. To ensure that such data can be collected from the system we must assume that there exist sequences of actions which take the dynamical system from a given state to some desired direction in feature space. This type of assumption is akin to the notion of controllability, which is standard in control theory. For example, a linear system $\vb x_{t + 1} = A \vb x_t + B \vb u_t$ is said to be controllable when the matrix $\begin{bmatrix} B & AB & \ldots & A^{d - 1} B \end{bmatrix}$ has full row rank. The interested reader can easily check that for a controllable linear system it is possible to get from any state to any other state in $d$ steps by appropriately choosing a sequence of inputs.
This notion of controllability can be extended to a class of nonlinear systems, called control affine systems, through the use of Lie brackets \cite{sastry2013nonlinear,slotine1991applied}. We require a different notion of controllability. Namely, we assume that in the absence of process noise we can take the system \eqref{eq:system} from any state to a feature vector that aligns sufficiently with a desired direction in feature space.
\begin{assumption}
\label{as:controllable}
There exist $\alpha$ and $H$, a positive real number and a positive integer, such that for any initial state $\vb x_0$ and goal vector $v \in \ensuremath{\mathbb{S}}^{k - 1}$ there exists a sequence of actions $\vb u_t$, with $\norm{\vb u_t} \leq b_u / 2$, such that $\left| \langle \phi(\vb x_t, \vb u_t), v \rangle \right| \geq \alpha > 0$ for some $0 \leq t \leq H$, with $\vb x_{j + 1} = A_\star \phi (\vb x_j, \vb u_j)$ for all $j$.
\end{assumption}
If the assumption is satisfied for some horizon $H$, it is clear that it is also satisfied for larger horizons. Moreover, one expects that a larger horizon $H$ allows a larger controllability parameter $\alpha$.
As discussed in the introduction, the larger $H$ is, the weaker our guarantee on estimation will be. However, the larger $\alpha$ is, the better our guarantee on estimation will be. Therefore, there is a tension between $\alpha$ and $H$ in our final result.
Assumptions~\ref{as:lip} to \ref{as:controllable} impose many constraints. Therefore, it is important to give examples of nonlinear dynamical systems that satisfy these assumptions. We give two simple examples. First we present a synthetic example for which it is easy to check that it satisfies all the assumptions, and then we discuss the simple pendulum.
\begin{example}[Smoothed Piecewise Linear System]
When the support sets of the different pieces are known, piecewise affine systems can be easily expressed as ~\eqref{eq:system}. However, the feature map $\phi$ would not be continuous. In this example, we present a smoothed version of a PWA system, which admits a $1$-Lipschitz feature map. Let $f : \mathbb{R} \to \mathbb{R}$ be defined by
\begin{align}
f(x) = \left\{
\begin{array}{ll}
0 & \text{if } x < -1/2,\\
x + 1/2 & \text{if } x \in [-1/2, 1/2],\\
1 & \text{if } x > 1/2.
\end{array}
\right.
\end{align}
We also consider the maps $g(\vb x) = \frac{\vb x_{t}}{\norm{\vb x_t}} \min \{\norm{\vb x_t}, b_x\}$ and $h(\vb u) = \frac{\vb u}{\norm{\vb u}} \min\{\norm{\vb u}, r_u\}$, for some values $b_x$ and $r_u$. In this example both the inputs and the states are $d$ dimensional. Then, we define the feature map $\phi : \mathbb{R}^{2d} \to \mathbb{R}^{3d}$ as follows
\begin{align}
\phi(\vb x, \vb u) = \begin{bmatrix}
g(\vb x) f( x_{1}) \\
g(\vb x)(1 - f(x_{1})) \\
h(\vb u)
\end{bmatrix},
\end{align}
where $x_{1}$ denotes the first coordinate of $\vb x$. Now, let us consider the following dynamical system:
\begin{align}
\label{eq:spls}
\vb x_{t + 1} = \begin{bmatrix}A_1 & A_2 & I_d \end{bmatrix}\phi(\vb x_t, \vb u_t) + \vb w_t,
\end{align}
where $A_1$ and $A_2$ are two unknown $d \times d$ matrices. For the purpose of this example we can assume the noise $\vb w_t$ is zero almost surely.
To better understand the system \eqref{eq:spls} note that when $\norm{\vb x_t} \leq b_x$ and $\norm{\vb u_t} \leq r_u$ we have
\begin{align*}
\vb x_{t + 1} &= A_1 \vb x_{t} + \vb u_t \quad \text{if }\; x_{t1} \geq 1/2, \\
\vb x_{t + 1} &= A_2 \vb x_{t} + \vb u_t \quad \text{if }\; x_{t1} \leq -1/2.
\end{align*}
By construction, the feature map of the system is $1$-Lipschitz and bounded. Therefore, \eqref{eq:spls} satisfies Assumptions \ref{as:lip}, and \ref{as:bounded}. We are left to show that we can choose $A_1$, $A_2$, $b_x$, and $r_u$ so that \eqref{eq:spls} satisfies Assumptions \ref{as:control} and \ref{as:controllable} as well.
It is easy to convince oneself that if $b_x > 2\sqrt{2}$, Assumptions~\ref{as:control} and \ref{as:controllable} hold for any $A_1$ and $A_2$ as long as $r_u$ is sufficiently large relative to $A_1$, $A_2$, and $b_x$. In fact, if $r_u$ is sufficiently large, Assumption~\ref{as:control} is satisfied with $\gamma = 0$. \exend
\end{example}
\begin{example}[Simple Pendulum]
We know that the dynamics of a simple pendulum in continuous time are described by the equation
\begin{align}
\label{eq:pendulum}
m\ell^2 \ddot{\theta}(t) + mg\ell \sin \theta(t) = - b\dot{\theta}(t) + u(t),
\end{align}
where $\theta(t)$ is the angle of the pendulum at time $t$, $m$ is the mass of the pendulum, $\ell$ is its length, $b$ is a friction coefficient, and $g$ is the gravitational acceleration.
Then, if we discretize \eqref{eq:pendulum} according to Euler's method~\footnote{Using a more refined discretization method, such as a Runge-Kutta method, would be more appropriate. Sadly, such discretization methods yield a discrete time system which cannot be easily put in the form \eqref{eq:delta_system}.} with step size $h$ and assume stochastic process noise, we obtain the two dimensional system:
\begin{align}
\vb x_{t + 1} = \vb x_t + \begin{bmatrix}
a_1 & a_2\\
h & 0
\end{bmatrix} \begin{bmatrix}
x_{t1} \\
\sin \left( x_{t2}\right)
\end{bmatrix} + \begin{bmatrix}
a_3 \\
0
\end{bmatrix} \vb u_t + \vb w_t,
\end{align}
where $x_{t1}$ and $x_{t2}$ are the coordinates of $\vb x_t$ and $a_1$, $a_2$, and $a_3$ are unknown real values. The first coordinate of $\vb x_t$ represents the angular velocity of the pendulum at time $t$, while the second coordinate represents the angle of the pendulum. Therefore, to put the inverted pendulum in the form of \eqref{eq:delta_system} we can consider the feature map
\begin{align}
\phi(\vb x_t, \vb u_t) = \begin{bmatrix}
x_{t1} \\
\sin \left( x_{t2}\right) \\
\vb u_t
\end{bmatrix}.
\end{align}
It can be easily checked that this feature map is $1$-Lipschitz. While it is not bounded, if pendulum experiences friction, we can ensure the feature values stay bounded by clipping the inputs $\vb u_t$, i.e. replace $\vb u_t$ with $\sgn(\vb u_t) \min \{|\vb u_t|, r_u\}$ for some value $r_u$.
The simple pendulum satisfies Assumption~\ref{as:controllable} because we can drive the system in a finite number of steps from any state $\vb x_t$ to states $\vb x_{t + H}$ for which the signs of $ x_{(t + h)1}$
and $\sin \left( x_{t1}\right)$ can take any value in $\{-1, 1\}^2$, with their absolute values lower bounded away from zero.
Finally, Assumption~\ref{as:control} holds with $\gamma \geq 1 + h$. This assumption is pessimistic because the simple pendulum is stabilizable and can track reference trajectories. However, Assumption~\ref{as:control} does not hold with $\gamma < 1$ since the input at time $t$ does not affect the position at time $t + 1$. \exend
\end{example}
Now we turn to our last two assumptions. We need to make an assumption about the process noise and we also must assume access to an initial $\widehat{A}$ to warm start our method.
\begin{assumption}
\label{as:noise}
The random vectors $\vb w_t$ are independent, zero mean, and $\norm{\vb w_t} \leq b_w$ a.s.\footnote{We can relax this assumption to only require $\vb w_t$ to be sub-Gaussian. In this case, we would make a truncation argument to obtain an upper bound on all $\vb w_t$ with high probability.}. Also, $\vb w_t$ is independent of $(\vb x_t, \vb u_t)$. Furthermore, we assume
\begin{align}
\label{eq:noise_bound}
b_w \leq \frac{ \alpha}{c_1 L (1 + \gamma + \ldots + \gamma^{H - 1})},
\end{align}%
for some universal constant $c_1 > 2$.
\end{assumption}
Equation~\ref{eq:noise_bound} imposes on upper bound on the size of the process noise in terms of system dependent quantities: the controllability parameter $\alpha$ introduced in Assumption~\ref{as:controllable}, the Lipschitz constant $L$ of the feature map, and the control parameter $\gamma$ introduced in Assumption~\ref{as:control}. An upper bound on $b_w$ is required because when the process noise is too large, it can be difficult to counteract its effects through feedback.
Finally, we assume access to an initial guess $\widehat{A}$ with $\norm{\widehat{A} -A_\star} = \ensuremath{\mathcal{O}} \left(L^{-1}(1 + \gamma +\ldots + \gamma^{H - 1})^{-1}\right)$. To understand the key issue this assumption resolves, suppose we are trying to track a reference trajectory $\{(\vb x_t^R, \vb u_t^R)\}_{t \geq 0}$ and $\norm{(\widehat{A} - A_\star) \phi(\vb x_t^R, \vb u_t^R)}$ is large.
Without an assumption on the size of $\norm{\widehat{A} - A_\star}$, the magnitude of $(\widehat{A} - A_\star) \phi(\vb x_t^R, \vb u_t^R)$ might be large while $\norm{\phi(\vb x_t^R, \vb u_t^R)}$ is small. Then, making a measurement at a point $(\vb x_t, \vb u_t)$ close to $(\vb x_t^R, \vb u_t^R)$ might not be helpful for estimation because $\phi(\vb x_t, \vb u_t)$ could be zero. Therefore, if $\norm{\widehat{A} - A_\star}$ is too large, we might both fail to track a reference trajectory and to collect a useful measurement. For ease of exposition, instead of assuming access to an initial guess $\widehat{A}$, we assume access to a dataset.
\begin{assumption}
\label{as:initial}
We have access to an initial trajectory $\ensuremath{\mathcal{D}} = \{(\vb x_t, \vb u_t, \vb x_{t + 1})\}_{0 \leq t < t_0}$ of transitions from the true system such that
\begin{align}
\lambda_{\min} \left(\sum_{t = 0}^{t_0 - 1} \phi(\vb x_t, \vb u_t) \phi(\vb x_t, \vb u_t)^\top \right) \geq 1 + c_2 b_w^2 L^2 \left(\sum_{i = 0}^{H - 1} \gamma^i\right)^2 \left(d + k \log(b_\phi^2 T) + \log\left(\frac{\pi^2 T^2 }{6\delta}\right)\right).
\end{align}
where $c_2$ is a sufficiently large universal constant and $T$ is the number of samples to be collected by our method. We make explicit the requirement on $c_2$ in Section~\ref{sec:proof}. In Appendix~\ref{app:refine} we show how to replace $T$ by a fixed quantity $T_\star$.
\end{assumption}
As shown in Section~\ref{sec:ols}, Assumption~\ref{as:initial} guarantees that the OLS estimate $\widehat{A}$ obtained from $\ensuremath{\mathcal{D}}$ satisfies $\norm{\widehat{A} - A_\star} \leq \frac{c_3}{\sqrt{c_2}} L^{-1}(1 + \gamma +\ldots + \gamma^{H - 1})^{-1}$ for some universal constant $c_3$. Since the features $\phi(\vb x, \vb u)$ can have magnitude as large as $b_\phi$, Assumption~\ref{as:initial} only implies $\norm{(\widehat{A} - A_\star) \phi(\vb x, \vb u)} = \ensuremath{\mathcal{O}}(b_\phi L^{-1} (1 + \gamma +\ldots + \gamma^{H - 1})^{-1})$. Therefore, Assumption~\ref{as:initial} does not imply a stringent upper bound on $\norm{(\widehat{A} - A_\star) \phi(\vb x, \vb u)}$ because $b_\phi$ can be arbitrarily large relative to $L$ and $\gamma$.
\section{Main Result}
\label{sec:main}
Our method for estimating the parameters of a dynamical system \eqref{eq:system} is shown in Algorithm~\ref{alg:traj_opt_exploration}. The trajectory planning and tracking routines are discussed in detail in Sections \ref{sec:plan} and \ref{sec:track} respectively. Our method is also presented in one block of pseudo-code in Appendix~\ref{app:alg}. Now, we can state our main result.
\begin{center}
\begin{algorithm}[h!]
\caption{Active learning for nonlinear system identification}{}
\begin{algorithmic}[1]
\REQUIRE{Parameters: the feature map $\phi$, initial trajectory $\ensuremath{\mathcal{D}}$, and parameters $T$, $\alpha$, and $\beta$.}
\STATE Initialize $\Phi$ to have rows $\phi(\vb x_j, \vb u_j)^\top$ and $Y$ to have rows $(\vb x_{j + 1})^\top$, for $(\vb x_j, \vb u_j, \vb x_{j + 1}) \in \ensuremath{\mathcal{D}}$.
\STATE Set $\widehat{A} \gets Y^\top \Phi (\Phi^\top \Phi)^{-1}$, i.e. the OLS estimate according to $\ensuremath{\mathcal{D}}$.
\STATE Set $t \gets t_0$.
\WHILE{$t \leq T + t_0$}
\STATE Set $\vb x_0^R \gets \vb x_t$,
\STATE Set $v$ to be a minimal eigenvector of $\Phi^\top \Phi$, with $\norm{v} = 1$.
\STATE \textbf{Trajectory planning:} find inputs $\vb u_0^R$, $\vb u_1^R$, \ldots, $\vb u_r^R$, with $\norm{\vb u_j^R} \leq b_u$ and $r \leq H$, such that
\begin{align*}
&\left | \langle \phi(\vb x^R_r, \vb u_r^R) , v \rangle \right | \geq \frac{\alpha}{2} \text{ or } \phi(\vb{x}^R_r, \vb u_r^R)^\top (\Phi^\top \Phi)^{-1} \phi(\vb{x}^R_r, \vb u_r^R) \geq \beta,
\end{align*}
where $\vb x_{j + 1}^R = \widehat{A} \phi(\vb x_j^R, \vb u_j^R)$ for all $j \in \{0, 1, \ldots, r - 1\}$.
\label{line:planning}
\STATE \textbf{Trajectory tracking:} track the reference trajectory $\{(\vb x_j^R, \vb u_j^R)\}_{j = 0}^r$ and increment $t$ as described in Section~\ref{sec:track}.
\STATE Set $\Phi^\top \gets [\phi_0, \phi_1, \ldots, \phi_{t -1}]$ and $Y^\top \gets [\vb x_1, \vb x_2, \ldots, \vb x_{t}]$, where $(\phi_j, \vb x_{j + 1})$ are all feature-state transitions observed so far.
\STATE \textbf{Re-estimate:} $\widehat{A} \gets Y^\top \Phi (\Phi^\top \Phi)^{-1}$.
\ENDWHILE
\STATE Output the last estimates $\widehat{A}$.
\end{algorithmic}
\label{alg:traj_opt_exploration}
\end{algorithm}
\end{center}
\begin{thm}
\label{thm:main}
Suppose $\vb x_{t + 1} = A_\star \phi(\vb x_t, \vb u_t) + \vb w_t$ is a nonlinear dynamical system which satisfies Assumptions~\ref{as:lip}-\ref{as:noise} and suppose $\ensuremath{\mathcal{D}}$ is an initial trajectory that satisfies Assumption~\ref{as:initial}. Also, let $\beta = c_4 \left(d + k \log(\beta_\phi^2 T) + \log(\pi^2 T^2 / (6\delta))\right)^{-1}$ with $c_4 \leq \frac{(c_1 - 2)^2}{36c_3^2}$ and\footnote{Recall $c_1$ is the universal constant appearing in Assumption~\ref{as:controllable} and $c_3$ is the universal constant appearing in the upper bound on the error of the OLS estimate, shown in Section~\ref{sec:ols}.} let
\begin{align}
N_e := \left\lceil \frac{2k \log\left(\frac{2k b_\phi^2}{\log(1 + \beta / 2)}\right)}{\log(1 + \beta / 2)} \right \rceil.
\end{align}
Then, with probability $1 - \delta$, Algorithm~\ref{alg:traj_opt_exploration} with parameters $T$ and $\beta$ outputs $\widehat{A}$ such that
\begin{align}
\norm{\widehat{A} - A_\star} \leq c_5 \frac{b_w}{\alpha} \sqrt{\frac{d + k \log(b_\phi^2 T) + \log\left(\frac{\pi^2 T}{6\delta}\right)}{T / H - N_e}}
\end{align}
whenever $T \geq \frac{32 k b_\phi^2 H}{\alpha^2} + HN_e$.
\end{thm}
There are several aspects of this result worth pointing out. First of all, the statistical rate we obtained in Theorem~\ref{thm:main} has the same form as the standard statistical rate for linear regression, which is $\ensuremath{\mathcal{O}}\left(b_w \sqrt{\frac{k}{T}} \right)$.
The two important distinctions are the dependence on the planning horizon $H$ and the controllability term $\alpha$, both of which are to be expected in our case.
Algorithm~\ref{alg:traj_opt_exploration} uses trajectory planning for data collection and the length of the reference trajectories is at most $H$. Since we can only guarantee one useful measurement per reference trajectory, it is to be expected that we can only guarantee an effective sample size of $T/H$.
The controllability term $\alpha$ is also natural in our result because it quantifies how large the feature vectors can become in different directions.
Larger feature vectors imply a larger signal-to-noise ratio, which in turn implies faster estimation.
\subsection{Trajectory planning}
\label{sec:plan}
The trajectory planning routine shown in Algorithm~\ref{alg:traj_opt_exploration} uses the current estimate $\widehat{A}$ to plan, assuming no process noise, a trajectory from the current state of the system $\vb x_0^R = \vb x_t$ to a high uncertainty region of the feature space, assuming no process noise. More precisely, it finds a sequence of actions $\{\vb u_j^R\}_{j = 0}^r$ which produces a sequence of reference states $\{\vb x_j^R\}_{j = 0}^r$ with the following properties:
\begin{itemize}
\item $\vb x_{j + 1}^R = \widehat{A} \phi(\vb x_j^R, \vb u_j^R)$,
\item The last reference state-action pair $(\vb x_r^R, \vb u_r^R)$ is either well aligned with $v$, the minimum eigenvector of $\Phi^\top \Phi$, or its feature vector is in a high uncertainty region of the state space. More precisely, $(\vb x_r^R, \vb u_r^R)$ must satisfy one of the following two inequalities:
\begin{align*}
\left | \langle \phi(\vb x^R_r, \vb u_r^R) , v \rangle \right | \geq \frac{\alpha}{2} \text{ or } \phi(\vb{x}^R_r, \vb u_r^R)^\top (\Phi^\top \Phi)^{-1} \phi(\vb{x}^R_r, \vb u_r^R) \geq \beta.
\end{align*}
\end{itemize}
It is not immediately obvious that we can always find such a sequence of inputs. In Section~\ref{sec:proof} we prove that when Assumptions~\ref{as:controllable} and \ref{as:initial} hold the trajectory planning problem is feasible.
From the study of OLS, discussed in Section~\ref{sec:ols}, we know that the matrix $\Phi^\top \Phi$ determines the uncertainty set of OLS. The larger $\lambda_{\min} \left(\Phi^\top \Phi\right)$ is, the smaller the uncertainty set will be.
Therefore, to reduce the size of the uncertainty set we want to collect measurements at feature vectors $\phi$ such that the smallest eigenvalues of $\Phi^\top \Phi + \phi \phi^\top$ are larger than the smallest eigenvalues of $\Phi^\top \Phi$. Ideally, $\phi$ is a minimal eigenvector of $\Phi^\top \Phi$. However, we cannot always drive the system to such a feature vector, especially in the presence of process noise.
Instead, we settle for feature vectors of the following two types. Firstly, trajectory planner tries to drive the system to feature vectors $\phi$ that are well aligned with the minimal eigenvector $v$ of $\Phi^\top \Phi$, i.e. $|\langle \phi, v \rangle| \geq \alpha$. Such a data collection scheme is an instance of E-optimal design \cite{pukelsheim1993optimal}, which has been shown by \citet{wagenmaker2020active} to produce inputs that allow the estimation of linear dynamics at an optimal rate.
However, if reaching a feature vector that aligns with the minimal eigenvector is not possible, the trajectory planner finds a reference trajectory to a feature vector $\phi$ such that $\phi^\top (\Phi^\top \Phi)^{-1} \phi \geq \beta$. When this inequality holds our uncertainty about the estimate $\widehat{A}$ in the direction $\phi$ is large. As shown in Section~\ref{sec:proof}, such feature vectors can be encountered only for a small number of iterations.
Finally, trajectory planning is computationally intractable in general. However, in this work we quantify the data requirements of identifying $A_\star$, leaving computational considerations for future work. We assume access to a computational oracle. This assumption is reasonable since trajectory planning is often solved successfully in practice \cite{kavraki1996probabilistic, lavalle2001randomized, zucker2013chomp}.
\subsection{Trajectory tracking}
\label{sec:track}
Now we detail the trajectory tracking component of our method. We saw that the trajectory planner produces a reference trajectory $\{(\vb x_j^R, \vb u_j^R)\}_{j = 0}^r$, with $r \leq H$. However, the planner assumes no process noise to generate this reference trajectory. Therefore, if we were to simply plug-in the sequence of actions $\{\vb u_j^R\}_{j = 0}^r$ into \eqref{eq:system}, the states of the system would diverge from $\vb x_j^R$. Instead, after observing each state $\vb x_t$ of the system \eqref{eq:system}, our method chooses an input $\vb u_t$ as follows:
\begin{itemize}
\item Given the current state $\vb x_t$, our method chooses an input $\vb u_t$ such that
\begin{align*}
\phi(\vb x_t, \vb u_t)^\top (\Phi^\top \Phi)^{-1} \phi(\vb x_t, \vb u_t) \geq \beta
\end{align*}
if there exists such an input. In other words, if there is an opportunity to greedily collect an informative measurement, our method takes it. If this situation is encountered, the trajectory tracker increments $t$ by $1$ and then stops tracking and returns.
\item If there is no opportunity for greedy exploration, our method chooses an input $\vb u_t$ that minimizes $\norm{\widehat{A} (\phi(\vb x_t,\vb u_t) - \phi(\vb x_j^R, \vb u_j^R))}$ and then increments $t$ and $j$ by one ($t$ indexes the time steps of the system \eqref{eq:system} and $j$ indexes the reference trajectory). Therefore, our method uses closed loop control for data generation since minimizing $\norm{\widehat{A} (\phi(\vb x_t,\vb u_t) - \phi(\vb x_j^R, \vb u_j^R))}$ requires access to the current state $\vb x_t$. At time $t$ we choose $\vb u_t$ in this fashion in order to minimize the tracking error $\mathbb{E} \norm{\vb x_{t + 1} - \vb x_{t + 1}^R}^2$ at the next time step, where the expectation is taken with respect to $\vb w_{t}$.
\item Our method repeats these steps until $j = r$, i.e. until it reaches the end of the reference trajectory. When $j = r$ the trajectory tracker sets $\vb u_t = \vb u_j^R$, increments $t$ by one, and returns.
\end{itemize}
\section{General Guarantee on Estimation}
\label{sec:ols}
In this section we provide a general upper bound on the error between an OLS estimate $\widehat{A}$ and the true parameters $A_\star$.
The guarantee is based on the work of \citet{simchowitz2018learning}. However, these types of results have been previously used in the study of online least squares and linear bandits \cite{abbasi2011online, dani2008stochastic,rusmevichientong2010linearly}.
We assume that we are given a sequence of observations $\{(\vb x_t, \vb u_t, \vb x_{t + 1})\}_{t \geq 0}$ generated by the system \eqref{eq:system},
with $u_t$ allowed to depend on $\vb x_0$, $\vb x_1$, \ldots, $\vb x_{t - 1}$ and independent of $\vb w_j$ for all $j \geq t$.
In what follows we denote $\phi_t := \phi(\vb x_t, \vb u_t)$.
Our method re-estimates the parameters $A_\star$ as more data is being collected. For the purpose of this section let us denote by $\widehat{A}_j$ the OLS estimate obtained using the first $j$ measurements $(\vb x_t, \vb u_t, \vb x_{t + 1})$, i.e.
\begin{align}
\label{eq:ols}
\widehat{A}_j = \arg \min_{A} \sum_{t = 0}^{j - 1} \norm{A \phi_t - \vb x_{t + 1}}^2.
\end{align}
\begin{prop}
\label{prop:ols}
If the dynamical system \eqref{eq:system} satisfies Assumptions~\ref{as:noise} and \ref{as:bounded} and if $\lambda_{\min} \left(\sum_{t = 0}^{t_0 - 1} \phi_t \phi_t^\top \right) \geq \underline{\lambda}$ for some $\underline{\lambda} > 0$ and $t_0 > 0$, the OLS estimates \eqref{eq:ols} satisfy
\begin{align}
\mathbb{P} \left[\exists u \in \ensuremath{\mathbb{S}}^{k - 1} \text{ and } j \geq t_0 \text{ s.t. } \norm{(\widehat{A}_j - A_\star ) u }\geq \mu_j \sqrt{u^\top \left(\sum_{t = 0}^{j - 1} \phi_t \phi_t^\top\right)^{-1} u} \right] \leq \delta,
\end{align}
\end{prop}
where $\mu_j = c_3 b_w \sqrt{d + k \log\left(\frac{b_\phi^2 j}{\underline{\lambda}}\right) + \log\left(\frac{\pi^2 j^2}{6 \delta} \right)}$ for some universal constant $c_3$.
\begin{proof}
By assumption $\lambda_{\min} \left(\sum_{t = 0}^{t_0 - 1} \phi_t \phi_t^\top \right) \geq \underline{\lambda} > 0$. Therefore, $\sum_{t = 0}^{j - 1} \phi_t \phi^\top_t$ is invertible and
\begin{align}
\widehat{A}_j - A_\star = W_j^\top \Phi_j (\Phi_j^\top \Phi_j)^{-1},
\end{align}
where $W_j^\top = [\vb w_0, \ldots, \vb w_{j - 1}]$ and $\Phi_j^\top = [\phi_0, \ldots, \phi_{j - 1}]$. Now, we fix the index $j$ and we consider the SVD decomposition $\Phi_{j} = U \Sigma V^\top$. Therefore, $\widehat{A}_j - A_\star = W_j^\top U \Sigma^\dagger V^\top$.
Recall that $\sup_{\vb x, \vb u}\|\phi(\vb x, \vb u)\|_2 \leq b_\phi$ by assumption. Then, according to the analysis of \citet{simchowitz2018learning} we know that
$ \norm{W_j^\top U } \leq \mu_j$ with probability at least $1 - 6\delta / (\pi^2j^2)$. Note that for all $u\in \ensuremath{\mathbb{S}}^{k - 1}$ we have
\begin{align*}
\norm{ (\widehat{A}_j - A_\star) u } &\leq \norm{W_j^\top U } \norm{\Sigma^\dagger V^\top u} = \norm{W_j^\top U} \sqrt{ u^\top V (\Sigma^\dagger)^\top \Sigma^\dagger V^\top u} \\
&= \norm{W_j^\top U} \sqrt{u^\top (\Phi_j^\top \Phi_j)^{-1}u}.
\end{align*}
Therefore, for a fixed index $j$, we have
\begin{align}
\mathbb{P} \left[\exists u \in \ensuremath{\mathbb{S}}^{k - 1} \text{ s.t. }\|(\widehat{A}_j - A_\star ) u \|_2 \geq \mu_j \sqrt{u^\top \left(\sum_{t = 0}^{j - 1} \phi_t \phi_t^\top\right)^{-1} u} \right] \leq \frac{6 \delta}{\pi^2 j^2}.
\end{align}
A direct application of the union bound yields the desired conclusion.
\end{proof}
\section{Proof of Theorem~\ref{thm:main}}
\label{sec:proof}
First let us observe that when $b_w = 0$ the result is trivial. Because we assume access to an initial trajectory $\ensuremath{\mathcal{D}}$ which satisfies Assumption~\ref{as:initial} we are guaranteed $\widehat{A} = A_\star$ when $b_w = 0$. Therefore, we can assume that $b_w > 0$, which implies that $\alpha$ must be strictly positive according to Assumption~\ref{as:controllable}. Throughout the proof we denote $\phi_t := \phi(\vb x_t, \vb u_t)$ and $\phi_j^R := \phi(\vb x_j^R, \vb u_j^R)$.
The proof of our result has three parts, which we now outline:
\begin{itemize}
\item We show that the trajectory planning step in Algorithm~\ref{alg:traj_opt_exploration} is always feasible.
\item We show that during the execution of Algorithm~\ref{alg:traj_opt_exploration} there are at most $N_e$ iterations in which either:
\begin{align}
\max_{\vb u \in \mathbb{B}_{r_u}} \phi(\vb x_t, \vb u)^\top (\Phi^\top \Phi)^{-1} \phi(\vb x_t, \vb u) \geq \beta \;\text{ or }\; (\phi_j^R)^\top (\Phi^\top \Phi)^{-1} \phi_j^R \geq \beta,
\end{align}
for some $t$ and $j$.
\item We show that Algorithm~\ref{alg:traj_opt_exploration} collects at least $T/H - N_e$ measurements $(\phi_t, \vb x_{t + 1})$ such that $|\langle \phi_t, v\rangle| \geq \alpha/ 4$, where $v$ is a minimal eigenvector used to plan the reference trajectories. As a consequence, we show that Algorithm~\ref{alg:traj_opt_exploration} collects measurements $(\phi_t, \vb x_{t + 1})$ such that
\begin{align}
\label{eq:min_eig_alg}
\lambda_{\min} \left(\sum_{t = 1}^{T + t_0} \phi_t \phi_t^\top \right) \geq \ensuremath{\mathcal{O}}(1) \alpha^2 \left(\frac{T}{H} - N_e\right) - \frac{k - 1}{2}b_\phi^2.
\end{align}
\end{itemize}
Once we have shown \eqref{eq:min_eig_alg} is true, Theorem~\ref{thm:main} follows from Proposition~\ref{prop:ols} and some algebra.
\subsection*{Part 1 of the proof of Theorem~\ref{thm:main}.}
We show that the trajectory planning step of Algorithm~\ref{alg:traj_opt_exploration} is always feasible.
Let
\begin{align*}
\mu = c_3 b_w \sqrt{d + k \log\left(b_\phi^2 T\right) + \log\left(\frac{\pi^2 T^2}{6 \delta} \right)},
\end{align*}
where $c_3$ is the universal constant appearing in Proposition~\ref{prop:ols}. Since Assumption~\ref{as:initial} guarantees that the minimum eigenvalue of the design matrix is at least $1$, we know that
\begin{align}
\label{eq:ols_part1}
\norm{(\widehat{A} - A_\star)\phi} \leq \mu \sqrt{\phi^\top \left(\Phi^\top \Phi\right)^{-1}\phi},
\end{align}
for all $\phi\in \ensuremath{\mathbb{S}}^{k-1}$ and all iterations of Algorithm~\ref{alg:traj_opt_exploration} with probability $1-\delta$.
Now, let $\beta = c_4 \left(d + k \log(\beta_\phi^2 T) + \log(\pi^2 T^2 / (6\delta))\right)^{-1}$ with $c_4 \leq c_1^2 / (4 c_3^2)$. Then, since $\alpha \geq c_1 L b_w (1 + \gamma + \ldots + \gamma^{H - 1})$, we have
\begin{align}
\label{eq:beta_bound}
\beta \leq \left(\frac{\alpha}{2 L (1 + \gamma + \ldots + \gamma^{H - 1})\mu}\right)^2.
\end{align}
Let us $\tilde{\vb x}_0$ be equal to the initial state $\vb x_0^R$ of the trajectory planning and let $v \in \mathbb{R}^k$ be the desired goal direction.
By Assumption~\ref{as:controllable} we know that there must exist a sequence of inputs $\tilde{\vb u}_0$, $\tilde{\vb u}_1$, \ldots, $\tilde{\vb u}_r$, with $r \leq H$ and $\norm{\tilde{\vb u}_j} \leq b_u / 2$, such that
$|\langle \phi(\tilde{\vb x}_r, \tilde{\vb u}_r) , v \rangle | \geq \alpha$, where $\tilde{\vb x}_{j + 1} = A_\star \phi(\tilde{\vb x}_j, \tilde{\vb u}_j)$.
Now, let $\vb x_{j + 1}^R = \widehat{A} \phi(\vb x_j^R, \vb u_j^R)$, where $\vb u_j^R$ is any input vector with $\norm{\vb u_j^R} \leq b_u$ such that
\begin{align}
\label{eq:ur_choice}
\norm{A_\star[\phi(\vb x_j^R, \vb u_j^R) - \phi(\tilde{\vb x}_j, \tilde{\vb u}_j)]} \leq \gamma\norm{\vb x_j^R - \tilde{\vb x}_j}
\end{align}
for $j < r$.
Assumption~\ref{as:controllable} guarantees the existence of $\vb u_j^R$. We set $\vb u_r^R = \tilde{\vb u}_r$ and denote $\tilde{\phi}_j = \phi(\tilde{\vb x}_j, \tilde{\vb u}_j)$ and $\phi_j^R = \phi(\vb x_j^R, \vb u_j^R)$.
\paragraph{Case 1.} There exists $j \in \{0,1,2, \ldots, r\}$ such that $(\phi_j^R)^\top \left(\Phi^\top \Phi\right)^{-1} \phi_j^R \geq \beta$.
If this is the case, we are done because we found a feasible sequence of inputs $\vb u^R_0$, $\vb u^R_1$, \ldots, $\vb u^R_j$.
\paragraph{Case 2.} We have $(\phi_j^R)^\top \left(\Phi^\top \Phi\right)^{-1} \phi_j^R \leq \beta$ for all $j\in \{0,1,2, \ldots, r\}$. In this case, we have
\begin{align*}
\tilde{\vb x}_{j + 1} - \vb x_{j + 1}^R &= A_\star \tilde{\phi}_j - \widehat{A} \phi_j^R = A_\star (\tilde{\phi}_j - \phi_j^R) + (A_\star - \widehat{A}) \phi_j^R.
\end{align*}
Therefore, using \eqref{eq:ols_part1}, \eqref{eq:beta_bound}, and \eqref{eq:ur_choice} we find
\begin{align*}
\norm{\tilde{\vb x}_{j + 1} - \vb x_{j + 1}^R} &\leq \norm{A_\star (\tilde{\phi}_j - \phi_j^R)} + \norm{(A_\star - \widehat{A}) \phi_j^R}\\
&\leq \gamma \norm{\tilde{\vb x}_j - \vb x_j^R} + \frac{\alpha}{2 L (1 + \gamma + \ldots + \gamma^{H - 1})}.
\end{align*}
Applying this inequality recursively, we find $\norm{\tilde{\vb x}_{r} - \vb x_{r}^R} \leq \frac{\alpha}{2L}$, which implies
$|\langle \phi_r^R, v \rangle | \geq \alpha / 2$ because $\norm{\phi_r^R - \tilde{\phi}_r} \leq L \norm{\tilde{\vb x}_{r} - \vb x_{r}^R}$ by Assumption~\ref{as:lip} and $|\langle \tilde{\phi}_r , v \rangle | \geq \alpha$ by construction.
Hence, we constructed a feasible sequence of inputs $\{\vb u_j\}_{j = 0}^r$ and Part 1 of the proof is complete.
\subsection*{Part 2 of the proof of Theorem~\ref{thm:main}.}
Now, we show that the number of iterations Algorithm~\ref{alg:traj_opt_exploration} encounters
\begin{align}
\label{eq:fast_shrink}
\max_{\vb u \in \mathbb{B}_{r_u}} \phi(\vb x_t, \vb u)^\top (\Phi^\top \Phi)^{-1} \phi(\vb x_t, \vb u) \geq \beta \;\text{ or }\; (\phi_j^R)^\top (\Phi^\top \Phi)^{-1} \phi_j^R \geq \beta
\end{align}
is upper bounded by
\begin{align}
\label{eq:max_num_ellipsoid}
N_e := \left\lceil \frac{2k \log\left(\frac{2k b_\phi^2}{\log(1 + \beta / 2)}\right)}{\log(1 + \beta / 2)} \right \rceil.
\end{align}
We rely on the following proposition whose proof is deferred to Appendix~\ref{app:ellipsoid}.
\begin{restatable}{prop}{ellipsoid}
\label{prop:ellipsoid_update}
Let $M_0$ be a positive definite matrix and let us consider a sequence of vectors $\{v_t\}_{t \geq 1}$ in $\mathbb{R}^k$ with $\max_{t \geq 1} \norm{v_t} \leq b$. Then, the number of vectors $v_{t + 1}$ such that
\begin{align*}
v_{t + 1}^\top \left(M_0 + \sum_{i = 1}^t v_i v_i^\top \right)^{-1} v_{t + 1} \geq \beta,
\end{align*}
is upper bounded by
\begin{align}
\left\lceil \frac{2k \log\left(\frac{2k b^2}{\lambda_k(M_0) \log(1 + \beta)}\right)}{\log(1 + \beta)} \right \rceil.
\end{align}
\end{restatable}
According to Proposition~\ref{prop:ellipsoid_update}, to prove \eqref{eq:max_num_ellipsoid} it suffices to show that during each iteration of Algorithm~\ref{alg:traj_opt_exploration} with \eqref{eq:fast_shrink} our method collects a measurement $(\phi_t, \vb x_{t + 1})$ such that $\phi_t^\top (\Phi^\top \Phi)^{-1} \phi_t \geq \beta / 2$.
By the definition of our trajectory tracker, whenever $\sup_{\vb u} \phi(\vb x_t, \vb u)^\top (\Phi^\top \Phi)^{-1} \phi(\vb x_t, \vb u) \geq \beta$ we collect a measurement $(\phi_t, \vb x_{t + 1})$ such that $\phi_t^\top (\Phi^\top \Phi)^{-1} \phi_t \geq \beta$.
Next, we show that when $(\phi_j^R)^\top (\Phi^\top \Phi)^{-1} \phi_j^R \geq \beta$, for some $j \leq r$, Algorithm~\ref{alg:traj_opt_exploration} is guaranteed to collect a measurement $(\phi_t, \vb x_{t + 1})$ such that $\phi_t^\top (\Phi^\top \Phi)^{-1} \phi_t \geq \beta / 2$. Let $s$ be the smallest index in the reference trajectory such that $(\phi_s^R)^\top (\Phi^\top \Phi)^{-1} \phi_s^R \geq \beta$.
For the remainder of this section we re-index the trajectory $\{(\vb x_t, \vb u_t)\}_{t \geq 0}$ collected by Algorithm~\ref{alg:traj_opt_exploration} so that $\vb x_j^R = \vb x_j$ for all $j \in \{0, 1, \ldots, s\}$. Then, we show that $(\phi_s^R)^\top (\Phi^\top \Phi)^{-1} \phi_s^R \geq \beta$ implies the existence of $j \in \{0,1,\ldots, s\}$ such that $\phi_j^\top (\Phi^\top \Phi)^{-1} \phi_j \geq \beta / 2$.
Let $\Delta = \phi_s^R - \phi_s$. The Cauchy-Schwarz inequality implies
\begin{align}
\phi_s (\Phi^\top \Phi)^{-1} \phi_s &= \phi_s^R (\Phi^\top \Phi)^{-1} \phi_s^R + \Delta^\top (\Phi^\top \Phi)^{-1} \Delta + 2\Delta^T (\Phi^\top \Phi)^{-1} \phi_s^R \nonumber \\
&\geq \left(\sqrt{\phi_s^R (\Phi^\top \Phi)^{-1} \phi_s^R} - \sqrt{\Delta^\top (\Phi^\top \Phi)^{-1} \Delta}\right)^2.
\label{eq:delta}
\end{align}
Then, as long as $\Delta^\top (\Phi^\top \Phi)^{-1} \Delta \leq \frac{\beta}{2}(3 - 2\sqrt{2})$, we are guaranteed to have $\phi_s^\top (\Phi^\top \Phi)^{-1} \phi_s \geq \beta / 2$.
Now, since $s$ is the smallest index such that $(\phi_s^R)^\top (\Phi^\top \Phi)^{-1} \phi_s^R \geq \beta$, we know that for all $j \in \{0,1, \ldots, s - 1\}$ we have
$(\phi_j^R)^\top (\Phi^\top \Phi)^{-1} \phi_j^R \leq \beta$. Also, we can assume that during reference tracking we do not encounter a state $\vb x_j$, with $j \in \{0,1,\ldots, s - 1\}$, such that
\begin{align*}
\max_{\vb u \in \mathbb{B}_{r_u}} \phi(\vb x_j, \vb u)^\top (\Phi^\top \Phi)^{-1} \phi(\vb x_t, \vb u) \geq \beta
\end{align*}
because we already discussed this case. Now, let us consider the difference
\begin{align*}
\vb x_{j + 1} - \vb x_{j + 1}^R &= A_\star \phi_j + \vb w_j - \widehat{A} \phi_j^R = (A_\star - \widehat{A})\phi_j + \vb w_j - \widehat{A} [\phi_j^R - \phi_j].
\end{align*}
Therefore, we obtain
\begin{align*}
\norm{\vb x_{j + 1} - \vb x_{j + 1}^R} \leq \norm{(A_\star - \widehat{A})\phi_j} + b_w + \norm{\widehat{A} [\phi_j^R - \phi_j]}.
\end{align*}
Let us denote $\delta_j(\vb u) = \phi(\vb x_j, \vb u) - \phi_j^R$. Hence, $\delta_j(\vb u_j) = \phi_j - \phi_j^R$. Now, let $\vb u_\star \in \mathbb{B}_{r_u}$ an input such that $\norm{A_\star \delta_t(\vb u_\star)} \leq \gamma \norm{\vb x_j - \vb x_j^R}$, which we know exists by Assumption~\ref{as:control} (note that $\vb u_\star$ depends on the index $j$, but we dropped this dependency from the notation for simplicity). Since our method attempts trajectory tracking by choosing $\vb u_j \in \arg \min_{\vb u \in \mathbb{B}_{r_u}} \norm{\widehat{A} (\phi(\vb x_t,\vb u) - \phi(\vb x_j^R, \vb u_j^R))}$ we have
\begin{align*}
\norm{\widehat{A} \delta_j(\vb u_j)} &\leq \norm{\widehat{A} \delta_j(\vb u_\star)} \leq \norm{A_\star \delta_j(\vb u_\star)} + \norm{(A_\star - \widehat{A}) \delta_j(\vb u_\star)} \\
&\leq \gamma \norm{\vb x_j - \vb x_j^R} + \norm{(A_\star - \widehat{A}) \delta_j(\vb u_\star)}\\
&\leq \gamma \norm{\vb x_j - \vb x_j^R} + \norm{(A_\star - \widehat{A})\phi(\vb x_j, \vb u_\star)} + \norm{(A_\star - \widehat{A})\phi_j^R}.
\end{align*}
As mentioned above, we can assume $\phi(\vb x_j, \vb u_\star)^\top (\Phi^\top \Phi)^{-1} \phi(\vb x_j, \vb u_\star) < \beta$. Also, recall that
\begin{align*}
(\phi_j^R)^\top (\Phi^\top \Phi)^{-1} \phi_j^R \leq \beta
\end{align*}
since $j < s$ and $s$ is the smallest index so that this inequality does not hold.
Hence, Proposition~\ref{prop:ols} implies that $\norm{(A_\star - \widehat{A})\phi(\vb x_t, \vb u_\star)} \leq \mu \sqrt{\beta}$ and $\norm{(A_\star - \widehat{A})\phi_r^R} \leq \mu \sqrt{\beta}$. Putting everything together we find
\begin{align*}
\norm{\vb x_{j + 1} - \vb x_{j + 1}^R} \leq \gamma \norm{\vb x_j - \vb x_j^R} + 3 \mu \sqrt{\beta} + b_w.
\end{align*}
Then, since the reference trajectory is initialized with the state $\vb x_{0}^R = \vb x_0$, we find
\begin{align*}
\norm{\Delta} = \norm{\phi_s - \phi_{s}^R} &\leq L(b_w + 3\mu \sqrt{\beta}) (1 + \gamma + \ldots + \gamma^{s - 1})\\
&= (3c_3 \sqrt{c_4} + 1) L b_w (1 + \gamma + \ldots + \gamma^{s - 1}),
\end{align*}
where the last identity follows because $\mu \sqrt{\beta} = c_3 \sqrt{c_4} b_w$.
Then, as long as $c_2 \geq \frac{2(3c_3 \sqrt{c_4} + 1)^2}{(3 - 2\sqrt{2})c_4}$, Assumption~\ref{as:initial} offers a lower bound on $\lambda_{\min} (\Phi^\top \Phi)$ which ensures that $\Delta^\top (\Phi^\top \Phi)^{-1} \Delta \leq \frac{\beta}{2}(3 - 2\sqrt{2})$, implying $\phi_s^\top (\Phi^\top \Phi)^{-1} \phi_s \geq \beta / 2$.
To summarize, we have shown whenever Algorithm~\ref{alg:traj_opt_exploration} encounters a situation in which either
\begin{align}
\label{eq:fast_shrink_2}
\sup_{\vb u} \phi(\vb x_t, \vb u)^\top (\Phi^\top \Phi)^{-1} \phi(\vb x_t, \vb u) \geq \beta \;\text{ or }\; (\phi_j^R)^\top (\Phi^\top \Phi)^{-1} \phi_j^R \geq \beta,
\end{align}
it collects a measurement $(\phi_t, \vb x_{t + 1})$ such that $\phi_t (\Phi^\top \Phi)^{-1} \phi_t \geq \beta / 2$. Hence, according to Proposition~\ref{prop:ellipsoid_update}, the event \eqref{eq:fast_shrink_2} can occur at most $N_e$ times (the value $N_e$ was defined in \eqref{eq:max_num_ellipsoid}).
\subsection*{Part 3 of the proof of Theorem~\ref{thm:main}.}
In this final part of the proof we analyze what happens when the trajectory planning problem returns a reference trajectory $(\vb x_j^R, \vb u_j^R)$ for which $|\langle \phi_r^R, v\rangle| \geq \alpha / 2$, where $v$ is a minimal eigenvector with unit norm of $\Phi^\top \Phi$.
We know that there will be at least $T/H$ reference trajectories produced during the run of the algorithm and from Part 2 of the proof we know that at least $T / H - N_e$ of the reference trajectories satisfy $|\langle \phi_r^R, v\rangle| \geq \alpha / 2$, with all states $\vb x_t$ encountered during tracking satisfying $\sup_{\vb u} \phi(\vb x_t, \vb u)^\top \left(\Phi^\top \Phi\right)^{-1} \phi(\vb x_t, \vb u) \leq \beta$ and $(\phi_j^R)^\top (\Phi^\top \Phi)^{-1} \phi_j^R \leq \beta$ for all $j \in \{0,1,\ldots, r\}$.
Following the same argument as in Part 2 of the proof we know that tracking the reference trajectory in this case takes the system to a state $\vb x_t$ such that
\begin{align}
\norm{\vb x_t - \vb x_r^R} \leq (3c_3 \sqrt{c_4} + 1) b_w (1 + \gamma + \ldots + \gamma^{r - 1}),
\end{align}
which implies by Assumption~\ref{as:lip} that
\begin{align}
\norm{\phi_t - \phi_{r}^R} \leq (3c_3 \sqrt{c_4} + 1) L b_w (1 + \gamma + \ldots + \gamma^{r - 1}).
\end{align}
This last inequality implies that $|\langle \phi_t, v\rangle| \geq \alpha / 4$ if $3 c_3 \sqrt{c_4} + 1 \leq c_1 / 2$. Recall that the only condition we imposed so far on $c_4$ is $c_4 \leq c_1^2 / (4 c_3^2)$ in Part 1 of the proof. Hence, since $c_1 > 2$, we can choose $c_4 \leq \frac{(c_1 - 2)^2}{36 c_3^2}$ to ensure that $c_4 \leq c_1^2 / (4 c_3^2)$ and $3 c_3 \sqrt{c_4} + 1 < c_1 / 2$.
Now, to finish the proof of Theorem~\ref{thm:main} we rely on the following result, whose proof is deferred to Appendix~\ref{app:rank_one}.
\begin{restatable}{prop}{rankone}
\label{prop:rank-one}
Let $\ensuremath{\mathcal{V}} \subset \mathbb{R}^k$ be a bounded set, with $\sup_{v\in \ensuremath{\mathcal{V}}}\norm{v} \leq b$, such that for any $u \in \ensuremath{\mathbb{S}}^{k - 1}$ there exists $v\in \ensuremath{\mathcal{V}}$ with $|\langle u, v \rangle| \geq \alpha$. Then, for all $T \geq 0$, given any sequence of vectors $\{v_t\}_{t \geq 0}$ in $\mathbb{R}^k$ we have
\begin{align*}
\lambda_{\min} \left(\sum_{i = 1}^T v_i v_i^\top \right) \geq \frac{\alpha^2 K(T)}{2k} - \frac{k - 1}{2}\left(b^2 - \frac{\alpha^2}{2}\right),
\end{align*}
where $K(T)$ is the number of times
\begin{align*}
v_{t + 1} \in \left\{v | v\in \ensuremath{\mathcal{V}} \text{ and } |\langle \tilde{v}_{t + 1}, v \rangle | \geq \alpha \right\}
\end{align*}
with $\tilde{v}_{t + 1} \in \arg \min_{\norm{v} = 1} v^\top \left(\sum_{i = 1}^t v_i v_i^\top\right)v$ and $t < T$.
\end{restatable}
We have shown that at least $T/H - N_e$ times the algorithm collects a state transition $(\vb x_t, \vb u_t, \vb x_{t + 1})$ for which $\phi_t$ is at least $\alpha / 4$ aligned with the minimal eigenvector of $\Phi^\top \Phi$, where $\Phi$ is the matrix of all $\phi_j$ observed prior to the last trajectory planning. Therefore, Proposition~\ref{prop:rank-one} implies that Algorithm~\ref{alg:traj_opt_exploration} collects a sequence of measurements $(\phi_t, \vb x_{t + 1})$ such that
\begin{align*}
\lambda_{\min} \left(\sum_{t = 1}^{T + t_0} \phi_t \phi_t^\top \right) \geq \frac{\alpha^2}{32} \left(\frac{T}{H} - N_e\right) - \frac{k - 1}{2}b_\phi^2.
\end{align*}
Putting together this result with Proposition~\ref{prop:ols} yields the desired conclusion.
\section{Related Work}
\label{sec:related}
System identification, being one of the cornerstones of control theory, has a rich history, which we cannot hope to summarize here. For an in-depth presentation of the field we direct the interested reader to the book by \citet{ljung1987system} and the review articles by \citet{aastrom1971system}, \citet{bombois2011optimal}, \citet{chiuso2019system}, \citet{hong2008model}, \citet{juditsky1995nonlinear}, \citet{ljung2020shift}, \citet{schoukens2019nonlinear}, and \citet{sjoberg1995nonlinear}. Instead, we discuss recent studies of system identification that develop finite time statistical guarantees.
Most recent theoretical guarantees of system identification apply to linear systems under various sets of assumptions \cite{campi2002finite, dahleh1993sample, faradonbeh2018finite, fattahi2019learning, hardt2018gradient,hazan17,hazan18,oymak2019non, sarkar2018near,sarkar2019finite, sarkar2019nonparametric, simchowitz2018learning,simchowitz2019learning,tsiamis2019finite,tsiamis2019sample, wagenmaker2020active}. Notably, \citet{simchowitz2018learning} derived sharp rates for the non-adaptive estimation of marginally stable systems. Then, \citet{sarkar2018near} developed a more general analysis that also applies to a certain class of unstable linear systems. Both of these studies assumed that the estimation method can directly observe the state of the system. We make the same assumption in our work. However, in many applications full state observation is not possible. Recently,
\citet{simchowitz2019learning} proved that marginally stable linear systems can be estimated from partial observations by using a prefiltered least squares method.
From the study of linear dynamics, the work of \citet{wagenmaker2020active} is the closest to our own. Inspired by E-optimal design \cite{pukelsheim1993optimal}, the authors propose and analyze an adaptive data collection method for linear system identification which maximizes the minimal eigenvalue $\lambda_{\min}(\sum_{t = 0}^{T - 1} \vb x_t \vb x_t^\top)$ under power constraints on the inputs. \citet{wagenmaker2020active} prove matching upper and lower bounds for their method.
Comparatively, there is little known about the sample complexity of nonlinear system identification. \citet{oymak2018stochastic} and \citet{bahmani2019convex} studied the estimation of the parameters $A$ and $B$ of a dynamical system of the form $\vb x_{t + 1} = \phi(A \vb x_t + B \vb u_t)$, where $\phi$ is a known activation function and the inputs $u_t$ are i.i.d. standard Gaussian vectors. Importantly, in this model both $\vb x_t$ and $\vb u_t$ are observed and there is no unobserved noise, which makes estimation easy when the map $\phi$ is invertible. In follow-up work, \citet{sattar2020non} and \citet{foster2020learning} generalized these results. In particular, \citet{foster2020learning} took inspiration from the study of generalized linear models and showed that a method developed for the standard i.i.d. setting can estimate dynamical systems of the form $\vb x_{t + 1} = \phi(A \vb x_t) + \vb w_t$ at an an optimal rate, where $\vb w_t$ is i.i.d. unobserved noise. All these works share a common characteristic, they study systems for which identification is possible through the use of non-adaptive inputs. We take the first step towards understanding systems that require adaptive methods for successful identification.
In a different line of work, \citet{singh2019learning} proposed a learning framework for trajectory planning from learned dynamics. They propose a regularizer of dynamics that promotes stabilizability of the learned model, which allows tracking reference trajectories based on estimated dynamics. Also, \citet{khosravi2020convex} and \citet{khosravi2020nonlinear} developed learning methods that exploit other control-theoretic priors. Nonetheless, none of these works characterize the sample complexity of the problem.
While most work that studies sample-complexity questions on tabular MDPs focuses on finding optimal policies, \citet{jin2020reward} and \citet{wolfer2018minimax} recently analyzed data collection for MDPs and system identification. More precisely, \citet{jin2020reward} developed an efficient algorithm for the exploration of tabular MDPs that enables near-optimal policy synthesis for an arbitrary number of reward functions, which are unknown during data collection, while \citet{wolfer2018minimax} derived minimax sample complexity guarantees for the estimation of ergodic Markov chains. Finally, we note that \citet{abbeel2005exploration} quantified the sample complexity of learning policies from demonstrations for tabular MDPs and for a simpler version of the model class \eqref{eq:system}.
\section{Discussion and Open Problems}
\label{sec:takeaways}
System identification led to the development of controllers for many applications and promises to help us tackle many others in the future. In this work we proposed and analyzed a method that estimates a class of nonlinear dynamical systems in finite time by adaptively collecting data that is informative enough. While this results takes us closer to understanding the fundamental limits of data driven control, there are many limitations to our model and approach. We would like to end with a list of open questions:
\begin{itemize}
\item To solve trajectory planning problems we assumed access to a computational oracle. Is it possible to develop a method that has good statistical guarantees and is also computationally tractable? In practice, successful nonlinear control is often based on linearizations of the dynamics. Is it possible to quantify the sample complexity of system identification when trajectory planning is implemented using linearizations?
\item Our method relies on full state observations. However, in many applications full state observations are impossible.
Is it possible to gain statistical understanding of nonlinear system identification from partial observations?
\item Our guarantee holds only when the true system being identified lies in the model class \eqref{eq:system}. When the true system is no part of the model class, how much data is needed to find the best model in class? \citet{ross2012agnostic} studied this problem under a generative model.
\item Only fully actuated systems can satisfy Assumption~\ref{as:control} with $\gamma < 1$. Is it possible to extend our result to systems that require multiple time steps to recover from disturbances?
\item Assumption~\ref{as:controllable} allows only systems whose feature vectors can align with any direction. What if the feature vectors can align only with vectors in a subspace? In this case, it is not possible to recover $A_\star$ fully. However, in this case, it would not be necessary to know $A_\star$ fully in order to predict or control. Is it possible to estimate $A_\star$ only in the relevant directions?
\item What if we consider infinite dimensional feature maps $\phi$? Can we develop a statistical theory of learning RKHS models of dynamical systems?
\end{itemize}
\subsection*{Acknowledgments}
This research is generously supported in part by ONR awards N00014-17-1-2191, N00014-17-1-2401, and N00014-18-1-2833, NSF CPS award 1931853, and the DARPA Assured Autonomy program (FA8750-18-C-0101).
We would like to thank Alekh Agarwal, Francesco Borrelli, Debadeepta Dey, Munther Dahleh, Ali Jadbabaie, Sham Kakade, Akshay Krishnamurthy, John Langford, and Koushil Sreenath for useful comments and for pointing out relevant related work. We would also like to thank Michael Muehlebach for detailed and valuable feedback on our manuscript.
\bibliographystyle{abbrvnat}
| {'timestamp': '2020-06-19T02:08:52', 'yymm': '2006', 'arxiv_id': '2006.10277', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10277'} | arxiv |
\section{Introduction\label{sec:intro}}
Recent advances in the science of complex systems aim for a better
understanding of
the higher-order connectivity as a possible basis for their
emerging properties and complex functions. Beyond the framework of
pairwise interactions, these connections described by
simplexes of different sizes provide the geometry
for higher-order interactions and simplex-related dynamical variables.
One line of research consists of modelling and analysis of the
structure of simplicial complexes in many complex systems, ranging from the
human connectome \cite{Brain_weSciRep2019} to quantum physics \cite{Geometries_QuantumPRE2015} and materials
science \cite{AT_Materials_Jap2016,we-SciRep2018}. Meanwhile,
considerable efforts aim at understanding the impact of geometry on
the dynamics.
In this context, the research has been done on modelling of the
simplex-based synchronisation processes
\cite{HOC_Synchro_ArenasPRL2019,HOC_synchroexpl_Bianconi2019}, on
studying the related spectral properties of the underlying networks
\cite{we-SpectraPRE2019,Spectra-rapisarda2019}, as well as on the interpretation of the dynamics of the brain \cite{HomologyBrain_petriJRSI2014,HOC_Brain_ReimanFrontCompNeuro2017,Brain_Hubs-dynamicsReview2018} and other complex
dynamical systems \cite{HOC_Kuehn2019}.
Recently, mapping the brain imaging data \cite{BrainMapping_Zhang2018} to
networks involved different types of signals across spatial and
temporal scales; consequently, a variety of structural and functional
networks have been obtained
\cite{BrainConnectivityNets_2010,BrainNetParcellation_Shen2010,EEGnets_ICAreconstr_PLOSone2016,Xbrain_hyperscanning}.
This network mapping enabled getting a new insight into the
functional organisation of the brain \cite{Brain_phys1review,Brain_phys2}, in particular, based on the standard and deep graph theoretic methods
\cite{Sporns_BrainNets_review2013,brainGraph_metods2014,GD_Bud_PLOS2015} and the algebraic topology of graphs \cite{Brain_weSciRep2019,Xbrain_wePLOS2016}.
The type of network that we consider in this work is the whole-brain
network \textit{human connectome}; it is mapped from the \textit{fMRI}
data available from the human connectome project \cite{HCP_Neuroimage}, see Methods. The network nodes are identified as the grey-matter anatomical brain regions, while the edges consist of the white-matter fibres between them. Beyond the pairwise connections, the human connectome
exhibits a rich structure of simplicial complexes and short cycles
between them, as it was shown in \cite{Brain_weSciRep2019}.
Furthermore, on a mesoscopic scale, a typical structure with anatomical modules is observed.
It has been recognised
\cite{brainNets_tasksPNAS2015,Brain_modularNNeurosci2017} that every module has an autonomous function, which contributes to performing complex tasks of the brain. Meanwhile, the integration of this distributed activity and transferring of information between different modules is performed by very central nodes (hubs) as many studies suggest, see a recent review \cite{Brain_Hubs-dynamicsReview2018} and references therein. Formally, hubs are identified as a group of four or five nodes in each brain hemisphere that appear as top-ranking according to the number of connections or another graph-centrality measure. Almost all formal criteria give the same set of nodes, which are anatomically located
deep inside the brain, through which many neuronal pathways go.
Recently, there has been an increased interest in the research of the hubs
of the human connectome. The aim is to decipher their topological configuration and how they fulfil their complex dynamic functions.
For example, it has been recognised that the brain hubs are mutually
connected such that they make a so-called ``rich
club'' structure \cite{Brain_Hubs-richclub2011}. Moreover, their topological configuration develops over time from the prenatal to childhood and adult brain \cite{Brain_Hubs-development2015,Brain_Hubs-development2019}. The hubs also can play a crucial role in the appearance of diseases when their typical configuration becomes
destroyed \cite{Brain_Hubs-diseases2012}.
Assuming that the higher-order connectivity may provide a clue
of how the hubs perform their function, here we examine the organisation of simplicial complexes around eight leading hubs in the human connectome. Based on our work \cite{Brain_weSciRep2019}, we use the consensus connectomes that we have generated at the Budapest connectome server \cite{http-Budapest-server3.0,Hung2}. These are connectomes that are common for one hundred female subjects (F-connectome) and similarly for one hundred male subjects (M-connectome), see Methods. Accordingly, we determine the hubs as eight top-ranking nodes in the whole connectome, performing the ranking according to the number of simplexes of all orders in which the node participates. These are the Putamen, Caudate, Hippocampus and Thalamus-Proper in the left and similarly in the right brain hemisphere; they also appear as hubs according to several other graph-theory measures. We then construct \textit{core networks} consisting of these hubs and all simplexes attached to them in both female and male connectomes. We determine the simplicial complexes and the related topological entropy in these core structures. To highlight the weight-related heterogeneity of connections, the structure of these core networks is gradually altered by increasing the threshold weight above which the connections are considered as significant. We show that the
connectivity up to the 6th order remains in both connectomes
even at a high threshold. Meanwhile, the identity of edges and their weights appear to be different in the F- and M-connectomes.
\section{Methods\label{sec:methods}}
\subsubsection{Data description}
We use the data for two \textit{consensus connectomes} that we have generated in \cite{Brain_weSciRep2019} at the Budapest connectome server 3.0 \cite{http-Budapest-server3.0,Hung2} based on the brain imaging data from Human Connectome Project \cite{HCP_Neuroimage}. Specifically, these are the weighted whole-brain networks that are common for 100 female subjects, \textit{F-connectome}, and similarly,
\textit{M-connectome}, which is common for 100 male subjects. Each connectome consists of $N=1015$ nodes annotated as the anatomical brain regions, and weighted edges, whose weight is given by the number of fibres between the considered pair of brain regions normalised by the average fibre length. Here, we consider the largest number
$10^6$ fibres tracked and set the minimum weight to four. The
corresponding core networks \textit{Fc-network} and \textit{Mc-network} are defined as subgraphs of the F- and M-connectomes, respectively, containing the leading hubs and their first neighbour nodes as well as
all edges between these nodes. Meanwhile, the hubs are determined according to the topological dimension criteria, as described below and in Results.
\subsubsection{Topology analysis and definition of quantities}
We apply the Bron-Kerbosch algorithm \cite{cliquecomplexes} to analyse
the structure of simplicial complexes, i.e., clique complexes, in the core Fc- and Mc-
connectomes. In this context, a \textit{simplex} of order $q$ is a
full graph (clique) of $q+1$ vertices $\sigma_q=\left \langle
i_0,i_1,i_2,...,i_{q}\right \rangle$. Then a simplex $\sigma_r$ of the order
$r<q$ which consists of $r$ vertices of the simplex $\sigma_q$ is a
\textit{face} of the simplex $\sigma_q$. Thus, the simplex $\sigma_q$
contains faces of all orders from $r=0$ (nodes), $r=1$ (edges), $r=2$ (triangles), $r=3$ (tetrahedrons), and so on, up to the order $r=q-1$. A set of simplexes connected via shared faces of different orders makes a
\textit{simplicial complex}. The order of a simplicial complex is
given by the order of the largest clique in this complex, and
$q_{max}$ is the largest order of all simplicial complexes.
Having the adjacency matrix of the graph, with the algorithm, we build
the incidence matrix ${\Lambda}$, which contain IDs of all
simplexes and IDs of nodes that make each simplex. With this
information at hand, we compute three structure vectors \cite{jj-book,Qanalysis1} to characterise the architecture of simplicial complexes:
\begin{itemize}
\item The \textit{first structure vector (FSV):}
$\mathbf{Q}=\{Q_0,Q_1,\cdots Q_{q_{max}-1}, Q_{q_{max}}\}$, where $Q_q$
is the number of $q$-connected components;
\item The \textit{second structure vector (SSV):} $\mathbf{N_s}=\{n_0,n_1, \cdots
n_{q_{max}-1},n_{q_{max}}\}$, where $n_q$ is the number of
simplexes from the level $q$ upwards;
\item The \textit{third structure vector (TSV):} the component $\hat{Q}_q \equiv
1-{Q_q}/{n_q}$ quantifies the degree of connectedness
among simplexes \textit{at} the topology level $q$.
\end{itemize}
Furthermore, we determine the topological dimension of
nodes and topological entropy introduced in \cite{we-PRE2015}. The topological dimension $dimQ_i$ of a node $i$ is defined
as the number of simplexes of all orders in which
the corresponding vertex participates,
\begin{equation}
dimQ_i \equiv \sum_{q=0}^{q_{max}}Q_q^i \ ,
\label{eq:dimQ}
\end{equation}
where $Q_q^i$ is determined directly from the
${\Lambda}$ matrix by tracking the orders of all simplexes in which the node
$i$ has a nonzero entry.
Then, with this information, the entropy of a topological level $q$
defined as
\begin{equation}
S_Q(q) = -\frac{\sum_i p_q^i \log p_q^i}{\log M_q} \;
\label{eq-entropy-q}
\end{equation}
is computed. Here, $p_q^i= \frac{Q_q^i}{\sum_i Q_q^i}$ is the node's
occupation probability of the $q$-level, and the sum runs over all
nodes. The normalisation factor $M_q=\sum_i\left(1-\delta_{Q_q^i,0}\right)$ is the number of vertices having a nonzero entry at the level $q$ in the entire graph.
Thus the topological entropy (\ref{eq-entropy-q}) measures the degree
of cooperation among vertices resulting in a minimum at a given
topology level. Meanwhile, towards the limits $q\to 0$
and $q\to q_{max}$, the occurrence of independent cliques results in a higher entropy at that level.
In addition, we compute the vector $\mathbf{f}= \left\{ f_0, f_1,
\cdots f_{q_{max}}\right\}$, which is defined
\cite{we-PRE2015} such that $f_q$ represents the \textit{number of simplxes and faces at the level} $q$. Given that a free simplex of the size
$n>q$ has the corresponding combinatorial number of faces of the order $q$, the component $f_q$ thus contains information about the actual number of shared faces between simplexes \textit{at} the level $q$.
\subsubsection{Network structure \& hyperbolicity}
The underlying topological graph represents the 1-skeleton of the simplicial complex. Using the graph-theory methods \cite{sergey-lectures}, we determine the degree--degree correlations that are relevant to the observed "rich club behaviour" of the hubs in the global connectome \cite{Brain_weSciRep2019,Brain_Hubs-richclub2011,Brain_Hubs-development2015,Brain_Hubs-development2019}.
Precisely, for each node in the considered network, the average number of edges of its nearest neighbour nodes is plotted against the node's degree. The
following scaling form is expected
\begin{equation}
\langle k\rangle_{i:nn} \sim k_i^\mu \ .
\label{eq:assort}
\end{equation}
Here, the positive values of the exponent $\mu > 0$ indicate the
\textit{assortative} correlations, while $\mu < 0$ corresponds to a
\textit{disassortative} mixing, and $\mu=0$ suggests the absence of
nodes correlations. We analyse the Fc- and Mc-graphs by considering
the edges that remain after applying different weight thresholds. The weight distribution $P(w)$ is determined for the
entire core-networks, see Results.
Furthermore, using the 4-point Gromov
criterion for the hyperbolic graphs \cite{HB-BermudoHBviasmallerGraph2013}, we determine the hyperbolicity parameter
$\delta_{max}$ of these graphs. Precisely, for each 4-tuple of nodes
$(A,B,C,D)$ in a $\delta$-hyperbolic
graph $G$, the ordered relation between the sums of shortest-path distances
${\cal{S}}\equiv d(A,B)+d(C,D) \leq {\cal{M}}\equiv d(A,C) + d(B,D)
\leq {\cal{L}}\equiv d(A,D)+ d(B,C)$ implies that
\begin{equation}
\delta(A,B,C,D) \equiv \frac{{\cal{L}} - {\cal{M}}}{2} \leq \delta (G)\; .
\label{eq:hb-condition}
\end{equation}
It follows from the triangle inequality that the upper bound of
$({\cal{L}}-{\cal{M}})/2$ is given by the minimal distance
$d_{min}\equiv min\{d(A,B),d(C,D)\} $ in the smallest sum
${\cal{S}}$. Thus, by sampling a large number
($10^9$) 4-tuples of nodes in each graph, and plotting $\delta(A,B,C,D) $
against the corresponding minimal distance $d_{min}$, we obtain $\delta (G)$
as the upper bound of $\delta_{max}=max_G\{\delta(A,B,C,D)\}$.
\section{Results\label{sec:results}}
\subsection{Whole-brain connectomes: Identification of hubs from
topological dimension }
We consider two whole-brain networks, precisely, the F-connectome,
which is common for 100 female subjects, and M-connectome,
consisting of the edges that are common to 100 maile subjects; see
Methods and \cite{Brain_weSciRep2019} for more details. For
illustration, the F-connectome is shown in the left panel of Figure\
\ref{fig-ranking2x}. Each connectome consists of 1015 nodes as
anatomical brain regions. These nodes are interconnected by a particular pattern of edges and organised in six mesoscopic communities.
For this work, we determine the \textit{global hubs} in the F- and M-connectomes. These are eight top-ranking nodes according to the number of simplexes attached to a node. Based on our work in \cite{Brain_weSciRep2019}, we use the
corresponding $\Lambda$-matrix for the F- and M-connectomes
and identify simplexes of all orders in which a particular node
$i=1,2,\cdots 1015$ participates. The node's topological dimension
$dimQ_i$, defined by (\ref{eq:dimQ}) is then computed. For both connectomes, the node's ranking distribution by the decreasing topological dimension is shown in the middle right panel of figure\ \ref{fig-ranking2x}. As the figure demonstrates, the eight top-ranking nodes (marked along the curve for the F-connectome) make a separate group compared to the rest of the curve. These nodes also appear (see the list below)
among the first eight ranked topological hubs in the M-connectome:
\begin{verbatim}
rank_F name rank_M
1 Left Putamen 1
2 Right Putamen 3
3 Left Caudate 2
4 Right Caudate 4
5 Left Thalamus-Propper 5
6 Left Hippocampus 7
7 Right Hippocampus 8
8 Right Thalamus-Propper 6
\end{verbatim}
For comparisons with other approaches, we also show that these nodes
(with altered order) also appear as eight hubs ranked according to the node's strength $S_i$, defined as the sum of weights of all edges of the node $i$. In this case, the ranking curves of the F- and M-connectomes
virtually overlap, see the top right panel in figure\
\ref{fig-ranking2x}. The lower right panel shows the 3-dimensional plot of the node's topological dimension over different topology
levels $q$. In this plot, the high peaks corresponding to our hubs
indicate what orders of simplexes mostly contribute to distinguishing the
hubs from the rest of the surrounding nodes.
Note that these eight nodes also appear as the leading hubs in several other sorting methods, for example, according to the node's degree and centrality measures \cite{Brain_Hubs-development2019,Brain_Hubs-richclub2011}.
For comparisons with other methods, we also show
the names of nodes that rank from 9-20 according to the topological
dimension in the case of the F-connectome:
\begin{verbatim}
rh.precentral_7, Right-Pallidum, rh.caudalmiddlefrontal_11,
lh.caudalmiddlefrontal_13, Brain-Stem, Left-Pallidum,
lh.precentral_21, lh.precentral_6,lh.superiorparietal_25,
rh.precentral_19, rh.precentral_15, rh.superiorparietal_13
\end{verbatim}
The nodes listed in the first two rows, except from the Brain Stem, also appear in this ranking range in the M-connectome.
\begin{figure}[htb]
\centering
\begin{tabular}{cc}
\resizebox{28pc}{!}{\includegraphics{Fig1_combFfull_ranking3x_w.png}}\\
\end{tabular}
\caption{(left) F-connectome, 1000K fibres, with labels as brain
areas. (right, top) Ranking of the vertices according to the strength
$S_i$, top, and topological dimension $dimQ_i$, lower panel, where eight leading vertices are marked (they also visible as hubs in the network on the left). (right,bottom) The 3D plot of the topological
dimension against the topology level $q$ and the node's index
$i$ for nodes in the F-core graph. }
\label{fig-ranking2x}
\end{figure}
Next, we consider a reduced network consisting of these
hubs and the nodes directly attached to any one of the hubs,
as well as the original edges between them in the F- and
M-connectomes. The resulting \textit{core networks}
termed Fc- and Mc-networks, respectively, are shown in figure\
\ref{fig-coreNets2x}. Note that, by definition, the topological
dimension of the hubs is invariant to this network reduction.
\subsection{Core networks associated with global
hubs in the female and male connectomes}
The extracted core Fc- and Mc-networks represent the part of the corresponding connectome in which the global hubs perform their function. Here, we explore in detail the structure of the core networks in the female and male connectomes. Furthermore, we analyse how the structure depends on the weights of the edges. The histogram of the weights is
shown in figure\ \ref{fig-PwFcMc}a for both Fc- and Mc-networks.
As figure\ \ref{fig-coreNets2x} demonstrates, these core networks
exhibit a similar community structure. Precisely, each community in the
Fc- and similarly in Mc-connectome is a part of the global connectome
community, cf. figure\ \ref{fig-ranking2x}. This fact suggests that, in both connectomes, the core network reaches to all parts of the brain. Meanwhile, it contains a smaller number of nodes (517 nodes in the Fc- and 418 in the Mc-network, respectively), and a considerably smaller number of connections compared to the whole connectome. Thus, the node's assortativity changes as compared to the whole network. As the inset
to figure\ \ref{fig-PwFcMc} shows, the hubs mix in line with other
vertices in the core graphs, while they make a separate group when the
whole connectomes are considered \cite{Brain_weSciRep2019}. This
assortative dependence emphasises the robustness of core networks
with respect to the hierarchical transmission of information among brain regions \cite{Nets_assortativegroups2018}.
\begin{figure}[htb]
\centering
\begin{tabular}{cc}
\resizebox{28pc}{!}{\includegraphics{Fig2_FcMc_comm_w.png}}\\
\end{tabular}
\caption{Core networks attached to the eight hubs in the female Fc- (left) and male
Mc-connectome (right) from the original full-connectomes data at
$N_F=10^6$ fibres tracked and the weight threshold $w_0=4$. The relative size of nodes is
proportional to the number of their connections in the core-networks;
the node's labels show the corresponding anatomical brain region,
and colours indicate five communities.}
\label{fig-coreNets2x}
\end{figure}
\subsection{Topology of core networks depending on the weights
of edges\label{sec:subnet}}
Using the approaches described in Methods, we determine several
algebraic-topology measures to characterise the structure of
simplicial complexes as well as the underlying topological graphs in the core Fc- and Mc-networks.
These results are summarised in figures\ \ref{fig-PwFcMc} and \ref{fig-coreNets2xw40}.
Apart from a different number of nodes and edges that comprise the Fc-
and Mc-networks, we note that both of them are heterogeneous concerning the weight of edges, resulting in the broad log-normal
distributions in figure\ \ref{fig-PwFcMc}a. Therefore, we obtain
different structures when the edges over a given threshold weight, $w_0$,
are considered. By gradually increasing the threshold $w_0=$10, 40, 100,
we show how the network properties change. More precisely, by removing the edges below the threshold, the network's diameter increases, and the distribution of the shortest-path distances change the
shape. Eventually, a larger cycle can appear, resulting in the
increased value of the hyperbolicity parameter, as shown in figure\
\ref{fig-PwFcMc}b,c. Meanwhile, the reduced networks preserve the
assortative mixing among the nodes, see the inset to figure \ref{fig-PwFcMc}a.
\begin{figure}[htb]
\centering
\begin{tabular}{cc}
\resizebox{26pc}{!}{\includegraphics{Fig3_PwAssPdHb_abc_w.png}}\\
\end{tabular}
\caption{(a) Histogram of the weights of edges in the core Fc -and Mc-networks of the corresponding female and male connectomes, main
panel; Inset: the assortativity plots of nodes in the core Fc- and
Mc-networks for the weight threshold $w_0$=4, 10, 40, and 100,
respectively, indicated by dotted vertical lines in the main panel.
(b) Distribution of distances $P(d)$ against the shortest path
distance $d$ and (c) the hyperbolicity parameter $\delta_{max}$
against the shortest distance $d_{min}$ for the core Fc- and
Mc-networks shown in figure \ref{fig-coreNets2x}, and these networks for two larger threshold weights, indicated in the legend.}
\label{fig-PwFcMc}
\end{figure}
\begin{figure}[H]
\centering
\begin{tabular}{cc}
\resizebox{26pc}{!}{\includegraphics{Fig4_SVs_Entr_fq_q_w0_w.png}}\\
\end{tabular}
\caption{The first (FSV) and third (TSV) structure vectors, the
number of simplexes and faces $f_q$, and the topological entropy
$S_Q(q)$ against the topology level $q$ in the core Fc- and Mc-networks with the edges of weights above the threshold $w_0=$10, 40, 100.
}
\label{fig-coreNets2xSVs}
\end{figure}
At the same time, the order of simplicial complexes gradually reduces
from $q_{max}=12$, in the case of $w_0=10$, to $q_{max}=5$ when edges
over the threshold $w_0=100$ are retained.
The number of simplexes of the order $q=0,1,2\cdots q_{max}$, given by
the FSV, and the ways that they interconnect, the TSV, change the
functional dependence of $q$ while at the same time reducing the difference between the Fc- and Mc-structures, cf.\ figure\ \ref{fig-coreNets2xw40}. The number of
simplexes and faces at the $q-$level, $f_q$, and the topological
entropy, $S_Q(q)$, follow a similar tendency. Moreover, the topological entropy
measure shows a pronounced minimum, indicating the
geometrical forms through which the nodes mostly interconnect. For example,
in the case of $w_0=100$, the minimum appears at $q=2$ (triangles) in
the Mc-, and $q=3$ (tetrahedrons) in the Fc-networks, respectively.
Figure \ref{fig-coreNets2xw40} illustrates the
remaining structures of the Fc- and Mc-networks when the weight
threshold $w_0=40$ is applied.
\begin{figure}[htb]
\centering
\begin{tabular}{cc}
\resizebox{24pc}{!}{\includegraphics{Fig5_FcMc_w40_white_FM_w.png}}\\
\end{tabular}
\caption{Core networks with the weights of edges above $w_0=40$ for the female (left) and male (right) connectomes. Labels of nodes indicate the affected brain regions.}
\label{fig-coreNets2xw40}
\end{figure}
An edge-to-edge comparison between the core Fc- and Mc-networks with
the threshold weight $w_0=40$, shown in figure \ref{fig-coreNets2xw40},
revealed 948 edges that appear in both of them. Besides, the core
Mc-network has 204 unique edges that are not present in the
Fc-network with this threshold value, while the Fc-network has 419
such edges that are not seen in the corresponding Mc-network.
Moreover, the weight difference among the common edges varies, as
shown in figure \ref{fig-mcfccommon-wdiff}. For example, the pairs of
nodes that make up 16 edges with a large difference $|w_M-wF| >300$ are listed below:
\begin{verbatim}
ID src_node ID dst_node w_M w_F
51 rh.parsopercularis_2 504 Right-Putamen 601 980
151 rh.precentral_9 504 Right-Putamen 740 375
159 rh.precentral_7 504 Right-Putamen 2453 1544
502 Right-Thalamus-Pr. 1008 Left-Thalamus-Pr. 809 1721
503 Right-Caudate 504 Right-Putamen 3340 2843
503 Right-Caudate 505 Right-Pallidum 3072 2280
503 Right-Caudate 507 Right-Hippocampus 937 591
503 Right-Caudate 1009 Left-Caudate 7122 8211
651 lh.precentral_21 1010 Left-Putamen 1220 765
654 lh.precentral_16 1008 Left-Thalamus-Pr. 137 584
654 lh.precentral_16 1010 Left-Putamen 1460 631
657 lh.precentral_4 1010 Left-Putamen 1796 993
661 lh.precentral_6 1010 Left-Putamen 618 1084
1008 Left-Thalamus-Pr. 1013 Left-Hippocampus 2481 2917
1009 Left-Caudate 1010 Left-Putamen 3174 2362
1009 Left-Caudate 1011 Left-Pallidum 3222 1805
\end{verbatim}
\begin{figure}[htb]
\centering
\begin{tabular}{cc}
\resizebox{22pc}{!}{\includegraphics{Fig6_commonedges_wdiff_w.png}}\\
\end{tabular}
\caption{The weight difference $w_M-w_F$ of the common edges, indexed from 1 to 948, in the Fc- and Mc-core networks in Fig.\
\ref{fig-coreNets2xw40} with the edges weight over 40.}
\label{fig-mcfccommon-wdiff}
\end{figure}
\section{Discussion and Conclusions\label{sec:discuss}}
We have analysed the structure of simplicial complexes surrounding eight topological hubs in the human connectomes. The hubs here
determined as the top-ranking nodes with the highest topological dimension (the number of simplexes attached). They represent the central
brain regions that coincide with the hubs determined by several other graph-theoretic measures. By parallel analysis of the
female and male consensus connectomes, we have extracted the
corresponding core segments, here termed the Fc- and Mc-networks, in
which the brain hubs perform their function. Further, we have demonstrated that these
core networks are heterogeneous concerning the weights of
edges and they possess different weight-dependent
organisations. Consequently, their structure simplifies with the
increased weight threshold, eventually reducing at significant
thresholds to the 6-clique structure. Interestingly, these six nodes\begin{verbatim}
Right_Thalamus_Proper,Right_Caudate,Right_Putamen,
Right_Pallidum, Right_Hippocampus, Right_Amygdala\end{verbatim} make up a remaining
6-clique structure in both female and male core networks. With two
additional nodes, we have found another 6-clique in the female core
network, i.e.,
\begin{verbatim}rh.precentral_15, rh.precentral_7, Right_Thalamus_Proper,
Right_Caudate,Right_Putamen, Right_Pallidum\end{verbatim}
In both core networks, the identity of
the affected brain regions, as well as the variation of the weights
along the commonly present edges, illustrates further differences between the female and male connectomes at the level of hubs.
In the context of higher-order connectivity, these findings can
contribute to better understanding the pattern of connections that
enable the brain hubs to perform their role in the female and male
connectomes.
Besides, the revealed detailed structure of simplicial complexes and the
identified brain regions that take part in them can facilitate the
desired simplex-based dynamics modelling of the brain functions.
| {'timestamp': '2020-06-19T02:11:20', 'yymm': '2006', 'arxiv_id': '2006.10357', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10357'} | arxiv |
\section{Introduction} \label{sec:intro}
Power law distributions account for phenomena and observations across diverse fields including physics, astronomy, biology, economics and the social sciences \citep{Sornette}. \cite{Newman} cites plenty of specific real-world examples including distribution of wealth, word frequency in a given text, population in a city etc. \cite{Taleb} states the most general form of the survival function\footnote{The cumulative density function (cdf) is $P(x)$, which is the probability that random variable $X$ is less than $x$. The complementary cumulative density function (ccdf) also referred to as the survival function is given by $\overline{P}(x) = 1 - P(x)$} describing power law distributions as
\begin{equation} \label{eq:PL_Gen}
\overline{P}(x) = L(x) x^{-\alpha}
\end{equation}
where $L(x)$ is a slowly-varying function, i.e.
\[
\lim_{x \rightarrow \infty} \frac{L(\lambda x)}{L(x)} = 1 \; \; \forall \lambda > 0
\]
The (tail) exponent $\alpha$ is referred to as the tail index\footnote{The tail index is also referred to as shape parameter in the context of Pareto distributions, stability parameter in the context of stable distributions and degrees of freedom in the context of t-distributions.}. The main motivation for this article and the accompanying \proglang{R} \citep{baseR} package is a study in a forthcoming publication \citep{RMM} analyzing power law data, in particular that of Pareto distributions, a special class of power laws with probability density function\footnote{The pdf is the derivative of the cdf: $p(x) = \frac{dP(x)}{dx}$} (pdf) defined for $x \geq x_{\mathrm{min}}>0$:
\begin{equation} \label{eq:Pareto1}
p(x) = \frac{ \alpha x^{\alpha}_{\mathrm{min}}}{x^{1+\alpha}}
\end{equation}
In the present \lq Big Data\rq era, it is essential for programs to be optimized for speed and have the ability to handle large data sets. In particular, there are applications in genetics involving large data sets where power-law distributions describe network connectivity \cite{BinZ}. We found some of the existing tail estimation packages are not optimized for speed especially when dealing with a large data set. Our team then decided that it would be better to code our own parameter estimation tools in \proglang{R} with the main goal being fast computation of the tail index $\alpha$. We would also like to have the ability to rapidly generate (large) Pareto data sets . This resulted in the creation of our \proglang{R}-package \pkg{ptsuite}.
Our main objective with our estimator package is to address the speed advantage. In particular, we want to examine how long the code takes to run. The effect of the sample size on the speed was examined. We compared our run times against some existing \proglang{R} packages.
The other objective is to test for the accuracy of our tail index estimates by seeing how close the tail index estimates are on known tail index values corresponding to generated Pareto data. As the tail index estimation algorithms are well-known, this is a secondary objective\footnote{In the Appendix \ref{sec:GPDevir}, we also look at the accuracy of the estimates produced by the other packages. All packages studied in this paper produce high accuracy estimates which improve with sample size.} We will also look at the size of the sample and the effect it has on accuracy. Finally, we look at tail index estimation for heavy tailed non-Pareto distributions.
This rest of the paper is structured in the following format. We review the Tail Index Estimation methods for the functions used in the package \pkg{ptsuite} in Section \ref{sec:overview}. Next in Section \ref{sec:speedresults} we present our speed results by comparing run times for functions in \pkg{ptsuite} with their counterpart functions from other \proglang{R}-packages. We conclude this section with a brief comparison of run times of the functions in \pkg{ptsuite}. The next Section \ref{sec:accuresults} looks at the accuracy of the \pkg{ptsuite} tail index estimates, in particular focusing on the Hill Estimate. Section \ref{sec:usingthepackage} follows and is a guide on using the \pkg{ptsuite} package. We conclude with Section \ref{sec:summary} which summarizes this work and discusses future directions.
\begin{leftbar}
In this article our main considerations are Pareto distributions which are pure power law distributions as per the definition in equation (\ref{eq:Pareto1}). With regards to the general definition of power law distributions as per (\ref{eq:PL_Gen}) we see there are three scenarios:
\begin{enumerate}
\item Right tails, i.e. power law behavior in the limit $x \rightarrow \infty$. The Pareto family is in this class.
\item Left tails, i.e. power law behavior in the limit $x \rightarrow - \infty$
\item Both left and right tails, i.e. power law behavior in limit $x \rightarrow \pm \infty$
\end{enumerate}
Symmetric stable distributions and Student-T distributions fall into the last class. More general forms of stable distributions include a skew parameter that can result in exclusively left or right tails - for more details please refer to \cite{Nolan}.
\end{leftbar}
\newpage
\section{Overview of Tail Index Estimation Methods} \label{sec:overview}
To identify Pareto behavior we can start with a frequency plot/histogram and try to visually identify a lower bound (c.f. $x_{\mathrm{min}}$) and `strict power law' behavior. We may also do further heuristics such as log-log plots and log-log rank plots and look for a linear relationship to identify power law behavior, though these methods are not fool proof \cite{Nair}. In \cite{Hubert} there is another Pareto test given which looks for linear behavior in the QQ-plots of the log transformed data against standard exponential data\footnote{The slope of this line would give the $\alpha$ estimate.}. A simple implementation of this method is included in our package. We focus on the tail index estimators given below.
\begin{leftbar}
Estimation methods 1 - 5 estimate the tail index working under the assumption of Pareto distributed data. To apply these methods for the general power law form (\ref{eq:PL_Gen}), we would look to identify where tail (power law) behavior starts which is not a precise or easy task \citep{Nair}. For a comprehensive list and the background theory, the interested reader is referred to \cite{Hill, Nair, Pokorna, Hubert}. The reference by \cite{Hundred} is a useful catalog of Pareto-tail index estimation techniques.
\end{leftbar}
\begin{enumerate}
\item Maximum Likelihood Estimation (MLE) \citep{Newman} \\
The MLE formula leads to a biased estimator $\hat{\alpha}$:
\begin{equation}
\label{eq:MLE}
\hat{\alpha} = N \cdot \left[ \sum_{i=1}^N \frac{x_i}{\hat{x}_{\mathrm{min}}} \right]^{-1}
\end{equation}
Here $x_i$ represents the data point for $i=1, \ldots, N$. The minimum value, $x_{\mathrm{min}}$, is estimated from the data set and hence denoted $\hat{x}_{\mathrm{min}}$. As MLE leads to asymptotic normality for the estimator, the error bounds may be given by the standard deviation:
\begin{equation}
\hat{\sigma} = \frac{\sqrt{n+1}}{n} \cdot \hat{\alpha}
\end{equation}
The estimate (\ref{eq:MLE}) can be converted to an unbiased version $\alpha^*$ as follows \cite{Rizzo}:
\[
\alpha^* = \frac{n-2}{n} \cdot \hat{\alpha}
\]
\item Least Squares Estimation (LS) \citep{Zaher, Nair} \\
The first step in this method is to sort the data in increasing order. Next for each value $i$ (of $N$ data points) we calculate $y_i$ the number of points greater than the $i^{th}$ data point. In this method one seeks to minimize the sum of the squared errors between the rank plot and the logarithm of the ccdf.
The estimator is given by
\begin{equation}
\label{eq:LS1}
\hat{\alpha} = \frac{ \sum_{i=1}^N \left( \hat{y_i} - \frac{1 }{N} \sum_{i=1}^N \hat{y_i} \right) \left( \ln x_i - \frac{1}{N} \sum_{i=1}^N \ln x_i \right) }{ \sum_{i=1}^N \left( \ln x_i - \frac{1}{N} \sum_{i=1}^N \ln x_i \right)^2}
\end{equation}
\item Weighted Least Squares Estimation (WLS) \citep{Nair} \\
The formulation is the same as for the LS method, except that the sum of squared errors is weighted. The choice of weight $w_i$ is defined to be
\begin{equation}
\label{eq:WLSweight}
w_i = \left[ \ln \left( \frac{x_i}{\hat{x}_{\mathrm{min}}} \right) \right]^{-1}
\end{equation}
For this choice of weight the WLS method is closely related to the MLE, in that they will converge in the large $N$-limit.
The tail index estimate is then given by
\begin{equation}
\label{eq:WLS1}
\hat{\alpha} = \frac{ - \sum_{i=1}^N \ln \left( \hat{y_i} / N \right) }{ \sum_{i=1}^N \ln \left( x_i / \hat{x}_{\mathrm{min}} \right)}
\end{equation}
If there are no ties in the sorted data we may directly write:
\begin{equation}
\label{eq:WLS2}
\hat{\alpha} = \frac{ - \sum_{i=1}^N \ln \left[ (N+1-i) / N \right] }{ \sum_{i=1}^N \ln \left( x_i / \hat{x}_{\mathrm{min}} \right)}
\end{equation}
\item Percentile Method (PM) \citep{Bhatti} \\
The PM estimator for the tail index is given by
\begin{equation}
\label{eq:PM}
\hat{\alpha} = \frac{ \ln 3}{ \ln (P^*_{75}) - \ln (P^*_{25})}
\end{equation}
Here $P^*_{q}$ is the $q^{th}$ percentile of the data set. We also test a modified version using the median which we refer to here as the Modified Percentile Method (MPM). This is given by
\begin{equation}
\label{eq:MPM}
\hat{\alpha} = \frac{ \ln 2}{ \ln (P^*_{75}) - \ln (P^*_{50})}
\end{equation}
The final modification we test makes use of the geometric mean and is written here in the shorthand Geometric Mean Percentile Method (GMPM):
\begin{equation}
\label{eq:GMPM}
\hat{\alpha} = \frac{ 1 - \ln 4}{ \frac{1}{N} \sum_{i=1}^N \ln x_i - \ln (P^*_{75}) }
\end{equation}
There are further variations on PM estimation in \cite{Bhatti}.
\item Method of Moments (MoM) \citep{Rytgaard}, \\
The MoM estimator is derived by equating the sample mean to the theoretical mean of the Pareto distribution.
\begin{equation}
\label{eq:MoM}
\hat{\alpha} = \frac{ \sum_{i=1}^N x_i }{ \sum_{i=1}^N x_i - N \cdot \hat{x}_{\mathrm{min}}}
\end{equation}
The major drawback with this method is that if $\alpha \leq 1$ the estimator will not converge to the true value - a Pareto distribution with $\alpha \leq 1$ has infinite mean. (For this estimator $\hat{\alpha}\longrightarrow 1$ when $\alpha \leq 1$ \citep{Vytaras}) It is always better to use this method in conjunction with another to check the validity of the estimate.
\item Hill Estimator (HE) \citep{Nair, Pokorna, Hill} \\
The HE method is a type of MLE method \citep{Hill, Hubert, Hundred} which can be used for general power law setting (\ref{eq:PL_Gen}) and one would need to specify where the tail starts. In particular the HE formula requires the specification of the tuning parameter (starting point) $k$. Identifying where the tail starts is an art in itself and requires a thorough examination of the data. If one chooses the parameter $k$ to be too large the variance of the estimator increases; on the other hand if it is too low the bias increases \citep{Hundred}. The data first needs to be sorted in increasing order and then we may write:
\begin{equation}
\label{eq:Hill}
\hat{\alpha} (k) = k \cdot \left[ \sum_{j=1}^k \ln \frac{x_{N-j+1}}{x_{N-k}} \right]^{-1}
\end{equation}
\end{enumerate}
\section{Results for Speed} \label{sec:speedresults}
In this section we look at the performance of functions in the \pkg{ptsuite} package against their (comparable) counterparts in other packages. All estimator functions in the \pkg{ptsuite} package have been coded in \proglang{C++} to ensure the highest possible performance. We compare the speed of the functions available in the package using the package \pkg{microbenchmark} \citep{microbenchR}. We compare the following estimators/functions from the \pkg{ptsuite} package and their counterparts:
\begin{longtable}{cll}
\hline
\textbf{Estimator/function} & \textbf{Package} & \textbf{Function in Package} \\*
\hline
\multirow{3}{*}{Hill's Estimator} & \pkg{ptsuite} & \code{alpha\_hills} \\*
& \pkg{laeken} & \code{thetaHill} \\*
& \pkg{evir} & \code{gpd} (set \code{nextremes} accordingly) \\*
\hline
\multirow{2}{*}{Method of Moments} & \pkg{ptsuite} & \code{alpha\_moment} \\*
& \pkg{laeken} & \code{thetaMoment} \\*
\hline
\multirow{4}{*}{MLE} & \pkg{ptsuite} & \code{alpha\_mle} \\*
& \pkg{EnvStats} & \code{epareto} (set \code{method = `mle'}) \\*
& \pkg{evir} & \code{gpd} (set \code{nextremes} to the sample size) \\*
& \pkg{DeMAND} & \code{pareto.fit} \\*
\hline
\multirow{2}{*}{Leaset Squares} & \pkg{ptsuite} & \code{alpha\_ls} \\*
& \pkg{EnvStats} & \code{epareto} (set \code{method = `ls'}) \\*
\hline
\multirow{3}{*}{Pareto Data Generation} & \pkg{ptsuite} & \code{generate\_pareto} \\*
& \pkg{EnvStats} & \code{rpareto} \\*
& \pkg{evir} & \code{rgpd} \\
\hline
\caption{Existing \pkg{R} packages and their functions corresponding to functions in \pkg{ptsuite}.}
\end{longtable}
We complete a hundred runs for a selected sample using \pkg{ptsuite} and the counterpart. We capture the following times: mean, maximum, median and minimum. These times are all measured in microseconds ($\mu$s)\footnote{Times are displayed in log microseconds in the graphs. Sample sizes are presented in log units. Overall the display is better with these unit adjustments.}. In all the tests, \pkg{ptsuite} comes out on top. We should note however for some of the functions, the fastest (minimum) time of the competing package has been faster than the slowest (maximum) time of the \pkg{ptsuite}.
\begin{figure}[H]
\begin{subfigure}{\textwidth}
\centering \includegraphics{Hills1}
\label{fig:hills1}
\caption{Speed comparison of \pkg{ptsuite} and \pkg{laeken}.}
\end{subfigure}
\begin{subfigure}{\textwidth}
\centering \includegraphics{Hills1_evir}
\caption{Speed comparison of \pkg{ptsuite} and \pkg{evir}.}
\label{fig:hills1_evir}
\end{subfigure}
\caption{Time plot of Hill's estimates for sample 1.}
\end{figure}
\small
\begin{longtable}{clcccc}
\multicolumn{6}{r}{\tablename\ \thetable\ -- \textit{Continued on next page}} \\
\endfoot
\endlastfoot
\hline
\textbf{Sample Size} & \textbf{Package} & \multicolumn{1}{l}{\textbf{Mean ($\mu$s)}} & \multicolumn{1}{l}{\textbf{Maximum ($\mu$s)}} & \multicolumn{1}{l}{\textbf{Median ($\mu$s)}} & \multicolumn{1}{l}{\textbf{Minimum ($\mu$s)}} \\*
\hline
\multirow{3}{*}{$10^{2}$} & ptsuite & 1.03E+01 & 1.58E+01 & 1.01E+01 & 7.30E+00 \\*
& laeken & 5.64E+01 & 9.20E+01 & 5.54E+01 & 4.39E+01 \\*
& evir & 5.77E+02 & 8.18E+02 & 5.66E+02 & 5.59E+02 \\*
\hline
\multirow{3}{*}{$10^{3}$} & ptsuite & 4.50E+01 & 7.27E+01 & 4.33E+01 & 3.92E+01 \\*
& laeken & 1.05E+02 & 2.26E+02 & 1.04E+02 & 8.52E+01 \\*
& evir & 2.81E+03 & 4.69E+03 & 2.67E+03 & 2.61E+03 \\*
\hline
\multirow{3}{*}{$10^{4}$} & ptsuite & 3.91E+02 & 4.26E+02 & 3.91E+02 & 3.74E+02 \\*
& laeken & 5.28E+02 & 5.87E+02 & 5.20E+02 & 4.96E+02 \\*
& evir & 2.44E+04 & 3.92E+04 & 2.36E+04 & 2.29E+04 \\*
\hline
\multirow{3}{*}{$10^{5}$} & ptsuite & 3.94E+03 & 4.17E+03 & 3.97E+03 & 3.79E+03 \\*
& laeken & 5.92E+03 & 8.23E+03 & 4.82E+03 & 4.51E+03 \\*
& evir & 2.40E+05 & 3.47E+05 & 2.38E+05 & 2.32E+05 \\*
\hline
\multirow{3}{*}{$10^{6}$} & ptsuite & 4.18E+04 & 5.28E+04 & 4.19E+04 & 3.95E+04 \\*
& laeken & 7.21E+04 & 1.15E+05 & 9.19E+04 & 4.67E+04 \\*
& evir & 2.47E+09 & 2.58E+09 & 2.49E+09 & 2.37E+09 \\*
\hline
\multirow{3}{*}{$10^{7}$} & ptsuite & 4.47E+05 & 4.92E+05 & 4.44E+05 & 4.21E+05 \\*
& laeken & 7.10E+05 & 1.23E+06 & 8.11E+05 & 4.69E+05 \\*
& evir & 2.49E+10 & 2.67E+10 & 2.46E+10 & 2.41E+10 \\
\hline
\caption{\label{tab:hills1} Function timing results using \pkg{microbenchmark} for Hill's Estimate with sample 1.}
\end{longtable}
\normalsize
\begin{figure}[H]
\centering \includegraphics{MoM2}
\caption{Time plot of MoM estimates for sample 2.}
\label{fig:mom2}
\end{figure}
\small
\begin{longtable}{clcccc}
\multicolumn{6}{r}{\tablename\ \thetable\ -- \textit{Continued on next page}} \\
\endfoot
\endlastfoot
\hline
\textbf{Sample Size} & \textbf{Package} & \multicolumn{1}{l}{\textbf{Mean ($\mu$s)}} & \multicolumn{1}{l}{\textbf{Maximum ($\mu$s)}} & \multicolumn{1}{l}{\textbf{Median ($\mu$s)}} & \multicolumn{1}{l}{\textbf{Minimum ($\mu$s)}} \\*
\hline
\multirow{2}{*}{$10^{2}$} & ptsuite & 2.95E+01 & 1.77E+02 & 3.06E+01 & 1.71E+01 \\*
& laeken & 1.04E+03 & 8.49E+04 & 1.90E+02 & 1.30E+02 \\*
\hline
\multirow{2}{*}{$10^{3}$} & ptsuite & 4.29E+01 & 5.81E+01 & 4.32E+01 & 4.09E+01 \\*
& laeken & 1.36E+02 & 2.30E+02 & 1.35E+02 & 1.32E+02 \\*
\hline
\multirow{2}{*}{$10^{4}$} & ptsuite & 3.85E+02 & 4.03E+02 & 3.85E+02 & 3.80E+02 \\*
& laeken & 9.60E+02 & 1.03E+03 & 9.74E+02 & 9.06E+02 \\*
\hline
\multirow{2}{*}{$10^{5}$} & ptsuite & 3.79E+03 & 3.92E+03 & 3.79E+03 & 3.76E+03 \\*
& laeken & 9.81E+03 & 1.72E+04 & 9.36E+03 & 9.25E+03 \\*
\hline
\multirow{2}{*}{$10^{6}$} & ptsuite & 3.91E+04 & 5.12E+04 & 3.87E+04 & 3.81E+04 \\*
& laeken & 1.33E+05 & 1.71E+05 & 1.29E+05 & 1.19E+05 \\*
\hline
\multirow{2}{*}{$10^{7}$} & ptsuite & 3.86E+05 & 4.12E+05 & 3.84E+05 & 3.82E+05 \\*
& laeken & 1.44E+06 & 1.58E+06 & 1.43E+06 & 1.39E+06 \\
\hline
\caption{\label{tab:mom2} Function timing results using \pkg{microbenchmark} for MoM Estimate with sample 2.}
\end{longtable}
\normalsize
\newpage
\begin{figure}[H]
\begin{subfigure}{\textwidth}
\centering \includegraphics{MLE3}
\caption{Speed comparison of \pkg{ptsuite} and \pkg{EnvStats}.}
\label{fig:MLE3}
\end{subfigure}
\begin{subfigure}{\textwidth}
\centering \includegraphics{MLE3_evir}
\caption{Speed comparison of \pkg{ptsuite} and \pkg{evir}.}
\label{fig:MLE3_evir}
\end{subfigure}
\caption{Time plots of MLE estimates for sample 3.}
\end{figure}
\small
\begin{longtable}{clcccc}
\hline
\textbf{Sample Size} & \textbf{Package} & \multicolumn{1}{l}{\textbf{Mean ($\mu$s)}} & \multicolumn{1}{l}{\textbf{Maximum ($\mu$s)}} & \multicolumn{1}{l}{\textbf{Median ($\mu$s)}} & \multicolumn{1}{l}{\textbf{Minimum ($\mu$s)}} \\*
\hline
\multirow{3}{*}{$10^{2}$} & ptsuite & 7.07E+00 & 3.83E+01 & 6.80E+00 & 5.50E+00 \\*
& EnvStats & 3.23E+01 & 1.20E+02 & 3.03E+01 & 2.85E+01 \\*
& evir & 5.72E+02 & 7.94E+02 & 5.66E+02 & 5.59E+02 \\*
\hline
\multirow{3}{*}{$10^{3}$} & ptsuite & 3.91E+01 & 2.47E+02 & 3.58E+01 & 3.41E+01 \\*
& EnvStats & 9.80E+01 & 1.93E+02 & 9.15E+01 & 8.73E+01 \\*
& evir & 2.94E+03 & 8.18E+03 & 2.93E+03 & 2.61E+03 \\*
\hline
\multirow{3}{*}{$10^{4}$} & ptsuite & 3.23E+02 & 4.50E+02 & 3.21E+02 & 3.17E+02 \\*
& EnvStats & 7.38E+02 & 8.19E+02 & 7.35E+02 & 6.60E+02 \\*
& evir & 2.57E+04 & 4.87E+04 & 2.46E+04 & 2.41E+04 \\*
\hline
\multirow{3}{*}{$10^{5}$} & ptsuite & 3.22E+03 & 3.54E+03 & 3.19E+03 & 3.15E+03 \\*
& EnvStats & 7.94E+03 & 2.10E+04 & 7.53E+03 & 6.84E+03 \\*
& evir & 2.47E+05 & 3.70E+05 & 2.45E+05 & 2.33E+05 \\*
\hline
\multirow{3}{*}{$10^{6}$} & ptsuite & 3.23E+04 & 3.48E+04 & 3.21E+04 & 3.18E+04 \\*
& EnvStats & 1.23E+05 & 1.70E+05 & 1.18E+05 & 1.06E+05 \\*
& evir & 2.66E+06 & 2.84E+06 & 2.66E+06 & 2.54E+06 \\*
\hline
\multirow{3}{*}{$10^{7}$} & ptsuite & 3.21E+05 & 3.35E+05 & 3.20E+05 & 3.17E+05 \\*
& EnvStats & 1.40E+06 & 1.53E+06 & 1.39E+06 & 1.30E+06 \\*
& evir & 2.66E+07 & 2.83E+07 & 2.65E+07 & 2.61E+07 \\
\hline
\caption{\label{tab:mle3} Function timing results using \pkg{microbenchmark} for MLE Estimate with sample 3.}
\end{longtable}
\normalsize
\newpage
\begin{figure}[H]
\centering \includegraphics{MLE_seed1_demand_ptsuite.jpeg}
\caption{Time plot of MLE estimates for sample 1.}
\label{fig:mle1_demand}
\end{figure}
\small
\begin{longtable}{clcccc}
\hline
\textbf{Sample Size} & \textbf{Package} & \multicolumn{1}{l}{\textbf{Mean ($\mu$s)}} & \multicolumn{1}{l}{\textbf{Maximum ($\mu$s)}} & \multicolumn{1}{l}{\textbf{Median ($\mu$s)}} & \multicolumn{1}{l}{\textbf{Minimum ($\mu$s)}} \\*
\hline
\multirow{2}{*}{$10^{2}$} & ptsuite & 8.61E+00 & 1.21E+01 & 8.80E+00 & 5.80E+00 \\*
& DeMAND & 1.59E+04 & 3.64E+04 & 1.50E+04 & 1.47E+04 \\*
\hline
\multirow{2}{*}{$10^{3}$} & ptsuite & 3.90E+01 & 5.78E+01 & 3.77E+01 & 3.44E+01 \\*
& DeMAND & 3.33E+05 & 4.14E+05 & 3.29E+05 & 3.16E+05 \\*
\hline
\multirow{2}{*}{$10^{4}$} & ptsuite & 3.27E+02 & 3.52E+02 & 3.24E+02 & 3.18E+02 \\*
& DeMAND & 1.99E+07 & 2.09E+07 & 1.99E+07 & 1.95E+07 \\
\hline
\caption{\label{tab:mle1_demand} Function timing results using \pkg{microbenchmark} for MLE Estimate with sample 1.}
\end{longtable}
\normalsize
\begin{figure}[H]
\centering \includegraphics{LS4}
\caption{Time plot of LS estimates for sample 4.}
\label{fig:ls4}
\end{figure}
\small
\begin{longtable}{clcccc}
\hline
\textbf{Sample Size} & \textbf{Package} & \multicolumn{1}{l}{\textbf{Mean ($\mu$s)}} & \multicolumn{1}{l}{\textbf{Maximum ($\mu$s)}} & \multicolumn{1}{l}{\textbf{Median ($\mu$s)}} & \multicolumn{1}{l}{\textbf{Minimum ($\mu$s)}} \\*
\hline
\multirow{2}{*}{$10^{2}$} & ptsuite & 2.02E+01 & 8.80E+01 & 1.55E+01 & 9.20E+00 \\*
& EnvStats & 2.10E+03 & 1.17E+05 & 7.23E+02 & 6.65E+02 \\*
\hline
\multirow{2}{*}{$10^{3}$} & ptsuite & 7.83E+01 & 1.28E+02 & 7.73E+01 & 7.28E+01 \\*
& EnvStats & 9.06E+02 & 3.47E+03 & 8.65E+02 & 8.19E+02 \\*
\hline
\multirow{2}{*}{$10^{4}$} & ptsuite & 7.81E+02 & 1.20E+03 & 7.73E+02 & 7.26E+02 \\*
& EnvStats & 3.19E+03 & 5.84E+03 & 3.20E+03 & 2.52E+03 \\*
\hline
\multirow{2}{*}{$10^{5}$} & ptsuite & 7.84E+03 & 1.73E+04 & 7.56E+03 & 7.34E+03 \\*
& EnvStats & 4.12E+04 & 6.60E+04 & 3.77E+04 & 3.42E+04 \\*
\hline
\multirow{2}{*}{$10^{6}$} & ptsuite & 9.45E+04 & 1.91E+05 & 8.06E+04 & 7.66E+04 \\*
& EnvStats & 3.28E+05 & 4.15E+05 & 3.23E+05 & 2.63E+05 \\*
\hline
\multirow{2}{*}{$10^{7}$} & ptsuite & 9.17E+05 & 1.61E+06 & 8.79E+05 & 8.09E+05 \\*
& EnvStats & 3.66E+06 & 4.87E+06 & 3.62E+06 & 3.34E+06 \\
\hline
\caption{\label{tab:ls4} Function timing results using \pkg{microbenchmark} for LS Estimate with sample 4.}
\end{longtable}
\normalsize
\newpage
\begin{figure}[H]
\begin{subfigure}{\textwidth}
\centering \includegraphics{gp5}
\caption{Speed comparison of \pkg{ptsuite} and \pkg{EnvStats}.}
\label{fig:gp5}
\end{subfigure}
\begin{subfigure}{\textwidth}
\centering \includegraphics{gp5_evir}
\caption{Speed comparison of \pkg{ptsuite} and \pkg{evir}.}
\label{fig:gp5_evir}
\end{subfigure}
\caption{Time plots of generating Pareto data for sample 5.}
\end{figure}
\small
\begin{longtable}{clcccc}
\hline
\textbf{Sample Size} & \textbf{Package} & \multicolumn{1}{l}{\textbf{Mean ($\mu$s)}} & \multicolumn{1}{l}{\textbf{Maximum ($\mu$s)}} & \multicolumn{1}{l}{\textbf{Median ($\mu$s)}} & \multicolumn{1}{l}{\textbf{Minimum ($\mu$s)}} \\*
\hline
\multirow{3}{*}{$10^{2}$} & ptsuite & 2.02E+01 & 2.71E+01 & 2.00E+01 & 1.79E+01 \\*
& EnvStats & 4.89E+02 & 3.23E+03 & 4.48E+02 & 4.07E+02 \\*
& evir & 1.97E+01 & 3.87E+01 & 1.93E+01 & 1.86E+01 \\*
\hline
\multirow{3}{*}{$10^{3}$} & ptsuite & 1.60E+02 & 1.91E+02 & 1.59E+02 & 1.56E+02 \\*
& EnvStats & 3.63E+03 & 5.44E+03 & 3.51E+03 & 3.24E+03 \\*
& evir & 1.62E+02 & 1.96E+02 & 1.61E+02 & 1.59E+02 \\*
\hline
\multirow{3}{*}{$10^{4}$} & ptsuite & 1.55E+03 & 1.60E+03 & 1.55E+03 & 1.54E+03 \\*
& EnvStats & 3.58E+04 & 7.29E+04 & 3.52E+04 & 3.23E+04 \\*
& evir & 1.57E+03 & 1.62E+03 & 1.57E+03 & 1.56E+03 \\*
\hline
\multirow{3}{*}{$10^{5}$} & ptsuite & 1.61E+04 & 2.33E+04 & 1.56E+04 & 1.54E+04 \\*
& EnvStats & 3.62E+05 & 4.05E+05 & 3.58E+05 & 3.31E+05 \\*
& evir & 1.57E+04 & 2.42E+04 & 1.56E+04 & 1.56E+04 \\*
\hline
\multirow{3}{*}{$10^{6}$} & ptsuite & 1.59E+05 & 2.11E+05 & 1.56E+05 & 1.55E+05 \\*
& EnvStats & 3.69E+06 & 4.02E+06 & 3.67E+06 & 3.59E+06 \\*
& evir & 1.61E+05 & 1.79E+05 & 1.60E+05 & 1.58E+05 \\*
\hline
\multirow{3}{*}{$10^{7}$} & ptsuite & 1.57E+06 & 1.68E+06 & 1.56E+06 & 1.55E+06 \\*
& EnvStats & 3.67E+07 & 4.00E+07 & 3.64E+07 & 3.59E+07 \\*
& evir & 1.60E+06 & 1.67E+06 & 1.60E+06 & 1.59E+06 \\
\hline
\caption{\label{tab:gp5} Function timing results using \pkg{microbenchmark} for generating Pareto data with sample 5.}
\end{longtable}
\normalsize
\subsection{Comparison of Estimation Methods within ptsuite package}
In this section, we compare and present the speed of the (estimation method) functions available in the package \pkg{ptsuite} using the package \pkg{microbenchmark} \citep{microbenchR}. We do not include Hill's Estimator as it restricts the domain to a subset of the sample. The results of this comparison can be seen in Table \ref{tab:speedptsuite}.
We note here that the most computationally intensive functions are the LS and the WLS methods with the WLS method consuming a very large time for progressively larger datasets. It is seen that the PM and the MPM are consistently the fastest methods regardless of the sample size (but we remind the reader that the results of the percentile methods are also the least accurate for small sample sizes).
\begin{figure}[H]
\centering
\includegraphics{all_ptsuite_speeds}
\caption{Function timing results using \pkg{microbenchmark} for various sample sizes.}
\label{fig:all_ptsuite_speeds}
\end{figure}
\small
\begin{longtable}{lcrrr}
\multicolumn{5}{r}{\tablename\ \thetable\ -- \textit{Continued on next page}} \\
\endfoot
\endlastfoot
\hline
\textbf{Method} & \textbf{Sample Size} & \textbf{Minimum ($\mu$s)} & \textbf{Median ($\mu$s)} & \textbf{Maximum ($\mu$s)} \endfirsthead
\hline
\multirow{5}{*}{MLE} & $10^{3}$ & 2.36E+01 & 2.45E+01 & 5.77E+01 \\*
& $10^{4}$ & 2.20E+02 & 2.23E+02 & 3.55E+02 \\*
& $10^{5}$ & 2.17E+03 & 2.23E+03 & 2.63E+03 \\*
& $10^{6}$ & 2.19E+04 & 2.23E+04 & 2.33E+04 \\*
& $10^{7}$ & 2.22E+05 & 2.30E+05 & 2.50E+05 \\*
\hline
\multirow{5}{*}{LS} & $10^{3}$ & 5.46E+01 & 5.63E+01 & 8.53E+01 \\*
& $10^{4}$ & 5.44E+02 & 5.92E+02 & 6.81E+02 \\*
& $10^{5}$ & 5.56E+03 & 5.82E+03 & 1.83E+04 \\*
& $10^{6}$ & 5.88E+04 & 5.96E+04 & 7.32E+04 \\*
& $10^{7}$ & 6.27E+05 & 6.79E+05 & 7.53E+05 \\*
\hline
\multirow{5}{*}{WLS} & $10^{3}$ & 5.09E+01 & 5.26E+01 & 9.79E+01 \\*
& $10^{4}$ & 5.17E+02 & 5.39E+02 & 7.50E+02 \\*
& $10^{5}$ & 5.20E+03 & 5.38E+03 & 5.78E+03 \\*
& $10^{6}$ & 7.70E+04 & 7.82E+04 & 1.04E+05 \\*
& $10^{7}$ & 3.12E+07 & 3.53E+07 & 3.70E+07 \\*
\hline
\multirow{5}{*}{PM} & $10^{3}$ & 6.83E+00 & 7.40E+00 & 7.14E+01 \\*
& $10^{4}$ & 7.08E+01 & 7.20E+01 & 1.04E+02 \\*
& $10^{5}$ & 8.01E+02 & 8.17E+02 & 1.36E+03 \\*
& $10^{6}$ & 9.37E+03 & 9.66E+03 & 1.18E+04 \\*
& $10^{7}$ & 1.30E+05 & 1.36E+05 & 7.45E+05 \\*
\hline
\multirow{5}{*}{MPM} & $10^{3}$ & 7.11E+00 & 7.54E+00 & 8.16E+01 \\*
& $10^{4}$ & 7.05E+01 & 7.23E+01 & 1.52E+02 \\*
& $10^{5}$ & 8.02E+02 & 8.15E+02 & 1.11E+03 \\*
& $10^{6}$ & 9.35E+03 & 9.66E+03 & 2.44E+04 \\*
& $10^{7}$ & 1.30E+05 & 1.36E+05 & 1.88E+05 \\*
\hline
\multirow{5}{*}{GMPM} & $10^{3}$ & 2.90E+01 & 3.02E+01 & 1.12E+02 \\*
& $10^{4}$ & 2.93E+02 & 2.95E+02 & 6.61E+02 \\*
& $10^{5}$ & 3.03E+03 & 3.07E+03 & 4.19E+03 \\*
& $10^{6}$ & 3.19E+04 & 3.24E+04 & 8.90E+04 \\*
& $10^{7}$ & 3.55E+05 & 3.72E+05 & 4.34E+05 \\*
\hline
\multirow{5}{*}{MoM} & $10^{3}$ & 2.56E+01 & 2.70E+01 & 1.83E+02 \\*
& $10^{4}$ & 2.39E+02 & 2.44E+02 & 3.44E+02 \\*
& $10^{5}$ & 2.36E+03 & 2.42E+03 & 2.81E+03 \\*
& $10^{6}$ & 2.40E+04 & 2.43E+04 & 6.68E+04 \\*
& $10^{7}$ & 2.42E+05 & 2.52E+05 & 2.79E+05 \\
\hline
\caption{\label{tab:speedptsuite} Function timing results using \pkg{microbenchmark} for various sample sizes.}
\end{longtable}
\normalsize
\section{Results for Accuracy} \label{sec:accuresults}
We begin by noting that we test the HE method separately as we have to supply an extra parameter, namely the tuning parameter $k$. To test each of the other six methods methods we do the following:
\begin{enumerate}
\item Simulate Pareto data for 4 different values of $\alpha$: 0.5, 1.5, 2.2, 5. Pareto data is generated via
\[
x_i = \frac{x_{\mathrm{min}}}{u_i^{1/\alpha}}
\]
where $u_i$ is a standard uniform random number. We work with $x_{\mathrm{min}}=2$ for all the tests.
\item For each $\alpha$ value we generate 3 different sample sizes: $10^3, 10^5, 10^6$ to test the effect of sample size on the accuracy.
\item For each sample size we generate four different samples (by changing the random number generator seed).
\end{enumerate}
In total we run $288 = 6 \times 4 \times 3 \times 4$ tests. To economize on space we present a sample of the results (Table \ref{tab:alpha2.2}) with the complete set of results given in Appendix \ref{sec:App-Est}. The $\hat{\alpha}$ error given is calculated as follows:
\[
\mathrm{Error \,\%} = \frac{|\alpha - \hat{\alpha}|}{\alpha} \times 100\%
\]
We also remark here that for the LS and PM methods, there is a peculiarity in that the accuracy dips slightly for particular increases in sample size. The reader is referred to Figure \ref{fig:LS_MLE_MoM_PM_accuracy} to observe the counter-intuitive behavior\footnote{Note that the error percentages are in log scale - hence larger negative bars indicate smaller error.}. For example when considering sample 1, the LS $\alpha$-estimate with $10^{3}$ samples has error $0.95\%$ and an error of $2.08\%$ with $10^{4}$ samples. When we increase the sample size to $10^{5}$, the error drops as expected. Similarly for sample 1, the PM $\alpha$-estimate with $10^{4}$ samples has error $0.07\%$ and an error of $0.85\%$ with $10^{5}$ samples. As with the LS method, when we increase the sample size to $10^{6}$, the error drops as expected. We are not certain as to the reason for the drop in accuracy for a certain values of larger samples - we consider other samples (by changing the seed) and these results are presented in Appendix \ref{sec:App-LS} and Appendix \ref{sec:App-PM} respectively. The other samples also have this counter-intuitive behavior but at different sample sizes.
\begin{figure}[H]
\centering
\includegraphics{all_log}
\caption{Accuracy plot of selected methods of estimation available in \pkg{ptsuite}. Sample results for $\alpha$ = 2.2 (using sample 1 from each run).}
\label{fig:LS_MLE_MoM_PM_accuracy}
\end{figure}
\begin{table}[H]
\small
\centering
\begin{tabular}{lcrr}
\hline
\textbf{Method} & \multicolumn{1}{l}{\textbf{Sample Size}} & \multicolumn{1}{l}{\textbf{$\hat{\alpha}$}} & \multicolumn{1}{l}{\textbf{$\hat{\alpha}$ error}} \\*
\hline
\multirow{6}{*}{MLE} & $10^{2}$ & 2.52705 & 14.87\% \\*
& $10^{3}$ & 2.22869 & 1.30\% \\*
& $10^{4}$ & 2.18519 & 0.67\% \\*
& $10^{5}$ & 2.19168 & 0.38\% \\*
& $10^{6}$ & 2.19971 & 0.01\% \\*
& $10^{7}$ & 2.19954 & 0.02\% \\*
\hline
\multirow{6}{*}{LS} & $10^{2}$ & 2.31566 & 5.26\% \\*
& $10^{3}$ & 2.22096 & 0.95\% \\*
& $10^{4}$ & 2.15422 & 2.08\% \\*
& $10^{5}$ & 2.18542 & 0.66\% \\*
& $10^{6}$ & 2.20057 & 0.03\% \\*
& $10^{7}$ & 2.19946 & 0.02\% \\*
\hline
\multirow{6}{*}{MoM} & $10^{2}$ & 2.62537 & 19.34\% \\*
& $10^{3}$ & 2.28164 & 3.71\% \\*
& $10^{4}$ & 2.18505 & 0.68\% \\*
& $10^{5}$ & 2.19049 & 0.43\% \\*
& $10^{6}$ & 2.19942 & 0.03\% \\*
& $10^{7}$ & 2.20004 & 0.00\% \\*
\hline
\multirow{6}{*}{PM} & $10^{2}$ & 2.7422 & 24.65\% \\*
& $10^{3}$ & 2.27278 & 3.31\% \\*
& $10^{4}$ & 2.20158 & 0.07\% \\*
& $10^{5}$ & 2.18126 & 0.85\% \\*
& $10^{6}$ & 2.19776 & 0.10\% \\*
& $10^{7}$ & 2.20044 & 0.02\% \\
\hline
\end{tabular}
\caption{\label{tab:alpha2.2} Sample results for $\alpha$ = 2.2 (using sample 1 from each run). The sample sizes are $10^3, 10^4, 10^5, 10^6 $ and $10^7$.}
\end{table}
\subsection{Accuracy of Hill's Estimator - Results}
The HE method differs from the other methods in this paper as one needs to specify a cut-off point from which to consider the ``tail'' portion of the distribution. This is denoted by the \code{k} value which is the \textit{$k^{th}$} largest observation of the data set. In other words, it can be thought of as the number of observations of the tail to be considered in estimating the shape parameter (tail index). We may also specify a value as a starting point of the tail estimation area instead of a ranked order.
\subsection{Hill's Estimator for Strictly Pareto data}
In this section we look at the impact of \code{k} when HE is used on strictly Pareto data. We consider the same random Pareto samples (with $\alpha = 0.5, 1.5, 2.2$ and $5.0$) used for the previous estimators but only consider $10^3, 10^5$ and $10^6$ sample sizes along with \code{k} set at the $25^{th}$, $50^{th}$ and $75^{th}$ percentiles for each sample size. (Refer Appendix \ref{sec:App-Hill} for the full set of results.)
We also generate four samples from the Pareto distribution with $\alpha=1.5$ and $\hat{x}_{\mathrm{min}} = 5$. Figure \ref{fig:pareto-k} shows how the HE varies with \code{k}. Since the data supplied is strictly Pareto, increasing \code{k} (from 1 to \code{n} = 100,000) increases the accuracy of the estimate and we can see the estimate stabilizing around $\hat{\alpha} = 1.5$.
\begin{figure}[h]
\begin{subfigure}{0.5\textwidth}
\includegraphics[width=0.9\linewidth, height=5cm]{pareto-density}
\caption{Density plot of Pareto distribution.}
\label{fig:pareto-density}
\end{subfigure}
\begin{subfigure}{0.5\textwidth}
\includegraphics[width=0.9\linewidth, height=5cm]{pareto-k}
\caption{Hill's estimate for $\alpha$ with varying \code{k}.}
\label{fig:pareto-k}
\end{subfigure}
\caption{Plot of pdf of Pareto distribution ($\alpha=1.5$, $\hat{x}_{\mathrm{min}} = 5$) and Hill's estimate for varying \code{k}.}
\end{figure}
\subsection{Hill's Estimator for Non-Pareto data}
To further test the accuracy of the HE method and understand the relationship of the value of \code{k} in estimating $\alpha$, we vary \code{k} in the presence of non-Pareto power law data. We consider data sampled from a i) t-distribution and ii) stable distribution respectively, and estimate the tail-index.
For this purpose we first generate four samples from the t-distribution with degrees of freedom (d.f.) equal to 3. The tail index $\alpha$ is estimated by varying \code{k} from 1 to \code{n} (where \code{n} = 100,000). It can be seen from Figure \ref{fig:t} that using a smaller value of \code{k} results in a more accurate estimation of the tail index - we feel this is because a smaller value of \code{k} avoids including observations from the ``body'' of the distribution. We should note however the earlier point about the bias of the estimator for small \code{k}.
\begin{figure}[h]
\begin{subfigure}{0.5\textwidth}
\includegraphics[width=0.9\linewidth, height=5cm]{t-density}
\caption{Density plot of t-distribution.}
\label{fig:t-density}
\end{subfigure}
\begin{subfigure}{0.5\textwidth}
\includegraphics[width=0.9\linewidth, height=5cm]{t}
\caption{Hill's estimate for $\alpha$ with varying \code{k}.}
\label{fig:t}
\end{subfigure}
\caption{Plot of pdf of t-distribution (d.f. = 3) and Hill's estimate for varying \code{k}.}
\end{figure}
Next we simulate four samples from a symmetric stable distribution\footnote{A symmetric stable distribution was generated using $\frac{\sin(\alpha V)}{(\cos(V))^{1/\alpha}}(\frac{\cos((1-\alpha)V)}{W})^{(1-\alpha)/\alpha} $ where $V \sim Unif[-\pi/2,\pi/2]$ and $W \sim Exp(1)$ \citep[p.149]{Glas04}.} with stability parameter\footnote{A symmetric stable distribution with stability parameter $\alpha$ has the following property $\lim_{x \rightarrow \pm \infty} p(x) \sim |x|^{1+\alpha}$.} (tail index) $\alpha$=1.5 and vary \code{k} to estimate $\alpha$. The results of this simulation are similar to that of t-distribution in that a smaller value of \code{k} leads to a closer estimate of the true $\alpha$. The results are as follows:
\begin{figure}[h]
\begin{subfigure}{0.5\textwidth}
\includegraphics[width=0.9\linewidth, height=5cm]{stable-density}
\caption{Density plot of stable distribution.}
\label{fig:stable-density}
\end{subfigure}
\begin{subfigure}{0.5\textwidth}
\includegraphics[width=0.9\linewidth, height=5cm]{stable}
\caption{Hill's estimate for $\alpha$ with varying \code{k}.}
\label{fig:stable}
\end{subfigure}
\caption{Plot of pdf of stable distribution ($\alpha = 1.5$) and Hill's estimate for varying \code{k}.}
\end{figure}
\newpage
\section{Using the ptsuite Package} \label{sec:usingthepackage}
The \pkg{ptsuite} is built with ease of use in mind. Here we go over the use of each of the functions provided in the package. The \pkg{ptsuite} is available on Centralized R Archive Network (CRAN): \url{https://cran.r-project.org/web/packages/ptsuite/index.html}.
\subsection[The generate-pareto function]{The \code{generate\_pareto} function}
This function is able to generate random Pareto distributed data with the specified \code{shape} and \code{scale} parameters. The function has been written to be similar in type to the popular \code{runif} and \code{rexp} type of functions for generating data from a particular distribution.
The full call of the function is:
\begin{Code}
generate_pareto(sampleSize, shape, scale)
\end{Code}
For example to generate a sample of size $100,000$ with $\alpha$ (shape parameter) = 1.2 and $x_{min}$ (scale parameter) = 3 and store it in the variable \code{data}, the following code could be used:
\begin{CodeChunk}
\begin{CodeInput}
R> set.seed(1234)
R> d <- generate_pareto(100000, 1.2, 3)
R> head(d)
\end{CodeInput}
This produces the following output:
\begin{CodeOutput}
[1] 18.364397 4.454392 4.533604 4.447960 3.398763
4.349730
\end{CodeOutput}
\end{CodeChunk}
\subsection[The pareto_qq_test function]{The \code{pareto\_qq\_test} function}
The \code{pareto\_qq\_test} function can be used as a first step to identify whether the data is Pareto distributed before estimating the tail index. If most of the data points appear to be distributed along a line, it is possible that the data may be Pareto. Conversely, if most of the data are distributed non-linearly, then the data is most probably not Pareto distributed.
This function\footnote{For added interactivity this package makes use of the \pkg{plotly} package \citep{plotlyR} to generate the Q-Q plots if it is available in the user's \proglang{R} library. If unavailable, it defaults to the \proglang{R} base plot.} plots the quantiles of the standard exponential distribution on the x-axis and the log values of the provided data on the y-axis. If Pareto data was supplied, a log transformation of this data would result in an exponential distribution with mean $\alpha^{-1}$. These data points would then show up on the QQ-plot as line with slope $\alpha^{-1}$.
\begin{leftbar}
\textbf{Note:} This is a heuristic test where one can look for data being distributed along a straight line indicating a possible Pareto distribution.
\end{leftbar}
The full call of the function is:
\begin{Code}
pareto_qq_test(dat)
\end{Code}
Demonstration of this function is carried out using a Pareto distributed sample of size $100,000$ with $\alpha$ (shape parameter) = 1.2 and $x_{min}$ (scale parameter) = 3, and using an exponentially distributed sample of size $100,000$ with $\lambda$ (reciprocal of mean) = 5 as an example of non-Pareto data.\\
Q-Q Plot constructed for Pareto distributed data:
\begin{CodeChunk}
\begin{CodeInput}
R> set.seed(1234)
R> d <- generate_pareto(100000, 1.2, 3)
R> pareto_qq_test(d)
\end{CodeInput}
\end{CodeChunk}
Q-Q Plot constructed for exponentially distributed data:
\begin{CodeChunk}
\begin{CodeInput}
R> set.seed(1234)
R> exp_data <- rexp(100000, 5)
R> pareto_qq_test(exp_data)
\end{CodeInput}
\end{CodeChunk}
\begin{figure}[h]
\begin{subfigure}{0.5\textwidth}
\includegraphics[width=0.9\linewidth, height=5cm]{QQ_pareto}
\caption{Q-Q Plot for Pareto distributed data.}
\label{fig:QQ_pareto}
\end{subfigure}
\begin{subfigure}{0.5\textwidth}
\includegraphics[width=0.9\linewidth, height=5cm]{QQ_exp}
\caption{Q-Q Plot for exponentially distributed data.}
\label{fig:QQ_exp}
\end{subfigure}
\caption[Outputs of pareto_qq_test function.]{Outputs of \code{pareto\_qq\_test} function.}
\end{figure}
\subsection[The pareto_test function]{The \code{pareto\_test} function}
The \code{pareto\_test} function can be used to identify whether the data is Pareto distributed \citep{Gulati}. The test generates a p-value corresponding to the actual distribution of the data and is tested for significance. In the case of Pareto data, the p-value should be greater than the pre-determined significance level (generally taken as $0.05$). In addition to using the function on Pareto data, we tested the function on selected non-Pareto (generated) data sets to ensure the test would reject those as Pareto. The tests were conducted on generated data sets of various sizes. The results\footnote{In the table, half-normal distribution is taken to be the positive tail of the standard normal distribution excluding zeros.} obtained are shown in Table \ref{tab:pvalues}.
\begin{table}[!h]
\centering
\begin{tabular}{lcr}
\hline
\textbf{Distribution} & \multicolumn{1}{l}{\textbf{Sample Size}} & \multicolumn{1}{l}{\textbf{p-value}} \\
\hline
\multirow{3}{*}{Pareto (shape = 1.2, scale = 3)} & $10^{2}$ & 0.5056804 \\
& $10^{3}$ & 0.1595162 \\
& $10^{5}$ & 0.849023 \\
\hline
\multirow{3}{*}{Exponential (rate = 5)} & $10^{2}$ & $4.76\times10^{-43}$ \\
& $10^{3}$ & 0 \\
& $10^{5}$ & 0 \\
\hline
\multirow{3}{*}{Binomial (n = 20, p = 0.6)} & $10^{2}$ & $1.06\times10^{-44}$ \\
& $10^{3}$ & 0 \\
& $10^{5}$ & 0 \\
\hline
\multirow{3}{*}{Normal (mean = 5, std = 3); positive tail} & $10^{2}$ & $1.26\times10^{-104}$ \\*
& $10^{3}$ & 0 \\*
& $10^{5}$ & 0 \\
\hline
\end{tabular}
\caption{\label{tab:pvalues} Results of \code{pareto\_test} function for various sample sizes.}
\end{table}
The full call of the function is:
\begin{Code}
pareto_test(dat)
\end{Code}
Demonstration of this function is carried out using a Pareto distributed sample of size $100,000$ with $\alpha$ (shape parameter) = 1.2 and $x_{min}$ (scale parameter) = 3, and using an exponentially distributed sample of size $100,000$ with $\lambda$ (reciprocal of mean) = 5 as an example of non-Pareto data.\\
\begin{CodeChunk}
\begin{CodeInput}
R> set.seed(1234)
R> d <- generate_pareto(100000, 1.2, 3)
R> pareto_test(d)
\end{CodeInput}
\begin{CodeOutput}
$`p-value`
[1] 0.8604162
\end{CodeOutput}
\begin{CodeInput}
R> set.seed(1234)
R> exp_data <- rexp(100000, 5)
R> pareto_test(exp_data)
\end{CodeInput}
\begin{CodeOutput}
$`p-value`
[1] 0
\end{CodeOutput}
\end{CodeChunk}
\subsection[The alpha_mle function]{The \code{alpha\_mle} function}
This function can be used to estimate the shape parameter ($\alpha$) using the Maximum Likelihood Estimator method - please refer equation (\ref{eq:MLE}). It can be used to obtain biased and unbiased estimates of the shape and scale parameters as well as the confidence interval for the shape parameter for the biased estimates.
The full call of the function is:
\begin{Code}
alpha_mle(dat, biased = TRUE, significance = NULL)
\end{Code}
To demonstrate the various possibilities of this function we first generate Pareto data with $\alpha = 1.2$ and $x_{min}=3 $ and assign it to the variable \code{data}. \code{alpha\_mle} is then used to obtain:
\begin{enumerate}
\item Biased Estimates for $\alpha$ and $x_{min}$
\item Unbiased Estimates for $\alpha$ and $x_{min}$
\item Biased Estimates for $\alpha$ and $x_{min}$ and the $95\%$ confidence interval for $\alpha$
\end{enumerate}
R implementation of the above mentioned demonstration is given below.
\\\\Generating data from a Pareto Distribution:
\begin{CodeChunk}
\begin{CodeInput}
R> set.seed(1234)
R> d <- generate_pareto(100000, 1.2, 3)
\end{CodeInput}
Obtaining the biased maximum likelihood estimates for $\alpha$ and $x_{min}$:
\begin{CodeInput}
R> alpha_mle(d)
\end{CodeInput}
\begin{CodeOutput}
$shape
[1] 1.201384
$scale
[1] 3.000005
\end{CodeOutput}
Obtaining the unbiased maximum likelihood estimates for $\alpha$ and $x_{min}$:
\begin{CodeInput}
R> alpha_mle(d, FALSE)
\end{CodeInput}
\begin{CodeOutput}
$shape
[1] 1.201359
$scale
[1] 2.99998
\end{CodeOutput}
Obtaining the biased maximum likelihood estimator for $\alpha$ and $x_{min}$ and the corresponding $95\%$ confidence interval for $\alpha$:
\begin{CodeInput}
R> alpha_mle(d, TRUE, 0.05)
\end{CodeInput}
\begin{CodeOutput}
$shape
[1] 1.201384
$lower_bound
[1] 1.193937
$upper_bound
[1] 1.20883
$scale
[1] 3.000005
\end{CodeOutput}
\end{CodeChunk}
\subsection[The alpha_hills function]{The \code{alpha\_hills} function}
The Hill's Estimator - please refer equation (\ref{eq:Hill}) - is particularly useful in the fact that it allows the specification of \code{k} as either the number of observations to be included in the tail (where \code{value = FALSE}) or the minimum value to be considered in the tail of the distribution (where \code{value = TRUE}). When \code{k}=\code{n}, the Hill's Estimator returns the same estimate as \code{alpha_mle} with a warning notifying the user.
The full call of the function is:
\begin{Code}
alpha_hills(dat, k, value = FALSE)
\end{Code}
We demonstrate the usage of the Hill's Estimator by generating Pareto data with $\alpha$=1.2 and $x_{min}$=3, assigning it to the variable \code{data} and then using \code{alpha_hills}
R implementation of the above mentioned demonstration is given below with the respective outputs:
\begin{CodeChunk}
\begin{CodeInput}
R> set.seed(1234)
R> d <- generate_pareto(100000, 1.2, 3)
R> alpha_hills(d, 8000, FALSE)
\end{CodeInput}
\begin{CodeOutput}
$shape
[1] 1.198717
$scale
[1] 24.54499
\end{CodeOutput}
\begin{CodeInput}
R> alpha_hills(d, 5000, TRUE)
\end{CodeInput}
\begin{CodeOutput}
$shape
[1] 1.125696
$scale
[1] 5002.76
\end{CodeOutput}
\begin{CodeInput}
R> alpha_hills(d, 100000, FALSE)
\end{CodeInput}
\begin{CodeOutput}
$shape
[1] 1.201384
$scale
[1] 3.000005
Warning message:
In alpha_hills(d, 1e+05, FALSE) :
Setting k as the number of observations makes it equivalent
to the MLE (alpha_mle function).
\end{CodeOutput}
\end{CodeChunk}
\subsection[The alpha_ls function]{The \code{alpha\_ls} function}
This function can be used to estimate the shape parameter ($\alpha$) using the Least Squares Estimator method - please refer equation (\ref{eq:LS1}).
The full call of the function is:
\begin{Code}
alpha_ls(dat)
\end{Code}
We demonstrate the usage of the Least Squares Estimator by generating Pareto data with $\alpha$=1.2 and $x_{min}$=3, assigning it to the variable \code{data} and then using \code{alpha_ls}.
R implementation of the above mentioned demonstration is given below with the respective output:
\begin{CodeChunk}
\begin{CodeInput}
R> set.seed(1234)
R> d <- generate_pareto(100000, 1.2, 3)
R> alpha_ls(d)
\end{CodeInput}
\begin{CodeOutput}
$shape
[1] 1.20067
$scale
[1] 3.000005
\end{CodeOutput}
\end{CodeChunk}
\subsection[The alpha_percentile function]{The \code{alpha\_percentile} function}
This function can be used to estimate the shape parameter ($\alpha$) using the Percentile Estimator method - please refer equation (\ref{eq:PM}).
The full call of the function is:
\begin{Code}
alpha_percentile(dat)
\end{Code}
We demonstrate the usage of the Percentile Estimator by generating Pareto data with $\alpha$=1.2 and $x_{min}$=3, assigning it to the variable \code{data} and then using \code{alpha_percentile}.
R implementation of the above mentioned demonstration is given below with the respective output:
\begin{CodeChunk}
\begin{CodeInput}
R> set.seed(1234)
R> d <- generate_pareto(100000, 1.2, 3)
R> alpha_percentile(d)
\end{CodeInput}
\begin{CodeOutput}
$shape
[1] 1.20048
$scale
[1] 3.000005
\end{CodeOutput}
\end{CodeChunk}
\subsection[The alpha_modified_percentile function]{The \code{alpha\_modified\_percentile} function}
This function can be used to estimate the shape parameter ($\alpha$) using the Modified Percentile Estimator method - please refer equation (\ref{eq:MPM}).
The full call of the function is:
\begin{Code}
alpha_modified_percentile(dat)
\end{Code}
We demonstrate the usage of the Modified Percentile Estimator by generating Pareto data with $\alpha$=1.2 and $x_{min}$=3, assigning it to the variable \code{data} and then using\\ \code{alpha_modified_percentile}.
R implementation of the above mentioned demonstration is given below with the respective output:
\begin{CodeChunk}
\begin{CodeInput}
R> set.seed(1234)
R> d <- generate_pareto(100000, 1.2, 3)
R> alpha_modified_percentile(d)
\end{CodeInput}
\begin{CodeOutput}
$shape
[1] 1.196936
$scale
[1] 3.000005
\end{CodeOutput}
\end{CodeChunk}
\subsection[The alpha_geometric_percentile function]{The \code{alpha\_geometric\_percentile} function}
This function can be used to estimate the shape parameter ($\alpha$) using the Geometric Percentile Estimator method - please refer equation (\ref{eq:GMPM}).
The full call of the function is:
\begin{Code}
alpha_geometric_percentile(dat)
\end{Code}
We demonstrate the usage of the Geometric Percentile Estimator by generating Pareto data with $\alpha$=1.2 and $x_{min}$=3, assigning it to the variable \code{data} and then using\\ \code{alpha_geometric_percentile}.
R implementation of the above mentioned demonstration is given below with the respective output:
\begin{CodeChunk}
\begin{CodeInput}
R> set.seed(1234)
R> d <- generate_pareto(100000, 1.2, 3)
R> alpha_geometric_percentile(d)
\end{CodeInput}
\begin{CodeOutput}
$shape
[1] 1.195801
$scale
[1] 3.000005
\end{CodeOutput}
\end{CodeChunk}
\subsection[The alpha_wls function]{The \code{alpha\_wls} function}
This function can be used to estimate the shape parameter ($\alpha$) using the Weighted Least Squares Estimator method - please refer to equations (\ref{eq:WLS1}) and (\ref{eq:WLS2}).
The full call of the function is:
\begin{Code}
alpha_wls(dat)
\end{Code}
We demonstrate the usage of the Weighted Least Squares Estimator by generating Pareto data with $\alpha$=1.2 and $x_{min}$=3, assigning it to the variable \code{data} and then using \code{alpha_wls}.
R implementation of the above mentioned demonstration is given below with the respective output:
\begin{CodeChunk}
\begin{CodeInput}
R> set.seed(1234)
R> d <- generate_pareto(100000, 1.2, 3)
R> alpha_wls(d)
\end{CodeInput}
\begin{CodeOutput}
$shape
[1] 1.201303
$scale
[1] 3.000005
\end{CodeOutput}
\end{CodeChunk}
\subsection[The alpha_moment function]{The \code{alpha\_moment} function}
This function can be used to estimate the shape parameter ($\alpha$) using the Moment Estimator method - please refer equation (\ref{eq:MoM}).
The full call of the function is:
\begin{Code}
alpha_moment(dat)
\end{Code}
We demonstrate the usage of the Moment Estimator by generating Pareto data with $\alpha$=1.2 and $x_{min}$=3, assigning it to the variable \code{data} and then using \code{alpha_moment}.
R implementation of the above mentioned demonstration is given below with the respective output:
\begin{CodeChunk}
\begin{CodeInput}
R> set.seed(1234)
R> d <- generate_pareto(100000, 1.2, 3)
R> alpha_moment(d)
\end{CodeInput}
\begin{CodeOutput}
$shape
[1] 1.241772
$scale
[1] 3.000005
\end{CodeOutput}
\end{CodeChunk}
\subsection[The generate_all_estimates function]{The \code{generate\_all\_estimates} function}
This function can be used to obtain estimates of the shape parameter ($\alpha$) using all estimators except the HE.
The full call of the function is:
\begin{Code}
generate_all_estimates(dat)
\end{Code}
We demonstrate the usage of the function by generating Pareto data with $\alpha$=1.2 and $x_{min}$=3, assigning it to the variable \code{data} and then using \code{generate_all_estimates}.
R implementation of the above mentioned demonstration is given below with the respective output:
\begin{CodeChunk}
\begin{CodeInput}
R> set.seed(1234)
R> d <- generate_pareto(100000, 1.2, 3)
R> generate_all_estimates(d)
\end{CodeInput}
\begin{CodeOutput}
Method.of.Estimation Shape.Parameter Scale.Parameter
1 Maximum Likelihood Estimate 1.201384 3.000005
2 Least Squares 1.200670 3.000005
3 Method of Moments 1.241772 3.000005
4 Percentiles Method 1.200480 3.000005
5 Modified Percentiles Method 1.196936 3.000005
6 Geometric Percentiles Method 1.195801 3.000005
7 Weighted Least Squares 1.201303 3.000005
\end{CodeOutput}
\end{CodeChunk}
\section{Summary and Future Work} \label{sec:summary}
\begin{leftbar}
Our \proglang{R} package \pkg{ptsuite} can be used in tail index estimation for Pareto distributed data. One may use the \code{pareto-qq-test} function as a first step to test (heuristically) if the data is Pareto. There are a number of methods which can be called on to estimate the tail index, and it is advisable to use more than one method as a comparison for the estimate.
Our main focus in developing this package was on
run-times for parameter estimation for large data samples. The estimation methods on \pkg{ptsuite} were faster than their counterpart methods in the packages \pkg{laeken} and \pkg{EnvStats}. The Pareto data generation function on \pkg{ptsuite} was also faster than that of the package \pkg{EnvStats}. All functions on \pkg{ptsuite} performed reasonably well in the speed tests, where we tested data sets with up to $10^7$ data points.
For future work we hope to add more tail estimation methods and functions found in the references to this package. In particular we hope to eventually incorporate the vast catalog of estimators in reference \cite{Hundred}.
\end{leftbar}
\section*{Computational details}
The results in this paper were obtained using
\proglang{R}~3.5.2.
and Microsoft \proglang{R}~3.5.1 \citep{micr}\footnote{Microsoft \proglang{R}
was used for the benchmark results of the speed and we note here that this version of \proglang{R} appeared to use slightly lower times in running the same tests.} with the
\pkg{ptsuite}~1.0.0 package. \proglang{R} itself
and all packages used are available from the Comprehensive
\proglang{R} Archive Network (CRAN) at
\url{https://CRAN.R-project.org/}. Microsoft \proglang{R} may be obtained from \url{https://mran.microsoft.com/open}.
RStudio V 1.1.423 \citep{rStudio} was used as the IDE for all tasks related to package development and generating results. The packages \pkg{devtools} \citep{devtools} and \pkg{roxygen2} \citep{roxygen} were used to assist in package documentation and development. The \pkg{Rcpp} package \citep{rcpp1,rcpp2,rcpp3} was used in the compilation of \proglang{C++} code used in all estimation functions of the package.
\pkg{microbenchmark} 1.4-4, \pkg{ggplot2} 3.0.0 \citep{ggplot} and \pkg{plotly} 4.8.0 were used in generating the results included in this paper.
Two computers were used in the building of this package and the generation of the results. The technical specifications of the two computers are as follows:
\begin{table}[h]
\centering
\begin{tabular}{lll}
\hline
\textbf{Specification} & \textbf{Laptop} & \textbf{Desktop} \\
\hline
\textbf{CPU} & \begin{tabular}[c]{@{}l@{}}Intel(R) Core(TM) i5-8250U~\\@ 1.60GHz, 1800 Mhz, \\4 Core(s), 8 Logical Processor(s) \end{tabular} & \begin{tabular}[c]{@{}l@{}}Intel(R) Core(TM) i7-7700~\\@ 3.60GHz, 3601 Mhz, \\4 Core(s), 8 Logical Processor(s) \end{tabular} \\
\textbf{RAM} & 8 GB & 32 GB \\
\textbf{OS} & \begin{tabular}[c]{@{}l@{}}Windows 10 Enterprise \\LTSC 10.0.17763 Build 17763\end{tabular} & \begin{tabular}[c]{@{}l@{}}Windows 10 Pro \\10.0.17763 Build 17763\end{tabular} \\\hline
\end{tabular}
\end{table}
\section*{Acknowledgments}
\begin{leftbar}
We wish to acknowledge Dr. J. Nair for helpful advice and in providing unpublished material for our research and Prof. S. Gulati for sharing knowledge on the Goodness of Fit tests. D. J. would also like to acknowledge Prof. S. Banneheka for a very useful discussion on the WLS method of estimation.
\end{leftbar}
| {'timestamp': '2020-06-19T02:10:08', 'yymm': '2006', 'arxiv_id': '2006.10308', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10308'} | arxiv |
\section{Introduction}
Fast, accurate machine translation is a fundamental goal with a wide range of applications both in research and production.
State-of-the-art neural machine translation systems generate translations \textit{autoregressively} where words are predicted one-by-one conditioned on all previous words \citep{kalchbrenner-blunsom-2013-recurrent, Sutskever2014SequenceTS, Bahdanau2014NeuralMT, gnmt, Vaswani2017AttentionIA}.
This sequential property limits parallelization, since multiple tokens in each sentence cannot be generated in parallel.
A flurry of recent work developed ways to (partially) parallelize the decoder with \textit{non-autoregressive} machine translation (NAR\xspace; \citealp{Gu2017NonAutoregressiveNM}), thereby speeding up decoding during inference.
NAR\xspace tends to suffer in translation quality because parallel decoding
assumes conditional independence between the output tokens
and prevents the model from properly capturing the highly multimodal distribution of target translations \citep{Gu2017NonAutoregressiveNM}.
Recent work proposed methods to mitigate this multimodality issue, including iterative refinement (e.g.,\ \citealp{Lee2018DeterministicNN, Ghazvininejad2019MaskPredictPD}),
and modeling with latent variables (e.g.,\ \citealp{Ma2019FlowSeqNC, Shu2019LatentVariableNN}). These approaches modify the decoder transformer to find a balance between decoding parallelism and translation quality.
In this work, however, we adopt a different speed-quality tradeoff. Recent work by \cite{kim-etal-2019-research} in autoregressive machine translation (AR\xspace) suggests that better speed-quality tradeoffs can be achieved by having different depths in the encoder and the decoder. Here, we make a formal argument in favor of \textit{deep encoder, shallow decoder} configurations and empirically demonstrate better speed-quality tradeoffs for the AR\xspace baselines.
We provide extensive speed-quality comparisons between iterative NAR\xspace models and AR\xspace models with varying numbers of encoder and decoder layers.
In particular, we use two types of speed measures for translation and discuss their relation to computational complexity.
The two measures reflect two different application scenarios: feeding one sentence at a time, and feeding as many words as possible into the GPU memory.
The first scenario is designed to simulate, for example, instantaneous machine translation that translates text (or even speech) input from users.
This is where current NAR\xspace models shine---we can make full use of parallelism across decoding positions in a GPU. %
For this reason, much prior work in NAR\xspace only measures speed using this metric (e.g., \citealp{Gu2017NonAutoregressiveNM, Gu2019LevenshteinT, Kasai2020ParallelMT, Li2020LAVANA}).
The second scenario aims at a situation where we want to translate a large amount of text as quickly as possible.
In this case, we see that AR\xspace models run faster than NAR\xspace models by a large margin.
Computation at each time step is large enough to exploit parallelism in a GPU, which cancels out the benefit from parallel NAR\xspace decoding.
Further, AR\xspace models can cache all previous hidden states \citep{ott-etal-2019-fairseq} and compute each step in linear time complexity with respect to the sequence length. %
In contrast, NAR\xspace models necessitate a fresh run of quadratic self and cross attention in every decoding iteration.
Interestingly, using a deep encoder and a shallow decoder in NAR\xspace models fails to retain the original translation accuracy by using 6 layers each (\S\ref{sec:results-deep-shallow}).
This suggests that departure from AR\xspace decoding necessitates more capacity in the decoder; the strategy is effective specifically for AR\xspace models.
In particular, our analysis demonstrates that an NAR\xspace decoder requires more layers %
to learn target word ordering (\S\ref{sec:reorder}).
In summary, our contributions are the following:
\begin{compactitem}
\item We challenge three conventional assumptions in NAR evaluation: suboptimal layer allocation, lack of distillation for AR baselines, and insufficiently general speed measures.
\item We provide a complexity analysis and identify an optimal layer allocation strategy that leads to better speed-quality tradeoffs, namely a \textit{deep-shallow} configuration.
\item We perform extensive analyses and head-to-head comparisons of AR and strong NAR models on seven standard translation directions. We demonstrate that the accuracy gap between the two model families is much wider than previously thought and that NAR models are unable to capture target word order well without sufficiently deep decoders.
\end{compactitem}
\section{Reevaluating Non-Autoregressive Machine Translation} %
\label{sec:drawbacks}
We critically examine in this section the evaluation practices and assumptions that are widely held in the non-autoregressive neural machine translation (NAR\xspace) literature (e.g., \citealp{Gu2017NonAutoregressiveNM, Ghazvininejad2019MaskPredictPD, Kasai2020ParallelMT}). In particular, we focus on three aspects: speed measurement (\S\ref{sec:sminsmax}), layer allocation (\S\ref{sec:layer_allocation}), and knowledge distillation (\S\ref{sec:distillation}).
\subsection{Speed Measures} %
One major benefit of NAR models over AR ones is their ability to generate text in parallel.
Current research on measuring speed has focused solely on the setting of translating one sentence at a time where full parallelization is trivial with a single GPU.
However, we argue that this speed measure is not realistic in some scenarios because the GPU memory is finite and the GPU unit in such a setting is underused.
\label{sec:sminsmax}
To address this issue, we use two translation speed metrics to measure inference speed:
\begin{compactitem}
\item \textbf{\text{$\text{S}_{\text{1}}$}\xspace} measures speed when translating one sentence at a time. This metric is used in standard practice and aligns with applications like instantaneous machine translation that translates text input from users immediately.
\item \textbf{\text{$\text{S}_{\text{max}}$}\xspace} measures speed when translating in mini-batches as large as the hardware allows.
This corresponds to scenarios where one wants to translate a large amount of text given in advance.
For instance, such large-batch machine translation is implemented in the Google cloud service.\footnote{\url{https://cloud.google.com/translate/docs/advanced/batch-translation}.}
\end{compactitem}
For all models, both metrics measure wall-clock time from when the weights are loaded until the last sentence is translated.
We report speedups relative to an AR\xspace baseline with a 6-layer encoder and a 6-layer decoder following prior work \citep{Gu2017NonAutoregressiveNM, Li2020LAVANA, Kasai2020ParallelMT}.
\subsection{Layer Allocation}
\label{sec:layer_allocation}
Current evaluation practice in the NAR\xspace literature uses an equal number of layers for the encoder and decoder both in AR\xspace baselines and NAR\xspace models.
However, previous studies in AR\xspace machine translation suggest that this allocation strategy leads to a suboptimal speed-quality tradeoff \citep{Barone2017DeepAF,kim-etal-2019-research}. These findings have several implications for evaluating NAR\xspace methods. We first discuss the strategy of \textit{deep encoder, shallow decoder} (\S \ref{sec:deepshallow}), and provide a theoretical analysis of the speed-quality tradeoff in the context of NAR\xspace evaluation (\S \ref{sec:asymptotic}). Our analyses are verified empirically in the next section (\S \ref{experiments}).
\subsubsection{Deep Encoder, Shallow Decoder}
\label{sec:deepshallow}
In line with prior work on deep encoders or shallow decoders \citep{Barone2017DeepAF,Wang2019LearningDT,kim-etal-2019-research}, we depart from the convention to allocate an equal number of layers on both sides and explore pairing
a deep encoder with
a shallow decoder for both AR\xspace and NAR\xspace methods. %
Here, we study the impact of such architectures and systematically compare AR\xspace and NAR\xspace methods.\footnote{Note that \cite{kim-etal-2019-research} proposed other methods to optimize CPU decoding of AR\xspace models, but we do not apply them, to ensure fair comparisons between AR\xspace and NAR\xspace models.}
As we will show in \S\ref{experiments}, an AR\xspace model with a \textit{deep-shallow} configuration retains translation accuracy, but can substantially reduce decoding time.
This is because at inference time, the encoder accounts for a smaller part of the overhead since its computation can be easily parallelized over source positions; on the other hand, the speedup gains from a lightweight decoder are substantial. %
\begin{table}[h]
\centering
\small
\addtolength{\tabcolsep}{-3.2pt}
\begin{tabular}{@{} l @{\hspace{.0cm}} l l l l l l @{}}
\toprule[.1em]
& \multicolumn{3}{c}{\textbf{By Layer}} & \multicolumn{3}{c}{\textbf{Full Model}}\\
\cmidrule(lr){2-4}
\cmidrule(lr){5-7}
& Enc.\ & AR\xspace Dec.\ & NAR\xspace Dec.\ & AR\xspace $E$-$D$ & AR\xspace $E$-$1$ & NAR\xspace $E$-$D$ \\
\textbf{Total Operations } & ${\mathcal{O}}(N^2) $ & ${\mathcal{O}}(N^2)$ & ${\mathcal{O}}(TN^2)$ & ${\mathcal{O}}(E N^2 +D N^2)$ & ${\mathcal{O}}(EN^2 + 1\cdot N^2)$ &${\mathcal{O}}(EN^2 +DTN^2)$ \\ %
\textbf{Time Complex.\ } & ${\mathcal{O}}(N) $ & ${\mathcal{O}}(N^2)$ & ${\mathcal{O}}(TN)$ & ${\mathcal{O}}(EN+DN^2)$& ${\mathcal{O}}(EN+N^2)$ & ${\mathcal{O}}(EN +DTN)$\\ %
\bottomrule[.1em]
\end{tabular}
\caption{Analysis of transformers. Time complex.\ indicates time complexity when full parallelization is assumed. $N$: source/target length; $E$: encoder depth; $D$: decoder depth; $T$: \# NAR\xspace iterations.}
\label{tab:complexity}
\vspace{-0.3cm}
\end{table}
\subsubsection{Complexity Analysis}
\label{sec:asymptotic}
This section analyzes the complexities of transformer-based encoders, autoregressive and non-autoregressive decoders.
We focus on two key properties: (1) the total amount of operations and (2) time complexity when full parallelization is assumed \citep{nvidia_cuda}.
\textbf{Notation} \
For simplicity let us assume the source and target text have the same length $N$.
$T$ is the number of iterations in an iterative NAR\xspace method (typically $T<N$).
Let $E$ and $D$ denote the numbers of encoder and decoder layers.
Table \ref{tab:complexity} breaks down the comparison.
AR\xspace and NAR\xspace models use the same encoder architecture.
There are several interesting distinctions between AR\xspace and NAR\xspace decoders.
First, although their total amounts of operations are both quadratic in sequence length,
an NAR\xspace decoder with $T$ decoding iterations needs $T$ times more computation.
Second, an AR\xspace decoder has time complexity quadratic in sequence length.
This contrasts with the linear time complexity of an NAR\xspace decoder, which is the powerhouse of its \text{$\text{S}_{\text{1}}$}\xspace speedup (\S \ref{sec:results-deep-shallow}).
This is because the attention computation can be readily parallelized across target positions in NAR\xspace decoders. %
By such comparisons we make the following key observations:
\begin{compactitem}
\item[(a)] For both AR\xspace and NAR\xspace models, the time complexity is dominated by decoders.
When $T<N$, an NAR\xspace model has an advantage over its AR\xspace counterpart with the same layers.
\item[(b)] Innocuous as it may seem, the constant $T$ contributes major computational cost in terms of the total operations of NAR\xspace models. Empirically, $T$ needs to be at least $4$ to perform competitively to AR\xspace models \citep{Ghazvininejad2019MaskPredictPD, Kasai2020ParallelMT}.
\end{compactitem}
(a) suggests that one can significantly speed up \text{$\text{S}_{\text{1}}$}\xspace decoding by using shallower decoders,
while increasing the encoder depth only results in a mild slowdown.
As we will show later in the experiments, AR\xspace decoders are much more robust to using fewer layers than NAR\xspace decoders.
For example, AR\xspace $E$-$1$ can decode much faster than AR\xspace $E$-$D$ and comparably to NAR\xspace $E$-$D$,
while retaining the accuracy of AR\xspace $E$-$D$.
From (b), one may expect a different trend in \text{$\text{S}_{\text{max}}$}\xspace from \text{$\text{S}_{\text{1}}$}\xspace:
in large mini-batch decoding, an AR\xspace model can make use of the GPU's compute units,
since now parallelization happens over the instances in a mini-batch.
In other words, under the \text{$\text{S}_{\text{max}}$}\xspace evaluation where the GPU is running close to its maximum flop/s,
NAR\xspace can actually be slower since it needs more operations due to its iterative decoding.
This is confirmed by our experiments (\S\ref{sec:results-deep-shallow}).
\subsection{Knowledge Distillation}
\label{sec:distillation}
Most NAR\xspace models rely on
sequence-level knowledge distillation \citep{Hinton2015DistillingTK, Kim2016SequenceLevelKD} to achieve a reasonable speed-quality tradeoff, where NAR\xspace models are trained on output translations from a (larger) AR\xspace model.
Nevertheless, standard practice in this area assumes that knowledge distillation is not required for the AR baseline. Here, we aim for fair evaluation by applying distillation to both model families; we depart from previous practice where NAR\xspace models trained \emph{with} distillation are compared with AR\xspace models trained \emph{without}~\citep{ReorderNAT, Sun2019Fast, Shu2019LatentVariableNN, UnderstandingKD, Saharia2020} with a few exceptions \citep{Ghazvininejad2019MaskPredictPD, Kasai2020ParallelMT}.
Our analysis (\S\ref{impact_of_distill}) demonstrates that AR\xspace models also benefit from knowledge distillation and that the accuracy gap between AR and NAR models is wider than previously established.
\section{Experiments}
\label{experiments}
We compare NAR\xspace and AR\xspace models with different layer allocation strategies on standard machine translation datasets of varying languages and sizes.
Our results show that deep-shallow AR\xspace models provide a better speed-quality tradeoff than NAR\xspace models.
\subsection{Baselines and Comparison}
\label{sec:baselines}
Prior work has proposed various approaches to non-autoregressive machine translation (NAR\xspace).
These methods must seek a balance between speed and quality: the more decoding parallelization is introduced into a model, the more the output quality deteriorates due to a conditional independence assumption.
Some of the existing NAR\xspace models rescore the candidates with external autoregressive models \citep{Sun2019Fast, Li2020LAVANA},
or apply reordering modules \citep{ReorderNAT}.
We mainly compare with two iterative NAR\xspace models \citep{Ghazvininejad2019MaskPredictPD, Kasai2020ParallelMT} because of their strong performance \emph{without} relying on any external system:
\begin{compactitem}
\item \textbf{CMLM} \citep{Ghazvininejad2019MaskPredictPD} predicts randomly masked target tokens
given observed ones as well as the source.
At inference time, it first predicts all target words non-autoregressively,
and then iteratively masks and predicts the words that the model is least confident about.
Following previous practice \citep{Ghazvininejad2019MaskPredictPD, Ghazvininejad2020SemiAutoregressiveTI},
we decode 5 candidate lengths in parallel (\textit{length beam}) with $T=4$ or $T=10$ iterations.
\item \textbf{DisCo} \citep{Kasai2020ParallelMT}
predicts every target token given an arbitrary subset of the rest of the target tokens.
Following \citet{Kasai2020ParallelMT}, we use their parallel easy-first inference,
and set the maximum number of iterations to 10 and the length beam size to 5.
\end{compactitem}
\textbf{Knowledge Distillation} \
We apply sequence-level knowledge distillation \citep{Hinton2015DistillingTK, Kim2016SequenceLevelKD} when training both NAR\xspace and AR\xspace models (\S\ref{sec:distillation}).
For the teacher models, we use left-to-right AR\xspace transformer models: transformer-large for EN-DE, EN-ZH, and EN-FR, and transformer-base for EN-RO \citep{Ghazvininejad2019MaskPredictPD, Kasai2020ParallelMT}.
\subsection{Experimental Setup}
\label{setup}
We experiment with 7 translation directions from four datasets of various training data sizes: WMT14 EN-DE (4.5M pairs, \citealp{wmt2014-findings}), WMT16 EN-RO (610K, \citealp{wmt2016-findings}), WMT17 EN-ZH (20M, \citealp{wmt2017-findings}), and WMT14 EN-FR (36M, EN$\rightarrow$FR only).
These datasets are all encoded into BPE subwords \citep{sennrich-etal-2016-neural}. %
We follow the preprocessing and data splits of previous work
(EN-DE: \citealp{Vaswani2017AttentionIA}; EN-RO: \citealp{Lee2018DeterministicNN}; EN-ZH: \citealp{Hassan2018AchievingHP, wu2018pay}; EN-FR: \citealp{Gehring2017ConvolutionalST}).
Following previous practice, we use SacreBLEU \citep{post-2018-call} to evaluate EN$\rightarrow$ZH performance,
and BLEU \citep{Papineni2001BleuAM} for others.\footnote{SacreBLEU hash: BLEU+case.mixed+lang.en-zh+numrefs.1+smooth.exp+test.wmt17+tok.zh+version.1.3.7.}
For all autoregressive models, we apply beam search with size 5 and length penalty 1.0.
All models are implemented using \texttt{fairseq} \citep{ott-etal-2019-fairseq}.
\text{$\text{S}_{\text{1}}$}\xspace and \text{$\text{S}_{\text{max}}$}\xspace wall-clock time speedups (\S\ref{sec:drawbacks}) are evaluated on the same single Nvidia V100 GPU with 16GB memory.
We apply half-precision training and inference \citep{micikevicius2018mixed, ott-etal-2019-fairseq}. It speeds up NAR\xspace models' \text{$\text{S}_{\text{max}}$}\xspace by 30+\%, but not \text{$\text{S}_{\text{1}}$}\xspace, in line with previous observations \citep{kim-etal-2019-research}.
\textbf{Hyperparameters} \
We follow the hyperparameters of the base sized transformer \citep{Vaswani2017AttentionIA}: 8 attention heads, 512 model dimensions, and 2,048 hidden dimensions for both the encoder and decoder.
For each model and dataset, the dropout rate is tuned from $[0.1, 0.2, 0.3]$ based on development BLEU performance.
The EN$\rightarrow$FR models are trained for 500K updates, while others for 300K \citep{Kasai2020ParallelMT}.
Dev.~BLEU is measured after each epoch, and we average the 5 best checkpoints to obtain the final model \citep{Vaswani2017AttentionIA}.
See the appendix for further details.
\section{Results and Discussion}
We provide in-depth results comparing performance and speedup across AR\xspace and NAR\xspace models.
\begin{figure*}[h]
\centering
\includegraphics[width=0.9999\textwidth]{group_en-de-ro.pdf}
\caption{BLEU and speed comparisons with varying numbers of encoder and decoder layers on the test data. 12-1 denotes 12 encoder layers and 1 decoder layer.
AR\xspace deep-shallow (12-1) finds a balanced middle ground in the tradeoff. Knowledge distillation is applied to all models (\S\ref{sec:baselines}). See Table \ref{bleu_speed_all} in Appendix for more results.}
\label{fig:group-en-de-ro}
\vspace{-0.5cm}
\end{figure*}
\subsection{Deep Encoder, Shallow Decoder}
\label{sec:results-deep-shallow}
Fig.\ \ref{fig:group-en-de-ro} shows translation speed-quality tradeoff curves of CMLM, DisCo, and AR\xspace models
on WMT14 EN-DE and WMT16 EN-RO test data.
For each model we plot the results of configurations with varying encoder and decoder depths.
For brevity, we denote by $E$-$D$ a model with an $E$-layer encoder and a $D$-layer decoder.
All speedups are measured relative to the AR\xspace 6-6 baseline (\S\ref{sec:drawbacks}).
Firstly, under the 6-6 configuration, the AR\xspace model outperforms both CMLM and DisCo by a considerable margin in BLEU,
but it achieves the slowest \text{$\text{S}_{\text{1}}$}\xspace (see Fig.~ 1A--D).
Using a single-layer decoder, AR\xspace 6-1 gains a substantial \text{$\text{S}_{\text{1}}$}\xspace speedup (2.6x for EN$\rightarrow$DE and 2.9x for RO$\rightarrow$EN),
but this comes at a cost of BLEU: 28.34 vs.\ 27.39 for EN$\rightarrow$DE, and 34.57 vs.\ 34.31 for RO$\rightarrow$EN.
AR\xspace 12-1 lands on a balanced middle ground:
it yields similar BLEU to AR\xspace 6-6, but its \text{$\text{S}_{\text{1}}$}\xspace is more than 2.5 times faster.
Notably, AR\xspace 12-1 achieves even faster \text{$\text{S}_{\text{1}}$}\xspace than that of the CMLM 6-6 model with 10 iterations.
In contrast, NAR\xspace 12-1 models generally suffer in BLEU compared to the 6-6 configuration;
e.g.,\ 26.75 (DisCo 12-1) vs.\ 27.35 (DisCo 6-6) in EN$\rightarrow$DE.
Interestingly, all NAR\xspace models achieve slower \text{$\text{S}_{\text{max}}$}\xspace than the AR\xspace 6-6 baseline (DisCo 6-6: 0.3x; CMLM 6-6 $T$=10: 0.1x in RO$\rightarrow$EN).
This is consistent with our complexity analysis in \S\ref{sec:asymptotic}, where we found that with the same layer allocation,
iterative NAR\xspace models need more total computation than the AR\xspace counterpart.
AR\xspace 12-1 still gains a considerable speedup over AR\xspace 6-6 (2.0x in RO$\rightarrow$EN).
These results suggest that current NAR\xspace models have little advantage when translating a large amount of text given in advance, and one should clarify this distinction when discussing translation speed.
See Table \ref{bleu_speed_all} in the appendix for full results from all four directions.
\begin{table*}[!htbp]
\centering
\addtolength{\tabcolsep}{-0.22pt}
\begin{tabular}{@{} l @{\hspace{-0.8cm}} cc m{0.001em} @{\hspace{1mm}} rcc rcc m{0.001em} @{\hspace{1mm}} rcc @{}}
\toprule[.1em]
\multicolumn{3}{l}{\textbf{Model}}
& &
\multicolumn{3}{c}{\textbf{WMT17 EN$\boldsymbol{\rightarrow}$ZH}} & \multicolumn{3}{c}{\textbf{WMT17 ZH$\boldsymbol{\rightarrow}$EN}} & &
\multicolumn{3}{c}{\textbf{WMT14 EN$\boldsymbol{\rightarrow}$FR}} \\
\cmidrule(lr){1-3}
\cmidrule(lr){5-7}
\cmidrule(lr){8-10}
\cmidrule(lr){12-14}
& {$\boldsymbol T$} & \textbf{$\boldsymbol{E}$-$\boldsymbol{D}$}
&&\textbf{BLEU}& $\textbf{S}_{\textbf{1}}$ & $\textbf{S}_{\textbf{max}}$
& \textbf{BLEU} & $\textbf{S}_{\textbf{1}}$ & $\textbf{S}_{\textbf{max}}$
&& \textbf{BLEU}& $\textbf{S}_{\textbf{1}}$ & $\textbf{S}_{\textbf{max}}$\\
\midrule[.1em]
CMLM
& $\phantom{0}$4 & $\phantom{0}$6-6
&& 33.58 & \textbf{3.5}$\boldsymbol{\times}$ & 0.2$\times$ & 22.56 & \textbf{3.8}$\boldsymbol{\times}$ & 0.2$\times$ & & 40.21 & \textbf{3.8}$\boldsymbol{\times}$ & 0.2$\times$\\
CMLM & 10 & $\phantom{0}$6-6
&& 34.24 & 1.5$\times$ & 0.1$\times$ & 23.76& 1.7$\times$& 0.1$\times$ && 40.55 & 1.7$\times$ & 0.1$\times$ \\
DisCo
& & $\phantom{0}$6-6
&& 34.63 & 2.5$\times$ & 0.2$\times$ & 23.83& 2.6$\times$& 0.2$\times$ && 40.60& 3.6$\times$ & 0.2$\times$ \\
AR\xspace Deep-Shallow
& & $\phantom{0}$12-1
&& 34.71 & 2.7$\times$ & \textbf{1.7}$\boldsymbol{\times}$ & \textbf{24.22} & 2.9$\times$ & \textbf{1.8}$\boldsymbol{\times}$ & & \textbf{42.04} & 2.8$\times$ & \textbf{1.9}$\boldsymbol{\times}$\\
\cdashlinelr{1-14}
AR\xspace & & $\phantom{0}$6-6
&& \textbf{35.06} & 1.0$\times$ & 1.0$\times$ & 24.19 & 1.0$\times$ & 1.0$\times$ && 41.98 & 1.0$\times$ & 1.0$\times$ \\
\midrule
Dist.\ Teacher & & $\phantom{0}$6-6
& & 35.01 & -- & -- & 24.65 & -- & -- & & 42.03 & -- & -- \\
\bottomrule[.1em]
\end{tabular}
\caption{Test BLEU and speed comparisons with varying numbers of encoder ($E$) and decoder ($D$) layers on large bitext. Best performance is bolded.}
\label{large_results}
\end{table*}
Table \ref{large_results} presents results from large bitext experiments, EN$\leftrightarrow$ZH and EN$\rightarrow$FR.
We observe similar trends:
AR\xspace deep-shallow achieves similar BLEU to AR\xspace 6-6 while boosting both \text{$\text{S}_{\text{1}}$}\xspace and \text{$\text{S}_{\text{max}}$}\xspace speed substantially.
For EN$\leftrightarrow$ZH, AR\xspace deep-shallow has a more \text{$\text{S}_{\text{1}}$}\xspace speedup than DisCo (2.7x vs.\ 2.5x in EN$\rightarrow$ZH, 2.9 vs.\ 2.6 in ZH$\rightarrow$EN).
Particularly noteworthy is its performance in EN$\rightarrow$FR:
42.04 BLEU, a 1.4 point improvement over the best NAR\xspace model.
These results illustrate that the strategy of having a deep encoder and shallow decoder remains effective in large bitext settings, when the model has to learn potentially more complex distributions from more samples.
\begin{table*}
\addtolength{\tabcolsep}{-0.4pt}
\centering
\vskip 0.1in
\begin{tabular}{@{} l crcr m{0.001em} @{\hspace{2.5mm}} crcr m{0.001em} @{\hspace{2.5mm}} crcr @{}}
\toprule[.1em]
&
\multicolumn{4}{c}{\textbf{WMT14 EN$-$DE}} &&
\multicolumn{4}{c}{\textbf{WMT16 EN$-$RO}} &&
\multicolumn{4}{c}{\textbf{WMT17 EN$-$ZH}} \\
\cmidrule(lr){2-5}
\cmidrule(lr){7-10}
\cmidrule(lr){12-15}
\textbf{Model}
& $\boldsymbol{\rightarrow}$\textbf{DE}& $\boldsymbol{T}$ & $\boldsymbol{\rightarrow}$\textbf{EN} & $\boldsymbol{T}$
&&$\boldsymbol{\rightarrow}$\textbf{RO} & $\boldsymbol{T}$ & $\boldsymbol{\rightarrow}$\textbf{EN}& $\boldsymbol{T}$
&& $\boldsymbol{\rightarrow}$\textbf{ZH}& $\boldsymbol{T}$ &$\boldsymbol{\rightarrow}$\textbf{EN} &$\boldsymbol{T}$\\
\midrule[.1em]
CMLM
& 25.9 & 4 & 29.9 & 4
&& 32.5 & 4 & 33.2 & 4
&& 32.6 & 4 & 21.9 & 4\\
& 27.0 & 10 & 31.0 & 10
&& 33.1& 10 & 33.3 & 10
&& 33.2& 10 &23.2 & 10\\
LevT
& 27.3 & $>$7 & -- & --
&& -- & -- & 33.3 & $>$7
&& -- & -- & -- & -- \\
DisCo
& 27.3 & 4.8 & 31.3 & 4.2
&& 33.2 & 3.3 & 33.2 & 3.1
&& 34.6 & 5.4 & 23.8 & 5.9\\
SMART
& 27.0 & 4 & 30.9 & 4
&& -- & -- & -- & --
&& 33.4 & 4 & 22.6 & 4\\
& 27.6 & 10 & 31.3 & 10
&& --& -- & -- & --
&& 34.1 & 10 & 23.8 & 10\\
Imputer
& 28.0 & 4 & 31.0 & 4
&& 34.3 & 4 & 34.1 & 4
&& -- & -- & -- & --\\
\ & 28.2 & 8 & 31.3 &8
&&34.4 & 8 & 34.1 & 8
&& -- & -- & -- & --\\
\midrule
AR\xspace 6-6
& \textbf{28.3} & $N$ & \textbf{31.8} & $N$
& & \textbf{34.6} & $N$ & 34.6 & $N$
&& \textbf{35.1} & $N$ & \textbf{24.2} & $N$ \\
AR\xspace 12-1
& \textbf{28.3} & $N$ & \textbf{31.8} & $N$
&& 33.8 & $N$ & \textbf{34.8} & $N$
&& 34.7 & $N$ & \textbf{24.2} & $N$ \\
\midrule
Teacher
& 28.6 & $N$ & 31.7 & $N$
& &34.6 & $N$ &34.6 & $N$
& & 35.0 & $N$ & 24.7 & $N$ \\
\bottomrule[.1em]
\end{tabular}
\caption{Test BLEU comparisons with iterative NAR\xspace methods.
$T$ indicates the average \# iterations.
CMLM: \citet{Ghazvininejad2019MaskPredictPD};
LevT: \citet{Gu2019LevenshteinT};
DisCo: \citet{Kasai2020ParallelMT};
SMART: \citet{Ghazvininejad2020SemiAutoregressiveTI};
Imputer: \citet{Saharia2020}.
Best performance is bolded.
}
\label{nat_comparison}
\vspace{-0.3cm}
\end{table*}
Lastly, Table~\ref{nat_comparison} compares AR\xspace deep-shallow to recent iteration-based NAR\xspace results.
All NAR\xspace models use the 6-6 configuration with the base size except that Imputer \citep{Saharia2020} uses 12 self-attention layers over the concatenated source and target.
Overall, our AR\xspace deep-shallow models outperform most NAR\xspace models,
with the only exception being EN$\rightarrow$RO where it underperforms Imputer
by 0.6 BLEU points.
However, each iteration takes strictly more time in the Imputer model than in CMLM or DisCo, since it requires
a fresh run of 12-layer self attention over a concatenation of input and output sequences.
As we saw in Fig.\ \ref{fig:group-en-de-ro}, AR\xspace deep-shallow yields comparable \text{$\text{S}_{\text{1}}$}\xspace to CMLM 6-6 with 4 iterations, which would be about twice as fast as Imputer with 8 iterations.
\subsection{Constrained Views}
In this section, we present two controlled experiments to compare NAR\xspace and AR\xspace models thoroughly.
\textbf{\text{$\text{S}_{\text{1}}$}\xspace Speed Constraint} \
From \S\ref{sec:results-deep-shallow} we see that compared to NAR\xspace models,
AR\xspace deep-shallow yields a better translation speed-quality balance---despite being slightly slower in \text{$\text{S}_{\text{1}}$}\xspace on some of the datasets,
it achieves better BLEU across the board.
To confirm this result, we further compare an AR\xspace deep-shallow model against two NAR\xspace models, controlling for \text{$\text{S}_{\text{1}}$}\xspace speed.
More specifically, we experiment with NAR\xspace models of varying encoder depths, and pair each with as many decoder layers as possible
until it reaches AR\xspace 12-1's \text{$\text{S}_{\text{1}}$}\xspace speed.
Fig.\ \ref{fig:latency_budget} (left) shows the results.
For CMLM $T$=4, CMLM $T$=10, and DisCo, the best configurations of 12-layer encoders were paired up with 12, 4, and 9 decoder layers, respectively.
All NAR\xspace models improve performance as the encoder becomes deeper and surpass the scores of the 6-6 baselines (shown as squares along $x=6$).
Nonetheless, there is still a large BLEU gap from AR\xspace 12-1.
This illustrates that the two NAR\xspace models are not able to match AR\xspace deep-shallow's accuracy under the same \text{$\text{S}_{\text{1}}$}\xspace speed budget.
\textbf{Layer Constraint} \
We can speed up autoregressive translation (AR\xspace) by developing a model with a deep encoder and a one-layer decoder. Here we thoroughly compare layer allocation strategies.
Shown in Fig.\ \ref{fig:latency_budget} (middle) are results of NAR\xspace and AR\xspace methods under the constraint of 12 transformer layers in total.
NAR\xspace models perform well when the decoder and encoder are balanced with slight tendency to deep encoders.
On the other hand, the AR\xspace models perform consistently well with 4 or more encoder layers.
This confirms that using deep encoders and shallow decoders is more effective in AR\xspace models than in NAR\xspace ones.
Note that the number of parameters in each layer allocation differs since a decoder layer contains 30\% more parameters than an encoder layer, due to cross attention.
\begin{figure}[h]
\vspace{-0.4cm}
\centering
\includegraphics[width=0.345\textwidth]{latency_budget.pdf}
\includegraphics[width=0.32\textwidth]{layer_budget.pdf}
\includegraphics[width=0.32\textwidth]{batch_speed.pdf}
\caption{WMT14 EN$\rightarrow$DE test results under various conditions. \textbf{Left}: varying depths of the encoder under the \text{$\text{S}_{\text{1}}$}\xspace speed constraint of \textcolor{nred}{AR\xspace 12-1} \textcolor{nred}{$\blacksquare$}. \textbf{Middle}: varying allocation of a total of 12 transformer layers over the encoder and decoder. \textbf{Right}: varying inference batch sizes.}
\label{fig:latency_budget}
\end{figure}
\section{Further Analysis}
\label{sec:further_analysis}
\textbf{Speedup and Batch Size} \
\label{speed_batch}
When decoding with large batches, NAR\xspace models can be slower than their AR\xspace counterpart (\S\ref{sec:results-deep-shallow}).
Here we further study this effect.
Fig.\ \ref{fig:latency_budget} (right) plots the relative speedups of different models' decoding with varying numbers of sentences per batch up to the hardware limit (``max,'' \S\ref{sec:sminsmax}).
The speedup by NAR\xspace models diminishes as the batch size grows: they have similar
decoding speed to AR\xspace 6-6 with batch size 50, and become slower with larger batch sizes.
In contrast, the speedup from AR\xspace deep-shallow decreases much more gradually. %
\begin{table}[h]
\centering
\addtolength{\tabcolsep}{-3pt}
\begin{tabular}{@{} l cccc @{}}
\toprule[.1em]
\textbf{Model} & \textbf{$\boldsymbol{E}$-$\boldsymbol{D}$}& \textbf{Orig.}\ & \textbf{Reorder} &$\Delta$ \\
\midrule[.1em]
CMLM, $T$ = 10 & 6-6 & 27.4& 31.7 &4.3 \\
CMLM, $T$ = 10 & 12-1 & 26.3 & 31.0 & 4.7\\
\midrule
DisCo & 6-6 & 27.4 & 31.0 & 3.6 \\
DisCo & 12-1 &26.8 & 31.6 &\textbf{4.8} \\
\midrule
AR\xspace & 6-6& \textbf{28.3} & \textbf{32.6} & 4.3 \\
AR\xspace Deep-Shallow & 12-1 & \textbf{28.3} & \textbf{32.6} & 4.3 \\
\bottomrule[.1em]
\end{tabular}
\quad \quad
\begin{tabular}{@{} l cccc @{}}
\toprule[.1em]
\textbf{Model} & \textbf{$\boldsymbol{E}$-$\boldsymbol{D}$} & \textbf{Raw}\ & \textbf{Dist.} & $\Delta$ \\
\midrule[.1em]
CMLM, $T$ = 4
& 6-6 & 22.3 & 25.9 & \textbf{3.6} \\
CMLM, $T$ = 10
& 6-6 & 24.6 & 27.0 & 2.4 \\
Imputer, $T$ = 4
& 12 &24.7 &27.9 & 3.2\\
Imputer, $T$ = 8
& 12 & 25.0&27.9 & 2.9\\
DisCo & 6-6 & 24.8 & 27.4 & 2.6\\
AR\xspace Deep-Shallow & 12-1 & 26.9 & \textbf{28.3} & 1.4 \\
\midrule
AR\xspace & 6-6& \textbf{27.4} & \textbf{28.3} & 0.9 \\
\bottomrule[.1em]
\end{tabular}
\caption{\textbf{Left}: WMT14 EN$\rightarrow$DE test results in BLEU using reordered English input. \textbf{Right}: WMT14 EN$\rightarrow$DE test results in BLEU that analyze the effects of distillation in fast translation methods. All distillation data are obtained from a transformer large. $E$: encoder depth; $D$: decoder depth; $T$: \# iterations. Imputer \citep{Saharia2020} uses 12 self-attention layers over the concatenated source and target, instead of the encoder-decoder architecture.}
\label{tab:reorder}
\vspace{-0.5cm}
\end{table}
\textbf{Decoder Depth and Reordering Words} \
\label{sec:reorder}
From earlier results we see that NAR\xspace models need deeper decoders than AR\xspace models to perform well.
We hypothesize that one reason
is that NAR\xspace decoders need to learn to adjust to diverging word order between the source and the target:
an AR\xspace decoder takes as input all preceding tokens and explicitly learns a conditional distribution,
while an NAR\xspace decoder needs to learn target word ordering from scratch.
To test this hypothesis, we conduct the following controlled experiment in EN$\rightarrow$DE translation.
We choose German because of its divergence in word order from English.
We first run the \texttt{fast\_align} tool \citep{Dyer2013ASF}\footnote{\url{https://github.com/clab/fast_align}.} on all bitext data (including the test set),
and disable the NULL word feature to ensure that every English word is aligned to exactly one German word.
We then shuffle the English words %
according to the order of their aligned German words.
When multiple English words are aligned to the same German word, we keep the original English order.
Finally, we apply the same BPE operations as the original data, and train and evaluate various models on the new reordered data.
Table \ref{tab:reorder} (left) shows the results.
AR\xspace gains the same improvement regardless of the layer configuration;
in contrast, NAR\xspace 12-1 benefits more than NAR\xspace 6-6. %
This result supports our hypothesis that word reordering is one reason why NAR\xspace models need a deeper decoder.
\textbf{Effects of Distillation} \
\label{impact_of_distill}
We applied sequence-level knowledge distillation \citep{Kim2016SequenceLevelKD} to all models.
Here we analyze its effects over the WMT14 EN$\rightarrow$DE test data (Table \ref{tab:reorder} right).
An AR\xspace transformer large model is used as the teacher model.
All models benefit from distillation as indicated by positive $\Delta$,
including the AR\xspace models.\footnote{While the same distillation data are used in \citet{Ghazvininejad2019MaskPredictPD}, they report a smaller improvement from distillation in BLEU. There are several potential reasons: we tuned the dropout rate for each model on the validation data and averaged the checkpoints that achieved the top 5 BLEU scores (\S\ref{setup}). We note that our results are in line with the previous observations \citep{kim-etal-2019-research, UnderstandingKD, Kasai2020ParallelMT} where a similar improvement is gained by distilling an AR\xspace transformer large model to a base one.}
Many recent works only compare NAR\xspace models trained with distillation to AR\xspace models trained \emph{without}.
Our finding shows that that AR\xspace models with distillation can be an additional baseline for future NAR\xspace research.
AR\xspace deep-shallow deteriorates much less on the raw data compared to the iterative NAR\xspace methods, suggesting that the strategy of speeding up AR\xspace models is better suited to modeling raw, complex data than the NAR\xspace methods.
\begin{figure*}[h]
\centering
\includegraphics[width=0.9\textwidth]{group_length_bleu.pdf}
\caption{Test BLEU and target length comparisons for the AR\xspace 6-6 and deep-shallow 12-1 models.}
\label{fig:group-length}
\vspace{-0.3cm}
\end{figure*}
\textbf{Breakdown by Sentence Length}
Fig.\ \ref{fig:group-length} illustrates the relation between BLEU scores and reference translation lengths.
We observe almost identical patterns between AR\xspace 6-6 and deep-shallow models, suggesting that they perform similarly regardless of the translation length.
\textbf{Can we reduce the decoder further?} \
We saw that an autoregressive model with a single-layer decoder and a sufficiently deep encoder can retain the accuracy of the baseline with 6 layers each.
One may ask whether we can make the decoder even more compact.
Our preliminary experiments showed that we can remove the feed-forward module from the decoder without hurting performance.
This increases the \text{$\text{S}_{\text{1}}$}\xspace speed by 10\%.
We leave further exploration to future work.
\textbf{Length Candidates and \text{$\text{S}_{\text{max}}$}\xspace for NAR\xspace}
Following the original works \citep{Ghazvininejad2019MaskPredictPD, Kasai2020ParallelMT}, we fixed the number of length candidates (i.e., the length beam size) to 5 for all NAR\xspace models, but a smaller beam size can speed up \text{$\text{S}_{\text{max}}$}\xspace by allowing more sentences to be fed in a batch.
Indeed, we found that NAR models can improve their \text{$\text{S}_{\text{max}}$}\xspace by reducing the beam size at the expense of some accuracy drop. For example, we observed a loss of 0.5 BLEU points in EN$\rightarrow$DE when decreasing the length beam size from 5 to 1.
Nonetheless, NAR\xspace 6-6 models with beam size 1 still resulted in 0.6--0.9x \text{$\text{S}_{\text{max}}$}\xspace compared to the AR 6-6 baseline.
\section{Further Related Work}
\label{related_work}
\textbf{Non-autoregressive Machine Translation} \
In addition to the work already discussed, several other works proposed to iteratively refine (or insert) output predictions \citep{Mansimov2019AGF, Stern2019InsertionTF, Gu2019InsertionbasedDW, Chan2019KERMITGI, Chan2019AnES, Li2020LAVANA, guo-etal-2020-jointly}.
Other approaches include adding a light autoregressive module to parallel decoding \citep{Kaiser2018FastDI,Sun2019Fast,ReorderNAT}, partially decoding autoregressively \citep{Stern2018BlockwisePD,Stern2019InsertionTF}, rescoring output candidates autoregressively (e.g.,\ \citealp{Gu2017NonAutoregressiveNM}), mimicking hidden states of an autoregressive teacher \citep{Li2019HintBasedTF}, training with different objectives than vanilla cross-entropy \citep{Libovick2018EndtoEndNN,Wang2019NonAutoregressiveMT,minBOW, Tu2020ENGINEEI, Saharia2020, Ghazvininejad2020AlignedCE}, reordering input sentences \citep{ReorderNAT}, training on additional data from an autoregressive model \citep{Zhou2020ImprovingNN}, and modeling with latent variables \citep{Ma2019FlowSeqNC, Shu2019LatentVariableNN}.
The approach of adding a light autoregressive module is closest to our method, but note that we pack all \textit{non-autoregressive} computation into the encoder. %
\textbf{Optimizing Autoregressive Transformer} \
Prior work has suggested various ways to optimize autoregressive transformers for fast inference.
For example, \citet{kim-etal-2019-research} considered shallow decoders and layer tying \citep{Dabre2019RecurrentSO, Dehghani2019UniversalT} on the transformer decoder and found that it sped up inference on CPUs, but not on a GPU, which was our focus.
\citet{kim-etal-2019-research} also explored concurrent streams where multiple batches are fed at once to make better use of a GPU.
\citet{Shi2017SpeedingUN} proposed a vocabulary reduction method to speed up the last softmax computation.
\citet{senellart-etal-2018-opennmt} also adopted vocabulary reduction and explored ``fat decoder, thin encoder" on RNN-based models.
\citet{Zhang2018AcceleratingNT} used dynamic programming in an average attention network to accelerate inference.
\citet{wu2018pay} developed a model with dynamic convolutions and compared its speed and accuracy with non-autoregressive models.
Other works proposed methods to reduce attention computation in autoregressive transformers \citep{Kitaev2020ReformerTE, katharopoulos-et-al-2020, chelba2020faster, RFA}.
Some of these methods can be used orthogonally to further facilitate fast inference in a transformer, but our goal is to fairly reexamine the speed-quality tradeoff between autoregressive and non-autoregressive approaches under the same conditions.
\section{Conclusion and Future Work}
We presented theoretical and empirical studies to demonstrate that autoregressive neural machine translation can be dramatically sped up by a simple layer allocation strategy: deep encoder, shallow decoder.
Compared to strong non-autoregressive models,
deep-shallow autoregressive models achieve substantial improvement in translation quality with comparable inference speed.
Our results suggest that layer allocation, knowledge distillation, and speed measurement are important aspects that future work on non-autoregressive machine translation should take into consideration.
More generally, a model with a deep encoder and a shallow decoder can be used for any sequence-to-sequence task, including large-scale pretraining \citep{Lewis2019BARTDS, MBART}. %
\section*{Acknowledgments}
We thank Luke Zettlemoyer, Marcin Junczys-Dowmunt, Ofir Press, and Tim Dettmers as well as the anonymous reviewers for their helpful feedback and discussions on this work.
This research was in part funded by the Funai Overseas Scholarship to Jungo Kasai.
Nikolaos Pappas was supported by the Swiss National Science Foundation under the project UNISON, grant number P400P2\_183911.
| {'timestamp': '2021-06-28T02:05:44', 'yymm': '2006', 'arxiv_id': '2006.10369', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10369'} | arxiv |
\section{%
\def\emph{e.g}} \def\Eg{\emph{E.g}{\emph{e.g}} \def\Eg{\emph{E.g}}
\def\emph{i.e.}} \def\Ie{\emph{I.e}{\emph{i.e.}} \def\Ie{\emph{I.e}}
\def\emph{c.f.}} \def\Cf{\emph{C.f}{\emph{c.f.}} \def\Cf{\emph{C.f}}
\def\emph{etc.}} \def\vs{\emph{vs}{\emph{etc.}} \def\vs{\emph{vs}}
\defw.r.t.} \def\dof{d.o.f.{w.r.t.} \def\dof{d.o.f.}
\def\emph{et al}\onedot{\emph{et al}\onedot}
\newcommand{state-of-the-art\xspace}{state-of-the-art\xspace}
\newcommand{HyNet\xspace}{HyNet\xspace}
\newcommand{L\textsubscript{2}\xspace}{L\textsubscript{2}\xspace}
\newcommand{HyNet}{HyNet}
\def\yurun#1{{\color{blue}{\bf [Yurun:} {\it{#1}}{\bf ]}}}
\def\axel#1{{\color{OliveGreen}{\bf [Axel:} {\it{#1}}{\bf ]}}}
\def\tony#1{{\color{magenta}{\bf [Tony:} {\it{#1}}{\bf ]}}}
\def\km#1{{\color{red}{\bf [KM:} {\it{#1}}{\bf ]}}}
\def\vb#1{{\color{green}{\bf [VB:} {\it{#1}}{\bf ]}}}
\title{HyNet: Learning Local Descriptor with Hybrid Similarity Measure and Triplet Loss}
\author{
Yurun Tian$^{1}$\hspace{10pt}
Axel Barroso-Laguna$^{1}$\hspace{10pt}
Tony Ng$^{1}$\hspace{10pt}
Vassileios Balntas$^{2}$\hspace{10pt}
\\
{\bf Krystian Mikolajczyk}$^{1}$
\vspace{10pt}\\
$^1$ Imperial College London\\
$^2$ Facebook Reality Labs\\
\texttt{\{yurun.tian,axel.barroso17,tony.ng14,k.mikolajczyk\}@imperial.ac.uk}\\
\texttt{[email protected]}}
\begin{document}
\maketitle
\begin{abstract}
Recent works show that local descriptor learning benefits from the use of L\textsubscript{2}\xspace normalisation, however, an in-depth analysis of this effect lacks in the literature.
In this paper, we investigate how L\textsubscript{2}\xspace normalisation affects the back-propagated descriptor gradients during training.
Based on our observations, we propose HyNet\xspace, a new local descriptor that leads to state-of-the-art results in matching.
HyNet\xspace introduces a hybrid similarity measure for triplet margin loss, a regularisation term constraining the descriptor norm, and a new network architecture that performs L\textsubscript{2}\xspace normalisation of all intermediate feature maps and the output descriptors. HyNet\xspace surpasses previous methods by a significant margin on standard benchmarks that include patch matching, verification, and retrieval, as well as outperforming full end-to-end methods on 3D reconstruction tasks.
Codes and models are available at \url{https://github.com/yuruntian/HyNet}.
\end{abstract}
\input{Sections/1_Introduction}
\input{Sections/3_Gradient_Analysis}
\input{Sections/4_Method}
\input{Sections/5_Experiment}
\input{Sections/6_Discussion}
\input{Sections/7_Conclusion}
\input{Sections/8_Supp}
\section*{Broader Impact}
Local feature descriptors and gradient based optimization are crucial components in a wide range of technologies such as stereo vision, AR, 3D reconstructions, SLAM, among others.
As such, the proposed approach improves the quality of results within these technologies, which are typically used in various applications including smartphone apps for image processing, driver-less cars, robotics, AR headsets.
Its societal impact potential is within these applications, in particular the reliability of the technologies behind, which our approach contributes to.
Similarly, any ethical issues are also associated with the applications as our approach cannot be used independently of a larger system.
\begin{ack}
This research was supported by UK EPSRC IPALM project EP/S032398/1.
\end{ack}
\bibliographystyle{plain}
\section{Experiment}
\label{sec:experiment}
Our novel architecture and training is implemented in PyTorch~\cite{pytorch2017}.
The network is trained for 200 epochs with a batch size of 1024 and Adam optimizer~\cite{adam2014}.
Training starts from scratch, and the threshold $\tau$ in TLU for each layer is initialised with $-1$.
We set $\alpha=2$ and $\gamma=0.1$.
In the following experiments, HyNet\xspace is compared with recent deep local descriptors~\cite{tfeat2016,l2net2017,hardnet2017,sosnet2019} as well as end-to-end methods~\cite{superpoint2018,d2net2019,r2d22019} on three standard benchmarks~\cite{ubc2011,hpatches2017,eth_benchmark2017}.
\subsection{UBC verification}
\label{subsec:ubc}
UBC dataset~\cite{ubc2011} consists of three subset-scenes, namely {\em Liberty}, {\em Notredame} and {\em Yosemite}. The benchmark is focused on the patch pair verification task, \emph{i.e.}} \def\Ie{\emph{I.e}, whether the match is positive or negative.
Following the evaluation protocol~\cite{ubc2011}, models are trained on one subset and tested on the other two.
In Table~\ref{tab:UBC_performance}, we report the standard measure of false positive rate at 95\% recall~(FPR@95)~\cite{ubc2011} on six train and test splits.
We can observe that, while the performance is nearly saturated, HyNet\xspace still shows remarkable improvements over previous methods.
\input{Tables/ubc}
\subsection{HPatches matching}
\label{subsec:hp}
HPatches dataset~\cite{hpatches2017} evaluates three tasks, patch verification, patch retrieval, and image matching for viewpoint and illumination changes between local patches.
Based on different levels of geometric noise, the results are divided into 3 groups: {\em easy}, {\em hard}, and {\em tough}.
\begin{figure*}[ht]
\centering
\includegraphics[trim={0.2cm 1.5cm 0.2cm 1.9cm}, clip, width=\linewidth]{Figures/hpatches_results.pdf}
\caption{
Results on test set `a' of HPatches~\cite{hpatches2017}.
HyNet\xspace outperforms the state-of-the-art\xspace SOSNet \cite{sosnet2019} and other local image descriptors in all metrics on this benchmark.}
\label{fig:hpatehes_results}
\vspace{-10pt}
\end{figure*}
We show the results in Fig.~\ref{fig:hpatehes_results}, where all models are trained on {\em Liberty}, which is the protocol proposed in~\cite{hpatches2017}.
HyNet\xspace improves the MAP from the previous state-of-the-art\xspace SOSNet~\cite{sosnet2019} by a large margin, \emph{i.e.}} \def\Ie{\emph{I.e}, {\bf 0.89}, {\bf 2.35}, and {\bf1.75} for the three tasks. Note that the improvement of SOSNet over its predecessor HardNet~\cite{hardnet2017} was 0.03, 0.96, and 1.14 at the time of its publication.
\subsection{ETH Structure from Motion}
\label{subsec:eth}
\input{Tables/eth}
ETH SfM benchmark~\cite{eth_benchmark2017} evaluates local descriptors in the task of Structure from Motion~(SfM) for outdoor scenes.
To quantify the SfM quality, in Table~\ref{tab:eth_results}, we follow the protocol from~\cite{eth_benchmark2017} and report the number of registered images, reconstructed sparse and dense points, mean track length, and mean reprojection error.
First, we compare HyNet\xspace with HardNet~\cite{hardnet2017} and SOSNet~\cite{sosnet2019} by using the same local patches extracted from DoG detector, which is presented above the dashed lines.
Since the detector is fixed, the results reflect the performance of the descriptors.
To ensure a fair comparison, HardNet, SOSNet, and HyNet\xspace are all trained on {\em Liberty} from UBC dataset~\cite{ubc2011}.
In this benchmark, HyNet\xspace exhibits significant superiority by registering more images for large scenes and reconstructing more spare points, while the results for the other metrics are on par with top performing descriptors.
Next, we compare HyNet\xspace to the recent end-to-end methods, namely SuperPoint~\cite{superpoint2018}, D2-Net~\cite{d2net2019} and R2D2~\cite{r2d22019}.
DoG+HyNet\xspace shows significantly better performance on larger scenes, for example, {\em Madrid Metropolis} and {\em Gendarmenmarkt}, where it gives over 50\% more of reconstructed sparse points in 3D. Note that in the SfM task, the number of registered images and reconstructed points is crucial for the quality of 3D models.
Moreover, results also show that HyNet\xspace generalises well to different patches provided by the state-of-the-art\xspace detector Key.Net~\cite{keynet2019}, where the average track length is increased
for a number of scenes.
\section{Gradient Analysis}
\label{sec:gradient_analysis}
In this section, we explore how the widely used
inner product and L\textsubscript{2}\xspace distance provide gradients for training normalised and unnormalised descriptors.
\subsection{Preliminaries}
\label{subsec:preliminary}
We denote $\mathcal{L}(\psi(\mathbf{x}, \mathbf{y}))$ as the loss for a descriptor pair $(\mathbf{x}, \mathbf{y})$, where $\psi(\cdot, \cdot)$ can be a similarity measure or a distance metric.
To ensure consistency in the following of the paper, we refer to distance metric also as a similarity measure even though it measures the inverse similarity.
Whether $(\mathbf{x}, \mathbf{y})$
are positive (matching) or negative (non-matching),
the gradients with respect to the descriptors are calculated as:
\begin{equation}
\label{eq:desc_grad}
\frac{\partial \mathcal{L}}{\partial \mathbf{x}}=\frac{\partial \mathcal{L}}{\partial \psi}\frac{\partial \psi}{\partial \mathbf{x}},~~~
\frac{\partial \mathcal{L}}{\partial \mathbf{y}}=\frac{\partial \mathcal{L}}{\partial \psi}\frac{\partial \psi}{\partial \mathbf{y}},
\end{equation}
where $(\mathbf{x}, \mathbf{y})$ are omitted for clarity.
Importantly, the gradients for learnable weights of a network are derived in Eqn.\eqref{eq:desc_grad} at the beginning of the chain, and play a key role during training.
Note that $\frac{\partial \mathcal{L}}{\partial \psi}$ is a scalar,
while the direction of the gradient is determined by the partial derivatives of $\psi$.
We consider the most commonly used inner product and L\textsubscript{2}\xspace distance, for descriptors with and without L\textsubscript{2}\xspace normalisation:
\begin{equation}\label{eq:3}
\begin{gathered}
\bar{s} = \mathbf{x}^{\text{T}} \mathbf{y},
~~~s = \frac{\mathbf{x}^{\text{T}} \mathbf{y}}{\|\mathbf{x}\|\|\mathbf{y}\|},~~~
\bar{d} = \|\mathbf{x}-\mathbf{y}\|,
~~~d = \|\frac{\mathbf{x}}{\|\mathbf{x}\|}-\frac{\mathbf{y}}{\|\mathbf{y}\|}\|,
\end{gathered}
\end{equation}
where $\| \cdot \|$ denotes the L\textsubscript{2}\xspace norm~($\|\mathbf{x}\|=\sqrt{\sum\mathbf{x}^{2}_{i}}$).
$\bar{s}$ and $\bar{d}$ are inner product and L\textsubscript{2}\xspace distance for raw descriptors while $s$ and $d$ are for normalised ones.
Note that we consider L\textsubscript{2}\xspace normalisation as a part of the similarity measure.
We then obtain the partial derivatives:
\begin{equation}\label{eq:grad}
\begin{gathered}
\frac{\partial \bar{s}}{\partial \mathbf{x}} = \mathbf{y},~~~
\frac{\partial \bar{s}}{\partial \mathbf{y}} = \mathbf{x},~~~
\frac{\partial \bar{d}}{\partial \mathbf{x}} = \frac{1}{\bar{d}}(\mathbf{x} - \mathbf{y}),~~~
\frac{\partial \bar{d}}{\partial \mathbf{y}} = \frac{1}{\bar{d}}(\mathbf{y} - \mathbf{x}),
\\
\frac{\partial s}{\partial \mathbf{x}} = \frac{1}{\|\mathbf{x}\|\|\mathbf{y}\|}(\mathbf{y}-\frac{\mathbf{x}^{\text{T}} \mathbf{y}}{\|\mathbf{x}\|^{2}}\mathbf{x}),~~
\frac{\partial s}{\partial \mathbf{y}} = \frac{1}{\|\mathbf{x}\|\|\mathbf{y}\|}(\mathbf{x}-\frac{\mathbf{x}^{\text{T}} \mathbf{y}}{\|\mathbf{y}\|^{2}}\mathbf{y}),\\
\frac{\partial d}{\partial \mathbf{x}} = \frac{1}{d\|\mathbf{x}\|\|\mathbf{y}\|}(\frac{\mathbf{x}^{\text{T}}\mathbf{y}}{\|\mathbf{x}\|^{2}}\mathbf{x}-\mathbf{y}),~~
\frac{\partial d}{\partial \mathbf{y}} = \frac{1}{d\|\mathbf{x}\|\|\mathbf{y}\|}(\frac{\mathbf{x}^{\text{T}} \mathbf{y}}{\|\mathbf{y}\|^{2}}\mathbf{y}-\mathbf{x}).
\end{gathered}
\end{equation}
In the following sections we analyse the above gradients in terms of directions and magnitudes.
\subsection{Gradient Direction}
\label{subsec:gradient_direction}
\begin{figure}[t!]
\centering
\hspace{-10pt}
\begin{subfigure}[b]{0.250\textwidth}
\includegraphics[width=\textwidth]{Figures/s_1.pdf}
\caption{$\bar{s}$}
\label{fig:grad_a}
\end{subfigure}
\begin{subfigure}[b]{0.230\textwidth}
\includegraphics[clip, width=\textwidth]{Figures/s_2.pdf}
\caption{$\bar{d}$}
\label{fig:grad_b}
\end{subfigure}
\begin{subfigure}[b]{0.233\textwidth}
\includegraphics[clip,width=\textwidth]{Figures/s_3.pdf}
\caption{$s$}
\label{fig:grad_c}
\end{subfigure}
\begin{subfigure}[b]{0.210\textwidth}
\includegraphics[clip,width=\textwidth]{Figures/s_4.pdf}
\caption{$d$}
\label{fig:grad_d}
\end{subfigure}
\caption{Gradient descent directions derived in Eqn.~\ref{eq:grad}, with $+$ and $-$ for positive and negative pairs. $\theta$ is the angle between the descriptors. {\bf Black} arrows: descriptors before L\textsubscript{2}\xspace normalisation. {\bf\textcolor{red}{Red}} arrow: gradient descent direction from $\mathbf{\Delta}$. {\bf\textcolor{ao}{Green}} arrow: parallel component from $\mathbf{\Delta}_{\parallel}$. \textcolor{Blue}{Blue} arrows: orthogonal component from $\mathbf{\Delta}_{\perp}$.
Better viewed in colour.}
\label{fig:grad}
\vspace{-10pt}
\end{figure}
Optimal gradient direction is the key for convergence, \emph{i.e.}} \def\Ie{\emph{I.e}, a learning process will not converge given incorrectly directed gradients, regardless of the learning rate.
We denote $\mathbf{\Delta}=\mathbf{\Delta}_{\parallel}+\mathbf{\Delta}_{\perp}$, where $\mathbf{\Delta}$ is the overall gradient direction, $\mathbf{\Delta}_{\parallel}$ and $\mathbf{\Delta}_{\perp}$ are the parallel and orthogonal components respectively.
According to Eqn.~\eqref{eq:grad}, we obtain $|\mathbf{\Delta}_{\parallel}|=\mathbf{x}^{\text{T}}\frac{\partial \bar{s}}{\partial \mathbf{x}}=0$, and similarly for $\mathbf{y}^{\text{T}}\frac{\partial \bar{s}}{\partial \mathbf{y}}=0$, $\mathbf{x}^{\text{T}}\frac{\partial \bar{d}}{\partial \mathbf{x}}=0$, and $\mathbf{y}^{\text{T}}\frac{\partial \bar{d}}{\partial \mathbf{y}}=0$, \emph{i.e.}} \def\Ie{\emph{I.e}, gradients are always orthogonal to the descriptors, indicating that L\textsubscript{2}\xspace normalised descriptors only have $\mathbf{\Delta}_{\perp}$.
Meanwhile, both components of unnormalised descriptors are non-zero.
For better understanding, we illustrate 2D descriptors and the corresponding gradient descent directions~(negative gradient direction) in Fig.~\ref{fig:grad}, where $\theta$ is the angle between descriptors.
Specifically, $\mathbf{\Delta}_{\parallel}$ modifies the descriptor magnitude~(L\textsubscript{2}\xspace norms), while $\mathbf{\Delta}_{\perp}$ updates the descriptor direction.
However, since descriptor magnitudes can be harmful for matching~(see Sec.~\ref{sec:introduction}), the training should focus on the optimisation of the descriptor directions, which can be achieved with L\textsubscript{2}\xspace normalised descriptors.
An interesting question is whether it is possible to make a better use of $\mathbf{\Delta}_{\parallel}$.
We address this problem in Sec.~\ref{subsec:l2_norm_regularisation} and show that detailed analysis leads to a training constraint that improve the performance.
\subsection{Gradient Magnitude}
\label{subsec:gradient_magnitude}
The training gradients should have not only the optimal directions but also the properly scaled magnitudes.
The magnitude should be adapted to the level of `hardness' of the training samples, \emph{i.e.}} \def\Ie{\emph{I.e}, hard samples should receive a stronger update over easy ones.
We focus on L\textsubscript{2}\xspace normalised descriptors whose gradients have optimal directions.
We denote $\mathbf{u}=\frac{\mathbf{x}}{\|\mathbf{x}\|}$ and $\mathbf{v}=\frac{\mathbf{y}}{\|\mathbf{y}\|}$ as two descriptors normalised with L\textsubscript{2}\xspace.
Further, $s$ and $d$ are expressed as a function of the angle between the descriptors:
\begin{equation}\label{eq:grad_mag}
\begin{gathered}
s(\theta)=\mathbf{u}^{\text{T}}\mathbf{v}=\cos\theta,~~~
g_{s}(\theta)=|s'(\theta)|= |\sin{\theta}|,
\\
d(\theta)=\|\mathbf{u}-\mathbf{v}\|=\sqrt{2(1-\cos\theta)},~~~
g_{d}(\theta)=|d'(\theta)|= |\frac{\sin{\theta}}{\sqrt{2(1-\cos{\theta})}}|,
\\
\end{gathered}
\end{equation}
where $\theta = \arccos\mathbf{u}^{\text{T}}\mathbf{v}$, $g(\theta)$ is the gradinet magnitude and $|\cdot|$ denotes absolute value operator.
We analyse the gradient magnitudes from Eqn.~\eqref{eq:grad_mag} in the real descriptor space during training. Fig.~\ref{fig:2}(a) shows the distribution of $\theta$ from 512K descriptor pairs, where the number of positive and negative pairs is 50\% each.
Following the hard negative mining strategy of~\cite{hardnet2017}, we sample 512 triplets (one positive pair and one negative) from each of the 1K randomly constructed batches of size 1024.
Fig.~\ref{fig:2}(a) shows the $\theta$ distribution of HardNet and SOSNet in training, \emph{i.e.}} \def\Ie{\emph{I.e}, both models are trained and tested on {\em Liberty}.
Note that from Eqn.~\ref{eq:grad_mag} the gradient magnitudes are periodic functions with a period of $\pi$.
As shown,
almost all hard negatives and positives have $\theta$ in the range $[0,\pi/2]$.
Therefore, we observe how $g_s$ and $g_d$ behave in range $[0,\pi/2]$, which is highlighted in Fig.~\ref{fig:2}(b).
\begin{wrapfigure}{r}{.45\textwidth}
\begin{minipage}{\linewidth}
\includegraphics[width=\linewidth]{Figures/hist_theta_train.pdf}
\vspace{-18pt}
\subcaption{Distribution of $\theta$.}
\label{fig:2a}
\includegraphics[width=\linewidth]{Figures/norm_s3_s4.pdf}
\vspace{-18pt}
\subcaption{$g_{s}(\theta)$ and $g_{d}(\theta)$}
\label{fig:2b}
\end{minipage}
\caption{Gradient magnitude and distribution of $\theta$.}
\label{fig:2}
\vspace{-10pt}
\end{wrapfigure}
The gradients differ, \emph{i.e.}} \def\Ie{\emph{I.e},
$g_s$ is monotonically increasing while $g_d$ is decreasing.
It indicates that $g_s$ is more beneficial for the optimisation of positives, since hard positives~(large $\theta\rightarrow\pi/2$), generate large gradients compared to easy positives~(small $\theta$).
In contrast, $g_d$ favours negatives, as hard negatives (small $\theta$) generate large updates compared to the easy negatives (large $\theta$).
These observations lead to the conclusion that neither the inner product nor the L\textsubscript{2}\xspace on its own can balance the optimisation with positives and negatives.
It is also worth noting that according to Eqn.~\eqref{eq:desc_grad}, the overall gradient magnitude is further weighted by $\frac{\partial \mathcal{L}}{\partial s}$, which means a better form of $\mathcal{L}$ may alleviate the inherent flaws of $g_s$ and $g_d$.
Consequently, in Sec.~\ref{subsec:hybrid_similarity} we show that a carefully designed similarity measure leads to the state-of-the-art performance with the standard triplet loss.
\section{Introduction}
\label{sec:introduction}
Local feature detectors and descriptors play a key role in many computer vision tasks such as 3D reconstruction\cite{colmapcvpr2016}, visual localisation\cite{sattler6dof,shi2019spatial} and image retrieval\cite{netvlad2016,gem2018,solar2020}.
Recently, joint detection and description~\cite{lift2016,lfnet2018,superpoint2018,d2net2019,r2d22019,gift2019,aslfeat2020,s2dnet2020,d2d2020,hdd2020} has drawn significant attention.
Despite the alluring idea of the end-to-end detection and description, the classic two-stage strategy withstood years of tests in many computer vision tasks and still gives a competitive performance in standard benchmarks~\cite{ubc2011,hpatches2017,eth_benchmark2017,imw2020}.
Moreover, customised matchers~\cite{learncorres2018,ncn2018,efficientncn2020,neuralransac2019,superglue2019} have also contributed to boosting the matching performance, where the time complexity is critical.
Despite the progress in end-to-end methods, the two-stage process still deserves attention since it often leads to competitive results in the overall matching system.
Deep descriptors~\cite{deepdesc2015,tfeat2016,l2net2017,hardnet2017,scaleaware2018,doap2018,sosnet2019,cdfmargin2019,yu2019unsupervised} have shown superiority over hand-crafted ones~\cite{sift2004,liop2011} in different tasks~\cite{hpatches2017,imw2020,ubc2011,eth_benchmark2017}.
Current works mainly focus on improving the loss function or the sampling strategy. L2-Net~\cite{l2net2017} introduces a progressive batch sampling with an N-Pair loss. HardNet~\cite{hardnet2017} uses a simple yet effective hard negative mining strategy, justifying the importance of the sampling.
Other than contrastive or triplet loss, DOAP~\cite{doap2018} employs a retrieval based ranking loss.
GeoDesc~\cite{geodesc2018} integrates geometry constraints from multi-view reconstructions to benefit the training.
Besides the first-order optimisation, SOSNet~\cite{sosnet2019} shows that second-order constraints further improve the descriptors.
It has been widely observed that L\textsubscript{2}\xspace normalisation of the descriptors leads to consistent improvements.
Methods such as~\cite{l2net2017,hardnet2017,doap2018,logpolar2019,sosnet2019,adasample2019,cdfmargin2019} which L\textsubscript{2}\xspace normalised descriptors, significantly outperform early unnormalised descriptors~\cite{deepdesc2015,tfeat2016}.
Moreover, even hand-crafted descriptors can be improved with L\textsubscript{2}\xspace normalisation~\cite{hpatches2017}.
All such observations indicate that descriptors are better distinguished by their vector directions rather than the magnitudes~(L\textsubscript{2}\xspace norms), where
similar conclusions can also be found in other feature embedding tasks~\cite{cosface2018,arcface2019,adaptface2019}.
We therefore analyse the impact of L\textsubscript{2}\xspace normalisation on learning from the gradients perspective.
Since the gradients for each layer are generated via the chain rule~\cite{deepleaning2016}, we analyse them at the beginning of the chain, where they are generated by the given similarity measure or distance metric.
Our intuition is that the gradient direction should benefit the optimisation of descriptor directions, while the gradient magnitude should be adaptive to the level of hardness of the training samples.
Consequently, HyNet\xspace is introduced to make better use of the gradient signals in terms of direction and magnitude.
Despite the evolving design of loss function, triplet loss is still employed in state-of-the-art\xspace local descriptors~\cite{hardnet2017,sosnet2019}.
Furthermore, triplet loss has also earned noticeable popularity in various embedding tasks, \emph{e.g}} \def\Eg{\emph{E.g}, face recognition~\cite{facenet2015,deepface2015} and person re-identification~\cite{reidtriplet2016,defensetriplet2017}.
An interesting observation in~\cite{check2020} indicates that the improvements from the classic contrastive and triplet loss are marginal.
In this work, we further show that
state-of-the-art\xspace local descriptor can be learned by triplet loss with a better designed similarity measure.
Specifically, we propose:
1) a hybrid similarity measure that can balance the gradient contributions from positive and negative samples,
2) a regularisation term which provides suitable constraints on descriptor norms,
and 3) a new network architecture that is able to L\textsubscript{2}\xspace normalise the intermediate feature maps.
\section{Related Work}
\label{related_work}
\section{Method}
\label{sec:method}
Building upon the analysis from the previous section,
we propose to improve the descriptor learning by
1) introducing a regularisation term that provides a beneficial $\mathbf{\Delta}_{\parallel}$,
2) a hybrid similarity measure that can strike a balance between the contribution of positives and negatives to the gradient update,
3) a new network architecture that normalises the intermediate feature maps mimicking the output descriptors such that they are optimised in their directions rather than the magnitudes.
\subsection{L\texorpdfstring{\textsubscript{2}}{\texttwoinferior} Norm Regularisation}
\label{subsec:l2_norm_regularisation}
Sec.~\ref{subsec:gradient_direction} shows that L\textsubscript{2}\xspace normalisation excludes parallel gradients $\mathbf{\Delta}_{\parallel}$, \emph{i.e.}} \def\Ie{\emph{I.e}, there are no constraints on the descriptor norms which can vary with scaling of image intensities.
Intuitively, a possible way of making positive contributions from $\mathbf{\Delta}_{\parallel}$ to the optimisation is to introduce the following constraint before the L\textsubscript{2}\xspace normalisation:
\begin{equation}
\label{eq:r_l2}
R_{L_2} = \frac{1}{N}\sum_{i=1}^{N}(\|\mathbf{x}_i\|- \|\mathbf{x}_{i}^{+}\|)^2,
\end{equation}
where $\mathbf{x}_i$ and $\mathbf{x}_{i}^{+}$ are a positive pair of descriptors before L\textsubscript{2}\xspace normalisation.
As a regularisation term, $R_{L_2}$ drives the network to be robust to image intensity changes, \emph{e.g}} \def\Eg{\emph{E.g}, caused by different illuminations.
\subsection{Hybrid Similarity Measure and Triplet Loss}
\label{subsec:hybrid_similarity}
Recent efforts on improving the standard triplet loss include smart sampling of triplets~\cite{hardnet2017,correctingtriplet2018} and adaptive margin~\cite{cdfdesc2019,cdfdesc2019}.
In contrast, we explore to boost the triplet loss with a hybrid similarity measure such that better gradients can be generated.
As discussed in Sec.~\ref{subsec:gradient_magnitude}, $s$ and $d$ favours the positive and negative samples respectively,
therefore we propose a hybrid similarity measure $s_\textit{H}$ that can make a balance between them:
\begin{equation}
\label{eq:triplet_loss}
\begin{gathered}
\mathcal{L}_\textit{Triplet} = \frac{1}{N}\sum_{i=1}^{N} \max(0, m + s_\textit{H}(\theta^{+}_{i}) - s_\textit{H}(\theta^{-}_{i})),\\
s_\textit{H}(\theta) = \frac{1}{Z} [\alpha(1-s(\theta)) + d(\theta)],
\end{gathered}
\end{equation}
where $\alpha$ is a scalar ranging from $0$ to $+\infty$ adjusting the ratio between $s$ and $d$, and $Z$ is the normalising factor ensuring the gradient has the maximum magnitude of $1$.
From the gradient perspective, when the margin constraint in Eqn.~\eqref{eq:triplet_loss} is not satisfied,
we obtain $\frac{\partial \mathcal{L}_\textit{Triplet}}{\partial s_\textit{H}(\theta^{+}_{i})}=\frac{\partial \mathcal{L}_\textit{Triplet}}{\partial s_\textit{H}(\theta^{-}_{i})}=1$, otherwise $0$. Hence, $s_\textit{H}'(\theta^{+}_{i})$ and $s_\textit{H}'(\theta^{-}_{i})$ are directly related to the gradient magnitude.
We will show in Sec.~\ref{sec:discussion} that Eqn.~\eqref{eq:triplet_loss} performs better over other possible solutions for balancing the gradients.
Finally, our overall loss function is defined as:
\begin{equation}
\label{eq:overall_loss}
\mathcal{L} = \mathcal{L}_\textit{Triplet} + \gamma R_{L_2},
\end{equation}
where $\gamma$ as a regularisation parameter and $\alpha$ balancing the contributions from $s$ and $d$. Optimal $\alpha$ can be found by a grid search which is discussed in Sec.~\ref{sec:discussion}.
\begin{figure}[t!]
\centering
\includegraphics[trim={1.5cm 9cm 3.2cm 9cm}, clip, width=\linewidth]{Figures/network.pdf}
\caption{
HyNet\xspace architecture.
}
\label{fig:network}
\vspace{-10pt}
\end{figure}
\subsection{Network Architecture}
In the work of L2-Net~\cite{l2net2017}, the authors show that flattened feature maps can be optimised in the same way as the final descriptors.
Thus, we are inspired to generalise the observations of Sec.\ref{sec:gradient_analysis} to the intermediate feature maps.
Instead of building extra loss functions, we propose to better manipulate the gradients for different layers.
Since feature maps are also feature vectors in high dimensional spaces, the previous gradient analysis can still be applied.
Our goal is to generate orthogonal gradients for the feature maps of all layers by L\textsubscript{2}\xspace normalising them, such that they can be better optimised in terms of directions mimicking the descriptors.
To this end, we can directly adopt the off-the-shelf Filter Response Normalisation(FRN)~\cite{frn2019}, which has been recently proposed and shown promising results in the classification task.
The core idea of FRN is to L\textsubscript{2}\xspace normalise the intermediate feature maps with learnable affine parameters.
Specifically, FRN normalises each layer of feature maps by:
\begin{equation}\label{eq:frn}
\hat{\mathbf{f}_i} =\gamma\sqrt{N} \frac{\mathbf{f}_i}{\|\mathbf{f}_i\|}+\beta,
\end{equation}
where $\gamma$ and $\beta$ are learned parameters,
$\mathbf{f}_i$ is the flattened feature map of the $i$-th channel and $N$ is the number of pixels.
Note that, it is also argued in~\cite{frn2019} that after FRN the gradients w.r.t.} \def\dof{d.o.f.~$\mathbf{f}_i$ are always orthogonal, which suits our scenario.
We will show in Sec.~\ref{sec:discussion} that although FRN can provide general performance boost, it is more compatible withe the proposed hybrid similarity.
Our HyNet\xspace architecture is based on L2-Net~\cite{l2net2017}, which consists of seven convolutional layers and outputs 128-dimensional descriptors.
As shown in Fig~\ref{fig:network}, all Batch Normalisation~(BN)~\cite{bn2015} layers, except the last one before the final L\textsubscript{2}\xspace normalisation in the original L2-Net, are replaced with FRN layers. Moreover, as recommended in~\cite{frn2019}, each FRN is followed by the Thresholded Linear Unit~(TLU) instead of the conventional ReLU.
Thus, HyNet\xspace has the same number of convolutional weights as HardNet \cite{hardnet2017} and SOSNet \cite{sosnet2019}.
\section{Conclusion}
\label{conclusion}
We have introduced a new deep local descriptor named HyNet\xspace, which is inspired by the analysis and optimisation of the descriptor gradients.
HyNet\xspace further benefits from a regularisation term that constrains the descriptor magnitude before L\textsubscript{2}\xspace normalisation, a hybrid similarity measure that makes different contributions from positive and negative pairs, and a new network architecture which L\textsubscript{2}\xspace normalises the intermediate feature maps.
Empirically, HyNet\xspace outperforms previous methods by a significant margin on various tasks.
Moreover, a comprehensive ablation study is conducted revealing the contribution of each proposed component on its final performance.
\section{Discussion}
\label{sec:discussion}
\input{Tables/ablation}
In this section, we first investigate how each building block of HyNet\xspace contributes to the overall performance.
\noindent{\bf Ablation Study}
is presented in Table.~\ref{tab:ablation},
which shows how the L\textsubscript{2}\xspace norm regularisation term $R_{L_2}$, similarity measure and feature map normalisation affect the performance.
Specifically, we train different models on {\em Liberty}~\cite{ubc2011} and report average MAP on Hpatches~\cite{hpatches2017} matching task.
First, we can see that $R_{L_2}$ helps to boost the performance, justifying our intuition that it optimises the network to be robust to intensity changes.
Next,
we compare $s_{\textit{H}}$ against $s$ and $d$ in Eqn.~\eqref{eq:overall_loss}, where the best results~(through grid search for optimal margin) for each similarity are reported.
$s_{\textit{H}}$ improves from $s$ and $d$ by {\bf 1.87} and {\bf 0.78} respectively, indicating its effectiveness in balancing the gradient magnitude obtained from the positive and negative samples.
Finally, Filter Response Normalisation~(FRN)~\cite{frn2019}
is compared to Batch Normalisation~(BN)~\cite{bn2015} and Instance Normalisation(IN)~\cite{in2016}, where the network with BN is used by previous methods~\cite{l2net2017, hardnet2017,sosnet2019,doap2018}.
FRN surpasses BN and IN by at least {\bf 1.5}, which demonstrates the advantage of L\textsubscript{2}\xspace normalising the intermediate feature maps.
Above all, by integrating $R_{L_2}$, $s_{\textit{H}}$ and FRN together, we achieve the best result.
Furthermore, to show that FRN is more compatible with the our proposed hybrid similarity, we retrain HardNet and SOSNet with HyNet\xspace architecture.
As shown, HyNet\xspace gains an MAP improvement of {\bf1.93} from FRN, whereas the numbers for HardNet and SOSNe are 1.33 and 1.10 respectively.
\noindent{\bf Effect of $\alpha$ and $m$}
is investigated with grid search and reported in Fig.~\ref{fig:discuss}(a), where HyNet\xspace reaches top performance with $\alpha=2$ and $m=1.2$.
Furthermore, we plot the gradient magnitude $g_{\textit{H}}|s'_\textit{H}(\theta)|$ in Fig.~\ref{fig:discuss}(b) by varying $\alpha$.
As seen, the curve of $\alpha=2$ is in between $\alpha=+\infty$ for $g_\textit{s}(\theta)$ and $\alpha=0$ for $g_\textit{d}(\theta)$, balancing the contributions from positives and negatives.
\noindent{\bf Other possible solutions} for using different metrics for the positives and negatives include:
\begin{equation}
\label{eq:L_2}
\begin{gathered}
\mathcal{L}_\textit{A} = \frac{1}{N}\sum_{i=1}^{N} \max(0, m_\textit{A} + s(\theta^{+}_{i}) - d(\theta^{-}_{i})),\\
\mathcal{L}_\textit{B} = \frac{\alpha}{N}\sum_{i=1}^{N} \max(0, m_{\textit{B}_1} + s(\theta^{+}_{i}) - s(\theta^{-}_{i}))
+ \frac{1}{N}\sum_{i=1}^{N} \max(0, m_{\textit{B}_2} + d(\theta^{+}_{i}) - d(\theta^{-}_{i})).
\end{gathered}
\end{equation}
\begin{figure}
\centering
\begin{subfigure}[b]{0.33\textwidth}
\centering
\includegraphics[trim={0cm 0.25cm 0cm 0cm}, clip, width=\linewidth]{Figures/margin.pdf}
\vspace{-15pt}
\caption{}
\label{fig:abla}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.33\textwidth}
\centering
\includegraphics[trim={0.3cm 0.25cm 0.22cm 0.2cm}, clip, width=\linewidth]{Figures/norm_s_hybrid.pdf}
\vspace{-15pt}
\caption{}
\label{fig:gh}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.325\textwidth}
\includegraphics[trim={0cm 0cm 0cm 0cm}, clip, width=\linewidth]{Figures/other_loss.pdf}
\vspace{-15pt}
\caption{}
\label{fig:diff_sollutions}
\end{subfigure}
\caption{(a) Effect of parameter $\alpha$ in the proposed hybrid loss.
(b) Gradient magnitude of the proposed HyNet\xspace loss for different $\alpha$.
(c) Comparison of the proposed loss to other variants that combine the inner product and L\textsubscript{2}\xspace loss.
}
\label{fig:discuss}
\vspace{-10pt}
\end{figure}
$\mathcal{L}_\textit{A}$ uses $s$
for positives while $d$ for negatives, which is intuitively the most direct approach for adaptive gradient magnitude.
Meanwhile, $\mathcal{L}_\textit{B}$ stacks two triplet losses, where $m_{\textit{B}_1}$ and $m_{\textit{B}_2}$ are the two margins.
We conduct grid search for $\mathcal{L}_\textit{A}$ and $\mathcal{L}_\textit{B}$, and set $m_{\textit{A}}=1.0$, $\alpha=2.0$, $m_{\textit{B}_1}=0.9$ and $m_{\textit{B}_2}=1.2$.
Following~\cite{sosnet2019}, we compare their training curves with our HyNet\xspace loss
in Fig.~\ref{fig:discuss}(c), where networks are trained on {\em Liberty} and FPR@95 are average on {\em Notredame} and {\em Yosemite}.
As shown, our HyNet\xspace loss using $s_\textit{H}$ surpasses the other two solutions.
Worth noting, that direct combination in $\mathcal{L}_\textit{A}$ does not show an advantage.
We believe that the triplet loss with a linear margin does not fit well the nonlinear transformation between $s$ and $d$, \emph{i.e.}} \def\Ie{\emph{I.e}, $d = \sqrt{ 2(1-s)}$, but we leave it for future investigation.
Meanwhile, stacking triplet losses with different similarity measures is also sub-optimal, which further justifies the effectiveness of the proposed hybrid similarity.
\section{Appendix}
\subsection{Image Matching Challenge 2020}
\label{sec:supp}
We further evaluate HyNet\xspace on the newly proposed Image Matching Challenge\footnote{\url{https://vision.uvic.ca/image-matching-challenge/benchmark/}}~(IMC) dataset~\cite{imw2020}.
It consists of two tasks, namely wide-baseline stereo and multi-view reconstruction.
Since the ground truth for the test set is not released, we report the performance on the validation set. For fair comparison, we use Key.Net~\cite{keynet2019} as the detector and compare HyNet\xspace with two other state-of-the-art descriptors, HardNet~\cite{hardnet2017} and SOSNet~\cite{sosnet2019}.
The evaluation protocol is with a maximum of 2048 keypoints per image and standard descriptor size (512 bytes). We use DEGENSAC~\cite{Chum2005} for geometric verification, and nearest-neighbour matcher with first-to-second nearest-neighbour ratio test for filtering false-positive matches.
Please refer to \cite{imw2020} for exact details of the challenge's settings.
\input{Tables/imw}
As can be seen from Table~\ref{tab:imw}, HyNet\xspace surpasses the previous state-of-the-art\xspace methods HardNet and SOSNet on both tasks, which further validates its effectiveness.
\subsection{Integrating HyNet\xspace with SOSR}
In this section, we test HyNet\xspace by combining it with the Second Order Similarity Regularisation~(SOSR) proposed in \cite{sosnet2019}, results are shown in Table~\ref{tab:UBC_performance_sosr} and Fig.~\ref{fig:hpatehes_results_sosr}.
As shown, HyNet\xspace generalises well with the extra supervision signal from SOSR, indicating its potential of being further boosted by other third-party loss terms.
\input{Tables/ubc_sosr}
\begin{figure*}[htb]
\centering
\includegraphics[trim={0cm 0cm 0cm 0cm}, clip, width=\linewidth]{Figures/hpatches_results_sosr.pdf}
\caption{
Results on test set `a' of HPatches~\cite{hpatches2017}.
Colour of the marker indicates EASY, HARD, and TOUGH noise. The type of marker corresponds to the variants of the experimental settings.}
\label{fig:hpatehes_results_sosr}
\end{figure*}
| {'timestamp': '2020-11-10T02:41:23', 'yymm': '2006', 'arxiv_id': '2006.10202', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10202'} | arxiv |
\section{Conclusions}
\label{sec:conclusions}
We have presented a novel methodology of active learning in image classification and regression using Graph Convolutional Network. After systematical and comprehensive experiments, our adapted sampling techniques, UncertainGCN and CoreGCN, produced state-of-the-art results on 6 benchmarks. We have shown through qualitative distributions that our selection functions maximises informativeness within the data space. The design of our sampling mechanism permits integration into other learning tasks. Furthermore, this approach enables further investigation in this direction where optimised selection criteria can be combined GCN sampler.
\section{Experiments}
\label{experiments}
We performed experiments on sub-sampling RGB and grayscale real images for classification,
depth real images for regression and RGB synthetic-generated for classification tasks. We describe them in details below.
\subsection{Classification}
\noindent \textbf{Datasets and Experimental Settings.}
We evaluated the proposed AL methods on four challenging image classification
benchmarks. These include three RGB image datasets, CIFAR-10\cite{cifar}, CIFAR-100\cite{cifar} and SVHN\cite{Goodfellow2014Multi-digitNetworks},
and a grayscale dataset, FashionMNIST\cite{Xiao2017Fashion-MNIST:Algorithms}.
Initially, for every benchmark, we consider the entire training set as an unlabelled pool ($\mathbf{D}_U$). As a cold-start, we randomly sample a small subset and query their labels, $\mathbf{D}_L$.
For CIFAR-10, SVHN and FashionMNIST, the size of the seed labelled examples is 1,000. Whereas, for CIFAR-100 we select 2,000
due to their comparatively more number of classes (100 vs 10).
We conduct our experiments for 10 cycles. At every stage, the budget is fixed at
1,000 images for the 10-class benchmarks and at 2,000
for CIFAR-100 which is a 100-class benchmark.
Similar to the existing works of \cite{BeluchBcai2018TheClassification,Yoo2019LearningLearning},
we apply our selection on randomly selected subsets $\mathbf{D}_S \hspace{-1pt}\subset\hspace{-1pt} \mathbf{D}_U$
of unlabelled images. This avoids the redundant occurrences which are common in all datasets~\cite{data_redundant}. The size of $\mathbf{D}_S$ is set to 10,000 for all the experiments.
\\
\noindent \textbf{Implementation details.}
ResNet-18 \cite{he2016deep} is the favourite choice as learner due to its relatively
higher accuracy and better training stability.
During training the learner, we set a batch size of 128. We use Stochastic Gradient Descent (SGD)
with a weight decay $5 \times 10^{-4}$ and a momentum of $0.9$. At every selection stage, we train the model for
200 epochs. We set the initial learning rate of 0.1 and decrease it by the factor of 10 after 160 epochs.
We use the same set of hyper-parameters in all the experiments.
For the sampler, GCN has 2 layers and we set the dropout rate to 0.3 to avoid over-smoothing~\cite{zhao2019pairnorm}.
The dimension of initial representations of a node is 1024 and it is projected to 512.
The objective function is binary cross-entropy per node.
We set the value of $\lambda = 1.2$ to give more importance to the larger unlabelled subset.
We choose Adam \cite{Kingma2015ADAM:Optimization} optimizer with a weight decay of $5 \times 10^{-4}$ and
a learning rate of $10^{-3}$. We initialise the nodes of the graph with the features of the images extracted from the learner.
We set the value of $s_{margin}$ to 0.1. For the empirical comparisons, we suggest readers to refer Supplementary Material.
\\
\noindent \textbf{Compared Methods and Evaluation Metric:} We compare our method with
a wide range of baselines which we describe here.
Random sampling is by default the most common sampling technique.
CoreSet\cite{Sener2017ActiveApproach} on learner feature space is one of the
best performing geometric techniques to date and it is another competitive baseline for us.
VAAL~\cite{Sinha2019VariationalLearning} and Learning Loss~\cite{Yoo2019LearningLearning}
are two state-of-the-art baselines from task-agnostic frameworks.
Finally, we also compare with FeatProp~\cite{Wu2019ActivePropagation} which
is a representative baseline for the GCN-based frameworks. This method is designed for cases
where a static fixed graph is available. To approximate their performance, we construct
a graph from the features extracted from learner and similarities between the features
as edges. We then compute the k-Medoids distance on this graph.
For quantitative evaluation, we report the mean average accuracy of
5 trials on the test sets.
\begin{figure}
\centering
\includegraphics[trim=2.5cm 0cm 3.5cm 1.0cm, clip, width=0.80\linewidth]{images/cifar10f2.pdf}
\includegraphics[trim=2.5cm 0cm 3.5cm 1.0cm, clip, width=0.80\linewidth]{images/cifar100f.pdf}
\caption{Quantitative comparison on CIFAR-10(top) and CIFAR-100(bottom) (Zoom in the view)}
\label{fig:cf10}
\end{figure}
\begin{figure}
\centering
\includegraphics[trim=2.5cm 0cm 3.5cm 1cm, clip, width=0.80\linewidth]{images/fmnistf.pdf}
\includegraphics[trim=2.5cm 0cm 3.5cm 1cm, clip, width=0.80\linewidth]{images/svhnf.pdf}
\caption{Quantitative comparison on FashionMNIST(top) and SVHN(bottom) (Zoom in the view)}
\label{fig:fm}
\end{figure}
\noindent \textbf{Quantitative Comparisons.} We train the ResNet-18 learner with all the available training examples on every dataset separately and report the performance on the test set. Our
implementation obtains 93.09\% on CIFAR-10, 73.02\% on CIFAR-100, 93.74\% on FashionMNIST,
and 95.35\% on SVHN. This is comparable as reported on the official implementation~\cite{he2016deep}.
These results are also set as the upper-bound performance of the active learning frameworks.
Figure \ref{fig:cf10} (left) shows the performance comparison of UncertainGCN and CoreGCN
with the other five existing methods on \textbf{CIFAR-10}. The solid line of the representation
is the mean accuracy and the faded colour shows the
standard deviation. Both our sampling techniques surpass almost every other compared methods in every selection stage.
CoreSet is the closest competitor for our methods. After selecting 10,000 labelled examples,
the CoreGCN achieves 90.7\% which is the highest performance amongst reported in the literature~\cite{Yoo2019LearningLearning,Sinha2019VariationalLearning}.
Likewise, Figure \ref{fig:cf10}~(right) shows the accuracy comparison on \textbf{CIFAR-100}.
We observe almost similar trends as on CIFAR-10.
With only 40\% of the training data, we achieve 69\% accuracy by applying CoreGCN.
This performance is just 4\% lesser than when training with the entire dataset.
Compared to CIFAR-10, we observe the better performance on VAAL
in this benchmark.
The reason is that VAE might favour a larger query batch size ($>$1,000).
This exhaustively annotates large batches of data when the purpose of active learning
is to find a good balance between exploration and exploitation as we constrain
the budget and batches sizes.
We further continue our evaluation on the image classification by applying our methods on
FashionMNIST and SVHN. In Figure \ref{fig:fm}, the left and the right graphs show the comparisons on
\textbf{FashionMNIST} and \textbf{SVHN} respectively. As in the previous cases, our methods achieve at minimum
similar performance to that of existing methods or outperforming them.
From the studies on these datasets, we observed consistent modest performance of FeatProp \cite{Wu2019ActivePropagation}.
This may be because it could not generalise on the unstructured
data like ours.
\begin{figure}
\centering
\includegraphics[trim=0cm 0cm 0cm 0cm, clip, width=0.49\linewidth]{images/comb.png}
\includegraphics[trim=0cm 0cm 0cm 0cm, clip, width=0.49\linewidth]{images/comb2.png}
\caption{Exploration comparison on CIFAR-10 between CoreSet and UncertainGCN (Zoom in the view)}
\label{fig:tsne}
\end{figure}
\begin{figure}
\centering
\includegraphics[trim=0cm 0cm 0cm 0cm, clip, width=0.49\linewidth]{images/tsne0.png}
\includegraphics[trim=0cm 0cm 0cm 0cm, clip, width=0.49\linewidth]{images/tsne2.png}
\caption{Exploration comparison on CIFAR-10 between CoreSet and CoreGCN (Zoom in the view)}
\label{fig:tsne_compare_coreset}
\end{figure}
\noindent \textbf{Qualitative Comparisons.}
To further analyse the sampling behaviour of our method we perform qualitative comparison with
existing method. We choose CoreSet for its consistently better performance in
empirical evaluations when compared to the other baselines.
We made this comparison on CIFAR-10.
For the two algorithms, we generate the t-SNE \cite{Maaten08visualizingdata} plots of
both labelled and unlabelled extracted features from the learner at
the first and fourth selection stage. To make a distinctive comparison of sampling behaviour
from early stage, we choose to keep a difference
of 3 stages.
Figure~\ref{fig:tsne}, t-SNE plots, compares the sampling behaviour of CoreSet and UncertainGCN.
In the first sampling stage, the selected samples distribution
is uniform which is similar for both techniques.
Without loss of generality, the learner trained with a small
number of seed annotated examples is sub-optimal, and, hence
the features of both labelled and unlabelled are not discriminative enough.
This makes the sampling behaviour for both methods near random.
At the fourth selection stage, the learner becomes relatively more discriminative.
This we can notice from the clusters representing each class of CIFAR-10.
Now, these features are robust to capture the relationship between the
labelled and unlabelled examples which we encode in the adjacency matrix.
Message-passing operations on GCN exploits the correlation between
the labelled and unlabelled examples by inducing similar representations.
This enables our method to target on the out-of-distribution
unlabelled samples and areas where features are hardly distinguished. This characteristics we can observe
on the plot of the fourth selection stage of UncertainGCN.
Similarly, in Figure \ref{fig:tsne_compare_coreset},
we continue the qualitative investigation for the CoreGCN acquisition method.
CoreGCN avoids over-populated areas while tracking out-of-distribution unlabelled data.
Compared to UncertainGCN, the geometric information from CoreGCN maintains a
sparsity throughout all the selection stages. Consequently, it preserves
the message passing through the uncertain areas while CoreSet keeps sampling
closer to cluster centres. This brings a stronger balance in comparison to
CoreSet between in and out-of-distribution selection with the availability of
more samples.
\noindent \textbf{Ablation Studies} To further motivate the GCN proposal, we conduct ablation studies on the sampler architecture. In Figure ~\ref{fig:abl_st}, still on CIFAR-10, we replace the GCN with a 2 Dense layer discriminator, \emph{UncertainDiscriminator}. This approach over-fits at early selection stages.
Although, GCN with 2 layers \cite{kipf2016semi} has been a de-facto optimal design choice,
we also report the performance with 1 layer (hinders long-range propagation) and 3 (over-smooths). However, to further quantify the significance of our adjacency matrix with feature correlations, we evaluate GCN samplers with identity (UncertainGCN Eye) and filled with 1s matrices (UncertainGCN Ones).
Finally, a study on
two important hyper-parameters: drop-out (0.3, 0.5, 0.8) and the number of hidden units (128, 256, 512) is in the Supplementary B.2.
We also fine-tune these parameters to obtain the optimal solution.
\begin{figure}
\centering
\includegraphics[trim=2cm 0cm 1cm 1cm, clip, width=0.80\linewidth]{gcn_abl2.pdf}
\caption{Ablation studies (Please zoom in)}
\label{fig:abl_st}
\end{figure}
\subsection{Regression}
\noindent \textbf{Dataset and Experimental Settings:} We further applied our method on
a challenging dataset for 3D Hand Pose Estimation benchmarks from depth images.
ICVL~\cite{icvl} contains 16,004 hand depth-images in the training set and the test set has 1,600. At every selection stage, similar to the experimental setup of image classification, we
randomly pre-sample 10\% of entire training examples $\mathbf{D}_S$ and apply the AL methods on
this subset of the data. Out of this pre-sampled images subset, we apply our sampler to select the
most influencing 100 examples.
\\
\noindent \textbf{Implementation Details:}
3D HPE is a regression problem which involves estimating the 3D coordinates of the hand joints from depth images.
Thus, we replace ResNet-18 by commonly used \emph{DeepPrior} \cite{deepprior} as learner.
The sampler and the other components in our pipeline remain the same as in
the image classification task. This is yet another evidence for our
sampling method being task-agnostic. For all the experiments, we train the 3D HPE with
Adam\cite{Kingma2015ADAM:Optimization} optimizer and with a learning rate of $10^{-3}$.
The batch size is 128. As pre-processing, we apply a pre-trained U-Net ~\cite{unet} model to detect hands,
centre, crop and resize images to the dimension of 128x128.
\\
\noindent \textbf{Compared Methods and Evaluation Metric:}
We compare our methods from the two ends of the spectrum of baselines. One is random sampling
which is the default mechanism. The other is CoreSet\cite{Sener2017ActiveApproach}, one of the best
performing baselines from the previous experiments.
We report the performance in terms of mean squared error averaged from 5 different trials
and its standard deviation.
\begin{figure}%
\centering
\includegraphics[trim=2.5cm 0.2cm 3.5cm 1cm, clip, width=.75\linewidth]{images/icvl2.pdf}
\caption{Quantitative comparison on 3D Hand Pose Estimation (lower is better)}%
\label{fig:hands}%
\end{figure}
\\
\noindent \textbf{Quantitative Evaluations:} Figure~\ref{fig:hands} shows the performance comparison
on ICVL dataset. In the Figure, we can observe that both our sampling methods, CoreGCN and UncertainGCN,
outperform the CoreSet and Random sampling consistently from the second selection stage.
The slope of decrease in error for our methods sharply falls down from the second
till the fifth selection stage for UncertainGCN and till the sixth for CoreGCN.
This gives us an advantage over the other methods when we have a very limited budget.
At the end of the selection stage, CoreGCN gives the least error of 12.3 mm.
In terms of performance, next to it is UncertainGCN.
\subsection{Sub-sampling of Synthetic Data.}
Unlike previous experiments of sub-sampling real images, we applied our method to select synthetic examples obtained from StarGAN~\cite{choi2018stargan} trained on RaFD~\cite{langner2010presentation} for translation of face
expressions.
Although Generative Adversarial Networks~\cite{goodfellow2014generative} are closing the gap between real and synthetic data~\cite{ravuri2019seeing}, still the synthetic images and its associated labels are not
yet suitable to train a downstream discriminative model. Recent study~\cite{bhattarai2020sampling} recommends sub-sampling the synthetic data before augmenting to the real data. Hence, we apply our algorithm to get a sub-set of the quality and influential synthetic examples. The experimental
setup is similar to that of the image classification which we described in our previous Section. Learner and Sampler remain the same.
The only difference will be in the nature of the pool images. Instead of real data, we have StarGAN
synthetic images.
Figure~\ref{fig:rafd} shows the performance comparison of random selection vs our UncertainGCN method in 5 trials. From the experiment, we can observe our method achieving higher accuracy with less variance than commonly used random sampling. The mean accuracy drops for both the methods from the fourth selection stage.
Only a small fraction of synthetic examples are useful to train the model~\cite{bhattarai2020sampling}. After the fourth stage, we force sampler to select more examples which may end up choosing noisy data.
\begin{figure}
\centering
\includegraphics[trim=2.5cm 0.2cm 3.5cm 1cm, clip, width=.75\linewidth]{images/rafdf.pdf}
\caption{Performance comparison on sub-sampling synthetic data to augment real data for expression classification}
\label{fig:rafd}
\end{figure}
\section{Introduction}
\label{sec:intro}
Deep learning has shown great advancements in several computer vision tasks such as
image classification~\cite{he2016deep,krizhevsky2012imagenet} and 3D Hand Pose Estimation (HPE) ~\cite{deepprior, qiye, deepprior++}.
This has been possible due to the availability of both the powerful computing infrastructure and the
large-scale datasets.
Data annotation is a time-consuming task, needs experts and is also expensive.
This gets even more challenging to some of the specific domains such as robotics or medical image analysis. Moreover, while optimizing deep neural network architectures, a gap is present concerning the representativeness of the data~\cite{data_redundant}. To overcome these issues, \emph{active learning}~\cite{Gal2017DeepDatab,near2} has been successfully deployed to efficiently select the most meaningful samples.
\begin{figure}
\centering
\includegraphics[trim=0cm 0cm 0cm 0.0cm, clip, width=0.47\textwidth]{images/pipeline.pdf}
\caption{The diagram outlines the proposed pipeline. \textbf{Phase I}: Train the learner to minimise the objective of downstream task from the available annotations, \textbf{Phase II}: Construct a graph with the representations of images extracted from the learner as vertices and their similarities as edges, \textbf{Phase III}: Apply GCN layers to minimise binary cross-entropy between labelled and unlabelled, \textbf{Phase IV}: Apply uncertainty sampling to select unlabelled examples to query their labels, \textbf{Phase V}: Annotate the selection, populate the number of labelled examples and repeat the cycle.}
\label{fig:prposed_pipeline}
\end{figure}
Essentially, there are three distinct components in any Active Learning (AL) framework.
These components are \emph{learner, sampler}, and \emph{annotator}. In brief, a \emph{learner} is a model
trained to minimize the objective of the target task. The \emph{sampler} is designed to select
the representative unlabelled examples within a fixed budget to deliver the highest performance.
Finally, an \emph{annotator} labels the queried data for learner re-training. Based on
the relationship between learner and sampler, AL frameworks can be categorised into
two major groups: task-dependent and task-agnostic. Task-dependents are the ones where
the sampler is specially designed for a specific task of the learner.
Majority of the previous works in active learning~\cite{cortes1995support, Gal2017DeepDatab,AbelRegionalLearning,Wu2019ActivePropagation,Cai2017ActiveEmbedding, anbr} are task-dependent in nature.
In other words, the sampling function is dependent on the objective of the learner.
This design limits the model to become optimal for a specific type of task while suffering from its scalability problem.
Some of the recent works such as
VAAL~\cite{Sinha2019VariationalLearning} and Learning
Loss~\cite{Yoo2019LearningLearning} tackle such a problem.
VAAL trains a variational auto-encoder (VAE) that learns a latent space for better discrimination
between labelled and unlabelled images in an adversarial manner.
Similarly, Learning Loss introduces a separate loss-prediction module to
be trained together with the learner.
The major drawback of these approaches is the lack of a mechanism that exploits the
correlation between the labelled and the unlabelled images. Moreover, VAAL has
no way to communicate between the learner and the sampler.
Graph Convolutional Networks(GCNs)~\cite{kipf2016semi,bronstein2017geometric} are capable
of sharing information between the nodes via message-passing operations.
In the AL domain, the application of GCNs \cite{Cai2017ActiveEmbedding, anbr, AbelRegionalLearning, Wu2019ActivePropagation}
is also slowly getting priority. However, these methods are applied only to
specific kind of datasets i.e. graph-structured data such as Cora, CiteSeer,
and PubMed~\cite{graph_datasets}. In this work, we are exploring
the image domain beyond graph-structured data.
To address the above-mentioned issues, we propose a sequential GCN for Active Learning in a task-agnostic manner.
Figure~\ref{fig:prposed_pipeline} shows the pipeline of the proposed method.
In the Figure, Phase I implements the learner. This is a model trained to minimize the
objective of the downstream task. Phase II, III and IV compose our sampler where
we deploy the GCN and apply the sampling techniques on
graph-induced node embeddings and their confidence scores. Finally, in Phase V, the
selected unlabelled examples are sent for annotation.
At the initial stage, the learner is trained with a small number of seed labelled examples.
We extract the features of both labelled and unlabelled images from the learner parameters.
During Phase II, we construct a graph where features are used to initialise the nodes of the graph
and similarities represent the edges. Unlike VAAL\cite{Sinha2019VariationalLearning}, the initialisation of the nodes
by the features extracted from the learner creates an opportunity to inherit
uncertainties to the sampler. This graph is passed through GCN layers (Phase III)
and the parameters of the graph are learned to
identify the nodes of labelled vs unlabelled example. This objective of the sampler is
independent of the one from the learner.
We convolve on the graph which does message-passing operations between the nodes to
induce the higher-order representations. The graph embedding of any image depends primarily
upon the initial representation and the associated neighbourhood nodes. Thus, the images
bearing similar semantic and neighbourhood
structure end up inducing close representations which will play a key
role in identifying the sufficiently different
unlabelled examples from the labelled ones. The nodes after convolutions are classified
as labelled or unlabelled. We sort the examples based on the confidence score, apply an uncertainty sampling
approach (Phase IV), and send the selected examples to query their labels(Phase V). We called this sampling
method as \textbf{UncertainGCN}. Figure~\ref{fig:sampling_simulation} simulates the
UncertainGCN sampling technique.
Furthermore, we adapt the higher-order graph node information under the CoreSet \cite{Sener2017ActiveApproach}
for a new sampling technique by introducing latent space distancing. In principle, CoreSet ~\cite{Sener2017ActiveApproach} uses risk minimisation between core-sets on the learner feature space while we
employ this operation over GCN features. We called this sampling technique as \textbf{CoreGCN}.
Our method has a clear advantage due to the aforementioned strengths of the GCN which is demonstrated by both
the quantitative and qualitative experiments (see Section \ref{experiments}).
Traversing from Phase I to Phase V as shown in Figure~\ref{fig:prposed_pipeline}
completes a cycle. In the next iteration, we flip the label of annotated
examples from unlabelled to labelled and re-train the whole framework.
We evaluated our sampler on four challenging real domain image classification benchmarks, one depth-based dataset for 3D HPE and a synthetic
image classification benchmark. We compared with several competitive sampling baselines and existing state-of-the-arts methods including CoreSet, VAAL and Learning Loss. From both the quantitative and the qualitative comparisons, our proposed framework is more accurate than existing methods.
\section{Introduction}
\input{intro}
\input{related_works}
\input{method}
\input{experiments}
\input{conclusions}
\section*{Acknowledgements}
This work is partially supported by Huawei Technologies Co. and by EPSRC Programme Grant FACER2VM (EP/N007743/1).
{\small
\bibliographystyle{ieee_fullname}
\section{Method}
\begin{figure*}
\centering
\includegraphics[trim=0.0cm 0.0cm 0.0cm 0.0cm, clip, width=0.9\textwidth]{images/diagram4.pdf}
\caption{ This Figure simulates the sampling behaviour of the proposed \textbf{UncertainGCN}
sampler at its first three selection stages. We run a toy experiment just taking 100 examples
from ICVL~\cite{icvl} Hand Pose dataset. Each node is initialised by the features extracted
from the learner and edges
capture their relation. Each concentric circle represents a cluster of strongly connected nodes.
Here, in our case, a group of images having similar viewpoints are in a concentric circle.
Considering two labelled examples as seed labelled examples in the centre-most circle, in the first selection stage, our algorithm selects samples from another concentric circle which is out-of-distribution than selecting the remaining examples from the innermost circle. Similarly,
in the second stage, our sampler chooses images residing in another outer concentric circle which are sufficiently different from those selected before.}
\label{fig:sampling_simulation}
\end{figure*}
\def\x {\mathbf{x}}
\def\mathbf{y} {\mathbf{y}}
In this section, we describe the proposed method in details.
First, we present the learners in brief for the image classification and regression tasks under the
pool-based active learning scenario. In the second part, we discuss our two novel sampling methods: \textbf{UncertainGCN} and ~\textbf{CoreGCN}. UncertainGCN is based on the standard AL method uncertainty sampling ~\cite{Sener2017ActiveApproach} which tracks the
confidence scores of the designed graph nodes. Furthermore, CoreGCN adapts the highly successful CoreSet~\cite{Sener2017ActiveApproach} on the induced graph embeddings by the sequentially trained GCN network.
\subsection{Learner}
In Figure~\ref{fig:prposed_pipeline}, Phase I depicts the learner. Its goal is to
minimise the objective of the downstream task. We have considered both the classification and regression tasks.
Thus, the objective of this learner varies with the nature of the task we are dealing with. \\
\noindent \textbf{Classification:}
For the classification tasks, the learner is a CNN image classifier.
We deploy a deep model $\mathcal{M}$ that maps a set of inputs $\x \in \mathbf{X}$ to
a discriminatory space of outputs $\mathbf{y} \in \mathbf{Y}$ with parameters $\textbf{$\theta$}$.
We took ResNet-18~\cite{he2016deep} as the CNN model due to its relatively higher performance
in comparison to other networks with comparable parameter complexity.
Any other model like VGG-11\cite{Simonyan2015VeryRecognition} can also be easily deployed (refer to Supplementary Material B.4).
A loss function $\mathcal{L}(\x,\mathbf{y};\theta)$ is minimized during the training process. The objective
function of our classifier is cross-entropy defined as below:
\begin{equation} \label{eq:1}
\mathcal{L}_{\mathcal{M}}^c(\x,\mathbf{y};\theta) = - \frac{1}{N_l}\sum_{i=1}^{N_l} \mathbf{y}_i \log(f(\x_i,\mathbf{y}_i;\theta)),
\end{equation}
where $N_l$ is the number of labelled training examples and $f(\x_i,\mathbf{y}_i;\theta)$ is the posterior probability of the model $\mathcal{M}$.
\noindent \textbf{Regression:} To tackle the 3D HPE, we deploy a well-known \textit{DeepPrior} \cite{deepprior}
architecture as model $\mathcal{M}$. Unlike the previous case, we regress the 3D hand joint coordinates from the
hand depth images. Thus, the objective function of the model changes as in Equation~\ref{eq:reg}.
In the Equation, $J$ is the number of joints to construct the hand pose.
\begin{equation} \label{eq:reg}
\mathcal{L}_{\mathcal{M}}^r(\x,\mathbf{y};\theta) = \frac{1}{N_l}\sum_{i=1}^{N_l} \Big( \frac{1}{J}\sum_{j=1}^J\|\mathbf{y}_{i,j} - f(\x_{i,j},\mathbf{y}_{i,j};\theta)\|^2\Big),
\end{equation}
To adapt our method to any other type of task, we just need to modify the learner.
The rest of our pipeline remains the same which we discuss in more details in the following Sections.
\subsection{Sampler}
Moving to the second Phase from Figure \ref{fig:prposed_pipeline}, we adopt a pool-based scenario for active learning.
This has become a standard in deep learning system due to its successful deployment in
recent methods~\cite{BeluchBcai2018TheClassification,Sener2017ActiveApproach, Sinha2019VariationalLearning, Yoo2019LearningLearning}.
In this scenario, from a pool of unlabeled dataset $\mathbf{D}_U$,
we randomly select an initial batch for labelling $\mathbf{D}_0\hspace{-1pt} \subset
\hspace{-1pt}\mathbf{D}_U$. Without loss of generality, in active learning research,
the major goal is to optimize a sampler's method for data acquisition, $\mathcal{A}$
in order to achieve minimum loss with the least number of batches $\mathbf{D}_n$. This
scope can be simply defined for $n$ number of active learning stages as following:
\begin{equation} \label{eq:2}
\min_n \min_{\mathcal{L}_{\mathcal{M}}} \mathcal{A}(\mathcal{L}_{\mathcal{M}}(\x,\mathbf{y};\theta)|\mathbf{D}_0\hspace{-1pt}\subset\hspace{-1pt} \cdots \hspace{-1pt}\subset\hspace{-1pt} \mathbf{D}_n\hspace{-1pt}\subset \hspace{-1pt} \mathbf{D}_U).
\end{equation}
We aim to minimise the number of stages so that fewer samples $(\x,\mathbf{y})$ would require annotation. For the sampling method $\mathcal{A}$, we bring the heuristic relation between the discriminative understanding of the model and the unlabelled data space. This is quantified
by a performance evaluation metric and traced at every querying stage.
\subsubsection{Sequential GCN selection process}
\label{subsection3.2}
During sampling as shown in Figure~\ref{fig:prposed_pipeline} from Phase II to IV, our contribution relies on sequentially training a GCN initialised with the features extracted from the learner for both labelled and unlabelled images at every active learning stage. As stated before, similar to VAAL \cite{Sinha2019VariationalLearning}, we consider this methodology as model-based where a separate architecture is required for sampling. Our motivation in introducing the graph is primarily in propagating the inherited uncertainty on the learner feature space between the samples (nodes). Thus, message-passing between the nodes induces higher-order representations of the nodes after applying convolution on the graph. Finally, our GCN will act as a binary classifier deciding which images are annotated.
\def\mathcal{G} {\mathcal{G}}
\def\mathcal{V} {\mathcal{V}}
\def\mathcal{E} {\mathcal{E}}
\def\mathbf{v} {\mathbf{v}}
\noindent \textbf{Graph Convolutional Network.} The key components of a graph, $\mathcal{G}$ are the nodes, also called vertices $\mathcal{V}$ and the edges $\mathcal{E}$. The edges capture the
relationship between the nodes and encoded in an adjacency matrix $A$. The nodes $\mathbf{v} \in \mathbb{R}^{(m \times N)}$ of the graph encode image-specific information and are initialised with the features extracted from the learner. Here, ~$N$ represents the total number of both labelled and unlabelled examples while
$m$ represents the dimension of features for each node.
After we apply $l_2$ normalisation to the features, the initial elements of $A$ result as vector product between every sample of $\mathbf{v}$ i.e. ($S_{ij}=\mathbf{v}_i^{\top} \mathbf{v}_j, \{i, j\} \in N$). This propagates the similarities between nodes while falling under the same metric space as the learner's objective. Furthermore, we subtract from $S$ the identity matrix $I$ and then we normalise by multiplying with its degree $D$. Finally, we add the self-connections back so that the closest correlation is with the node itself. This can simply be summarised under:
\begin{equation} \label{eq:4}
A = D^{-1}(S-I)+I.
\end{equation}
To avoid over-smoothing of the features in GCN \cite{kipf2016semi}, we adopt a two-layer architecture. The first GCN layer can be described as a function $f_\mathcal{G}^1(A, \mathcal{V}; \Theta_1):\mathbb{R}^{N\times N} \times \mathbb{R}^{m\times N} \rightarrow \mathbb{R}^{h\times N}$ where $h$ is number of hidden units and $\Theta_1$ are its parameters. A rectified linear unit activation \cite{relu} is applied after the first layer to maximise feature contribution. However, to map the nodes as labelled or unlabelled, the final layer is activated through a sigmoid function. Thus, the output of $f_{\mathcal{G}}$ is a vector length of $N$ with values between 0 and 1 (where 0 is considered unlabelled and 1 is for labelled). We can further define the entire network function as:
\begin{equation}
f_{\mathcal{G}}= \sigma(\Theta_2(ReLU(\Theta_1A)A).
\end{equation}
In order to satisfy this objective, our loss function will be defined as:
\begin{equation}
\begin{split}
\mathcal{L}_{\mathcal{G}}(\mathcal{V},A;\Theta_1,\Theta_2) &= - \frac{1}{N_l}\sum_{i=1}^{N_l} \log(f_{\mathcal{G}}(\mathcal{V},A;\Theta_1,\Theta_2)_i) -\\
& \hspace{-28pt}- \frac{\lambda}{N-N_l}\sum_{i=N_l+1}^N\log(1-f_{\mathcal{G}}(\mathcal{V},A;\Theta_1,\Theta_2)_i),
\end{split}
\end{equation}
where $\lambda$ acts as a weighting factor between the labelled and unlabelled cross-entropy.
\\
\noindent \textbf{UncertainGCN: Uncertainty sampling on GCN.} Once the training of the GCN is complete, we move forward to selection. From the remaining unlabelled samples $\mathbf{D}_U$, we can draw their confidence scores $f_{\mathcal{G}}(\mathbf{v}_i ; \mathbf{D}_U)$ as outputs of the GCN. Similarly to uncertainty sampling, we propose to select with our method, \textbf{UncertainGCN}, the unlabelled images with the confidence depending on a variable $s_{margin}$. While querying a fixed number of $b$ points for a new subset $\mathbf{D}_L$, we apply the following equation:
\begin{equation} \label{eq:3}
\mathbf{D}_L = \mathbf{D}_L \cup \argmax_{i=1\cdots b}\lvert s_{margin}- f_{\mathcal{G}}(\mathbf{v}_i ; \mathbf{D}_U\hspace{-1pt})\rvert.
\end{equation}
For selecting the most uncertain unlabelled samples, $s_{margin}$ should be closer to 0. In this manner, the selected images are challenging to discriminate, similarly to the adversarial training scenario \cite{goodfellow2014generative}.
This stage is repeated as long as equation \ref{eq:2} is satisfied. Algorithm \ref{alg:1} summarises the GCN sequential training with the UncertainGCN sampling method.
\begin{algorithm}
\caption{UncertainGCN active learning algorithm}
\begin{algorithmic}[1]
\State \textbf{Given}: Initial labelled set $\mathbf{D}_0$, unlabelled set $\mathbf{D}_U$ and query budget $b$
\State \textbf{Initialise} $(\x_L, \mathbf{y}_L) ,(\x_U)$ - labelled and unlabelled images
\Repeat
\State $\theta \leftarrow f(\x_L, \mathbf{y}_L)$ \Comment{Train learner with labelled}
\State $\mathcal{V} = [\mathbf{v}_L, \mathbf{v}_U] \leftarrow f{(\x_L \cup \x_U ; \theta)}$ \Comment{Extract features for labelled and unlabelled}
\State \textit{Compute adjacency matrix $A$ according to Equation \ref{eq:4}}
\State $\Theta \leftarrow f_\mathcal{G}(\mathcal{V}, A)$ \Comment{Train the GCN}
\For{$i = 1 \to b$}
\State $\mathbf{D}_L$ = $\mathbf{D}_L \cup \argmax_i \lvert s_{margin}- f_{\mathcal{G}}(\mathbf{v} ; \mathbf{D}_U)\rvert$
\Comment{Add nodes depending on the label confidence}
\EndFor
\State \textit{Label $\mathbf{y}_U$ given new $\mathbf{D}_L$}
\Until {\textit{Equation \ref{eq:2}} is satisfied}
\end{algorithmic}
\label{alg:1}
\end{algorithm}
\noindent \textbf{CoreGCN: CoreSet sampling on GCN.}
\label{subsection3.3}
To integrate geometric information between the labelled and unlabelled graph representation, we approach a CoreSet technique \cite{Sener2017ActiveApproach} in our sampling stage. This has shown better performance in comparison to uncertainty-based methods \cite{Wu2019ActivePropagation}. \cite{Sener2017ActiveApproach} shows how bounding the difference between the loss of the unlabelled samples and the one of the labelled is similar to the \emph{k-Centre} minimisation problem stated in \cite{wolf}.
In this approach, the sampling is based on the $l2$ distances between the features extracted from the trained classifier.
Instead of that, we will make use of our GCN architecture by applying CoreSet method on the features represented after the first layer of the graph. To this, the CoreSet method benefits from the cyclical dependencies. The sampling method is adapted to our mechanism for each $b$ data point under the equation:
\begin{equation}
\mathbf{D}_L = \mathbf{D}_L \cup \argmax_{i \in \mathbf{D}_U} \min_{j \in \mathbf{D}_L} \delta( f_\mathcal{G}^1(A, \mathbf{v}_i; \Theta_1), f_\mathcal{G}^1(A, \mathbf{v}_j; \Theta_1)),
\end{equation}
where $\delta$ is the Euclidean distance between the graph features of the labelled node $\mathbf{v}_i$ and the ones from the unlabelled node $ \mathbf{v}_j$. We define this method as \textbf{CoreGCN}.
Finally, given the model-based mechanism, we claim that our sampler is task-agnostic as long as the learner is producing a form of feature representations. In the following section, we will experimentally demonstrate the performance of our methods quantitatively and qualitatively.
\section{Related Works}
\label{related_works}
\noindent \textbf{Model-based methods.} Recently, a new category of methods is explored in the active learning paradigm where a separate model from the learner is trained for selecting a sub-set of the most representative data. Our method is based on this category. One of the first approaches \cite{Yoo2019LearningLearning} attached a loss-learning module so that loss can be predicted offline for the unlabelled samples. In \cite{Sinha2019VariationalLearning}, another task-agnostic solution deploys a variational auto-encoder (VAE) to map the available data on a latent space. Thus, a discriminator is trained in an adversarial manner to classify labelled from unlabelled. The advantage of our method over this approach is the exploitation of the relative relationship between the
examples by sharing information through message-passing operations in GCN.
\noindent \textbf{GCNs in active learning.}
GCNs ~\cite{kipf2016semi} have opened new active learning methods that have been successfully applied in~\cite{AbelRegionalLearning,Wu2019ActivePropagation,Cai2017ActiveEmbedding, anbr}. In comparison to these methods, our approach has distinguished learner and sampler. It makes our approach task-agnostic and also
gets benefited from model-based methods mentioned just before. Moreover, none of these methods is trained in a sequential manner.
~\cite{Wu2019ActivePropagation} proposes K-Medoids clustering for the feature propagation between the labelled and unlabelled nodes. A regional uncertainty algorithm is presented in \cite{AbelRegionalLearning} by extending the PageRank \cite{ilprints422} algorithm to the active learning problem. Similarly, \cite{Cai2017ActiveEmbedding} combines node uncertainty with graph centrality for selecting the new samples. A more complex algorithm is introduced in \cite{anbr} where a reinforcement scheme with multi-armed bandits decides between the three query measurements from \cite{Cai2017ActiveEmbedding}.
However, these works~\cite{Cai2017ActiveEmbedding, anbr, Wu2019ActivePropagation} derive their selection mechanism on the assumption of a Graph learner. This does not make them directly comparable with our proposal where a GCN is trained separately for a different objective function than the learner.
\noindent \textbf{Uncertainty-based methods.} Earlier techniques for sampling unlabelled data have been explored through uncertainty exploration of the convolutional neural networks (CNNs). A Bayesian approximation introduced in \cite{Gal2016DropoutGhahramani} produce meaningful uncertainty measurements by variational inference of a Monte Carlo Dropout (MC Dropout) adapted architecture. Hence, it is successfully integrated into active learning by \cite{Gal2017DeepDatab,Houlsby2011BayesianLearning,Kirsch2019BatchBALD:Learning, Pinsler2019BayesianApproximation}.
With the rise of GPU computation power, \cite{BeluchBcai2018TheClassification} ensemble-based method outperformed MC Dropout
\\
\textbf{Geometric-based methods.} Although there have been studies exploring the data space through the representations of the learning model (\cite{near2,coresvm,Har-Peled2007}), the first work applying it for CNNs as an active learning problem, CoreSet, has been presented in \cite{Sener2017ActiveApproach}. The key principle depends on minimising the difference between the loss of a labelled set and a small unlabelled subset through a geometric-defined bound. We furthermore represent this baseline in our experiments as it successfully over-passed the uncertainty-based ones.
\section{Supplementary Material}
| {'timestamp': '2021-04-02T02:35:10', 'yymm': '2006', 'arxiv_id': '2006.10219', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10219'} | arxiv |
\section{A Newton/gradient coordinate descent optimizer for classification}
Denote by $\mathcal{D} = \left\{(\mathbf{x}_i,\mathbf{y}_i)\right\}_{i=1}^{N_\text{data}}$ data/label pairs, and consider the following class of deep learning architectures:
\begin{equation}\label{eq:architecture}
\mathcal{L}(\mathbf{W},\xi,\mathcal{D}) = \sum_{(\mathbf{x}_i,\mathbf{y}_i) \in \mathcal{D}} \mathcal{L}_{\text{CE}}(\cdot;\mathbf{y}_i) \circ \mathcal{F}_{\text{SM}} \circ \mathcal{F}_{\text{LL}} (\cdot; \mathbf{W}) \circ \mathcal{F}_{\text{HL}} (\mathbf{x}_i; \xi),
\end{equation}
where $\mathcal{L}_{\text{CE}},\mathcal{F}_{\text{SM}},\mathcal{F}_{\text{LL}}$ and $\mathcal{F}_{\text{HL}}$ denote a cross-entropy loss, softmax layer, linear layer, and hidden layer, respectively. We denote linear layer weights by $\mathbf{W}$, and consider a general class of hidden layers (e.g. dense networks, convolutional networks, etc.), denoting associated weights and biases by the parameter $\xi$. The final three layers are expressed as
\begin{equation}\label{eq:final_layers}
\mathcal{L}_{\text{CE}}(\mathbf{x};\mathbf{y}) = -{\sum_{i=1}^{N_c} {y}^i \log {x}^i}; \quad
\mathcal{F}^i_{\text{SM}}(\mathbf{x}) = \frac{\exp (-x_i)}{\sum_{j=1}^{N_c}\exp(-x_j)};\quad
\mathcal{F}^i_{\text{LL}}(\mathbf{x}) = {\mathbf{W}} \mathbf{x}
\end{equation}
and map $\mathcal{F}_{\text{HL}}:\mathbb{R}^{N_{\text{in}}}\rightarrow \mathbb{R}^{N_{\text{basis}}}$; $\mathcal{F}_{\text{LL}}:\mathbb{R}^{N_{\text{basis}}}\rightarrow \mathbb{R}^{N_{\text{classes}}}$; $\mathcal{F}_{\text{SM}}:\mathbb{R}^{N_{\text{classes}}}\rightarrow \mathbb{R}^{N_{\text{classes}}}$; and $\mathcal{L}_{\text{CE}}:\mathbb{R}^{N_{\text{classes}}}\rightarrow \mathbb{R}$. Here, $N_{\text{basis}}$ is the dimension of the output of the hidden layer; this notation is explained in the next paragraph. The standard classification problem is to solve
\begin{equation}\label{eq:fullLoss}
\left(\mathbf{W}^*,\xi^*\right) = \underset{\mathbf{W},\xi}{\text{argmin}}\, \mathcal{L}(\mathbf{W},\xi,\mathcal{D}).
\end{equation}
The recent work by~\citet{cyr2019robust} performed a similar partition of weights into linear layer weights $\mathbf{W}$ and hidden layer weights $\xi$ for regression problems. Two important observations were made using
this decomposition. First, the output of the hidden layers can be treated as an adaptive basis with the learned weights $\mathbf{W}$ corresponding to the coefficients producing the prediction. Second, holding $\xi$ fixed leads to a linear least squares problem for the basis coefficients $\mathbf{W}$ that can be solved for a global minimum. This work builds on these two observations for classification problems.
The output of the hidden layers $\mathcal{F}_{\text{HL}}$ defines a basis
\begin{equation}
\Phi_\alpha(\cdot,\xi): \mathbb{R}^{N_{\text{in}}} \rightarrow \mathbb{R} \mbox{ for } \alpha = 1 \ldots N_{\text{basis}}
\label{eq:adapt-basis}
\end{equation}
where $\Phi_\alpha(x,\xi)$ is row $\alpha$ of $\mathcal{F}_{\text{HL}}(x,\xi)$.
Thus the input to the softmax classification layer are $N_{\text{classes}}$ functions, each defined using the adaptive basis $\Phi_\alpha$ and a single row of the weight matrix $\mathbf{W}$.
The crux of this approach to classification is the observation that
for all $\xi$, the function
\begin{equation}\label{eq:S_def}
\mathcal{S}(\mathbf{W}, \mathcal{D}) = \mathcal{L}(\mathbf{W},\xi, \mathcal{D})
\end{equation}
is convex with respect to $\mathbf{W}$,
and therefore the global minimizer
\begin{equation}\label{eq:WLoss}
\mathbf{W}^* = \underset{\mathbf{W}}{\text{argmin}}\, \mathcal{S}(\mathbf{W}, \mathcal{D})
\end{equation}
may be obtained via Newton iteration with line search.
In Sec. \ref{sec:algo}, we introduce a coordinate-descent optimizer that alternates between a globally optimal solution of \eqref{eq:WLoss} and a gradient descent step minimizing \eqref{eq:fullLoss}. Combining this with the interpretation of the hidden layer as providing a data-driven adaptive basis, this ensures that during training the parameters evolve along a manifold providing optimal fit of the adaptive basis to data \citep{cyr2019robust}. We summarize this perspective and relation to previous work in Sec. \ref{sec:literature}, and in Sec. \ref{sec:results} we investigate how this approach differs from stochastic gradient descent (GD), both in accuracy and in the qualitative properties of the hidden layer basis.
\section{Convexity analysis and invertibility of the Hessian} \label{sec:convexity}
In what follows, we use basic properties of convex functions \citep{boyd2004convex} and the Cauchy-Schwartz inequality \citep{folland1999real} to prove that $\mathcal{S}$ in \eqref{eq:S_def} is convex. Recall that convexity is preserved under affine transformations. We first note that $\mathcal{L}_{\text{LL}}(\mathbf{W};\mathcal{D},\xi)$ is linear.
By \eqref{eq:architecture}, it remains only to show that $\mathcal{L}_{\text{CE}} \circ \mathcal{F}_{\text{SM}}$ is convex. We write, for any data vector $\mathbf{y}$,
\begin{align}
\mathcal{L}_{\text{CE}} \circ \mathcal{F}_{\text{SM}} (\mathbf{x}; \mathbf{y}) &= - \sum_{i=1}^{N_{\text{classes}}} y_
\log\left(\frac{\exp(-x_i)}{\sum_{j=1}^{N_\text{classes}} \exp(- x_j)}\right)\\
&= \sum_{i=1}^{N_{\text{classes}}} y_
x_i - N_{\text{classes}} \log \left( \sum_{i=1}^{N_{\text{classes}}} \exp \left(-x_i \right)\right).
\end{align}
The first term above is affine and thus convex. We prove the convexity of the second term
${f(\mathbf{x}) := -\log \left( \sum_{i=1}^{N_{\text{classes}}} \exp \left(-x_i \right)\right)}$ by writing
\begin{equation}
f(\theta \mathbf{x} + (1-\theta)\mathbf{y}) = \log \left( \sum_{i=1}^{N_{\text{classes}}}
\left( \exp(-x_i) \right)^\theta
\left( \exp(-y_i) \right)^{1-\theta}
\right).
\end{equation}
Applying Cauchy-Schwartz with $1/p = \theta$ and $1/q = 1 - \theta$, noting that $1/p + 1/q = 1$, we obtain
\begin{align}
f(\theta \mathbf{x} + (1-\theta)\mathbf{y}) &\leq
\log \left(
\left( \sum_{i=1}^{N_{\text{classes}}}\exp(-x_i) \right)^\theta
\left( \sum_{i=1}^{N_{\text{classes}}}\exp(-y_i) \right)^{1-\theta}
\right)\\
&= \theta f(\mathbf{x}) + (1-\theta)f(\mathbf{y}).
\end{align}
Thus $f$, and therefore $\mathcal{L}_{\text{CE}} \circ \mathcal{F}_{\text{SM}}$ and $\mathcal{S}$, are convex. As a consequence, the Hessian $H$ of $\mathcal{S}$ with respect to $\mathbf{W}$ is a symmetric positive semi-definite function, allowing application of a convex optimizer in the following section to realize a global minimum.
\section{Algorithm} \label{sec:algo}
Application of the traditional Newton method to the problem \eqref{eq:fullLoss} would require solution of a dense matrix problem of size equal to the total number of parameters in the network. In contrast, we alternate between applying Newton's method to solve only for $\mathbf{W}$ in \eqref{eq:WLoss} and a single step of a gradient-based optimizer for the remaining parameters $\xi$; the Newton step therefore scales with the number of weights ($N_{\text{basis}}\times N_{\text{classes}}$) in the linear layer. Since $\mathcal{S}$ is convex,
Newton's method with appropriate backtracking or trust region may be expected to achieve a global minimizer. We pursue a simple backtracking approach, taking the step direction and size from standard Newton and repeatedly reducing the step direction until the Armijo condition is satisfied, ensuring an adequate reduction of the loss \citep{armijo1966minimization,dennis1996numerical}. For the gradient descent step we apply Adam \citep{kingma2014adam}, although one may apply any gradient-based optimizer; we denote such an update to the hidden layers for fixed $\mathbf{W}$ by the function $\text{GD}(\xi,\mathcal{B},\mathbf{W})$. To handle large data sets, stochastic gradient descent (GD) updates parameters using gradients computed over disjoint subsets $\mathcal{B} \subset \mathcal{D}$ \citep{bottou2010large}.
To expose the same parallelism, we apply our coordinate descent update over the same batches by solving \eqref{eq:WLoss} restricted to $\mathcal{B}$. Note that this implies an optimal choice of $\mathbf{W}$ over $\mathcal{B}$ only. We summarize the approach in Alg. \ref{thealg}.
\RestyleAlgo{plainruled}
\begin{algorithm}[t]
\KwData{batch $\mathcal{B}\subset \mathcal{D},\xi_{\text{old}},\mathbf{W}_{\text{old}},\alpha,\rho$}
\KwResult{$\xi_{\text{new}}, \mathbf{W}_{\text{new}}$}
\For{$j \in \{1,...,\texttt{\textup{newton\_steps}}\}$}{
Compute gradient $G = \nabla_{\mathbf{W}} S(\mathbf{W}_{\text{old}},\mathcal{B}) $ and Hessian $H = \nabla_{\mathbf{W}} \nabla_{\mathbf{W}} S(\mathbf{W}_{\text{old}},\mathcal{B})$ \;
Solve $H\bm{s} = -G$\;
$\mathbf{W}^{\dagger} \gets \mathbf{W}_{\text{old}} + \bm{s}$\;
$\lambda \gets 1$\;
\While{$S(\mathbf{W}^{\dagger},\mathcal{B}) > S(\mathbf{W}_{\textup{old}},\mathcal{B}) + \alpha \lambda G \cdot \bm{s}$}{
$\lambda \gets \lambda \rho$;\\
$\mathbf{W}^{\dagger} \gets \mathbf{W}_{\text{old}} + \lambda \bm{s}$\;
}
}
$\mathbf{W}_{\text{new}} \gets \mathbf{W}^\dagger$\;
${\xi}_{\text{new}} \gets \mathrm{GD}(\xi_{\text{old}},\mathcal{B},\mathbf{W}_{\text{new}})$\;
\caption{Application of coordinate descent algorithm for classification to a single batch $\mathcal{B}\subset \mathcal{D}$. For the purposes of this work, we use $\rho = 0.5$ and $\alpha = 10^{-4}$.}
\label{thealg}
\end{algorithm}
While $H$ and $G$ may be computed analytically from \eqref{eq:final_layers}, we used automatic differentiation for ease of implementation.
The system $H\bm{s} = -G$ can be solved using either a dense or an iterative method. Having proven convexity of $\mathcal{S}$ in \eqref{eq:WLoss}, and thus positive semi-definiteness of the Hessian, we may apply a conjugate gradient method. We observed that solving to a relatively tight residual resulted in overfitting during training, while running a fixed number $N_{cg}$ of iterations improved validation accuracy. Thus, we treat $N_{cg}$ as a hyperparameter in our studies below. We also experimented with dense solvers; due to rank deficiency we considered a pseudo-inverse of the form $H^\dagger = (H + \epsilon I)^{-1}$, where taking a finite $\epsilon>0$ provided similar accuracy gains. We speculate that these approaches may be implicitly regularizing the training. For brevity we only present results using the iterative approach; the resulting accuracy was comparable to the dense solver. In the following section we typically use only a handful of Newton and CG iterations, so the additional cost is relatively small.
We later provide convergence studies comparing our technique to GD using the Adam optimizer and identical batching. We note that a lack of optimized software prevents a straightforward comparison of the performance of our approach vs. standard GD; while optimized GPU implementations are already available for GD, it is an open question how to most efficiently parallelize the current approach. For this reason we compare performance in terms of iterations, deferring wall-clock benchmarking to a future work when a fair comparison is possible.
\section{Relation to previous works} \label{sec:literature}
We seek an extension of \citet{cyr2019robust}. This work used an adaptive basis perspective to motivate a block coordinate descent approach utilizing a linear least squares solver.
The training strategy they develop can be found under the name of variable projection, and was used to train small networks~\citep{mcloone1998hybrid,pereyra2006variable}.
In addition to the work in \citet{cyr2019robust}, the perspective of neural networks producing an adaptive basis has been considered by several approximation theorists to study the accuracy of deep networks \citep{yarotsky2017error,opschoor2019deep, daubechies2019nonlinear}. The combination of the adaptive basis perspective combined with the block coordinate descent optimization demonstrated dramatic increases in accuracy and performance in \citet{cyr2019robust}, but was limited to an $\ell_2$ loss. None of the previous works have considered the generalization of this approach to training deep neural networks with a cross-entropy loss typically used in classification as we develop here.
\citet{bottou2018optimization} provides a mathematical summary on the breadth of work on numerical optimizers used in machine learning.
Several recent works have sought different means to incorporate second-order optimizers to accelerate training and avoid issues with selecting hyperparameters and training schedules \citep{osawa2019large,osawa2020scalable,botev2017practical,martens2010deep}. Some pursue a quasi-Newton approach, defining approximate Hessians, or apply factorization to reduce the effective bandwidth of the Hessian \citep{botev2017practical,xu2019newton}. Our work pursues a (block) coordinate descent strategy, partitioning degrees of freedom into sub-problems amenable to more sophisticated optimization \citep{nesterov2012efficiency,wright2015coordinate,blondel2013block}. Many works have successfully employed such schemes in ML contexts (e.g. \citep{blondel2013block,fu1998penalized,shevade2003simple,clarkson2012sublinear}), but they typically rely on stochastic partitioning of variables rather than the partition of the weights of deep neural networks into hidden layer variables and their complement pursued here. The strategy of extracting convex approximations to nonlinear loss functions is classical \citep{bubeck2014convex}, and some works have attempted to minimize general loss functions by minimizing surrogate $\ell_2$ problems \citep{barratt2020least}.
\section{Results} \label{sec:results}
We study the performance and properties of the NGD algorithm as compared to the standard stochastic gradient descent (GD) on several benchmark problems with various architectures. We start by applying dense network architectures to classification in the peaks problem. This allows us to plot and compare the qualitative properties of the basis functions $\Phi_\alpha(\cdot,\xi)$
encoded in the hidden layer \eqref{eq:adapt-basis} when trained with the two methods. We then compare the performance of NGD and GD for the standard image classification benchmarks CIFAR-10, MNIST, and Fashion MNIST using both dense and convolutional (ConvNet) architectures. Throughout this section, we compare performance in terms of iterations of Alg. \ref{thealg} for NGD and iterations of stochastic gradient descent, each of which achieves a single update of the parameters $(\mathbf{W}, \xi)$ in the respective algorithm based on a batch $\mathcal{B}$; this is the number of epochs multiplied by the number of batches.
\subsection{Peaks problem} \label{sec:peaks}
The peaks benchmark is a synthetic dataset for understanding the qualitative performance of classification algorithms \citep{haber2017stable}. Here, a scattered point cloud in the two- dimensional unit square $[0,1]^2$ is partitioned into disjoint sets. The classification problem is to determine which of those sets a given 2D point belongs to.
The two-dimensional nature allows visualization of how NGD and GD classify data. In particular, plots of both how the nonlinear basis encoded by the hidden layer maps onto classification space and how the linear layer combines the basis functions to assign a probability map over the input space are readily obtained. We train a depth 4 dense network of the form \eqref{eq:architecture} with $N_{\text{in}} = 2$, three hidden layers of width 12 contracting to a final hidden layer of width $N_{\text{basis}} = 6$, with $\tanh$ activation and batch normalization, and $N_{\text{classes}} = 5$ classes.
As specified by \citet{haber2017stable}, $5000$ training points are sampled from $[0,1]^2$. The upper-left most image in Figure~\ref{fig:peaks2} shows the sampled data points with their observed classes. For the peaks benchmark we use a single batch containing all training points, i.e. $\mathcal{B} = \mathcal{D}$. The NGD algorithm uses $5$ Newton iterations per training step with $3$ CG iterations approximating the linear solve. The learning rate for Adam for both NGD and GD is $10^{-4}$.
\begin{figure}
\centering
\includegraphics[width=0.49\textwidth]{Images/levelset_train_accur-crop.pdf}
\includegraphics[width=0.49\textwidth]{Images/levelset_test_accur-crop.pdf}
\caption{The training (\textit{left}) and validation (\textit{right}) accuracy for the peaks problem for both gradient descent (GD) and the Newton/gradient descent (NGD) algorithm. The solid lines represent the mean of 16 independent runs, and the shaded areas represent the mean $\pm$ one standard deviation.}
\label{fig:peaks1}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=0.8\textwidth]{Images/Figure_1_yet_another_run_cropped.pdf}
\includegraphics[width=0.4\textwidth]{Images/Figure_2_yet_another_run_adjusted_cropped.pdf}
\hspace{0.05\textwidth}
\includegraphics[width=0.4\textwidth]{Images/Figure_4_yet_another_run_adjusted_cropped.pdf}
\includegraphics[width=0.4\textwidth]{Images/Figure_3_yet_another_run_adjusted_cropped.pdf}
\hspace{0.05\textwidth}
\includegraphics[width=0.4\textwidth]{Images/Figure_5_yet_another_run_adjusted_cropped.pdf}
\caption{Results for peaks benchmarks, with comparison between NGD and GD on an identical architecture. In this example, GD obtained a training accuracy of 99.3\% and validation accuracy of 96.2\%, while NGD obtained a training accuracy of 99.6\% and validation accuracy of 98.0\%. \textbf{Top:} Training data (\textit{left}), classification by GD (\textit{center}), and classification by NGD (\textit{right}). GD misclassifies large portions of the input space.
\textbf{Middle:} The linear and softmax layers combine basis functions to assign classification probabilities to each class. The sharp basis learned in GD leads to artifacts and attribution of probability far from the sets (\textit{left}) while diffuse basis in NGD provides a sharp characterization of class boundaries (\textit{right}).
\textbf{Bottom:} Adaptive basis encoded by hidden layer, as learnt by GD (\textit{left}) and NGD (\textit{right}). For GD the basis is sharp, and individual basis functions conform to classification boundaries, while NGD learns a more regular basis. }
\label{fig:peaks2}
\end{figure}
Figure \ref{fig:peaks1} demonstrates that for an identical architecture, NGD provides a rapid increase in both training and validation accuracy over GD after a few iterations. For a large number of iterations both approaches achieve comparable training accuracy, although NGD generalizes better to the validation set.
The improvement in validation accuracy is borne out in Figure \ref{fig:peaks2}, which compares representative instances of training using GD and NGD.
While a single instance is shown, the character of these results is consistent with other neural networks trained for the Peaks problem in the same way.
The top row illustrates the predicted classes $\text{argmax } [\mathcal{F}_{\text{SM}}(\mathbf{x})] \in \{0,1,2,3,4\}$ for $\mathbf{x} \in [0,1]^2$ and the training data, demonstrating that
the NGD-trained network predicts the class $i=2$ of lowest training point density more accurately than the GD-trained network.
The remaining sets of images visualize both the classification probability map $[\mathcal{F}_{\text{SM}}(\mathbf{x})]_i$ for $i \in \{0,1,2,3,4\}$ (middle row) and the six basis functions $\Phi_\alpha(\mathbf{x}, \xi)$ (bottom row) learned by each optimizer.
The difference in the learned bases is striking.
GD learns a basis that is nearly discontinuous, in which the support of each basis function appears fit to the class boundaries. On the other hand, NGD learns a far smoother basis that can be combined to give sharper class boundary predictions.
This manifests in the resulting probability map assigned to each class; linear combinations of the rougher GD basis results in imprinting and assignment of probability far from the relevant class.
This serves as an explanation of the improved validation accuracy of NGD as compared to GD despite similar final training accuracy.
The NGD algorithm separates refinement of the basis from the determination of the coefficients. This provides an effective regulation of the final basis, leading to improved generalization.
\subsection{Image recognition benchmarks}
We consider in this section a collection of image classification benchmarks: MNIST \citep{deng2012mnist,grother1995nist}, fashion MNIST \citep{xiao2017fashion}, and CIFAR-10 \citep{krizhevsky2009learning}. We focus primarily on CIFAR-10 due to its increased difficulty;
it is well-known that one may obtain near-perfect accuracy in the MNIST benchmark without sophisticated choice of architecture.
For all problems, we consider a simple dense network architecture to highlight the role of the optimizer, and for CIFAR-10 we also utilize convolutional architectures (ConvNet). This highlights that our approach applies to general hidden layer architectures. Our objective is to demonstrate improvements in accuracy due to optimization with all other aspects held equal. For CIFAR-10, for example, the state-of-the-art requires application of techniques such as data-augmentation and complicated architectures to realize good accuracy; for simplicity we do not consider such complications to allow a simple comparison. The code for this study is provided at \url{github.com/rgp62/}.
For all results reported in this section, we first optimize the hyperparameters listed in Table~\ref{tab:parameters} by maximizing the validation accuracy over the training run. We perform this search using the Gaussian process optimization tool in the scikit-optimize package with default options \citep{scikitopt}. This process is performed for both GD and NGD to allow a fair comparison. The ranges for the search are shown in Table~\ref{tab:parameters} with the optimal hyperparameters for each dataset examined in this study. For all problems we partition data into training, validation and test sets to ensure hyperparameter optimization is not overfitting. For MNIST and fashion MNIST we consider a $50K/10K/10K$ partition, while for CIFAR-10 we consider a $40K/10K/10K$ partition. All training is performed with a batch size of $1000$ over $100$ epochs. For all results the test accuracy falls within the first standard deviation error bars included in Figures \ref{fig:three_sets} and \ref{fig:convnet}.
Figure~\ref{fig:three_sets} shows the training and validation accuracies using the optimal hyperparameters for a dense architecture with two hidden layers of width 128 and 10 and ReLU activation functions. We find for all datasets, NGD more quickly reaches a maximum validation accuracy compared to GD, while both optimizers achieve a similar final validation accuracy. For the more difficult CIFAR-10 benchmark, NGD attains the maximum validation accuracy of GD in roughly one-quarter of the number of iterations.
In Figure~\ref{fig:convnet}, we use the CIFAR-10 dataset to compare the dense architecture to the following ConvNet architecture,
\begin{equation*}
\begin{aligned}
&\underset{\textrm{8 channels, 3x3 kernel}}{\textrm{Convolution}} \rightarrow \underset{\textrm{2x2 window}}{\textrm{Max Pooling}} \rightarrow \underset{\textrm{16 channels, 3x3 kernel}}{\textrm{Convolution}} \\
& \rightarrow \underset{\textrm{2x2 window}}{\textrm{Max Pooling}} \rightarrow \underset{\textrm{16 channels, 3x3 kernel}}{\textrm{Convolution}} \rightarrow \underset{\textrm{width 64}}{\textrm{Dense}} \rightarrow \underset{\textrm{width 10}}{\textrm{Dense}}
\end{aligned}
\end{equation*}
where the convolution and dense layers use the ReLU activation function. Again, NGD attains the maximum validation accuracy of GD in one-quarter the number of iterations, and also leads to an improvement of 1.76\% in final test accuracy. This illustrates that NGD accelerates training and can improve accuracy for a variety of architectures.
\begin{table}
\begin{center}
\begin{tabular}{ c|c|c|c|c|c }
Hyperparameter & range & MNIST & Fashion & CIFAR-10 & CIFAR-10 \\
& & & MNIST & & ConvNet \\
\hline
& & & & \\
Learning rate & $[10^{-8},10^{-2}]$ & $10^{-2.81}$ & $10^{-3.33}$ & $10^{-3.57}$ & $10^{-2.66}$ \\
& & $10^{-2.26}$ & $10^{-2.30}$ & $10^{-2.50}$ & $10^{-2.30}$ \\
\hline
Adam decay & $[0.5,1]$ & $0.537$ & $0.756$ & $0.629$ & $0.755$ \\
parameter 1 & & $0.630$ & $0.657$ & $0.891$ & $0.657$ \\
\hline
Adam decay & $[0.5,1]$ & $0.830$ & $0.808$ & $0.782$ & $0.858$ \\
parameter 2 & & $0.616$ & $0.976$ & $0.808$ & $0.976$ \\
\hline
CG iterations & $[1,10]$ & $3$ & $1$ & $2$ & $2$ \\
\hline
Newton iterations & $[1,10]$ & $6$ & $5$ & $4$ & $7$ \\
\end{tabular}
\end{center}
\caption{Hyperparameters varied in study (\textit{first column}), ranges considered (\textit{second column}), and optimal values found for MNIST (\textit{third column}), Fashion MNIST (\textit{fourth column}), CIFAR-10 (\textit{fifth column}), and CIFAR-10 with the ConvNet architecture (\textit{last column}). For the learning rate and the Adam decay parameters, the optimal values for NGD followed by GD are shown. The optimal CG and Newton iterations are only applicable to NGD.}
\label{tab:parameters}
\end{table}
\begin{figure}
\centering
\includegraphics[width=1\textwidth]{Images/three_sets_cropped.pdf}
\caption{Training accuracy (\textit{top row}) and validation accuracy (\textit{bottom row}) for CIFAR-10, Fashion MNIST, and MNIST datasets. Mean and standard deviation over 10 training runs are shown.}
\label{fig:three_sets}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=5in]{Images/cifar_convnet_cropped.pdf}
\caption{Training accuracy (\textit{left}) and validation accuracy (\textit{right}) for ConvNet architectures. Mean and standard deviation over 10 training runs are shown.}
\label{fig:convnet}
\end{figure}
\section{Conclusions}
The NGD method, motivated by the adaptive basis interpretation of deep neural networks, is a block coordinate descent method for classification problems. This method separates the weights of the linear layer from the weights of the preceding nonlinear layers. NGD uses this decomposition to exploit the convexity of the cross-entropy loss with respect to the linear layer variables. It utilizes a Newton method to approximate the global minimum for a given batch of data before performing a step of gradient descent for the remaining variables. As such, it is a hybrid first/second order optimizer which extracts significant performance from a second-order substep that only scales with the number of weights in the linear layer, making it an appealing and feasible application of second-order methods for training very deep neural networks. Applying this optimizer to dense and convolutional networks, we have demonstrated acceleration with respect to the number of epochs in the validation loss for the peaks, MNIST, Fashion MNIST, and CIFAR-10 benchmarks, with improvements in accuracy for peaks benchmark and CIFAR-10 benchmark using a convolutional network.
Examining the basis functions encoded in the hidden layer of the network in the peaks benchmarks revealed significant qualitative difference between NGD and stochastic gradient descent in the exploration of parameter space corresponding to the hidden layer variables. This, and the role of the tolerance in the Newton step as an implicit regularizer, merit further study.
The difference in the regularity of the learned basis and probability classes suggests that one may obtain a qualitatively different model by varying only the optimization scheme used. We hypothesize that this more regular basis may have desirable robustness properties which may effect resulting model sensitivity. This could have applications toward training networks to be more robust against adversarial attacks.
\begin{ack}
Sandia National Laboratories is a multimission laboratory managed and operated by National Technology and Engineering Solutions of Sandia, LLC, a wholly owned subsidiary of Honeywell International, Inc., for the U.S. Department of Energy’s National Nuclear Security Administration under contract {DE-NA0003525}. This paper describes objective technical results and analysis. Any subjective views or opinions that might be expressed in the paper do not necessarily represent the views of the U.S. Department of Energy or the United States Government. SAND Number: {SAND2020-6022 J}.
The work of R. Patel, N. Trask, and M. Gulian are supported by the U.S. Department of Energy, Office of Advanced Scientific Computing Research under the Collaboratory on Mathematics and Physics-Informed Learning Machines for Multiscale and Multiphysics Problems (PhILMs) project. E. C. Cyr is supported by the Department of Energy early career program. M. Gulian is supported by the John von Neumann fellowship at Sandia National Laboratories.
\end{ack}
\bibliographystyle{abbrvnat}
| {'timestamp': '2020-06-19T02:02:36', 'yymm': '2006', 'arxiv_id': '2006.10123', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10123'} | arxiv |
\section{Introduction}\label{sec:intro}
Bitcoin is designed to be a peer-to-peer electronic cash system, introducing an innovative consensus mechanism and incentives for participants.
All participants in the consensus protocol must run a full node.
Bitcoin has inspired hundreds of cryptocurrencies utilizing blockchain technology to serve as a decentralized means of transferring crypto-assets.
There were 98 cryptocurrencies introduced in 2016, 412 introduced in 2017, and 726 introduced in 2018.
Given that Bitcoin's codebase~\cite{bitcoin-codebase} is publicly available, developers may easily fork its repository from GitHub and make custom modifications, which they might later publish as their own cryptocurrency.
In this way, many cryptocurrencies might become popular and adopted by the public.
However, many cryptocurrencies are also ``popular'' due to various high profile security incidents~\cite{SRA-homoliak,bonneau2015sok,wang2018survey,conti2018survey}.
Detecting and patching the vulnerabilities manually is prohibitively costly.
Due to the decentralized nature of cryptocurrencies, whenever a patch is created, individual miners have to patch their own nodes independently.
In the case of the inflation bug in Bitcoin, the vulnerability was fixed by only 31.65\% of all nodes~\cite{inflation-bug-after} even after a full year from the disclosure.\footnote{Note that as of $30^{th}$ September 2020, the ratio of updated nodes is even worse and is equal to 14.42\%. See \url{https://luke.dashjr.org/programs/bitcoin/files/charts/security.html?201817144}.}
The inflation bug~\cite{inflation-bug} was discovered in September 2018 and allowed the inflation of the total Bitcoin supply.
Upon analysis, it was found that this vulnerability had been present since 2017 but has been patched only in 2019.
Nevertheless, this vulnerability is shared by 31 cryptocurrencies that emerged as modifications of Bitcoin clones.
Patching the vulnerability across all such cryptocurrencies is of paramount importance for their financial stability.
\begin{figure}[t]
\centering
\vspace{0.1cm}
\includegraphics[width=0.32\textwidth]{img/histogram.png}
\caption{A histogram of forked projects from Bitcoin and their clone ratios as compared to Bitcoin v0.17.0.}
\label{fig:histogram}
\vspace{-0.4cm}
\end{figure}
Our empirical study shows that 786 cryptocurrencies were directly or indirectly forked from a version of Bitcoin.
\autoref{fig:histogram} depicts the histogram of code similarity (i.e., clone ratio) of cryptocurrencies against the Bitcoin codebase.
In most of the cases, the clone ratio is below 30\%; however, some of them have this ratio even higher than $50\%$.
Therefore, once a vulnerability is discovered in one cryptocurrency, the vulnerability is very likely to be propagated among its clones.
Editing cloned codebases is a common phenomenon in software engineering and maintenance.
Nevertheless, the popularity of forking codebases of cryptocurrencies makes the problem unique in that:
(1) the clones are spread across a vast number of projects, which makes overall clone management difficult,
(2) the code among cryptocurrency projects is of high similarity, and
(3) the financial impact of neglecting a propagated vulnerability might be extremely costly.
In this work, we propose \textsc{CoinWatch}\xspace ($\mathcal{CW}$\xspace), a clone-based approach that indicates propagated vulnerabilities across cryptocurrencies.
At the input, $\mathcal{CW}$\xspace takes the code fragment relevant to a known vulnerability in a \textit{target} cryptocurrency and the code repositories of \textit{monitored} cryptocurrencies.
First, $\mathcal{CW}$\xspace analyzes when the vulnerability of the target cryptocurrency was introduced within its incremental code history (e.g., Git).
Next, $\mathcal{CW}$\xspace goes through the suspicious cryptocurrencies and infers whether they were forked before the vulnerability was introduced.
In the positive case, $\mathcal{CW}$\xspace conducts clone detection to find out whether the given vulnerability has been already fixed and if not it reports a warning.
We have built a proof-of-concept tool for $\mathcal{CW}$\xspace, which to the date scans 1094 cryptocurrencies and compares them to Bitcoin, serving as the target cryptocurrency.
For evaluation purposes, we selected the top four cryptocurrency-oriented CVEs in terms of severity.
In sum, $\mathcal{CW}$\xspace reported 786 propagated vulnerabilities across 384 cryptocurrencies, achieving a true positive rate of 89.7\%.
We notified the developers of affected cryptocurrencies and reported vulnerabilities found to NVD NIST.
In turn, we obtained 4 CVE extensions:
\textbf{CVE-2018-17144}, \textbf{CVE-2016-10724}, \textbf{CVE-2016-10725}, and \textbf{CVE-2019-7167}, which are described at \url{https://github.com/JinBean/CVE-Extension/}.
\section{An Illustrating Example} \label{sec:example}
In this section, we illustrate how $\mathcal{CW}$\xspace works while taking CVE-2018-17144 as an example.
\lstset{
basicstyle=\tiny\ttfamily\scriptsize,
breaklines=true,
frameround=tttt,
frame=trBL,
basewidth=0.5em,
linewidth=0.98\columnwidth,
tabsize=2,
showstringspaces=false,
escapeinside={<@}{@>},
}
\subsection{CVE-2018-17144 Explained}
This vulnerability is a result of \textit{reachable assertion} weakness CWE-617~\cite{CWE-617}, and it enables the crashing of any node in the network by crafting a transaction that double spends (see \autoref{tbl:double_propagation_a}), which causes a DoS of all nodes that receive a mined block containing such a transaction.
The vulnerability was fixed in Bitcoin release 0.16.3 on Sep 18, 2018.
We depict the vulnerable period of this vulnerability across various Bitcoin clones in \autoref{tbl:affected_coins_time}.
\begin{figure}[b]
\vspace{-13pt}
\centering
\includegraphics[width=0.46\textwidth]{img/doublespend1.png}
\caption{Propagated code of DoS vulnerability (CVE-2018-17144).}
\label{tbl:double_propagation_a}
\vspace{-0.1cm}
\end{figure}
\subsection{Using \textsc{CoinWatch}\xspace}
Given the CVE description and details about a vulnerability, the codebase of the target cryptocurrency (i.e., Bitcoin) is analyzed for the specific code segments causing the vulnerability:
\begin{compactenum}
\item the bug-fixing commit (b8f8019) is identified in GitHub,
\item the bug-introducing commits (eecffe5, 5083079, 3533fb4) are identified in GitHub,
\item the first cut of potentially vulnerable cryptocurrencies is generated based on the fork dates of input candidates.
\end{compactenum}
Hence, if a cryptocurrency was created before the bug-introducing commits in its ``parent,'' it is unlikely that it will contain the bug.
In the next step of $\mathcal{CW}$\xspace, the code segment that patches the vulnerability is identified.
Given this information, $\mathcal{CW}$\xspace performs a test using clone detection to check for the existence of the vulnerable code (and the fix) within all monitored cryptocurrencies.
The results mark vulnerable cryptocurrencies: they contain the code with the vulnerability but not the fix.
\begin{table}[t]
\vspace{0.3cm}
\footnotesize
\begin{tabular}{r c c}
\toprule
\textbf{Cryptocurrency} & \textbf{Timeframe (MM/DD)} & \textbf{Months Vulnerable} \\ \midrule
Argentum & 12/16-11/18 & 23 \\
Chaincoin & 12/16-10/18 & 22 \\
CreativeCoin & 12/16-11/18 & 23 \\
DigiByte & 12/16-9/18 & 21 \\
EliCoin & 2/18-11/18 & 9 \\
Irlecoin & 6/18-present & not fixed \\
Litecoin & 12/16-9/18 & 21 \\
Lynx & 12/6-10/18 & 22 \\
Machinecoin & 4/17-10/18 & 18 \\
MatrixCoin & 12/16-10/18 & 22 \\
Methuselah & 4/18-10/18 & 6 \\
MinexCoin & 7/17-4/19 & 21 \\
MktCoin & 10/17-present & not fixed \\
PlatinCoin & 7/18-2/20 & 19 \\
Quasarcoin & 11/17-present & not fixed \\
United Bitcoin & 12/16-9/18 & 21 \\
Unitus & 4/17-11/18 & 19 \\
\bottomrule
\end{tabular}
\caption{Vulnerable period of CVE-2018-17144 across Bitcoin clones.}
\label{tbl:affected_coins_time}
\vspace{-0.4cm}
\end{table}
\subsection{Applying $\mathcal{CW}$\xspace on CVE-2018-17144}
The full detection process consists of scanning the codebase of all monitored cryptocurrencies (1094) from our dataset while searching for the code that causes the vulnerability.
On completion, $\mathcal{CW}$\xspace reports a candidate set of \textit{suspicious} cryptocurrencies that might be vulnerable with a high likelihood.
\myparagraph{\textbf{PigeonCoin}}
On 26 September 2018, PigeonCoin was attacked~\cite{pigeoncoin-hack} due to CVE-2018-17144, resulting in a loss of 235 million PGN (i.e., \$15,000 USD).
The fix~\cite{pigeoncoin-fix} of the vulnerability was only uploaded to their GitHub repository on 27 September 2018: 9 days after it was added to Bitcoin.
If $\mathcal{CW}$\xspace had monitored the PigeonCoin, the vulnerability would be discovered and fixed before its exploitation.
\section{\textsc{CoinWatch}\xspace}\label{sec:approach}
\begin{figure*}[t]
\centering
\fontsize{7}{10}\selectfont
\includegraphics[scale=0.75]{img/process_overall.pdf}
\caption{Overview of \textsc{CoinWatch}\xspace.}\label{tbl:workflow}
\vspace{-0.4cm}
\end{figure*}
\subsection{Overview}
The overall workflow of $\mathcal{CW}$\xspace is shown in \autoref{tbl:workflow}.
First, a target CVE~\cite{cve} is provided at input together with data publicly obtainable from its structured details.
After picking a target CVE, $\mathcal{CW}$\xspace performs a code evolution analysis of the parent project to obtain bug fixing and bug introducing commits.
The bug introducing and fixing commits are then manually annotated to minimize the code responsible for the vulnerability and the fix, respectively.
Then, $\mathcal{CW}$\xspace generates a detection test for a clone detector.
Before running the clone detector, the list of monitored projects is filtered based on the date of the fork to narrow down the search space by pruning unrelated and unaffected projects.
Then, at the heart of $\mathcal{CW}$\xspace is the clone detector, which, given the filtered codebases of monitored cryptocurrencies, identifies and reports cloned projects that are likely to be affected by the vulnerability.
\begin{algorithm}[b]
\small
\caption{An extended SZZ algorithm.}\label{fig:SZZ}
\SetAlgoLined
\LinesNumbered
\SetKwInOut{Input}{Input}
\SetKwInOut{Output}{Output}
\Input{~$I$: Issues that match criteria}
\Input{~$S$: Regex string}
\Output{~$G_b := \emptyset$: Git commits with bugs}
\Output{~$G_f := \emptyset$: Git commits with fixes}
\ForEach {i in $I$}{
\ForEach {$c$ in i.commits}{
$G_f$ := $G_f ~\cup~$ RE.match($S$, $c$)}{
}
}
\ForEach{cf in $G_f$}{
$G_b$ := $G_b ~\cup~$ getPrevCommits(cf)\;
}
\Return $G_f, G_b$
\medskip
\end{algorithm}
\subsection{Details}
\myparagraph{\textbf{CVE Parsing}}
After a new vulnerability in the parent project is reported, the $\mathcal{CW}$\xspace triggers its execution.
First, $\mathcal{CW}$\xspace parses the input CVE and extracts details about CVE:
(1) the date of publishing,
(2) keywords from the description using a text mining for short texts~\cite{carretero2013improving},
(3) external links pointing to resources of the version control system (e.g., issues, pull requests, release notes),
and (4) the list of cryptocurrencies affected by the CVE along with the programming language they were written in.
Then, $\mathcal{CW}$\xspace performs a check whether the vulnerability is dependent on the code specific to the cryptocurrency since some vulnerabilities may originate from used underlying protocols (e.g., TLS).
Finally, the software release versions corresponding to the bug and the fixes are extracted using web scrapping techniques and utilized for a code evolution analysis that takes into account the incremental code history of a project.
\myparagraph{\textbf{Code Evolution Analysis}}
$\mathcal{CW}$\xspace uses the code evolution of a target project (e.g., Bitcoin) to discover the commit IDs containing both the fix and the bug.
$\mathcal{CW}$\xspace sets the entry point as the release date of the vulnerability and proceeds back in time while iterating over the issues, until it links the fixing commit(s) with the input CVE.
To track down the commit ID, $\mathcal{CW}$\xspace utilizes the SZZ algorithm proposed by \textbf{S}liwerski, \textbf{Z}immermann, and \textbf{Z}eller~\cite{sliwerski2005changes}.
SZZ algorithm was developed as an approach to identify bug-introducing commits in a software repository.
By leveraging on the issue-tracking system of GitHub, we improve the accuracy using the \textit{git-blame} command for finding the bug-introducing commits.
An open implementation of the SZZ algorithm called \textit{SZZ Unleashed}~\cite{borg2019szz} provides insight on how to apply it in practice.
\begin{algorithm}[b]
\small
\SetAlgoLined
\LinesNumbered
\SetKwInOut{Input}{Input}
\SetKwInOut{Output}{Output}
\Input{$V_c$: set of monitored projects}
\Input{$G_b, G_f$: bug-introducing and fixing commits}
\Output{$V_{vuln}$: set of potentially vulnerable projects}
\ForEach {$p$ in $V_c$}{
\If{$p.repoForkDate \geq minDate(G_b)$\ $\wedge $\ $p.repoForkDate \leq maxDate(G_f)$}{
$V_{vuln} := V_{vuln} ~\cup~ p$\;
}
}
\Return $V_{vuln}$
\medskip
\caption{Initial filtering of monitored projects.}\label{fig:pseudocode}
\end{algorithm}
In this work, we built on the SZZ algorithm and extend it for our purpose to identify bug-fixing and bug-introducing commits.
Using regular expression matching (lines 1 to 5 of \autoref{fig:SZZ}, we search through all issues that have been fixed, resolved, closed, or labeled as a "bug".
$\mathcal{CW}$\xspace uses keywords such as "CVE", "CVE-ID" and extracted keywords from the CVE details as the string pattern for regular expression matching.
This allows $\mathcal{CW}$\xspace to locate the bug-fixing commits, which are stored at $G_f$.
To find the bug-introducing commit $G_b$, $\mathcal{CW}$\xspace uses git-blame functionality, which annotates the line of code with information from the revision that modified the line as the last one (i.e., \textit{getPrevCommits()}).
We emphasize that $\mathcal{CW}$\xspace takes a conservative approach to pick the oldest date for the bug-introducing commit and the newest date for the bug-fixing commit.
This method allows us to track down both bug-introducing and bug-fixing commits, with which we can estimate the time-frame of the presence of the bug in any codebase.
We use this time-frame as a window representing its propagation within a project that was created by forking the target project.
\myparagraph{\textbf{Identification of Vulnerable Code}}
After obtaining bug fixing and bug introducing commits, $\mathcal{CW}$\xspace requires manual annotation of the code in these commits (i.e., the code responsible for the vulnerability and the fix).
This requires understanding the cause of the vulnerability; however, this manual effort is only a one-time action (per vulnerability), while all monitored projects are checked automatically later.
Next, $\mathcal{CW}$\xspace transforms the annotated code to a detection test suitable for a clone detector.
\myparagraph{\textbf{Filtering of Monitored Projects}}
We provide a simple method for the initial filtering of monitored cryptocurrencies in \autoref{fig:pseudocode}, which is based on the timestamp of forking these projects from the parent project.
Letting $V_c$ be the set of monitored cryptocurrency projects, if $p \in V_c$ is created after $G_b.date$ and before $G_f.date$, we consider $V_c$ for further analysis.
Otherwise, if the repository of $p$ was created before the bug was introduced or after the bug was fixed, we ignore this case since the bug had not existed at the time of forking the project.
The list of candidate projects forms our first cut of potentially vulnerable projects.
\autoref{fig:pseudocode} uses the output of \autoref{fig:SZZ} to identify the dates when the vulnerability was created and presented until by checking the timestamps associated with the particular commit IDs.
\myparagraph{\textbf{Detection Process}}
Finally, using the generated detection tests, $\mathcal{CW}$\xspace applies the clone detector to find clones of the parent project in the monitored list of cryptocurrencies, which are then analyzed using $G_f$ and $G_b$ to indicate such cloned projects that are potentially vulnerable.
\section{Implementation} \label{sec:implementation}
\myparagraph{\textbf{Experiment Setup}}
All the experiments we performed ran on the machine with a quad-core i7-7500U CPU clocked at 2.70GHz and equipped with 16 GB of memory.
We conducted a simulation experiment where we applied $\mathcal{CW}$\xspace on the versions of projects dating before the version where the vulnerability was disclosed.
The simulation experiment evaluated whether some cryptocurrencies might have been fixed earlier if our approach has been adopted.
To instantiate a clone detector, we chose Simian~\cite{Simian}, a similarity analyzer that identifies duplication in C++ code as well as other tools that use text-based string comparison to identify type I clones.
The Type I clones represent the situation when code fragments in a particular code-base are the same, omitting the comments and indentations~\cite{roy2014vision},~\cite{roy2009detection}.
Note that Type II clones are syntactically similar code fragments, which are usually created from Type I clones by renaming variable names or modifying data types.
Finally, Type III clones are created due to additions, deletions, or modifications of code fragments in Type I or Type II clones.
\lstset{
language=XML,
keywordstyle=\color{red},
morekeywords={encoding, lineCount, sourceFile, processingTime},
linewidth=56em,
xleftmargin=.03\textwidth,
}
\begin{figure*}[h]
\vspace{0.5cm}
\centering
\fontsize{9}{1}
\selectfont
\lstinputlisting{code/simianXML.txt}
\caption{An example of XML output from Simian.}
\label{tbl:simian_output}
\vspace{-0.3cm}
\end{figure*}
\myparagraph{\textbf{Testing Simian}}
Before we conducted any clone detection experiment, we first ran a test to verify that Simian is capable of accurate detection of cloned code within the full code structure.
Therefore, we performed a positive test and compared a cloned repository of Bitcoin-0.17 with a portion of its own code. This identified the correct file and line numbers of the entire code snippet.
We then performed a negative test with a code that did not exist within Bitcoin-0.17.
We found that to minimize false positives, we had to set the code line threshold to the exact length of each snippet of vulnerable code.
This ensures that only cryptocurrencies containing the full code causing the vulnerability are detected.
However, doing so increased the chance of false negatives; due to the time-sensitive nature of cryptocurrencies and a large attack surface, we adopted this setting since it is more important to detect truly vulnerable projects than to miss potentially vulnerable ones.
\myparagraph{\textbf{Identifying Vulnerable Code}}
Using the CVE database specific to Bitcoin~\cite{BitcoinVulnerabilities} (i.e., the parent project), we reviewed Bitcoin's CVEs to select vulnerabilities that are contained in its codebase versions in the range $\langle 2016, 2018 \rangle$, a time frame where many alternative cryptocurrencies were created.
Once a CVE was selected for analysis, $\mathcal{CW}$\xspace searched for the bug fixing and bug introducing commits.
Then, we manually annotated the code segments of these commits, which are related to the vulnerability and the fix, based on which, $\mathcal{CW}$\xspace generated detection tests for Simian.
Next, $\mathcal{CW}$\xspace parsed information from the Bitcoin version where the vulnerability was introduced in and the version it was eventually fixed at.
\myparagraph{\textbf{Clone Detection in Monitored Projects}}
We wrote Python scripts that scraped \textit{coingecko.com} to collect a dataset of the names of all existing cryptocurrencies, the link of their GitHub repositories, and the language that the cryptocurrency was written in.
Out of the 1970 cryptocurrencies that we had, 43 were listed with a broken GitHub link or were just links to websites.
We then used Git to clone all valid repositories.
Since we wanted to identify vulnerabilities from Bitcoin clones, we removed all cryptocurrencies that had not used C++.
We were then left with 1094 cryptocurrencies.
The folder structure for the analysis is comprised of one main folder, which we will call the \textit{comparison folder}.
Inside the \textit{comparison folder} were two more folders; the first containing the vulnerable code and the second containing the code of the cryptocurrency we wanted to compare against.
Python scripts were used to automate the moving of the code from our database into the comparison folder, running the Simian clone detection, and then moving the code back.
This was done iteratively for each cryptocurrency in the database.
Simian produced an XML file after every iteration containing the results of the clone detection.
The XML file contains the file path of each detected clone, the number of lines detected, and the processing time, as seen in \autoref{tbl:simian_output}.
Another script then ran to parse each of the Simian outputs, which gave us the list of suspicious vulnerable cryptocurrencies.
To support the validity of our methodology, we also experimented with Zcash (and its CVEs) serving as a parent project (see vulnerability CVE-2019-7167).
\myparagraph{\textbf{Responsible Disclosure}}
Finally, before disclosing vulnerabilities in the cloned projects, we filed 4 CVE extensions with MITRE.
Once the CVEs were accepted, we informed the developers of these projects about the vulnerability and the fix recommended in the CVE description.
\section{Evaluation} \label{sec:evaluation}
We evaluated $\mathcal{CW}$\xspace through various experiments.
The experiments were designed to answer the following research questions (RQs):
\begin{compactitem}
\item \textbf{RQ1}: Are clones prevalent in cryptocurrencies?
\item \textbf{RQ2}: Can we accurately detect propagated vulnerabilities through clones?
\item \textbf{RQ3}: Are the propagated vulnerabilities real problems?
\end{compactitem}
\smallskip\noindent
RQ1 examines our hypothesis, i.e., clones are prevalent in cryptocurrencies, and therefore identifying vulnerabilities by tracking clones is an important problem.
RQ2 evaluates the accuracy of our approach.
RQ3 is designed to question the usefulness of $\mathcal{CW}$\xspace in practice and reports on true positive and false positive rates.
\subsection{RQ1: Clone Prevalence}
To answer RQ1, we systematically applied $\mathcal{CW}$\xspace to the latest versions of the cryptocurrencies within our dataset scraped from Coingecko as of October 2018.\footnote{https://www.coingecko.com/en}
In total, there were initially 2079 cryptocurrencies as of Oct 2018, and 4389 cryptocurrencies as of Apr 2019.
We note that a large number of new cryptocurrencies were created in this short period of time.
There are also different types of cryptocurrencies; e.g, 2431 of them are ERC-20 tokens~\cite{EthereumEIP20}, which we consider as out-of-scope.\footnote{Note that ERC-20 tokens are built on the Ethereum platform and contain a standardized smart contract code that is parametrized by particular tokens.}
Out of the remaining 2079 cryptocurrencies that we scraped, 1094 cryptocurrencies are written in C++, the same programming language as Bitcoin is written in.
The breakdown of the remaining cryptocurrencies can be found in \autoref{tbl:coin_language}.
\begin{table}[b]
\footnotesize
\centering
\begin{tabular}{r c} \toprule
\textbf{Language} & \textbf{The Number of Projects} \\
\midrule
C++ & 1094 \\
Javascript & 334 \\
C & 65 \\
Go & 65 \\
Python & 36 \\
Java & 30 \\
Others & 455 \\
\bottomrule
\end{tabular}
\caption{Distribution of programming languages across cryptocurrencies considered in our work.}
\label{tbl:coin_language}
\end{table}
\setlength{\tabcolsep}{4.2pt}
\begin{table*}[t]
\vspace{0.3cm}
\centering
\footnotesize
\begin{tabular}{r r c c c c c c c} \toprule
\textbf{Cryptocurrency} & \textbf{LOC} & \textbf{Bitcoin 0.17.0} & \textbf{Bitcoin 0.16.3} & \textbf{Bitcoin 0.15.2} & \textbf{Bitcoin 0.14.2} & \textbf{Bitcoin 0.13.2} & \textbf{Bitcoin 0.12.0} & \textbf{Bitcoin 0.11.2} \\ \midrule
Bitcoin Cash & 68,545 & 26.0\% & 32.2\% & \textbf{34.2\%} & 27.3\% & 20.3\% & 17.2\% & 13.1\% \\
Bitcoin Diamond & 51,102 & 55.6\% & 70.2\% & 77.2\% & \textbf{98.1\%} & 73.6\% & 56.2\% & 42.3\% \\
DogeCoin & 38,073 & 33.2\% & 40.8\% & 43.9\% & 55.2\% & 67.1\% & 77.5\% & \textbf{91.6\%} \\
Monero & 57,232 & 0.0\% & 0.0\% & 0.0\% & 0.0\% & 0.0\% & 0.0\% & 0.0\% \\
Zcash & 51,509 & 21.1\% & 24.4\% & 25.1\% & 33.8\% & \textbf{42.2\%} & 46.0\% & 40.7\% \\
Dash & 65,104 & 40.24\% & 47.23\% & 52.52\% & \textbf{63.93\%} & 46.25\% & 38.62\% & 28.64\% \\
DigiByte & 63,769 & \textbf{90.90\%} & 69.32\% & 60.81\% & 42.02\% & 30.94\% & 24.14\% & 18.85\% \\
Electroneum & 37,040 & 0.00\% & 0.00\% & 0.00\% & 0.00\% & 0.00\% & 0.00\% & 0.00\% \\
EOS & 96,066 & 0.00\% & 0.00\% & 0.00\% & 0.00\% & 0.00\% & 0.00\% & 0.00\% \\
Litecoin & 57,014 & 76.73\% & \textbf{98.17\%} & 86.11\% & 58.55\% & 43.75\% & 33.27\% & 25.83\% \\
Nano & 26,987 & 0.00\% & 0.00\% & 0.00\% & 0.00\% & 0.00\% & 0.00\% & 0.00\% \\
Qtum & 112,867 & 37.52\% & \textbf{48.18\%} & 42.68\% & 28.82\% & 21.48\% & 16.30\% & 12.68\% \\
Ravencoin & 62,200 & 63.33\% & 81.09\% & \textbf{82.41\%} & 55.93\% & 41.22\% & 31.45\% & 24.27\% \\
Steem & 108,561 & 0.01\% & 0.02\% & 0.02\% & 0.02\% & 0.02\% & 0.02\% & \textbf{0.07\%}
\\ \bottomrule
\end{tabular}
\caption{Percentage of cloned code as compared to various Bitcoin versions.}
\label{tbl:percentage_compare}
\end{table*}
As we conjecture that these cryptocurrencies are clones of various versions of Bitcoin, using $\mathcal{CW}$\xspace, we systematically apply Simian to compare each of these cryptocurrencies with different versions of Bitcoin.
Part of the results are summarized in \autoref{tbl:percentage_compare}, where the second column shows the overall number of lines of code (LOC) in the project and the following columns show the clone ratio of each cryptocurrency in respect to different versions of Bitcoin.
The clone ratio is defined as follows:
\begin{eqnarray}
ratio_{clone} &=&\frac{K}{T},
\end{eqnarray}
where $K$ is the number of LOC cloned from Bitcoin and $T$ is the total number of LOC.
Note that \autoref{tbl:percentage_compare} shows the clone ratio of a subset of 14 cryptocurrencies that were among the top 50 by the market capitalization as of the time of making the experiment.
The average clone ratio was found to be 30.7\%.
However, if we compare the highest clone ratio among all versions of the same set of cryptocurrencies written in C++, the average clone ratio increases to 46.6\%.
Furthermore, multiple cryptocurrencies have a clone ratio of more than 90\%.
Hence, we conclude that code clones are indeed prevalent in cryptocurrencies.
\subsection{RQ2: Accuracy of \textsc{CoinWatch}\xspace}
To answer this question, we systematically apply $\mathcal{CW}$\xspace to multiple vulnerabilities discovered in recent years and see whether they are propagated to other cryptocurrencies.
We focus on such vulnerabilities due to the following reasons.
First, these are high-profile vulnerabilities.
Second, these vulnerabilities are reported between the years 2016 to 2018, in which we evinced a boom of a vast number of cryptocurrencies.
A vulnerability propagates itself across clones since it is not yet discovered at the time when the parent project is cloned.
The propagation of a vulnerability is highly dependent on when the source code was cloned and how long the vulnerability has existed before it was fixed.
If a cryptocurrency forked the code during the time frame when the bug was presented in the source code, there is a high chance of the clone containing vulnerable code.
As a result, we found out that $\mathcal{CW}$\xspace is capable of accurate detection of vulnerabilities in cloned projects as proven by filing 4 CVE extensions.
\begin{table}[t]
\centering
\begin{tabular}{@{}rcccc@{}}
\toprule
\textbf{Vulnerability} & \textbf{\specialcell{Parent\\Project}} & \textbf{\specialcell{\# Investigated\\~~~~Projects}} & \multicolumn{1}{c}{\textbf{TPR}} & \multicolumn{1}{c}{\textbf{FPR}} \\ \midrule
\textbf{CVE-2018-17144} & Bitcoin & 31 & 100.0\% & 0.00\% \\
\textbf{CVE-2016-10724} & Bitcoin & 422 & 89.3\% & 10.7\% \\
\textbf{CVE-2016-10725} & Bitcoin & 422 & 89.3\% & 10.7\% \\
\textbf{CVE-2019-7167} & Zcash & 1 & 100.0\% & 0.00\% \\
\bottomrule
\end{tabular}
\caption{A summary of the results obtained by $\mathcal{CW}$\xspace.}\label{tab:summary-results}
\end{table}
\myparagraph{\textbf{Case Study}}
In the following, we focus on CVE-2018-17144.
Among 985 pre-filtered cryptocurrencies monitored using $\mathcal{CW}$\xspace, we found that as of October 2018, 31 cryptocurrencies had Type I clones of a vulnerable code found in Bitcoin and hence were exposed to this vulnerability.
We monitored the situation after we alerted vulnerable projects and our CVE extension was published at NVD.
In February 2019, the results from $\mathcal{CW}$\xspace suggest that 22 of the 31 cryptocurrencies have patched the vulnerability, while in June 2020 there were still 4 projects unfixed.
This implies that attackers had at least a month's time frame from the time the CVE was announced in September 2018 to attack the 31 vulnerable cryptocurrencies, exposing up to $\$35,585,594$ market capital (as of 07 October 2018).
Moreover, in February 2019 and June 2020, attackers could still attack the remaining 9 and 4 unfixed cryptocurrencies, respectively.
\subsection{RQ3: Is a clone equal to a vulnerability?}\label{sec:RQ3}
To answer this question, we investigate how many of the candidate cryptocurrencies that are discovered using $\mathcal{CW}$\xspace are indeed vulnerable.
This is a challenging problem since we must be able to determine whether the affected code is reached or not, and whether its execution would result in the same reported vulnerability as in the target project.
Therefore, we attempt to answer the question in two ways.
First, we manually examined all the patches of 4 CVEs (that we extended) and cross-checked them with cryptocurrencies reported by $\mathcal{CW}$\xspace.
For each patch, we checked if the vulnerable cloned code was already modified (by maintainers) in the most recent version of the project, and if so, whether it was modified in a way similar to the fix of the CVE in the parent project.
In the positive case, we considered a discovery made by $\mathcal{CW}$\xspace on a particular cryptocurrency as a true vulnerability.
The second way we answer the question was manual checking with the developers/maintainers of the project.
\myparagraph{\textbf{True Positives VS False Positives}}
The summary of our results is presented in \autoref{tab:summary-results}.
In the case of CVE-2018-17144, due to an extremely severe consequence of this double-spending vulnerability, many popular cloned cryptocurrencies quickly applied the fix after the CVE was released, e.g. Dash, Ravencoin, Bitcoin Cash, etc.
This is not the case for low-profile vulnerabilities or for smaller cryptocurrencies, which are less diligent in keeping their codebases updated.
Pigeoncoin is an example of a cryptocurrency that suffered from this vulnerability, and which was also exploited.
We analyzed different releases of Pigeoncoin and found that it contained the double-spending vulnerability from its official launch on 07 April 2018 until 27 September 2018.
The reason for the bug fix on 27 September was the attack made on it.
If $\mathcal{CW}$\xspace were to monitor Pigeoncoin at the time the Bitcoin patch was released, we could have identified the vulnerability and prevented the attack.
In the case of CVE-2018-17144 and CVE-2019-7167, there were no false positives since all candidate cryptocurrencies reported were confirmed to contain these vulnerabilities.
On the other hand, $\mathcal{CW}$\xspace reported a few false positives as well.
For example, although we initially found out that 422 cryptocurrencies had enabled the alert system (causing CVE-2016-10724 and CVE-2016-10725 in the parent project), 45 cryptocurrencies reported at the output of $\mathcal{CW}$\xspace did not reference it during compilation and thus are not vulnerable.
Due to this, the true positive rate of $\mathcal{CW}$\xspace was deteriorated to 89.3\% for these particular vulnerabilities.
\lstset{
basicstyle=\tiny\ttfamily\scriptsize,
breaklines=true,
frameround=tttt,
frame=trBL,
basewidth=0.5em,
xleftmargin=.02\textwidth, xrightmargin=.615\textwidth,
tabsize=1,
showstringspaces=false,
escapeinside={<@}{@>},
}
\begin{figure}[t]
\vspace{2pt}
\centering
\includegraphics[width=0.46\textwidth]{img/dos_Diamond.png}
\caption{Propagated code for DoS vulnerability in Bitcoin Diamond.}
\label{tbl:bcd_dos}
\end{figure}
\begin{figure}[t]
\centering
\includegraphics[width=0.46\textwidth]{img/dos_Stash.png}
\caption{Propagated code for DoS vulnerability in Bitcoin Stash.}
\label{tbl:bitstash_dos}
\vspace{-0.6cm}
\end{figure}
\myparagraph{\textbf{Type II and III Clones and Possible False Negatives}}
Type II and III clones come into play when the codebase is edited by changing the way certain functions work or are named.
One example of a Type III clone that we identified was presented in Bitcoin Diamond Version 0.14.0 and 0.13.0.
The code can be seen in \autoref{tbl:bcd_dos}.
Bitcoin Diamond modified its function \textit{CheckTransaction()} to include new arguments that are specific to Bitcoin Diamond itself.
An example of Type II clone was identified in Bitcoin Stash as seen in \autoref{tbl:bitstash_dos}, where the \textit{CheckTransaction()} function was renamed to \textit{CheckRegularTransaction()}.
These clones cannot be detected using Simian as the clone detector, and they require more sophisticated tools which we will consider in our future work.
We contacted the development team of these two projects regarding the possible vulnerabilities but did not get the response; hence, we cannot confirm whether these two cases represent false negatives.
\section{Discussion}
\myparagraph{\textbf{Scope of Clones}}
The results presented in this paper are related mainly to Bitcoin, as it is currently the dominant cryptocurrency and has the most number of forks from its GitHub repository.
However, there are other cryptocurrencies written in different programming languages (or are close-sourced) that are similar to Bitcoin but would not be detected as Type I clones.
There is a trade-off between false positives and false negatives if we use more complex types of code clone detection techniques such as the ones searching for Type II or Type III clones.
In some cases we would have to conduct a decompilation of binaries and do the analysis on abstract syntax trees of assembly rather than a verification of source code for match.
This is the direction that we will investigate in our future work.
\myparagraph{\textbf{Manual Annotation}}
A semi-automated nature of $\mathcal{CW}$\xspace is another limitation, which stems from the manual annotation of the vulnerable code and fix within the bug fixing and bug introducing commits.
However, this is a one-time action per vulnerability and can be performed in a relatively short time, while later $\mathcal{CW}$\xspace continues automatically in checking the full list of monitored projects.
In our future work, we plan to design simple heuristic methods that can automate this step.
\myparagraph{\textbf{Non-Standard Assumptions}}
$\mathcal{CW}$\xspace assumes that if a cryptocurrency project was forked after the bug was introduced in the parent project and before the bug was fixed, it is likely to suffer from the vulnerability.
However, we note that sometimes forked projects may cherry-pick commits from their parents or apply patches mitigating some security issues, which we currently do not distinguish in $\mathcal{CW}$\xspace.
However, we emphasize that such selected projects represent only the first cut of potentially vulnerable candidate projects and if they contain a fix, the clone detector will mark them as safe.
In the worst case, if the fix is presented in a modified form that is not matched by the clone detector, they are reported as false positives -- this causes a notification to the maintainers, who just ignore it.
\section{Related Work}\label{sec:related_work}
\textbf{Security of Cryptocurrencies.}
The security of cryptocurrencies has been undermined by several high profile incidents.
Bitcoin~\cite{nakamoto2008bitcoin} itself has been described to be vulnerable to several attacks such as double-spending~\cite{karame2012double}, transaction malleability ~\cite{decker2014bitcoin}, networking attacks ~\cite{heilman2015eclipse}~\cite{apostolaki2017hijacking}, attacks targeting mining~\cite{eyal2018majority}~\cite{sapirshtein2016optimal}~\cite{eyal2015miner}, and others~\cite{SRA-homoliak}~\cite{bonneau2015sok}.
As a research topic, Bitcoin's security is attractive due to a broad number of use cases proposed for its underlying technology, blockchain.
Bitcoin has inspired several cryptocurrencies to build and improve different aspects of its code to increase its transaction throughput (eg. Bitcoin Cash) or provide greater anonymity (eg. Bitcoin Private).
The intense scrutiny of Bitcoin's security has led to a gap in research on the effects of vulnerabilities from Bitcoin propagating to other cryptocurrencies that have copied parts of Bitcoin's code.
These cryptocurrencies also store value but are not as valuable as Bitcoin and thus do not have as many developers and resources to build a body of research around their security.
Therefore, we developed $\mathcal{CW}$\xspace\ to address the security problem of propagated vulnerabilities from Bitcoin while focusing on real-world attacks that have been identified and fixed within Bitcoin's code.
\\
\textbf{Clones among Cryptocurrencies.}
Some cryptocurrencies fork existing repositories and launch their own cryptocurrencies with a specific focus.
As these cryptocurrencies are changing only a portion of the forked codebase before launching, a large portion of their code is cloned from the specific version it was forked from.
Prior work suggests that code clones increase maintenance effort~\cite{monden2002software}~\cite{mondal2012comparative}, might cause bugs (Li et. al analyzed Linux, FreeBSD, Apache~\cite{li2006cp}), and signal errors in other parts of a codebase.
It is known that clone genealogy information can be used to identify clones that may benefit new approaches and clone management~\cite{kim2005empirical}.
Based on the findings of the authors of~\cite{kim2005empirical}, aggressive code refactoring might not be necessary for code clones that are volatile and that the technique of refactoring needs to be complemented by other code maintenance approaches.
Prior research analyzing package dependencies~\cite{zhang2015assessing} utilizes a systematic approach of measuring the attack surface exposed by individual vulnerabilities through component level dependency analysis.
In this work, cloned cryptocurrencies do not utilize Bitcoin as a package but the concept that the attack surface is dependent on code utilized from elsewhere.
The authors of~\cite{reibel2019short} analyzed code diversity in the cryptocurrency projects basing on the source code similarity.
The intention of the authors was to examine the extent to which new cryptocurrencies provide innovations.
\textbf{Code Clone Detection.} Basic code clone detection techniques are performed using several tools and generally follow a 6-step process~\cite{roy2009comparison} to generate clone pairs.
Code cloning can be used for the detection of code refactoring, greater efficiency of development, etc.
However, this methodology has been used for other purposes due to the large volume of open-source code that can be analyzed, such as detecting vulnerabilities.
For example, Viertel et al.~\cite{viertel2019detecting} utilized this technique for detecting vulnerabilities in codebases of Java-written projects, in a similar fashion than $\mathcal{CW}$\xspace does.
A similar environment is represented by smart contracts in Ethereum or other smart contract platforms.
Early work focused on finding semantic clones in smart contracts that contained vulnerabilities in the smart contract logic is presented in~\cite{liu2018eclone}.
A tool detecting previously discovered smart contract vulnerabilities through clones was proposed, and can quickly identify other smart contracts that are semantically equivalent (and thus might contain the same set of vulnerabilities).
The automatic classification of Ponzi smart contracts based on code clones was proposed in~\cite{chen2018detecting}, and it bases on the fact that related smart contracts have fundamentally similar programming logic.
Clone detection was also performed after transferring the code into an abstract form such as strings~\cite{johnson1994substring}, tokens~\cite{higo2002software}, and abstract syntax trees (AST)~\cite{koschke2006clone}.
An efficient heuristic technique basing on edit distance and AST for pair-wise comparison of smart contract byte codes was proposed in~\cite{hartel2019empirical}.
Techniques such as line comparison based on dot plots~\cite{rieger2005effective}, comparing whole files~\cite{manber1994finding}, pattern recognition of code characteristics through clustering~\cite{merlo2004linear}, finding clones within a syntactic unit through post-processing ~\cite{higo2002software}, and pre-processing~\cite{cordy2004practical} are also used for clone detection.
\section{Conclusion}\label{sec:conclusion}
In this work, we proposed \textsc{CoinWatch}\xspace, an approach that monitors a specified set of cryptocurrency projects for the presence of vulnerabilities disclosed in their parent projects.
We applied \textsc{CoinWatch}\xspace on 1094 monitored cryptocurrencies using 4 CVEs at the input, and we identified 786 true vulnerable projects, which were confirmed with developers and successfully reported as CVE extensions.
Our results show that many attacks could have been prevented should \textsc{CoinWatch}\xspace has been monitoring the attacked projects.
In future work, we plan to extend code clone detection to Type II and III clones to increase the detection performance as well as eliminate a need for a manual step of annotating the code within bug fixing and introducing commits.
\bibliographystyle{IEEEtran}
\IEEEtriggeratref{34}
| {'timestamp': '2020-10-29T01:24:03', 'yymm': '2006', 'arxiv_id': '2006.10280', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10280'} | arxiv |
\section{Introduction}
\label{sec:introduction}
Occam's razor and the bias-variance trade-off have long provided
guidance for model selection in machine learning and statistics.
Given a dataset, these principles recommend selecting a model that
balances between the competing criteria of (a) fitting the data well,
while (b) having relatively low complexity. On the one hand, a model
whose complexity is too low incurs \emph{high bias}, i.e., it does not
fit the training data well (under-fitting). On the other hand, an
overly complex model memorizes the training data, suffering from
\emph{high variance}, i.e. poor performance on unforeseen data
(over-fitting).
There are numerous characterizations of complexity in the statistical machine learning literature that are commonly used to perform model selection,
and to establish bounds on prediction error.
For linear models, a common proxy for model complexity is the degrees of
freedom~\citep{efron1986biased,buja1989linear,efron2004estimation},
along with extensions such as effective or generalized degrees of
freedom for more complex
models~\citep{meyer2000degrees,shen2002adaptive,efron2004estimation,hastie2005elements,zhang2012generalized},
as well as high-dimensional sparse
regression~\citep{zou2007degrees,tibshirani2012degrees,hastie2017generalized}.
Intuitively, such measures reflect the effective number of parameters
used to fit the model. As a special case, in an unstructured linear
regression problem based on $n$ samples with $d$ features (with $d <
n$), the degrees of freedom is equal to $d$. However, recent
work~\citep{kaufman2014does,janson2015effective,tibshirani2015degrees}
has shown that when moving to the over-parameterized setting ($d >
n$), effective degrees of freedom may be a poor measure of model
complexity. Even earlier, several other complexity measures such as
Vapnik-Chervonenkis dimension~\citep{vapnik2015uniform}, Rademacher
complexity~\citep{bartlett2002rademacher,anthony2009neural,van2006empirical},
Akaike information criterion~\citep{akaike1974new}, Mallow's
$C_p$~\citep{mallows1973some}, and Bayesian information
criterion~\citep{schwarz1978estimating} were proposed in the
literature. In the classical regime $d < n$ with well-conditioned
design matrices, all of these measures reduce to parameter counting
for linear models.
A more recent line of work has derived generalization error bounds for
deep neural
networks~\citep{neyshabur2015norm,bartlett2017spectrally,neyshabur2017pac,golowich2017size,li2018tighter,neyshabur2018role}
based on Rademacher-like complexity notions. However, at least thus
far, such bounds remain too loose to inform practical
performance~\citep{arora2018stronger}. Moreover, there is growing
evidence that large-scale trained models are often not complex, due to
the implicit regularization induced by model architecture,
optimization methods, and training datasets~\citep{Nakkiran2019DeepDD,
neyshabur2014search, arora2019implicit, neyshabur2018role}.
Using complexity measures based on counting parameters, some recent
work~\citep{hastie2019surprises,belkin2019two} have revealed that in
the overparameterized setting ($d > n$), the test error can behave in
seemingly contradictory ways. Even in the simple case of linear
regression, the test error of the minimum-norm ordinary least squares
(OLS) estimator does not follow the classical U-shaped curve (as would
have been predicted by bias-variance tradeoff); instead, it can
decrease when the number of parameters grows beyond $d>n$. (See
Figure~\ref{fig:bias_var} for our reproduction of this phenomenon.)
It is worth noting that this \emph{double-descent} phenomenon was
documented in early work on linear discriminant
analysis~\citep{skurichina1998bagging,skurichina2001bagging,skurichina2002bagging},
and more recently, it has been studied for high-dimensional linear
regression~\citep{hastie2019surprises,belkin2019two,muthukumar2020harmless},
as well as for DNNs applied to classification~\citep{advani2017high,
Nakkiran2019DeepDD}. These observations have prompted several
researchers to question the validity of the bias-variance tradeoff
principle, especially in high-dimensional
regimes~\citep{belkin2019reconciling, belkin2019two}.
\paragraph{Our contributions:} Prompted by this apparent
contradiction, we revisit the two choices underlying the bias-variance
tradeoff: (1) the class of estimators, and (2) the definition of
complexity. With regard to the class of estimators, we argue in
Section~\ref{sec:bias_var_tradeoff} that the bias-variance tradeoff is
only sensible when considered for a given dataset over a class of
estimators that provide reasonable performance. This observation
motivates us to seek a valid complexity measure defined with respect
to a reasonably good class of models. We do so by building on the
optimality principle put forth in the algorithmic complexity of
Kolmogorov, Chaitin, and
Solomonoff~\citep{kolmogorov1963tables,kolmogorov1968three,li2008introduction}
and the principle of minimum description length (MDL) of
Rissanen~\citep{rissanen1986stochastic,barron1998minimum,hansen2001model,grunwald2007minimum}.
In Section~\ref{sec:complexity}, we begin by reviewing the MDL
principle, and then build our way to defining the notion of MDL-COMP.
It corresponds to the minimum excess bits required to transmit the
data when constructing an optimal code for a given dataset via a
family of models based on the ridge estimators. Within this
framework, we undertake a detailed study of high-dimensional linear
models and reproducing kernel Hilbert space methods. Notably, both of
these model classes have studied in recent work as tractable settings
for providing theoretical insight into the behavior of
(overparameterized) deep neural networks~\citep{jacot2018neural,
du2018gradient, allen2018convergence}. In
Section~\ref{sec:main_results}, we start with results for linear
models, where we provide an analytical investigation of
\ensuremath{\textrm{MDL-COMP}}\ (\cref{thm:complexity_expressions}). We show that
\ensuremath{\textrm{MDL-COMP}}\ has a wide range of behavior depending on the design matrix,
and while it usually scales like $d/n$ for $d<n$, it grows very
slowly---logarithmic in $d$---for $d>n$ (see
\cref{fig:mdl_gaussian,fig:mdl_spike_design}). Next, we show that
\ensuremath{\textrm{MDL-COMP}}\ provides an upper bound for in-sample MSE
(\cref{thm:lam_opt}), and that it satisfies certain minimax optimality
criterion (\cref{thm:minimax_codelength}).
Next, we derive MDL-COMP expressions for kernel methods
(\cref{thm:mdl_kernel} and Corollary~\ref{cor:mdl_kernel_smooth}). We
show that for kernels in Gaussian and Sobolev spaces, MDL-COMP can
inform the minimax in-sample generalization. On the other hand, for
deep neural tangent kernels (NTKs), we find that MDL-COMP can
sometimes reduce when the dimensionality of the input increases.
Finally, to establish usefulness of \ensuremath{\textrm{MDL-COMP}}\ in practice, in
Section~\ref{sec:experiments}, we consider a data-driven form of
\ensuremath{\textrm{MDL-COMP}}-inspired hyperparameter selection, which we refer to as the
\textrm{Prac-MDL-COMP}\ criterion. We show that this criterion provides
competitive performance over cross-validation for ridge regression (in
terms of test MSE), especially in limited data settings, in several
simulations and real-data experiments involving both low and
high-dimensional linear models and neural tangent kernels. We conclude
with a discussion and directions for future work in
Section~\ref{sec:discussion}. Proofs of all results and additional
experiments are provided in the appendix.
\section{Revisiting the bias-variance tradeoff: Role of estimators}
\label{sec:bias_var_tradeoff}
We begin by revisiting recent results on the behavior of test-mean
squared error (MSE) for minimum-norm ordinary least squares (OLS), and
cross-validation-tuned ridge estimators in high-dimensional linear
regression~\citep{hastie2019surprises,muthukumar2020harmless}. As
noted earlier, the bias-variance tradeoff should be studied for a
given dataset where only the choice of models fitted to the data is
varied (as opposed to a set-up in which the data generating mechanism
itself is varied). Here we consider a dataset of $200$ observations
and $2000$ (ordered) features simulated from a Gaussian linear model
\begin{align}
\yi = \axi ^\top \tvar_\star + \noise, \qtext{for} i = 1, 2, \ldots, n,
\qtext{or} \v{y} = \mat{X} \tvar_\star + \v{\noise[]},
\label{eq:linear_model}
\end{align}
such that the true response depends on only on the feature indices $1,
2, \ldots, 60 =d_\star$; and the true signal $\tvar_\star \in \ensuremath{\mathbb{R}}^{60}$
satisfies $\enorm{\tvar_\star}=1$, where $\noise
\stackrel{\mrm{i.i.d.}}{\sim}\mathcal{N}(0, \sigma^2)$ denotes the noise
in the response variable when compared to the true response $\axi ^\top
\tvar_\star $. We set $\sigma^2 = 0.01$ for the experiments associated
with \cref{fig:bias_var}. We then fit OLS and Ridge estimators with
the first $d$ features for different values of $d\in \braces{20, 40,
60, \ldots, 2000}$. \cref{fig:bias_var} plots the mean-squared
error (MSE) on a held-out dataset of $1000$ samples and the
bias-variance tradeoff for the OLS and Ridge estimator as a function
of $d$.
\begin{figure}[ht]
\centering
\begin{tabular}{ccc}
\includegraphics[width=0.31\linewidth]{../figs/identity0test_mse}
&
\includegraphics[width=0.31\linewidth]{../figs/identity0bias_variance_ols}
&
\includegraphics[width=0.31\linewidth]{../figs/identity0bias_variance_ridge}
\end{tabular}
\caption{The bias-variance tradeoff for linear models fit to
Gaussian data as $d$ is varied. While the OLS estimator shows a
peaky behavior in test-error for $d=n$, the error of the ridge
estimator shows the typical U-shaped curve. Both OLS and Ridge
estimator show the classical bias-variance tradeoff for $d\leq
d_\star = 60$ (left of vertical dashed line). For $d > d_\star$
the bias increases monotonically, while the variance shows an
increase until $d = n$, and it decreases decreases (for $d >
n$). }
\label{fig:bias_var}
\end{figure}
In \cref{fig:bias_var}(a), we also plot the test-error of the trivial zero estimator for the Gaussian design (Zero-Est).
We observe that while the test error for ridge estimator shows a typical U-shaped curve (as the bias-variance tradeoff principle suggests),
the test MSE of OLS shows a peak at $d/n=1$; although the rest of the curve seems to track the Ridge-curve pretty closely.
The peaking at $d/n=1$ is caused by the instability of the inverse of the matrix $\xmat^\top\xmat$ when $d\approx n$. Recently, this phenomenon has been referred to as double-descent (because of the second decrease in test MSE of OLS for $d>n$) and has reinvigorated the discussion whether a bias-variance tradeoff holds in high dimensional models~\citep{hastie2019surprises,belkin2019two,muthukumar2020harmless}.
However, it is worth noting that: (I) The trivial (zero) estimator has constant bias and variance, and thus does not exhibit any bias-variance tradeoff for all choices of $d$.
(II) The OLS estimator admits a bias-variance tradeoff for $d\leq d_\star$ (vertical dashed line); wherein the bias decreases and the variance increases as $d$ increases. However beyond $d>d_\star$, the variance peaks abruptly at $d=n$ and then decreases beyond $d>n$; and bias
is negligible for $d \in [d_\star, n]$, and then increases for $d>n$.
(III) The Ridge estimator shows a similar bias-variance tradeoff as OLS for most values of $d$. However, a key difference is the absence of the peaking behavior for the variance (and hence the test MSE) showing that the peaky behavior of OLS is indeed due to its instability in high dimensions.
In \cref{sub:different_design}, we further discuss the bias-variance
tradeoff for a few different designs and also consider the case
$d_\star >n$. \cref{fig:test_mse_diff_design,fig:bias_var_diff_design}
show that for different choice of covariates $\mat{X}$, the test MSE of
OLS can have \emph{multiple peaks}, although overall the OLS estimator
seems to have well-defined global minima (over $d$) and can be a
reasonable choice for model selection in all settings. The behavior of
the ridge estimator remains qualitatively similar to that in
\cref{fig:bias_var}, and its test-MSE is always lowest at
$d=d_\star$. These observations reveal that the bias-variance tradeoff
is not merely a function of the number of parameters considered;
rather, it is tightly coupled with the estimators considered along
with problem structure, with the design matrix $\mat{X}$ being
especially relevant for linear regression. A large part of the
unexpected behavior with the bias-variance tradeoff can be attributed
to the choice of $x$-axis where we treat $d$ as the complexity of the
estimator---but as we now discuss such a choice is not well justified
for $d>n$.
\section{Revisiting complexity using minimum description length}
\label{sec:complexity}
The choice of parameter count as a complexity measure for linear
models is rigorously justified when the data is low-dimensional ($d <
n$), and the design matrix is well-conditioned (so that all $d$
directions contribute in roughly equal measure). Indeed, the OLS
estimate has good performance when $d \ll n$, and its test error
increases proportionally with $d$ in this regime. Such linear scaling
is seen in other many complexity measures in this regime, including
the Rademacher, AIC, and BIC complexities. However, using $d$ as the
complexity measure when $d>n$ remains unjustified (even for linear
models). Indeed, in \cref{fig:bias_var}, we observe that the variance
term for both OLS and Ridge first increase with $d$ up to $n$, and
then decreases as $d$ further increases beyond $n$. Such an
observation has also been made in regards to the double-descent
observed in deep neural networks~\citep{yang2020rethinking}, wherein
an increase in the width of the hidden layers beyond a threshold leads
to a decrease in the variance. In some past work, the variance term
itself has sometimes been used as a measure of complexity (e.g., in
$L^2$-boosting~\citep{buhlmann2003boosting}). However, since the
fitted model does not match the dimensionality of the true model in
\cref{fig:bias_var}, such a choice may be misinformed here.
\subsection{Background on the principle of minimum description length}
In order to define a complexity measure in a principled manner, we
build upon Rissanen's principle of minimum description length (MDL).
It has its intellectual roots in Kolmogorov's theory of complexity.
Both approaches are based on an optimality requirement: namely, the
shortest length program that outputs the sequence on a universal
Turing machine for Kolmogorov complexity, and the shortest
(probability distribution-based) codelength for the data for MDL.
Indeed, Rissannen generalized Shannon's coding theory to universal
coding and used probability distributions to define universal encoding
for a dataset and then used the codelength as an approximate measure
of Kolmogorov's complexity.
From the perspective of minimum description length, a model or a
probability distribution for data is equivalent to a (prefix) code;
one prefers a code that exploits redundancy in the data to compress it
into as few bits as possible;
see~\citep{rissanen1986stochastic,barron1998minimum,grunwald2007minimum}.
Since its introduction, MDL has been used in many tasks including
density estimation~\citep{zhang2006}, time-series
analysis~\citep{tanaka2005discovery}, model
selection~\citep{barron1998minimum, hansen2001model,
miyaguchi2018high}, and DNN
training~\citep{hinton1993keeping,schmidhuber1997discovering,li2018measuring,blier2018description}.
For readers unfamiliar with MDL, Sections 1 and 2 of the
papers~\citep{barron1998minimum,hansen2001model} provide background on
MDL.
In the MDL
framework, any probability model is viewed as a type of coding, so
that for example, fitting a Gaussian linear model is equivalent to
using a Gaussian code for compressing the data. The goal is to select
the code that provides the shortest description of data; in most
settings, this translates into picking the model with the best fit to
the data. More formally, suppose we are given a set of $\samples$
observations $\v{y} = \braces{\yi[1], \yi[2], \ldots, \yi[n]}$. Let
$\mathbb{Q}$ refer to a probability distribution on the space $\ensuremath{\mathcal{Y}^n}$
(e.g., a subset of $\ensuremath{\mathbb{R}}^n$) where $\v{y}$ takes values, and let
$\mc{Q}$ denote a set of such distributions. Given a probability
distribution $\mathbb{Q}$, we can associate an
\emph{information-theoretic} prefix code for the space $\ensuremath{\mathcal{Y}^n}$,
wherein for any observation $\v{y}$ we need to use $\log(1/\mathbb{Q}(\v{y}))$
number of bits to \emph{describe} $\v{y}$. The MDL principle dicates
choosing the code $\mathbb{Q}$ associated with the shortest possible
description length---namely, a code achieving the minimum
$\min_{\mathbb{Q} \in \mc{Q} } \log(1/\mathbb{Q}(\v{y}))$. Note that when $\mc{Q}$
is simply a parametric family, the direct MDL principle reduces to the
maximum likelihood principle. But the advantage of MDL comes from the
fact that the set $\mc{Q}$ can be more complex, for example a nested
union of parametric families, or a set of codes not indexed by the
canonical parameter of interest. Furthermore, even without a
generative modeling assumption, the notion of shortest description
over an arbitrary set of codes $\mc{Q}$ continues to be
well-defined. (For further discussion about MDL vs maximum likelihood,
we refer the reader to \cref{sub:further_background}.)
\paragraph{Two-stage MDL:} One of the most basic notions of MDL is a two-stage MDL, often considered for doing model selection over a nested family of parametric model classes, where the dimensionality of the parameter varies across different parameteric classes.
This version of MDL turns out to be equivalent to the Bayesian
information criterion (BIC)---that is, it peforms model selection
based on a regularized maximum likelihood, where the regularization
term is simply $\frac d2\log n$. Consequently, apart from the
additional logarithmic term, the MDL complexity in this set-up simply
reduces to parameter counting.
\subsubsection{Normalized maximum likelihood}
Many modern approaches to MDL are based on a form of universal coding
known as \emph{normalized maximum likelihood}, or NML for short. In
this approach, the distribution $\mathbb{Q}$ is defined directly on the
space $\ensuremath{\mathcal{Y}^n}$; at least in general, it is \emph{not} explicitly
parametrized by the parameter of interest. More concretely, given a
family of codes $\mc P_{\Theta} = \braces{p(\cdot; \theta),
\theta\in \Theta}$, the NML code is defined as
\begin{align}
\label{eq:nml_defn}
q_{\mrm{NML}}(\v{y}) := \frac{\max_{\theta} p(\v{y}; \theta)}{\int_{\ensuremath{\mathcal{Y}^n}} \max_{\theta'} p(\v{z}; \theta') d\v{z}},
\end{align}
assuming that the integral in the denominator is finite.
\cite{shtar1987universal} established that this NML distribution (when
defined) provides the best encoding for the family $\mc P_{\Theta}$ in
a minimax sense. The log normalization constant $\log
\int_{\ensuremath{\mathcal{Y}^n}} \max_{\theta'} p(\v{z}; \theta') d\v{z}$
associated with this code is referred to as the \emph{NML or Shtarkov
complexity.} Note that the normalization~\eqref{eq:nml_defn} ensures
that $\mathbb{Q}_{\mrm{NML}}$ is a valid code by making $q_{\mrm{NML}}$ a
valid density.\footnote{Thus, Kraft's inequality guarantees the
existence of a code corresponding to it.} Such codes are called
\emph{universal codes}, since the codelength
$\log(1/q_{\mrm{NML}}(\v{y}))$ is universally valid for any $\v{y}
\in \ensuremath{\mathcal{Y}^n}$.
Suppose that $\mc P_{\Theta}$ is a parametric class of dimension $d$.
In this special case, the NML complexity scales asymptotically as
$\tfrac{1}{2} d \log n$, for fixed $d$ with $n \to \infty$;
consequently, it is asymptotically equivalent to the BIC complexity
measure~\citep{barron1998minimum,foster2004contribution,hansen2001model}
to the first order $\mc O(\log n)$ term. In a recent work,
\cite{grunwald2017tight} further developed a framework to unify
several complexities including Rademacher and NML, and derived excess
risk bounds in terms of this unifying complexity measure, for several
low-dimensional settings.
\subsubsection{Luckiness normalized maximum likelihood}
The NML code often suffers from the \emph{infinity} problem, namely
when the normalization constant in \cref{eq:nml_defn} is infinite, and
the NML distribution is not defined. While a canonical solution is to
truncate the observation space so as to make the integral finite,
another solution was proposed in recent works, namely, the luckiness
normalized maximum likelihood (LNML) code (see Chapter
11~\citep{grunwald2007minimum}). While NML can be seen as a
generalization of maximum likelihood, LNML can be seen as a
generalization of regularized maximum likelihood. Given the class of
codes $\mc P_{\Theta}$, and a luckiness function $p_\textrm{luck}:\Theta \to
\ensuremath{\mathbb{R}}_+$ (not necessarily a code), one way to define the LNML code is
as follows:
\begin{align}
\label{eq:lnml}
q_{\mrm{LNML}}(\v{y}) := \frac{\max_{\theta} \parenth{p(\v{y}; \theta) \cdot p_\textrm{luck}(\theta)}}{
\displaystyle\int_{\v{z}\in\ensuremath{\mathbb{R}}^n}\max_{\theta'}\parenth{p(\v{z}; \theta') \cdot p_\textrm{luck}(\theta')}\; d\v{z}}.
\end{align}
Once again, the normalization in \cref{eq:lnml} ensures that $\mathbb{Q}_{\mrm{LNML}}$ whenever well-defined is a universal code. While one can still treat the log normalization constant as another notion of complexity, theoretical investigations with such codes have not been extensively done in the prior work, and are central to the current work.
\subsubsection{Optimal redundancy as the complexity}
Suppose that the observations follow a generative model, say
$\v{y}{\sim}$ is drawn from some distribution $\mathbb{P}_{\star}$. One
metric to measure the effectiveness of any code $\mathbb{Q}$ is the
\emph{redundancy} or the expected excess code-length for $\mathbb{Q}$
compared to the true (but unknown) distribution $\mathbb{P}_{\star}$,
given by:
\begin{align*}
\frac{1}{n} \ensuremath{{\mathbb{E}}}_{\v{y} \sim \mathbb{P}_{\star}} \brackets{\log
\parenth{\frac{1}{\mathbb{Q}(\v{y})}} - \log
\parenth{\frac{1}{\mathbb{P}_{\star}(\v{y})}}} =
\ensuremath{{\mathbb{E}}}_{\v{y}\sim\mathbb{P}_{\star}}\brackets{ \frac{1}{n} \log \parenth{
\frac{\mathbb{P}_{\star}(\v{y})}{\mathbb{Q}(\v{y})}}} = \frac{1}{n}
\kull{\mathbb{P}_{\star}}{\mathbb{Q}},
\end{align*}
where we normalized by $n$, to obtain bits(/nats) per sample point,
since in our notation the code $\mathbb{Q}$ is defined jointly over the
$n$ observations. Here $\kull{\mathbb{P}_{\star}}{\mathbb{Q}}$ denotes the
Kullback-Leibler divergence between the two distributions and is
non-negative unless $\mathbb{Q} = \mathbb{P}_\star$. (In other words, the
unknown $\mathbb{P}_\star$ is also the best possible encoding of the
data.) Thus, the complexity of the data with respect to the set of
codes $\mc{Q}$ can be defined via the best possible excess codelength
also known as \emph{optimal redundancy}:
\begin{align}
\label{eq:ropt_defn}
\ensuremath{\mc R_{\textrm {opt}}}(\mathbb{P}_\star, \mc{Q}) := \min_
{\mathbb{Q}\in\mc{Q}}
\kull{\mathbb{P}_{\star}}{\mathbb{Q}}.
\end{align}
For this complexity measure to be effective, the set of codes $\mc{Q}$
should be rich enough; otherwise the calculated complexity would be
loose. As noted earlier, the advantage of the MDL framework comes from
the fact that (a) that the set $\mc{Q}$ does not have to be the usual
parametric class used for computing maximum likelihood (and as noted
above, the NML and LNML codes are strict global generalizations of the
maximum likelihood principle), and (b) we do not need a generative
model $\mathbb{P}_\star$. However, for analytical derivations, it is
helpful to impose a generative model over the observed data.
In this work, we define a new complexity measure, MDL-COMP, using the
optimality principle~\cref{eq:ropt_defn} and a rich set of LNML codes
induced by ridge estimators. We use ridge estimators to construct the
LNML codes for multiple reasons. First, we are interested in an
operational definition of complexity, and hence we consider encodings
that are associated with a computationally feasible set of
estimators. Second, for the complexity to be informative, we prefer
the set of codes to be rich enough, and thus the estimators that we
consider should achieve good predictive performance. Ridge estimators
are known to achieve the minimax performance with linear and kernel
methods~\citep{raskutti2011minimax,zhang2015divide,dicker2016ridge},
and often provide competitive predictive performance in applied
machine learning tasks~\citep{bernau2014cross}.\footnote{We do not
default to simply using the ordinary least squares estimator based
code---which in the NML framing would reduce the problem to a single
NML code, and the Shtarkov complexity---for the following reasons: (i)
it has poor performance in the over-parameterized regime with linear
models, and for any setting of kernel regression (for
infinite-dimensional kernels), and (ii) it is known that the Shtarkov
complexity is typically infinite when $\mc{Y}$ is unbounded (see
\citet[Example 11.1]{grunwald2007minimum}), like in the settings
considered here.} We define the details of these codes in
\cref{sub:ridge_lnml_codes} (besides providing a brief recap of ridge
regression), and then formally define the MDL-COMP in
\cref{sub:mdl_comp_defn}.
\subsection{Ridge-based LNML codes}
\label{sub:ridge_lnml_codes}
As in the MDL literature, we design codes over response vectors $\v{y}
\in \ensuremath{\mathbb{R}}^n$ conditional on a fixed matrix $\mat{X} \in \ensuremath{\mathbb{R}}^{n \times
d}$ of covariates. We briefly recap ridge regression estimators for
linear models and kernel methods in \cref{sub:ridge_background},
followed by the definitions of the corresponding LNML codes in
\cref{sub:lnml_code_defn} that underlie our definition of MDL-COMP in
\cref{sub:mdl_comp_defn}.
\subsubsection{Background on ridge regression}
\label{sub:ridge_background}
For linear models, the generalized $\ell_2$-regularized least square estimators, with the penalty~$\theta^\top\mat{\Lambda}\theta$ for a positive definite matrix $\mat{\Lambda}$, is given by
\begin{align}
\label{eq:ridge_new_closed}
\widehat{\tvar}_\mat{\Lambda}(\v{y}) := \argmin_{\theta\in \R^{\ensuremath{d}}}
\parenth{\frac{1}{2}\enorm{\v{y}-\mat{X}\theta}_2^2 + \frac12\theta^\top
\mat{\Lambda} \theta} = (\xridge[\lammat])^{-1} \mat{X}^\top\v{y}.
\end{align}
A common choice for the regularization matrix is $\mat{\Lambda} = \lambda
\mat{I}$. We also define some notation to be useful later on:
\begin{align}
\label{eq:xmatrix}
\xmat^\top\xmat = \mat{U} \mat{D} \mat{U}^\top \qtext{where} \mat{D} =
\diag(\evali[1], \ldots, \evali[d]),
\end{align}
where for $d>n$, we use the convention that $\evali =0 $ if $i>n$.
Here the matrix $\mat U \in \ensuremath{\mathbb{R}}^{\ensuremath{d} \times \ensuremath{d}}$ denotes the
(complete set of) eigenvectors of the matrix $\xmat^\top\xmat$.
Next, we briefly describe kernel ridge regression. Consider a
reproducing kernel $\mc{K}$ and the corresponding reproducing kernel
Hilbert space (RKHS), i.e., for all $x\in \ensuremath{\mathbb{R}}^d$, $\mc{K}(x, \cdot)
\in \mb{H}$ and for any $f \in \mb{H}$, we have $\doth{f, \mc{K}(x,
\cdot)} = f(x)$. In kernel ridge regression, given the data
$\braces{(x_i, y_i)}_{i=1}^n$, we need find an estimate $\widehat{f}
\in \mb{H}$ such that $\widehat{f}(x_i) \approx y_i$. The corresponding
estimate is given by
\begin{align}
\label{eq:kernel_ridge}
\widehat{f} := \argmin_{f\in \mb{H}}
\parenth{\frac{1}{2}\enorm{\v{y} -\v{f}_1^n}_2^2 + \frac{\lambda}{2}
\enorm{f}_{\mb{H}}^2 } \qtext{where} \v{f}_1^n := (f(x_1),
\ldots, f(x_n)) ^\top,
\end{align}
and $\lambda > 0$ denotes a regularization parameter. Representer theorem
for reproducing kernels implies that to solve~\eqref{eq:kernel_ridge}
it suffices to consider functions of the form $f(\cdot) =
\sum_{i=1}^n\beta_i \mc{K}(x_i, \cdot)$ for $\beta \in
\ensuremath{\mathbb{R}}^n$. Substituting this functional form back in
\cref{eq:kernel_ridge} yields a regularized least-squares problem from
$\theta$ which admits a closed-form:
\begin{align}
\label{eq:kernel_ridge2}
\widehat{\beta}_{\lambda}(\v{y}) := \argmin_{\beta\in \ensuremath{\mathbb{R}}^n}
\parenth{\frac{1}{2}\enorm{\v{y}-\mat{K}\beta}_2^2 +
\frac{\lambda}{2}\beta^\top\mat{K}\beta} = (\mat{K} + \lambda \mat{I})^{-1} \v{y}.
\end{align}
where $\mat{K}$ is the $n\times n$ kernel matrix with
$\mat{K}_{ij}=\mc{K}(x_i, x_j)$. With this fit, one can recover the
estimates for in sample observations as $\widehat{\v{y}} =
\mat{K}\widehat{\beta}_{\lambda}$, and for any new point $x$, the estimate is
given by $\widehat{f}(x) = \sum_{i=1}^n[\widehat{\beta}_{\lambda}]_i
\mc{K}(x_i, x)$.
\subsubsection{Defining ridge based LNML codes}
\label{sub:lnml_code_defn}
We start with the linear model setting, and then discuss the kernel
setting. In accordance with MDL convention, we assume that the design
matrix $\mat{X} \in \ensuremath{\mathbb{R}}^{\samples \times d}$ is known, and only the
information in the response vector $\v{y} \in \ensuremath{\mathbb{R}}^\samples$ is to be
encoded.
\paragraph{LNML codes for linear methods:}
We use the notation:
\begin{align}
\label{eq:pdist}
g(\v{y}; \mat{X}, \mat{\Lambda}, \theta) = \frac{1}{(2 \pi \sigma^2)^{n/2}}
e^{-\frac{1}{2\sigma^2} \enorm{\v{y}-\mat{X}\theta}^2} \cdot e^{
-\frac{1}{2\sigma^2} \theta^\top\mat{\Lambda}\theta} , \qtext{for} \v{y} \in
\ensuremath{\mathbb{R}}^n, \theta \in \R^{\ensuremath{d}}.
\end{align}
Letting the first term in \cref{eq:pdist} denote the code $p_{\mrm{data}}$ for
data fit, and the second term $(e^{-\frac{1}{2\sigma^2}
\theta^\top\mat{\Lambda}\theta})$ as the luckiness factor $p_\textrm{luck}$, and
comparing with \cref{eq:lnml}, we define the corresponding LNML code
as follows:
\begin{align}
\label{eq:ridge_dist}
q_{\mrm{LNML}}(\v{y}) = q_{\mat{\Lambda}}(\v{y}) = \frac{g(\v{y}; \mat{X},
\mat{\Lambda}, \widehat{\tvar}_{\mat{\Lambda}}(\v{y}))}{\mrm{C}_{\mat{\Lambda}}} \qtext{where} \mrm{C}_{\mat{\Lambda}}
:= \displaystyle\int_{\ensuremath{\mathbb{R}}^n} g(\v{z}; \mat{X}, \mat{\Lambda},
\widehat{\tvar}_{\mat{\Lambda}}(\v{z}))d\v{z}.
\end{align}
It is a valid density for an LNML code, denoted by $\mathbb{Q}_{\mat{\Lambda}}$,
since
\begin{align}
\label{eq:lnml_ridge}
\argmax_{\theta} \parenth{p_{\mrm{data}}(\v{y}; \mat{X}, \theta) \cdot
p_\textrm{luck}(\theta)} \stackrel{\eqref{eq:ridge_new_closed}}{=}
\widehat{\tvar}_{\mat{\Lambda}}(\v{y}).
\end{align}
In other words, $\mathbb{Q}_{\mat{\Lambda}}$ is the LNML code induced by the
ridge estimator $\widehat{\tvar}_{\mat{\Lambda}}$.
Our definition of complexity, in fact, makes use of a family of LNML
codes. For the linear setting, we consider the family:
\begin{align}
\label{eq:lnml_family_lin}
\mc{Q}_{\mrm{Ridge}}^{\taglin} := \!\braces{\mathbb{Q}_{\mat{\Lambda}}\!:\!\mat{\Lambda}\! \in\!
\mc{M}}, \text{ where } \mc{M}\!:=\!\braces{\mat U \diag (\lambda_1,
\ldots, \lambda_d)\mat U^\top \vert \lambda_j \geq 0, j\!=\!1,\ldots d},
\end{align}
where $\mat U$ denotes the eigenvectors of the matrix
$\xmat^\top\xmat$~\eqref{eq:xmatrix}. We once again note that the family
$\mc{Q}_{\mrm{Ridge}}^{\taglin}$ is not parametric in the classical sense (as it is not
indexed by the canonical parameter $\theta$). However, since the LNML
codes are induced by the ridge estimators, selecting a particular
$\mathbb{Q}_{\mat{\Lambda}}$ code corresponds to choosing a particular $\mat{\Lambda}$
based-ridge estimator for all $\v{y}$. We also explain below the reasons
behind the particular choice of $\mc M$.
A key difference from the NML setting is that the LNML codes are
indexed by hyper-parameter $\mat{\Lambda}$, and thus it remains to add the
codelength corresponding to the index. To this end, we use a simple
quantization-based encoding for the hyper-parameters
$\braces{\lambda_j}$, in the spirit of the two-stage encoding for the
hyper-parameters as in prior
works~\citep{barron1998minimum,hansen2001model,grunwald2007minimum}:
\begin{align}
\mc L(\mat{\Lambda}) &=\frac12\sum_{\lambda_i>0} \log\lambda_i,
\label{eq:lamopt_claim}
\end{align}
where the factor $\frac12$ is chosen for theoretical convenience
(achievable by apriori deciding to encode $\sqrt{\lambda_i}$). In
principle, one should use the codelength $\log (\max{\lambda_i/\Delta,
1})$ for some small enough resolution $\Delta$; and
$\Delta=\frac{1}{\sqrt{n}}$ is often the default choice. Adding such a
constant term would lead to an additive term of $\frac{d}{2n}\log n$
in \ensuremath{\textrm{MDL-COMP}}\ for $d<n$, and $\log n$ for $d>n$. As conventional in the
MDL literature, we omit these additional bits due to the $\Delta$ term
in our discussion to follow.
Our definition~\eqref{eq:lnml_family_lin} makes use of the
eigenvectors of the matrix $\xmat^\top\xmat$ to define the set $\mc M$ of all
possible $\mat{\Lambda}$ for considering the LNML codes (in other words, we
assume $\mat{\Lambda}$ and $\xmat^\top\xmat$ are simultaneously orthogonally
diagnolizable). Such a definition tries to address two concerns:
First, having a rich set of codes is essential to provide us a better
understanding of how much compression in the data is possible, so
having richer set than $\braces{\lambda \mat I; \lambda \geq 0}$ is
desirable. On the other hand, choosing $\mc M$ to be the set of all
PSD matrices would defeat the purpose of measuring the complexity of
data, since the bits needed to encode an arbitrary PSD matrix in
linear model setting would be $\order{\min\braces{d^2, n^2}}$, which
would simply overwhelm the bits needed to encode the data itself. In
the prior theoretical works with MDL, often very simplistic
assumptions, like $\mat{\Lambda} = c\xmat^\top\xmat$ have been
made~\citep{hansen2001model}, and the bits needed to transmit the
scalar $c$ have been treated as fixed. For our choice of $\mc M$, we
note that $\mat U$ can be computed from $\xmat^\top\xmat$, and hence we only need
to count the bits needed to encode the hyper-parameters
$\braces{\lambda_j}$, for which we use \cref{eq:lamopt_claim}.
\paragraph{LNML codes for kernel methods:}
Given the estimators~\eqref{eq:kernel_ridge} and
\eqref{eq:kernel_ridge2}, one can define the LNML codes given a set of
points, the kernel and the corresponding kernel matrix as follows. We
define the function $h(\cdot; \beta, \mat{K})$
\begin{align}
\label{eq:k_pdist}
h(\v{y}; \beta, \mat{K}) := \frac{1}{(2 \pi \sigma^2)^{n/2}}
e^{-\frac{1}{2 \sigma^2} \enorm{\v{y} - \mat{K} \beta}^2} \cdot
e^{-\frac{\lambda}{2 \sigma^2} \beta ^\top \mat{K} \beta},
\end{align}
Letting the first term in \cref{eq:k_pdist} denote the code $p_{\mrm{data}}$
for data fit, and the second term $(e^{-\frac{\lambda}{2\sigma^2}
\beta^\top \mat{K}\beta})$ as the luckiness factor $p_\textrm{luck}$, and arguing
similar to \cref{eq:ridge_dist,eq:lnml_ridge}, we conclude that the
LNML code is given by
\begin{align}
\label{eq:k_ridge_dist}
\widetilde{q}_{\lambda}(\v{y}) = \frac{h(\v{y}; \widehat{\beta}_{\lambda}(\v{y}),
\mat{K})}{\mrm{C}_{\lambda, \kernel}} \qtext{where} \mrm{C}_{\lambda, \kernel} :=
\displaystyle\int_{\ensuremath{\mathbb{R}}^n} h(\v{z}; \widehat{\beta}_{\lambda}(\v{z}),
\mat{K})d\v{z},
\end{align}
and let $\widetilde{\mathbb{Q}}_{\lambda}$ denote the distribution
corresponding to $ \widetilde{q}_{\lambda}$. Finally, our definition
of complexity for kernel methods makes use of the following family of
LNML codes:
\begin{align}
\label{eq:lnml_family_ker}
\mc{Q}_{\mrm{Ridge}}^{\tagker} = \braces{\widetilde{\mathbb{Q}}_{\lambda} : \lambda \geq 0}.
\end{align}
In contrast to the linear setting, here we consider the family of
codes indexed by a single parameter, as using multiple $\lambda$'s
would break the equivalence between
\cref{eq:kernel_ridge,eq:kernel_ridge2}, unless we alter the Hilbert
norm that is being penalized in \cref{eq:kernel_ridge}.
\subsection{Defining MDL-COMP via ridge-LNML codes}
\label{sub:mdl_comp_defn}
We are now ready to define the MDL-based complexity. We define the
complexity as optimal redundancy over the LNML codes with certain
generative assumptions for the data.
\paragraph{MDL-COMP for linear models:}
We consider the generative model
\begin{align}
\label{eq:linear_model_revisit}
\yi = \axi ^\top \tvar_\star + \noise, \qtext{for} i = 1, 2, \ldots, n,
\qtext{or} \v{y} = \mat{X} \tvar_\star + \v{\noise[]},
\end{align}
where we assume that $\noise[]\sim \mc N(0, \sigma^2 \mat I_n)$, so
that $\mathbb{P}_\star = \pdist_{\tvar_\star}= \mc{N}(\mat{X} \tvar_\star, \sigma^2 \mat I_n)
$.\footnote{Although we later discuss a minimax setting while relaxing
this assumption on the noise, see \cref{thm:minimax_codelength}.}
Given this notation, the $\ensuremath{\textrm{MDL-COMP}}$ for this setting is defined as the
sum of the optimal redundancy over the codes
$\mc{Q}_{\mrm{Ridge}}^{\taglin}$~\eqref{eq:lnml_family_lin}, and the codelength needed to
encode the optimal hyperparameters:
\begin{subequations}
\begin{align}
\label{eq:mdl_linear}
\ensuremath{\textrm{MDL-COMP}}(\pdist_{\tvar_\star}, \mc{Q}_{\mrm{Ridge}}^{\taglin}) & := \frac{1}{n} (\ensuremath{\mc R_{\textrm {opt}}}(\pdist_{\tvar_\star}, \mc{Q}_{\mrm{Ridge}}^{\taglin})
+ \mc L(\mat{\Lambda}_{\textrm{opt}})), \qtext{where} \\
%
\label{eq:ropt_linear}
\ensuremath{\mc R_{\textrm {opt}}}(\pdist_{\tvar_\star},\!\mc{Q}_{\mrm{Ridge}}^{\taglin}) & := \min_{\mathbb{Q} \in \mc{Q}_{\mrm{Ridge}}^{\taglin}}
\kull{\pdist_{\tvar_\star}}{\mathbb{Q}} =\min_{\mat{\Lambda} \in
\mc{M}}\kull{\pdist_{\tvar_\star}}{\mathbb{Q}_{\mat{\Lambda}}},
\end{align}
\end{subequations}
and $\mat{\Lambda}_{\textrm{opt}}$ denotes the $\arg\min$ in \cref{eq:ropt_linear}.
\paragraph{MDL-COMP for kernel methods:}
We assume throughout this paper that the reproducing kernel $\mc{K}$
is a Mercer kernel~\citep{mercer1909functions}, which admits the
eigen-expansion:
\begin{align}
\label{eq:mercer_kernel}
\mc{K}(x, y) = \sum_{k=1}^{\infty} \mu_k \phi_k(x) \phi_k(y),
\qtext{for all} x, y \in \ensuremath{\mathbb{R}}^d,
\end{align}
where $\mu_1 \geq \mu_2 \cdots \geq 0$ denotes the sequence of
(non-negative) eigenvalues of the kernel and
$\braces{\phi_k}_{k=1}^\infty$ denotes the associated eigenfunction
taken to be orthonormal in $\mathbb{L}^2(\nu)$ for a suitably chosen
distribution $\nu$. (In the model below, we assume $\nu$ is the
marginal distribution of the covariates.) Let $\mb{H}$ denote the
reproducing kernel Hilbert space of the kernel $\mc{K}$. We consider
the generative model
\begin{align}
\label{eq:kernel_Generative_model}
y_i = f^\star(x_i) + \noise, \qtext{for} i = 1, 2, \ldots, n,
\qtext{or} \v{y} = \v{(f^\star)}_1^n+ \v{\noise[]}.
\end{align}
where we assume that $x_i$'s are drawn i.i.d. from the distribution
$\nu$, and $f^\star \in \mb{H}$, and use the notation $\v{(f^\star)}_1^n
= (f^\star(x_1), \ldots, f^\star(x_n))^\top$. We also assume that
$\noise[]\sim \mc N(0, \sigma^2 \mat I_n)$, so that $\mathbb{P}_\star =
\mb{P}_{f^\star} = \mc{N}((\v{f^\star})_1^n, \sigma^2 \mat
I_n)$.\footnote{We can relax this assumption (without altering the
guarantees derived later) to the noise being zero mean, with variance
$\sigma^2$ and being uncorrelated with $\v{(f^\star)}_1^n$.} With
this notation, we define MDL-COMP for the kernel setting as the
optimal redundancy over the codes $\mc{Q}_{\mrm{Ridge}}^{\tagker}$ in the
family~\eqref{eq:lnml_family_ker}:
\begin{align}
\label{eq:mdl_kernel_defn}
\ensuremath{\textrm{MDL-COMP}}(\mb{P}_{f^\star},\!\mc{Q}_{\mrm{Ridge}}^{\tagker}) :=
\frac{1}{n}\min_{\widetilde{\mathbb{Q}}\in\mc{Q}_{\mrm{Ridge}}^{\tagker}}\kull{\pdist_{\tvar_\star}}{\widetilde{\mathbb{Q}}}
:= \frac{1}{n} \min_{\lambda \geq 0}
\kull{\mb{P}_{f^\star}}{\widetilde{\mathbb{Q}}_{\lambda}}.
\end{align}
where $\mat{K}=(\mc{K}(x_i, x_j))_{j=1}^{n}$ denotes the kernel matrix at the observed covariates.
\paragraph{Remark:} Note that, in place of \cref{eq:mdl_linear}, one can alternatively also consider a joint minimization over the redundancy plus the codelength for $\mat{\Lambda}$, i.e., $\min_{\mat{\Lambda}}[\kull{\pdist_{\tvar_\star}}{\mathbb{Q}_{\mat{\Lambda}}} + \mc L(\mat{\Lambda})]$, to define \ensuremath{\textrm{MDL-COMP}}. Such a choice would be analogous to defining the index of resolvability by \citet{barron1991minimum} in density estimation; where they optimize jointly over the codelength needed to encode the distribution fitted besides the code length corresponding to the data. For such a joint optimization, we need to define a suitable choice of a prefix code on the space of hyper-parameters. In contrast, our treatment of the codelength for $\mat{\Lambda}$ here, namely adding the codelength using simple quantizations scheme after optimizing redundancy, is in line with that for hyperparameters done in the two-stage MDL~\citep{barron1998minimum,hansen2001model,grunwald2007minimum}. Next, we note that compared to \cref{eq:mdl_linear}, we do not add another $\lambda$ dependent codelength in \cref{eq:mdl_kernel_defn}, as there is only one regularization parameter in kernel regression. One may alternatively consider adding a term $\log(\lambda_\textrm{opt})/n$ on the RHS of \cref{eq:mdl_kernel_defn} (without losing the qualitative conclusions in Theorem~\ref{thm:mdl_kernel} or quantitative conclusions in Corollary~\ref{cor:mdl_kernel_smooth} in the sequel).
\section{Main results}
\label{sec:main_results}
We are now ready to state our main results. We start with an explicit characterization of MDL-COMP for linear models in \cref{sub:mdl_complexity_for_linear_models}, and then discuss it for the kernel methods in \cref{sub:mdl_complexity_kernel_methods}.
\subsection{Characterizing MDL-COMP for linear models}
\label{sub:mdl_complexity_for_linear_models}
Our first result provides an explicit expression for
MDL-COMP~\eqref{eq:mdl_linear} for the linear models.
\begin{theorem}
\label{thm:complexity_expressions}
For the linear model~\eqref{eq:linear_model_revisit}, let $\mat U$ and
$\braces{\evali}$ denote the eigenvectors and eigenvalues of $\xmat^\top\xmat$,
and define the vector $\v{\myvec} := \mat U^\top \tvar_\star$. Then the
MDL complexity~\eqref{eq:mdl_linear} and optimal
redundancy~\eqref{eq:ropt_linear} are given by
\begin{subequations}
\begin{align}
\label{eq:mdl_linear_explicit}
\ensuremath{\textrm{MDL-COMP}}(\pdist_{\tvar_\star}, \mc{Q}_{\mrm{Ridge}}^{\taglin}) & = \frac{1}{2n}\sumn[\min\braces{n, d}]
\log\parenth{\evali + \frac{\sigma^2}{\myvec_i^2}}, \quad
\mbox{and} \\
\label{eq:ropt_lin_model}
\ensuremath{\mc R_{\textrm {opt}}}(\pdist_{\tvar_\star},\!\mc{Q}_{\mrm{Ridge}}^{\taglin}) & = \frac{1}{2n}\sumn[\min\braces{n, d}] \log
\parenth{ 1 + \frac{\evali\myvec_i^2}{\sigma^2}}.
\end{align}
\end{subequations}
\end{theorem}
\noindent See \cref{sub:proof_of_thm:complexity_expressions} for the
proof. \cref{thm:complexity_expressions} provides an explicit
expression for \ensuremath{\textrm{MDL-COMP}}\ which is not merely a parameter count or a
simple function of $d$ and $n$, rather, it depends on the interaction
between the eigenvalues of the covariance matrix $\xmat^\top\xmat$, and the
rotated true parameter scaled by noise variance $\v{\myvec}/\sigma=
\mat U^\top \tvar_\star/\sigma$. The
expression~\eqref{eq:mdl_linear_explicit} is oracle in nature since it
depends on an unknown quantity, namely the true parameter $\tvar_\star$ via
the relation $\v{\myvec} = \mat U ^\top \tvar_\star$.\footnote{\label{footnote:defining_w}When model is under-specified in terms of the features, i.e., $\mat{X}$ includes a subset of features needed to correctly specify the model~\eqref{eq:linear_model_revisit}, $\v{\myvec}$ is defined by considering the restricted version of $\tvar_\star$; and when it is over-specified, i.e., $\mat{X}$ denotes a superset of features, $\v{\myvec}$ is defined by appending zeros to $\tvar_\star$ as necessary. Refer to footnote~\ref{proof:thm1_under_over_specified}, and \cref{sub:mdl_plots_details} for further discussion.}
In \cref{sec:experiments}, we propose a
data-driven and \ensuremath{\textrm{MDL-COMP}}\ inspired hyper-parameter selection criterion
called \textrm{Prac-MDL-COMP}\ to tune the ridge hyper-parameter. Later in
\cref{sec:experiments}, we provide a data-driven approximation to
$\ensuremath{\textrm{MDL-COMP}}$ so that our proposed complexity can also be computed as a
practical complexity measure without requiring knowledge of $\tvar_\star$.
Next, we illustrate the scaling of \ensuremath{\textrm{MDL-COMP}}\ in various settings in
\cref{ssub:scaling_of_mdlcomp} and then prove in
\cref{sub:mdl_complexity_versus_the_mmse} that it informs the fixed
design generalization error (see \cref{thm:lam_opt}). In
\cref{sub:a_minimax_optimality_via_mdltag}, we establish a minimax
optimality of the optimal code that defines \ensuremath{\textrm{MDL-COMP}}\ (see
\cref{thm:minimax_codelength}). \cref{thm:lam_opt,thm:minimax_codelength}
and the empirical performance observed in \cref{sec:experiments}
provide supporting evidence that partially justify our choice of using
ridge based LNML codes to define \ensuremath{\textrm{MDL-COMP}}.
\subsubsection{Scaling of \ensuremath{\textrm{MDL-COMP}}\ for various covariate design}
\label{ssub:scaling_of_mdlcomp}
We now numerically compute \ensuremath{\textrm{MDL-COMP}}\ in several synthetic settings. Below we plot results for three different settings on the covariate design $\mat{X}$, and two different settings for the true parameter. In all cases, the rows of $\mat{X}$ are drawn from $\mc{N}(0, \Sigma)$. In \cref{fig:mdl_gaussian}, we consider two cases $\Sigma = \mat I_d$ (labeled as $\alpha=0$), and $\Sigma = \diag(1, 2^{-\alpha}, \ldots, d^{-\alpha})$ for $\alpha=0.5$.
In \cref{fig:mdl_spike_design}, we choose a \emph{spike design}, where $\Sigma = \diag(16, 16, \ldots, 16, 1, \ldots, 1)$ with the first $s$ (spike dimension) diagonal entries taking value 16, and the rest taking value $1$. In both figures, we evaluate two different settings of $d_\star$ for the true dimensionality of $\tvar_\star$, and select the true parameter $\tvar_\star$ by drawing i.i.d. entries from standard normal, and then normalizing it to have norm $1$. Note that as we move from left to right on the x-axis in these figures, only the covariates used for fitting the model vary, and the generated data remains fixed (so that the model is under-specified for $d<d_\star$, and correctly (over) specified for $d \geq d_\star$). See \cref{sub:mdl_plots_details} for more details on the simulation set-up.
In both the figures, we note the non-linear scaling of MDL-COMP in the overparameterized regime ($d>n$). As we vary the dimension $d$ of the covariates used for computing \ensuremath{\textrm{MDL-COMP}}, in \cref{fig:mdl_gaussian}, we observe a linear scaling of \ensuremath{\textrm{MDL-COMP}}\ with $d$ for $d<n$, but a slow logarithmic or $\log d$ growth for $d>n$. On the other hand, the growth is clearly not linear even for $d<n$ for some of the spike design settings in \cref{fig:mdl_spike_design}. We provide further discussion on the set-up and scaling of MDL-COMP from these figures in \cref{sub:mdl_plots_details,sub:sketch_gaussian,sub:ropt_large_scale} (also see \cref{thm:rmt_expressions}).
\begin{figure}[ht]
\centering
\includegraphics[width=0.9\textwidth]{../figs/gauss_results_n_200}
\caption{Scaling of MDL-COMP for Gaussian design. \textbf{(A)} $\sigma^2=1$, and \textbf{(B)} $\sigma^2=0.01$. We fix the generated data with $n=200$ samples, and vary the dimensionality $d$ of the covariates used for fitting the data. Here $\alpha$ denotes the decay of the eigenvalues in the covariance matrix for the covariates, and $d_\star$ denotes the true dimensionality of $\tvar_\star$.
}
\label{fig:mdl_gaussian}
\end{figure}
\begin{figure}[ht]
\centering
\includegraphics[width=0.9\textwidth]{../figs/sparse_design_snr_4_n_200_noise_std_0}
\caption{Scaling of MDL-COMP for spike design. We fix the generated data with $n=200$ samples, and $\sigma^2=0.01$, and vary the dimensionality $d$ of the covariates used for fitting the data. Here $s$ denotes the spike dimension of the covariance matrix, and $d_\star$ denotes the true dimensionality of $\tvar_\star$.
}
\label{fig:mdl_spike_design}
\end{figure}
\mjwcomment{Doesn't this fact under-cut the main message that we
are trying to make? Namely that using $d$ is what is leading
to double-descent etc.?}
\paragraph{Remark:}
While \cref{thm:complexity_expressions} already provides an analytical expression for \ensuremath{\textrm{MDL-COMP}}\ that can potentially form the new ``x-axis" on the bias-variance tradeoff curves, it largely remains monotone with $d$, implying that the qualitative behavior of estimators in \cref{fig:bias_var} would remain the same.
\subsubsection{\ensuremath{\textrm{MDL-COMP}}\ informs fixed design mean-squared error}
\label{sub:mdl_complexity_versus_the_mmse}
Next, we show that $\ensuremath{\textrm{MDL-COMP}}$ (without the codelength for $\mat{\Lambda}$)
directly bounds the optimal fixed design prediction error (MSE). For
the training data points $\braces{(x_i, y_i)}_{i=1}^n$ generated from
a true model~\eqref{eq:linear_model} with true parameter $\tvar_\star$, the
fixed design prediction MSE of an estimator $\widehat{\tvar}$ is given by
\begin{align}
\label{eq:in_sample_mse}
\textrm{fixed design pred. MSE} :=
\frac{1}{n}\sum_{i=1}^{n}(x_i^\top\widehat{\tvar}-x_i^\top\tvar_\star)^2 =
\frac{1}{n}\enorm{\mat{X} \widehat{\theta} -\mat{X} \tvar_\star}^2.
\end{align}
Note that this fixed design prediction error is very different from
the training MSE \mbox{$(\frac{1}{n}\enorm{\mat{X} \widehat{\theta}
-\v{y}}^2)$.} The in-sample MSE can be considered as a valid proxy
for the out-of-sample MSE (which in turn is usually estimated by test
MSE~\eqref{eq:test_mse}, when the out-of-sample points have the same
covariates as that of the training data; and it has been often used in
prior works to study the bias-variance trade-off for different
estimators~\citep{raskutti2014early}. Our next result shows that the
optimal redundancy $\ensuremath{\mc R_{\textrm {opt}}}$ bounds the optimal in-sample MSE, and that
$\mat{\Lambda}_{\textrm{opt}}$ that achieves $\ensuremath{\mc R_{\textrm {opt}}}$ and defined \ensuremath{\textrm{MDL-COMP}}\ also minimizes
the in-sample MSE. The reader should recall the
definition~\eqref{eq:ropt_linear} of $\ensuremath{\mc R_{\textrm {opt}}}$ and $\mat{\Lambda}_{\textrm{opt}}$.
\begin{theorem}
\label{thm:lam_opt}
For the ridge estimators~\eqref{eq:ridge_new_closed}, we have
\begin{subequations}
\begin{align}
\ensuremath{{\mathbb{E}}}_{\noise[]}
\brackets{\frac{1}{n}\enorm{\mat{X}\widehat{\tvar}_{\mat{\Lambda}_{\textrm{opt}}}-\mat{X}\tvar_\star}^2}
\label{eq:opt_lam_insample_mse}
& = \min_{\mat{\Lambda} \in \mc{M}}\ensuremath{{\mathbb{E}}}_{\noise[]}
\brackets{\frac{1}{n}\enorm{\mat{X}\widehat{\tvar}_{\mat{\Lambda}}-\mat{X}\tvar_\star}^2}
\\
& \leq \frac{\sigma^2}{n}\ensuremath{\mc R_{\textrm {opt}}}(\pdist_{\tvar_\star},\!\mc{Q}_\mrm{Ridge}).
\label{eq:ropt_bounds_insample_mse}
\end{align}
\end{subequations}
\end{theorem}
\noindent See \cref{sub:proof_of_thm:lam_opt} for the proof
of this claim. \\
Later, we show that in experiments, tuning the ridge model via a
practical (data driven) variant of $\ensuremath{\textrm{MDL-COMP}}$ can often minimize
out-of-sample MSE, and provide predictive performance that is
competitive with CV-tuned ridge estimator.
\subsection{Characterizing MDL-COMP for kernel methods}
\label{sub:mdl_complexity_kernel_methods}
We now turn to the non-linear settings, namely kernel methods. Our next result provides a bound on \ensuremath{\textrm{MDL-COMP}}\ for kernel methods.
\begin{theorem}
\label{thm:mdl_kernel}
For the kernel setting~\eqref{eq:kernel_Generative_model}, the MDL complexity~\eqref{eq:mdl_kernel_defn} is bounded as
\begin{align}
\label{eq:mdl_kernel}
\ensuremath{\textrm{MDL-COMP}}(\mb{P}_{f^\star},\!\mc{Q}_{\mrm{Ridge}}^{\tagker}) \leq \inf_{\lambda}\parenth{
\frac{\lambda}
{2n} \frac{\enorm{f^\star}^2_{\mb{H}}}{\sigma^2} + \frac{1}{2n}\sumn \log\parenth{\frac{\evali}{\lambda}+1}}
\end{align}
where $\braces{\evali}_{i=1}^n$ denote the eigenvalues of the kernel
matrix $\mat{K}=(\mc{K}(x_i, x_j))_{i, j=1}^n$.
\end{theorem}
See \cref{sub:proof_of_theorem_thm:mdl_kernel} for the proof. Note that unlike \cref{thm:complexity_expressions}, here we establish an upper bound on MDL-COMP since closed-form expression does not exist. However, as we remark in the proof, we expect this bound to be tight for carefully constructed $f^\star$ for a wide range of behavior on $\braces{\evali}$.
The bound~\eqref{eq:mdl_kernel} in \cref{thm:mdl_kernel} is generic, and can be applied to any kernel setting including the neural tangent kernels that have recently been investigated in the theoretical literature on deep neural networks. Like \cref{eq:mdl_linear_explicit}, this expression also depends on the various problem parameters, including the signal-to-noise ratio $\frac{\enorm{f^\star}_{\mb{H}}}{\sigma} $, and the eigenvalues of the kernel matrix. When additional information on the decay of the eigenvalues $\braces{\evali}$ is available, we can characterize a more refined bound on \ensuremath{\textrm{MDL-COMP}}\ as in the next corollary.
\begin{corollary}
\label{cor:mdl_kernel_smooth}
Suppose $\mc{K}(x, x)=1$, $\evali$ denote the eigenvalues of the kernel matrix $\mat{K}$, and $\textrm{SNR}:=\frac{\enorm{f^\star}_{\mb{H}}}{\sigma}>C$ for some universal constant $C$. Then, we have
\begin{align}
\label{eq:mdl_kernel_smooth}
\ensuremath{\textrm{MDL-COMP}}(\mb{P}_{f^\star},\!\mc{Q}_{\mrm{Ridge}}^{\tagker})
\leq
\begin{cases}
\displaystyle \frac{d\log^2 (nd\textrm{SNR}^2)}{n}
&\text{ if }\evali \precsim n\exp(-i^{1/d}), \\
\displaystyle C_{d, \omega, \textrm{SNR}} \cdot \parenth{\frac{\log (n\textrm{SNR}^2)}{n}}^{\frac{2\omega}{2\omega+d}}
&\text{ if }\evali \precsim n i^{-2\omega/d}, \omega\!>\!d/2, \\[4mm]
\displaystyle C_{d, a, \textrm{SNR}} \cdot \parenth{\frac{\log (n\textrm{SNR}^2)}{n}}^{\frac{d+a}{d+a+1}}
&\text{ if }\evali \precsim ni^{-d-a}, d\!+\!a\!>\!1,
\end{cases}
\end{align}
where the constants $ C_{d, \omega, \textrm{SNR}}, C_{d, a, \textrm{SNR}}$ are independent of $n$, and are defined in \cref{eq:constant_ker_smooth}.
\end{corollary}
See \cref{sub:proof_of_cref_cor_mdl_kernel_smooth} for the proof, where we also provide expressions for the constants appearing on the RHS above.
\paragraph{\ensuremath{\textrm{MDL-COMP}}\ informs minimax in-sample MSE:}
The eigenvalue decay rate of order $\exp(-i^{1/d})$ and,
$i^{-2\omega/d}$ are known to be exhibited by Gaussian kernels and
reproducing kernels for Sobolev spaces of smoothness $\omega$ in
$\ensuremath{\mathbb{R}}^d$ respectively (see
\citet[Thm.~15,16]{santin2016approximation}). Up to logarithmic
factors, the scaling of \ensuremath{\textrm{MDL-COMP}}\ in \cref{eq:mdl_kernel_smooth} with
the sample size $n$ for these settings matches with the
minimax-optimal scaling of the in-sample risk
$\frac{1}{n}\sumn(f^\star(x_i)-\widehat{f}(x_i))^2$~\citep{stone1982optimal,raskutti2014early,wainwright2019high}.
Consequently, in such cases, the scaling of \ensuremath{\textrm{MDL-COMP}}\ is directly
informative of the minimax fixed design prediction error. This
matching of rates between \ensuremath{\textrm{MDL-COMP}}\ and the minimax error provides an
indirect justification for our choice of LNML
codes~\eqref{eq:lnml_family_ker} based on ridge estimators.
\paragraph{MDL-COMP for neural tangent kernels:}
The eigenvalue decay rate of order $i^{-d-a}$ has been recently
established with $a=2$ for deep random feature model, and $a=0$ for
deep neural tangent kernel (NTK) with ReLU activation functions, and
$a=\frac{1}{2^{L}}$ for an $L$-layer deep NTK with step activation
function (see~\citet[Cor.~2,3]{bietti2021deep}) when the covariates
are drawn uniformly from the $d$-dimensional unit sphere. For deep
NTK, the bound~\eqref{eq:mdl_kernel_smooth} and a close tracking of
the constants from the proof (\cref{eq:constant_ker_smooth}) shows
that the MDL-COMP for NTK scales like $(d\log n/n)^{d/(d+1)} \cdot
\textrm{SNR}^{2/(1+d)}$---which depends on the number of layers only through
the change in $\textrm{SNR}$. Consequently, for these setting, our conclusion
parallels that of \cite{bietti2021deep}---namely, adding layers does
not add to the complexity of NTK network. However, we also note that
for a fixed but large sample size $n$, this complexity can decrease as
the dimensionality $d$ of the data increases, at least assuming the
change in $\textrm{SNR}$ does not alter the scaling.
\section{Experiments with data-driven MDL-COMP}
\label{sec:experiments}
This section proposes a practical version of \ensuremath{\textrm{MDL-COMP}}. Simulations and
real-data experiments show that this data-driven \ensuremath{\textrm{MDL-COMP}}\ is useful
for informing generalization. In the experiments to follow, this
data-driven \ensuremath{\textrm{MDL-COMP}}\ as a hyperparameter tuning criteria. While
\cref{thm:lam_opt} guarantees that the optimal regularization defining
(the oracle) $\ensuremath{\textrm{MDL-COMP}}$ also obtains the minimum possible in-sample
MSE, in this section we numerically illustrate the usefulness of the
\textrm{Prac-MDL-COMP}\ for achieving good test MSE which is computed on a fresh
set of samples $(x_i', y_i')_{i=1}^{n_{\textrm{test}}}$ as follows:
\begin{align}
\label{eq:test_mse}
\textrm{test-MSE} & := \frac{1}{n_{\textrm{test}}} \sum_{i=1}^{n_{\textrm{test}}} (y_i'-
\widehat{\tvar} ^\top x_i')^2.
\end{align}
In particular, we first demonstrate that
solving~\eqref{eq:mdl_comp_objective} correlates well with minimizing
test MSE (\cref{fig:vary_lambda}) for linear models. Next, we find
that, for real datasets, \ensuremath{\textrm{MDL-COMP}}\ is competitive with cross-validation
(CV) for performing model selection, actually outperforming CV in the
low-sample regime (\cref{fig:pmlb}). In this section, the linear
models (ridge) and kernel methods are fit using
scikit-learn~\citep{pedregosa2011scikit} and optimization for
hyper-parameter tuning (see~\eqref{eq:mdl_comp_objective}) is
performed using SciPy~\citep{2020SciPy-NMeth}.
\subsection{\ensuremath{\textrm{MDL-COMP}}\ inspired hyper-parameter tuning}
\label{subsec:mld_comp_practical}
As defined, the complexity $\ensuremath{\textrm{MDL-COMP}}$ can not be computed in practice,
since it assumes knowledge of true parameter. Moreover, ridge
estimators are typically fit with only one regularization parameter,
shared across all features. As an alternative that circumvents these
issues, we propose the following data-driven \emph{practical
MDL-COMP}:
\begin{align}
\label{eq:mdl_comp_objective}
\textrm{Prac-MDL-COMP} = \min_{\lambda} \frac{1}{n} \parenth{\frac{\enorm{\mat{X}
\widehat{\tvar}-\v{y}}^2}{2 \sigma^2} + \frac{\lambda \enorm{\widehat{\tvar}}^2}{2
\sigma^2} + \frac{1}{2} \sum_{1=i}^{\min\braces{n,d}} \log
\parenth{1 + \frac{\evali}{\lambda}}},
\end{align}
where $\widehat{\tvar} := \parenth{\xmat^\top\xmat+\lambda \mat I}^{-1} \mat{X}^\top \v{y}$ is the
ridge estimator~\eqref{eq:ridge_new_closed} for $\mat{\Lambda} = \lambda
\mat I_d$, and we use $\evali$ to denote the non-zero eigenvalues of
the matrix $\xmat^\top\xmat$. This expression is the sample-version of the
expression~\eqref{eq:exp_1} for $\ensuremath{\mc R_{\textrm {opt}}}$ derived in the proof of
Theorem~\ref{thm:complexity_expressions} where we enforce $\mat{\Lambda} =
\lambda \mat I$. And similarly, \cref{eq:ropt_expression} from the
proof suggests that we can define a data-driven approximate optimal
redundancy ($\ensuremath{\mc R_{\textrm {opt}}}$) as follows:
\begin{align}
\label{eq:approx_ropt}
\widehat{\mc{R}}_{\textrm{opt}} := \frac1{2n} \sum_{i=1}^{\min\braces{n, d}}\log\parenth{1+\frac{\evali}{\lambda_{\textrm{opt}}}}
\end{align}
where $\lambda_{\textrm{opt}}$ is the optimal hyperparameter for the objective~\eqref{eq:mdl_comp_objective}. Since we only have one hyper-parameter in defining \textrm{Prac-MDL-COMP}, we can also treat the approximate $\widehat{\mc{R}}_{\textrm{opt}}$ as a proxy for \ensuremath{\textrm{MDL-COMP}}\ over the class $\braces{\mathbb{Q}_{\lambda}: \lambda \in (0, \infty)}$.
For kernel methods, an analogous data-driven criterion for MDL-COMP is given by
\begin{align}
\label{eq:kernel_prac_mdl_comp}
\textrm{Prac-MDL-COMP}_{\mat{K}} = \min_{\lambda}
\frac{1}{n}\parenth{\frac{\enorm{\mat{K} \widehat{\tvar}-\v{y}}^2}{2\sigma^2} + \frac{\lambda \widehat{\tvar}^\top \mat{K} \widehat{\tvar}}{2\sigma^2}
+ \frac12 \sum_{i=1}^n \log \parenth{1+\frac{\evali}{\lambda}}}
\end{align}
where now $\widehat{\tvar} = (\mat{K} + \lambda \mat{I})^{-1} \v{y} $~\eqref{eq:kernel_ridge}, and
$\{ \evali \}_{i=1}^n$ denote the eigenvalues of the kernel matrix
$\mat{K}$.
\subsection{\textrm{Prac-MDL-COMP}\ informs test MSE in Gaussian simulations}
\label{sub:test_mse}
\cref{fig:vary_lambda} shows that the model corresponding to the optimal
$\lambda$ achieving the minimum in \cref{eq:mdl_comp_objective}, has a low
test MSE (panels A-E), and comparable to the one obtained by leave-one-out
cross validation (LOOCV, panel F).
The setup follows the same Gaussian design as in \cref{fig:bias_var}, except the noise variance $\sigma^2$ is set to 1.
Here the covariates are $d=100$ dimensional and are drawn i.i.d. from $\mc N(0, 1)$.
$\tvar_\star$ is taken to have dimension $50$ (resulting in misspecification when $d<50$); its entries are first drawn i.i.d. from $\mc N(0, 1)$ and then scaled so that $\Vert\tvar_\star\Vert=1$. The noise variance $\sigma^2$ is set to $1$. We tune the parameter $\lambda$ over 20 values equally spaced on a log-scale from $10^{-3}$ to $10^6$.
Across all panels (A-E), i.e., any choice of $d/n \in \braces{1/10, 1/2, 1, 2, 10}$, we observe that the minima of the test MSE and the objective~\eqref{eq:mdl_comp_objective} for defining \textrm{Prac-MDL-COMP}\ often occur close to each other (points towards the bottom left of these panels).
\cref{fig:vary_lambda}F shows the generalization performance of the models
selected by \textrm{Prac-MDL-COMP}\ in the same setting. Selection via \textrm{Prac-MDL-COMP}\
generalizes well, very close to the best ridge estimator selected by leave-one-out
cross-validation.
\cref{sec:supp_experiments} shows more results suggesting that \textrm{Prac-MDL-COMP}\ can select models well even under different forms of misspecification.
\begin{figure}[ht]
\centering \includegraphics[width=\textwidth]{fig_lambda_top}
\makebox[\textwidth][c]
{\includegraphics[height=1.37in]{fig_lambda_bot}
\includegraphics[height=1.32in]{fig_iid_mse} }
\caption{Minimizing the objective~\eqref{eq:mdl_comp_objective}
which defines \textrm{Prac-MDL-COMP}\ selects models with low test
error. \textbf{A-E.} Different panels show that this holds even
as $d/n$ is varied. \textbf{F}. \textrm{Prac-MDL-COMP} selects a model
with Test MSE very close to Ridge cross-validation, avoiding the
peak exhibited by OLS.}
\label{fig:vary_lambda}
\end{figure}
\subsection{Experiments with PMLB datasets}
\label{sub:real_experiments}
In this section, we report results on the behavior
\textrm{Prac-MDL-COMP}~\eqref{eq:mdl_comp_objective} when used to perform model
selection on real datasets. Datasets are taken from PMLB
\citep{olson2017pmlb, OpenML2013}, a repository of diverse tabular
datasets for benchmarking machine-learning algorithms. We omit
datasets that are simply transformations of one another, or that have
too few features; doing so yields a total of 19 datasets spanning a
variety of tasks, such as predicting breast cancer from image
features, predicting automobile prices, and election results from
previous elections~\citep{simonoff2013analyzing}. The mean number of
data points for these datasets is 122,259 and the mean number of
features is 19.1. For a given dataset, we fix $d$ to be the number of
features, and we vary $n$ downwards from its maximum value (by
subsampling the dataset) to construct instances with different values
of the ratio $d/n$. The hyperparameter $\lambda$ takes on 10 values
equally spaced on a log scale between $10^{-3}$ and $10^3$. The test
set consists of 25\% of the entire dataset.
\cref{fig:pmlb}A compares the performance of Prac-MDL-COMP to
Ridge-CV. We find that shows that in the limited data regime,
i.e. when $d/n$ is large, Prac-MDL-COMP tends to outperform. As the
number of training samples is increased (i.e., $d/n$ decreases), the
advantage provided by selection via Prac-MDL-COMP decreases. Further
details, and experiments on omitted datasets are provided in
\cref{sub:real_data_experiments_continued}; in particular, see
\cref{fig:pmlb_5fold,fig:pmlb_full,tab:datasets}.
\begin{figure}[ht]
\centering
\makebox[\textwidth][c]{\includegraphics[width=1\textwidth]{fig_pmlb}}
\caption{Comparing test-error when selecting models using Prac-MDL-COMP
versus using cross-validation on real datasets. \textbf{A}. When data
is most limited, Prac-MDL-COMP based hyperparameter tuning outperforms Ridge-CV. \textbf{B, C}. As the amount of training samples increases, Prac-MDL-COMP performs comparably to Ridge-CV. Each point averaged over 3 random bootstrap samples.}
\label{fig:pmlb}
\end{figure}
\subsection{Experiments with fMRI data}
We now focus on a challenging type of data that arises in
neuroscience. The dataset consists of neural responses of human
subjects, as recorded by functional magnetic-resonance imaging (fMRI),
as they are shown natural
movies~\citep{nishimoto2011reconstructing}. The training data consists
of 7,200 time points and the test data consists of 540 time points,
where at each timepoint a subject is watching a video clip. The test
data is averaged over 10 repetitions of showing the same clip to the
same subject. Following the previous work, we extract video features
using a Gabor transform, resulting in 1,280 features per
timepoint. From these features, we predict the response for each voxel
in the brain using ridge regression. To summarize, for this setting,
we have $d=1280, n_{\textrm{train}}=7200$ and $n_{\textrm{test}}=540$.
We restrict our analysis to 50 voxels with no missing data in the V1,
V2, and V4 regions of the brain, which are known to be easier to
predict. Before fitting, the features and responses are each
normalized to have mean zero and variance one. In all fMRI
experiments, $\lambda$ takes on 40 values equally spaced on a log
scale between $10^{0}$ and $10^6$.
\cref{fig:fmri_results} shows our prediction results when using Prac-MDL-COMP for model selection to predict the fMRI responses. We compare to Automatic Relevance Determination (ARD), a popular Bayesian approach which places an adaptive prior over the regression parameters~\citep{mackay1994bayesian}. \cref{fig:fmri_results}A shows that Prac-MDL-COMP consistently outperforms the Bayesian ARD baseline across voxels. Moreover, Prac-MDL-COMP is roughly on par with leave-one-out cross-validation (CV) for model selection in this data (\cref{fig:fmri_results}).
CV outperforms Prac-MDL-COMP for a majority of the voxels by a slight margin, but on the remaining voxels, Prac-MDL-COMP tends to outperform CV by a substantial margin.
\begin{figure}[ht]
\centering
\includegraphics[width=0.9\textwidth]{fig_fmri_results_test_only.pdf}
\caption{Prac-MDL-COMP succesfully selects models which predict fMRI responses well. \textbf{A}. Prac-MDL-COMP outperforms the Bayesian ARD baseline for every voxel (each point represents one voxel). \textbf{B}. Prac-MDL-COMP is on par with cross-validation. }
\label{fig:fmri_results}
\end{figure}
\cref{fig:fmri_results_scatter_plot}A shows the relationship between the Prac-MDL-COMP objective and the test error. Test error tends to increase as the Prac-MDL-COMP objective increases, showing that minimizing the objective continues to inform good model selection for minimizing test error even for this challenging real dataset. In \cref{fig:fmri_results_scatter_plot}B, we provide a scatter plot of the test MSE versus $\widehat{\mc R}_{\textrm{opt}}$ computed from data. We notice a linear relationship between the two quantities, and observe a correlation of $0.69$. While, \cref{thm:lam_opt} guaranteed that the optimal redundancy $\ensuremath{\mc R_{\textrm {opt}}}$ bounds the in-sample MSE, \cref{fig:fmri_results_scatter_plot}B suggests that its data-driven approximation also provides useful information about the (ordering of) test MSE.
\begin{figure}[ht]
\centering
\includegraphics[width=0.9\textwidth]{fig_fmri_results_variation_mse_prac_mdl_comp.pdf}
\caption{\textbf{A}. Test MSE often increases when Prac-MDL-COMP objective increases, showing that minimizing the objective informs good model selection for minimizing Test MSE. Each gray curve represents one randomly chosen voxel (only 10 out of 50 are shown for visualization). \textbf{B} Scatter plot (over the 50 different voxels) of test MSE versus the estimated $\widehat{\mc R}_{\textrm{opt}}$.}
\label{fig:fmri_results_scatter_plot}
\end{figure}
\subsection{Experiments with neural tangent kernel}
\cref{fig:fmri_ntk_results} shows the results when repeating the
experiments in \cref{fig:fmri_results}, but now using kernel ridge
regression with the neural tangent kernel~\citep{jacot2018neural}
rather than linear ridge regression. It shows the prediction results
when using Prac-MDL-COMP (applied to kernel ridge regression, see
\cref{eq:kernel_prac_mdl_comp}) for model selection to predict the
fMRI responses. For the neural tangent kernel computation, we use the
neural-tangents library~\citep{neuraltangents2020} with its default
parameters (ReLU nonlinearity, two hidden linear layers with hidden
size of 512). \cref{fig:fmri_ntk_results}A shows that Prac-MDL-COMP is
roughly on par with leave-one-out cross-validation for model selection
in this data. \cref{fig:fmri_ntk_results}B shows the relationship
between the Prac-MDL-COMP objective and the test error, where we see
that the curves are flatter when compared to
\cref{fig:fmri_results_scatter_plot}A. Nonetheless, the test error
often decreases as the Prac-MDL-COMP objective increases, suggesting
that minimizing the objective is a good proxy for model selection for
minimizing test error even for this setting.
\begin{figure}[ht]
\centering
\includegraphics[width=\textwidth]{../figs/fig_kernel_fmri_results}
\caption{Prac-MDL-COMP succesfully selects models which predict
fMRI responses well when using
NTK-kernel. \textbf{A}. Prac-MDL-COMP is on par with
cross-validation for every voxel (each point represents one
voxel). \textbf{B}. Test MSE often increases when Prac-MDL-COMP
objective increases, showing that minimizing the objective
informs good model selection for minimizing Test MSE. Each gray
curve represents one randomly chosen voxel (only 8 are shown for
visualization).}
\label{fig:fmri_ntk_results}
\end{figure}
\section{Discussion}
\label{sec:discussion}
In this work, we revisited the two factors dictating the bias-variance
tradeoff principle: the class of estimators and the complexity
measure. We argued that the bias-variance tradeoff can be expected to
hold given a fixed set of samples, as the complexity of estimators is
varied; where the class of estimators has to be , and the complexity
has to be a valid notion. We argue that there is a lack of theoretical
justification for using parameter count as complexity in
high-dimensions. In order to derive a valid notion for all dimensions,
we defined an MDL-based complexity measure MDL-COMP for linear models
using codes enduced by ridge estimators. Our analytical results show
that MDL-COMP depends on $d, n$, the covariate/kernel matrix, and the
true parameter/function values. It does not grow linearly in $d$ in
the over-parameterized setting; in fact, it often grows much more
slowly as $\log d$ for $d > n$. Numerical experiments show that an
practical hyperparameter tuning scheme, inspired by MDL-COMP, provides
generalization performance for various types of ridge estimators,
often outperforming cross-validation when the number of observations
is limited. We prove that MDL-COMP informs the fixed design
generalization error, and and provides good empirical results for the
random design generalization error. We believe our work takes a
useful step towards better understanding the bias-variance trade-off,
and provides a proof of concept for the value of revisiting the
complexity measure in modern high-dimensional settings.
Several future directions arise from our work. Relating MDL-COMP with
out-of-sample guarantees under additional assumptions on the covariate
design, like those in~\citep{hsu2012random,dobriban2018high} for
linear models, is one interesting open problem. Ridge estimators are
not suitable for parameter estimation with sparse models in
high-dimensions, and thus deriving MDL-COMP with codes suitably
adapted for $\ell_1$-regularization would also be
interesting. Additionally, it remains to define and investigate
\ensuremath{\textrm{MDL-COMP}}\ beyond linear and kernel methods, e.g., for deep neural
networks, as well as for classification tasks.
\acks{This work was partially supported by National Science Foundation
grant NSF-DMS-1613002, NSF-2015341, and the Center for Science of
Information (CSoI), a US NSF Science and Technology Center, under
grant agreement CCF-0939370, and an Amazon Research Award to BY, and
Office of Naval Research grant DOD ONR-N00014-18-1-2640 and National
Science Foundation grant NSF-DMS-2015454 to MJW.}
\begin{appendix}
\setcounter{table}{0}
\setcounter{figure}{0}
\renewcommand{\thefigure}{A\arabic{figure}}
\renewcommand{\thetable}{A\arabic{table}}
\section{Further discussion of \ensuremath{\textrm{MDL-COMP}} }
\label{sub:non_isotropic}
We start with additional details on the simulation set-up and sketch
related to the \ensuremath{\textrm{MDL-COMP}}\ scaling from
\cref{sub:mdl_complexity_for_linear_models} in
\cref{sub:mdl_plots_details}. In \cref{sub:sketch_gaussian}, we
sketch the proof for the \ensuremath{\textrm{MDL-COMP}}'s behavior as observed in
\cref{fig:mdl_gaussian}, and then provide an analytical bound for
$\ensuremath{\mc R_{\textrm {opt}}}$ in \cref{sub:ropt_large_scale} under high-dimensional
asymptotics. In \cref{sub:a_minimax_optimality_via_mdltag}, we argue
that the minimax optimality of MDL-COMP holds under a broad class of
noise distributions (beyond Gaussian) under the linear
model~\eqref{eq:linear_model_revisit}. Finally, we collect some
additional background related to MDL in \cref{sub:further_background}.
\subsection{Simulation set-up}
\label{sub:mdl_plots_details}
Here we elaborate the set-up associated with
\cref{fig:mdl_gaussian,fig:mdl_spike_design}. The true dimensionality
$d_\star$ denotes that the observations $\v{y} = \widetilde{\mat{X}}\tvar_\star
+ \noise[]$ depend only on first $d_\star$ covariates of the full
matrix $ \mat{X}_{\textrm{full}}$, Given a sample size $n$ (fixed for a
given dataset, fixed in a given plot), the matrix
$\mat{X}_{\textrm{full}} \in \ensuremath{\mathbb{R}}^{n \times \overline{d}}$, and
$\widetilde{\mat{X}} \in \ensuremath{\mathbb{R}}^{n\times d_\star}$ where $\overline{d}$ denotes
the maximum number of covariates available for fitting the model (and
in our plots can be computed by multiplying the sample size with the
the maximum value of $d/n$ denoted on the $x$-axis). When we vary $d$,
we use $\mat{X} \in \ensuremath{\mathbb{R}}^{n \times d}$ (selecting first $d$ columns of
$\mat{X}_{\textrm{full}}$) for fitting the ridge model and computing the
\ensuremath{\textrm{MDL-COMP}}.
\paragraph{Defining $\v{\myvec}$, and clarifying footnote~\ref{footnote:defining_w}:}
In order to compute \ensuremath{\textrm{MDL-COMP}}~\eqref{eq:mdl_linear_explicit}, we need to
compute the eigenvalues $\evali$ of $\xmat^\top\xmat$, where $\mat{X} \in \ensuremath{\mathbb{R}}^{n
\times d}$ denotes the first $d$ columns of the full matrix
$\mat{X}_{\textrm{full}}$ that are used for fitting the ridge model, and
computing the corresponding encoding and \ensuremath{\textrm{MDL-COMP}}. Moreover, we need
to compute the vector $\v\myvec$ defined equal to $\mat U ^\top \tvar_\star$
in equation~\eqref{eq:xmatrix}. Note that $\mat U$ has size $d \times
d$ and $\tvar_\star$ is $d_\star$ dimensional. So when $d<d_\star$, the
vector $\v\myvec$ is computed by restricting $\tvar_\star$ to first $d$
dimensions (in \cref{eq:xmatrix}), i.e., using $\widetilde{\theta}_{\star} =
(\tvar_\star)_{[1:d]}$ (the orthogonal projection of $\tvar_\star$ on $\xmat^\top\xmat$)
and define $\v\myvec = \mat U ^\top \widetilde{\tvar_\star}$. On the other
hand, for $d>d_\star$, we simply extend the $\tvar_\star$ by appending
$d-d_\star$ $0$'s, i.e., $\widetilde{\theta}_{\star} = \begin{bmatrix} \tvar_\star
\\ \mathbf 0 _{d-d_\star}
\end{bmatrix}$ and then set $\v\myvec = \mat U ^\top \widetilde{\theta}_{\star}$.
\subsection{Proof sketch for random isotropic
designs}
\label{sub:sketch_gaussian}
In this section, we provide a proof sketch to explain the behavior of
\ensuremath{\textrm{MDL-COMP}}/ when applied to random isotropic designs, as plotted in
\cref{fig:mdl_gaussian}. Suppose that the design matrix $\mat{X} \in
\ensuremath{\mathbb{R}}^{n \times d}$ has entries drawn from iid from the Gaussian
distribution $\mc N(0, 1/n)$; the $1/n$-variance serves to ensure that
$\mat{X}$ has columns with expected squared norm equal to one. When $n
\gg d$, standard random matrix theory guarantees that $\xmat^\top\xmat \approx
\mat I_d$ and hence $\evali \approx 1$. For $d \gg n$, one can apply
the same argument to the matrix $\mat{X}\xmat^\top$ to conclude that
$\mat{X} \mat{X}^\top \approx \frac dn \mat I_n$; thus, the matrix $\xmat^\top\xmat$
has rank $n$ with its non-zero eigenvalues roughly equal to $d/n$. And, from above, we recall the definition $\v\myvec = \mat U^\top \widetilde{\theta}_{\star}$, where $\widetilde{\theta}_{\star}$ is either a restriction of $\tvar_\star$ when the model is under-specified, or is obtained by appending zeros when the model is over-specified..
Since the matrix $\mat U$ consists of the eigenvectors of $\xmat^\top\xmat$, it
has a uniform distribution over the space of all orthogonal matrices
in dimension $d$. Let $r^2 := \enorm{\tvar_\star}^2$ and, note from above that $\enorm{\v\myvec}^2 = \enorm{\widetilde{\theta}_{\star}}^2$. When $d \geq d_\star$, we have $\enorm{\widetilde{\theta}_{\star}}^2 = r^2$, and when $d<d_{\star}$, and the coordinates of $\tvar_\star$ are drawn iid, we have $\enorm{\widetilde{\theta}_{\star}}^2 \approx \frac{d}{d_{\star}} r^2$. Given the distribution of $\mat U$, we have that the entries of $w_i^2$ are approximately equal, and thus conclude that $ w_i^2 \approx \min\braces{1, \frac{d}{d_{\star}}} \frac{r^2}{d} = r^2 \cdot
\min\braces{\frac{1}{d}, \frac{1}{d_\star}}$. Plugging in these
approximations, when $d_\star <n$, we find that
\begin{align}
\ensuremath{\textrm{MDL-COMP}}\!=\! \frac1{2n}\sumn[\min\braces{n, d}] \log\parenth{\evali+ \frac{\sigma^2}
{\myvec_i^2}}
\approx \begin{cases}
\displaystyle \frac dn \log\parenth{1+ d_\star/r^2}
&\text{ if }d \in [1, d_\star]\\[2mm]
\displaystyle \frac dn \log\parenth{1+d/r^2}
&\text{ if } d \in [d_\star, n]\\[2mm]
\displaystyle \log \brackets{d \parenth{\frac{1}{r^2}+\frac 1n}}
&\text{ if } d \in [n, \infty)
\end{cases}
\label{eq:adj_scaling}
\end{align}
\begin{align}
\ensuremath{\mc R_{\textrm {opt}}}\!=\!\frac1{2n}\sumn[\min\braces{n, d}] \log\parenth{1 + \frac{\evali\myvec_i^2}{\sigma^2}}
\approx \begin{cases}
\displaystyle \frac dn \log\parenth{1+ \frac{r^2}{d_\star}}
&\text{ if } d \in [1, d_\star]\\[2mm]
\displaystyle\frac dn \log\parenth{1+ \frac{r^2}{d}}
&\text{ if }d \in [d_\star, n]\\[2mm]
\displaystyle \log\parenth{1+ \frac{r^2}{n}}
&\text{ if } d \in [n, \infty).
\end{cases}
\label{eq:adj_scaling_ropt}
\end{align}
For the case when $d_\star > n$, i.e., the true dimensionality is larger than the sample size, we have
\begin{align}
\ensuremath{\textrm{MDL-COMP}}\!=\! \frac1{2n}\sumn[\min\braces{n, d}] \log\parenth{\evali+ \frac{\sigma^2}
{\myvec_i^2}}
&\approx \begin{cases}
\displaystyle \frac dn \log\parenth{1+ \frac{d_\star}{r^2}}
&\text{ if } d \in [1, n]\\[2mm]
\displaystyle\log\parenth{\frac dn + \frac{d_\star}{r^2}}
&\text{ if } d \in [n, d_\star]\\[2mm]
\displaystyle \log \brackets{d \parenth{\frac{1}{r^2}+\frac 1n}}
&\text{ if } d \in [d_\star, \infty),
\end{cases}
\label{eq:adj_scaling_high_dim} \\
\ensuremath{\mc R_{\textrm {opt}}}= \frac1{2n}\sumn[\min\braces{n, d}] \log\parenth{1 + \frac{\evali\myvec_i^2}{\sigma^2}}
&\approx \begin{cases}
\displaystyle \frac dn \log\parenth{1+ \frac{r^2}{d_\star}}
&\text{ if } d \in [1, d_\star]\\[2mm]
\displaystyle\frac dn \log\parenth{1+ \frac{r^2}{d}}
&\text{ if } d \in [d_\star, n]\\[2mm]
\displaystyle \log\parenth{1+ \frac{r^2}{n}}
&\text{ if } d \in [n, \infty).
\end{cases}
\label{eq:adj_scaling_ropt_high_dim}
\end{align}
In both of the cases covered by equations~\eqref{eq:adj_scaling} and
\eqref{eq:adj_scaling_high_dim}, we find that the MDL-COMP has scaling
$\mc O(d/n)$ for small $d$, and $\mc O (\log d)$ for $d \gg n$.
Overall, this argument along with results in \cref{fig:mdl_gaussian}
suggest that $d/n$ should not be treated as the default complexity for
$d > n$, and that \ensuremath{\textrm{MDL-COMP}}\ provides a scaling of order $\log d$ for $d
> n$.
\subsection{Expressions for $\ensuremath{\mc R_{\textrm {opt}}}$ for large scale settings}
\label{sub:ropt_large_scale}
In recent work, a number of
authors~\citep{hastie2019surprises,belkin2019two} have studied the
generalization error of different estimators applied to linear models
under the high-dimensional asymptotic scaling $\ensuremath{d}, \samples \to \infty$
and $\ensuremath{d}/\samples \to \gamma$. In a similar setting, we can derive an
expression for the optimal redundancy $\ensuremath{\mc R_{\textrm {opt}}}$.
\begin{theorem}
\label{thm:rmt_expressions}
Suppose that the covariate matrix $\mat X \in \ensuremath{\mathbb{R}}^{n \times d}$ has
i.i.d. entries drawn from a distribution with mean $0$, variance $1/n$
and fourth moments of order $1/n^2$, and that the parameter $\tvar_\star$
is drawn randomly from a rotationally invariant distribution, with
$\ensuremath{{\mathbb{E}}}[\frac{\enorm{\tvar_\star}^2}{\sigma^2 d}] = \mrm{snr}$. Then, we have
\begin{align}
\label{eq:mdl_complexity_rmt}
\lim_{n, d\to \infty, \frac{d}{n}\to\gamma}\ensuremath{{\mathbb{E}}}_{\tvar_\star}[\ensuremath{\mc R_{\textrm {opt}}}(\pdist_{\tvar_\star}, \mc{Q}_{\mrm{Ridge}}^{\taglin})]
\leq \gamma \log(1+\mrm{snr} - \delta)
+ \log(1+\gamma \cdot \mrm{snr} - \delta)
- \frac{\delta}{\mrm{snr}},
\end{align}
almost surely, where $\delta := (\sqrt{\mrm{snr}(1+\sqrt{\gamma})^2+1} - \sqrt{\mrm{snr}(1-\sqrt{\gamma})^2+1})^2/4$.
\end{theorem}
See \cref{sub:proof_of_thm:rmt_expressions} for the proof. We remark
that the inequality in the theorem is a consequence of Jensen's
inequality and can be removed whenever a good control over the
quantity $\ensuremath{{\mathbb{E}}}_{w_i^2}\log(1+w_i^2 \evali)$ with $\evali$ denotes the eigenvalues of $\xmat^\top\xmat$
is available.
The first term on the RHS of \cref{eq:mdl_complexity_rmt} has a
scaling of order $d/n$ when the norm of $\tvar_\star$ grows with $d$.
However, when $\enorm{\tvar_\star}$ is held constant with $d$, the optimal
redundacy $\ensuremath{\mc R_{\textrm {opt}}}$ does not grow and remains bounded by a constant. The
bound~\eqref{eq:mdl_complexity_rmt} has a similar scaling as that
noted earlier in
\cref{eq:adj_scaling_ropt,eq:adj_scaling_ropt_high_dim} from our proof
sketch (for $d \in [d_\star, n]$ or $d\in [n , \infty)$, assuming
$d_\star$ fixed, $r^2$ growing with $d$).
\subsection{\ensuremath{\textrm{MDL-COMP}} over a wider range of noise distributions}
\label{sub:a_minimax_optimality_via_mdltag}
\cref{thm:complexity_expressions} provides an explicit expression for
\ensuremath{\textrm{MDL-COMP}}\ assuming that the noise follows a Gaussian distribution. In
this section, we show that the optimal code from \cref{eq:ropt_linear}
defining the \ensuremath{\textrm{MDL-COMP}}\ procedure~\eqref{eq:mdl_linear} also achieves a
minimax codelength over a wider range of noise distributions. Let
$\mc{P}$ denote the set of all distributions on $\ensuremath{\mathbb{R}}^n$, and define
the family
\begin{align}
\label{eq:plin_defn}
\mc{P}_{\textrm{bndvar}} = \braces{\P \in \mc{P}: \ensuremath{{\mathbb{E}}}[\noise[]] = 0,
\textrm{Var}(\noise[])\preceq \sigma^2 \mat I_n }.
\end{align}
For the generative linear model~\eqref{eq:linear_model_revisit} with
noise distribution now allowed to belong to the family
$\mc{P}_{\textrm{bndvar}}$~\eqref{eq:plin_defn}, we have
\begin{align*}
\ensuremath{{\mathbb{E}}}_{\noise[]}[\v{y}\vert \mat{X}] = \mat{X} \tvar_\star, \qtext{and}
\textrm{Var}_{\noise[]}(\v{y} \vert \mat{X}) \preceq \sigma^2 \mat
I_n.
\end{align*}
Our next result shows that the code definining \ensuremath{\textrm{MDL-COMP}}\ also achieves
the minimax codelength over the noise distributions in $\mc{P}_{\textrm{bndvar}}$.
\begin{theorem}
\label{thm:minimax_codelength}
The distribution $\mathbb{Q}_{\mat{\Lambda}_{\textrm{opt}}}$ that achieves the \ensuremath{\textrm{MDL-COMP}}\ in
\cref{eq:mdl_linear} also achieves the minimax codelength in the
class $\mc{P}_{\textrm{bndvar}}$, i.e.,
\begin{align}
\label{eq:minimax_codelength}
\mathbb{Q}_{\mat{\Lambda}_{\textrm{opt}}} \in\arg\min_{\mathbb{Q}\in\mc{Q}_{\mrm{Ridge}}^{\taglin}}
\max_{\P\in\mc{P}_{\textrm{bndvar}}}
\ensuremath{{\mathbb{E}}}_{\noise[]\sim\P}\log\parenth{\frac{1}{q(\v{y})}},
\end{align}
where $q$ denotes the density of the distribution $\mathbb{Q}$.
\end{theorem}
\noindent See \cref{sub:proof_of_thm:minimax_codelength} for the proof
of this claim. \\
\subsection{Further background on MDL}
\label{sub:further_background}
As noted earlier, for computing the optimal redundancy in
\cref{eq:ropt_defn}, one can replace the set of codes
$\mc{Q}_{\mrm{Ridge}}$ by a generic set of codes $\mc{Q}$ corresponding to
many classes of models. In contrast, for maximum likelhood estimation
(MLE), one maximizes the log likelihood of the data over a fixed model
class. Maximum likelihood is generally used when a model class is
fixed, and is known to break down when considering even nested classes
of parametric models~\citep{hansen2001model}. In fact, the
definition~\eqref{eq:ropt_defn} can be suitably adjusted even for the
case when there is no true generative model for $\v{y}$. At least in
general, the quantity $\mathbb{Q}(\v{y})$ need not denote the likelihood of
the observation $\v{y}$, and the distribution $\mathbb{Q}$ may not even
correspond to a generative model. In such cases, the optimal choice of
$\mathbb{Q}$ in \cref{eq:ropt_defn} is supposed to be optimal not just for
$\v{y}$ from a parametric family, but also for $\v{y}$ from one of many
parametric model classes of different dimensions.
However, when $\mc{Q}$ is a single parametric family, i.e., $\mc{Q} =
\braces{\mathbb{P}_{\theta}, \theta \in \Theta}$ where $\theta$ denotes
the unknown parameter of interest, the MDL principle does reduce to
the MLE principle. In more precise terms, the MLE can be seen as the
continuum limit of two-part MDL (see Chapter
15.4~\citep{grunwald2007minimum}). In this case, the optimal NML code
$\mathbb{Q}^\star(\v{y})$ is given by the logarithm of the likelihood
computed at MLE plus a term that depends on the normalization constant
of the maximum likelihood over all possible observations; this fact
underlies the nomenclature of normalized maximum likelihood, or NML
for short.
For the low-dimensional linear models (fixed $d$ and $n\to \infty)$,
while several MDL-based complexities, namely two-part codelength,
stochastic information complexity, and NML complexity are equivalent
to the first $\mc O(\log n)$ term---which in turn scales like
$\tfrac{1}{2} d \log n$. Moreover, the NML complexity can be deemed
optimal when accounting for the constant term, i.e., NML complexity
achieves the optimal $\mc O(1)$ term which involves Jeffrey's
prior~\citep{barron1998minimum}, asymptotically for low-dimensional
linear models. We refer readers to the
sources~\citep{rissanen1986stochastic,barron1998minimum,hansen2001model}
for further discussion on two-part coding, stochastic information
complexity, and toSections 5.6, 15.4 of the
book~\citep{grunwald2007minimum} for further discussion on the
distinctions between MDL and MLE.
\section{Further numerical experiments}
\label{sec:supp_experiments}
\setcounter{table}{0} \setcounter{figure}{0}
\renewcommand{\thefigure}{B\arabic{figure}}
\renewcommand{\thetable}{B\arabic{table}}
We now present additional experiments showing the usefulness of the
data-driven \textrm{Prac-MDL-COMP}~\eqref{eq:mdl_comp_objective}. In particular,
we show that \textrm{Prac-MDL-COMP}\ informs out-of-sample MSE in Gaussian as
well as several misspecified linear models
(\cref{sub:misspecified_linear_models}), and then provide further
insight on the performance of real-data experiments (deferred from
\cref{sub:real_experiments} of the main paper) in
\cref{sub:real_data_experiments_continued}.
\subsection{Misspecified linear models}
\label{sub:misspecified_linear_models}
We specify three different types of model misspecification taken from
prior work \citep{yu2020veridical} and analyze the ability of MDL-COMP
to select models that generalize. \cref{fig:shifts} shows that under
these conditions, MDL-COMP still manages to pick a $\lambda$ which
generalizes fairly well. \textit{T-distribution} refers to errors
being distributed with a t-distribution with three degrees of freedom.
\textit{Decaying eigenvalues} refers to the eigenvalues of the
covariance matrix $\lambda_i$ decaying as $1/2^{i}$, inducing
structure in the covariance matrix. \textit{Thresholds} refers to
calculating the outcome using indicator functions for $X>0$ in place
of $X$. Here, Ridge-CV (orange dotted line) refers to model selection
using leave-one-out cross-validation and Prac-MDL-COMP (blue line)
refers to model selection for a ridge model based on optimizing
Prac-MDL-COMP.
\begin{figure}[ht]
\centering \includegraphics[width=\textwidth]{fig_shifts}
\caption{Model selection under misspecification. Under various
misspecifications, \textrm{Prac-MDL-COMP}\ still manages to select models
which generalize reasonably well. Different from other figures
presented in the paper, here $d$ is fixed and the sample size
$n$ is varied.}
\label{fig:shifts}
\end{figure}
\subsection{Real data experiments continued}
\label{sub:real_data_experiments_continued}
We now provide further investigation. First, the good performance of
\textrm{Prac-MDL-COMP}\ based linear model also holds ground against $5$-fold CV,
see \cref{fig:pmlb_5fold}.
Here we show results for 28 real datasets in \cref{fig:pmlb_full}
where the plot titles correspond to dataset IDs in
OpenML~\citep{OpenML2013}. In the limited data regime (when $d/n$ is
large, the right-hand side of each plot), MDL-COMP tends to outperform
Ridge-CV. As the number of training samples is increased, the gap
closes or cross-validation begins to outperform MDL-COMP. These
observations provide evidence for promises of \textrm{Prac-MDL-COMP}\ based
regularization for limited data settings.
\begin{figure}[ht]
\centering
\makebox[\textwidth][c]{\includegraphics[width=\textwidth]{fig_pmlb_5fold}}
\caption{Results for \fref{fig:pmlb} hold when using 5-fold CV rather than LOOCV.}
\label{fig:pmlb_5fold}
\end{figure}
\begin{figure}[ht]
\centering
\makebox[\textwidth][c]{\includegraphics[width=1\textwidth]{fig_pmlb_curves}}
\caption{Test MSE when varying the number of training points sampled from real datasets (lower is better). MDL-COMP performs well, particularly when the number of training points is small (right-hand side of each plot). Each point averaged over 3 random bootstrap samples.}
\label{fig:pmlb_full}
\end{figure}
\begin{table}[ht]
\makebox[\textwidth][c]{
\small
\centering
\begin{tabular}{lrrcc}
\toprule
\shortstack{\bf Dataset name \\ \bf(OpenML ID)} & \shortstack{\bf \#obs $n$} &
\shortstack{\bf \#feats $d$ } & \shortstack{\bf Ridge-CV\\ \bf MSE} &
\shortstack{\bf Prac-MDL-COMP \\ \bf MSE} \\
\midrule
1028\_SWD & 1000 & 11 & 1.17 & \bf 0.97 \\
1029\_LEV & 1000 & 5 & NaN* & \bf 1.10 \\
1030\_ERA & 1000 & 5 & NaN* & \bf 1.05 \\
1096\_FacultySalaries & 50 & 5 & NaN* & \bf 2.01 \\
1191\_BNG\_pbc & 1000000 & 19 & 1.02 & \bf 1.00 \\
1193\_BNG\_lowbwt & 31104 & 10 & \bf 0.98 & 1.01 \\
1196\_BNG\_pharynx & 1000000 & 11 & 1.03 & \bf 1.00 \\
1199\_BNG\_echoMonths & 17496 & 10 & 1.47 & \bf 1.00 \\
1201\_BNG\_breastTumor & 116640 & 10 & 2.61 & \bf 1.12 \\
192\_vineyard & 52 & 3 & NaN* & \bf 1.57 \\
201\_pol & 15000 & 49 & \bf 0.82 & 0.87 \\
210\_cloud & 108 & 6 & 3.41 & \bf 0.73 \\
215\_2dplanes & 40768 & 11 & 0.88 & \bf 0.85 \\
218\_house\_8L & 22784 & 9 & 4.37 & \bf 1.01 \\
225\_puma8NH & 8192 & 9 & 3.26 & \bf 0.87 \\
228\_elusage & 55 & 3 & NaN* & \bf 1.44 \\
229\_pwLinear & 200 & 11 & 0.83 & \bf 0.67 \\
230\_machine\_cpu & 209 & 7 & 2.48 & \bf 0.71 \\
294\_satellite\_image & 6435 & 37 & 0.47 & \bf 0.44 \\
344\_mv & 40768 & 11 & \bf 0.85 & 1.06 \\
4544\_GeographicalOriginalofMusic & 1059 & 118 & 0.67 & \bf 0.60 \\
519\_vinnie & 380 & 3 & NaN* & \bf 0.92 \\
522\_pm10 & 500 & 8 & 2.31 & \bf 0.96 \\
523\_analcatdata\_neavote & 100 & 3 & NaN* & \bf 1.15 \\
527\_analcatdata\_election2000 & 67 & 15 & 0.50 & \bf 0.49 \\
529\_pollen & 3848 & 5 & NaN* & \bf 0.94 \\
537\_houses & 20640 & 9 & 3.00 & \bf 1.06 \\
542\_pollution & 60 & 16 & 0.88 & \bf 0.82 \\
\bottomrule
\end{tabular}
}
\caption{\textrm{Prac-MDL-COMP}\ vs Cross-validation for a range of datasets when the training data is limited. This table contains details about the datasets used in \cref{fig:pmlb,fig:pmlb_full,fig:pmlb_5fold}. The first column denotes the name of the datasets, and the second and third columns report the size of the datasets. In the last two columns, we report the performance for CV-tuned Ridge (LOOCV), and \textrm{Prac-MDL-COMP}\ tuned ridge estimator, trained on a subsampled dataset such that $d/n=1$.
The reported MSE is computed on a hold-out testing set (which consists of 25\% of the observations), and the better (of the two) MSE for each dataset is highlighted in bold. We observe that \textrm{Prac-MDL-COMP}\ based tuning leads to superior performance compared to cross-validation for most of the datasets. *When too few points are available, cross-validation fails to numerically fit for low values of $\lambda$, returning a value of NaN.}
\label{tab:datasets}
\end{table}
\FloatBarrier
\section{Proofs}
\label{sec:proofs}
This appendix serves to collect the proofs of all of our results. The
proofs for Theorems~\ref{thm:complexity_expressions}
through~\ref{thm:minimax_codelength} are provided in
\cref{sub:proof_of_thm:complexity_expressions} through
\cref{sub:proof_of_thm:rmt_expressions}. We prove
Corollary~\ref{cor:mdl_kernel_smooth} in
\cref{sub:proof_of_cref_cor_mdl_kernel_smooth}.
\subsection{Proof of \cref{thm:complexity_expressions}}
\label{sub:proof_of_thm:complexity_expressions}
Our proof is based on establishing that
\begin{align}
\label{eq:ropt_claim}
\lambda_i^{\textrm{opt}} = \frac{\sigma^2}{\myvec_i^2} \quad
\mbox{and} \quad \ensuremath{\mc R_{\textrm {opt}}} = \frac{1}{2n} \sumn[\min\braces{n, d}] \log\parenth{1 +
\frac{\evali}{\lambda_i^{\textrm{opt}}}}.
\end{align}
The claimed expressions for $\ensuremath{\mc R_{\textrm {opt}}}$ and \ensuremath{\textrm{MDL-COMP}}\ follow by using these
expressions and performing some algebra.
Let $\pdist_{\tvar_\star}$ denote the distribution of the multivariate Gaussian
$\mc{N}(\mat{X}\tvar_\star, \sigma^2\mb{I}_n)$, and let $p(\v{y};\mat{X},
\tvar_\star)$ denote its density. Note $\v{y} \sim \pdist_{\tvar_\star}$ by assumption.\footnote{\label{proof:thm1_under_over_specified} In our our earlier discussion with under-specified models in the simulations related to \cref{fig:mdl_gaussian}, and the discussion in \cref{sub:mdl_plots_details,sub:sketch_gaussian}, $\mat{X}$ denotes a subset of full features, in which case $\mat{X}\tvar_\star$ does not capture the mean of the random vector $\v{y}$, and there is a bias. However, given the definition of our MDL-COMP, where we compare to the best possible encoding using $\mat{X}$ at hand, this bias term arises in both the numerator and denominator in \cref{eq:mdl_comp_proof_reatio}, and cancels out thereby not affecting the subsequent derivations. On the other hand, with over-specified models, i.e., when $\mat{X}$ is a superset of features needed to correctly specify the mean of the random vector $\v{y}$, we can append zeros to the true parameter $\tvar_\star$ as necessary, and continue to assume $\v{y} \sim \pdist_{\tvar_\star}$.}
In order to simplify notation, we introduce the shorthand $\widehat{\tvar} =
\widehat{\tvar}_{\mat{\Lambda}}(\v{y})$.
We have
\begin{align}
\label{eq:mdl_comp_proof_reatio}
\kull{\mathbb{P}_{\tvar_\star}}{\mathbb{Q}_{\mat{\Lambda}}} & =\ensuremath{{\mathbb{E}}}_{\v{y}}\brackets{
\log\parenth{\frac{ \frac{1}{(2\pi\sigma^2)^{n/2}}
\exp\parenth{-\frac{1}{2\sigma^2}\enorm{\v{y}-\mat{X}\tvar_\star}^2 }}
{\frac{1}{\mrm{C}_{\mat{\Lambda}}(2\pi\sigma^2)^{n/2}}
\exp\parenth{-\frac{1}{2\sigma^2}\enorm{\v{y}-\mat{X}\widehat{\tvar}}^2
-\frac{1}{2\sigma^2} \widehat{\tvar}^\top\mat{\Lambda}\widehat{\tvar}}} } } \\
&= \;
\sum_{j=1}^3 T_j, \notag
\end{align}
where
\begin{align}
\label{eq:thm_1_step_1}
T_1 := -\ensuremath{{\mathbb{E}}}_{\v{y}} \brackets{\frac{1}{2\sigma^2} \enorm{\v{y}
- \mat{X} \tvar_\star}^2}, \quad
T_2 := \ensuremath{{\mathbb{E}}} \brackets {\frac{1}{2 \sigma^2}\enorm{\v{y} -
\mat{X}\widehat{\tvar}}^2 + \frac{1}{2\sigma^2} \widehat{\tvar} ^\top \mat{\Lambda} \widehat{\tvar}},
\quad
\end{align}
and $T_3 := \log \mrm{C}_{\mat{\Lambda}}$. By inspection, we have $T_1 = -n/2$.
Dividing both sides by $\samples$ yields
\begin{align}
\label{eq:exp_1}
\ensuremath{\mc R_{\textrm {opt}}} = \min_{\mat{\Lambda} \in \mc{M}} \braces{\ensuremath{{\mathbb{E}}}\brackets{
\frac{\enorm{\v{y} -\mat{X} \widehat{\tvar}}^2 + \widehat{\tvar}^\top \mat{\Lambda} \widehat{\tvar}
}{2n\sigma^2} } + \frac{1}{2n}\sumn[d]
\log\parenth{1+\frac{\evali}{\lambda_i}} } - \frac{1}{2}
\end{align}
Next we claim that
\begin{subequations}
\begin{align}
T_2 & = \frac{(n-\min\braces{n, d})}{2} + \frac12\sumn[\min\braces{n, d}]
\frac{(\evali\myvec_i^2/\sigma^2 +
1)\lambda_i}{\lambda_i+\evali}, \qtext{and} \label{eq:t2}\\ T_3
&=
\frac12\sumn[\min\braces{n, d}]\log\parenth{\frac{\evali+\lambda_i}{\lambda_i}}\label{eq:t3}
\end{align}
\end{subequations}
Assuming these claims as given at the moment, let us now complete the
proof. We have
\begin{subequations}
\label{eq:thm_1_kull}
\begin{align}
\frac{1}{n} \kull{\pdist_{\tvar_\star}}{\mathbb{Q}_{\mat{\Lambda}}} = \frac{1}{n}
\sum_{j=1}^3 T_j & = -\frac{\min\braces{n, d}}{2n} + \frac{1}{2n}
\sumn[\min\braces{n, d}] f_i(\lambda_i), \qquad \mbox{where} \\
f_i(\lambda_i) & := \parenth{ \frac{ (\evali\myvec_i^2/\sigma^2 +
1)\lambda_i}{\lambda_i+\evali} +
\log\parenth{\frac{\evali+\lambda_i}{\lambda_i}} }.
\end{align}
\end{subequations}
Finally, in order to compute $\ensuremath{\mc R_{\textrm {opt}}}$ defined in
equation~\eqref{eq:exp_1}, we need to minimize the
KL-divergence~\eqref{eq:thm_1_kull} as a function of the vector
$\lambda = (\lambda_1, \ldots, \lambda_{\min\braces{n, d}})$. Note that the
objective on the RHS of \cref{eq:thm_1_kull} is separable across the
components of $\lambda$, so we need only solve a univariate problem
for each $\lambda_i$. Taking derivatives to find stationary points,
we have
\begin{align}
\label{eq:lam_opt_mdl}
f_i'(\lambda_i) = 0 \quad \Longleftrightarrow \quad
-\frac{(\evali\myvec_i^2/\sigma^2 + 1)}{(1+\evali/\lambda_i)^2} +
\frac{1}{1+\evali/\lambda_i} = 0 \quad\Longleftrightarrow\quad
\lambda_i^{\textrm{opt}} = \frac{\sigma^2}{\myvec_i^2}.
\end{align}
Moreover, checking on the boundary of feasible values of $\lambda_i =
[0, \infty)$, we have $f_i(\lambda_i)\to \infty$ as $\lambda_i\to
0^+$, and $f_i(\lambda_i) \to 1+\evali \myvec_i^2/\sigma^2$ as
$\lambda_i\to \infty$. Noting that $1 +\log a \leq a$ for all $a
\geq 1$, we conclude that $f_i$ achieves its minimum at
$\lambda_i^{\textrm{opt}}$, and we have
$f_i(\lambda_i^{\textrm{opt}}) = 1+ \log
(1+\evali\myvec_i^2/\sigma^2)$. Substituting this value into the
expression~\eqref{eq:lam_opt_mdl} yields
\begin{align}
\ensuremath{\mc R_{\textrm {opt}}} & = -\frac{\min\braces{n, d}}{2n}+ \frac1{2n}\sumn[\min\braces{n, d}] \parenth{1+
\log\parenth{1+\frac{\evali\myvec_i^2} {\sigma^2}}}
\notag \\
& =\frac{1}{2n} \sumn[\min\braces{n, d}] \log\parenth{1+\frac{\evali\myvec_i^2}
{\sigma^2}}. \label{eq:ropt_expression}
\end{align}
We now turn to proving our earlier claims~\eqref{eq:t2} and
\eqref{eq:t3}. We prove them separately. We start with the
low-dimensional case, i.e., when $d<n$. Since the proof for the
high-dimensional case is similar, we only outline the mains steps in
Appendix~\ref{ssub:proof_high_dim}.
\subsubsection{Proof of claims~\eqref{eq:t2} and \eqref{eq:t3} for the case $d<n$}
\label{ssub:proof_low_dim}
Let the singular value decomposition of the matrix $\mat{X}$ be given by
\begin{align}
\label{eq:svd}
\mat X = \mat V \sqrt{\mat D} \mat U^\top.
\end{align}
Here the matrix $\mat D\in \ensuremath{\mathbb{R}}^{d\times d}$ is a diagonal matrix,
with $i$-th diagonal entry denoting the $i$-th squared singular value
of the matrix $\mat{X}$. Moreover, the matrices $\mat V \in \ensuremath{\mathbb{R}}^{n
\times d}$ and $\mat U \in \ensuremath{\mathbb{R}}^ {d\times d}$, respectively,contain
the left and right singular vectors of the matrix $\mat X$,
respectively. (I.e., the $i$-th column denotes the singular vector
corresponding the $i$-th singular value.) Note that we have the
relations $\mat U\mat U^\top = \mat U^\top \mat U = \mat V^\top\mat V = \mat
I_d$, and moreover, the matrix $\mat V \mat V^\top$ is a projection
matrix of rank $d$. Finally, let $\overline{\mat{\Lambda}} = \diag(\lambda_1, \ldots,
\lambda_d)$ be such that $\mat{\Lambda} = \mat U \overline{\mat{\Lambda}} \mat U^\top $. With
this notation in place, we claim that
\begin{subequations}
\label{eq:linear_algebra}
\begin{align}
\label{eq:i_minus_xlam}
(\mat I_n - \mat{X} (\xmat^\top\xmat + \mat{\Lambda}) ^{-1} \mat{X}^\top)^2 &= \mat V
\overline{\mat{\Lambda}}^2(\mat D + \overline{\mat{\Lambda}})^{-2} \mat V ^\top + (\mat I_n-\mat V
\mat V^\top) \\
%
\label{eq:x_lam}
\mat{X}(\xmat^\top\xmat+\mat{\Lambda})^{-1} \mat{\Lambda} (\xmat^\top\xmat+\mat{\Lambda})^{-1} \mat{X}^\top &= \mat V
\mat D\overline{\mat{\Lambda}} (\mat D+\overline{\mat{\Lambda}})^{-2} \mat V^\top, \quad \mbox{and}
\\
\label{eq:w_expand}
\mat{X}(\xmat^\top\xmat+\mat{\Lambda})^{-1} \xmat^\top\xmat\tvar_\star &= \mat V \sqrt{\mat D} (\mat D +
\overline{\mat{\Lambda}})^{-1} \mat D \mat U^\top \tvar_\star\notag \\ &= \mat V \sqrt{\mat D}
(\mat D + \overline{\mat{\Lambda}})^{-1} \mat D \v{\myvec}
\end{align}
\end{subequations}
See Appendix~\ref{sub:few_linear_algebra_simplifications} for the
proofs of these claims, which involve elementary linear algebra.
\subsubsection{Proof of the expression~\eqref{eq:t2} for term $T_2$}
We have
\begin{align}
\frac{1}{2\sigma^2} & \enorm{\v{y} - \mat{X} \widehat{\tvar}}^2 + \frac{1}{2
\sigma^2} \widehat{\tvar} ^\top \mat{\Lambda} \widehat{\tvar} \notag \\
& = \frac{1}{2 \sigma^2} \enorm{\parenth{\mat I_n - \mat{X} (\xmat^\top\xmat +
\mat{\Lambda})^{-1} \mat{X}^\top}\v{y})}^2 + \frac{1}{2 \sigma^2} \enorm{\sqrt
\mat{\Lambda} (\xmat^\top\xmat + \mat{\Lambda})^{-1} \mat{X}^\top \v{y} }^2 \notag \\
& \stackrel{(i)}{=} \frac{1}{2 \sigma^2} \v{y} ^\top \parenth{\mat V
\overline{\mat{\Lambda}}^2 (\mat D + \overline{\mat{\Lambda}})^{-2} \mat V ^\top} \v{y} + \frac{1}{2
\sigma^2} \v{y} ^\top (\mat I_n-\mat V \mat V ^\top) \v{y} + \frac{1}{2
\sigma^2} \v{y} ^\top \parenth{\mat V \overline{\mat{\Lambda}} \mat D (\mat D +
\overline{\mat{\Lambda}})^{-2} \mat V ^\top} \v{y} \notag \\
& = \frac{1}{2\sigma^2} \v{y} ^\top \parenth{\mat V (\overline{\mat{\Lambda}}^2+\overline{\mat{\Lambda}}
\mat D) (\mat D + \overline{\mat{\Lambda}})^ {-2} \mat V^\top} \v{y} +
\frac{1}{2\sigma^2} \v{y} ^\top \mat (\mat I_n-\mat V \mat V^\top) \v{y}
\notag \\
\label{eq:thm_1_step_2}
& =\frac{1}{2 \sigma^2} \v{y} ^\top \parenth{\mat V \overline{\mat{\Lambda}} (\mat D +
\overline{\mat{\Lambda}})^{-1} \mat V ^\top} \v{y} + \frac{1}{2\sigma^2} \v{y} ^\top (\mat
I_n - \mat V \mat V ^\top ) \v{y},
\end{align}
where step~(i) follows from \cref{eq:i_minus_xlam,eq:x_lam}. The
latter steps make use of the fact that diagonal matrices commute.
Next we note that $\v{y} \sim \mc{N}(\mat{X}\tvar_\star, \sigma^2\mb{I}_n)$,
and thus $\ensuremath{{\mathbb{E}}}[\v{y}^\top \mat A \v{y} ] = \tvar_\star^\top\mat{X}^\top \mat A \mat{X}
\tvar_\star + \sigma^2 \trace(\mat A)$. Using
\cref{eq:thm_1_step_1,eq:thm_1_step_2}, we find that
\begin{align}
T_2 & = \ensuremath{{\mathbb{E}}}\brackets{\frac{1}{2\sigma^2}\enorm{\v{y}-\mat{X}\widehat{\tvar}}^2 +
\frac{1} {2\sigma^2} \widehat{\tvar}^\top\mat{\Lambda}\widehat{\tvar}} \notag \\
& = \frac{1}{2\sigma^2} \tvar_\star^\top\mat{X}^\top \parenth{\mat V
\overline{\mat{\Lambda}} (\mat D + \overline{\mat{\Lambda}})^ {-1} \mat V^\top}\mat{X} \tvar_\star +
\frac{1}{2\sigma^2} [\sigma^2\trace(\mat V \overline{\mat{\Lambda}} (\mat D +
\overline{\mat{\Lambda}})^ {-1} \mat V^\top)] \notag \\
& \qquad\qquad\qquad +\frac{1}{2\sigma^2} \tvar_\star^\top\mat{X}^\top (\mat
I-\mat V\mat V^\top)\mat{X} \tvar_\star + \frac{1}{2\sigma^2}
[\sigma^2\trace(\mat I-\mat V\mat V^\top)] \notag \\
& \stackrel{(i)}{=} \frac{1}{2\sigma^2} \tvar_\star^\top\mat{X}^\top
\parenth{\mat V \overline{\mat{\Lambda}} (\mat D + \overline{\mat{\Lambda}})^ {-1} \mat V^\top}\mat{X}
\tvar_\star + \frac{1}{2\sigma^2} [\sigma^2\trace(\mat V \overline{\mat{\Lambda}} (\mat D
+ \overline{\mat{\Lambda}})^ {-1} \mat V^\top)]\label{eq:thm_1_step_3a} \\
& \qquad\qquad\qquad + 0 +\frac{1}{2}\cdot (n-d) \notag \\
& \stackrel{(ii)}{=} \frac1{2\sigma^2}\parenth{\v{w}^\top \mat D
\mat{\Lambda} (\mat D + \mat{\Lambda})^{-1} \v{w} + \sigma^2 \trace [\overline{\mat{\Lambda}}
(\mat D +\overline{\mat{\Lambda}})^{-1}]} +\frac{1}{2}\cdot (n-d) \notag \\
%
\label{eq:thm_1_step_3}
& = \frac{(n-d)}{2} +\frac{1}{2}\sumn[d]
\parenth{\frac{\evali\myvec_i^2 } {\sigma^2} + 1} \frac{\lambda_i}
{\lambda_i+\evali}
\end{align}
where step~(i) follows from the facts that the matrix $(\mat I_n -
\mat V\mat V^\top)$ is a projection matrix of rank $n-d$, and is
orthogonal to the matrix $\mat X$, i.e., $(\mat I_n - \mat V\mat
V^\top)\mat X = 0$. Step~(ii) follows from a similar computation as
that done to obtain \cref{eq:thm_1_step_2}, along with
claim~\eqref{eq:w_expand}, and the following identity for the matrix
trace
\begin{align*}
\trace(\mat V \overline{\mat{\Lambda}} (\mat D + \overline{\mat{\Lambda}})^{-1} \mat V^\top) =
\trace(\overline{\mat{\Lambda}} (\mat D + \overline{\mat{\Lambda}})^{-1} \mat V^\top\mat V ) =
\trace(\overline{\mat{\Lambda}} (\mat D + \overline{\mat{\Lambda}})^{-1}\mat I_d).
\end{align*}
\subsubsection{Proof of claim~\eqref{eq:t3} (term $T_3$):}
From the normalization of a multivariate Gaussian density, we have
\begin{align}
\label{eq:gauss_norm}
\frac{1}{(2\pi\sigma^2)^{n/2}} \int_{\v{y}\in\ensuremath{\mathbb{R}}^n} \exp\parenth{-
\frac{\v{y}^\top \mat A \v{y}}{2\sigma^2}} d\v{y}
= \sqrt{\det(\mat A^{-1})},
\end{align}
valid for any positive definite matrix $\mat A \in \ensuremath{\mathbb{R}}^ {n \times
n}$.
Putting together the definition~\eqref{eq:ridge_dist} of $\mrm{C}_{\mat{\Lambda}}$
and equation~\eqref{eq:thm_1_step_2}, we find that
\begin{align}
\mrm{C}_{\mat{\Lambda}} = \frac{1}{(2\pi\sigma^2)^{n/2}} \int_{\v{y}\in\ensuremath{\mathbb{R}}^n} \exp\parenth{-
\frac{\v{y}^\top \mat A_{\mat{\Lambda}} \v{y}}{2\sigma^2}} d\v{y}
\qtext{where}
\mat A_{\mat{\Lambda}} &= \parenth{\mat V \overline{\mat{\Lambda}} (\mat D + \overline{\mat{\Lambda}})^{-1}
\mat V^\top}
+ (\mat I_n-\mat V \mat V^\top) \notag\\
&= \mat I_n - \mat V \mat D (\mat D + \overline{\mat{\Lambda}})^{-1}\mat V^\top.
\label{eq:a_lammat}
\end{align}
The eigenvalues of the $n \times n$ matrix $\mat A_{\mat{\Lambda}}$
are given by
$\braces{\frac{\lambda_1}{\lambda_1+\evali[1]},
\frac{\lambda_2}{\lambda_2+\evali[2]}, \ldots, \frac{\lambda_d}{\lambda_d+\evali
[d]},
1, 1, \ldots, 1}$, where the multiplicity of the eigenvalue $1$ is $n-d$.
Finally, applying \cref{eq:gauss_norm}, we find that
\begin{align}
T_3 = \log \mrm{C}_{\mat{\Lambda}} =
\log\sqrt{\det(\mat A_{\mat{\Lambda}}^{-1})}
=
\frac12\sumn[d]\log\parenth{\frac{\evali+\lambda_i}{\lambda_i}}
\label{eq:thm_1_step_4}
\end{align}
and the claim follows.
\subsubsection{Proof of claims~\eqref{eq:t2} and \eqref{eq:t3} for the case $d>n$}
\label{ssub:proof_high_dim}
In this case, the dimensions of the matrices in the singular value decomposition~\eqref{eq:svd} changes.
The argument for the proof remains similar with suitable adaptations due
to the change in the size of the matrices. As a result, we only outline the main steps.
We write
\begin{align}
\label{eq:svd_new}
\mat X = \mat V \begin{bmatrix}
\sqrt{\widetilde{\mat D}} & \mat 0
\end{bmatrix} \mat U^\top
\quad\Longrightarrow \quad
\xmat^\top\xmat = \mat U \underbrace{\begin{bmatrix}
\widetilde{\mat D} & \mat 0 \\ \mat 0 & \mat 0
\end{bmatrix}}_{\mat D} \mat U^\top
\end{align}
where $\mat V \in \ensuremath{\mathbb{R}}^{n\times n}$, $\widetilde{\mat D} \in \ensuremath{\mathbb{R}}^{n\times
n}$ and $\mat U \in \ensuremath{\mathbb{R}}^{d\times d}$.
Note that the non-zero entries of the matrix $\mat D$ are precisely the
ones denoted by $\widetilde{\mat D}$.
Let $\overline{\mat{\Lambda}}_n = \diag(\lambda_1, \ldots, \lambda_n)$ denote the $n \times
n$ principal minor of the matrix $\overline{\mat{\Lambda}}$, where $\mat{\Lambda} = \mat U \overline{\mat{\Lambda}}
\mat U^\top$.
With these notations, we find that the claims~\eqref{eq:linear_algebra}
are replaced by
\begin{subequations}
\label{eq:linear_algebra_new}
\begin{align}
(\mat I_n - \mat{X} (\xmat^\top\xmat+\mat{\Lambda})^{-1} \mat{X}^\top)^2
&= \mat V \overline{\mat{\Lambda}}_n^2(\widetilde{\mat D} + \overline{\mat{\Lambda}}_n)^{-2} \mat V^\top
\label{eq:i_minus_xlam_high}\\
\mat{X}(\xmat^\top\xmat+\mat{\Lambda})^{-1} \mat{\Lambda} (\xmat^\top\xmat+\mat{\Lambda})^{-1} \mat{X}^\top
&= \mat V \widetilde{\mat D}\overline{\mat{\Lambda}}_n (\widetilde{\mat D}+\overline{\mat{\Lambda}}_n)^
{-2} \mat V^\top
\label{eq:x_lam_high}\\
\mat{X}(\xmat^\top\xmat+\mat{\Lambda})^{-1} \xmat^\top\xmat\tvar_\star &=
\mat V \begin{bmatrix}
\sqrt{\widetilde{\mat D}} & \mat 0
\end{bmatrix} (\mat D + \overline{\mat{\Lambda}})^{-1} \mat D
\underbrace{\mat U^\top \tvar_\star}_{=:\v{\myvec}}\notag
\\
&= \mat V \sqrt{\widetilde{\mat D}} (\widetilde{\mat D} + \overline{\mat{\Lambda}}_n)^{-1}
\widetilde{\mat D} \v{\myvec}_{1:n}
\label{eq:w_expand_high}
\end{align}
\end{subequations}
where $\v{\myvec}_{1:n}$ denotes the first $n$ entries of the vector $\v{\myvec}$.
The proof of these claims can be derived in a similar manner to that of
claims~\eqref{eq:linear_algebra} (see Appendix~\ref{sub:few_linear_algebra_simplifications}).
Applying \cref{eq:i_minus_xlam_high,eq:x_lam_high}, we find that the equation~\eqref{eq:thm_1_step_2}
is modified to
\begin{align*}
\frac{1}{2\sigma^2}&\enorm{\v{y}-\mat{X}\widehat{\tvar}}^2 +\frac{1}{2\sigma^2} \widehat{\tvar}^\top\mat{\Lambda}\widehat{\tvar}
= \frac{1}{2\sigma^2}\v{y}^\top \parenth{\mat V \overline{\mat{\Lambda}}_n (\widetilde{\mat
D} +
\overline{\mat{\Lambda}}_n)^{-1} \mat V^\top} \v{y}
\end{align*}
which along with \cref{eq:w_expand_high} implies that the equation~\eqref{eq:thm_1_step_3}
is now replaced by
\begin{align*}
T_2 &= \ensuremath{{\mathbb{E}}}\brackets{\frac{1}{2\sigma^2}\enorm{\v{y}-\mat{X}\widehat{\tvar}}^2 +
\frac{1}
{2\sigma^2} \widehat{\tvar}^\top\mat{\Lambda}\widehat{\tvar}}
= \frac{1}{2}\sumn[n] \parenth{\frac{\evali\myvec_i^2 }
{\sigma^2} + 1} \frac{\lambda_i}{\lambda_i+\evali}.
\end{align*}
Thus, we obtain the claimed expression~\eqref{eq:t2} for
$T_2$ when $d>n$.
Next, to prove~\eqref{eq:t3} for this case, we find that the matrix $\mat
A_{\mat{\Lambda}}$ (defined in equation~\eqref{eq:a_lammat}) for this case gets
modified to
\begin{align*}
\mat A_{\mat{\Lambda}} = \mat I_n - \mat V \mat D (\mat D + \overline{\mat{\Lambda}})^{-1}\mat V^\top.
\end{align*}
Since $\mat V\mat V^\top = \mat I_n$, we find that the eigenvalues of the
$n\times n$ matrix $\mat A_{\mat{\Lambda}}$ are given by $\braces{\frac{\lambda_1}{\evali [1]+\lambda_1},\ldots,\frac{\lambda_n}{\evali
[n]+\lambda_n}}$. Therefore, we conclude that
\begin{align*}
T_3 = \log \mrm{C}_{\mat{\Lambda}} =
\log\sqrt{\det(\mat A_{\mat{\Lambda}}^{-1})}
=
\frac12\sumn[n]\log\parenth{\frac{\evali+\lambda_i}{\lambda_i}}.
\end{align*}
\subsubsection{Proof of claims~\eqref{eq:i_minus_xlam} and ~\eqref{eq:i_minus_xlam_high}}
\label{sub:few_linear_algebra_simplifications}
For completeness, we discuss the proofs of the linear-algebra claims~\eqref{eq:linear_algebra}
and \eqref{eq:linear_algebra_new}.
Here we establish the claim~\eqref{eq:i_minus_xlam} (for $n>d$) and \eqref{eq:i_minus_xlam_high}
(for $n<d$). The other claims in the equations~\eqref{eq:linear_algebra}
and \eqref{eq:linear_algebra_new} can be derived
in a similar fashion.
Note that for both cases $n>d$ and $n<d$, our notations~\eqref{eq:svd} and
\eqref{eq:svd_new} are set-up such that
\begin{align*}
(\xmat^\top\xmat+\mat{\Lambda})^{-1} = \mat U (\mat D + \overline{\mat{\Lambda}})^{-1} \mat U^\top,
\end{align*}
where the inverse is well-defined since $\overline{\mat{\Lambda}} = \diag(\lambda_1, \ldots,
\lambda_d)$ is assumed to be a positive definite matrix.
We use the fact that diagonal matrices commute, several times in our arguments.
\paragraph{Proof of claim~\eqref{eq:i_minus_xlam}:}
Using the decomposition~\eqref{eq:svd} for $n>d$ and noting that $\mat U^\top
\mat U = \mat I_d$, we find that
\begin{align}
(\mat I_n - \mat{X} (\xmat^\top\xmat+\mat{\Lambda})^{-1} \mat{X}^\top)^2
&= (\mat I_n - \mat V \sqrt{\mat D} \mat U^\top \mat U (\mat D + \overline{\mat{\Lambda}})^{-1}
\mat U^\top \mat U \sqrt{\mat D} \mat V^\top)^2 \notag\\
&= (\mat I_n-\mat V\mat V^\top +\mat V \mat V^\top
- \mat V \sqrt{\mat D}(\mat D + \overline{\mat{\Lambda}})^{-1}
\sqrt{\mat D} \mat V^\top)^2 \notag\\
&= (\mat I_n-\mat V\mat V^\top +\mat V (\mat I_d -\sqrt{\mat D}(\mat D
+ \overline{\mat{\Lambda}})^{-1}
\sqrt{\mat D}) \mat V^\top)^2 \notag\\
&= (\mat I_n-\mat V\mat V^\top +\mat V \overline{\mat{\Lambda}}(\mat D + \overline{\mat{\Lambda}})^{-1}
\mat V^\top )^2 \notag\\
&= \mat I_n-\mat V\mat V^\top +\mat V \overline{\mat{\Lambda}}^2(\mat D + \overline{\mat{\Lambda}})^{-2}
\mat V^\top,
\notag
\end{align}
where the last step follows from the following facts (a) $\mat I-\mat V\mat
V^\top$ is a projection matrix, (b) $(\mat I-\mat V\mat V^\top) \mat V = \mat
0$, and (c) $\mat V^\top\mat V = \mat I_d$.
\paragraph{Proof of claim~\eqref{eq:i_minus_xlam_high}:}
Note that for the decomposition~\eqref{eq:svd_new}, we have $\mat V\mat
V^\top = \mat V^\top \mat V = \mat I_n$ and $\mat U \mat U^\top = \mat U^\top \mat
U = \mat I_d$. Using these facts along with the notation $\overline{\mat{\Lambda}}_n
=\diag(\lambda_1, \ldots, \lambda_n)$ for $d>n$, we find that
\begin{align}
(\mat I_n - \mat{X} (\xmat^\top\xmat+\mat{\Lambda})^{-1} \mat{X}^\top)^2
&= (\mat I_n - \mat V \begin{bmatrix}
\sqrt{\widetilde{\mat D}} & \mat 0
\end{bmatrix} \mat U^\top \mat U (\mat
D + \overline{\mat{\Lambda}})^{-1}
\mat U^\top \mat U \begin{bmatrix}
\sqrt{\widetilde{\mat D}} \\
\mat 0
\end{bmatrix} \mat V^\top )^2\notag\\
&= (\mat I_n - \mat V \begin{bmatrix}
\sqrt{\widetilde{\mat D}} & \mat 0
\end{bmatrix} (\mat D + \overline{\mat{\Lambda}})^{-1}
\begin{bmatrix}
\sqrt{\widetilde{\mat D}} \\
\mat 0
\end{bmatrix} \mat V^\top )^2\notag\\
&=(\mat I_n - \mat V \sqrt{\widetilde{\mat D}} (\widetilde{\mat D}+\overline{\mat{\Lambda}}_n)^{-1}
\sqrt{\widetilde{\mat D}}
\mat V^\top)^2 \notag\\
&=(\mat V \mat V^\top - \mat V \widetilde{\mat D} (\widetilde{\mat
D} + \overline{\mat{\Lambda}}_n)^{-1} \mat V^\top)^2 \notag \\
&=(\mat V(\mat I_n- \widetilde{\mat D} (\widetilde{\mat
D} + \overline{\mat{\Lambda}}_n)^{-1}) \mat V^\top)^2 \notag\\
&=\mat V \overline{\mat{\Lambda}}_n^2 (\widetilde{\mat
D} + \overline{\mat{\Lambda}}_n)^{-2} \mat V^\top,
\notag
\end{align}
which yields the claim.
\subsection{Proof of \cref{thm:lam_opt}}
\label{sub:proof_of_thm:lam_opt}
For $\widehat{\tvar} = \widehat{\tvar}_{\mat{\Lambda}}(\v{y})$, we claim that
\begin{align}
\label{eq:in_sample_mse_exp}
\frac{1}{n}\ensuremath{{\mathbb{E}}}\brackets{\enorm{\mat{X}\widehat{\tvar} -\mat{X}\tvar_\star }^2}
= \frac{1}{n}\sumn[\min\braces{n, d}] \underbrace{\frac{\lambda_i^2\evali\myvec_i^2
+ \sigma^2
\evali^2}{(\evali+\lambda_i)^2}}_{=:h_i(\lambda_i)}
\end{align}
Let us assume the claim as given at the moment, and prove \cref{eq:opt_lam_insample_mse}.
Recalling the optimal choice $\lambda_{i, {\textrm{opt}}}$
of the regularization parameter for \ensuremath{\textrm{MDL-COMP}}\ from equation~\eqref{eq:lam_opt_mdl},
and noting that the in-sample MSE
is separable in each term $\lambda_i$, it remains
to show that
\begin{align}
\label{eq:g_opt}
\argmin_{\lambda_i \in[0, \infty)} h_i(\lambda_i) = \lambda_{i, {\textrm{opt}}}
= \frac{\sigma^2}{\myvec_i^2}
\end{align}
To this end, we note that
\begin{align*}
h_i'(\lambda_i) = 0
\quad\Longleftrightarrow\quad
2\frac{\evali^2\myvec_i^2\lambda_i}{(\evali+\lambda_i)^3}
-2\frac{\evali^2\sigma^2}{(\evali+\lambda_i)^3}
= 0
\quad\Longleftrightarrow\quad
\widetilde{\lambda}_{i, \textrm{opt}} = \frac{\sigma^2}{\myvec_i^2}.
\end{align*}
On the boundary of feasible values of $\lambda_i = [0,
\infty)$, we have $h_i(0) = \sigma^2$, and $h_i(\lambda_i) \to \evali\myvec_i^2$
as $\lambda_i\to
\infty$. Noting that
\begin{align*}
h_i(\widetilde{\lambda}_i^{\textrm{opt}}) = \frac{\evali\myvec_i^2\sigma^2}
{\evali\myvec_i^2+\sigma^2}
\leq \min\braces{\evali\myvec_i^2, \sigma^2},
\end{align*}
yields the claim~\eqref{eq:g_opt}.
Next we establish the bound~\eqref{eq:ropt_bounds_insample_mse} on the
fixed design prediction error. Using $\lambda_i$ as a convenient
shorthand for $\lambda_{i, {\textrm{opt}}}$, we substitute it into the
RHS of \cref{eq:in_sample_mse_exp}, thereby finding that
\begin{align*}
\frac{1}{n} \ensuremath{{\mathbb{E}}}\brackets{\enorm{\mat{X} \widehat{\tvar}_{\mat{\Lambda}_{\textrm{opt}}} - \mat{X}
\tvar_\star }^2} & = \frac{1}{n} \sumn[\min\braces{n, d}] \frac{ (
\frac{\sigma^2}{\myvec_i^2})^2 \evali \myvec_i^2 + \sigma^2
\evali^2}{(\evali + (\frac{\sigma^2}{\myvec_i^2} ) )^2} \\
& = \frac{\sigma^2}{n} \sumn[\min\braces{n, d}] \frac{1}{1 +
\frac{\sigma^2}{\evali \myvec_i^2}}.
\end{align*}
We now make note of the elementary inequality $x \leq -\log(1- x)$
valid for $x \in [0, 1)$. Applying this inequality with $x = (1 +
\frac{\sigma^2}{\evali \myvec_i^2})^{-1}$, we have $-\log(1-x) =
\log (1 + \tfrac{\evali \myvec_i^2}{\sigma^2})$, and hence
\begin{align*}
\frac{1}{n} \ensuremath{{\mathbb{E}}} \brackets{\enorm{\mat{X} \widehat{\tvar}_{\mat{\Lambda}_{\textrm{opt}}} - \mat{X}
\tvar_\star}^2 } & \leq \frac{\sigma^2}{n} \sumn[\min\braces{n, d}] \log
\parenth{ 1 + \frac{\evali\myvec_i^2}{\sigma^2}} =
\frac{\sigma^2}{n} \ensuremath{\mc R_{\textrm {opt}}},
\end{align*}
where we have used $\ensuremath{\mc R_{\textrm {opt}}}$ as a shorthand for the optimal redundancy.
\paragraph{Proof of \cref{eq:in_sample_mse_exp}:}
There are two cases to be considered, namely $d > n$ and $d < n$.
Both cases can be handled together by using the linear-algebraic
claims~\eqref{eq:linear_algebra} and \eqref{eq:linear_algebra_new} as
needed. Following steps similar to those in the proof of
Theorem~\ref{thm:complexity_expressions}, we find that
\begin{align*}
\ensuremath{{\mathbb{E}}} \brackets{\enorm{\mat{X}\widehat{\tvar} -\mat{X}\tvar_\star }^2} &= \ensuremath{{\mathbb{E}}}
\brackets{\enorm{\mat{X}(\xmat^\top\xmat+\mat{\Lambda})^{-1} \mat{X}^\top \v{y} -\mat{X}\tvar_\star
}^2} \\ &= \enorm{\mat{X}(\xmat^\top\xmat+\mat{\Lambda})^{-1} \xmat^\top\xmat\tvar_\star -\mat{X}\tvar_\star
}^2 + \ensuremath{{\mathbb{E}}}\brackets{\enorm{\mat{X}(\xmat^\top\xmat+\mat{\Lambda})^{-1}
\mat{X}^\top\noise[]}^2} \\
& \stackrel{(i)}{=} \enorm{\mat V \sqrt{\mat D} ((\mat D+\overline{\mat{\Lambda}})^{-1}
\mat D -\mat I)\v{\myvec} }^2 + \ensuremath{{\mathbb{E}}}\brackets{\enorm{\mat V
\sqrt{\mat D}(\mat D + \overline{\mat{\Lambda}})^{-1} \sqrt{\mat D} \mat V^\top
\noise[]}^2} \\
& = \enorm{\sqrt{\mat D} ((\mat D+\overline{\mat{\Lambda}})^{-1} \overline{\mat{\Lambda}})\v{\myvec}
}^2 + \sigma^2\trace\parenth{\sqrt{\mat D} (\mat D + \overline{\mat{\Lambda}})^{-1}
\mat D (\mat D+\overline{\mat{\Lambda}})^{-1} \sqrt{\mat D}} \\
& = \sumn[\min\braces{n, d}] \parenth{\frac{ \evali \lambda_i^2
\myvec_i^2}{(\evali + \lambda_i)^2} + \frac{\sigma^2
\evali^2}{(\evali + \lambda_i)^2}},
\end{align*}
and we are done.
\subsection{Proof of Theorem~\ref{thm:mdl_kernel}}
\label{sub:proof_of_theorem_thm:mdl_kernel}
Let us introduce the shorthand $\v{y^\star} = (f^\star(x_1), \ldots,
f^\star(x_n))^\top$. Given data $\v{y}$ generated according to the
model~\eqref{eq:kernel_Generative_model}, we have
$\v{y}\sim\mc{N}(\v{y^\star}, \sigma^2\mb{I}_n)$. Let $p(\v{y};\v{y^\star})$
denote the corresponding density of $\v{y}$. With this notation, we can
write
\begin{align*}
\kull{\mathbb{P}_{f^\star}}{\mathbb{Q}_{\lambda}} &=
\ensuremath{{\mathbb{E}}}_{\v{y}}\brackets{\log{\frac{p(\v{y};\v{y^\star})}
{q_{\lambda}(\v{y})} } } \\
& = \underbrace{-\ensuremath{{\mathbb{E}}}_{\v{y}}\brackets{\frac{1}{2\sigma^2} \enorm{\v{y} -
\v{y^\star}}^2}}_{=:T_1} + \underbrace{\ensuremath{{\mathbb{E}}}_{\v{y}}
\brackets{\frac{1}{2 \sigma^2}\enorm{\v{y} - \mat{K} \widehat{\tvar}}^2 +
\frac{\lambda}{2 \sigma^2} \widehat{\tvar} ^\top \mat{K} \widehat{\tvar}}}_{=:T_2} +
\underbrace{\log \mrm{C}_{\lambda}}_{=:T_3}.
\end{align*}
Note that the term $T_1 = - n/2$ by definition of our noisy
observation model. Turning to the term $T_2$, we substitute the
expression~\eqref{eq:kernel_ridge2} for $\widehat{\tvar}$, thereby finding that
\begin{align*}
\enorm{\v{y}-\mat{K}\widehat{\tvar}}^2 + \lambda\enorm{\widehat{\tvar}}^2 &= \v{y}^\top \lambda^2
(\mat{K} + \lambda \mat{I})^ {-2} \v{y} + \lambda \v{y}^\top (\mat{K} + \lambda \mat{I})^{-1} \mat{K} (\mat{K} + \lambda \mat{I})^{-1}
\v{y} \\ &= \lambda\v{y}^\top (\mat{K} + \lambda \mat{I})^{-1} \v{y}
\end{align*}
and thus
\begin{align*}
T_2 =\frac{1}{2\sigma^2} \ensuremath{{\mathbb{E}}}[\enorm{\v{y}-\mat{K}\widehat{\tvar}}^2 + \lambda\enorm{\widehat{\tvar}}^2]
= \frac{\lambda}{2\sigma^2} \v{y^\star}^\top (\mat{K} + \lambda \mat{I})^{-1} \v{y^\star} + \frac12\sum_
{i=1}^
{n} \frac{\lambda}{\evali+\lambda}.
\end{align*}
Moreover, using an argument similar to that used in \cref{eq:thm_1_step_4},
we can write
\begin{align}
T_3 = \log \mrm{C}_{\lambda} =
\log\sqrt{\det(\frac{1}{\lambda} (\mat{K} + \lambda \mat{I}))}
=
\frac12\sumn[n]\log\parenth{\frac{\evali+\lambda_i}{\lambda_i}}.
\notag
\end{align}
Using the eigenvalue decomposition $\mat{K} = \mat U \mat D \mat U^\top$ where
$\mat D = \diag(\evali[1], \ldots, \evali[n]) $,
and setting $\alpha := \mat U^\top \v{y^\star}$, we thus find that
\begin{align}
\label{eq:mdl_kridge}
\frac{1}{n}\kull{\mb{P}_{f^\star}}{\mathbb{Q}_{\lambda}}
= \frac{1}{2n}\sumn \frac{\lambda}{\lambda+\evali}\parenth{\frac{\alpha_i^2}{\sigma^2}+1}
+ \frac{1}{2n}\sumn \log\parenth{\frac{\evali}{\lambda}+1}-\frac{1}{2}.
\end{align}
The remaining proof make use of arguments similar to those in
\citet[Lemma 7]{raskutti2014early}. Recall the
decomposition~\eqref{eq:mercer_kernel} for the kernel $\mc{K}$. For
any function $f^\star \in \mb{H}$, we can write
\begin{align*}
f^\star(x) = \sum_{k=1}^{\infty} \sqrt{\mu_k} a_k \phi_k(x)
\qtext{with} a_k = \frac{1}{\sqrt{\mu_k}} \int f(z) \phi_k(z)d\nu(z)
\qtext{and} \enorm{f^\star}^2_{\mb{H}} = \sum_{k=1}^\infty a_k^2,
\end{align*}
where $\nu$ denotes the marginal distribution of the covariates.
Define the linear operators $\Psi_{\mat{X}}:\ell^2(\mb{N}) \to \ensuremath{\mathbb{R}}^n$
as $\Psi_{\mat{X}}[i, j] = \phi_i(x_j)$ for $i \in \mb{N}$ and $j \in
[n]$. and the diagonal linear operator $\mathfrak{D}:\ell^2(\mb{N})
\to \ell^2 (\mb{N})$ as $\mathfrak{D}[i, i]=\mu_i$ and
$\mathfrak{D}[i, j]=0$ if $i \neq j$ for $i, j \in \mb{N}$. Given
this representation, we can rewrite the vector $\v{y^\star}$ and the kernel
matrix $\mat{K}$ as follows
\begin{align*}
\v{y^\star} =\Psi_{\mat{X}} \mathfrak{D}^{\frac12} a
\qtext{and}
\mat{K} = \Psi_{\mat{X}} \mathfrak{D} \Psi_{\mat{X}}^\top
\end{align*}
Combining the latter representation with $\mat{K} = \mat U \mat D \mat U^\top$,
we find that there exists an operator $\Gamma: \ell^2(\mb{N})\to \ensuremath{\mathbb{R}}^n$
with adjoint $\Gamma^*:\ensuremath{\mathbb{R}}^n \to \ell^{2}(\mb{N})$ and $\Gamma\Gamma^*=
\mat I_{n}$ such that
\begin{align*}
\Psi_{\mat{X}} \mathfrak{D}^{\frac12} = \mat U \mat D^{\frac12} \Gamma
\implies \alpha = \mat U^\top \v{y^\star} = \mat U^\top \Psi_{\mat{X}} \mathfrak{D}^{\frac12} a
= \mat U^\top \mat U \mat D^{\frac12} \underbrace{\Gamma a}_{=:\beta}
= \mat D^{\frac12}\beta.
\end{align*}
Note that $\beta \in \ensuremath{\mathbb{R}}^n$ and we have $\alpha_i^2
= \evali \beta_i^2$. Furthermore,
\begin{align}
\label{eq:beta_norm}
\sumn\beta_i^2 = \enorm{\Gamma a}_2^2\leq \enorm{a}_2^2 = \enorm{f^\star}_{\mb{H}}^2,
\end{align}
since $\Gamma$ is a unitary operator. Thus, we can
rewrite~\eqref{eq:mdl_kridge} as
\begin{align}
\frac{1}{n} \kull{\mb{P}_{f^\star}}{\mathbb{Q}_{\lambda}} & = \frac{1}{2n}
\sumn \frac{\lambda}{\lambda + \evali}
\parenth{\frac{\evali\beta_i^2}{\sigma^2}+1} + \frac{1}{2n} \sumn
\log\parenth{\frac{\evali}{\lambda}+1}-\frac{1}{2} \notag \\
& = \frac{1}{2n} \lambda \sumn
\frac{\evali}{\lambda+\evali}\frac{\beta_i^2}{\sigma^2} + \frac{1}{2n}
\sumn \log\parenth{\frac{\evali}{\lambda}+1} + \frac{1}{2n} \sumn
\frac{\lambda}{\lambda+\evali}- \frac{1}{2} \notag \\
& \sless{(i)} {\frac{\lambda}{2n} \parenth{\frac{\sumn
\beta_{i}^2}{\sigma^2}} + \frac{1}{2n}\sumn \log\parenth{
\frac{\evali}{\lambda}+1}} \notag\\
\label{eq:final_bound_ropt_kernel}
& \sless{(ii)} {\frac{\lambda}{2n} \frac{
\enorm{f^\star}^2_{\mb{H}}}{\sigma^2} + \frac{1}{2n} \sumn \log
\parenth{ \frac{\evali}{\lambda} + 1}},
\end{align}
where step~(i) follows from the fact that $\max\braces{\evali,
\lambda}/(\lambda+\evali)\leq 1$, and step~(ii) from the
bound~\eqref{eq:beta_norm}. The proof is now complete.
\paragraph{Remark:}
Let us discuss some scenarios in which the inequalities in (i) and
(ii) are tight after optimizing the
bound~\eqref{eq:final_bound_ropt_kernel} over $\lambda$. Call the
optimal choice $\lambda_{\mrm{opt}}$, and let $i^\star$ denote the index
such that $\lambda_{\mrm{opt}} \approx \evali[i^\star]$. The inequality
in step~(i) is relatively tight when: (a)
$\sum_{i=1}^{n}\lambda/(\lambda+\evali) \approx n$; and (b)
$\enorm{\beta}_2^2 \approx \sum_{j\leq i^\star} \beta_j^2$. Condition
(a) holds if the eigenvalue $\braces{\evali}$ have suitablly rapid
decay. whereas condition (b) holds when $i^\star < n$ and the
$\{\beta_j\}$ sequence is suitably decaying.
In order for inequality~(ii) to be relatively tight, we need the
inequality~\eqref{eq:beta_norm} to be relatively tight. This property
holds when we can obtain a good approximation of the
sum~\eqref{eq:mercer_kernel} by summing only its first $n$ terms; in
this case, $\Gamma$ and $\Gamma^\star$ are simply $n \times n$ unitary
matrices. This property holds when either the eigenvalues $\{\mu_k\}$
decay quickly, or the kernel $\mc{K}$ has a finite rank strictly
smaller than $n$, in which case $\mu_k=0$ for $k \geq n$. Note that
the different decay conditions covered in
Corollary~\ref{cor:mdl_kernel_smooth} are all sufficient for these
kernel conditions to hold.
\subsection{Proof of \cref{thm:rmt_expressions}}
\label{sub:proof_of_thm:rmt_expressions}
Our result involves the function
\begin{align}
\label{eq:g_fun}
g(a, b) := \frac{1}{4} \parenth{\sqrt{\mrm{snr} (1 + \sqrt{\gamma} )^2 +
1} - \sqrt{\mrm{snr}(1 - \sqrt{\gamma})^2 + 1}}^2, \qtext{for} a, b >
0.
\end{align}
The proof of this theorem makes use of the analytical expression of
$\ensuremath{\textrm{MDL-COMP}}$ from Theorem~\ref{thm:complexity_expressions} and few random
matrix theory results. Let $\mb{F}_d: a \mapsto
\frac{1}{d}\sumn[d]\mathbf{1}(a\leq\evali)$ denote the empirical
distribution of the eigenvalues of the matrix $\xmat^\top\xmat$.
First, we note that since $\tvar_\star$ is assumed to be drawn from
rotationally invariant distribution, we can rewrite the MDL-complexity
expression as
\begin{align*}
\ensuremath{{\mathbb{E}}}_{\tvar_\star}[\ensuremath{\mc R_{\textrm {opt}}}] = \ensuremath{{\mathbb{E}}}_{\v{\myvec}}\brackets{\frac{1}{n}
\sumn[\min\braces{n, d}] \log \parenth{1 + \frac{\evali\myvec_i^2}
{\sigma^2}}} & \stackrel{(i)}{\leq} \brackets{\frac{1}{n}
\sumn[\min\braces{n, d}] \log \parenth{1 + \frac{\evali
\ensuremath{{\mathbb{E}}}_{\v{\myvec}}[\myvec_i^2]} {\sigma^2}}} \\
& \stackrel{(ii)}{=} \frac{1}{n} \sumn[d] \log\parenth{1 + \evali
\cdot \mrm{snr}} \\
& = \frac{d}{n} \parenth{\frac{1}{d} \sumn[d] \log \parenth{1+\evali
\cdot \mrm{snr}}} \\
& = \frac{d}{n} \cdot \int_{Z=0}^\infty \log(1+Z\cdot \mrm{snr}) d \mb{F}_d
(Z),
\end{align*}
where step~(i) follows from Jensen's inequality, i.e.,
$\ensuremath{{\mathbb{E}}}[\log(1+W)] \leq \log (1+\ensuremath{{\mathbb{E}}}[W])$, and step~(ii) follows from
the fact that $\tvar_\star$ is drawn from rotationally-invariant
distribution and hence $\v{\myvec} = \mat U^\top \tvar_\star \stackrel{d}{=}
\tvar_\star$, and that $\ensuremath{{\mathbb{E}}}[\myvec_i^2] = \ensuremath{{\mathbb{E}}}[\enorm{\tvar_\star}^2]/d$.
Next, we recall a standard result from random matrix theory. Under
the assumptions of Theorem~\ref{thm:rmt_expressions}, as $d, n\to
\infty$ with $d/n\to \gamma$, the empirical distribution $\mb{F}_d$ of
the eigenvalues of the matrix $\xmat^\top\xmat$ converges weakly, almost surely
to a nonrandom limiting distribution $\mb{MP}_\gamma$ with density
\begin{align}
\label{eq:mp_law}
m_{\gamma}(a) = \parenth{1-\frac{1}{\gamma}}_{+} \delta(a) +
\frac{\sqrt{(a-b_1)_+(b_2-a)_+}}{2\pi\gamma a}, \qtext{where $b_1 =
(1-\sqrt\gamma)^2$ and $b_2 = (1+\sqrt\gamma)^2$.}
\end{align}
This distribution is also known as the
Mar$\breve{\textrm{c}}$enko-Pastur law with ratio index $\gamma$. (For
background, see the
papers~\citep{marvcenko1967distribution,silverstein1995strong}, or
Theorem 2.35 in the book~\citep{tulino2004random})
Next, we claim that as $d, n\to \infty$ with $d/n\to \gamma$, we have
\begin{align}
\label{eq:rmt_claim}
\ensuremath{\mc R_{\textrm {opt}}}
= \frac{d}{n} \cdot \int_{0}^\infty \log(1+Z\cdot \mrm{snr}) d\mb{F}_d(Z)
\longrightarrow
\gamma\cdot \ensuremath{{\mathbb{E}}}_{Z\sim \mb{MP}_\gamma}\brackets{\log(1+\mrm{snr}\cdot Z)},
\end{align}
almost surely. Assuming this claim as given at the moment, let us now
complete the proof. In general, the analytical expressions for
expectations under the distribution $\mb{MP}_{\gamma}$ are difficult
to compute. However, the expectation $\ensuremath{{\mathbb{E}}}_{Z\sim \mb{MP}_\gamma}
\brackets{\log(1+\gamma Z)}$ is known as the Shannon transform and
there exists a closed form for it (see Example
2.14~\citep{tulino2004random})\footnote{The transform in the
reference~\citep{tulino2004random} uses the $\log_2$ (base-$2$
logarithm) notation. The results stated here have been adapted for
$\log_e$ (base-$e$, natural logarithm) in a straightforward manner.}:
\begin{align}
\ensuremath{{\mathbb{E}}}_{Z\sim \mb{MP}_\gamma}\brackets{\log(1+\mrm{snr}\cdot Z)}
=: \mc{V}_Z(\mrm{snr})
= \log\parenth{1+\mrm{snr}-\delta} + \frac{1}{\gamma}\log\parenth{1+\gamma\cdot\mrm{snr}
-\delta} - \frac{\delta}{\mrm{snr}\cdot \gamma},
\label{eq:shannon_transform}
\end{align}
where $\delta = g(\mrm{snr}, \gamma)$ and the function $g$ was defined in equation~\eqref{eq:g_fun}.
Putting the \cref{eq:rmt_claim,eq:shannon_transform} together yields the
expression~\eqref{eq:mdl_complexity_rmt} stated in Theorem~\ref{thm:rmt_expressions}.
\paragraph{Proof of claim~\eqref{eq:rmt_claim}:}
This part makes use of the Portmanteau theorem and some known results
from~\cite{bai2008limit}. Recalling the constant $b_2 := (1+\sqrt
\gamma)^2$ from equation~\eqref{eq:mp_law}, for $a \in [0, \infty)$,
consider the function $f(a) \log (1+\mrm{snr}\cdot a) \mathbf{1} (a\leq
2b_2) $ As $n, d\to \infty$ with $d/n\to\gamma$, we have
\begin{align*}
\int_{0}^\infty f(Z) d\mb{F}_d(Z) \stackrel{(i)}{=} \int_{0}^{2b_2}
f(Z) d\mb{F}_d(Z) \stackrel{(ii)}{\longrightarrow} \int_{0}^{2b_2}
f(Z) d\mb{MP}_\gamma(Z) &\stackrel{(iii)}{=} \int_{0}^{\infty} f(Z)
d\mb{MP}_\gamma(Z) \\ &= \ensuremath{{\mathbb{E}}}_{Z\sim\mb{MP}_\gamma}[1+\log(\mrm{snr}\cdot
Z)],
\end{align*}
where steps~(i) and (iii) follow from the definition of $f$, i.e.,
$f(Z)=0$ for any $Z>2b+2$. Moreover, step~(ii) follows from applying
the Portmanteau theorem, which states that the weak almost sure
convergence~\eqref{eq:mp_law} implies the convergence in expectation
for any bounded function, and $f$ is a bounded function. Finally, we
argue that for large enough $n$, we have
\begin{align*}
\int_{0}^\infty \log(1+Z\cdot \mrm{snr}) d\mb{F}_d(Z)
\stackrel{(iv)}{=} \int_{0}^{2b_2} \log(1+Z\cdot \mrm{snr})
d\mb{F}_d(Z) \stackrel{(v)}{=} \int_{0}^\infty f(Z) d\mb{F}_d(Z)
\end{align*}
In order to establish step~(iv), we invoke a result from the
work~\citep{bai2008limit} (Corollary 1.8). It states that for large
enough $n$, the largest eigenvalue of the matrix $\xmat^\top\xmat$ is bounded
above by $2(1+\sqrt\gamma)^2$ almost surely, and thus, we can restrict
the limits of the integral on the LHS to the interval $[0, 2b_2]$.
Step~(v) follows trivially from the definition of the function $f$.
Putting the pieces together yields the claim~\eqref{eq:rmt_claim}.
\subsection{Proof of \cref{thm:minimax_codelength}}
\label{sub:proof_of_thm:minimax_codelength}
The proof of this theorem makes use of the algebra used in previous
proofs, and hence we simply illustrate the main steps. We have
\begin{align*}
\mathbb{E} \brackets{\log \parenth {\frac{1}{q_{\mat{\Lambda}}(\v{y})}}} & = \ensuremath{{\mathbb{E}}}
\brackets{\frac{1}{2\sigma^2}\enorm{\v{y} - \mat{X} \widehat{\tvar}}^2 +
\frac{1}{2\sigma^2} \widehat{\tvar} ^\top \mat{\Lambda} \widehat{\tvar}} + \log \mrm{C}_{\mat{\Lambda}},
\end{align*}
where \mbox{$\log \mrm{C}_{\mat{\Lambda}} = \frac{1}{2} \sumn[\min\braces{n, d}]
\log\parenth{\frac{\evali+\lambda_i}{\lambda_i}}$.} Repeating
arguments similar to those in \cref{eq:thm_1_step_3a,eq:thm_1_step_3},
we find that
\begin{align*}
\notag & \ensuremath{{\mathbb{E}}}\brackets{\frac{1}{2 \sigma^2} \enorm{ \v{y} - \mat{X}
\widehat{\tvar}}^2 + \frac{1}{2 \sigma^2} \widehat{\tvar} ^\top \mat{\Lambda}\widehat{\tvar}} \\
& = \frac{1}{2\sigma^2} \tvar_\star ^\top \mat{X} ^\top \parenth{\mat V \overline{\mat{\Lambda}}
(\mat D + \overline{\mat{\Lambda}})^ {-1} \mat V^\top} \mat{X} \tvar_\star +
\frac{1}{2\sigma^2}\trace \brackets{\textrm{Var}(\v{y}\vert\mat{X}) \mat
V \overline{\mat{\Lambda}} (\mat D + \overline{\mat{\Lambda}})^{-1} \mat V^\top } \notag \\
& \qquad\qquad\qquad + \frac{1}{2\sigma^2} \trace
\brackets{\textrm{Var}(\v{y} \vert \mat{X})(\mat I - \mat V \mat V^\top)}
\notag \\
& \stackrel{(i)}{\leq} \frac1{2\sigma^2}\parenth{\v{w} ^\top \mat D
\mat{\Lambda} (\mat D + \mat{\Lambda}) ^{-1} \v{w}} + \frac{1}{2 \sigma^2}\trace
\brackets{\sigma^2 \mat I_n {\textrm{Var}(\v{y} \vert \mat{X})} \mat V
\overline{\mat{\Lambda}} (\mat D + \overline{\mat{\Lambda}})^{-1} \mat V ^\top } \notag \\
& \qquad\qquad\qquad + \frac{1}{2 \sigma^2} \trace
\brackets{\sigma^2 \mat I_n (\mat I - \mat V \mat V ^\top)} \notag \\
& =\frac{(n -\min \braces{n, d})}{2} +\frac{1}{2}\sumn[d]
\parenth{\frac{\evali \myvec_i^2 } {\sigma^2} + 1} \frac{\lambda_i}
{\lambda_i + \evali}
\end{align*}
where step~(i) follows from the following linear algbera fact: For
matrices $\mat A, \mat B, \mat C \succeq 0$, if $\mat A \succeq \mat
B$, then $\trace[\mat{AC}] \geq \trace[\mat{BC}]$. Moreover, noting
that in step~(i), we have equality when $\text{Var}(\v{y}\vert\mat{X}) =
\sigma^2 \mat I_n$. Putting the pieces together, we conclude that
\begin{align*}
\max_{\P \in \mc{P}_{\textrm{bndvar}}} \mathbb{E} \brackets{\log
\parenth{\frac{1}{q_{\mat{\Lambda}}(\v{y})}}} = \frac{(n - \min
\braces{n, d})}{2} + \frac{1}{2}\sumn[d] \parenth{\frac{\evali
\myvec_i^2 } {\sigma^2} + 1} \frac{\lambda_i} {\lambda_i +
\evali} + \frac{1}{2} \sumn[\min\braces{n, d}] \log \parenth{\frac{\evali +
\lambda_i}{\lambda_i}}.
\end{align*}
As function of $\braces{\lambda_i}$ in comparison to the function
\cref{eq:thm_1_kull}, this objective is a simply shifted by a
constant. Consequently, it admits the same minimizer
\begin{align*}
\arg \min_{\mathbb{Q}_{\mat{\Lambda}} \in \mc{Q}_{\mrm{Ridge}}} \max_{\P \in
\mc{P}_{\textrm{bndvar}}} \mathbb{E} \brackets{\log \parenth{\frac{1}{q_{\mat{\Lambda}}(\v{y})}}}
= \mathbb{Q}_{\mat{\Lambda}_{\textrm{opt}}},
\end{align*}
as claimed.
\subsection{Proof of Corollary~\ref{cor:mdl_kernel_smooth}}
\label{sub:proof_of_cref_cor_mdl_kernel_smooth}
We prove the bounds for polynomial and exponential decay of
eigenvalues separately.
\subsubsection{Proof with polynomial decay of eigenvalues}
When $\mc{K}(x, x)=1$, we have $\trace(\mat{K}) = \sum_{i=1}^n\evali =
n$. Thus, with $\evali \precsim i^{-2\alpha}$, we can conclude that
$\evali \leq c_\alpha n i^{-2\alpha} $ where
$c_{\alpha}:=\sum_{j=1}^nj^{-2\alpha} \leq 1/(2\alpha-1)$, where the additional factor of $n$ arises due to the constraint that $\trace(\mat{K}) = \sum_{i=1}^n\evali =
n$.
Since the MDL-COMP is an increasing function in $\evali$, it suffices
to consider the case when $\evali = n c_\alpha i^{-2\alpha}$. Setting
$\alpha = \omega/d$ covers the case of $\evali \precsim
i^{-2\omega/d}$, and setting $\alpha = \frac{1}{2} (d+a)$ covers the
case of $\evali \precsim i^{-(d+a)}$. With the assumptions $\omega >
d/2$ and $d + a >1$, we find that for both cases $2 \alpha - 1 >0$ and
hence $c_{\alpha}$ is finite.
Let us write $\lambda$ as $nM^{-2\alpha}$, and given the rapid decay
of $\evali$, we can use the bounds
\begin{align*}
\sum_{i=1}^{\ceil{M}} \log(\evali/\lambda+1) \leq
\sum_{i=1}^{\ceil{M}} \log((M/i)^{2\alpha}+1) \stackrel{(i)}{\leq}
c_1 \cdot \alpha M \log M
\\
\sum_{i=\ceil{M}+1}^n \log(\evali/\lambda+1) \leq
\sum_{i=\ceil{M}+1}^{n} \log((M/i)^{2\alpha}+1) \leq
\sum_{i=\ceil{M}+1}^{n} (M/i)^{2\alpha} \leq c_\alpha.
\end{align*}
where step~(i) uses the fact that $\int_{1}^{x} \log z dz = x \log x -
x \leq x \log x$ for $x > 1$, and step~(ii) uses the fact that
$\sum_{i=\ceil{M}+1}^{n}(M/i)^{2\alpha} \leq
\sum_{j=1}^{\infty}j^{-2\alpha} = c_{\alpha}$. Thus, we can write the
RHS in \cref{eq:mdl_kernel} as
\begin{align*}
\frac{\lambda}{2n} \frac{\enorm{f^\star}^2_{\mb{H}}}{\sigma^2} +
\frac{1}{2n} \sumn \log\parenth{\frac{\evali}{\lambda}+1} \leq
\frac{1}{2n} \brackets{n M^{-2\alpha}\textrm{SNR}^2 + c \alpha M\log M +
c_{\alpha}}
\end{align*}
In order to minimize the RHS above with respect to $M$, we can equate
the two terms inside the brackets, and obtain
\begin{align*}
\frac{n \textrm{SNR}^2}{\alpha} \asymp M^{1+2\alpha}\log M
\quad\Longleftrightarrow\quad M \asymp \left(\frac{{n
\textrm{SNR}^2}/{\alpha}}{\log({n
\textrm{SNR}^2}/{\alpha})}\right)^{1/(1+2\alpha)}
\end{align*}
which yields
\begin{align*}
\ensuremath{\textrm{MDL-COMP}} \asymp M^{-2\alpha}\textrm{SNR}^2 & = \left(\frac{{n
\textrm{SNR}^2}/{\alpha}}{ \log({n
\textrm{SNR}^2}/{\alpha})}\right)^{-2\alpha/(1+2\alpha)} \textrm{SNR}^2 \\
& = c'_{\alpha} \left(\frac{ \log({n
\textrm{SNR}^2})}{n}\right)^{2\alpha/(1+2\alpha)} \textrm{SNR}^{2/(1+2\alpha)}
\\
& = C_{\alpha, \textrm{SNR}} \left( \frac{\log
(n\textrm{SNR}^2)}{n}\right)^{2\alpha/(1+2\alpha)},
\end{align*}
where
\begin{align}
\label{eq:constant_ker_smooth}
C_{\alpha, \textrm{SNR}} = \alpha^{2\alpha/(1+{2\alpha})} \textrm{SNR}^{2/(1+2\alpha)}.
\end{align}
Setting $\alpha = \omega/d$ and $\frac12(d+a)$ respectively recovers
the first two bounds stated in the
display~\eqref{eq:mdl_kernel_smooth}.
\subsubsection{Proof with exponential decay of eigenvalues}
Now, we do a reparametrization of $\lambda$ as $n\exp(-M/d)$, and
given the rapid decay of $\evali$, we use the following bounds:
\begin{align*}
\sum_{i=1}^{\ceil{M}}\log(\evali/\lambda+1) \leq
\sum_{i=1}^{\ceil{M}}\log(e^{(M-i)/d}+1) \stackrel{(i)}{\leq}
\frac{c}{d} \cdot \sum_{i=1}^{\ceil{M}} (M-i) \leq c'
\frac{M^2}{d} \\
\sum_{i={\ceil{M}}+1}^n\log(\evali/\lambda+1) =
\sum_{i={\ceil{M}}+1}^{n}\log(e^{(M-i)/d}+1) \leq
\sum_{i={\ceil{M}}+1}^{n} e^{(M-i)/d} \leq c_d''.
\end{align*}
where we use the fact that $\log(1+ e^{x}) \leq c x$ for large $x$,
and $\log(1+e^x) \leq e^x$ for all $x$. Thus, we can write the RHS in
\cref{eq:mdl_kernel} as
\begin{align*}
\frac{\lambda}{2n} \frac{\enorm{f^\star}^2_{\mb{H}}}{\sigma^2} +
\frac{1}{2n}\sumn \log\parenth{\frac{\evali}{\lambda}+1} \leq
\frac{1}{2n}\brackets{ne^{-M/d}\textrm{SNR}^2 + c' \frac{M^2}{d} + c_{d}''}
\end{align*}
In order to minimize the RHS of the above display with respect to $M$,
we can equate the two terms inside the brackets, and obtain
\begin{align*}
d n \textrm{SNR}^2 \asymp e^{M/d} M^2 \quad\Longleftrightarrow\quad M \asymp
d \log\parenth{\frac{nd\textrm{SNR}^2}{d\log(nd\textrm{SNR}^2))}}.
\end{align*}
Thus, we have
\begin{align*}
\ensuremath{\textrm{MDL-COMP}} \asymp \frac{M^2}{dn} &= \frac{d\log^2(nd \textrm{SNR}^2)}{n},
\end{align*}
as claimed.
\section{Bias-variance tradeoff with different designs}
\label{sub:different_design}
\setcounter{table}{0} \setcounter{figure}{0}
\renewcommand{\thefigure}{F\arabic{figure}}
\renewcommand{\thetable}{F\arabic{table}}
In this section, we show that the bias-variance tradeoff for OLS
heavily depends on the design matrix. More precisely, depending on
the structure of the design matrix, it is possible to observe
double-descent or multiple descent, where the peaks can occur at
values of $d/n$ not necessarily equal to $1$ in the test MSE when
varying $d$. While OLS can exhibit a wide range of behavior, we also
show that the test MSE for CV-tuned ridge regression exhibits
the familiar U-shaped behavior for all the choices of design
considered here.
In the experimental results shown here, we generate data from a linear
Gaussian model of the form
\begin{align}
\v{y} = \underbrace{\mat{X} \tvar_\star}_{\v{y}_\star} + \noise[],
\end{align}
where $\noise[] \in \ensuremath{\mathbb{R}}^n \sim \mc N(0, \sigma \mat I_n)$ with
$\sigma = 0.1$. In all cases, we keep the training sample size fixed
at $n=200$, and the maximum size of covariates is fixed at $2000$.
With these fixed choices, we consider several different choices of the
design matrix $\mat{X}$, along with two choices for the unknown
regression vector $\tvar_\star$.
\paragraph{Choice for $\mat{X}$:}
We consider two possible random ensembles for the design matrix
$\mat{X}$. Let $\mat A \in \ensuremath{\mathbb{R}}^{200 \times 2000}$ denote a matrix
whose entries are drawn iid from $\mc N(0, 1)$. Let $\mat B \in
\ensuremath{\mathbb{R}}^{2000 \times 2000}$ denote a diagonal matrix such that $\mat
B_{ii} = \vert\cos i\vert$ for $i$ even, and $0$ otherwise. Then the
two choices for the design matrix $\mat{X}$ are (I) \emph{Gaussian
design} with $\mat{X} = \mat A$, and (II) \emph{Cosine design} with
$\mat{X} = \mat A \mat B$.
\paragraph{Choice for $\tvar_\star$:}
In parallel, we consider two possible random ensembles for the unknown
regression vector $\tvar_\star$. In all cases, the response $\v{y}_\star$
depends on only on $d_\star$ covariates in total. In setting (A)
where $\mathbf {d_\star < n}$, we choose $\tvar_\star$ to have non-zero
entries for the index $\braces{11, 12, \ldots, 60}$, i.e., the true
dimensionality of the dataset is $d_\star =60$, which is less than the
sample size $n=200$. In setting (B) where $\mathbf {d_\star > n}$, we
choose $\tvar_\star$ to have non-zero entries for all indices in the set
$\braces{1, 2, \ldots, 400}$. Consequently, the number of free
parameters $d_\star=400$ is much larger than the sample size
$n=200$. In both settings, the non-zero entries of $\tvar_\star$ are drawn
iid from $\mc N(0, 1)$, and then normalized such that $\enorm{\tvar_\star}=
1$. \\
\vspace*{0.2in}
Taking all possible combinations of random ensembles for $\mat{X}$ and
$\tvar_\star$ yields four distinct experimental settings: IA, IB, IIA, IIB.
Given a particular setting---for instance, setting IA with Gaussian
design and $d_\star = 60 < n$ (IA)---we generate a dataset of $n$
observations and then fit different estimators with a varying number
of covariates (denoted by $d$); i.e., the response variable $\v{y}$
remains fixed and we only vary the dimensionality of the design matrix
for fitting OLS or Ridge model. We then compute the test MSE
(computed on an independent draw of $\v{y}_\star^{\textrm{test}}$ of
size $n_{\textrm{test}}=1000$). We redraw the noise in the
observation $50$ times ($\v{y}_\star^{\textrm{train}} \text{ and }
\v{y}_\star^{\textrm{test}}$ remain fixed), and plot the average of test
MSE over these runs. For a given $d$, the bias and variance for a
given estimator (OLS or Ridge) are computed as follows:
\begin{align*}
\textrm{Bias}(d) &= \frac{1}{n_{\textrm{test}}}
\enorm{\v{y}_\star^{\textrm{test}}-\overline{\v{y}^{\textrm{est}}}}^2,
\qtext{and}\\ \textrm{Variance}(d) &=\frac{1}{50} \sum_{r=1}^{50}
\frac{1}{n_{\textrm{test}}}
\enorm{\v{y}^{\textrm{est}}_r-\overline{\v{y}^{\textrm{est}}}}^2,
\end{align*}
where $r$ denotes the index of the experiment (redraw of noise
$\noise[]$), $\v{y}^{\textrm{est}}_r$ denotes the estimate for the
response for the test dataset for the $r$-th experiment, and
$\overline{\v{y}^ {\textrm{est}}}$ denotes the average of the
predictions made by the estimator across all $50$ experiments.
The four panels in \cref{fig:test_mse_diff_design} show, for each of
these four settings, plots of the radio $d/n$ versus test MSE for the
OLS and CV-tuned ridge estimators. \cref{fig:bias_var_diff_design}
shows the underlying bias-variance tradeoff curves in settings IA and
IIA.
\begin{figure}[ht]
\centering
\begin{tabular}{cc}
\includegraphics[width=0.36\linewidth]{../figs/identity0detailed_test_mse}
&
\includegraphics[width=0.36\linewidth]{../figs/identity_high_dim0detailed_test_mse}
\\ (a) & (b)
\\ \includegraphics[width=0.36\linewidth]{cosine0detailed_test_mse}
&
\includegraphics[width=0.36\linewidth]{cosine_high_dim0detailed_test_mse}
\\ (c) & (d)
\end{tabular}
\caption{Plots of test MSE for OLS and CV-tuned Ridge for the four
designs discussed in \cref{sub:different_design}, versus the
dimensionality of the covariates in the fitted model varies. The
training sample size is fixed at $n=200$.
} \vspace{2mm}
\label{fig:test_mse_diff_design}
\end{figure}
From these figures, we can draw the following conclusions. On one
hand, the test MSE of the CV-tuned ridge estimator exhibits the
classical U-shaped curve for all the settings. On the other hand, the
behavior of OLS is heavily dependent on the covariate design along
with the choice of $d_\star$. For $d<d_\star$, both OLS and Ridge show
the classical tradeoff between bias (deccreasing in $d$) and variance
(increasing in $d$). For $d>d_\star$, the bias of the tuned ridge
increases monotonically with $d$, but the variance increases until a
design-dependent threshold, after which it then decreases. In almost
all cases, the bias of OLS monotonically increases as $d$ increases
above $d_\star$; however, the variance term can show multiple peaks
depending on the design, and these peaks frequently show up in the
test MSE as well.
\begin{figure}[ht]
\centering
\begin{tabular}{cc}
\includegraphics[width=0.36\linewidth]{../figs/identity0detailed_bias_variance_ols}
&
\includegraphics[width=0.36\linewidth]{../figs/identity0detailed_bias_variance_ridge}
\\ (a) & (b)
\\ \includegraphics[width=0.36\linewidth]{cosine0detailed_bias_variance_ols}
&
\includegraphics[width=0.36\linewidth]{cosine0detailed_bias_variance_ridge}
\\ (c) & (d)
\end{tabular}
\caption{Bias-variance tradeoff of OLS and CV-tuned Ridge
estimators for various designs discussed in
\cref{sub:different_design}. Panels (a) and (b) show the results
for design IA corresponding to the
\cref{fig:test_mse_diff_design}(a), and panels (c) and (d) show
it for design IIA corresponding to the
\cref{fig:test_mse_diff_design}(c). }
\label{fig:bias_var_diff_design}
\end{figure}
\end{appendix}
{\small
\section{Introduction}
\label{sec:introduction}
Occam's razor and the bias-variance tradeoff have long provided
guidance for model selection in statistics and machine learning.
Given a dataset, these principles recommend selecting a model that
balances between (a) fitting the data well,
and (b) having relatively low complexity.
Roughly speaking, in the low-dimensional regime, one typically observed the following tradeoff:
On the one hand, a model whose complexity is too low incurs \emph{high bias}, i.e., it does not fit the training data well (under-fitting);
on the other hand, an overly complex model memorizes the training data, suffering from \emph{high variance}, i.e. poor performance on unforeseen data (over-fitting).
There are numerous characterizations of complexity in the statistical machine learning literature that are commonly used to perform model selection, and to establish bounds on prediction error.
These include Akaike information criterion~\citep{akaike1974new}, Mallow's $C_p$~\citep{mallows1973some}, Bayesian information
criterion~\citep{schwarz1978estimating},
Vapnik-Chervonenkis dimension~\citep{vapnik2015uniform}, and Rademacher complexity~\citep{bartlett2002rademacher,anthony2009neural,van2006empirical}. Intuitively, such measures reflect the effective number of parameters used to fit the model.
In the classical regime for linear regression with $d$ features, and $n$ training data points, when $d < n$, and the design matrices are well-conditioned, all of these measures reduce to simple parameter counting for linear models. Another common proxy for model complexity is the degrees of
freedom~\citep{efron1986biased,buja1989linear,efron2004estimation},
along with extensions such as effective or generalized degrees of freedom for more complex models~\citep{meyer2000degrees,shen2002adaptive,efron2004estimation,hastie2005elements,zhang2012generalized}, and high-dimensional sparse regression~\citep{zou2007degrees,tibshirani2012degrees,hastie2017generalized}.
As a special case, in an unstructured linear
regression problem based on $n$ samples with $d$ features (with $d <
n$), the degree of freedom is equal to $d$.
However, recent work~\citep{kaufman2014does,janson2015effective,tibshirani2015degrees}
has shown that when moving to the over-parameterized setting ($d >
n$), effective degrees of freedom may be a poor measure of model
complexity. In some past work, the variance of the estimator itself has sometimes been used as a measure of complexity (e.g., in $L^2$-boosting~\citep{buhlmann2003boosting}). However, such a choice may be misinformed when the bias term is dominant.
Overall, the choice of parameter count as a complexity measure for linear
models is rigorously justified when the data is low-dimensional ($d <
n$), and the design matrix is well-conditioned (so that all $d$
directions contribute in roughly equal measure).
Indeed, under these conditions, the OLS
estimate has good performance when $d \ll n$, and its test error
increases proportionally with $d$ in this regime. However, using $d$ as the complexity measure when $d>n$ remains unjustified even for linear models, and for low-dimensional linear models when the design matrix is not well-conditioned; and in high-dimensional models, the design matrix by definition is ill-conditioned since it does not even have full rank.
More recently, a line of work has derived generalization error bounds for deep neural networks~\citep{neyshabur2015norm,bartlett2017spectrally,neyshabur2017pac,golowich2017size,li2018tighter,neyshabur2018role}
based on Rademacher-like complexity notions.
However, at least thus far, such bounds remain too loose to inform practical performance~\citep{arora2018stronger}. Moreover, there is growing evidence that heavily overparameterized models once trained are often not complex, due to the implicit regularization induced by model architecture, optimization methods including initialization, and training datasets~\citep{Nakkiran2019DeepDD,neyshabur2014search, arora2019implicit, neyshabur2018role}.
There has been a series of recent work investigating generalization performance of overparameterized linear models and kernel methods as they can be seen as as tractable settings for providing theoretical insight into the behavior of
(overparameterized) deep neural networks. See, e.g., \cite{belkin2018understand,jacot2018neural,du2018gradient, allen2018convergence,hastie2019surprises,bartlett2020benign,tsigler2020benign} and the references therein.
The starting point for this work is to seek a valid complexity measure for regression tasks with overparameterized linear models, that can be easily extended to kernel methods, and then to use this complexity measure for tuning regularization parameter.
To do so, we build on the optimality principle put forth in the algorithmic complexity of Kolmogorov, Chaitin, and Solomonoff~\citep{kolmogorov1963tables,kolmogorov1968three,li2008introduction} and the principle of minimum description length (MDL) of
Rissanen~\citep{rissanen1986stochastic,barron1998minimum,hansen2001model,grunwald2007minimum}. For linear models, the known MDL complexity measures also scale roughly linearly with dimension $d$, or they can be infinite (see \cref{sub:nml})
\paragraph{Our contributions:}
We define a new complexity measure MDL-COMP that corresponds to the minimum excess bits required to transmit the data when constructing an optimal code for a given dataset via a family of models based on the ridge estimators. Within this framework, we undertake a detailed study of high-dimensional linear models and kernel methods.
We show that \ensuremath{\textrm{MDL-COMP}}\ has a wide range of behavior depending on the design matrix (or the kernel matrix). For linear models with $d$ features, and $n$ samples, it usually scales like $d/n$ for $d<n$, and grows very slowly---logarithmic in $d$---for $d>n$ (see \cref{fig:mdl_gaussian,fig:mdl_spike_design}). We establish that \ensuremath{\textrm{MDL-COMP}}\ provides an upper bound for in-sample MSE
(\cref{thm:lam_opt}), and that it satisfies certain minimax optimality
criterion (\cref{thm:minimax_codelength}). For kernel methods, we show that for kernels in Gaussian and Sobolev spaces, MDL-COMP can inform the minimax in-sample generalization (\cref{thm:mdl_kernel} and Corollary~\ref{cor:mdl_kernel_smooth}). Interestingly, for neural tangent kernels (NTKs), we find that MDL-COMP itself can sometimes reduce when the dimensionality of the input increases.
Next, to evaluate the practical usefulness of \ensuremath{\textrm{MDL-COMP}}, we consider a data-driven form of
\ensuremath{\textrm{MDL-COMP}}-inspired hyperparameter selection, which provides competitive performance with cross-validation for ridge regression (in terms of test MSE), especially in limited data settings in several simulations and real-data experiments. Moreover, this criterion can provide computational savings especially while training overparameterized models in contrast to the vanilla K-fold cross-validation (since computation is only required for a single fold). Finally, we also highlight some insights that our findings provide for the recently observed \emph{double descent} phenomenon on test error of overparameterized models.
\paragraph{Organization:}
\label{par:organization_}
We start with a background on MDL and setting the notation in \cref{sub:background}, followed by the definitions of complexity central to this work in \cref{sec:complexity}. We then provide our main results and their consequences in \cref{sec:main_results}, and present several numerical experiments in \cref{sec:experiments}.
We conclude with a discussion and directions for future work in
\cref{sec:discussion}, where we also discuss the consequences of our results for double-descent. Proofs of all results and additional experiments are provided in the appendix.
\section{Background on the principle of minimum description length}
\label{sub:background}
In order to define a complexity measure in a principled manner, we
build upon Rissanen's principle of minimum description length (MDL).
It has its intellectual roots in Kolmogorov's theory of complexity.
Both approaches are based on an optimality requirement: namely, the
shortest length program that outputs a given sequence on a universal
Turing machine for Kolmogorov complexity, and the shortest
(probability distribution-based) codelength for the given data for MDL.
Indeed, Rissannen generalized Shannon's coding theory to universal
coding and used probability distributions to define a universal encoding
for a dataset and then used the codelength as an approximate measure
of Kolmogorov's complexity.
\subsection{Basic principle}
\label{sub:introduction}
From the perspective of minimum description length, a model or a
probability distribution for data is equivalent to a (prefix) code;
one prefers a code that exploits redundancy in the data to compress it
into as few bits as possible;
see~\citep{rissanen1986stochastic,barron1998minimum,grunwald2007minimum}.
Since its introduction, MDL has been used in many tasks including
density estimation~\citep{zhang2006}, time-series
analysis~\citep{tanaka2005discovery}, model
selection~\citep{barron1998minimum, hansen2001model,
miyaguchi2018high}, and DNN
training~\citep{hinton1993keeping,schmidhuber1997discovering,li2018measuring,blier2018description}.
For readers unfamiliar with MDL, Sections 1 and 2 of the
papers~\citep{barron1998minimum,hansen2001model} provide background on
MDL.
In the MDL
framework, any probability model is viewed as a type of coding, so
that for example, fitting a Gaussian linear model is equivalent to
using a Gaussian code for compressing the data. The goal is to select
the code that provides the shortest description of data; in most
settings, this translates into picking the model with the best fit to
the data. More formally, suppose we are given a set of $\samples$
observations $\v{y} = \braces{\yi[1], \yi[2], \ldots, \yi[n]}$. Let
$\mathbb{Q}$ refer to a probability distribution on the space $\ensuremath{\mathcal{Y}^n}$
(e.g., a subset of $\ensuremath{\mathbb{R}}^n$) where $\v{y}$ takes values, and let
$\mc{Q}$ denote a set of such distributions. Given a probability
distribution $\mathbb{Q}$, we can associate an
\emph{information-theoretic} prefix code for the space $\ensuremath{\mathcal{Y}^n}$,
wherein for any observation $\v{y}$ we need to use $\log(1/\mathbb{Q}(\v{y}))$
number of bits to \emph{describe} $\v{y}$. The MDL principle dictates
choosing the code $\mathbb{Q}$ associated with the shortest possible
description length---namely, a code achieving the minimum
$\min_{\mathbb{Q} \in \mc{Q} } \log(1/\mathbb{Q}(\v{y}))$. Note that when $\mc{Q}$
is simply a parametric family, the direct MDL principle reduces to the
maximum likelihood principle. But the advantage of MDL comes from the
fact that the set $\mc{Q}$ can be more complex, e.g. a nested
union of parametric families, or a set of codes not indexed by the
canonical parameter of interest. Furthermore, even without a
generative modeling assumption, the notion of shortest description
over an arbitrary set of codes $\mc{Q}$ continues to be
well-defined. (For further discussion about MDL vs maximum likelihood,
we refer the reader to \cref{sub:further_background}.)
\subsection{Two-stage MDL}
\label{sub:two_stage}
One of the earliest notions of MDL is two-stage MDL, often considered for doing model selection over a nested family of parametric model classes, where the dimensionality of the parameter varies across different parametric classes.
This version of MDL turns out to be equivalent to the Bayesian
information criterion (BIC)---that is, it performs model selection
based on a regularized maximum likelihood, where the regularization
term is simply $\frac d2\log n$. Consequently, apart from the
additional logarithmic term, the MDL complexity in this set-up simply
reduces to parameter counting.
\subsection{Normalized maximum likelihood}
\label{sub:nml}
Many modern approaches to MDL are based on a form of universal coding
known as \emph{normalized maximum likelihood}, or NML for short. In
this approach, the distribution $\mathbb{Q}$ is defined directly on the
space $\ensuremath{\mathcal{Y}^n}$; at least in general, it is \emph{not} explicitly
parametrized by the parameter of interest. More concretely, given a
family of codes $\mc P_{\Theta} = \braces{p(\cdot; \theta),
\theta\in \Theta}$, the NML code is defined as
\begin{align}
\label{eq:nml_defn}
q_{\mrm{NML}}(\v{y}) := \frac{\max_{\theta} p(\v{y}; \theta)}{\int_{\ensuremath{\mathcal{Y}^n}} \max_{\theta'} p(\v{y'}; \theta') d\v{y'}},
\end{align}
assuming that the integral in the denominator is finite.
\cite{shtar1987universal} established that this NML distribution (when
defined) provides the best encoding for the family $\mc P_{\Theta}$ in
a minimax sense. The log normalization constant
\begin{align}
\label{eq:shtarkov_complexity}
\log \int_{\ensuremath{\mathcal{Y}^n}} \max_{\theta'} p(\v{y'}; \theta') d\v{y'}
\end{align}
associated with this code is referred to as the \emph{NML or Shtarkov
complexity.} Note that the normalization~\eqref{eq:nml_defn} ensures
that $\mathbb{Q}_{\mrm{NML}}$ is a valid code by making $q_{\mrm{NML}}$ a
valid density.\footnote{Thus, Kraft's inequality guarantees the
existence of a code corresponding to it.} Such codes are called
\emph{universal codes}, since the codelength
$\log(1/q_{\mrm{NML}}(\v{y}))$ is universally valid for any $\v{y}
\in \ensuremath{\mathcal{Y}^n}$.
\paragraph{Known results:}
Suppose that $\mc P_{\Theta}$ is a parametric class of dimension $d$.
In this special case, under suitable regularity conditions, the NML complexity scales asymptotically as
$\tfrac{1}{2} d \log n$, for fixed $d$ with $n \to \infty$;
consequently, it is asymptotically equivalent to the BIC complexity
measure~\citep{barron1998minimum,foster2004contribution,hansen2001model}
to the first order $\mc O(\log n)$ term. In recent work,
\cite{grunwald2017tight} further developed a framework to unify
several complexities including Rademacher and NML, and derived excess
risk bounds in terms of this unifying complexity measure, for several
low-dimensional settings.
\paragraph{Challenges with NML complexity:}
In overparametrized settings (and even in several settings otherwise), the NML code suffers from the \emph{infinity} problem, namely the normalization constant in \cref{eq:nml_defn} is infinite, and the NML distribution is not defined. A canonical solution is to truncate the observation space so as to make the integral finite. But with simple models like linear regression, such schemes provide volume of the truncated space as the complexity measure. For example, consider the codes corresponding to Gaussian linear model, where
\begin{align}
\label{eq:linear_code}
p(\v{y}; \theta) \propto \exp(-\frac{1}{2\sigma^2}\norm{\mat{X}\theta-\v{y}}_2^2),
\end{align}
and we treat the design matrix $\mat{X} \in \ensuremath{\mathbb{R}}^{d\times n}$ and the scalar $\sigma^2$ known and fixed, and $\v{y}\in\mc Y \subset \ensuremath{\mathbb{R}}^{n}$ denotes the observation. When $d>n$, and $\mat{X}$ has full row rank ($n$), it is straightforward to see that, $\max_{\theta}p(\v{y}; \theta) = \text{constant}$, which in turn implies that the NML complexity in \cref{eq:shtarkov_complexity} is infinite; and the NML code~\eqref{eq:nml_defn} is not defined (also, see
\citet[Example 11.1]{grunwald2007minimum}). A canonical solution of this problem is truncation of the response space~\cite{barron1998minimum}, but in the setting above such a restriction leads to a trivial NML complexity measure that depends merely on the volume of the truncated space (and is independent of $\mat{X}, d$).
\subsection{Luckiness normalized maximum likelihood}
To deal with the infinity problem discussed above, another solution was proposed in recent works, namely, the luckiness normalized maximum likelihood (LNML) code (see Chapter
11~\citep{grunwald2007minimum}). Given a class of codes $\mc P_{\Theta}$, and a luckiness function $p_\textrm{luck}:\Theta \to \ensuremath{\mathbb{R}}_+$ (not necessarily a code), one way to define the LNML code is
as follows:
\begin{align}
\label{eq:lnml}
q_{\mrm{LNML}}(\v{y}) := \frac{\max_{\theta} \parenth{p(\v{y}; \theta) \cdot p_\textrm{luck}(\theta)}}{
\displaystyle\int_{\v{z}\in\ensuremath{\mathbb{R}}^n}\max_{\theta'}\parenth{p(\v{z}; \theta') \cdot p_\textrm{luck}(\theta')}\; d\v{z}}.
\end{align}
Once again, the normalization in \cref{eq:lnml} ensures that $\mathbb{Q}_{\mrm{LNML}}$ whenever well-defined is a universal code. One can now treat the log normalization constant of this code as a complexity measure, but such a definition would vary with the luckiness function chosen by the user. In the sequel, we provide a principled way to consider a family of such LNML codes and then derive a complexity measure using an optimality criterion over these codes. Theoretical investigations with LNML codes have not been extensively done in the prior work, and are central to the current work. It is worth noting that while NML can be seen as a generalization of the maximum likelihood principle, LNML can be seen as a generalization of regularized maximum likelihood principle.
\subsection{Optimal redundancy as a complexity measure}
One metric to measure the effectiveness of any code $\mathbb{Q}$ when the observations follow a generative model $\v{y}\sim\mathbb{P}_{\star}$, is the \emph{redundancy} or the expected excess code-length for $\mathbb{Q}$ compared to the true (but unknown) distribution $\mathbb{P}_{\star}$,
given by:
\begin{align*}
\frac{1}{n} \ensuremath{{\mathbb{E}}}_{\v{y} \sim \mathbb{P}_{\star}} \brackets{\log
\parenth{\frac{1}{\mathbb{Q}(\v{y})}} - \log
\parenth{\frac{1}{\mathbb{P}_{\star}(\v{y})}}} =
\ensuremath{{\mathbb{E}}}_{\v{y}\sim\mathbb{P}_{\star}}\brackets{ \frac{1}{n} \log \parenth{
\frac{\mathbb{P}_{\star}(\v{y})}{\mathbb{Q}(\v{y})}}} = \frac{1}{n}
\kull{\mathbb{P}_{\star}}{\mathbb{Q}},
\end{align*}
where we normalized by $n$, to obtain bits(/nats) per sample point,
since in our notation the code $\mathbb{Q}$ is defined jointly over the
$n$ observations. Here $\kull{\mathbb{P}_{\star}}{\mathbb{Q}}$ denotes the
Kullback-Leibler divergence between the two distributions and is
non-negative unless $\mathbb{Q} = \mathbb{P}_\star$. Or, in other words, the
unknown $\mathbb{P}_\star$ is also the best possible encoding of the
data. Thus, the complexity of the data with respect to a given set of
codes $\mc{Q}$ can be defined via the best possible excess codelength
also known as \emph{optimal redundancy}:
\begin{align}
\label{eq:ropt_defn}
\ensuremath{\mc R_{\textrm {opt}}}(\mathbb{P}_\star, \mc{Q}) := \min_
{\mathbb{Q}\in\mc{Q}}
\kull{\mathbb{P}_{\star}}{\mathbb{Q}}.
\end{align}
\paragraph{Remark:} For the complexity measure~\eqref{eq:ropt_defn} to be effective, the set of codes $\mc{Q}$ should be rich enough; otherwise, the calculated complexity can provide trivial or loose estimates (e.g., as discussed above, in overparameterized setting when $\mc Q$ contains only the NML code and $\mc Y$ is unbounded). As noted earlier, the advantage of the MDL framework comes from the fact that the set $\mc{Q}$ does not have to be the usual parametric class used for computing maximum likelihood (and as noted above, the NML and LNML codes are strict global generalizations of the maximum likelihood principle). Furthermore, even without a generative model, one can consider a minimax notion of redundancy as a complexity measure~\cite{barron1998minimum}.
In the sequel, however, we restrict our derivations to settings with a known generative model over the observed data and briefly discuss a minimax set-up in \cref{sub:a_minimax_optimality_via_mdltag}.
\section{Ridge-based minimum description length complexity}
\label{sec:complexity}
In this work, we define a new complexity measure, MDL-COMP, using the optimality principle~\eqref{eq:ropt_defn} and a family of LNML codes, that are induced by ridge estimators. In a nutshell, the luckiness function~\eqref{eq:lnml} is inspired by the penalty used in ridge regression. Our choice of ridge-based LNML codes is informed by multiple reasons: First, we are interested in an operational definition of complexity, and hence we consider encodings that are associated with a computationally feasible set of estimators. Second, for the complexity to be informative, we prefer the set of codes to be rich enough, and thus the estimators that we consider should achieve good predictive performance. Ridge estimators are known to achieve the minimax performance with linear and kernel methods~\citep{raskutti2011minimax,zhang2015divide,dicker2016ridge}, and often provide competitive predictive performance in applied
machine-learning tasks~\citep{bernau2014cross}.\footnote{We do not
default to simply using the ordinary least squares estimator based
code---which in the NML framework would reduce the problem to a single
NML code, and the Shtarkov complexity---for the following reasons: (i)
it has poor performance in the over-parameterized regime with linear
models, and for any setting of kernel regression (for
infinite-dimensional kernels), and (ii) as shown earlier, the Shtarkov
complexity would be infinite when $\mc{Y}$ is unbounded, in the overparameterized settings
considered in the sequel.}
We now define the details of these codes in
\cref{sub:ridge_lnml_codes} (besides providing a brief recap of ridge
regression), and then formally define the MDL-COMP in
\cref{sub:mdl_comp_defn}.
\subsection{Ridge-based LNML codes}
\label{sub:ridge_lnml_codes}
As in the MDL literature, we design codes over response vectors $\v{y}
\in \ensuremath{\mathbb{R}}^n$ conditional on a fixed matrix $\mat{X} \in \ensuremath{\mathbb{R}}^{n \times
d}$ of covariates. We briefly recap ridge regression estimators for
linear models and kernel methods in \cref{sub:ridge_background},
followed by the definitions of the corresponding LNML codes in
\cref{sub:lnml_code_defn} that underlie our definition of MDL-COMP in
\cref{sub:mdl_comp_defn}.
\subsubsection{Background on ridge regression}
\label{sub:ridge_background}
For linear models, the generalized $\ell_2$-regularized least square estimators, with the penalty~$\theta^\top\mat{\Lambda}\theta$ for a positive definite matrix $\mat{\Lambda}$, is given by
\begin{align}
\label{eq:ridge_new_closed}
\widehat{\tvar}_\mat{\Lambda}(\v{y}) := \argmin_{\theta\in \R^{\ensuremath{d}}}
\parenth{\frac{1}{2}\enorm{\v{y}-\mat{X}\theta}_2^2 + \frac12\theta^\top
\mat{\Lambda} \theta} = (\xridge[\lammat])^{-1} \mat{X}^\top\v{y}.
\end{align}
A common choice for the regularization matrix is $\mat{\Lambda} = \lambda
\mat{I}$. We also define some notation to be useful later on:
\begin{align}
\label{eq:xmatrix}
\xmat^\top\xmat = \mat{U} \mat{D} \mat{U}^\top \qtext{where} \mat{D} =
\diag(\evali[1], \ldots, \evali[d]),
\end{align}
where for $d>n$, we use the convention that $\evali =0 $ if $i>n$.
Here the matrix $\mat U \in \ensuremath{\mathbb{R}}^{\ensuremath{d} \times \ensuremath{d}}$ denotes the
(complete set of) eigenvectors of the matrix $\xmat^\top\xmat$.
Next, we briefly describe kernel ridge regression. Consider a
reproducing kernel $\mc{K}$ and the corresponding reproducing kernel
Hilbert space (RKHS), i.e., for all $x\in \ensuremath{\mathbb{R}}^d$, $\mc{K}(x, \cdot)
\in \mb{H}$ and for any $f \in \mb{H}$, we have $\doth{f, \mc{K}(x,
\cdot)} = f(x)$. In kernel ridge regression, given the data
$\braces{(x_i, y_i)}_{i=1}^n$, we need find an estimate $\widehat{f}
\in \mb{H}$ such that $\widehat{f}(x_i) \approx y_i$. The corresponding
estimate is given by
\begin{align}
\label{eq:kernel_ridge}
\widehat{f} := \argmin_{f\in \mb{H}}
\parenth{\frac{1}{2}\enorm{\v{y} -\v{f}_1^n}_2^2 + \frac{\lambda}{2}
\enorm{f}_{\mb{H}}^2 } \qtext{where} \v{f}_1^n := (f(x_1),
\ldots, f(x_n)) ^\top,
\end{align}
and $\lambda > 0$ denotes a regularization parameter. Representer theorem
for reproducing kernels implies that to solve~\eqref{eq:kernel_ridge}
it suffices to consider functions of the form $f(\cdot) =
\sum_{i=1}^n\beta_i \mc{K}(x_i, \cdot)$ for $\beta \in
\ensuremath{\mathbb{R}}^n$. Substituting this functional form back in
\cref{eq:kernel_ridge} yields a regularized least-squares problem from
$\theta$ which admits a closed-form:
\begin{align}
\label{eq:kernel_ridge2}
\widehat{\beta}_{\lambda}(\v{y}) := \argmin_{\beta\in \ensuremath{\mathbb{R}}^n}
\parenth{\frac{1}{2}\enorm{\v{y}-\mat{K}\beta}_2^2 +
\frac{\lambda}{2}\beta^\top\mat{K}\beta} = (\mat{K} + \lambda \mat{I})^{-1} \v{y}.
\end{align}
where $\mat{K}$ is the $n\times n$ kernel matrix with
$\mat{K}_{ij}=\mc{K}(x_i, x_j)$. With this fit, one can recover the
estimates for in sample observations as $\widehat{\v{y}} =
\mat{K}\widehat{\beta}_{\lambda}$, and for any new point $x$, the estimate is
given by $\widehat{f}(x) = \sum_{i=1}^n[\widehat{\beta}_{\lambda}]_i
\mc{K}(x_i, x)$.
\subsubsection{Defining ridge-based LNML codes}
\label{sub:lnml_code_defn}
We start with the linear model setting and then discuss the kernel
setting. In accordance with MDL convention, we assume that the design
matrix $\mat{X} \in \ensuremath{\mathbb{R}}^{\samples \times d}$ is known, and only the
information in the response vector $\v{y} \in \ensuremath{\mathbb{R}}^\samples$ is to be
encoded.
\paragraph{LNML codes for linear methods:}
We use the notation:
\begin{align}
\label{eq:pdist}
g(\v{y}; \mat{X}, \mat{\Lambda}, \theta) = \frac{1}{(2 \pi \sigma^2)^{n/2}}
e^{-\frac{1}{2\sigma^2} \enorm{\v{y}-\mat{X}\theta}^2} \cdot e^{
-\frac{1}{2\sigma^2} \theta^\top\mat{\Lambda}\theta} , \qtext{for} \v{y} \in
\ensuremath{\mathbb{R}}^n, \theta \in \R^{\ensuremath{d}}.
\end{align}
Letting the first term in \cref{eq:pdist} denote the code $p_{\mrm{data}}$ for
data fit, and the second term $(e^{-\frac{1}{2\sigma^2}
\theta^\top\mat{\Lambda}\theta})$ as the luckiness factor $p_\textrm{luck}$, and
comparing with \cref{eq:lnml}, we define the corresponding LNML code
as follows:
\begin{align}
\label{eq:ridge_dist}
q_{\mrm{LNML}}(\v{y}) = q_{\mat{\Lambda}}(\v{y}) = \frac{g(\v{y}; \mat{X},
\mat{\Lambda}, \widehat{\tvar}_{\mat{\Lambda}}(\v{y}))}{\mrm{C}_{\mat{\Lambda}}} \qtext{where} \mrm{C}_{\mat{\Lambda}}
:= \displaystyle\int_{\ensuremath{\mathbb{R}}^n} g(\v{z}; \mat{X}, \mat{\Lambda},
\widehat{\tvar}_{\mat{\Lambda}}(\v{z}))d\v{z}.
\end{align}
It is a valid density for an LNML code, denoted by $\mathbb{Q}_{\mat{\Lambda}}$,
since
\begin{align}
\label{eq:lnml_ridge}
\argmax_{\theta} \parenth{p_{\mrm{data}}(\v{y}; \mat{X}, \theta) \cdot
p_\textrm{luck}(\theta)} \stackrel{\eqref{eq:ridge_new_closed}}{=}
\widehat{\tvar}_{\mat{\Lambda}}(\v{y}).
\end{align}
In other words, $\mathbb{Q}_{\mat{\Lambda}}$ is the LNML code induced by the
ridge estimator $\widehat{\tvar}_{\mat{\Lambda}}$.\footnote{In a similar fashion, one can see that the OLS estimator would correspond to the NML code~\eqref{eq:nml_defn} for the codes given by~\eqref{eq:linear_code}.}
Our definition of complexity, as alluded to earlier, makes use of a family of LNML
codes. For the linear setting, we consider the family:
\begin{align}
\label{eq:lnml_family_lin}
\mc{Q}_{\mrm{Ridge}}^{\taglin} := \!\braces{\mathbb{Q}_{\mat{\Lambda}}\!:\!\mat{\Lambda}\! \in\!
\mc{M}}, \text{ where } \mc{M}\!:=\!\braces{\mat U \diag (\lambda_1,
\ldots, \lambda_d)\mat U^\top \vert \lambda_j \geq 0, j\!=\!1,\ldots d},
\end{align}
where $\mat U$ denotes the eigenvectors of the matrix
$\xmat^\top\xmat$~\eqref{eq:xmatrix}. We once again note that the family
$\mc{Q}_{\mrm{Ridge}}^{\taglin}$ is not parametric in the classical sense (as it is not
indexed by the canonical parameter $\theta$). However, since the LNML
codes are induced by the ridge estimators, selecting a particular
$\mathbb{Q}_{\mat{\Lambda}}$ code corresponds to choosing a particular $\mat{\Lambda}$
based-ridge estimator for all $\v{y}$. Moreover, this family can be seen as a family of LNML
codes induced due to different choices of the luckiness functions in \cref{eq:lnml}.
We also explain below the reasons
behind the particular choice of $\mc M$.
A key difference from the NML setting is that the LNML codes are
indexed by hyper-parameter $\mat{\Lambda}$, and thus it remains to add the
codelength corresponding to the index. To this end, we use a simple
quantization-based encoding for the hyper-parameters
$\braces{\lambda_j}$, in the spirit of the two-stage encoding for the
hyper-parameters as in prior
works~\citep{barron1998minimum,hansen2001model,grunwald2007minimum}:
\begin{align}
\mc L(\mat{\Lambda}) &=\frac12\sum_{\lambda_i>0} \log\lambda_i,
\label{eq:lamopt_claim}
\end{align}
where the factor $\frac12$ is chosen for theoretical convenience
(achievable by apriori deciding to encode $\sqrt{\lambda_i}$). In
principle, one should use the codelength $\log (\max{\lambda_i/\Delta,
1})$ for some small enough resolution $\Delta$; and
$\Delta=\frac{1}{\sqrt{n}}$ is often the default choice. Adding such a
constant term would lead to an additive term of $\frac{d}{2n}\log n$
in \ensuremath{\textrm{MDL-COMP}}\ for $d<n$, and $\log n$ for $d>n$. As conventional in the
MDL literature, we omit these additional bits due to the $\Delta$ term
in our discussion to follow.
Our definition~\eqref{eq:lnml_family_lin} makes use of the
eigenvectors of the matrix $\xmat^\top\xmat$ to define the set $\mc M$ of all
possible $\mat{\Lambda}$ for considering the LNML codes (in other words, we
assume $\mat{\Lambda}$ and $\xmat^\top\xmat$ are simultaneously orthogonally
diagonalizable). Such a definition tries to address two concerns:
First, having a rich set of codes is essential to provide us a better
understanding of how much compression in the data is possible, so
having richer set than $\braces{\lambda \mat I; \lambda \geq 0}$ is
desirable. On the other hand, choosing $\mc M$ to be the set of all
PSD matrices would defeat the purpose of measuring the complexity of
data, since the bits needed to encode an arbitrary PSD matrix in
linear model setting would be $\order{\min\braces{d^2, n^2}}$, which
would simply overwhelm the bits needed to encode the data itself. In
the prior theoretical works with MDL, often very simplistic
assumptions, like $\mat{\Lambda} = c\xmat^\top\xmat$ have been
made~\citep{hansen2001model}, and the bits needed to transmit the
scalar $c$ have been treated as fixed. For our choice of $\mc M$, we
note that $\mat U$ can be computed from $\xmat^\top\xmat$, and hence we only need
to count the bits needed to encode the hyper-parameters
$\braces{\lambda_j}$, for which we use \cref{eq:lamopt_claim}.
\paragraph{LNML codes for kernel methods:}
Given the estimators~\eqref{eq:kernel_ridge} and
\eqref{eq:kernel_ridge2}, one can define the LNML codes given a set of
points, the kernel and the corresponding kernel matrix as follows. We
define the function $h(\cdot; \beta, \mat{K})$
\begin{align}
\label{eq:k_pdist}
h(\v{y}; \beta, \mat{K}) := \frac{1}{(2 \pi \sigma^2)^{n/2}}
e^{-\frac{1}{2 \sigma^2} \enorm{\v{y} - \mat{K} \beta}^2} \cdot
e^{-\frac{\lambda}{2 \sigma^2} \beta ^\top \mat{K} \beta},
\end{align}
Letting the first term in \cref{eq:k_pdist} denote the code $p_{\mrm{data}}$
for data fit, and the second term $(e^{-\frac{\lambda}{2\sigma^2}
\beta^\top \mat{K}\beta})$ as the luckiness factor $p_\textrm{luck}$, and arguing
similar to \cref{eq:ridge_dist,eq:lnml_ridge}, we conclude that the
LNML code is given by
\begin{align}
\label{eq:k_ridge_dist}
\widetilde{q}_{\lambda}(\v{y}) = \frac{h(\v{y}; \widehat{\beta}_{\lambda}(\v{y}),
\mat{K})}{\mrm{C}_{\lambda, \kernel}} \qtext{where} \mrm{C}_{\lambda, \kernel} :=
\displaystyle\int_{\ensuremath{\mathbb{R}}^n} h(\v{z}; \widehat{\beta}_{\lambda}(\v{z}),
\mat{K})d\v{z},
\end{align}
and let $\widetilde{\mathbb{Q}}_{\lambda}$ denote the distribution
corresponding to $ \widetilde{q}_{\lambda}$. Finally, our definition
of complexity for kernel methods makes use of the following family of
LNML codes:
\begin{align}
\label{eq:lnml_family_ker}
\mc{Q}_{\mrm{Ridge}}^{\tagker} = \braces{\widetilde{\mathbb{Q}}_{\lambda} : \lambda \geq 0}.
\end{align}
In contrast to the linear setting, here we consider the family of
codes indexed by a single parameter, as using multiple $\lambda$'s
would break the equivalence between
\cref{eq:kernel_ridge,eq:kernel_ridge2}, unless we alter the Hilbert
norm that is being penalized in \cref{eq:kernel_ridge}.
\subsection{Defining MDL-COMP via ridge-LNML codes}
\label{sub:mdl_comp_defn}
We are now ready to define the MDL-based complexity. We define the
complexity as optimal redundancy over the LNML codes with certain
generative assumptions for the data.
\paragraph{MDL-COMP for linear models:}
We consider the generative model
\begin{align}
\label{eq:linear_model_revisit}
\yi = \axi ^\top \tvar_\star + \noise, \qtext{for} i = 1, 2, \ldots, n,
\qtext{or} \v{y} = \mat{X} \tvar_\star + \v{\noise[]},
\end{align}
where we assume that $\noise[]\sim \mc N(0, \sigma^2 \mat I_n)$, so
that $\mathbb{P}_\star = \pdist_{\tvar_\star}= \mc{N}(\mat{X} \tvar_\star, \sigma^2 \mat I_n)
$.\footnote{Although we later discuss a minimax setting while relaxing
this assumption on the noise, see \cref{thm:minimax_codelength}.}
Given this notation, the $\ensuremath{\textrm{MDL-COMP}}$ for this setting is defined as the
sum of the optimal redundancy over the codes
$\mc{Q}_{\mrm{Ridge}}^{\taglin}$~\eqref{eq:lnml_family_lin}, and the codelength needed to
encode the optimal hyperparameters:
\begin{subequations}
\begin{align}
\label{eq:mdl_linear}
\ensuremath{\textrm{MDL-COMP}}(\pdist_{\tvar_\star}, \mc{Q}_{\mrm{Ridge}}^{\taglin}) & := \frac{1}{n} (\ensuremath{\mc R_{\textrm {opt}}}(\pdist_{\tvar_\star}, \mc{Q}_{\mrm{Ridge}}^{\taglin})
+ \mc L(\mat{\Lambda}_{\textrm{opt}})), \qtext{where} \\
%
\label{eq:ropt_linear}
\ensuremath{\mc R_{\textrm {opt}}}(\pdist_{\tvar_\star},\!\mc{Q}_{\mrm{Ridge}}^{\taglin}) & := \min_{\mathbb{Q} \in \mc{Q}_{\mrm{Ridge}}^{\taglin}}
\kull{\pdist_{\tvar_\star}}{\mathbb{Q}} =\min_{\mat{\Lambda} \in
\mc{M}}\kull{\pdist_{\tvar_\star}}{\mathbb{Q}_{\mat{\Lambda}}},
\end{align}
\end{subequations}
and $\mat{\Lambda}_{\textrm{opt}}$ denotes the $\arg\min$ in \cref{eq:ropt_linear}.
\paragraph{Remark:} We note that for the definitions above, in principle, $\pdist_{\tvar_\star}$ can be replaced by an arbitrary (and not necessarily even linear) generative model, and MDL-COMP would still be a valid complexity measure---as it measures the best possible excess number of bits over the class $\mc{Q}_{\mrm{Ridge}}^{\taglin}$ for encoding data generated by $\pdist_{\tvar_\star}$.
However, for establishing analytical results in the following section, we restrict ourselves to a linear generative model $\pdist_{\tvar_\star}$ while analyzing MDL-COMP with linear fitted models.
\paragraph{MDL-COMP for kernel methods:}
We assume throughout this paper that the reproducing kernel $\mc{K}$
is a Mercer kernel~\citep{mercer1909functions}, which admits the
eigen-expansion:
\begin{align}
\label{eq:mercer_kernel}
\mc{K}(x, y) = \sum_{k=1}^{\infty} \mu_k \phi_k(x) \phi_k(y),
\qtext{for all} x, y \in \ensuremath{\mathbb{R}}^d,
\end{align}
where $\mu_1 \geq \mu_2 \cdots \geq 0$ denotes the sequence of
(non-negative) eigenvalues of the kernel and
$\braces{\phi_k}_{k=1}^\infty$ denotes the associated eigenfunction
taken to be orthonormal in $\mathbb{L}^2(\nu)$ for a suitably chosen
distribution $\nu$.\footnote{In the model below, we assume $\nu$ is the
marginal distribution of the covariates.} Let $\mb{H}$ denote the
reproducing kernel Hilbert space of the kernel $\mc{K}$. We consider
the generative model
\begin{align}
\label{eq:kernel_Generative_model}
y_i = f^\star(x_i) + \noise, \qtext{for} i = 1, 2, \ldots, n,
\qtext{or} \v{y} = \v{(f^\star)}_1^n+ \v{\noise[]}.
\end{align}
where we assume that $x_i$'s are drawn i.i.d. from the distribution
$\nu$, and $f^\star \in \mb{H}$, and use the notation $\v{(f^\star)}_1^n
= (f^\star(x_1), \ldots, f^\star(x_n))^\top$. We also assume that
$\noise[]\sim \mc N(0, \sigma^2 \mat I_n)$, so that $\mathbb{P}_\star =
\mb{P}_{f^\star} = \mc{N}((\v{f^\star})_1^n, \sigma^2 \mat
I_n)$.\footnote{We can relax this assumption (without altering the
guarantees derived later) to the noise being zero mean, with variance
$\sigma^2$ and being uncorrelated with $\v{(f^\star)}_1^n$.} With
this notation, we define MDL-COMP for the kernel setting as the
optimal redundancy over the codes $\mc{Q}_{\mrm{Ridge}}^{\tagker}$ in the
family~\eqref{eq:lnml_family_ker}:
\begin{align}
\label{eq:mdl_kernel_defn}
\ensuremath{\textrm{MDL-COMP}}(\mb{P}_{f^\star},\!\mc{Q}_{\mrm{Ridge}}^{\tagker}) :=
\frac{1}{n}\min_{\widetilde{\mathbb{Q}}\in\mc{Q}_{\mrm{Ridge}}^{\tagker}}\kull{\pdist_{\tvar_\star}}{\widetilde{\mathbb{Q}}}
:= \frac{1}{n} \min_{\lambda \geq 0}
\kull{\mb{P}_{f^\star}}{\widetilde{\mathbb{Q}}_{\lambda}}.
\end{align}
where $\mat{K}=(\mc{K}(x_i, x_j))_{j=1}^{n}$ denotes the kernel matrix at the observed covariates. Like in the linear setting, one can replace $\mb{P}_{f^\star}$ by an arbitrary generative model and MDP-COMP would continue to be a valid measure of complexity. But for the analytical derivations in the sequel we restrict our attention to generative models of the form~\eqref{eq:kernel_Generative_model} when dealing with kernel methods.
\paragraph{Remark:} Note that, in place of \cref{eq:mdl_linear}, one can alternatively also consider a joint minimization over the redundancy plus the codelength for $\mat{\Lambda}$, i.e., $\min_{\mat{\Lambda}}[\kull{\pdist_{\tvar_\star}}{\mathbb{Q}_{\mat{\Lambda}}} + \mc L(\mat{\Lambda})]$, to define \ensuremath{\textrm{MDL-COMP}}. Such a choice would be analogous to defining the index of resolvability by \citet{barron1991minimum} in density estimation; where they optimize jointly over the codelength needed to encode the distribution fitted besides the code length corresponding to the data. For such a joint optimization, we need to define a suitable choice of a prefix code on the space of hyper-parameters. In contrast, our treatment of the codelength for $\mat{\Lambda}$ here, namely adding the codelength using simple quantizations scheme after optimizing redundancy, is in line with that for hyperparameters done in the two-stage MDL~\citep{barron1998minimum,hansen2001model,grunwald2007minimum}. Next, we note that compared to \cref{eq:mdl_linear}, we do not add another $\lambda$ dependent codelength in \cref{eq:mdl_kernel_defn}, as there is only one regularization parameter in kernel regression. One may alternatively consider adding a term $\log(\lambda_\textrm{opt})/n$ on the RHS of \cref{eq:mdl_kernel_defn} (without losing the qualitative conclusions in Theorem~\ref{thm:mdl_kernel} or quantitative conclusions in Corollary~\ref{cor:mdl_kernel_smooth} in the sequel).
\section{Main results}
\label{sec:main_results}
We are now ready to state our main results. We start with an explicit characterization of MDL-COMP for linear models, and its consequences in \cref{sub:mdl_complexity_for_linear_models}. We then characterize it for kernel methods and unpack the consequences in \cref{sub:mdl_complexity_kernel_methods}.
\subsection{Characterizing MDL-COMP for linear models}
\label{sub:mdl_complexity_for_linear_models}
Our first result provides an explicit expression for
MDL-COMP~\eqref{eq:mdl_linear} for the linear models.
\begin{theorem}
\label{thm:complexity_expressions}
For the linear model~\eqref{eq:linear_model_revisit}, let $\mat U$ and
$\braces{\evali}$ denote the eigenvectors and eigenvalues of $\xmat^\top\xmat$,
and define the vector $\v{\myvec} := \mat U^\top \tvar_\star$. Then the
MDL complexity~\eqref{eq:mdl_linear} and optimal
redundancy~\eqref{eq:ropt_linear} are given by
\begin{subequations}
\begin{align}
\label{eq:mdl_linear_explicit}
\ensuremath{\textrm{MDL-COMP}}(\pdist_{\tvar_\star}, \mc{Q}_{\mrm{Ridge}}^{\taglin}) & = \frac{1}{2n}\sumn[\min\braces{n, d}]
\log\parenth{\evali + \frac{\sigma^2}{\myvec_i^2}}, \quad
\mbox{and} \\
\label{eq:ropt_lin_model}
\ensuremath{\mc R_{\textrm {opt}}}(\pdist_{\tvar_\star},\!\mc{Q}_{\mrm{Ridge}}^{\taglin}) & = \frac{1}{2n}\sumn[\min\braces{n, d}] \log
\parenth{ 1 + \frac{\evali\myvec_i^2}{\sigma^2}}.
\end{align}
\end{subequations}
\end{theorem}
\noindent See \cref{sub:proof_of_thm:complexity_expressions} for the
proof.
We recall that the NML complexity for over-parameterized settings is typically infinite, or just a function of the volume of the space when one truncates the space of observation for theoretical analysis (\cref{sub:nml}). Even in the latter case, for overparameterized setting, the complexity does not depend on the design matrix. Our notion of MDL-COMP on the other hand, as seen by \cref{thm:complexity_expressions}, is not merely a parameter count or a
simple function of $d$ and $n$. Rather, it depends on the interaction
between the eigenvalues of the covariance matrix $\xmat^\top\xmat$, and the
rotated true parameter scaled by noise variance $\v{\myvec}/\sigma=
\mat U^\top \tvar_\star/\sigma$. The
expression~\eqref{eq:mdl_linear_explicit} is oracle in nature since it
depends on an unknown quantity, namely the true parameter $\tvar_\star$ via
the relation $\v{\myvec} = \mat U ^\top \tvar_\star$.\footnote{\label{footnote:defining_w}When model is under-specified in terms of the features, i.e., $\mat{X}$ includes a subset of features needed to correctly specify the model~\eqref{eq:linear_model_revisit}, $\v{\myvec}$ is defined by considering the restricted version of $\tvar_\star$; and when it is over-specified, i.e., $\mat{X}$ denotes a superset of features, $\v{\myvec}$ is defined by appending zeros to $\tvar_\star$ as necessary. Refer to footnote~\ref{proof:thm1_under_over_specified}, and \cref{sub:mdl_plots_details} for further discussion.}
In \cref{sec:experiments}, we propose a
data-driven and \ensuremath{\textrm{MDL-COMP}}\ inspired hyper-parameter selection criterion
called \textrm{Prac-MDL-COMP}\ to tune the ridge hyper-parameter. Later in
\cref{sec:experiments}, we provide a data-driven approximation to
$\ensuremath{\textrm{MDL-COMP}}$ so that our proposed complexity can also be computed as a
practical complexity measure without requiring knowledge of $\tvar_\star$.
Next, we discuss some consequences for linear models: We illustrate the scaling of \ensuremath{\textrm{MDL-COMP}}\ in various settings in
\cref{ssub:scaling_of_mdlcomp}, and then prove in
\cref{sub:mdl_complexity_versus_the_mmse} that \ensuremath{\textrm{MDL-COMP}}\ informs the fixed
design generalization error (see \cref{thm:lam_opt}). Furthermore, in
\cref{sub:a_minimax_optimality_via_mdltag}, we establish a certain minimax optimality property of the code that defines \ensuremath{\textrm{MDL-COMP}}\ (see
\cref{thm:minimax_codelength}). We turn to MDL-COMP for kernel methods in \cref{sub:mdl_complexity_kernel_methods}.
\subsubsection{Scaling of \ensuremath{\textrm{MDL-COMP}}\ for various covariate designs}
\label{ssub:scaling_of_mdlcomp}
We now numerically compute \ensuremath{\textrm{MDL-COMP}}\ in several synthetic settings. Below we plot results for three different settings on the covariate design $\mat{X}$, and two different settings for the true parameter. In all cases, the rows of $\mat{X}$ are drawn from $\mc{N}(0, \Sigma)$. In \cref{fig:mdl_gaussian}, we consider two cases $\Sigma = \mat I_d$ (labeled as $\alpha=0$), and $\Sigma = \diag(1, 2^{-\alpha}, \ldots, d^{-\alpha})$ for $\alpha=0.5$.
In \cref{fig:mdl_spike_design}, we choose a \emph{spike design}, where $\Sigma = \diag(16, 16, \ldots, 16, 1, \ldots, 1)$ with the first $s$ (spike dimension) diagonal entries taking value 16, and the rest taking value $1$. In both figures, we evaluate two different settings of $d_\star$ for the true dimensionality of $\tvar_\star$, and select the true parameter $\tvar_\star$ by drawing i.i.d. entries from standard normal, and then normalizing it to have norm $1$. Note that as we move from left to right on the x-axis in these figures, only the covariates used for fitting the model vary, and the generated data remains fixed (so that the model is under-specified for $d<d_\star$, and correctly (over) specified for $d \geq d_\star$). See \cref{sub:mdl_plots_details} for more details on the simulation set-up.
In both the figures, we note the non-linear scaling of MDL-COMP in the overparameterized regime ($d>n$). As we vary the dimension $d$ of the covariates used for computing \ensuremath{\textrm{MDL-COMP}}, in \cref{fig:mdl_gaussian}, we observe a linear scaling of \ensuremath{\textrm{MDL-COMP}}\ with $d$ for $d<n$, but a slow logarithmic or $\log d$ growth for $d>n$. On the other hand, the growth is clearly not linear even for $d<n$ for some of the spike design settings in \cref{fig:mdl_spike_design}. We provide further discussion on the set-up and scaling of MDL-COMP from these figures in \cref{sub:mdl_plots_details,sub:sketch_gaussian,sub:ropt_large_scale} (also see \cref{thm:rmt_expressions}).
\begin{figure}[ht]
\centering
\includegraphics[width=0.9\textwidth]{../figs/gauss_results_n_200}
\caption{Scaling of MDL-COMP for Gaussian design. \textbf{(A)} $\sigma^2=1$, and \textbf{(B)} $\sigma^2=0.01$. We fix the generated data with $n=200$ samples, and vary the dimensionality $d$ of the covariates used for fitting the data. Here $\alpha$ denotes the decay of the eigenvalues in the covariance matrix for the covariates, and $d_\star$ denotes the true dimensionality of $\tvar_\star$.
}
\label{fig:mdl_gaussian}
\end{figure}
\begin{figure}[ht]
\centering
\includegraphics[width=0.9\textwidth]{../figs/sparse_design_snr_4_n_200_noise_std_0}
\caption{Scaling of MDL-COMP for spike design. We fix the generated data with $n=200$ samples, and $\sigma^2=0.01$, and vary the dimensionality $d$ of the covariates used for fitting the data. Here $s$ denotes the spike dimension of the covariance matrix, and $d_\star$ denotes the true dimensionality of $\tvar_\star$.
}
\label{fig:mdl_spike_design}
\end{figure}
\subsubsection{\ensuremath{\textrm{MDL-COMP}}\ informs fixed design mean-squared error}
\label{sub:mdl_complexity_versus_the_mmse}
Next, we show that $\ensuremath{\textrm{MDL-COMP}}$ (without the codelength for $\mat{\Lambda}$)
directly bounds the optimal fixed design prediction error (MSE). For
the training data points $\braces{(x_i, y_i)}_{i=1}^n$ generated from
a true model~\eqref{eq:linear_model_revisit} with true parameter $\tvar_\star$, the
fixed design prediction MSE of an estimator $\widehat{\tvar}$ is given by
\begin{align}
\label{eq:in_sample_mse}
\textrm{fixed design pred. MSE} :=
\frac{1}{n}\sum_{i=1}^{n}(x_i^\top\widehat{\tvar}-x_i^\top\tvar_\star)^2 =
\frac{1}{n}\enorm{\mat{X} \widehat{\theta} -\mat{X} \tvar_\star}^2.
\end{align}
Note that this fixed design prediction error is very different from
the training MSE \mbox{$(\frac{1}{n}\enorm{\mat{X} \widehat{\theta}
-\v{y}}^2)$.} The in-sample MSE can be considered as a valid proxy
for the out-of-sample MSE (which in turn is usually estimated by test
MSE~\eqref{eq:test_mse}, when the out-of-sample points have the same
covariates as that of the training data; and it has been often used in
prior works to study the bias-variance trade-off for different
estimators~\citep{raskutti2014early}. Our next result shows that the
optimal redundancy $\ensuremath{\mc R_{\textrm {opt}}}$ bounds the optimal in-sample MSE, and that
$\mat{\Lambda}_{\textrm{opt}}$ that achieves $\ensuremath{\mc R_{\textrm {opt}}}$ and defined \ensuremath{\textrm{MDL-COMP}}\ also minimizes
the in-sample MSE. The reader should recall the
definition~\eqref{eq:ropt_linear} of $\ensuremath{\mc R_{\textrm {opt}}}$ and $\mat{\Lambda}_{\textrm{opt}}$.
\begin{theorem}
\label{thm:lam_opt}
For the ridge estimators~\eqref{eq:ridge_new_closed}, we have
\begin{subequations}
\begin{align}
\ensuremath{{\mathbb{E}}}_{\noise[]}
\brackets{\frac{1}{n}\enorm{\mat{X}\widehat{\tvar}_{\mat{\Lambda}_{\textrm{opt}}}-\mat{X}\tvar_\star}^2}
\label{eq:opt_lam_insample_mse}
& = \min_{\mat{\Lambda} \in \mc{M}}\ensuremath{{\mathbb{E}}}_{\noise[]}
\brackets{\frac{1}{n}\enorm{\mat{X}\widehat{\tvar}_{\mat{\Lambda}}-\mat{X}\tvar_\star}^2}
\\
& \leq \frac{\sigma^2}{n}\ensuremath{\mc R_{\textrm {opt}}}(\pdist_{\tvar_\star},\!\mc{Q}_\mrm{Ridge}).
\label{eq:ropt_bounds_insample_mse}
\end{align}
\end{subequations}
\end{theorem}
\noindent See \cref{sub:proof_of_thm:lam_opt} for the proof
of this claim. \\
Later, we show that in experiments, tuning the ridge model via a
practical (data driven) variant of $\ensuremath{\textrm{MDL-COMP}}$ can often minimize
out-of-sample MSE, and provide predictive performance that is
competitive with CV-tuned ridge estimator.
\subsection{Characterizing MDL-COMP for kernel methods}
\label{sub:mdl_complexity_kernel_methods}
We now turn to the non-linear settings, namely kernel methods. Our next result provides a bound on \ensuremath{\textrm{MDL-COMP}}\ for kernel methods.
\begin{theorem}
\label{thm:mdl_kernel}
For the kernel setting~\eqref{eq:kernel_Generative_model}, the MDL complexity~\eqref{eq:mdl_kernel_defn} is bounded as
\begin{align}
\label{eq:mdl_kernel}
\ensuremath{\textrm{MDL-COMP}}(\mb{P}_{f^\star},\!\mc{Q}_{\mrm{Ridge}}^{\tagker}) \leq \inf_{\lambda}\parenth{
\frac{\lambda}
{2n} \frac{\enorm{f^\star}^2_{\mb{H}}}{\sigma^2} + \frac{1}{2n}\sumn \log\parenth{\frac{\evali}{\lambda}+1}}
\end{align}
where $\braces{\evali}_{i=1}^n$ denote the eigenvalues of the kernel
matrix $\mat{K}=(\mc{K}(x_i, x_j))_{i, j=1}^n$.
\end{theorem}
See \cref{sub:proof_of_theorem_thm:mdl_kernel} for the proof. Note that unlike \cref{thm:complexity_expressions}, here we establish an upper bound on MDL-COMP since closed-form expression does not exist. However, as we remark in the proof, we expect this bound to be tight for carefully constructed $f^\star$ for a wide range of behavior on $\braces{\evali}$.
The bound~\eqref{eq:mdl_kernel} in \cref{thm:mdl_kernel} is generic, and can be applied to any kernel setting including the neural tangent kernels that have recently been investigated in the theoretical literature on deep neural networks. Like \cref{eq:mdl_linear_explicit}, this expression also depends on the various problem parameters, including the signal-to-noise ratio $\frac{\enorm{f^\star}_{\mb{H}}}{\sigma} $, and the eigenvalues of the kernel matrix. When additional information on the decay of the eigenvalues $\braces{\evali}$ is available, we can characterize a more refined bound on \ensuremath{\textrm{MDL-COMP}}\ as in the next corollary.
\begin{corollary}
\label{cor:mdl_kernel_smooth}
Suppose $\mc{K}(x, x)=1$, $\evali$ denote the eigenvalues of the kernel matrix $\mat{K}$, and $\textrm{SNR}:=\frac{\enorm{f^\star}_{\mb{H}}}{\sigma}>C$ for some universal constant $C$. Then, we have
\begin{align}
\label{eq:mdl_kernel_smooth}
\ensuremath{\textrm{MDL-COMP}}(\mb{P}_{f^\star},\!\mc{Q}_{\mrm{Ridge}}^{\tagker})
\leq
\begin{cases}
\displaystyle \frac{d\log^2 (nd\textrm{SNR}^2)}{n}
&\text{ if }\evali \precsim n\exp(-i^{1/d}), \\
\displaystyle C_{d, \omega, \textrm{SNR}} \cdot \parenth{\frac{\log (n\textrm{SNR}^2)}{n}}^{\frac{2\omega}{2\omega+d}}
&\text{ if }\evali \precsim n i^{-2\omega/d}, \omega\!>\!d/2, \\[4mm]
\displaystyle C_{d, a, \textrm{SNR}} \cdot \parenth{\frac{\log (n\textrm{SNR}^2)}{n}}^{\frac{d+a}{d+a+1}}
&\text{ if }\evali \precsim ni^{-d-a}, d\!+\!a\!>\!1,
\end{cases}
\end{align}
where the constants $ C_{d, \omega, \textrm{SNR}}, C_{d, a, \textrm{SNR}}$ are independent of $n$, and are defined in \cref{eq:constant_ker_smooth}.
\end{corollary}
See \cref{sub:proof_of_cref_cor_mdl_kernel_smooth} for the proof, where we also provide expressions for the constants appearing on the RHS above. We note that the $n$ appearing in the scaling of the eigenvalues is not an arbitrary assumption, but an immediate consequence of the fact that the trace of the kernel matrix is equal to $n$ since $\mc{K}(x, x) = 1$.
\subsubsection{\ensuremath{\textrm{MDL-COMP}}\ informs minimax in-sample MSE}
The eigenvalue decay rate of order $\exp(-i^{1/d})$ and,
$i^{-2\omega/d}$ are known to be exhibited by Gaussian kernels and
reproducing kernels (like Mat\'ern kernels) for Sobolev spaces of smoothness $\omega$ in
$\ensuremath{\mathbb{R}}^d$ respectively (see
\citet[Thm.~15,16]{santin2016approximation}). Up to logarithmic
factors, the scaling of \ensuremath{\textrm{MDL-COMP}}\ in \cref{eq:mdl_kernel_smooth} with
the sample size $n$ for these settings matches with the
minimax-optimal scaling of the in-sample risk
$\frac{1}{n}\sumn(f^\star(x_i)-\widehat{f}(x_i))^2$~\citep{stone1982optimal,raskutti2014early,wainwright2019high}.
Consequently, in such cases, the scaling of \ensuremath{\textrm{MDL-COMP}}\ is directly
informative of the minimax fixed design prediction error. This
matching of rates between \ensuremath{\textrm{MDL-COMP}}\ and the minimax error provides an
indirect justification for our choice of LNML
codes~\eqref{eq:lnml_family_ker} based on ridge estimators.
\subsubsection{MDL-COMP for neural tangent kernels}
The eigenvalue decay rate of order $i^{-d-a}$ has been recently
established with $a=2$ for deep random feature model, and $a=0$ for
deep neural tangent kernel (NTK) with ReLU activation functions, and
$a=\frac{1}{2^{L}}$ for an $L$-layer deep NTK with step activation
function (see~\citet[Cor.~2,3]{bietti2021deep}) when the covariates
are drawn uniformly from the $d$-dimensional unit sphere. For deep
NTK, the bound~\eqref{eq:mdl_kernel_smooth} and a close tracking of
the constants from the proof (\cref{eq:constant_ker_smooth}) shows
that the MDL-COMP for NTK scales as follows:
$$\textrm{SNR}^{2/(1+d)} \cdot \left(\frac{d\log n}{n}\right)^{d/(d+1)}$$
This depends on the number of layers only through
the change in $\textrm{SNR}$. Consequently, for this setting, our conclusion
parallels that of \cite{bietti2021deep}---namely, adding layers does
not add to the complexity of the NTK.
However, we also note that for a fixed but large sample size $n$, this complexity can decrease as the dimensionality $d$ of the data increases, under the assumption that the change in $\textrm{SNR}$ with dimension $d$ does not alter the scaling.
\section{Experiments with data-driven MDL-COMP}
\label{sec:experiments}
This section proposes a practical version of \ensuremath{\textrm{MDL-COMP}}. Simulations and
real-data experiments show that this data-driven \ensuremath{\textrm{MDL-COMP}}\ is useful
for informing generalization. In the experiments to follow, this
data-driven \ensuremath{\textrm{MDL-COMP}}\ as a hyperparameter tuning criteria. While
\cref{thm:lam_opt} guarantees that the optimal regularization defining
(the oracle) $\ensuremath{\textrm{MDL-COMP}}$ also obtains the minimum possible in-sample
MSE, in this section we numerically illustrate the usefulness of the
\textrm{Prac-MDL-COMP}\ for achieving good test MSE which is computed on a fresh
set of samples $(x_i', y_i')_{i=1}^{n_{\textrm{test}}}$ as follows:
\begin{align}
\label{eq:test_mse}
\textrm{test-MSE} & := \frac{1}{n_{\textrm{test}}} \sum_{i=1}^{n_{\textrm{test}}} (y_i'-
\widehat{\tvar} ^\top x_i')^2.
\end{align}
In particular, we first demonstrate that
solving~\eqref{eq:mdl_comp_objective} correlates well with minimizing
test MSE (\cref{fig:vary_lambda}) for linear models. Next, we find
that, for real datasets, \ensuremath{\textrm{MDL-COMP}}\ is competitive with cross-validation
(CV) for performing model selection (in terms of regularization hyperparameter tuning), actually outperforming CV in the
low-sample regime (\cref{fig:pmlb}). In this section, the linear
models (ridge) and kernel methods are fit using
scikit-learn~\citep{pedregosa2011scikit} and optimization for
hyper-parameter tuning (see~\eqref{eq:mdl_comp_objective}) is
performed using SciPy~\citep{2020SciPy-NMeth}.
\subsection{\ensuremath{\textrm{MDL-COMP}}\ inspired hyper-parameter tuning}
\label{subsec:mld_comp_practical}
As defined, the complexity $\ensuremath{\textrm{MDL-COMP}}$ can not be computed in practice,
since it assumes knowledge of true parameter. Moreover, ridge
estimators are typically fit with only one regularization parameter,
shared across all features. As an alternative that circumvents these
issues, we propose the following data-driven \emph{practical
MDL-COMP}:
\begin{align}
\label{eq:mdl_comp_objective}
\textrm{Prac-MDL-COMP} = \min_{\lambda} \frac{1}{n} \parenth{\frac{\enorm{\mat{X}
\widehat{\tvar}-\v{y}}^2}{2 \sigma^2} + \frac{\lambda \enorm{\widehat{\tvar}}^2}{2
\sigma^2} + \frac{1}{2} \sum_{1=i}^{\min\braces{n,d}} \log
\parenth{1 + \frac{\evali}{\lambda}}},
\end{align}
where $\widehat{\tvar} := \parenth{\xmat^\top\xmat+\lambda \mat I}^{-1} \mat{X}^\top \v{y}$ is the
ridge estimator~\eqref{eq:ridge_new_closed} for $\mat{\Lambda} = \lambda
\mat I_d$, and we use $\evali$ to denote the non-zero eigenvalues of
the matrix $\xmat^\top\xmat$. This expression is the sample-version of the
expression~\eqref{eq:exp_1} for $\ensuremath{\mc R_{\textrm {opt}}}$ derived in the proof of
Theorem~\ref{thm:complexity_expressions} where we enforce $\mat{\Lambda} =
\lambda \mat I$. And similarly, \cref{eq:ropt_expression} from the
proof suggests that we can define a data-driven approximate optimal
redundancy ($\ensuremath{\mc R_{\textrm {opt}}}$) as follows:
\begin{align}
\label{eq:approx_ropt}
\widehat{\mc{R}}_{\textrm{opt}} := \frac1{2n} \sum_{i=1}^{\min\braces{n, d}}\log\parenth{1+\frac{\evali}{\lambda_{\textrm{opt}}}}
\end{align}
where $\lambda_{\textrm{opt}}$ is the optimal hyperparameter for the objective~\eqref{eq:mdl_comp_objective}. Since we only have one hyper-parameter in defining \textrm{Prac-MDL-COMP}, we can also treat the approximate $\widehat{\mc{R}}_{\textrm{opt}}$ as a proxy for \ensuremath{\textrm{MDL-COMP}}\ over the class $\braces{\mathbb{Q}_{\lambda}: \lambda \in (0, \infty)}$.
For kernel methods, an analogous data-driven criterion for MDL-COMP is given by
\begin{align}
\label{eq:kernel_prac_mdl_comp}
\textrm{Prac-MDL-COMP}_{\mat{K}} = \min_{\lambda}
\frac{1}{n}\parenth{\frac{\enorm{\mat{K} \widehat{\tvar}-\v{y}}^2}{2\sigma^2} + \frac{\lambda \widehat{\tvar}^\top \mat{K} \widehat{\tvar}}{2\sigma^2}
+ \frac12 \sum_{i=1}^n \log \parenth{1+\frac{\evali}{\lambda}}}
\end{align}
where now $\widehat{\tvar} = (\mat{K} + \lambda \mat{I})^{-1} \v{y} $~\eqref{eq:kernel_ridge}, and
$\{ \evali \}_{i=1}^n$ denote the eigenvalues of the kernel matrix
$\mat{K}$.
\paragraph{Computational benefits of \textrm{Prac-MDL-COMP}\ over cross-validation:}
\label{sub:run_time_comparisons_between_cross_validation_and_pra}
We note that for a given hyperparameter $\lambda$, implementing the \textrm{Prac-MDL-COMP}\ criterion requires (1) solving a regularized least squares problem of size $n \times d$, and (2) computing the eigenvalues of the matrix $\xmat^\top\xmat$, both of which take $\order{dn^2}$ time when $d>n$, and $\order{nd^2}$ time when $n>d$ when using practical and stable numerical solvers. Thus the overall computational complexity is $\order{\min(n, d)^2 \max(n, d)}$. On the other hand, implementing $k$-fold cross-validation for a given $\lambda$ requires us to solve $k$ regularized least squares problem of size $\order{n} \times d$, and thereby the overall computational complexity is $\order{k \cdot \min(n, d)^2 \max(n, d)}$. In simple words, \textrm{Prac-MDL-COMP}\ is $\order{k}$ computationally more efficient than $k$-fold cross-validation.
\subsection{\textrm{Prac-MDL-COMP}\ informs test MSE in Gaussian simulations}
\label{sub:test_mse}
\cref{fig:vary_lambda} shows that the model corresponding to the optimal
$\lambda$ achieving the minimum in \cref{eq:mdl_comp_objective}, has a low
test MSE (panels A-E), and comparable to the one obtained by leave-one-out
cross validation (LOOCV, panel F).
The setup follows the Gaussian model as in \cref{eq:linear_model_revisit} with the noise variance $\sigma^2$ set to 1, with sample size $n=100$ fixed.
Here the covariates are drawn i.i.d. from $\mc N(0, 1)$, and then fixed. The true parameter $\tvar_\star$ is set to be in dimension $50$ (extended to larger dimensions by appending zeros); its entries are first drawn i.i.d. from $\mc N(0, 1)$ and then scaled so that $\Vert\tvar_\star\Vert=1$. We tune the parameter $\lambda$ over 20 values equally spaced on a log-scale from $10^{-3}$ to $10^6$.
We vary the number of covariates ($d$) used for fitting the model and report the results for $d/n \in \braces{1/10, 1/2, 1, 2, 10}$ (noting that we have a misspecified model when fitting with $d<50$ features). Across all panels (A-E), we observe that the minima of the test MSE and the objective~\eqref{eq:mdl_comp_objective} for defining \textrm{Prac-MDL-COMP}\ often occur close to each other (points towards the bottom left of these panels).
\cref{fig:vary_lambda}F shows the generalization performance of the models
selected by \textrm{Prac-MDL-COMP}\ in the same setting. Selection via \textrm{Prac-MDL-COMP}\
generalizes well, very close to the best ridge estimator selected by leave-one-out
cross-validation. While the tuned ridge estimators (via CV, or MDL-COMP) exhibit the usual U-shaped curve for the test error in \cref{fig:vary_lambda}F, the OLS estimator exhibits a peak, a phenomenon termed as double-descent (that has been seriously investigated in recent works; see \cref{sec:discussion} for further discussion)
.
\cref{sec:supp_experiments} shows more results suggesting that \textrm{Prac-MDL-COMP}\ can select models well even under different forms of misspecification.
\begin{figure}[ht]
\centering \includegraphics[width=\textwidth]{fig_lambda_top}
\makebox[\textwidth][c]
{\includegraphics[height=1.37in]{fig_lambda_bot}
\includegraphics[height=1.32in]{fig_iid_mse} }
\caption{Minimizing the objective~\eqref{eq:mdl_comp_objective}
which defines \textrm{Prac-MDL-COMP}\ selects models with low test
error. \textbf{A-E.} Different panels show that this holds even
as $d/n$ is varied. \textbf{F}. \textrm{Prac-MDL-COMP}\ selects a model
with Test MSE very close to Ridge cross-validation, avoiding the
peak exhibited by OLS.}
\label{fig:vary_lambda}
\end{figure}
\subsection{Experiments with PMLB datasets}
\label{sub:real_experiments}
In this section, we report results on the behavior
\textrm{Prac-MDL-COMP}~\eqref{eq:mdl_comp_objective} when used to perform model
selection on real datasets. Datasets are taken from PMLB
\citep{olson2017pmlb, OpenML2013}, a repository of diverse tabular
datasets for benchmarking machine-learning algorithms. We omit
datasets that are simply transformations of one another, or that have
too few features; doing so yields a total of 19 datasets spanning a
variety of tasks, such as predicting breast cancer from image
features, predicting automobile prices, and election results from
previous elections~\citep{simonoff2013analyzing}. The mean number of
data points for these datasets is 122,259 and the mean number of
features is 19.1. For a given dataset, we fix $d$ to be the number of
features, and we vary $n$ downwards from its maximum value (by
subsampling the dataset) to construct instances with different values
of the ratio $d/n$. The hyperparameter $\lambda$ takes on 10 values
equally spaced on a log scale between $10^{-3}$ and $10^3$. The test
set consists of 25\% of the entire dataset.
\cref{fig:pmlb}A compares the performance of Prac-MDL-COMP to
Ridge-CV. We find that shows that in the limited data regime,
i.e. when $d/n$ is large, Prac-MDL-COMP tends to outperform. As the
number of training samples is increased (i.e., $d/n$ decreases), the
advantage provided by selection via Prac-MDL-COMP decreases. Further
details, and experiments on omitted datasets are provided in
\cref{sub:real_data_experiments_continued}; in particular, see
\cref{fig:pmlb_5fold,fig:pmlb_full,tab:datasets}.
\begin{figure}[ht]
\centering
\makebox[\textwidth][c]{\includegraphics[width=1\textwidth]{fig_pmlb}}
\caption{Comparing test-error when selecting models using Prac-MDL-COMP
versus using cross-validation on real datasets. \textbf{A}. When data
is most limited, Prac-MDL-COMP based hyperparameter tuning outperforms Ridge-CV. \textbf{B, C}. As the amount of training samples increases, Prac-MDL-COMP performs comparably to Ridge-CV. Each point averaged over 3 random bootstrap samples.}
\label{fig:pmlb}
\end{figure}
\subsection{Experiments with fMRI data}
We now focus on a challenging type of data that arises in
neuroscience. The dataset consists of neural responses of human
subjects, as recorded by functional magnetic-resonance imaging (fMRI),
as they are shown natural
movies~\citep{nishimoto2011reconstructing}. The training data consists
of 7,200 time points and the test data consists of 540 time points,
where at each timepoint a subject is watching a video clip. The test
data is averaged over 10 repetitions of showing the same clip to the
same subject. Following the previous work, we extract video features
using a Gabor transform, resulting in 1,280 features per
timepoint. From these features, we predict the response for each voxel
in the brain using ridge regression. To summarize, for this setting,
we have $d=1280, n_{\textrm{train}}=7200$ and $n_{\textrm{test}}=540$.
We restrict our analysis to 50 voxels with no missing data in the V1,
V2, and V4 regions of the brain, which are known to be easier to
predict. Before fitting, the features and responses are each
normalized to have mean zero and variance one. In all fMRI
experiments, $\lambda$ takes on 40 values equally spaced on a log
scale between $10^{0}$ and $10^6$.
\cref{fig:fmri_results} shows our prediction results when using Prac-MDL-COMP for model selection to predict the fMRI responses. We compare to Automatic Relevance Determination (ARD), a popular Bayesian approach which places an adaptive prior over the regression parameters~\citep{mackay1994bayesian}. \cref{fig:fmri_results}A shows that Prac-MDL-COMP consistently outperforms the Bayesian ARD baseline across voxels. Moreover, Prac-MDL-COMP is roughly on par with leave-one-out cross-validation (CV) for model selection in this data (\cref{fig:fmri_results}).
CV outperforms Prac-MDL-COMP for a majority of the voxels by a slight margin, but on the remaining voxels, Prac-MDL-COMP tends to outperform CV by a substantial margin.
\begin{figure}[ht]
\centering
\includegraphics[width=0.9\textwidth]{fig_fmri_results_test_only.pdf}
\caption{Prac-MDL-COMP succesfully selects models which predict fMRI responses well. \textbf{A}. Prac-MDL-COMP outperforms the Bayesian ARD baseline for every voxel (each point represents one voxel). \textbf{B}. Prac-MDL-COMP is on par with cross-validation. }
\label{fig:fmri_results}
\end{figure}
\cref{fig:fmri_results_scatter_plot}A shows the relationship between the Prac-MDL-COMP objective and the test error. Test error tends to increase as the Prac-MDL-COMP objective increases, showing that minimizing the objective continues to inform good model selection for minimizing test error even for this challenging real dataset. In \cref{fig:fmri_results_scatter_plot}B, we provide a scatter plot of the test MSE versus $\widehat{\mc R}_{\textrm{opt}}$ computed from data. We notice a linear relationship between the two quantities, and observe a correlation of $0.69$. While, \cref{thm:lam_opt} guaranteed that the optimal redundancy $\ensuremath{\mc R_{\textrm {opt}}}$ bounds the in-sample MSE, \cref{fig:fmri_results_scatter_plot}B suggests that its data-driven approximation also provides useful information about the (ordering of) test MSE.
\begin{figure}[ht]
\centering
\includegraphics[width=0.9\textwidth]{fig_fmri_results_variation_mse_prac_mdl_comp.pdf}
\caption{\textbf{A}. Test MSE often increases when Prac-MDL-COMP objective increases, showing that minimizing the objective informs good model selection for minimizing Test MSE. Each gray curve represents one randomly chosen voxel (only 10 out of 50 are shown for visualization). \textbf{B} Scatter plot (over the 50 different voxels) of test MSE versus the estimated $\widehat{\mc R}_{\textrm{opt}}$.}
\label{fig:fmri_results_scatter_plot}
\end{figure}
\subsection{Experiments with neural tangent kernel on fMRI data}
\cref{fig:fmri_ntk_results} shows the results when repeating the
experiments in \cref{fig:fmri_results}, but now using kernel ridge
regression with the neural tangent kernel~\citep{jacot2018neural}
rather than linear ridge regression. It shows the prediction results
when using Prac-MDL-COMP (applied to kernel ridge regression, see
\cref{eq:kernel_prac_mdl_comp}) for model selection to predict the
fMRI responses. For the neural tangent kernel computation, we use the
neural-tangents library~\citep{neuraltangents2020} with its default
parameters (ReLU nonlinearity, two hidden linear layers with hidden
size of 512). \cref{fig:fmri_ntk_results}A shows that Prac-MDL-COMP is
roughly on par with leave-one-out cross-validation for model selection
in this data. \cref{fig:fmri_ntk_results}B shows the relationship
between the Prac-MDL-COMP objective and the test error, where we see
that the curves are flatter when compared to
\cref{fig:fmri_results_scatter_plot}A. Nonetheless, the test error
often decreases as the Prac-MDL-COMP objective increases, suggesting
that minimizing the objective is a good proxy for model selection for
minimizing test error even for this setting.
\begin{figure}[ht]
\centering
\includegraphics[width=\textwidth]{../figs/fig_kernel_fmri_results}
\caption{Prac-MDL-COMP succesfully selects models which predict
fMRI responses well when using
NTK-kernel. \textbf{A}. Prac-MDL-COMP is on par with
cross-validation for every voxel (each point represents one
voxel). \textbf{B}. Test MSE often increases when Prac-MDL-COMP
objective increases, showing that minimizing the objective
informs good model selection for minimizing Test MSE. Each gray
curve represents one randomly chosen voxel (only 8 are shown for
visualization).}
\label{fig:fmri_ntk_results}
\end{figure}
\section{Discussion}
\label{sec:discussion}
In this work, we revisited complexity
measures in the context of overparameterized models. We argued that there is a lack of theoretical justification for using parameter count as a complexity measure in overparameterized settings. We defined an MDL-based complexity measure MDL-COMP for linear and kernel methods, using codes induced by ridge estimators that can also deal with overparameterized settings. Our analytical results show that MDL-COMP depends on dimension $d$, sample size $n$, the covariate/kernel matrix, the true parameter/function properties, and the noise in the data. It does not grow linearly in $d$
for over-parameterized linear models, in fact, it often grows much more
slowly as $\log d$ for $d > n$. We prove that MDL-COMP informs the fixed design generalization error and provides good empirical results for the random design generalization error. Numerical experiments show that a practical hyperparameter tuning scheme, inspired by MDL-COMP, provides generalization performance for various types of ridge estimators, often (although not always) outperforming cross-validation (CV) when the number of observations is limited.
Moreover, MDL-COMP based tuning offers computational savings over $K$-fold cross validation as it tunes the parameter using only a single-fold computation, thereby serving as a competitive alternative to CV in limited data regimes.
\subsection{Consequences for bias-variance tradeoff in overparameterized models}
Another consequence of our results is a better understanding of the recent mysteries around the bias-variance tradeoff principle with overparameterized models which we now elaborate. While the classical bias-variance tradeoff is known to exhibit a U-shaped curve in well-posed regimes, several recent works have exhibited a \emph{double-descent} curve that looks like the peaky curve of the OLS estimator from \cref{fig:vary_lambda}F (also see \cref{fig:test_mse_diff_design}(a)) in ill-posed regimes. (Notably we do not observe the double descent with good regularized estimators.)
Such a double-descent behavior for test error---with parameter count like measures on the $x$-axis as a proxy for complexity---has been observed and investigated in a series of recent works for linear regression~\citep{hastie2019surprises,belkin2019two,muthukumar2020harmless} as well as DNNs for classifications \citep{advani2017high,Nakkiran2019DeepDD} among other models~\citep{belkin2019reconciling}.\footnote{It is worth noting that this double-descent phenomenon was
documented as instability in early work on linear discriminant
analysis~\citep{skurichina1998bagging,skurichina2001bagging,skurichina2002bagging}. See \cite{loog2020brief} for further discussion on the history of double descent.
These non-classical test error curves have prompted several researchers to question the validity of the bias-variance tradeoff
principle, especially in overparameterized regimes~\citep{belkin2019reconciling, belkin2019two}. We highlight that double descent can also occur in non-overparameterized regimes when the covariate matrix is ill-conditioned (see \cref{fig:test_mse_diff_design}(c), and the discussion in this section).}
\paragraph{Investigating two possible causes of double descent:}
Our investigation into the complexity measures was partially motivated to better understand the double descent phenomenon. First, we note that the classical bias-variance tradeoff generally applies to \emph{a fixed training/test dataset in well-posed regimes, with a class of good estimators that are ordered by a suitable notion of complexity}. Thus, a non-classical test error curve, in principle, can arise for two reasons: (i) The choice of complexity measure is not suitable or well-justified, e.g., the parameter count in overparameterized regimes. (ii) The choice of estimators is not suitable due to ill-posedness of the data/model, e.g., OLS estimators with ill-conditioned covariate matrix, or in overparameterized regimes.
The concurrent work on double descent uses parameter count as the complexity measure while plotting the test error of a range of ill-posed and well-posed estimators or models\footnote{Applied papers use fixed test set, but theory papers use varying training and test sets. Refer to the discussion on related work in the sequel.} (the shape of the OLS curve in \cref{fig:vary_lambda}F is representative of the double descent figures in the recent related work), and thus apriori it is not clear if the double descent phenomenon is a consequence of (i) or (ii).
As a check for (i) (complexity), we can replace parameter count with MDL-COMP expressions (\cref{thm:complexity_expressions}, \cref{fig:mdl_gaussian}) on the $x$-axis of these test error plots (as it is valid even for overparameterized models). However, since MDL-COMP remains monotone with dimension $d$, the qualitative conclusion about the double descent of the test error does not change.
Next, to investigate (ii) (estimators), we note from \cref{fig:vary_lambda}F that the tuned ridge estimators, either using cross-validation, or \textrm{Prac-MDL-COMP}, do exhibit the classical U-shaped curve with either choice of complexity measures, and obtain minimum test error at the true dimensionality of the data generating model. Furthermore, this conclusion is robust across ill-conditioned designs: \cref{fig:test_mse_diff_design} shows that tuned ridge estimators exhibit U-shaped test error curves even when the covariate matrix is ill-conditioned, and achieve superior test error than OLS. In fact, for our choice of covariate matrices, the OLS estimator exhibits double descent and \emph{even multiple descent} in both low and high-dimensional settings, including non-overparameterized regimes.\footnote{Here low and high-dimensional setting respectively denotes whether or not the true generative model has more parameters than the training sample size.} Moreover, when using the best prediction error to do model selection (across the choice of number of features), the OLS estimator admits worse (sometimes significant worse) prediction error than its Ridge counterpart.
\paragraph{Related work on double descent:}
Recently, there has been a lot of research interest in probing the double descent phenomenon via different lenses.
On the one hand, several works establish sufficient conditions for the OLS estimator to achieve good generalization in an overparameterized setting ($d\gg n$), a phenomenon referred to as the \emph{benign overfitting}~\citep{bartlett2020benign,muthukumar2020harmless,hastie2019surprises,tsigler2020benign}. It is worth noting that the OLS estimator can continue to exhibit double descent even for these settings.
On the other hand, many works investigate the test error curves of ridge estimators for various settings: (a) When the dimensionality of the generative model $d$ varies along with the fitted model (keeping the fitted model correctly specified), \cite{hastie2019surprises} prove that optimally tuned ridge estimators exhibit a U-shape curve for linear models and isotropic features. In their set-up, one plots the test error curve for range of $d$ keeping the sample size fixed.
(b) \cite{nakkiran2020optimal} make a similar conclusion for linear models with isotropic features but now for a fixed $d$ while varying the sample size $n$. We highlight that both (a) and (b) are subtly different than the practical set-up discussed in the previous paragraph where the training observations are fixed and only the fitted models vary. In contrast, both (a) and (b) vary the training observations simultaneously with the fitted estimator (and the fitted model always remains correctly specified). However, the qualitative conclusions drawn remain similar---tuned regularization restores the classical U-shape of test error curves.
\paragraph{Conclusions about the possible cause of double descent:}
Combining our findings along with the concurrent work, we can hypothesize that while parameter count is not a justified complexity measure, the double descent phenomenon is likely to be a consequence of a poor choice of estimators in ill-posed regimes. Poor estimators like OLS can exhibit double descent or even multiple descent depending on the covariate matrix, while regularized estimators with tuned hyper-parameters continue to exhibit U-shaped test error curves.
\subsection{Future directions}
We believe that our work takes a useful step towards questioning the fundamental components that underlie the principle of bias-variance tradeoff, and provides a proof of concept for the value of revisiting the complexity measure in overparameterized settings.
Besides, several direct future directions arise from our work. Relating MDL-COMP with
out-of-sample guarantees under additional assumptions on the covariate
design, like those in~\citep{hsu2012random,dobriban2018high} for the linear model is an interesting open problem. Next, we note that our measures are based on ridge estimators but they are often
not suitable for parameter estimation with sparse models in
high-dimensions, and thus deriving MDL-COMP with codes suitably
adapted for $\ell_1$-regularization would also be
interesting. Additionally, it remains to define and investigate
\ensuremath{\textrm{MDL-COMP}}\ beyond linear and kernel methods, e.g., for deep neural
networks, as well as for classification tasks.
\acks{This work was partially supported by
National Science Foundation
grant NSF-DMS-1613002, NSF-2015341, and the Center for Science of
Information (CSoI), a US NSF Science and Technology Center, under
grant agreement CCF-0939370, the NSF grant 2023505 on Collaborative Research: Foundations of Data Science Institute (FODSI), the NSF and the Simons Foundation for the Collaboration on the Theoretical Foundations of Deep Learning through awards DMS-2031883 and 814639, and an Amazon Research Award to BY, and
Office of Naval Research grant DOD ONR-N00014-18-1-2640 and National
Science Foundation grant NSF-DMS-2015454 to MJW.}
\begin{appendix}
\setcounter{table}{0}
\setcounter{figure}{0}
\renewcommand{\thefigure}{A\arabic{figure}}
\renewcommand{\thetable}{A\arabic{table}}
\section{Further discussion of \ensuremath{\textrm{MDL-COMP}} }
\label{sub:non_isotropic}
We start with additional details on the simulation set-up and sketch
related to the \ensuremath{\textrm{MDL-COMP}}\ scaling from
\cref{sub:mdl_complexity_for_linear_models} in
\cref{sub:mdl_plots_details}. In \cref{sub:sketch_gaussian}, we
sketch the proof for the \ensuremath{\textrm{MDL-COMP}}'s behavior as observed in
\cref{fig:mdl_gaussian}, and then provide an analytical bound for
$\ensuremath{\mc R_{\textrm {opt}}}$ in \cref{sub:ropt_large_scale} under high-dimensional
asymptotics. In \cref{sub:a_minimax_optimality_via_mdltag}, we argue
that the minimax optimality of MDL-COMP holds under a broad class of
noise distributions (beyond Gaussian) under the linear
model~\eqref{eq:linear_model_revisit}. Finally, we collect some
additional background related to MDL in \cref{sub:further_background}.
\subsection{Simulation set-up}
\label{sub:mdl_plots_details}
Here we elaborate the set-up associated with
\cref{fig:mdl_gaussian,fig:mdl_spike_design}. The true dimensionality
$d_\star$ denotes that the observations $\v{y} = \widetilde{\mat{X}}\tvar_\star
+ \noise[]$ depend only on first $d_\star$ covariates of the full
matrix $ \mat{X}_{\textrm{full}}$, Given a sample size $n$ (fixed for a
given dataset, fixed in a given plot), the matrix
$\mat{X}_{\textrm{full}} \in \ensuremath{\mathbb{R}}^{n \times \overline{d}}$, and
$\widetilde{\mat{X}} \in \ensuremath{\mathbb{R}}^{n\times d_\star}$ where $\overline{d}$ denotes
the maximum number of covariates available for fitting the model (and
in our plots can be computed by multiplying the sample size with the
the maximum value of $d/n$ denoted on the $x$-axis). When we vary $d$,
we use $\mat{X} \in \ensuremath{\mathbb{R}}^{n \times d}$ (selecting first $d$ columns of
$\mat{X}_{\textrm{full}}$) for fitting the ridge model and computing the
\ensuremath{\textrm{MDL-COMP}}.
\paragraph{Defining $\v{\myvec}$, and clarifying footnote~\ref{footnote:defining_w}:}
In order to compute \ensuremath{\textrm{MDL-COMP}}~\eqref{eq:mdl_linear_explicit}, we need to
compute the eigenvalues $\evali$ of $\xmat^\top\xmat$, where $\mat{X} \in \ensuremath{\mathbb{R}}^{n
\times d}$ denotes the first $d$ columns of the full matrix
$\mat{X}_{\textrm{full}}$ that are used for fitting the ridge model, and
computing the corresponding encoding and \ensuremath{\textrm{MDL-COMP}}. Moreover, we need
to compute the vector $\v\myvec$ defined equal to $\mat U ^\top \tvar_\star$
in equation~\eqref{eq:xmatrix}. Note that $\mat U$ has size $d \times
d$ and $\tvar_\star$ is $d_\star$ dimensional. So when $d<d_\star$, the
vector $\v\myvec$ is computed by restricting $\tvar_\star$ to first $d$
dimensions (in \cref{eq:xmatrix}), i.e., using $\widetilde{\theta}_{\star} =
(\tvar_\star)_{[1:d]}$ (the orthogonal projection of $\tvar_\star$ on $\xmat^\top\xmat$)
and define $\v\myvec = \mat U ^\top \widetilde{\tvar_\star}$. On the other
hand, for $d>d_\star$, we simply extend the $\tvar_\star$ by appending
$d-d_\star$ $0$'s, i.e., $\widetilde{\theta}_{\star} = \begin{bmatrix} \tvar_\star
\\ \mathbf 0 _{d-d_\star}
\end{bmatrix}$ and then set $\v\myvec = \mat U ^\top \widetilde{\theta}_{\star}$.
\subsection{Proof sketch for random isotropic
designs}
\label{sub:sketch_gaussian}
In this section, we provide a proof sketch to explain the behavior of
\ensuremath{\textrm{MDL-COMP}}/ when applied to random isotropic designs, as plotted in
\cref{fig:mdl_gaussian}. Suppose that the design matrix $\mat{X} \in
\ensuremath{\mathbb{R}}^{n \times d}$ has entries drawn from iid from the Gaussian
distribution $\mc N(0, 1/n)$; the $1/n$-variance serves to ensure that
$\mat{X}$ has columns with expected squared norm equal to one. When $n
\gg d$, standard random matrix theory guarantees that $\xmat^\top\xmat \approx
\mat I_d$ and hence $\evali \approx 1$. For $d \gg n$, one can apply
the same argument to the matrix $\mat{X}\xmat^\top$ to conclude that
$\mat{X} \mat{X}^\top \approx \frac dn \mat I_n$; thus, the matrix $\xmat^\top\xmat$
has rank $n$ with its non-zero eigenvalues roughly equal to $d/n$. And, from above, we recall the definition $\v\myvec = \mat U^\top \widetilde{\theta}_{\star}$, where $\widetilde{\theta}_{\star}$ is either a restriction of $\tvar_\star$ when the model is under-specified, or is obtained by appending zeros when the model is over-specified..
Since the matrix $\mat U$ consists of the eigenvectors of $\xmat^\top\xmat$, it
has a uniform distribution over the space of all orthogonal matrices
in dimension $d$. Let $r^2 := \enorm{\tvar_\star}^2$ and, note from above that $\enorm{\v\myvec}^2 = \enorm{\widetilde{\theta}_{\star}}^2$. When $d \geq d_\star$, we have $\enorm{\widetilde{\theta}_{\star}}^2 = r^2$, and when $d<d_{\star}$, and the coordinates of $\tvar_\star$ are drawn iid, we have $\enorm{\widetilde{\theta}_{\star}}^2 \approx \frac{d}{d_{\star}} r^2$. Given the distribution of $\mat U$, we have that the entries of $w_i^2$ are approximately equal, and thus conclude that $ w_i^2 \approx \min\braces{1, \frac{d}{d_{\star}}} \frac{r^2}{d} = r^2 \cdot
\min\braces{\frac{1}{d}, \frac{1}{d_\star}}$. Plugging in these
approximations, when $d_\star <n$, we find that
\begin{align}
\ensuremath{\textrm{MDL-COMP}}\!=\! \frac1{2n}\sumn[\min\braces{n, d}] \log\parenth{\evali+ \frac{\sigma^2}
{\myvec_i^2}}
\approx \begin{cases}
\displaystyle \frac dn \log\parenth{1+ d_\star/r^2}
&\text{ if }d \in [1, d_\star]\\[2mm]
\displaystyle \frac dn \log\parenth{1+d/r^2}
&\text{ if } d \in [d_\star, n]\\[2mm]
\displaystyle \log \brackets{d \parenth{\frac{1}{r^2}+\frac 1n}}
&\text{ if } d \in [n, \infty)
\end{cases}
\label{eq:adj_scaling}
\end{align}
\begin{align}
\ensuremath{\mc R_{\textrm {opt}}}\!=\!\frac1{2n}\sumn[\min\braces{n, d}] \log\parenth{1 + \frac{\evali\myvec_i^2}{\sigma^2}}
\approx \begin{cases}
\displaystyle \frac dn \log\parenth{1+ \frac{r^2}{d_\star}}
&\text{ if } d \in [1, d_\star]\\[2mm]
\displaystyle\frac dn \log\parenth{1+ \frac{r^2}{d}}
&\text{ if }d \in [d_\star, n]\\[2mm]
\displaystyle \log\parenth{1+ \frac{r^2}{n}}
&\text{ if } d \in [n, \infty).
\end{cases}
\label{eq:adj_scaling_ropt}
\end{align}
For the case when $d_\star > n$, i.e., the true dimensionality is larger than the sample size, we have
\begin{align}
\ensuremath{\textrm{MDL-COMP}}\!=\! \frac1{2n}\sumn[\min\braces{n, d}] \log\parenth{\evali+ \frac{\sigma^2}
{\myvec_i^2}}
&\approx \begin{cases}
\displaystyle \frac dn \log\parenth{1+ \frac{d_\star}{r^2}}
&\text{ if } d \in [1, n]\\[2mm]
\displaystyle\log\parenth{\frac dn + \frac{d_\star}{r^2}}
&\text{ if } d \in [n, d_\star]\\[2mm]
\displaystyle \log \brackets{d \parenth{\frac{1}{r^2}+\frac 1n}}
&\text{ if } d \in [d_\star, \infty),
\end{cases}
\label{eq:adj_scaling_high_dim} \\
\ensuremath{\mc R_{\textrm {opt}}}= \frac1{2n}\sumn[\min\braces{n, d}] \log\parenth{1 + \frac{\evali\myvec_i^2}{\sigma^2}}
&\approx \begin{cases}
\displaystyle \frac dn \log\parenth{1+ \frac{r^2}{d_\star}}
&\text{ if } d \in [1, d_\star]\\[2mm]
\displaystyle\frac dn \log\parenth{1+ \frac{r^2}{d}}
&\text{ if } d \in [d_\star, n]\\[2mm]
\displaystyle \log\parenth{1+ \frac{r^2}{n}}
&\text{ if } d \in [n, \infty).
\end{cases}
\label{eq:adj_scaling_ropt_high_dim}
\end{align}
In both of the cases covered by equations~\eqref{eq:adj_scaling} and
\eqref{eq:adj_scaling_high_dim}, we find that the MDL-COMP has scaling
$\mc O(d/n)$ for small $d$, and $\mc O (\log d)$ for $d \gg n$.
Overall, this argument along with results in \cref{fig:mdl_gaussian}
suggest that $d/n$ should not be treated as the default complexity for
$d > n$, and that \ensuremath{\textrm{MDL-COMP}}\ provides a scaling of order $\log d$ for $d
> n$.
\subsection{Expressions for $\ensuremath{\mc R_{\textrm {opt}}}$ for large scale settings}
\label{sub:ropt_large_scale}
In recent work, a number of
authors~\citep{hastie2019surprises,belkin2019two} have studied the
generalization error of different estimators applied to linear models
under the high-dimensional asymptotic scaling $\ensuremath{d}, \samples \to \infty$
and $\ensuremath{d}/\samples \to \gamma$. In a similar setting, we can derive an
expression for the optimal redundancy $\ensuremath{\mc R_{\textrm {opt}}}$.
\begin{theorem}
\label{thm:rmt_expressions}
Suppose that the covariate matrix $\mat X \in \ensuremath{\mathbb{R}}^{n \times d}$ has
i.i.d. entries drawn from a distribution with mean $0$, variance $1/n$
and fourth moments of order $1/n^2$, and that the parameter $\tvar_\star$
is drawn randomly from a rotationally invariant distribution, with
$\ensuremath{{\mathbb{E}}}[\frac{\enorm{\tvar_\star}^2}{\sigma^2 d}] = \mrm{snr}$. Then, we have
\begin{align}
\label{eq:mdl_complexity_rmt}
\lim_{n, d\to \infty, \frac{d}{n}\to\gamma}\ensuremath{{\mathbb{E}}}_{\tvar_\star}[\ensuremath{\mc R_{\textrm {opt}}}(\pdist_{\tvar_\star}, \mc{Q}_{\mrm{Ridge}}^{\taglin})]
\leq \gamma \log(1+\mrm{snr} - \delta)
+ \log(1+\gamma \cdot \mrm{snr} - \delta)
- \frac{\delta}{\mrm{snr}},
\end{align}
almost surely, where $\delta := (\sqrt{\mrm{snr}(1+\sqrt{\gamma})^2+1} - \sqrt{\mrm{snr}(1-\sqrt{\gamma})^2+1})^2/4$.
\end{theorem}
See \cref{sub:proof_of_thm:rmt_expressions} for the proof. We remark
that the inequality in the theorem is a consequence of Jensen's
inequality and can be removed whenever a good control over the
quantity $\ensuremath{{\mathbb{E}}}_{w_i^2}\log(1+w_i^2 \evali)$ is available, where $\evali$ denoting the eigenvalues of $\xmat^\top\xmat$.
The first term on the RHS of \cref{eq:mdl_complexity_rmt} has a
scaling of order $d/n$ when the norm of $\tvar_\star$ grows with $d$.
However, when $\enorm{\tvar_\star}$ is held constant with $d$, the optimal
redundacy $\ensuremath{\mc R_{\textrm {opt}}}$ does not grow and remains bounded by a constant. The
bound~\eqref{eq:mdl_complexity_rmt} has a similar scaling as that
noted earlier in
\cref{eq:adj_scaling_ropt,eq:adj_scaling_ropt_high_dim} from our proof
sketch (for $d \in [d_\star, n]$ or $d\in [n , \infty)$, assuming
$d_\star$ fixed, $r^2$ growing with $d$).
\subsection{\ensuremath{\textrm{MDL-COMP}}\ over a wider range of noise distributions}
\label{sub:a_minimax_optimality_via_mdltag}
\cref{thm:complexity_expressions} provides an explicit expression for
\ensuremath{\textrm{MDL-COMP}}\ assuming that the noise follows a Gaussian distribution. In
this section, we show that the optimal code from \cref{eq:ropt_linear}
defining the \ensuremath{\textrm{MDL-COMP}}\ procedure~\eqref{eq:mdl_linear} also achieves a
minimax codelength over a wider range of noise distributions. Let
$\mc{P}$ denote the set of all distributions on $\ensuremath{\mathbb{R}}^n$, and define
the family
\begin{align}
\label{eq:plin_defn}
\mc{P}_{\textrm{bndvar}} = \braces{\P \in \mc{P}: \ensuremath{{\mathbb{E}}}[\noise[]] = 0,
\textrm{Var}(\noise[])\preceq \sigma^2 \mat I_n }.
\end{align}
For the generative linear model~\eqref{eq:linear_model_revisit} with
noise distribution now allowed to belong to the family
$\mc{P}_{\textrm{bndvar}}$~\eqref{eq:plin_defn}, we have
\begin{align*}
\ensuremath{{\mathbb{E}}}_{\noise[]}[\v{y}\vert \mat{X}] = \mat{X} \tvar_\star, \qtext{and}
\textrm{Var}_{\noise[]}(\v{y} \vert \mat{X}) \preceq \sigma^2 \mat
I_n.
\end{align*}
Our next result shows that the code definining \ensuremath{\textrm{MDL-COMP}}\ also achieves
the minimax codelength over the noise distributions in $\mc{P}_{\textrm{bndvar}}$.
\begin{theorem}
\label{thm:minimax_codelength}
The distribution $\mathbb{Q}_{\mat{\Lambda}_{\textrm{opt}}}$ that achieves the \ensuremath{\textrm{MDL-COMP}}\ in
\cref{eq:mdl_linear} also achieves the minimax codelength in the
class $\mc{P}_{\textrm{bndvar}}$, i.e.,
\begin{align}
\label{eq:minimax_codelength}
\mathbb{Q}_{\mat{\Lambda}_{\textrm{opt}}} \in\arg\min_{\mathbb{Q}\in\mc{Q}_{\mrm{Ridge}}^{\taglin}}
\max_{\P\in\mc{P}_{\textrm{bndvar}}}
\ensuremath{{\mathbb{E}}}_{\noise[]\sim\P}\log\parenth{\frac{1}{q(\v{y})}},
\end{align}
where $q$ denotes the density of the distribution $\mathbb{Q}$.
\end{theorem}
\noindent See \cref{sub:proof_of_thm:minimax_codelength} for the proof
of this claim. \\
\subsection{Further background on MDL}
\label{sub:further_background}
As noted earlier, for computing the optimal redundancy in
\cref{eq:ropt_defn}, one can replace the set of codes
$\mc{Q}_{\mrm{Ridge}}$ by a generic set of codes $\mc{Q}$ corresponding to
many classes of models. In contrast, for maximum likelhood estimation
(MLE), one maximizes the log likelihood of the data over a fixed model
class. Maximum likelihood is generally used when a model class is
fixed, and is known to break down when considering even nested classes
of parametric models~\citep{hansen2001model}. In fact, the
definition~\eqref{eq:ropt_defn} can be suitably adjusted even for the
case when there is no true generative model for $\v{y}$. At least in
general, the quantity $\mathbb{Q}(\v{y})$ need not denote the likelihood of
the observation $\v{y}$, and the distribution $\mathbb{Q}$ may not even
correspond to a generative model. In such cases, the optimal choice of
$\mathbb{Q}$ in \cref{eq:ropt_defn} is supposed to be optimal not just for
$\v{y}$ from a parametric family, but also for $\v{y}$ from one of many
parametric model classes of different dimensions.
However, when $\mc{Q}$ is a single parametric family, i.e., $\mc{Q} =
\braces{\mathbb{P}_{\theta}, \theta \in \Theta}$ where $\theta$ denotes
the unknown parameter of interest, the MDL principle does reduce to
the MLE principle. In more precise terms, the MLE can be seen as the
continuum limit of two-part MDL (see Chapter
15.4~\citep{grunwald2007minimum}). In this case, the optimal NML code
$\mathbb{Q}^\star(\v{y})$ is given by the logarithm of the likelihood
computed at MLE plus a term that depends on the normalization constant
of the maximum likelihood over all possible observations; this fact
underlies the nomenclature of normalized maximum likelihood, or NML
for short.
For the low-dimensional linear models (fixed $d$ and $n\to \infty)$,
while several MDL-based complexities, namely two-part codelength,
stochastic information complexity, and NML complexity are equivalent
to the first $\mc O(\log n)$ term---which in turn scales like
$\tfrac{1}{2} d \log n$. Moreover, the NML complexity can be deemed
optimal when accounting for the constant term, i.e., NML complexity
achieves the optimal $\mc O(1)$ term which involves Jeffrey's
prior~\citep{barron1998minimum}, asymptotically for low-dimensional
linear models. We refer readers to the
sources~\citep{rissanen1986stochastic,barron1998minimum,hansen2001model}
for further discussion on two-part coding, stochastic information
complexity, and toSections 5.6, 15.4 of the
book~\citep{grunwald2007minimum} for further discussion on the
distinctions between MDL and MLE.
\section{Further numerical experiments}
\label{sec:supp_experiments}
\setcounter{table}{0} \setcounter{figure}{0}
\renewcommand{\thefigure}{B\arabic{figure}}
\renewcommand{\thetable}{B\arabic{table}}
We now present additional experiments showing the usefulness of the
data-driven \textrm{Prac-MDL-COMP}~\eqref{eq:mdl_comp_objective}. In particular,
we show that \textrm{Prac-MDL-COMP}\ informs out-of-sample MSE in Gaussian as
well as several misspecified linear models
(\cref{sub:misspecified_linear_models}), and then provide further
insight on the performance of real-data experiments (deferred from
\cref{sub:real_experiments} of the main paper) in
\cref{sub:real_data_experiments_continued}.
\subsection{Misspecified linear models}
\label{sub:misspecified_linear_models}
We specify three different types of model misspecification taken from
prior work \citep{yu2020veridical} and analyze the ability of MDL-COMP
to select models that generalize. \cref{fig:shifts} shows that under
these conditions, MDL-COMP still manages to pick a $\lambda$ which
generalizes fairly well. \textit{T-distribution} refers to errors
being distributed with a t-distribution with three degrees of freedom.
\textit{Decaying eigenvalues} refers to the eigenvalues of the
covariance matrix $\lambda_i$ decaying as $1/2^{i}$, inducing
structure in the covariance matrix. \textit{Thresholds} refers to
calculating the outcome using indicator functions for $X>0$ in place
of $X$. Here, Ridge-CV (orange dotted line) refers to model selection
using leave-one-out cross-validation and Prac-MDL-COMP (blue line)
refers to model selection for a ridge model based on optimizing
Prac-MDL-COMP.
\begin{figure}[ht]
\centering \includegraphics[width=\textwidth]{fig_shifts}
\caption{Model selection under misspecification. Under various
misspecifications, \textrm{Prac-MDL-COMP}\ still manages to select models
which generalize reasonably well. Different from other figures
presented in the paper, here $d$ is fixed and the sample size
$n$ is varied.}
\label{fig:shifts}
\end{figure}
\subsection{Real data experiments continued}
\label{sub:real_data_experiments_continued}
We now provide further investigation. First, the good performance of
\textrm{Prac-MDL-COMP}\ based linear model also holds ground against $5$-fold CV,
see \cref{fig:pmlb_5fold}.
Here we show results for 28 real datasets in \cref{fig:pmlb_full}
where the plot titles correspond to dataset IDs in
OpenML~\citep{OpenML2013}. In the limited data regime (when $d/n$ is
large, the right-hand side of each plot), MDL-COMP tends to outperform
Ridge-CV. As the number of training samples is increased, the gap
closes or cross-validation begins to outperform MDL-COMP. These
observations provide evidence for promises of \textrm{Prac-MDL-COMP}\ based
regularization for limited data settings.
\begin{figure}[ht]
\centering
\makebox[\textwidth][c]{\includegraphics[width=\textwidth]{fig_pmlb_5fold}}
\caption{Results for \fref{fig:pmlb} hold when using 5-fold CV rather than LOOCV.}
\label{fig:pmlb_5fold}
\end{figure}
\begin{figure}[ht]
\centering
\makebox[\textwidth][c]{\includegraphics[width=1\textwidth]{fig_pmlb_curves}}
\caption{Test MSE when varying the number of training points sampled from real datasets (lower is better). MDL-COMP performs well, particularly when the number of training points is small (right-hand side of each plot). Each point averaged over 3 random bootstrap samples.}
\label{fig:pmlb_full}
\end{figure}
\begin{table}[ht]
\makebox[\textwidth][c]{
\small
\centering
\begin{tabular}{lrrcc}
\toprule
\shortstack{\bf Dataset name \\ \bf(OpenML ID)} & \shortstack{\bf \#obs $n$} &
\shortstack{\bf \#feats $d$ } & \shortstack{\bf Ridge-CV\\ \bf MSE} &
\shortstack{\bf Prac-MDL-COMP \\ \bf MSE} \\
\midrule
1028\_SWD & 1000 & 11 & 1.17 & \bf 0.97 \\
1029\_LEV & 1000 & 5 & NaN* & \bf 1.10 \\
1030\_ERA & 1000 & 5 & NaN* & \bf 1.05 \\
1096\_FacultySalaries & 50 & 5 & NaN* & \bf 2.01 \\
1191\_BNG\_pbc & 1000000 & 19 & 1.02 & \bf 1.00 \\
1193\_BNG\_lowbwt & 31104 & 10 & \bf 0.98 & 1.01 \\
1196\_BNG\_pharynx & 1000000 & 11 & 1.03 & \bf 1.00 \\
1199\_BNG\_echoMonths & 17496 & 10 & 1.47 & \bf 1.00 \\
1201\_BNG\_breastTumor & 116640 & 10 & 2.61 & \bf 1.12 \\
192\_vineyard & 52 & 3 & NaN* & \bf 1.57 \\
201\_pol & 15000 & 49 & \bf 0.82 & 0.87 \\
210\_cloud & 108 & 6 & 3.41 & \bf 0.73 \\
215\_2dplanes & 40768 & 11 & 0.88 & \bf 0.85 \\
218\_house\_8L & 22784 & 9 & 4.37 & \bf 1.01 \\
225\_puma8NH & 8192 & 9 & 3.26 & \bf 0.87 \\
228\_elusage & 55 & 3 & NaN* & \bf 1.44 \\
229\_pwLinear & 200 & 11 & 0.83 & \bf 0.67 \\
230\_machine\_cpu & 209 & 7 & 2.48 & \bf 0.71 \\
294\_satellite\_image & 6435 & 37 & 0.47 & \bf 0.44 \\
344\_mv & 40768 & 11 & \bf 0.85 & 1.06 \\
4544\_GeographicalOriginalofMusic & 1059 & 118 & 0.67 & \bf 0.60 \\
519\_vinnie & 380 & 3 & NaN* & \bf 0.92 \\
522\_pm10 & 500 & 8 & 2.31 & \bf 0.96 \\
523\_analcatdata\_neavote & 100 & 3 & NaN* & \bf 1.15 \\
527\_analcatdata\_election2000 & 67 & 15 & 0.50 & \bf 0.49 \\
529\_pollen & 3848 & 5 & NaN* & \bf 0.94 \\
537\_houses & 20640 & 9 & 3.00 & \bf 1.06 \\
542\_pollution & 60 & 16 & 0.88 & \bf 0.82 \\
\bottomrule
\end{tabular}
}
\caption{\textrm{Prac-MDL-COMP}\ vs Cross-validation for a range of datasets when the training data is limited. This table contains details about the datasets used in \cref{fig:pmlb,fig:pmlb_full,fig:pmlb_5fold}. The first column denotes the name of the datasets, and the second and third columns report the size of the datasets. In the last two columns, we report the performance for CV-tuned Ridge (LOOCV), and \textrm{Prac-MDL-COMP}\ tuned ridge estimator, trained on a subsampled dataset such that $d/n=1$.
The reported MSE is computed on a hold-out testing set (which consists of 25\% of the observations), and the better (of the two) MSE for each dataset is highlighted in bold. We observe that \textrm{Prac-MDL-COMP}\ based tuning leads to superior performance compared to cross-validation for most of the datasets. *When too few points are available, cross-validation fails to numerically fit for low values of $\lambda$, returning a value of NaN.}
\label{tab:datasets}
\end{table}
\FloatBarrier
\section{Proofs}
\label{sec:proofs}
This appendix serves to collect the proofs of all of our results. The
proofs for Theorems~\ref{thm:complexity_expressions}
through~\ref{thm:minimax_codelength} are provided in
\cref{sub:proof_of_thm:complexity_expressions} through
\cref{sub:proof_of_thm:minimax_codelength}. We prove
Corollary~\ref{cor:mdl_kernel_smooth} in
\cref{sub:proof_of_cref_cor_mdl_kernel_smooth}.
\subsection{Proof of \cref{thm:complexity_expressions}}
\label{sub:proof_of_thm:complexity_expressions}
Our proof is based on establishing that
\begin{align}
\label{eq:ropt_claim}
\lambda_i^{\textrm{opt}} = \frac{\sigma^2}{\myvec_i^2} \quad
\mbox{and} \quad \ensuremath{\mc R_{\textrm {opt}}} = \frac{1}{2n} \sumn[\min\braces{n, d}] \log\parenth{1 +
\frac{\evali}{\lambda_i^{\textrm{opt}}}}.
\end{align}
The claimed expressions for $\ensuremath{\mc R_{\textrm {opt}}}$ and \ensuremath{\textrm{MDL-COMP}}\ follow by using these
expressions and performing some algebra.
Let $\pdist_{\tvar_\star}$ denote the distribution of the multivariate Gaussian
$\mc{N}(\mat{X}\tvar_\star, \sigma^2\mb{I}_n)$, and let $p(\v{y};\mat{X},
\tvar_\star)$ denote its density. Note $\v{y} \sim \pdist_{\tvar_\star}$ by assumption.\footnote{\label{proof:thm1_under_over_specified} In our our earlier discussion with under-specified models in the simulations related to \cref{fig:mdl_gaussian}, and the discussion in \cref{sub:mdl_plots_details,sub:sketch_gaussian}, $\mat{X}$ denotes a subset of full features, in which case $\mat{X}\tvar_\star$ does not capture the mean of the random vector $\v{y}$, and there is a bias. However, given the definition of our MDL-COMP, where we compare to the best possible encoding using $\mat{X}$ at hand, this bias term arises in both the numerator and denominator in \cref{eq:mdl_comp_proof_reatio}, and cancels out thereby not affecting the subsequent derivations. On the other hand, with over-specified models, i.e., when $\mat{X}$ is a superset of features needed to correctly specify the mean of the random vector $\v{y}$, we can append zeros to the true parameter $\tvar_\star$ as necessary, and continue to assume $\v{y} \sim \pdist_{\tvar_\star}$.}
In order to simplify notation, we introduce the shorthand $\widehat{\tvar} =
\widehat{\tvar}_{\mat{\Lambda}}(\v{y})$.
We have
\begin{align}
\label{eq:mdl_comp_proof_reatio}
\kull{\mathbb{P}_{\tvar_\star}}{\mathbb{Q}_{\mat{\Lambda}}} & =\ensuremath{{\mathbb{E}}}_{\v{y}}\brackets{
\log\parenth{\frac{ \frac{1}{(2\pi\sigma^2)^{n/2}}
\exp\parenth{-\frac{1}{2\sigma^2}\enorm{\v{y}-\mat{X}\tvar_\star}^2 }}
{\frac{1}{\mrm{C}_{\mat{\Lambda}}(2\pi\sigma^2)^{n/2}}
\exp\parenth{-\frac{1}{2\sigma^2}\enorm{\v{y}-\mat{X}\widehat{\tvar}}^2
-\frac{1}{2\sigma^2} \widehat{\tvar}^\top\mat{\Lambda}\widehat{\tvar}}} } } \\
&= \;
\sum_{j=1}^3 T_j, \notag
\end{align}
where
\begin{align}
\label{eq:thm_1_step_1}
T_1 := -\ensuremath{{\mathbb{E}}}_{\v{y}} \brackets{\frac{1}{2\sigma^2} \enorm{\v{y}
- \mat{X} \tvar_\star}^2}, \quad
T_2 := \ensuremath{{\mathbb{E}}} \brackets {\frac{1}{2 \sigma^2}\enorm{\v{y} -
\mat{X}\widehat{\tvar}}^2 + \frac{1}{2\sigma^2} \widehat{\tvar} ^\top \mat{\Lambda} \widehat{\tvar}},
\quad
\end{align}
and $T_3 := \log \mrm{C}_{\mat{\Lambda}}$. By inspection, we have $T_1 = -n/2$.
Dividing both sides by $\samples$ yields
\begin{align}
\label{eq:exp_1}
\ensuremath{\mc R_{\textrm {opt}}} = \min_{\mat{\Lambda} \in \mc{M}} \braces{\ensuremath{{\mathbb{E}}}\brackets{
\frac{\enorm{\v{y} -\mat{X} \widehat{\tvar}}^2 + \widehat{\tvar}^\top \mat{\Lambda} \widehat{\tvar}
}{2n\sigma^2} } + \frac{1}{2n}\sumn[d]
\log\parenth{1+\frac{\evali}{\lambda_i}} } - \frac{1}{2}
\end{align}
Next we claim that
\begin{subequations}
\begin{align}
T_2 & = \frac{(n-\min\braces{n, d})}{2} + \frac12\sumn[\min\braces{n, d}]
\frac{(\evali\myvec_i^2/\sigma^2 +
1)\lambda_i}{\lambda_i+\evali}, \qtext{and} \label{eq:t2}\\ T_3
&=
\frac12\sumn[\min\braces{n, d}]\log\parenth{\frac{\evali+\lambda_i}{\lambda_i}}\label{eq:t3}
\end{align}
\end{subequations}
Assuming these claims as given at the moment, let us now complete the
proof. We have
\begin{subequations}
\label{eq:thm_1_kull}
\begin{align}
\frac{1}{n} \kull{\pdist_{\tvar_\star}}{\mathbb{Q}_{\mat{\Lambda}}} = \frac{1}{n}
\sum_{j=1}^3 T_j & = -\frac{\min\braces{n, d}}{2n} + \frac{1}{2n}
\sumn[\min\braces{n, d}] f_i(\lambda_i), \qquad \mbox{where} \\
f_i(\lambda_i) & := \parenth{ \frac{ (\evali\myvec_i^2/\sigma^2 +
1)\lambda_i}{\lambda_i+\evali} +
\log\parenth{\frac{\evali+\lambda_i}{\lambda_i}} }.
\end{align}
\end{subequations}
Finally, in order to compute $\ensuremath{\mc R_{\textrm {opt}}}$ defined in
equation~\eqref{eq:exp_1}, we need to minimize the
KL-divergence~\eqref{eq:thm_1_kull} as a function of the vector
$\lambda = (\lambda_1, \ldots, \lambda_{\min\braces{n, d}})$. Note that the
objective on the RHS of \cref{eq:thm_1_kull} is separable across the
components of $\lambda$, so we need only solve a univariate problem
for each $\lambda_i$. Taking derivatives to find stationary points,
we have
\begin{align}
\label{eq:lam_opt_mdl}
f_i'(\lambda_i) = 0 \quad \Longleftrightarrow \quad
-\frac{(\evali\myvec_i^2/\sigma^2 + 1)}{(1+\evali/\lambda_i)^2} +
\frac{1}{1+\evali/\lambda_i} = 0 \quad\Longleftrightarrow\quad
\lambda_i^{\textrm{opt}} = \frac{\sigma^2}{\myvec_i^2}.
\end{align}
Moreover, checking on the boundary of feasible values of $\lambda_i =
[0, \infty)$, we have $f_i(\lambda_i)\to \infty$ as $\lambda_i\to
0^+$, and $f_i(\lambda_i) \to 1+\evali \myvec_i^2/\sigma^2$ as
$\lambda_i\to \infty$. Noting that $1 +\log a \leq a$ for all $a
\geq 1$, we conclude that $f_i$ achieves its minimum at
$\lambda_i^{\textrm{opt}}$, and we have
$f_i(\lambda_i^{\textrm{opt}}) = 1+ \log
(1+\evali\myvec_i^2/\sigma^2)$. Substituting this value into the
expression~\eqref{eq:lam_opt_mdl} yields
\begin{align}
\ensuremath{\mc R_{\textrm {opt}}} & = -\frac{\min\braces{n, d}}{2n}+ \frac1{2n}\sumn[\min\braces{n, d}] \parenth{1+
\log\parenth{1+\frac{\evali\myvec_i^2} {\sigma^2}}}
\notag \\
& =\frac{1}{2n} \sumn[\min\braces{n, d}] \log\parenth{1+\frac{\evali\myvec_i^2}
{\sigma^2}}. \label{eq:ropt_expression}
\end{align}
We now turn to proving our earlier claims~\eqref{eq:t2} and
\eqref{eq:t3}. We prove them separately. We start with the
low-dimensional case, i.e., when $d<n$. Since the proof for the
high-dimensional case is similar, we only outline the mains steps in
Appendix~\ref{ssub:proof_high_dim}.
\subsubsection{Proof of claims~\eqref{eq:t2} and \eqref{eq:t3} for the case $d<n$}
\label{ssub:proof_low_dim}
Let the singular value decomposition of the matrix $\mat{X}$ be given by
\begin{align}
\label{eq:svd}
\mat X = \mat V \sqrt{\mat D} \mat U^\top.
\end{align}
Here the matrix $\mat D\in \ensuremath{\mathbb{R}}^{d\times d}$ is a diagonal matrix,
with $i$-th diagonal entry denoting the $i$-th squared singular value
of the matrix $\mat{X}$. Moreover, the matrices $\mat V \in \ensuremath{\mathbb{R}}^{n
\times d}$ and $\mat U \in \ensuremath{\mathbb{R}}^ {d\times d}$, respectively,contain
the left and right singular vectors of the matrix $\mat X$,
respectively. (I.e., the $i$-th column denotes the singular vector
corresponding the $i$-th singular value.) Note that we have the
relations $\mat U\mat U^\top = \mat U^\top \mat U = \mat V^\top\mat V = \mat
I_d$, and moreover, the matrix $\mat V \mat V^\top$ is a projection
matrix of rank $d$. Finally, let $\overline{\mat{\Lambda}} = \diag(\lambda_1, \ldots,
\lambda_d)$ be such that $\mat{\Lambda} = \mat U \overline{\mat{\Lambda}} \mat U^\top $. With
this notation in place, we claim that
\begin{subequations}
\label{eq:linear_algebra}
\begin{align}
\label{eq:i_minus_xlam}
(\mat I_n - \mat{X} (\xmat^\top\xmat + \mat{\Lambda}) ^{-1} \mat{X}^\top)^2 &= \mat V
\overline{\mat{\Lambda}}^2(\mat D + \overline{\mat{\Lambda}})^{-2} \mat V ^\top + (\mat I_n-\mat V
\mat V^\top) \\
%
\label{eq:x_lam}
\mat{X}(\xmat^\top\xmat+\mat{\Lambda})^{-1} \mat{\Lambda} (\xmat^\top\xmat+\mat{\Lambda})^{-1} \mat{X}^\top &= \mat V
\mat D\overline{\mat{\Lambda}} (\mat D+\overline{\mat{\Lambda}})^{-2} \mat V^\top, \quad \mbox{and}
\\
\label{eq:w_expand}
\mat{X}(\xmat^\top\xmat+\mat{\Lambda})^{-1} \xmat^\top\xmat\tvar_\star &= \mat V \sqrt{\mat D} (\mat D +
\overline{\mat{\Lambda}})^{-1} \mat D \mat U^\top \tvar_\star\notag \\ &= \mat V \sqrt{\mat D}
(\mat D + \overline{\mat{\Lambda}})^{-1} \mat D \v{\myvec}
\end{align}
\end{subequations}
See Appendix~\ref{sub:few_linear_algebra_simplifications} for the
proofs of these claims, which involve elementary linear algebra.
\subsubsection{Proof of the expression~\eqref{eq:t2} for term $T_2$}
We have
\begin{align}
\frac{1}{2\sigma^2} & \enorm{\v{y} - \mat{X} \widehat{\tvar}}^2 + \frac{1}{2
\sigma^2} \widehat{\tvar} ^\top \mat{\Lambda} \widehat{\tvar} \notag \\
& = \frac{1}{2 \sigma^2} \enorm{\parenth{\mat I_n - \mat{X} (\xmat^\top\xmat +
\mat{\Lambda})^{-1} \mat{X}^\top}\v{y})}^2 + \frac{1}{2 \sigma^2} \enorm{\sqrt
\mat{\Lambda} (\xmat^\top\xmat + \mat{\Lambda})^{-1} \mat{X}^\top \v{y} }^2 \notag \\
& \stackrel{(i)}{=} \frac{1}{2 \sigma^2} \v{y} ^\top \parenth{\mat V
\overline{\mat{\Lambda}}^2 (\mat D + \overline{\mat{\Lambda}})^{-2} \mat V ^\top} \v{y} + \frac{1}{2
\sigma^2} \v{y} ^\top (\mat I_n-\mat V \mat V ^\top) \v{y} + \frac{1}{2
\sigma^2} \v{y} ^\top \parenth{\mat V \overline{\mat{\Lambda}} \mat D (\mat D +
\overline{\mat{\Lambda}})^{-2} \mat V ^\top} \v{y} \notag \\
& = \frac{1}{2\sigma^2} \v{y} ^\top \parenth{\mat V (\overline{\mat{\Lambda}}^2+\overline{\mat{\Lambda}}
\mat D) (\mat D + \overline{\mat{\Lambda}})^ {-2} \mat V^\top} \v{y} +
\frac{1}{2\sigma^2} \v{y} ^\top \mat (\mat I_n-\mat V \mat V^\top) \v{y}
\notag \\
\label{eq:thm_1_step_2}
& =\frac{1}{2 \sigma^2} \v{y} ^\top \parenth{\mat V \overline{\mat{\Lambda}} (\mat D +
\overline{\mat{\Lambda}})^{-1} \mat V ^\top} \v{y} + \frac{1}{2\sigma^2} \v{y} ^\top (\mat
I_n - \mat V \mat V ^\top ) \v{y},
\end{align}
where step~(i) follows from \cref{eq:i_minus_xlam,eq:x_lam}. The
latter steps make use of the fact that diagonal matrices commute.
Next we note that $\v{y} \sim \mc{N}(\mat{X}\tvar_\star, \sigma^2\mb{I}_n)$,
and thus $\ensuremath{{\mathbb{E}}}[\v{y}^\top \mat A \v{y} ] = \tvar_\star^\top\mat{X}^\top \mat A \mat{X}
\tvar_\star + \sigma^2 \trace(\mat A)$. Using
\cref{eq:thm_1_step_1,eq:thm_1_step_2}, we find that
\begin{align}
T_2 & = \ensuremath{{\mathbb{E}}}\brackets{\frac{1}{2\sigma^2}\enorm{\v{y}-\mat{X}\widehat{\tvar}}^2 +
\frac{1} {2\sigma^2} \widehat{\tvar}^\top\mat{\Lambda}\widehat{\tvar}} \notag \\
& = \frac{1}{2\sigma^2} \tvar_\star^\top\mat{X}^\top \parenth{\mat V
\overline{\mat{\Lambda}} (\mat D + \overline{\mat{\Lambda}})^ {-1} \mat V^\top}\mat{X} \tvar_\star +
\frac{1}{2\sigma^2} [\sigma^2\trace(\mat V \overline{\mat{\Lambda}} (\mat D +
\overline{\mat{\Lambda}})^ {-1} \mat V^\top)] \notag \\
& \qquad\qquad\qquad +\frac{1}{2\sigma^2} \tvar_\star^\top\mat{X}^\top (\mat
I-\mat V\mat V^\top)\mat{X} \tvar_\star + \frac{1}{2\sigma^2}
[\sigma^2\trace(\mat I-\mat V\mat V^\top)] \notag \\
& \stackrel{(i)}{=} \frac{1}{2\sigma^2} \tvar_\star^\top\mat{X}^\top
\parenth{\mat V \overline{\mat{\Lambda}} (\mat D + \overline{\mat{\Lambda}})^ {-1} \mat V^\top}\mat{X}
\tvar_\star + \frac{1}{2\sigma^2} [\sigma^2\trace(\mat V \overline{\mat{\Lambda}} (\mat D
+ \overline{\mat{\Lambda}})^ {-1} \mat V^\top)]\label{eq:thm_1_step_3a} \\
& \qquad\qquad\qquad + 0 +\frac{1}{2}\cdot (n-d) \notag \\
& \stackrel{(ii)}{=} \frac1{2\sigma^2}\parenth{\v{w}^\top \mat D
\mat{\Lambda} (\mat D + \mat{\Lambda})^{-1} \v{w} + \sigma^2 \trace [\overline{\mat{\Lambda}}
(\mat D +\overline{\mat{\Lambda}})^{-1}]} +\frac{1}{2}\cdot (n-d) \notag \\
%
\label{eq:thm_1_step_3}
& = \frac{(n-d)}{2} +\frac{1}{2}\sumn[d]
\parenth{\frac{\evali\myvec_i^2 } {\sigma^2} + 1} \frac{\lambda_i}
{\lambda_i+\evali}
\end{align}
where step~(i) follows from the facts that the matrix $(\mat I_n -
\mat V\mat V^\top)$ is a projection matrix of rank $n-d$, and is
orthogonal to the matrix $\mat X$, i.e., $(\mat I_n - \mat V\mat
V^\top)\mat X = 0$. Step~(ii) follows from a similar computation as
that done to obtain \cref{eq:thm_1_step_2}, along with
claim~\eqref{eq:w_expand}, and the following identity for the matrix
trace
\begin{align*}
\trace(\mat V \overline{\mat{\Lambda}} (\mat D + \overline{\mat{\Lambda}})^{-1} \mat V^\top) =
\trace(\overline{\mat{\Lambda}} (\mat D + \overline{\mat{\Lambda}})^{-1} \mat V^\top\mat V ) =
\trace(\overline{\mat{\Lambda}} (\mat D + \overline{\mat{\Lambda}})^{-1}\mat I_d).
\end{align*}
\subsubsection{Proof of claim~\eqref{eq:t3} (term $T_3$):}
From the normalization of a multivariate Gaussian density, we have
\begin{align}
\label{eq:gauss_norm}
\frac{1}{(2\pi\sigma^2)^{n/2}} \int_{\v{y}\in\ensuremath{\mathbb{R}}^n} \exp\parenth{-
\frac{\v{y}^\top \mat A \v{y}}{2\sigma^2}} d\v{y}
= \sqrt{\det(\mat A^{-1})},
\end{align}
valid for any positive definite matrix $\mat A \in \ensuremath{\mathbb{R}}^ {n \times
n}$.
Putting together the definition~\eqref{eq:ridge_dist} of $\mrm{C}_{\mat{\Lambda}}$
and equation~\eqref{eq:thm_1_step_2}, we find that
\begin{align}
\mrm{C}_{\mat{\Lambda}} = \frac{1}{(2\pi\sigma^2)^{n/2}} \int_{\v{y}\in\ensuremath{\mathbb{R}}^n} \exp\parenth{-
\frac{\v{y}^\top \mat A_{\mat{\Lambda}} \v{y}}{2\sigma^2}} d\v{y}
\qtext{where}
\mat A_{\mat{\Lambda}} &= \parenth{\mat V \overline{\mat{\Lambda}} (\mat D + \overline{\mat{\Lambda}})^{-1}
\mat V^\top}
+ (\mat I_n-\mat V \mat V^\top) \notag\\
&= \mat I_n - \mat V \mat D (\mat D + \overline{\mat{\Lambda}})^{-1}\mat V^\top.
\label{eq:a_lammat}
\end{align}
The eigenvalues of the $n \times n$ matrix $\mat A_{\mat{\Lambda}}$
are given by
$\braces{\frac{\lambda_1}{\lambda_1+\evali[1]},
\frac{\lambda_2}{\lambda_2+\evali[2]}, \ldots, \frac{\lambda_d}{\lambda_d+\evali
[d]},
1, 1, \ldots, 1}$, where the multiplicity of the eigenvalue $1$ is $n-d$.
Finally, applying \cref{eq:gauss_norm}, we find that
\begin{align}
T_3 = \log \mrm{C}_{\mat{\Lambda}} =
\log\sqrt{\det(\mat A_{\mat{\Lambda}}^{-1})}
=
\frac12\sumn[d]\log\parenth{\frac{\evali+\lambda_i}{\lambda_i}}
\label{eq:thm_1_step_4}
\end{align}
and the claim follows.
\subsubsection{Proof of claims~\eqref{eq:t2} and \eqref{eq:t3} for the case $d>n$}
\label{ssub:proof_high_dim}
In this case, the dimensions of the matrices in the singular value decomposition~\eqref{eq:svd} changes.
The argument for the proof remains similar with suitable adaptations due
to the change in the size of the matrices. As a result, we only outline the main steps.
We write
\begin{align}
\label{eq:svd_new}
\mat X = \mat V \begin{bmatrix}
\sqrt{\widetilde{\mat D}} & \mat 0
\end{bmatrix} \mat U^\top
\quad\Longrightarrow \quad
\xmat^\top\xmat = \mat U \underbrace{\begin{bmatrix}
\widetilde{\mat D} & \mat 0 \\ \mat 0 & \mat 0
\end{bmatrix}}_{\mat D} \mat U^\top
\end{align}
where $\mat V \in \ensuremath{\mathbb{R}}^{n\times n}$, $\widetilde{\mat D} \in \ensuremath{\mathbb{R}}^{n\times
n}$ and $\mat U \in \ensuremath{\mathbb{R}}^{d\times d}$.
Note that the non-zero entries of the matrix $\mat D$ are precisely the
ones denoted by $\widetilde{\mat D}$.
Let $\overline{\mat{\Lambda}}_n = \diag(\lambda_1, \ldots, \lambda_n)$ denote the $n \times
n$ principal minor of the matrix $\overline{\mat{\Lambda}}$, where $\mat{\Lambda} = \mat U \overline{\mat{\Lambda}}
\mat U^\top$.
With these notations, we find that the claims~\eqref{eq:linear_algebra}
are replaced by
\begin{subequations}
\label{eq:linear_algebra_new}
\begin{align}
(\mat I_n - \mat{X} (\xmat^\top\xmat+\mat{\Lambda})^{-1} \mat{X}^\top)^2
&= \mat V \overline{\mat{\Lambda}}_n^2(\widetilde{\mat D} + \overline{\mat{\Lambda}}_n)^{-2} \mat V^\top
\label{eq:i_minus_xlam_high}\\
\mat{X}(\xmat^\top\xmat+\mat{\Lambda})^{-1} \mat{\Lambda} (\xmat^\top\xmat+\mat{\Lambda})^{-1} \mat{X}^\top
&= \mat V \widetilde{\mat D}\overline{\mat{\Lambda}}_n (\widetilde{\mat D}+\overline{\mat{\Lambda}}_n)^
{-2} \mat V^\top
\label{eq:x_lam_high}\\
\mat{X}(\xmat^\top\xmat+\mat{\Lambda})^{-1} \xmat^\top\xmat\tvar_\star &=
\mat V \begin{bmatrix}
\sqrt{\widetilde{\mat D}} & \mat 0
\end{bmatrix} (\mat D + \overline{\mat{\Lambda}})^{-1} \mat D
\underbrace{\mat U^\top \tvar_\star}_{=:\v{\myvec}}\notag
\\
&= \mat V \sqrt{\widetilde{\mat D}} (\widetilde{\mat D} + \overline{\mat{\Lambda}}_n)^{-1}
\widetilde{\mat D} \v{\myvec}_{1:n}
\label{eq:w_expand_high}
\end{align}
\end{subequations}
where $\v{\myvec}_{1:n}$ denotes the first $n$ entries of the vector $\v{\myvec}$.
The proof of these claims can be derived in a similar manner to that of
claims~\eqref{eq:linear_algebra} (see Appendix~\ref{sub:few_linear_algebra_simplifications}).
Applying \cref{eq:i_minus_xlam_high,eq:x_lam_high}, we find that the equation~\eqref{eq:thm_1_step_2}
is modified to
\begin{align*}
\frac{1}{2\sigma^2}&\enorm{\v{y}-\mat{X}\widehat{\tvar}}^2 +\frac{1}{2\sigma^2} \widehat{\tvar}^\top\mat{\Lambda}\widehat{\tvar}
= \frac{1}{2\sigma^2}\v{y}^\top \parenth{\mat V \overline{\mat{\Lambda}}_n (\widetilde{\mat
D} +
\overline{\mat{\Lambda}}_n)^{-1} \mat V^\top} \v{y}
\end{align*}
which along with \cref{eq:w_expand_high} implies that the equation~\eqref{eq:thm_1_step_3}
is now replaced by
\begin{align*}
T_2 &= \ensuremath{{\mathbb{E}}}\brackets{\frac{1}{2\sigma^2}\enorm{\v{y}-\mat{X}\widehat{\tvar}}^2 +
\frac{1}
{2\sigma^2} \widehat{\tvar}^\top\mat{\Lambda}\widehat{\tvar}}
= \frac{1}{2}\sumn[n] \parenth{\frac{\evali\myvec_i^2 }
{\sigma^2} + 1} \frac{\lambda_i}{\lambda_i+\evali}.
\end{align*}
Thus, we obtain the claimed expression~\eqref{eq:t2} for
$T_2$ when $d>n$.
Next, to prove~\eqref{eq:t3} for this case, we find that the matrix $\mat
A_{\mat{\Lambda}}$ (defined in equation~\eqref{eq:a_lammat}) for this case gets
modified to
\begin{align*}
\mat A_{\mat{\Lambda}} = \mat I_n - \mat V \mat D (\mat D + \overline{\mat{\Lambda}})^{-1}\mat V^\top.
\end{align*}
Since $\mat V\mat V^\top = \mat I_n$, we find that the eigenvalues of the
$n\times n$ matrix $\mat A_{\mat{\Lambda}}$ are given by $\braces{\frac{\lambda_1}{\evali [1]+\lambda_1},\ldots,\frac{\lambda_n}{\evali
[n]+\lambda_n}}$. Therefore, we conclude that
\begin{align*}
T_3 = \log \mrm{C}_{\mat{\Lambda}} =
\log\sqrt{\det(\mat A_{\mat{\Lambda}}^{-1})}
=
\frac12\sumn[n]\log\parenth{\frac{\evali+\lambda_i}{\lambda_i}}.
\end{align*}
\subsubsection{Proof of claims~\eqref{eq:i_minus_xlam} and ~\eqref{eq:i_minus_xlam_high}}
\label{sub:few_linear_algebra_simplifications}
For completeness, we discuss the proofs of the linear-algebra claims~\eqref{eq:linear_algebra}
and \eqref{eq:linear_algebra_new}.
Here we establish the claim~\eqref{eq:i_minus_xlam} (for $n>d$) and \eqref{eq:i_minus_xlam_high}
(for $n<d$). The other claims in the equations~\eqref{eq:linear_algebra}
and \eqref{eq:linear_algebra_new} can be derived
in a similar fashion.
Note that for both cases $n>d$ and $n<d$, our notations~\eqref{eq:svd} and
\eqref{eq:svd_new} are set-up such that
\begin{align*}
(\xmat^\top\xmat+\mat{\Lambda})^{-1} = \mat U (\mat D + \overline{\mat{\Lambda}})^{-1} \mat U^\top,
\end{align*}
where the inverse is well-defined since $\overline{\mat{\Lambda}} = \diag(\lambda_1, \ldots,
\lambda_d)$ is assumed to be a positive definite matrix.
We use the fact that diagonal matrices commute, several times in our arguments.
\paragraph{Proof of claim~\eqref{eq:i_minus_xlam}:}
Using the decomposition~\eqref{eq:svd} for $n>d$ and noting that $\mat U^\top
\mat U = \mat I_d$, we find that
\begin{align}
(\mat I_n - \mat{X} (\xmat^\top\xmat+\mat{\Lambda})^{-1} \mat{X}^\top)^2
&= (\mat I_n - \mat V \sqrt{\mat D} \mat U^\top \mat U (\mat D + \overline{\mat{\Lambda}})^{-1}
\mat U^\top \mat U \sqrt{\mat D} \mat V^\top)^2 \notag\\
&= (\mat I_n-\mat V\mat V^\top +\mat V \mat V^\top
- \mat V \sqrt{\mat D}(\mat D + \overline{\mat{\Lambda}})^{-1}
\sqrt{\mat D} \mat V^\top)^2 \notag\\
&= (\mat I_n-\mat V\mat V^\top +\mat V (\mat I_d -\sqrt{\mat D}(\mat D
+ \overline{\mat{\Lambda}})^{-1}
\sqrt{\mat D}) \mat V^\top)^2 \notag\\
&= (\mat I_n-\mat V\mat V^\top +\mat V \overline{\mat{\Lambda}}(\mat D + \overline{\mat{\Lambda}})^{-1}
\mat V^\top )^2 \notag\\
&= \mat I_n-\mat V\mat V^\top +\mat V \overline{\mat{\Lambda}}^2(\mat D + \overline{\mat{\Lambda}})^{-2}
\mat V^\top,
\notag
\end{align}
where the last step follows from the following facts (a) $\mat I-\mat V\mat
V^\top$ is a projection matrix, (b) $(\mat I-\mat V\mat V^\top) \mat V = \mat
0$, and (c) $\mat V^\top\mat V = \mat I_d$.
\paragraph{Proof of claim~\eqref{eq:i_minus_xlam_high}:}
Note that for the decomposition~\eqref{eq:svd_new}, we have $\mat V\mat
V^\top = \mat V^\top \mat V = \mat I_n$ and $\mat U \mat U^\top = \mat U^\top \mat
U = \mat I_d$. Using these facts along with the notation $\overline{\mat{\Lambda}}_n
=\diag(\lambda_1, \ldots, \lambda_n)$ for $d>n$, we find that
\begin{align}
(\mat I_n - \mat{X} (\xmat^\top\xmat+\mat{\Lambda})^{-1} \mat{X}^\top)^2
&= (\mat I_n - \mat V \begin{bmatrix}
\sqrt{\widetilde{\mat D}} & \mat 0
\end{bmatrix} \mat U^\top \mat U (\mat
D + \overline{\mat{\Lambda}})^{-1}
\mat U^\top \mat U \begin{bmatrix}
\sqrt{\widetilde{\mat D}} \\
\mat 0
\end{bmatrix} \mat V^\top )^2\notag\\
&= (\mat I_n - \mat V \begin{bmatrix}
\sqrt{\widetilde{\mat D}} & \mat 0
\end{bmatrix} (\mat D + \overline{\mat{\Lambda}})^{-1}
\begin{bmatrix}
\sqrt{\widetilde{\mat D}} \\
\mat 0
\end{bmatrix} \mat V^\top )^2\notag\\
&=(\mat I_n - \mat V \sqrt{\widetilde{\mat D}} (\widetilde{\mat D}+\overline{\mat{\Lambda}}_n)^{-1}
\sqrt{\widetilde{\mat D}}
\mat V^\top)^2 \notag\\
&=(\mat V \mat V^\top - \mat V \widetilde{\mat D} (\widetilde{\mat
D} + \overline{\mat{\Lambda}}_n)^{-1} \mat V^\top)^2 \notag \\
&=(\mat V(\mat I_n- \widetilde{\mat D} (\widetilde{\mat
D} + \overline{\mat{\Lambda}}_n)^{-1}) \mat V^\top)^2 \notag\\
&=\mat V \overline{\mat{\Lambda}}_n^2 (\widetilde{\mat
D} + \overline{\mat{\Lambda}}_n)^{-2} \mat V^\top,
\notag
\end{align}
which yields the claim.
\subsection{Proof of \cref{thm:lam_opt}}
\label{sub:proof_of_thm:lam_opt}
For $\widehat{\tvar} = \widehat{\tvar}_{\mat{\Lambda}}(\v{y})$, we claim that
\begin{align}
\label{eq:in_sample_mse_exp}
\frac{1}{n}\ensuremath{{\mathbb{E}}}\brackets{\enorm{\mat{X}\widehat{\tvar} -\mat{X}\tvar_\star }^2}
= \frac{1}{n}\sumn[\min\braces{n, d}] \underbrace{\frac{\lambda_i^2\evali\myvec_i^2
+ \sigma^2
\evali^2}{(\evali+\lambda_i)^2}}_{=:h_i(\lambda_i)}
\end{align}
Let us assume the claim as given at the moment, and prove \cref{eq:opt_lam_insample_mse}.
Recalling the optimal choice $\lambda_{i, {\textrm{opt}}}$
of the regularization parameter for \ensuremath{\textrm{MDL-COMP}}\ from equation~\eqref{eq:lam_opt_mdl},
and noting that the in-sample MSE
is separable in each term $\lambda_i$, it remains
to show that
\begin{align}
\label{eq:g_opt}
\argmin_{\lambda_i \in[0, \infty)} h_i(\lambda_i) = \lambda_{i, {\textrm{opt}}}
= \frac{\sigma^2}{\myvec_i^2}
\end{align}
To this end, we note that
\begin{align*}
h_i'(\lambda_i) = 0
\quad\Longleftrightarrow\quad
2\frac{\evali^2\myvec_i^2\lambda_i}{(\evali+\lambda_i)^3}
-2\frac{\evali^2\sigma^2}{(\evali+\lambda_i)^3}
= 0
\quad\Longleftrightarrow\quad
\widetilde{\lambda}_{i, \textrm{opt}} = \frac{\sigma^2}{\myvec_i^2}.
\end{align*}
On the boundary of feasible values of $\lambda_i = [0,
\infty)$, we have $h_i(0) = \sigma^2$, and $h_i(\lambda_i) \to \evali\myvec_i^2$
as $\lambda_i\to
\infty$. Noting that
\begin{align*}
h_i(\widetilde{\lambda}_i^{\textrm{opt}}) = \frac{\evali\myvec_i^2\sigma^2}
{\evali\myvec_i^2+\sigma^2}
\leq \min\braces{\evali\myvec_i^2, \sigma^2},
\end{align*}
yields the claim~\eqref{eq:g_opt}.
Next we establish the bound~\eqref{eq:ropt_bounds_insample_mse} on the
fixed design prediction error. Using $\lambda_i$ as a convenient
shorthand for $\lambda_{i, {\textrm{opt}}}$, we substitute it into the
RHS of \cref{eq:in_sample_mse_exp}, thereby finding that
\begin{align*}
\frac{1}{n} \ensuremath{{\mathbb{E}}}\brackets{\enorm{\mat{X} \widehat{\tvar}_{\mat{\Lambda}_{\textrm{opt}}} - \mat{X}
\tvar_\star }^2} & = \frac{1}{n} \sumn[\min\braces{n, d}] \frac{ (
\frac{\sigma^2}{\myvec_i^2})^2 \evali \myvec_i^2 + \sigma^2
\evali^2}{(\evali + (\frac{\sigma^2}{\myvec_i^2} ) )^2} \\
& = \frac{\sigma^2}{n} \sumn[\min\braces{n, d}] \frac{1}{1 +
\frac{\sigma^2}{\evali \myvec_i^2}}.
\end{align*}
We now make note of the elementary inequality $x \leq -\log(1- x)$
valid for $x \in [0, 1)$. Applying this inequality with $x = (1 +
\frac{\sigma^2}{\evali \myvec_i^2})^{-1}$, we have $-\log(1-x) =
\log (1 + \tfrac{\evali \myvec_i^2}{\sigma^2})$, and hence
\begin{align*}
\frac{1}{n} \ensuremath{{\mathbb{E}}} \brackets{\enorm{\mat{X} \widehat{\tvar}_{\mat{\Lambda}_{\textrm{opt}}} - \mat{X}
\tvar_\star}^2 } & \leq \frac{\sigma^2}{n} \sumn[\min\braces{n, d}] \log
\parenth{ 1 + \frac{\evali\myvec_i^2}{\sigma^2}} =
\frac{\sigma^2}{n} \ensuremath{\mc R_{\textrm {opt}}},
\end{align*}
where we have used $\ensuremath{\mc R_{\textrm {opt}}}$ as a shorthand for the optimal redundancy.
\paragraph{Proof of \cref{eq:in_sample_mse_exp}:}
There are two cases to be considered, namely $d > n$ and $d < n$.
Both cases can be handled together by using the linear-algebraic
claims~\eqref{eq:linear_algebra} and \eqref{eq:linear_algebra_new} as
needed. Following steps similar to those in the proof of
Theorem~\ref{thm:complexity_expressions}, we find that
\begin{align*}
\ensuremath{{\mathbb{E}}} \brackets{\enorm{\mat{X}\widehat{\tvar} -\mat{X}\tvar_\star }^2} &= \ensuremath{{\mathbb{E}}}
\brackets{\enorm{\mat{X}(\xmat^\top\xmat+\mat{\Lambda})^{-1} \mat{X}^\top \v{y} -\mat{X}\tvar_\star
}^2} \\ &= \enorm{\mat{X}(\xmat^\top\xmat+\mat{\Lambda})^{-1} \xmat^\top\xmat\tvar_\star -\mat{X}\tvar_\star
}^2 + \ensuremath{{\mathbb{E}}}\brackets{\enorm{\mat{X}(\xmat^\top\xmat+\mat{\Lambda})^{-1}
\mat{X}^\top\noise[]}^2} \\
& \stackrel{(i)}{=} \enorm{\mat V \sqrt{\mat D} ((\mat D+\overline{\mat{\Lambda}})^{-1}
\mat D -\mat I)\v{\myvec} }^2 + \ensuremath{{\mathbb{E}}}\brackets{\enorm{\mat V
\sqrt{\mat D}(\mat D + \overline{\mat{\Lambda}})^{-1} \sqrt{\mat D} \mat V^\top
\noise[]}^2} \\
& = \enorm{\sqrt{\mat D} ((\mat D+\overline{\mat{\Lambda}})^{-1} \overline{\mat{\Lambda}})\v{\myvec}
}^2 + \sigma^2\trace\parenth{\sqrt{\mat D} (\mat D + \overline{\mat{\Lambda}})^{-1}
\mat D (\mat D+\overline{\mat{\Lambda}})^{-1} \sqrt{\mat D}} \\
& = \sumn[\min\braces{n, d}] \parenth{\frac{ \evali \lambda_i^2
\myvec_i^2}{(\evali + \lambda_i)^2} + \frac{\sigma^2
\evali^2}{(\evali + \lambda_i)^2}},
\end{align*}
and we are done.
\subsection{Proof of Theorem~\ref{thm:mdl_kernel}}
\label{sub:proof_of_theorem_thm:mdl_kernel}
Let us introduce the shorthand $\v{y^\star} = (f^\star(x_1), \ldots,
f^\star(x_n))^\top$. Given data $\v{y}$ generated according to the
model~\eqref{eq:kernel_Generative_model}, we have
$\v{y}\sim\mc{N}(\v{y^\star}, \sigma^2\mb{I}_n)$. Let $p(\v{y};\v{y^\star})$
denote the corresponding density of $\v{y}$. With this notation, we can
write
\begin{align*}
\kull{\mathbb{P}_{f^\star}}{\mathbb{Q}_{\lambda}} &=
\ensuremath{{\mathbb{E}}}_{\v{y}}\brackets{\log{\frac{p(\v{y};\v{y^\star})}
{q_{\lambda}(\v{y})} } } \\
& = \underbrace{-\ensuremath{{\mathbb{E}}}_{\v{y}}\brackets{\frac{1}{2\sigma^2} \enorm{\v{y} -
\v{y^\star}}^2}}_{=:T_1} + \underbrace{\ensuremath{{\mathbb{E}}}_{\v{y}}
\brackets{\frac{1}{2 \sigma^2}\enorm{\v{y} - \mat{K} \widehat{\tvar}}^2 +
\frac{\lambda}{2 \sigma^2} \widehat{\tvar} ^\top \mat{K} \widehat{\tvar}}}_{=:T_2} +
\underbrace{\log \mrm{C}_{\lambda}}_{=:T_3}.
\end{align*}
Note that the term $T_1 = - n/2$ by definition of our noisy
observation model. Turning to the term $T_2$, we substitute the
expression~\eqref{eq:kernel_ridge2} for $\widehat{\tvar}$, thereby finding that
\begin{align*}
\enorm{\v{y}-\mat{K}\widehat{\tvar}}^2 + \lambda\enorm{\widehat{\tvar}}^2 &= \v{y}^\top \lambda^2
(\mat{K} + \lambda \mat{I})^ {-2} \v{y} + \lambda \v{y}^\top (\mat{K} + \lambda \mat{I})^{-1} \mat{K} (\mat{K} + \lambda \mat{I})^{-1}
\v{y} \\ &= \lambda\v{y}^\top (\mat{K} + \lambda \mat{I})^{-1} \v{y}
\end{align*}
and thus
\begin{align*}
T_2 =\frac{1}{2\sigma^2} \ensuremath{{\mathbb{E}}}[\enorm{\v{y}-\mat{K}\widehat{\tvar}}^2 + \lambda\enorm{\widehat{\tvar}}^2]
= \frac{\lambda}{2\sigma^2} \v{y^\star}^\top (\mat{K} + \lambda \mat{I})^{-1} \v{y^\star} + \frac12\sum_
{i=1}^
{n} \frac{\lambda}{\evali+\lambda}.
\end{align*}
Moreover, using an argument similar to that used in \cref{eq:thm_1_step_4},
we can write
\begin{align}
T_3 = \log \mrm{C}_{\lambda} =
\log\sqrt{\det(\frac{1}{\lambda} (\mat{K} + \lambda \mat{I}))}
=
\frac12\sumn[n]\log\parenth{\frac{\evali+\lambda_i}{\lambda_i}}.
\notag
\end{align}
Using the eigenvalue decomposition $\mat{K} = \mat U \mat D \mat U^\top$ where
$\mat D = \diag(\evali[1], \ldots, \evali[n]) $,
and setting $\alpha := \mat U^\top \v{y^\star}$, we thus find that
\begin{align}
\label{eq:mdl_kridge}
\frac{1}{n}\kull{\mb{P}_{f^\star}}{\mathbb{Q}_{\lambda}}
= \frac{1}{2n}\sumn \frac{\lambda}{\lambda+\evali}\parenth{\frac{\alpha_i^2}{\sigma^2}+1}
+ \frac{1}{2n}\sumn \log\parenth{\frac{\evali}{\lambda}+1}-\frac{1}{2}.
\end{align}
The remaining proof make use of arguments similar to those in
\citet[Lemma 7]{raskutti2014early}. Recall the
decomposition~\eqref{eq:mercer_kernel} for the kernel $\mc{K}$. For
any function $f^\star \in \mb{H}$, we can write
\begin{align*}
f^\star(x) = \sum_{k=1}^{\infty} \sqrt{\mu_k} a_k \phi_k(x)
\qtext{with} a_k = \frac{1}{\sqrt{\mu_k}} \int f(z) \phi_k(z)d\nu(z)
\qtext{and} \enorm{f^\star}^2_{\mb{H}} = \sum_{k=1}^\infty a_k^2,
\end{align*}
where $\nu$ denotes the marginal distribution of the covariates.
Define the linear operators $\Psi_{\mat{X}}:\ell^2(\mb{N}) \to \ensuremath{\mathbb{R}}^n$
as $\Psi_{\mat{X}}[i, j] = \phi_i(x_j)$ for $i \in \mb{N}$ and $j \in
[n]$. and the diagonal linear operator $\mathfrak{D}:\ell^2(\mb{N})
\to \ell^2 (\mb{N})$ as $\mathfrak{D}[i, i]=\mu_i$ and
$\mathfrak{D}[i, j]=0$ if $i \neq j$ for $i, j \in \mb{N}$. Given
this representation, we can rewrite the vector $\v{y^\star}$ and the kernel
matrix $\mat{K}$ as follows
\begin{align*}
\v{y^\star} =\Psi_{\mat{X}} \mathfrak{D}^{\frac12} a
\qtext{and}
\mat{K} = \Psi_{\mat{X}} \mathfrak{D} \Psi_{\mat{X}}^\top
\end{align*}
Combining the latter representation with $\mat{K} = \mat U \mat D \mat U^\top$,
we find that there exists an operator $\Gamma: \ell^2(\mb{N})\to \ensuremath{\mathbb{R}}^n$
with adjoint $\Gamma^*:\ensuremath{\mathbb{R}}^n \to \ell^{2}(\mb{N})$ and $\Gamma\Gamma^*=
\mat I_{n}$ such that
\begin{align*}
\Psi_{\mat{X}} \mathfrak{D}^{\frac12} = \mat U \mat D^{\frac12} \Gamma
\implies \alpha = \mat U^\top \v{y^\star} = \mat U^\top \Psi_{\mat{X}} \mathfrak{D}^{\frac12} a
= \mat U^\top \mat U \mat D^{\frac12} \underbrace{\Gamma a}_{=:\beta}
= \mat D^{\frac12}\beta.
\end{align*}
Note that $\beta \in \ensuremath{\mathbb{R}}^n$ and we have $\alpha_i^2
= \evali \beta_i^2$. Furthermore,
\begin{align}
\label{eq:beta_norm}
\sumn\beta_i^2 = \enorm{\Gamma a}_2^2\leq \enorm{a}_2^2 = \enorm{f^\star}_{\mb{H}}^2,
\end{align}
since $\Gamma$ is a unitary operator. Thus, we can
rewrite~\eqref{eq:mdl_kridge} as
\begin{align}
\frac{1}{n} \kull{\mb{P}_{f^\star}}{\mathbb{Q}_{\lambda}} & = \frac{1}{2n}
\sumn \frac{\lambda}{\lambda + \evali}
\parenth{\frac{\evali\beta_i^2}{\sigma^2}+1} + \frac{1}{2n} \sumn
\log\parenth{\frac{\evali}{\lambda}+1}-\frac{1}{2} \notag \\
& = \frac{1}{2n} \lambda \sumn
\frac{\evali}{\lambda+\evali}\frac{\beta_i^2}{\sigma^2} + \frac{1}{2n}
\sumn \log\parenth{\frac{\evali}{\lambda}+1} + \frac{1}{2n} \sumn
\frac{\lambda}{\lambda+\evali}- \frac{1}{2} \notag \\
& \sless{(i)} {\frac{\lambda}{2n} \parenth{\frac{\sumn
\beta_{i}^2}{\sigma^2}} + \frac{1}{2n}\sumn \log\parenth{
\frac{\evali}{\lambda}+1}} \notag\\
\label{eq:final_bound_ropt_kernel}
& \sless{(ii)} {\frac{\lambda}{2n} \frac{
\enorm{f^\star}^2_{\mb{H}}}{\sigma^2} + \frac{1}{2n} \sumn \log
\parenth{ \frac{\evali}{\lambda} + 1}},
\end{align}
where step~(i) follows from the fact that $\max\braces{\evali,
\lambda}/(\lambda+\evali)\leq 1$, and step~(ii) from the
bound~\eqref{eq:beta_norm}. The proof is now complete.
\paragraph{Remark:}
Let us discuss some scenarios in which the inequalities in (i) and
(ii) are tight after optimizing the
bound~\eqref{eq:final_bound_ropt_kernel} over $\lambda$. Call the
optimal choice $\lambda_{\mrm{opt}}$, and let $i^\star$ denote the index
such that $\lambda_{\mrm{opt}} \approx \evali[i^\star]$. The inequality
in step~(i) is relatively tight when: (a)
$\sum_{i=1}^{n}\lambda/(\lambda+\evali) \approx n$; and (b)
$\enorm{\beta}_2^2 \approx \sum_{j\leq i^\star} \beta_j^2$. Condition
(a) holds if the eigenvalue $\braces{\evali}$ have suitablly rapid
decay. whereas condition (b) holds when $i^\star < n$ and the
$\{\beta_j\}$ sequence is suitably decaying.
In order for inequality~(ii) to be relatively tight, we need the
inequality~\eqref{eq:beta_norm} to be relatively tight. This property
holds when we can obtain a good approximation of the
sum~\eqref{eq:mercer_kernel} by summing only its first $n$ terms; in
this case, $\Gamma$ and $\Gamma^\star$ are simply $n \times n$ unitary
matrices. This property holds when either the eigenvalues $\{\mu_k\}$
decay quickly, or the kernel $\mc{K}$ has a finite rank strictly
smaller than $n$, in which case $\mu_k=0$ for $k \geq n$. Note that
the different decay conditions covered in
Corollary~\ref{cor:mdl_kernel_smooth} are all sufficient for these
kernel conditions to hold.
\subsection{Proof of \cref{thm:rmt_expressions}}
\label{sub:proof_of_thm:rmt_expressions}
Our result involves the function
\begin{align}
\label{eq:g_fun}
g(a, b) := \frac{1}{4} \parenth{\sqrt{\mrm{snr} (1 + \sqrt{\gamma} )^2 +
1} - \sqrt{\mrm{snr}(1 - \sqrt{\gamma})^2 + 1}}^2, \qtext{for} a, b >
0.
\end{align}
The proof of this theorem makes use of the analytical expression of
$\ensuremath{\textrm{MDL-COMP}}$ from Theorem~\ref{thm:complexity_expressions} and few random
matrix theory results. Let $\mb{F}_d: a \mapsto
\frac{1}{d}\sumn[d]\mathbf{1}(a\leq\evali)$ denote the empirical
distribution of the eigenvalues of the matrix $\xmat^\top\xmat$.
First, we note that since $\tvar_\star$ is assumed to be drawn from
rotationally invariant distribution, we can rewrite the MDL-complexity
expression as
\begin{align*}
\ensuremath{{\mathbb{E}}}_{\tvar_\star}[\ensuremath{\mc R_{\textrm {opt}}}] = \ensuremath{{\mathbb{E}}}_{\v{\myvec}}\brackets{\frac{1}{n}
\sumn[\min\braces{n, d}] \log \parenth{1 + \frac{\evali\myvec_i^2}
{\sigma^2}}} & \stackrel{(i)}{\leq} \brackets{\frac{1}{n}
\sumn[\min\braces{n, d}] \log \parenth{1 + \frac{\evali
\ensuremath{{\mathbb{E}}}_{\v{\myvec}}[\myvec_i^2]} {\sigma^2}}} \\
& \stackrel{(ii)}{=} \frac{1}{n} \sumn[d] \log\parenth{1 + \evali
\cdot \mrm{snr}} \\
& = \frac{d}{n} \parenth{\frac{1}{d} \sumn[d] \log \parenth{1+\evali
\cdot \mrm{snr}}} \\
& = \frac{d}{n} \cdot \int_{Z=0}^\infty \log(1+Z\cdot \mrm{snr}) d \mb{F}_d
(Z),
\end{align*}
where step~(i) follows from Jensen's inequality, i.e.,
$\ensuremath{{\mathbb{E}}}[\log(1+W)] \leq \log (1+\ensuremath{{\mathbb{E}}}[W])$, and step~(ii) follows from
the fact that $\tvar_\star$ is drawn from rotationally-invariant
distribution and hence $\v{\myvec} = \mat U^\top \tvar_\star \stackrel{d}{=}
\tvar_\star$, and that $\ensuremath{{\mathbb{E}}}[\myvec_i^2] = \ensuremath{{\mathbb{E}}}[\enorm{\tvar_\star}^2]/d$.
Next, we recall a standard result from random matrix theory. Under
the assumptions of Theorem~\ref{thm:rmt_expressions}, as $d, n\to
\infty$ with $d/n\to \gamma$, the empirical distribution $\mb{F}_d$ of
the eigenvalues of the matrix $\xmat^\top\xmat$ converges weakly, almost surely
to a nonrandom limiting distribution $\mb{MP}_\gamma$ with density
\begin{align}
\label{eq:mp_law}
m_{\gamma}(a) = \parenth{1-\frac{1}{\gamma}}_{+} \delta(a) +
\frac{\sqrt{(a-b_1)_+(b_2-a)_+}}{2\pi\gamma a}, \qtext{where $b_1 =
(1-\sqrt\gamma)^2$ and $b_2 = (1+\sqrt\gamma)^2$.}
\end{align}
This distribution is also known as the
Mar$\breve{\textrm{c}}$enko-Pastur law with ratio index $\gamma$. (For
background, see the
papers~\citep{marvcenko1967distribution,silverstein1995strong}, or
Theorem 2.35 in the book~\citep{tulino2004random})
Next, we claim that as $d, n\to \infty$ with $d/n\to \gamma$, we have
\begin{align}
\label{eq:rmt_claim}
\ensuremath{\mc R_{\textrm {opt}}}
= \frac{d}{n} \cdot \int_{0}^\infty \log(1+Z\cdot \mrm{snr}) d\mb{F}_d(Z)
\longrightarrow
\gamma\cdot \ensuremath{{\mathbb{E}}}_{Z\sim \mb{MP}_\gamma}\brackets{\log(1+\mrm{snr}\cdot Z)},
\end{align}
almost surely. Assuming this claim as given at the moment, let us now
complete the proof. In general, the analytical expressions for
expectations under the distribution $\mb{MP}_{\gamma}$ are difficult
to compute. However, the expectation $\ensuremath{{\mathbb{E}}}_{Z\sim \mb{MP}_\gamma}
\brackets{\log(1+\gamma Z)}$ is known as the Shannon transform and
there exists a closed form for it (see Example
2.14~\citep{tulino2004random})\footnote{The transform in the
reference~\citep{tulino2004random} uses the $\log_2$ (base-$2$
logarithm) notation. The results stated here have been adapted for
$\log_e$ (base-$e$, natural logarithm) in a straightforward manner.}:
\begin{align}
\ensuremath{{\mathbb{E}}}_{Z\sim \mb{MP}_\gamma}\brackets{\log(1+\mrm{snr}\cdot Z)}
=: \mc{V}_Z(\mrm{snr})
= \log\parenth{1+\mrm{snr}-\delta} + \frac{1}{\gamma}\log\parenth{1+\gamma\cdot\mrm{snr}
-\delta} - \frac{\delta}{\mrm{snr}\cdot \gamma},
\label{eq:shannon_transform}
\end{align}
where $\delta = g(\mrm{snr}, \gamma)$ and the function $g$ was defined in equation~\eqref{eq:g_fun}.
Putting the \cref{eq:rmt_claim,eq:shannon_transform} together yields the
expression~\eqref{eq:mdl_complexity_rmt} stated in Theorem~\ref{thm:rmt_expressions}.
\paragraph{Proof of claim~\eqref{eq:rmt_claim}:}
This part makes use of the Portmanteau theorem and some known results
from~\cite{bai2008limit}. Recalling the constant $b_2 := (1+\sqrt
\gamma)^2$ from equation~\eqref{eq:mp_law}, for $a \in [0, \infty)$,
consider the function $f(a) \log (1+\mrm{snr}\cdot a) \mathbf{1} (a\leq
2b_2) $ As $n, d\to \infty$ with $d/n\to\gamma$, we have
\begin{align*}
\int_{0}^\infty f(Z) d\mb{F}_d(Z) \stackrel{(i)}{=} \int_{0}^{2b_2}
f(Z) d\mb{F}_d(Z) \stackrel{(ii)}{\longrightarrow} \int_{0}^{2b_2}
f(Z) d\mb{MP}_\gamma(Z) &\stackrel{(iii)}{=} \int_{0}^{\infty} f(Z)
d\mb{MP}_\gamma(Z) \\ &= \ensuremath{{\mathbb{E}}}_{Z\sim\mb{MP}_\gamma}[1+\log(\mrm{snr}\cdot
Z)],
\end{align*}
where steps~(i) and (iii) follow from the definition of $f$, i.e.,
$f(Z)=0$ for any $Z>2b+2$. Moreover, step~(ii) follows from applying
the Portmanteau theorem, which states that the weak almost sure
convergence~\eqref{eq:mp_law} implies the convergence in expectation
for any bounded function, and $f$ is a bounded function. Finally, we
argue that for large enough $n$, we have
\begin{align*}
\int_{0}^\infty \log(1+Z\cdot \mrm{snr}) d\mb{F}_d(Z)
\stackrel{(iv)}{=} \int_{0}^{2b_2} \log(1+Z\cdot \mrm{snr})
d\mb{F}_d(Z) \stackrel{(v)}{=} \int_{0}^\infty f(Z) d\mb{F}_d(Z)
\end{align*}
In order to establish step~(iv), we invoke a result from the
work~\citep{bai2008limit} (Corollary 1.8). It states that for large
enough $n$, the largest eigenvalue of the matrix $\xmat^\top\xmat$ is bounded
above by $2(1+\sqrt\gamma)^2$ almost surely, and thus, we can restrict
the limits of the integral on the LHS to the interval $[0, 2b_2]$.
Step~(v) follows trivially from the definition of the function $f$.
Putting the pieces together yields the claim~\eqref{eq:rmt_claim}.
\subsection{Proof of \cref{thm:minimax_codelength}}
\label{sub:proof_of_thm:minimax_codelength}
The proof of this theorem makes use of the algebra used in previous
proofs, and hence we simply illustrate the main steps. We have
\begin{align*}
\mathbb{E} \brackets{\log \parenth {\frac{1}{q_{\mat{\Lambda}}(\v{y})}}} & = \ensuremath{{\mathbb{E}}}
\brackets{\frac{1}{2\sigma^2}\enorm{\v{y} - \mat{X} \widehat{\tvar}}^2 +
\frac{1}{2\sigma^2} \widehat{\tvar} ^\top \mat{\Lambda} \widehat{\tvar}} + \log \mrm{C}_{\mat{\Lambda}},
\end{align*}
where \mbox{$\log \mrm{C}_{\mat{\Lambda}} = \frac{1}{2} \sumn[\min\braces{n, d}]
\log\parenth{\frac{\evali+\lambda_i}{\lambda_i}}$.} Repeating
arguments similar to those in \cref{eq:thm_1_step_3a,eq:thm_1_step_3},
we find that
\begin{align*}
\notag & \ensuremath{{\mathbb{E}}}\brackets{\frac{1}{2 \sigma^2} \enorm{ \v{y} - \mat{X}
\widehat{\tvar}}^2 + \frac{1}{2 \sigma^2} \widehat{\tvar} ^\top \mat{\Lambda}\widehat{\tvar}} \\
& = \frac{1}{2\sigma^2} \tvar_\star ^\top \mat{X} ^\top \parenth{\mat V \overline{\mat{\Lambda}}
(\mat D + \overline{\mat{\Lambda}})^ {-1} \mat V^\top} \mat{X} \tvar_\star +
\frac{1}{2\sigma^2}\trace \brackets{\textrm{Var}(\v{y}\vert\mat{X}) \mat
V \overline{\mat{\Lambda}} (\mat D + \overline{\mat{\Lambda}})^{-1} \mat V^\top } \notag \\
& \qquad\qquad\qquad + \frac{1}{2\sigma^2} \trace
\brackets{\textrm{Var}(\v{y} \vert \mat{X})(\mat I - \mat V \mat V^\top)}
\notag \\
& \stackrel{(i)}{\leq} \frac1{2\sigma^2}\parenth{\v{w} ^\top \mat D
\mat{\Lambda} (\mat D + \mat{\Lambda}) ^{-1} \v{w}} + \frac{1}{2 \sigma^2}\trace
\brackets{\sigma^2 \mat I_n {\textrm{Var}(\v{y} \vert \mat{X})} \mat V
\overline{\mat{\Lambda}} (\mat D + \overline{\mat{\Lambda}})^{-1} \mat V ^\top } \notag \\
& \qquad\qquad\qquad + \frac{1}{2 \sigma^2} \trace
\brackets{\sigma^2 \mat I_n (\mat I - \mat V \mat V ^\top)} \notag \\
& =\frac{(n -\min \braces{n, d})}{2} +\frac{1}{2}\sumn[d]
\parenth{\frac{\evali \myvec_i^2 } {\sigma^2} + 1} \frac{\lambda_i}
{\lambda_i + \evali}
\end{align*}
where step~(i) follows from the following linear algbera fact: For
matrices $\mat A, \mat B, \mat C \succeq 0$, if $\mat A \succeq \mat
B$, then $\trace[\mat{AC}] \geq \trace[\mat{BC}]$. Moreover, noting
that in step~(i), we have equality when $\text{Var}(\v{y}\vert\mat{X}) =
\sigma^2 \mat I_n$. Putting the pieces together, we conclude that
\begin{align*}
\max_{\P \in \mc{P}_{\textrm{bndvar}}} \mathbb{E} \brackets{\log
\parenth{\frac{1}{q_{\mat{\Lambda}}(\v{y})}}} = \frac{(n - \min
\braces{n, d})}{2} + \frac{1}{2}\sumn[d] \parenth{\frac{\evali
\myvec_i^2 } {\sigma^2} + 1} \frac{\lambda_i} {\lambda_i +
\evali} + \frac{1}{2} \sumn[\min\braces{n, d}] \log \parenth{\frac{\evali +
\lambda_i}{\lambda_i}}.
\end{align*}
As function of $\braces{\lambda_i}$ in comparison to the function
\cref{eq:thm_1_kull}, this objective is a simply shifted by a
constant. Consequently, it admits the same minimizer
\begin{align*}
\arg \min_{\mathbb{Q}_{\mat{\Lambda}} \in \mc{Q}_{\mrm{Ridge}}} \max_{\P \in
\mc{P}_{\textrm{bndvar}}} \mathbb{E} \brackets{\log \parenth{\frac{1}{q_{\mat{\Lambda}}(\v{y})}}}
= \mathbb{Q}_{\mat{\Lambda}_{\textrm{opt}}},
\end{align*}
as claimed.
\subsection{Proof of Corollary~\ref{cor:mdl_kernel_smooth}}
\label{sub:proof_of_cref_cor_mdl_kernel_smooth}
We prove the bounds for polynomial and exponential decay of
eigenvalues separately.
\subsubsection{Proof with polynomial decay of eigenvalues}
When $\mc{K}(x, x)=1$, we have $\trace(\mat{K}) = \sum_{i=1}^n\evali =
n$. Thus, with $\evali \precsim i^{-2\alpha}$, we can conclude that
$\evali \leq c_\alpha n i^{-2\alpha} $ where
$c_{\alpha}:=\sum_{j=1}^nj^{-2\alpha} \leq 1/(2\alpha-1)$, where the additional factor of $n$ arises due to the constraint that $\trace(\mat{K}) = \sum_{i=1}^n\evali =
n$.
Since the MDL-COMP is an increasing function in $\evali$, it suffices
to consider the case when $\evali = n c_\alpha i^{-2\alpha}$. Setting
$\alpha = \omega/d$ covers the case of $\evali \precsim
i^{-2\omega/d}$, and setting $\alpha = \frac{1}{2} (d+a)$ covers the
case of $\evali \precsim i^{-(d+a)}$. With the assumptions $\omega >
d/2$ and $d + a >1$, we find that for both cases $2 \alpha - 1 >0$ and
hence $c_{\alpha}$ is finite.
Let us write $\lambda$ as $nM^{-2\alpha}$, and given the rapid decay
of $\evali$, we can use the bounds
\begin{align*}
\sum_{i=1}^{\ceil{M}} \log(\evali/\lambda+1) \leq
\sum_{i=1}^{\ceil{M}} \log((M/i)^{2\alpha}+1) \stackrel{(i)}{\leq}
c_1 \cdot \alpha M \log M
\\
\sum_{i=\ceil{M}+1}^n \log(\evali/\lambda+1) \leq
\sum_{i=\ceil{M}+1}^{n} \log((M/i)^{2\alpha}+1) \leq
\sum_{i=\ceil{M}+1}^{n} (M/i)^{2\alpha} \leq c_\alpha.
\end{align*}
where step~(i) uses the fact that $\int_{1}^{x} \log z dz = x \log x -
x \leq x \log x$ for $x > 1$, and step~(ii) uses the fact that
$\sum_{i=\ceil{M}+1}^{n}(M/i)^{2\alpha} \leq
\sum_{j=1}^{\infty}j^{-2\alpha} = c_{\alpha}$. Thus, we can write the
RHS in \cref{eq:mdl_kernel} as
\begin{align*}
\frac{\lambda}{2n} \frac{\enorm{f^\star}^2_{\mb{H}}}{\sigma^2} +
\frac{1}{2n} \sumn \log\parenth{\frac{\evali}{\lambda}+1} \leq
\frac{1}{2n} \brackets{n M^{-2\alpha}\textrm{SNR}^2 + c \alpha M\log M +
c_{\alpha}}
\end{align*}
In order to minimize the RHS above with respect to $M$, we can equate
the two terms inside the brackets, and obtain
\begin{align*}
\frac{n \textrm{SNR}^2}{\alpha} \asymp M^{1+2\alpha}\log M
\quad\Longleftrightarrow\quad M \asymp \left(\frac{{n
\textrm{SNR}^2}/{\alpha}}{\log({n
\textrm{SNR}^2}/{\alpha})}\right)^{1/(1+2\alpha)}
\end{align*}
which yields
\begin{align*}
\ensuremath{\textrm{MDL-COMP}} \asymp M^{-2\alpha}\textrm{SNR}^2 & = \left(\frac{{n
\textrm{SNR}^2}/{\alpha}}{ \log({n
\textrm{SNR}^2}/{\alpha})}\right)^{-2\alpha/(1+2\alpha)} \textrm{SNR}^2 \\
& = c'_{\alpha} \left(\frac{ \log({n
\textrm{SNR}^2})}{n}\right)^{2\alpha/(1+2\alpha)} \textrm{SNR}^{2/(1+2\alpha)}
\\
& = C_{\alpha, \textrm{SNR}} \left( \frac{\log
(n\textrm{SNR}^2)}{n}\right)^{2\alpha/(1+2\alpha)},
\end{align*}
where
\begin{align}
\label{eq:constant_ker_smooth}
C_{\alpha, \textrm{SNR}} = \alpha^{2\alpha/(1+{2\alpha})} \textrm{SNR}^{2/(1+2\alpha)}.
\end{align}
Setting $\alpha = \omega/d$ and $\frac12(d+a)$ respectively recovers
the first two bounds stated in the
display~\eqref{eq:mdl_kernel_smooth}.
\subsubsection{Proof with exponential decay of eigenvalues}
Now, we do a reparametrization of $\lambda$ as $n\exp(-M/d)$, and
given the rapid decay of $\evali$, we use the following bounds:
\begin{align*}
\sum_{i=1}^{\ceil{M}}\log(\evali/\lambda+1) \leq
\sum_{i=1}^{\ceil{M}}\log(e^{(M-i)/d}+1) \stackrel{(i)}{\leq}
\frac{c}{d} \cdot \sum_{i=1}^{\ceil{M}} (M-i) \leq c'
\frac{M^2}{d} \\
\sum_{i={\ceil{M}}+1}^n\log(\evali/\lambda+1) =
\sum_{i={\ceil{M}}+1}^{n}\log(e^{(M-i)/d}+1) \leq
\sum_{i={\ceil{M}}+1}^{n} e^{(M-i)/d} \leq c_d''.
\end{align*}
where we use the fact that $\log(1+ e^{x}) \leq c x$ for large $x$,
and $\log(1+e^x) \leq e^x$ for all $x$. Thus, we can write the RHS in
\cref{eq:mdl_kernel} as
\begin{align*}
\frac{\lambda}{2n} \frac{\enorm{f^\star}^2_{\mb{H}}}{\sigma^2} +
\frac{1}{2n}\sumn \log\parenth{\frac{\evali}{\lambda}+1} \leq
\frac{1}{2n}\brackets{ne^{-M/d}\textrm{SNR}^2 + c' \frac{M^2}{d} + c_{d}''}
\end{align*}
In order to minimize the RHS of the above display with respect to $M$,
we can equate the two terms inside the brackets, and obtain
\begin{align*}
d n \textrm{SNR}^2 \asymp e^{M/d} M^2 \quad\Longleftrightarrow\quad M \asymp
d \log\parenth{\frac{nd\textrm{SNR}^2}{d\log(nd\textrm{SNR}^2))}}.
\end{align*}
Thus, we have
\begin{align*}
\ensuremath{\textrm{MDL-COMP}} \asymp \frac{M^2}{dn} &= \frac{d\log^2(nd \textrm{SNR}^2)}{n},
\end{align*}
as claimed.
\section{Bias-variance tradeoff: Role of estimator and design matrix}
\label{sub:different_design}
\setcounter{table}{0} \setcounter{figure}{0}
\renewcommand{\thefigure}{F\arabic{figure}}
\renewcommand{\thetable}{F\arabic{table}}
In this appendix, we show that the bias-variance tradeoff for OLS
heavily depends on the design matrix. More precisely, depending on
the structure of the design matrix, it is possible to observe
double-descent or multiple descent, where the peaks can occur at
values of $d/n$ not necessarily equal to $1$ in the test MSE when
varying $d$. While OLS can exhibit a wide range of behavior, we also
show that the test MSE for CV-tuned ridge regression exhibits
the familiar U-shaped behavior for all the choices of design
considered here.
In the experimental results shown here, we generate data from a linear
Gaussian model of the form
\begin{align}
\v{y} = \underbrace{\mat{X} \tvar_\star}_{\v{y}_\star} + \noise[],
\end{align}
where $\noise[] \in \ensuremath{\mathbb{R}}^n \sim \mc N(0, \sigma \mat I_n)$ with
$\sigma = 0.1$. In all cases, we keep the training sample size fixed
at $n=200$, and the maximum size of covariates is fixed at $2000$.
With these fixed choices, we consider several different choices of the
design matrix $\mat{X}$, along with two choices for the unknown
regression vector $\tvar_\star$.
\paragraph{Choice for $\mat{X}$:}
We consider two possible random ensembles for the design matrix
$\mat{X}$. Let $\mat A \in \ensuremath{\mathbb{R}}^{200 \times 2000}$ denote a matrix
whose entries are drawn iid from $\mc N(0, 1)$. Let $\mat B \in
\ensuremath{\mathbb{R}}^{2000 \times 2000}$ denote a diagonal matrix such that $\mat
B_{ii} = \vert\cos i\vert$ for $i$ even, and $0$ otherwise. Then the
two choices for the design matrix $\mat{X}$ are (I) \emph{Gaussian
design} with $\mat{X} = \mat A$, and (II) \emph{Cosine design} with
$\mat{X} = \mat A \mat B$.
\paragraph{Choice for $\tvar_\star$:}
In parallel, we consider two possible random ensembles for the unknown
regression vector $\tvar_\star$. In all cases, the response $\v{y}_\star$
depends on only on $d_\star$ covariates in total. In setting (A)
where $\mathbf {d_\star < n}$, we choose $\tvar_\star$ to have non-zero
entries for the index $\braces{11, 12, \ldots, 60}$, i.e., the true
dimensionality of the dataset is $d_\star =60$, which is less than the
sample size $n=200$. In setting (B) where $\mathbf {d_\star > n}$, we
choose $\tvar_\star$ to have non-zero entries for all indices in the set
$\braces{1, 2, \ldots, 400}$. Consequently, the number of free
parameters $d_\star=400$ is much larger than the sample size
$n=200$. In both settings, the non-zero entries of $\tvar_\star$ are drawn
iid from $\mc N(0, 1)$, and then normalized such that $\enorm{\tvar_\star}=
1$. \\
\vspace*{0.2in}
Taking all possible combinations of random ensembles for $\mat{X}$ and
$\tvar_\star$ yields four distinct experimental settings: IA, IB, IIA, IIB.
Given a particular setting---for instance, setting IA with Gaussian
design and $d_\star = 60 < n$ (IA)---we generate a dataset of $n$
observations and then fit different estimators with a varying number
of covariates (denoted by $d$); i.e., the response variable $\v{y}$
remains fixed and we only vary the dimensionality of the design matrix
for fitting OLS or Ridge model. We then compute the test MSE
(computed on an independent draw of $\v{y}_\star^{\textrm{test}}$ of
size $n_{\textrm{test}}=1000$). We redraw the noise in the
observation $50$ times ($\v{y}_\star^{\textrm{train}} \text{ and }
\v{y}_\star^{\textrm{test}}$ remain fixed), and plot the average of test
MSE over these runs. For a given $d$, the bias and variance for a
given estimator (OLS or Ridge) are computed as follows:
\begin{align*}
\textrm{Bias}(d) &= \frac{1}{n_{\textrm{test}}}
\enorm{\v{y}_\star^{\textrm{test}}-\overline{\v{y}^{\textrm{est}}}}^2,
\qtext{and}\\ \textrm{Variance}(d) &=\frac{1}{50} \sum_{r=1}^{50}
\frac{1}{n_{\textrm{test}}}
\enorm{\v{y}^{\textrm{est}}_r-\overline{\v{y}^{\textrm{est}}}}^2,
\end{align*}
where $r$ denotes the index of the experiment (redraw of noise
$\noise[]$), $\v{y}^{\textrm{est}}_r$ denotes the estimate for the
response for the test dataset for the $r$-th experiment, and
$\overline{\v{y}^ {\textrm{est}}}$ denotes the average of the
predictions made by the estimator across all $50$ experiments.
The four panels in \cref{fig:test_mse_diff_design} show, for each of
these four settings, plots of the radio $d/n$ versus test MSE for the
OLS and CV-tuned ridge estimators. \cref{fig:bias_var_diff_design}
shows the underlying bias-variance tradeoff curves in settings IA and
IIA.
\begin{figure}[ht]
\centering
\begin{tabular}{cc}
\includegraphics[width=0.36\linewidth]{../figs/identity0detailed_test_mse}
&
\includegraphics[width=0.36\linewidth]{../figs/identity_high_dim0detailed_test_mse}
\\ (a) & (b)
\\ \includegraphics[width=0.36\linewidth]{cosine0detailed_test_mse}
&
\includegraphics[width=0.36\linewidth]{cosine_high_dim0detailed_test_mse}
\\ (c) & (d)
\end{tabular}
\caption{Plots of test MSE for OLS and CV-tuned Ridge for the four
designs discussed in \cref{sub:different_design}, versus the
dimensionality of the covariates in the fitted model varies. The
training sample size is fixed at $n=200$.
} \vspace{2mm}
\label{fig:test_mse_diff_design}
\end{figure}
From these figures, we can draw the following conclusions. On one
hand, the test MSE of the CV-tuned ridge estimator exhibits the
classical U-shaped curve for all the settings. On the other hand, the
behavior of OLS is heavily dependent on the covariate design along
with the choice of $d_\star$. For $d<d_\star$, both OLS and Ridge show
the classical tradeoff between bias (deccreasing in $d$) and variance
(increasing in $d$). For $d>d_\star$, the bias of the tuned ridge
increases monotonically with $d$, but the variance increases until a
design-dependent threshold, after which it then decreases. In almost
all cases, the bias of OLS monotonically increases as $d$ increases
above $d_\star$; however, the variance term can show multiple peaks
depending on the design, and these peaks frequently show up in the
test MSE as well.
\begin{figure}[ht]
\centering
\begin{tabular}{cc}
\includegraphics[width=0.36\linewidth]{../figs/identity0detailed_bias_variance_ols}
&
\includegraphics[width=0.36\linewidth]{../figs/identity0detailed_bias_variance_ridge}
\\ (a) & (b)
\\ \includegraphics[width=0.36\linewidth]{cosine0detailed_bias_variance_ols}
&
\includegraphics[width=0.36\linewidth]{cosine0detailed_bias_variance_ridge}
\\ (c) & (d)
\end{tabular}
\caption{Bias-variance tradeoff of OLS and CV-tuned Ridge
estimators for various designs discussed in
\cref{sub:different_design}. Panels (a) and (b) show the results
for design IA corresponding to the
\cref{fig:test_mse_diff_design}(a), and panels (c) and (d) show
it for design IIA corresponding to the
\cref{fig:test_mse_diff_design}(c). }
\label{fig:bias_var_diff_design}
\end{figure}
\end{appendix}
{\small
\section{Unused for now}
\subsubsection{Decaying eigenvalues}
The expressions~\eqref{eq:mdl_scaling} and \eqref{eq:adj_scaling} were computed assuming all eigenvalues were constant.
We now provide analytical expressions when the eigenvalues decay, and show that \ensuremath{\textrm{MDL-COMP}}\ in such cases can grow
slowly than $\mc O(d/n)$ for $d<n$.
To keep the analysis tractable, we make an assumption that the eigenvalues are arranged such that the product $\evali \myvec_i^2$ decays as $A/i^{\decay}$. In such cases, standard calculus shows that
\begin{align}
\ensuremath{\textrm{MDL-COMP}}(\decay) \precsim \begin{cases}
\displaystyle\mc{O}\parenth{\frac{C\sqrt {\min\braces{d, n}}}{n}}, \quad&\text{if } \decay= \frac12 \\[4mm]
\displaystyle\mc{O}\parenth{\frac{C (1+\log(\min\braces{d, n}) }{n}},\quad&\text{if } \decay= 1,
\end{cases}
\end{align}
for some choices of constant $C$ (which may differ from line-to-line).
In other words, when $\decay=0.5$, \ensuremath{\textrm{MDL-COMP}}\ increases sub-linearly with $d$ until $d=n$, and then remains bounded for $d>n$ by $C/\sqrt n$.
When the terms decay faster, i.e., $\decay=1$, the growth of \ensuremath{\textrm{MDL-COMP}}\ is even slower ($\log d$) with $d$, and for high-dimensions \ensuremath{\textrm{MDL-COMP}}\ remains bounded as $\mc{O}((\log n)/n)$.
One can derive similar expressions for \textrm{Adj-MDL-COMP} under a variety of assumptions, we omit the
derivation for brevity.
We provide more detailed expressions for these cases below:
\begin{align*}
\decay &= \frac{1}{2} \quad\Longrightarrow \quad
\ensuremath{\textrm{MDL-COMP}} = \begin{cases} \frac{C\sqrt d}{2n} + \frac{d}{2n} \log\parenth{\frac{C}{\sqrt d} + 1}
= \mc{O}\parenth{\frac{C\sqrt d}{n}}, \quad\text{if } d \leq n\\
\frac{C}{2\sqrt n} + \frac12 \log\parenth{\frac{C}{\sqrt n} + 1}
= \mc{O}\parenth{\frac{C}{\sqrt n}} \quad\text{if } d > n.
\end{cases} \\
\decay &= 1 \quad\Longrightarrow \quad
\ensuremath{\textrm{MDL-COMP}} = \begin{cases}
\frac{d}{2n} \log\parenth{\frac{C}{d}+1} + \frac{C}{2n} \log\parenth{C+d}
= \mc{O}\parenth{\frac{C(1+\log d)}{n}}, \quad\text{if } d \leq n\\
\frac{1}{2} \log\parenth{\frac{C}{n}+1} + \frac{C}{2n}\log(C+n)
= \mc{O}\parenth{\frac{C(1+\log n)}{\sqrt n}} \quad\text{if } d > n.
\end{cases}
\\
\decay &= 2 \quad\Longrightarrow \quad
\ensuremath{\textrm{MDL-COMP}} = \begin{cases}
\frac{d}{2n} \log\parenth{\frac{C}{d^2}+1} + \frac{\sqrt C}{n} \tan^{-1}\parenth{\frac {d}{\sqrt C} }
= \mc{O}\parenth{\frac{ \sqrt C}{n}}, \quad\text{if } d \leq n\\
\frac{1}{2} \log\parenth{\frac{C}{n^2}+1} + \frac{\sqrt C}{n} \tan^{-1}\parenth{\frac {n}{\sqrt C} }
= \mc{O}\parenth{\frac{ \sqrt C}{n}}, \quad\text{if } d > n
\end{cases}
\end{align*}
\subsection{Other variants of MDL-COMP}
\begin{align*}
\ensuremath{\mc R_{\textrm {opt}}} &:= \min_{\mat{\Lambda}}\frac1n \kull{\pdist_{\tvar_\star}}{\mathbb{Q}_{\mat{\Lambda}}} \\ &= \frac1n\log\det((\mat I_n - \mat{X} (\xmat^\top\xmat+\mat{\Lambda}_{\textrm{opt}})^{-1} \mat{X} ^\top )^{-1})
= \frac1n \sum_{i=1}^{\min\braces{n, d}} \log(1+ \frac{\evali}{ \lambda_{i, \mrm{opt} }}) \\
\lambda_{i, \mrm{opt}} &= \frac{\sigma_i^2}{w_i^2}, \qtext{and} w = \mat U^\top \tvar_\star \\
\mc L(\mat{\Lambda}_{\textrm{opt}}) &= \frac{1}{n} \sum_{i=1}^{\min\braces{n, d}} \log( \lambda_{i, \mrm{opt}}/\Delta) \qtext{and} \\
\ensuremath{\textrm{MDL-COMP}} &:= \ensuremath{\mc R_{\textrm {opt}}} + \mc L(\mat{\Lambda}_{\textrm{opt}})
= \frac1n \sum_{i=1}^{\min\braces{n, d}} \log(1+ \frac{\evali}{\lambda_{i, \mrm{opt}}}) + \frac{1}{n} \sum_{i=1}^{\min\braces{n, d}} \log(\lambda_{i, \mrm{opt}}/\Delta) \\
&= \frac1n\sum_{i=1}^{\min\braces{n, d}} \log( \evali + \lambda_{i, \mrm{opt}}) - \min\braces{1, \frac{d}{n}} \log\Delta
\end{align*}
OR
\begin{align*}
\ensuremath{\textrm{MDL-COMP}}_2 &:= \min_{\mat{\Lambda}}\frac1n \kull{\pdist_{\tvar_\star}}{\mathbb{Q}_{\mat{\Lambda}}} + \mc L(\mat{\Lambda}) \\
&= -\frac{\min\braces{n, d}}{2n} + \min_{\mat{\Lambda}}\frac{1}{2n} \sumn[\min\braces{n, d}] \parenth{
\frac{
(\evali\myvec_i^2/\sigma^2
+ 1)\lambda_i}{\lambda_i+\evali}
+ \log\parenth{\evali+\lambda_i}
} \\
&= -\frac{\min\braces{n, d}}{2n} +\frac{1}{2n} \sumn[\min\braces{n, d}] \log\parenth{\evali} \\
\lambda_{i, \mrm{opt}} &= 0
\end{align*}
OR
\begin{align*}
\ensuremath{\textrm{MDL-COMP}}_3 &:= \min_{\lambda}\frac1n \kull{\pdist_{\tvar_\star}}{\mathbb{Q}_{\lambda}} + \frac1n \log (\lambda/\Delta) \\
&= -\frac{\min\braces{n, d}}{2n} + \min_{\lambda} \brackets{\frac1n \log (\lambda/\Delta) + \frac{1}{2n} \sumn[\min\braces{n, d}] \parenth{
\frac{
(\evali\myvec_i^2/\sigma^2
+ 1)\lambda}{\lambda+\evali}
+ \log\parenth{1+\frac{\evali}{\lambda}}
}} \\
\lambda_{\mrm{opt}} &= \text{no closed form}
\end{align*} | {'timestamp': '2021-09-28T02:42:18', 'yymm': '2006', 'arxiv_id': '2006.10189', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10189'} | arxiv |
\section{Introduction}\label{sec:intro}
Imagine being able to search for the moment in a video where an adorable kitten sneezes, even though the uploader has not tagged its timestamp. Finding such important events in a video is called a temporal moment localization. Videos contain many untagged topics and hence, addressing temporal localization problem is versatile. For instance, progress on temporal moment localization can benefit video search, video summarization, action moment detection and many other areas.
We address the problem of language based action localization in untrimmed videos, where the task is to identify the temporal location within a video that is described by a given natural language query. For example in Figure~\ref{fig:example-coffee}, if we were to query \textit{``Person drinking a cup of coffee''}, the network should locate frames in the video where a person is drinking a coffee. This problem is challenging due to the complexity of action identification in an untrimmed video that may contain a diverse combination of actors, actions and objects over time.
A prior work, Temporal Activity Localization via Language (TALL) \cite{Gao2017TALLTA} compares visual features with sentence embeddings via a Multi-Modal Processing Unit (MPU). It maps the visual and textual features to a single feature space by performing element-wise addition, element-wise multiplication and concatenation. Then, the concatenated output of these operations is used to generate a visual-semantic alignment score along with a location regression result for each video clip. However, visual features used by \cite{Gao2017TALLTA} are trained for activity classification and not to compare with text.
Recent work by Ge et al.~\cite{Ge2018MACMA}, argues that TALL~\cite{Gao2017TALLTA} model ignores rich semantic information about activities in videos and queries. They improved TALL architecture and proposed Mining Activity Concepts (MAC), which extracts activity concepts from verb/object pairs of query sentence and videos. The verb/object pair represents semantic activity concepts that identify the action of a query. The video features from the last layer (FC8) of a C3D model~\cite{Tran2014C3DGF}, trained on Kinetics activity classification dataset, represents visual activity concepts. These activity concepts can be combined using a MPU to predict video moments. Although some Kinetics classes identify an object (e.g. playing guitar), it ignores a large number of object classes contained in a video.
To overcome above mentioned limitations, we propose Multi-Faceted Moment Localizer (MML) that uses object features from semantic segmentation model and video understanding features from a video captioning model. Our contributions can be summarized as follows:
\begin{itemize}
\item Introducing frame-level object evidence via semantic object segmentation features to explicitly identify the relationship between the query object and visible objects in video frames.
\item Introducing video captioning features as an additional feature for joint-embedding between video clip and query text.
\item Improved language modelling of query text via the introduction of BERT sentence embedding. Experiments on improving Verb/Object pair (VO pair) encoding via BERT which did not improve results, and we provide the reasons that may have caused this counter-intuitive outcome in Section~\ref{subsec:bert}.
\end{itemize}
We performed extensive ablation study to validate each architectural component we introduced. Our code and pre-trained model is available at \textit{\url{https://github.com/madhawav/MML}}.
\begin{figure}[t]
\centering
\includegraphics[width=\linewidth]{QualitativeCoffe.png}
\caption{An example for query \textit{``Person drinking a cup of coffee''}. Green, red and blue lines indicate the ground truth frames, baseline~\cite{Ge2018MACMA} prediction and prediction by our method respectively.}
\label{fig:example-coffee}
\end{figure}
\section{Approach}\label{sec:approach}
The proposed work Multi-Faceted Moment Localizer (MML) is based on the prior work MAC \cite{Ge2018MACMA}, which is the current state-of-the-art method for text based video moment localization. We developed our model on top of a PyTorch implementation of MAC available here~\footnote{https://github.com/WuJie1010/Temporally-language-grounding}. We focused on improving the MAC architecture by introducing additional features that support video moment localization. Figure~\ref{fig:archdiag} shows the architecture of our model in which the blocks with green and blue colour text indicate our contributions.
Similar to the approach taken in MAC, we first divide a video into overlapping video clips. Then an alignment score and location offset pair is calculated considering the query sentence and each video clip. This calculation involves: 1) comparison of low-level video clip features (C3D FC6 features from MAC and video captioning features we introduced) with sentence embedding, 2) comparison of high-level video clip features (visual activity concepts from MAC and object segmentation features we introduced) with VO pair glove embedding.
Two Multi Modal Processing Units \cite{Gao2017TALLTA} ($\text{MPU}^{\text{low}}$ and $\text{MPU}^{\text{high}}$) are used for above mentioned comparisons. The outputs from two MPU's are concatenated and passed through an additional fully connected layer (MLP) to obtain alignment score and location offsets. Following the same approach as MAC, the alignment score is then multiplied by the actionness score, which indicates the likelihood of the candidate video clip to have meaningful activities. The location offsets are added to video clip time bounds to obtain a particular prediction.
\begin{figure}[t]
\centering
\includegraphics[scale=0.19]{ArchDiag.png}
\caption{Architecture diagram of MML. Blocks with blue text indicate components we introduced. Blocks with green text indicate components we improved. Blocks with red text indicate components considered for improvements. Blocks with black text indicate other components from baseline~\cite{Ge2018MACMA}.}
\label{fig:archdiag}
\end{figure}
\subsection{Contribution 1: Improvements on language modelling}\label{subsec:bert}
Both TALL~\cite{Gao2017TALLTA} and MAC~\cite{Ge2018MACMA} models use skip-thought vectors for sentence embedding.
In our approach, we replaced skip-thought embeddings using Google’s pre-trained BERT~\cite{devlin2018bert} model features.
The intuition behind this change is two-fold: 1) Skip-thoughts is a 4800-dimensional vector whereas BERT is a 768-dimensional vector, thereby reducing the parameter count and improving the generalization of the model; and 2) BERT is trained on a significantly larger datasets: BooksCorpus (800M words) and Wikipedia (2,500M words).
As explained in Section~\ref{sec:experiments}, the introduction of BERT sentence embeddings improved the results of our model. We also tried
Facebook AI’s RoBERTa~\cite{liu2019roberta}, a derivative of BERT.
But RoBERTa reduced the performance of our model. This reduction is probably because RoBERTa has removed the next sentence prediction training objective, which had made BERT versatile for sentence embedding.
The MAC~\cite{Ge2018MACMA} model uses GloVe embedding for VO word pairs. We tried using BERT as a substitute for GloVe, but that only degraded results. This is probably because BERT embedding (768d) is much larger than GloVe embedding (300d), which causes the number of parameters in the model to increase, and it may have influenced the generalization of the model.
\subsection{Contribution 2: Introducing object segmentation features}\label{sec:intro-object-segment}
The baseline~\cite{Ge2018MACMA} uses FC8 features (i.e. action class predictions) of a C3D model trained on Kinetics dataset as visual activity concepts used to identify actions in a clip. However, only 15.82\% of the objects mentioned in the query text of Charades-STA dataset are covered by Kinetics classes. To overcome this issue, we used object segmentation features to explicitly include object information contained in clip.
For identifying objects in video frames, we considered semantic segmentation models trained on ADE20K dataset~\cite{ADE20K} which consists of 150 object classes. From the provided pre-trained object segmentation models \footnote{https://github.com/CSAILVision/semantic-segmentation-pytorch}, we used \textit{``MobileNetV2dilated + C1\_deepsup''} in the interest of time, which provided required features in about 5 days. We sampled every $16^{th}$ frame of video clips and obtained each frame's class distribution using the semantic segmentation model. We obtained the class means of each frame and then max pooled across the time dimension. The above process resulted in a 150 dimension vector ($V_{\text{obj}}$) for each video clip. Figure~\ref{fig:obj-feature-extracts} demonstrates the aforementioned object feature extraction process.
At training time, $V_{\text{obj}}$ is normalized, scaled (using scale ratio $S_{\text{obj}} \in [0,1]$) and concatenated with Visual Activity Concept features ($V_{\text{vac}}$), before being passed to the MLP that generate the input for $\text{MPU}^{\text{high}}$. In order to address over-fitting, dropout layers (with dropout ratios $D_{\text{obj}}$ and $D_{\text{vac}}$) were used for $V_{\text{obj}}$ and $V_{\text{vac}}$. The input to the MLP is as follows:
\[
MLP_{input} = \textbf{Dropout}(\frac{V_{\text{obj}}}{|V_{\text{obj}}|} \cdot S_{\text{obj}}, \text{dropout\_ratio}=D_{\text{obj}}) \mathbin\Vert \textbf{Dropout}(V_{\text{vac}},\text{dropout\_ratio}=D_{\text{vac}})
\]
In order to identify suitable hyper-parameter values for $S_{\text{obj}}$, $D_{\text{obj}}$ and $D_{\text{vac}}$, we used a 3 axis parameter sweep as explained in Section~\ref{sec:param-sweep}.
\begin{figure}[t]
\centering
\includegraphics[scale=0.4]{ObjectFeatureExtract.png}
\caption{Process of extracting object segmentation features.}
\label{fig:obj-feature-extracts}
\end{figure}
\subsection{Contribution 3: Introducing video captioning features}
Existing methods for video moment localization use C3D features from activity classification domain. However, the task of moment localization is different from activity classification as we have to compare data from two different domains: highly complex video domain and a relatively simple text domain. Thus, it may be helpful to use features from a model that compares videos with text, and thus we incorporate video captioning features into our model.
We use Temporal Shift Module (TSM)~\cite{lin2019tsm} for this task, as it is the state of the art method in video understanding. We have used \textit{TSM ResNet50}~\footnote{https://github.com/mit-han-lab/temporal-shift-module} model pre-trained on $16$ frames to extract video captioning features. This model was trained on Kinetics-400 dataset. Hence, it outputs features per frame. We perform average pooling across all frames of a clip to obtain one feature vector of size $2048$ for each video clip. These features denote a low-level representation of the video clip. Hence, we concatenate these features with FC6 features of C3D model to calculate the alignment score and frame offset. Result of using video captioning features is given in Table~\ref{table:quantitative-feature-selection}.
\section{Experiments} \label{sec:experiments}
\subsection{Dataset}
We used Charades-STA~\cite{Gao2017TALLTA} dataset for training and evaluating the MML model. This dataset contains around 10,000 videos where each video contains clip-level sentence descriptions coupled with start/end time-stamps. In total, there are 13898 clip-sentence pairs in Charades-STA training set and 4233 clip-sentence pairs in test set. To keep our results comparable, we used the same train/test splits of Charades STA as baseline\cite{Ge2018MACMA} for all the experiments.
\subsection{Evaluation Metrics}
We adopted the evaluation metrics \textit{R@1 on IOU=0.5} and \textit{R@5 on IOU=0.5} used by baseline\cite{Ge2018MACMA}. \textit{R@N on IOU=u} can be calculated as $\frac{1}{N_q}\sum_{i=1}^{N_q} r(n, u, q_i)$ where $r(n,u,q_i)$ is the alignment result for query $q_i$. Here, $r(n,u,q_i) = 1$ indicates correct alignment and $r(n,u,q_i) = 0$ indicates wrong alignment, considering the top $n$ scored video clips having a temporal IOU greater than or equal to $u$ with the ground truth of $q_i$. The value $N_q$ represents the total number of queries and thus \textit{R@n on IOU=u} is an averaged figure. A higher value is preferred for\textit{ R@n on IOU=u}. All measurements in this paper are at \textit{IOU = 0.5}.
\subsection{Baseline}
The baseline model by MAC \cite{Ge2018MACMA} authors exhibit \textit{R@1} of $0.304$ and \textit{R@5} of $0.648$ on Charades-STA dataset. However, the PyTorch implementation~\footnote{https://github.com/WuJie1010/Temporally-language-grounding} of the same model provide slightly different values at $0.297$ for R@1 and $0.641$ for R@5. The MML was developed from the code base of this PyTorch implementation. Thus, we consider both of these as baselines for our experiments.
\subsection{Experimental results}
The best models we identified provide 4.93\% (R@1) and 1.70\% (R@5) improvements over MAC author's baseline. In this subsection, we first discuss the effect of each component of the architecture using an ablation study. Then we provide details of hyper-parameter tuning of object segmentation features and video captioning features, followed by a qualitative analysis of the proposed model.
\begin{table}[t]
\caption{Effect of different features on performance of MML. R@1 and R@5 are used as evaluation metric. Best performing models are highlighted in blue color.}
\label{table:quantitative-feature-selection}
\centering
\resizebox{\textwidth}{!}{%
\begin{tabular}{@{}l|llll|ll@{}}
\toprule
\multicolumn{1}{r|}{} & & & & & & \\
\multicolumn{1}{r|}{\multirow{-2}{*}{\textbf{Features}}} & & & & & & \\
\textbf{Models} & \multirow{-3}{*}{\begin{tabular}[c]{@{}l@{}}\textbf{Sentence}\\ \textbf{Embedding}\end{tabular}} & \multirow{-3}{*}{\begin{tabular}[c]{@{}l@{}}\textbf{VO} \\ \textbf{Embedding}\end{tabular}} & \multirow{-3}{*}{\begin{tabular}[c]{@{}l@{}}\textbf{Object}\\ \textbf{Segmentation}\\ \textbf{Features}\end{tabular}} & \multirow{-3}{*}{\begin{tabular}[c]{@{}l@{}}\textbf{Video}\\ \textbf{Captioning}\\ \textbf{Features}\end{tabular}} & \multirow{-3}{*}{\textbf{R@1}} & \multirow{-3}{*}{\textbf{R@5}} \\ \midrule
\begin{tabular}[c]{@{}l@{}}\textbf{MAC} \\ \textbf{(authors baseline)}\end{tabular} & SkipThought & GloVe & - & - & 0.304 & 0.648 \\
\begin{tabular}[c]{@{}l@{}}\textbf{MAC}\\ \textbf{(PyTorch baseline)}\end{tabular} & SkipThought & GloVe & - & - & 0.297 & 0.641 \\
\textbf{Model 1} & BERT & GloVe & - & - & 0.299 & 0.647 \\
\textbf{Model 2} & SkipThought & GloVe & \checkmark & - & 0.308 & 0.646 \\
{\color[HTML]{3166FF} \textbf{Model 3}} & {\color[HTML]{3166FF} \textbf{BERT}} & {\color[HTML]{3166FF} \textbf{GloVe}} & {\color[HTML]{3166FF} \textbf{\checkmark}} & {\color[HTML]{3166FF} -} & {\color[HTML]{3166FF} \textbf{0.313}} & {\color[HTML]{3166FF} \textbf{0.659}} \\
\textbf{Model 4}& SkipThought & BERT & \checkmark & - & 0.302 & 0.642 \\
\textbf{Model 5} & BERT & BERT & \checkmark & - & 0.301 & 0.647 \\
\textbf{Model 6}& RoBERTa & GloVe & \checkmark & - & 0.238 & 0.574 \\
{\color[HTML]{3166FF} \textbf{Model 7}} & {\color[HTML]{3166FF} \textbf{BERT}} & {\color[HTML]{3166FF} \textbf{GloVe}} & {\color[HTML]{3166FF} \textbf{\checkmark}} & {\color[HTML]{3166FF} \textbf{\checkmark}} & {\color[HTML]{3166FF} \textbf{0.319}} & {\color[HTML]{3166FF} \textbf{0.651}} \\ \bottomrule
\end{tabular}%
}
\end{table}
\subsubsection{Ablation study on feature selection}
We perform extensive ablation study to validate the effectiveness of individual components of the proposed model.
Table \ref{table:quantitative-feature-selection} illustrates R@1 and R@5 scores of various ablations studies. Introduction of BERT sentence embedding and object segmentation features help outperform the baseline. The best models we identified (Model 3 and Model 7) necessarily includes BERT sentence embedding, object segmentation features and GloVe VO embeddings. Introduction of video captioning features further improves R@1. These best models provide 4.93\% (R@1 of Model 7) and 1.70\% (R@5 of Model 3) improvements over MAC authors baseline. Considering the model 3 alone, we obtain 2.96\% (R@1) and 1.70\% (R@5) improvements.
The models 3 and 7, which are the best performing MML models, achieve 7.41\% and 4.93\% improvements in R@1 over MAC PyTorch baseline. The introduction of object segmentation features (model 2 vs. baseline) and video captioning features (model 7 vs. model 2) boosts R@1 by 3.70\% and 2.02\% respectively. Although BERT sentence embedding alone contribute only a 0.67\% increase in R@1 score, its combination with object segmentation features provide a further improvement of 1.01\%.
\subsubsection{Hyper-parameter tuning on object segmentation and video captioning features}\label{sec:param-sweep}
As mentioned in Section \ref{sec:intro-object-segment}, we consider multiple values for hyper-parameters $D_{\text{obj}}$, $D_{\text{vac}}$ and $S_{\text{obj}}$ to address over-fitting. We used a 3 axis parameter sweep to find a suitable set of hyper-parameters considering candidate values $S_{\text{obj}} \in \{ 0,0.005,0.05,0.1,0.25,0.5,0.75,1\}$, $D_{\text{obj}} \in \{0,0.1,0.25,0.5\}$ and $D_{\text{vac}} \in \{0,0.1,0.25,0.5\}$. We effectively validated $8\times4\times4=128$ models that use BERT sentence embedding, GloVe VO embedding and no video captioning features, and identified $D_{\text{obj}}=0.5, D_{\text{vac}}=0$ and $S_{\text{obj}}=0.005$ as the best configuration. This configuration resulted in model 3 in Table \ref{table:quantitative-feature-selection}. The complete parameter sweep took about 2 days to complete on a machine with RTX 2080Ti GPU, having cached all the features in the system memory.
\begin{figure*}[t]
\centering
\begin{subfigure}{0.5\textwidth}
\centering
\includegraphics[scale=0.18]{ObjectParamTuneR_1.png}
\caption{R@1 (IOU=0.5) on test set}
\end{subfigure}%
~
\begin{subfigure}{0.5\textwidth}
\centering
\includegraphics[scale=0.18]{ObjectParamTuneR_5.png}
\caption{R@5 (IOU=0.5) on test set}
\end{subfigure}
\caption{Metrics at various $S_{\text{obj}}$ and $D_{\text{obj}}$. $D_{\text{vac}}$ is kept at 0. BERT sentence embedding, GloVe VO embedding and no video captioning features are used. Baseline by MAC authors is provided.}
\label{fig:obj-param-tune}
\end{figure*}
Figure~\ref{fig:obj-param-tune} shows the plots of R@1 and R@5 of best models at various scale ratios and dropout ratios of object features. The best models are identified by validating after each epoch. $D_{\text{vac}}$ is set to 0 (no visual activity concept dropout) as it is identified to be the best configuration. A significant reduction in R@1 and R@5 is observed when $S_{\text{obj}}$ is increased, indicating the models as over-fitting.
We performed a similar hyper-parameter search for finding a suitable scale for incorporating video captioning features, based on the best performing hyper-parameters for object segmentation features. We obtained the best results with a scale of $0.005$. The results are shown in model 7 of Table~\ref{table:quantitative-feature-selection}.
\subsubsection{Qualitative results}
Figures \ref{fig:qualitative-study-positive} and \ref{fig:qualitative-study-no-change} show qualitative examples from MML compared to the MAC baseline. These examples are from Model 7 in Table \ref{table:quantitative-feature-selection}. Below each example, ground truth (green stripe), MAC prediction (red stripe) and MML prediction (blue stripe) are indicated.
Figure \ref{fig:qualitative-study-positive} shows examples where the use of MML improved results over the MAC baseline. The improvement on examples \ref{fig:qualitative-shoe}, \ref{fig:qualitative-pillow}, \ref{fig:qualitative-phone}, \ref{fig:qualitative-sandwich} and \ref{fig:qualitative-paper-towel} can be largely attributed to the introduction of object segmentation features. This is because, in these examples, the objects referred by the queries enter/leave visibility at the vicinity of predictions.
In the example \ref{fig:qualitative-dishes}, improvements are made despite the object (``shoe'') being on the scene throughout the video. Thus, BERT sentence embedding and video captioning features may have played a role in these improvements.
Figure \ref{fig:qualitative-study-no-change} shows two examples where improvements of MML model did not improve the results. In Figure \ref{fig:qualitative-shoes-on}, the object does not change visibility and therefore, the results are identical to the baseline. Figure \ref{fig:qualitative-person-stand-up} shows an example where MML has performed worse than MAC baseline. In this case, there is no object in the sentence.
\begin{figure}[h!]
\centering
\begin{subfigure}{.49\textwidth}
\centering
\includegraphics[scale=0.028]{QualitativeShoe.jpg}
\caption{person hold the shoes}
\label{fig:qualitative-shoe}
\end{subfigure}
\begin{subfigure}{.49\textwidth}
\centering
\includegraphics[scale=0.040]{QualitativePillow.jpg}
\caption{person puts a pillow on their head}
\label{fig:qualitative-pillow}
\end{subfigure}
\begin{subfigure}{.49\textwidth}
\centering
\includegraphics[scale=0.032]{QualitativePlayPhone.jpg}
\caption{the person is playing with a phone}
\label{fig:qualitative-phone}
\end{subfigure}
\begin{subfigure}{.49\textwidth}
\centering
\includegraphics[scale=0.032]{QualitativeSandwich.jpg}
\caption{person finally eating a sandwich in a living room}
\label{fig:qualitative-sandwich}
\end{subfigure}
\begin{subfigure}{.49\textwidth}
\centering
\includegraphics[scale=0.031]{QualitativePaperTowel.jpg}
\caption{the person takes a paper towel from the table}
\label{fig:qualitative-paper-towel}
\end{subfigure}
\begin{subfigure}{.49\textwidth}
\centering
\includegraphics[scale=0.048]{QualitativeDishes.jpg}
\caption{the person washes dishes over the sink}
\label{fig:qualitative-dishes}
\end{subfigure}
\caption{Selected top-1 results with improvements. Green lines, red lines and blue lines indicate ground truths, MAC results and MML results respectively. Queries are provided below each figure.}
\label{fig:qualitative-study-positive}
\end{figure}
\begin{figure}[h!]
\centering
\begin{subfigure}{.39\textwidth}
\centering
\includegraphics[scale=0.025]{QualitativeShoesOn.jpg}
\caption{person puts shoes on}
\label{fig:qualitative-shoes-on}
\end{subfigure}
\begin{subfigure}{.49\textwidth}
\centering
\includegraphics[scale=0.035]{QualitativeStandUp.jpg}
\caption{the person stands up}
\label{fig:qualitative-person-stand-up}
\end{subfigure}
\caption{Selected top-1 results with no improvements. Green lines, red lines and blue lines indicate ground truths, MAC results and MML results respectively. Queries are provided below each figure.}
\label{fig:qualitative-study-no-change}
\end{figure}
\section{Conclusion}\label{sec:conclusion}
In this project, we addressed the problem of video moment localization and proposed a novel method \textit{Multi-faceted Video Moment Localization} (MML). Our model is built on top of the current state-of-the-art model MAC~\cite{Ge2018MACMA}. We introduced BERT sentence features for the text query, and object segmentation features and video captioning features for the video, thereby improving language based localization of moments in a given video. We performed an extensive ablation study to validate the effectiveness of each component introduced in MML. Our experiments show the significance of our proposed method over the current baselines.
\bibliographystyle{unsrt}
| {'timestamp': '2020-06-19T02:08:14', 'yymm': '2006', 'arxiv_id': '2006.10260', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10260'} | arxiv |
\section*{NumPy arrays}
The NumPy array is a data structure that efficiently stores and accesses
multidimensional arrays \cite{vanderwalt2011numpy}, also known as tensors, and
enables a wide variety of scientific computation.
It consists of a pointer to memory, along with metadata used to interpret the
data stored there, notably {\em data type}, {\em shape}, and {\em strides}
(Fig.~\ref{fig:array-concepts}a).
The \emph{data type} describes the nature of elements stored in an array.
An array has a single data type, and each array element occupies the same
number of bytes in memory.
Examples of data types include real and complex numbers (of lower and higher
precision), strings, timestamps, and pointers to Python objects.
The \emph{shape} of an array determines the number of elements along each axis,
and the number of axes is the array's dimensionality.
For example, a vector of numbers can be stored as a one-dimensional array of
shape $N$, while color videos are four-dimensional arrays of shape
$(T, M, N, 3)$.
\emph{Strides} are necessary to interpret computer memory, which stores elements
linearly, as multidimensional arrays.
It describes the number of bytes to move forward in memory to jump from row to
row, column to column, and so forth.
Consider, for example, a 2-D array of floating-point numbers with shape
$(4, 3)$, where each element occupies 8 bytes in memory.
To move between consecutive columns, we need to jump forward 8 bytes in memory,
and to access the next row $3 \times 8 = 24$ bytes.
The strides of that array are therefore $(24, 8)$. NumPy can
store arrays in either C or Fortran memory order, iterating
first over either rows or columns. This allows external libraries
written in those languages to access NumPy array data in memory directly.
Users interact with NumPy arrays using {\em indexing} (to access
subarrays or individual elements), {\em operators} (e.g., $+$, $-$, $\times$
for vectorized operations and $@$ for matrix multiplication), as well as {\em array-aware functions};
together, these provide an easily readable, expressive, high-level API for
array programming, while NumPy
deals with the underlying mechanics of making operations fast.
\emph{Indexing} an array returns single elements, subarrays, or elements that satisfy
a specific condition (Fig.~\ref{fig:array-concepts}b).
Arrays can even be indexed using other arrays (Fig.~\ref{fig:array-concepts}c).
Wherever possible, indexing that retrieves a subarray returns a {\em view} on
the original array, such that data is shared between the two arrays.
This provides a powerful way to operate on subsets of array data while
limiting memory usage.
To complement the array syntax, NumPy includes functions that perform
\emph{vectorized} calculations on arrays, including arithmetic, statistics, and
trigonometry (Fig.~\ref{fig:array-concepts}d).
Vectorization---operating on whole arrays rather than their individual
elements---is essential to array programming.
This means that operations that would take many tens of lines to express in
languages such as C can often be implemented as a single, clear Python
expression.
This results in concise code and frees users to focus on the details of
their analysis, while NumPy handles looping over array elements near-optimally,
taking into consideration, for example, strides, to best utilize the
computer's fast cache memory.
When performing a vectorized operation (such as addition) on two arrays with
the same shape, it is clear what should happen.
Through \emph{broadcasting}, NumPy allows the dimensions to differ, while
still producing results that appeal to intuition.
A trivial example is the addition of a scalar value to an array, but broadcasting also
generalizes to more complex examples such as scaling each column of an array
or generating a grid of coordinates.
In broadcasting, one or both arrays are virtually duplicated (that is, without
copying any data in memory), so that the shapes of the operands match
(Fig.~\ref{fig:array-concepts}d).
Broadcasting is also applied when an array is indexed using arrays of
indices (Fig.~\ref{fig:array-concepts}c).
Other array-aware functions, such as \texttt{sum}, \texttt{mean}, and \texttt{maximum}, perform
element-by-element \emph{reductions}, aggregating results across one,
multiple, or all axes of a single array.
For example, summing an $n$-dimensional array over $d$ axes results in a
$(n-d)$-dimensional array (Fig.~\ref{fig:array-concepts}f).
NumPy also includes array-aware functions for creating, reshaping, concatenating, and padding
arrays; searching, sorting, and counting data; and reading and writing files.
It provides extensive support for generating pseudorandom numbers,
includes an assortment of probability distributions, and
performs accelerated linear algebra, utilizing one of several backends
such as OpenBLAS \cite{wang2013augem,xianyi2012model} or Intel MKL optimized
for the CPUs at hand.
Altogether, the combination of a simple in-memory array
representation, a syntax that closely mimics mathematics, and a
variety of array-aware utility functions forms a productive and
powerfully expressive array programming language.
\begin{figure}
\centering
\includegraphics[width=.5\textwidth]{ecosystem}
\caption{\textbf{NumPy is the base of the scientific Python ecosystem.}
Essential libraries and projects that depend on NumPy's API gain access to new array
implementations that support NumPy's array protocols (Fig.~\ref{fig:array-protocol}).
}
\label{fig:ecosystem}
\end{figure}
\section*{Scientific Python ecosystem}
Python is an open-source, general-purpose, interpreted programming language
well-suited to standard programming tasks such as cleaning data,
interacting with web resources, and parsing text.
Adding fast array operations and linear algebra allows scientists to do all
their work within a single language---and one that has the advantage of
being famously easy to learn and teach, as witnessed by its adoption
as a primary learning language in many universities.
Even though NumPy is not part of Python's standard library,
it benefits from a good relationship with the Python developers.
Over the years, the Python language has added new features and
special syntax so that NumPy would have a more succinct and
easier to read array notation.
Since it is not part of the standard library, NumPy is able to
dictate its own release policies and development patterns.
SciPy and Matplotlib are tightly coupled with NumPy---in terms of
history, development, and use.
SciPy provides fundamental algorithms for scientific computing,
including mathematical, scientific, and engineering routines.
Matplotlib generates publication-ready figures and visualizations.
The combination of NumPy, SciPy, and Matplotlib, together with
an advanced interactive environment like IPython \cite{perez2007ipython},
or Jupyter \cite{Kluyver:2016aa}, provides a solid foundation for array
programming in Python.
The scientific Python ecosystem (Fig.~\ref{fig:ecosystem}) builds on top of
this foundation to provide several, widely used \emph{technique specific}
libraries \cite{pedregosa2011scikit,vanderwalt2014scikit,SciPyProceedings_11},
that in turn underlay numerous \emph{domain specific} projects
\cite{astropy:2013,astropy:2018,cock2009biopython,millman2007analysis,sunpy2015,2018EGUGA..2012146H}.
NumPy, at the base of the ecosystem of array-aware libraries,
sets documentation standards, provides array testing infrastructure,
and adds build support for Fortran and other compilers.
Many research groups have designed large,
complex scientific libraries, which add \emph{application specific} functionality
to the ecosystem.
For example, the \texttt{eht-imaging} library \cite{chael2019ehtim} developed by
the Event Horizon Telescope collaboration for radio interferometry imaging,
analysis, and simulation, relies on many lower-level components of the scientific Python
ecosystem.
NumPy arrays are used to store and manipulate numerical data at every step
in the processing chain: from raw data through calibration and image
reconstruction.
SciPy supplies tools for general image processing tasks such as
filtering and image alignment, while scikit-image, an image processing
library that extends SciPy, provides higher-level functionality such as
edge filters and Hough transforms.
The \texttt{scipy.optimize} module performs mathematical optimization.
NetworkX \cite{SciPyProceedings_11}, a package for complex
network analysis, is used to verify image comparison consistency.
Astropy \cite{astropy:2013, astropy:2018} handles standard
astronomical file formats and computes time/coordinate transformations.
Matplotlib is used to visualize data and to generate the final image of the black hole.
The interactive environment created by the array programming
foundation along with the surrounding ecosystem of tools---inside of
IPython or Jupyter---is ideally suited to exploratory data analysis.
Users fluidly inspect, manipulate, and visualize their data, and
rapidly iterate to refine programming statements. These statements are
then stitched together into imperative or functional programs, or
notebooks containing both computation and narrative.
Scientific computing beyond exploratory work is often done in a text editor
or an integrated development environment (IDEs) such as Spyder.
This rich and productive environment has made Python popular
for scientific research.
To complement this facility for exploratory work and rapid
prototyping, NumPy has developed a culture of
employing time-tested software engineering practices to improve collaboration and
reduce error \cite{millman2014developing}. This culture is not only
adopted by leaders in the project but also enthusiastically taught to
newcomers. The NumPy team was early in adopting distributed revision
control and code review to improve collaboration on code, and
continuous testing that runs an extensive battery of automated tests for
every proposed change to NumPy. The project also has comprehensive,
high-quality documentation, integrated with the source
code \cite{vanderwalt2008scipy,harrington2008scipy,harrington2009scipy}.
This culture of using best practices for producing reliable scientific software
has been adopted by the ecosystem of libraries that build on NumPy.
For example, in a recent award given by the Royal Astronomical Society to
Astropy, they state:
\begin{quotation}
\noindent\emph{The Astropy Project has provided hundreds of junior scientists
with experience in professional-standard software development practices
including use of version control, unit testing, code review and issue tracking
procedures. This is a vital skill set for modern researchers that is often
missing from formal university education in physics or astronomy.}
\end{quotation}
Community members explicitly work to address this lack of formal education
through courses and workshops
\cite{wilson-software-carpentry,hannay-scientific-software-survey,millman2018teaching}.
The recent rapid growth of data science, machine learning, and
artificial intelligence has further and dramatically boosted the usage of
scientific Python. Examples of its significant application, such as the
\texttt{eht-imaging} library, now exist in almost every discipline in the natural and social
sciences. These tools have become \emph{the primary}
software environment in many fields. NumPy and its ecosystem are commonly
taught in university courses, boot camps, and summer schools, and are
at the focus of community conferences and workshops worldwide.
NumPy and its API have become truly ubiquitous.
\section*{Array proliferation and interoperability}
\begin{figure*}
\centering
\includegraphics[width=\textwidth]{protocol}
\caption{\textbf{NumPy's API and array protocols expose new arrays to the ecosystem.}
In this example, NumPy's \texttt{mean} function is called on a Dask
array. The call succeeds by dispatching to the appropriate library implementation
(i.e., Dask in this case) and results in a new Dask array. Compare this
code to the example code in Fig.~\ref{fig:array-concepts}g.
}\label{fig:array-protocol}
\end{figure*}
NumPy provides in-memory, multidimensional, homogeneously typed
(i.e., single pointer and strided) arrays on CPUs. It runs on machines
ranging from embedded devices to the world's largest supercomputers,
with performance approaching that of compiled languages.
For most its existence, NumPy addressed the vast majority of
array computation use cases.
However, scientific data sets now routinely exceed the memory capacity of a single machine and may
be stored on multiple machines or in the cloud.
In addition, the recent need to accelerate deep learning and artificial intelligence applications
has led to the emergence of specialized accelerator hardware,
including graphics processing units (GPUs), tensor processing units (TPUs),
and field-programmable gate arrays (FPGAs).
Due to its in-memory data model, NumPy is currently unable to
utilize such storage and specialized hardware directly. However, both
distributed data and the parallel execution of GPUs, TPUs, and FPGAs map well
to the \emph{paradigm} of array programming: a gap, therefore, existed between
available modern hardware architectures and the tools necessary to
leverage their computational power.
The community's efforts to fill this gap led to a
proliferation of new array implementations. For example, each deep learning framework created
its own arrays; PyTorch \cite{NEURIPS2019_9015},
Tensorflow \cite{abadi2016tensorflow}, Apache MXNet \cite{chen2015mxnet},
and JAX arrays all have the
capability to run on CPUs and GPUs, in a distributed fashion, utilizing lazy evaluation
to allow for additional performance optimizations. SciPy and PyData/Sparse both
provide sparse arrays---which typically contain few non-zero values and store
only those in memory for efficiency.
In addition, there are projects that build on top of NumPy arrays as a data
container and \textit{extend} its capabilities. Distributed arrays are
made possible that way by Dask, and labeled arrays---referring to dimensions of
an array by name rather than by index for clarity, compare \texttt{x[:,~1]} vs.
\texttt{x.loc[:,~'time']}---by xarray \cite{hoyer2017xarray}.
Such libraries often mimic the NumPy API, because it lowers the
barrier to entry for newcomers and provides the wider community with a
stable array programming interface. This, in turn, prevents disruptive
schisms like the divergence of Numeric and Numarray.
But exploring new ways of working with arrays is experimental by nature
and, in fact, several promising libraries---such as Theano and Caffe---have
already ceased development. And each time that a user
decides to try a new technology, they must
change import statements and ensure that the new library implements
all the parts of the NumPy API they currently use.
Ideally, operating on specialized arrays using NumPy functions or semantics would
simply work, so that users could write code once, and would then benefit
from switching between NumPy arrays, GPU arrays, distributed arrays,
and so forth, as appropriate.
To support array operations between external array objects, NumPy
therefore added the capability to act as a central coordination
mechanism with a well-specified API (Fig.~\ref{fig:ecosystem}).
To facilitate this \emph{interoperability}, NumPy provides
``protocols'' (or contracts of operation), that allow for specialized arrays to be
passed to NumPy functions (Fig.~\ref{fig:array-protocol}).
NumPy, in turn, dispatches operations to the originating library, as required.
Over four hundred of the most popular
NumPy functions are supported.
The protocols are implemented by widely used libraries such as Dask, CuPy,
xarray, and PyData/Sparse.
Thanks to these developments, users can now, for example, scale
their computation from a single machine to distributed systems using Dask.
The protocols also \textit{compose} well, allowing users to redeploy NumPy
code at scale on distributed, multi-GPU systems via, for instance, CuPy arrays embedded in Dask
arrays. Using NumPy's high-level API, users can leverage highly parallel code
execution on multiple systems with millions of cores, all with minimal code
changes \cite{entschev2019}.
These array protocols are now a key feature of NumPy, and are expected to only
increase in importance. As with the rest of NumPy, we iteratively refine and
add protocol designs to improve utility and simplify adoption.
\section*{Discussion}
NumPy combines the expressive power of \emph{array programming},
the performance of C, and
the readability, usability, and versatility of Python in a mature,
well-tested, well-documented, and community-developed library.
Libraries in the scientific Python ecosystem provide fast implementations of most important algorithms.
Where extreme optimization is warranted, compiled languages such as
Cython \cite{behnel2011cython}, Numba \cite{Lam:2015:NLP:2833157.2833162},
and Pythran \cite{guelton2015pythran}, that
extend Python and transparently accelerate bottlenecks, can be
used.
Because of NumPy's simple memory model, it is easy to write low-level, hand-optimized code, usually in C
or Fortran, to manipulate NumPy arrays and pass them back to
Python.
Furthermore, using array protocols, it is possible to utilize the full
spectrum of specialized hardware acceleration with minimal changes to
existing code.
NumPy was initially developed by students, faculty, and researchers to
provide an advanced, open-source array programming library for Python,
which was free to use and unencumbered by license servers, dongles, and the like.
There was a sense of building something consequential together,
for the benefit of many others. Participating in
such an endeavor, within a welcoming community of like-minded
individuals, held a powerful attraction for many early contributors.
These user-developers frequently had to write code from scratch to solve
their own or their colleagues' problems---often in low-level languages
that precede Python, like Fortran \cite{dongarra2008netlib} and C.
To them, the advantages of an interactive, high-level array library
were evident. The design of this new tool was informed by other
powerful interactive programming languages for scientific computing
such as Basis \cite{dubois1989basis}, Yorick \cite{munro1995using}, R \cite{ihaka1996r},
and APL \cite{iverson1962programming},
as well as commercial languages and environments like IDL and {MATLAB}.
What began as an attempt to add an array object to Python became the
foundation of a vibrant ecosystem of tools. Now, a large amount of
scientific work depends on NumPy being correct, fast, and stable. It
is no longer a small community project, but is core scientific
infrastructure.
The developer culture has matured: while initial development was
highly informal, NumPy now has a roadmap and a process for proposing
and discussing large changes. The project has formal governance
structures and is fiscally sponsored by NumFOCUS, a nonprofit that
promotes open practices in research, data, and scientific computing.
Over the past few years, the project attracted its first funded
development, sponsored by the Moore and Sloan Foundations, and
received an award as part of the Chan Zuckerberg Initiative's
Essentials of Open Source Software program. With this funding, the
project was (and is) able to have sustained focus over multiple months
to implement substantial new features and improvements. That said, it
still depends heavily on contributions made by graduate students and
researchers in their free time.
NumPy is no longer \emph{just} the foundational array library underlying
the scientific Python ecosystem, but has also become the standard API
for tensor computation and a central coordinating mechanism between
array types and technologies in Python. Work continues to expand on and
improve these interoperability features.
Over the next decade, we will face several challenges. New devices will be
developed, and existing specialized hardware will evolve, to meet diminishing
returns on Moore's law. There will be more, and a wider variety of, data
science practitioners, a significant proportion of whom will be using NumPy.
The scale of scientific data gathering will continue to expand, with the
adoption of devices and instruments such as light sheet microscopes and the
Large Synoptic Survey Telescope (LSST) \cite{jenness2018lsst}. New generation
languages, interpreters, and compilers, such as Rust
\cite{10.1145/2692956.2663188}, Julia \cite{Julia-2017}, and LLVM
\cite{LLVM:CGO04}, will invent and determine the viability of new concepts and
data structures.
Through various mechanisms described in this paper, NumPy is poised to
embrace such a changing landscape, and to continue playing a leading
role in interactive scientific computation. To do so will require
sustained funding from government, academia, and industry. But,
importantly, it will also need a new generation of graduate students
and other developers to engage, to build a NumPy that meets the needs
of the next decade of data science.
| {'timestamp': '2020-06-19T02:08:10', 'yymm': '2006', 'arxiv_id': '2006.10256', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10256'} | arxiv |
\subsection{Regret analysis}\label{section:regret_analysis_appendix}
In order to show a regret bound for Algorithm \ref{alg::optimism_pessimism}, we start with the following regret decomposition:
\begin{align*}
\mathcal{R}_\Pi(T) &= \sum_{t=1}^T \mathbb{E}_{a\sim \pi^*}[\bar{r}_a] - \mathbb{E}_{a \sim \pi_t}[\bar{r}_{a}] \\
&=\underbrace{\left( \sum_{t=1}^T \mathbb{E}_{a\sim \pi^*}[\bar{r}_a] - \mathbb{E}_{a \sim \pi_t}[u_a^r(t)] \right)}_{(i)} +\underbrace{ \left(\sum_{t=1}^T \mathbb{E}_{a\sim \pi_t}[u^r_a(t)] - \mathbb{E}_{a \sim \pi_t}[\bar{r}_{a}] \right) }_{(ii)}.
\end{align*}
In order to bound $\mathcal{R}_\Pi(T)$, we independently bound terms $(i)$ and $(ii)$.
We start by bounding term (i). We proceed by first proving an Lemma~\ref{lemma::optimism}, the equivalent version of Lemma~\ref{lemma:linear_bandits_optimism} for the multi armed bandit problem.
\subsection{Proof of Lemma~\ref{lemma::optimism}}
\begin{proof}
Throughout this proof we denote as $\pi_0$ to the delta function over the safe arm $1$. We start by noting that under $\mathcal{E}$, and because $\alpha_r, \alpha_c \geq 1$, then:
\begin{equation}
\label{equation::confidence_interval_lower_bounds}
(\alpha_r-1)\beta_a(t) \leq \xi_a^r(t) \leq (\alpha_r + 1)\beta_a(t) \text{ } \forall a \quad \text{ and } \quad (\alpha_c-1)\beta_a(t) \leq \xi_a^c(t) \leq (\alpha_c+1)\beta_a(t) \text{ } \forall a \neq 0.
\end{equation}
If $\pi^*\in \Pi_t$, it immediately follows that:
\begin{equation}
\label{equation::feasible_lower_bound}
\mathbb{E}_{a\sim \pi^*}\left[\bar{r}_a \right] \leq \mathbb{E}_{a\sim \pi^*}\left[u_a^r(t)\right] \leq \mathbb{E}_{a \sim \pi_t}\left[ u_a^r(t)\right].
\end{equation}
Let's now assume $\pi^* \not\in \Pi_t$, i.e.,~$\mathbb{E}_{a\sim\pi^*}\left[u_a^c(t)\right] > \tau$. Let $\pi^* = \rho^* \bar{\pi}^* + (1-\rho)\pi_0$ with $\bar{\pi}^* \in \Delta_K[2:K]$\footnote{In other words, the support of $\bar{\pi}^*$ does not contain the safe arm $1$.}.
Consider a mixture policy $\widetilde{\pi}_t = \gamma_t \pi^* + (1-\gamma_t)\pi_0 = \gamma_t \rho^* \bar{\pi}^* + (1-\gamma_t \rho^*)\pi_0$, where $\gamma_t$ is the maximum $\gamma_t\in [0,1]$ such that $\widetilde{\pi}_t\in\Pi_t$. It can be easily established that
\begin{align*}
\gamma_t &= \frac{\tau-\bar{c}_1}{\rho^*\mathbb{E}_{a \sim \bar{\pi}^*}\left[u^c_a(t)\right] - \rho^*\bar{c}_1} =\frac{\tau - \bar{c}_1}{ \mathbb{E}_{a \sim \bar{\pi}^*}[\rho^*(\bar{c}_a + \xi_a^c(t) )] - \rho^* \bar{c}_1} \\
&\stackrel{(i)}{ \geq} \frac{\tau - \bar{c}_1}{\tau - \bar{c}_1 + \rho^* (1+\alpha_c)\mathbb{E}_{a \sim \bar{\pi}^*}[\beta_a(t)]}.
\end{align*}
{\bf (i)} is a consequence of~\eqref{equation::confidence_interval_lower_bounds} and of the observation that since $\pi^*$ is feasible $\rho^*\mathbb{E}_{a \sim \bar{\pi}^*}[\bar{c}_a] + (1-\rho^*)\bar{c}_1 \leq \tau$. Since $\widetilde{\pi}_t\in\Pi_t$, we have
\begin{align*}
\mathbb{E}_{a \sim \pi_t }[u_a^r(t)] &\geq \underbrace{\gamma_t \mathbb{E}_{a \sim \pi^*}[u_a^r(t)] + (1-\gamma_t)u^r_0(t)}_{\mathbb{E}_{a\sim \widetilde{\pi}_t}\left[ u_a^r(t)\right]} \\
&\stackrel{(ii)}{\geq} \frac{\tau - \bar{c}_1}{\tau - \bar{c}_1 + \rho^* (1+\alpha_c)\mathbb{E}_{a \sim \bar{\pi}^*}[\beta_a(t)]} \times \mathbb{E}_{a \sim \pi^*}[u_a^r(t)] \\
&= \frac{\tau-\bar{c}_1}{\tau -\bar{c}_1 + \rho^*(1+\alpha_c)\mathbb{E}_{a \sim \bar{\pi}^*}[\beta_a(t)]} \times \Big(\mathbb{E}_{a \sim \pi^*}[\bar{r}_a] + \mathbb{E}_{a \sim \pi^*}[\xi_a^r(t)]\Big) \\
&\stackrel{(iii)}{\geq} \frac{\tau - \bar{c}_1}{\tau -\bar{c}_1 +\rho^* (1+\alpha_c)\mathbb{E}_{a \sim \bar{\pi}^*}[\beta_a(t)]} \times \Big(\mathbb{E}_{a \sim \pi^*}[\bar{r}_a] + (\alpha_r-1)\mathbb{E}_{a \sim \pi^*}[\beta_a(t)]\Big) \\
&\stackrel{(iv)}{\geq}\underbrace{\frac{\tau-\bar{c}_1}{\tau -\bar{c}_1+ (1+\alpha_c)\mathbb{E}_{a \sim \pi^*}[\beta_a(t)]} \times \Big(\mathbb{E}_{a \sim \pi^*}[\bar{r}_a ] + (\alpha_r-1)\mathbb{E}_{a \sim \pi^*}[\beta_a(t)]\Big)}_{C_0}.
\end{align*}
{\bf (ii)} holds because $u_0^r(t)\geq 0$. {\bf (iii)} is a consequence of~\eqref{equation::confidence_interval_lower_bounds} and {\bf (iv)} follows because $\mathbb{E}_{a \sim \pi^*}[ \beta_a(t)] = \rho^* \mathbb{E}_{a \sim \bar{\pi}^*}[\beta_a(t)] + (1-\rho^*)\beta_0(t) \geq \rho^* \mathbb{E}_{a \sim \bar{\pi}^*}[\beta_a(t)]$ since $\beta_a(t) \geq 0$ for all $a$ and $t$.
Let $C_1 = \mathbb{E}_{a \sim \pi^*}[\beta_a(t)]$. The following holds:
\begin{equation*}
C_0 = \frac{\tau-\bar{c}_1}{\tau - \bar{c}_1 + (1+\alpha_c)C_1}\times\Big(\mathbb{E}_{a \sim \pi^*}[\bar{r}_a] + (\alpha_r-1)C_1\Big).
\end{equation*}
Note that $C_0 \geq \mathbb{E}_{a \sim \pi^*}\left[\bar{r}_a \right]$ iff:
\begin{equation*}
(\tau-\bar{c}_1) \mathbb{E}_{a \sim \pi^*}[\bar{r}_a] + (\tau-\bar{c}_1)(\alpha_r-1)C_1 \geq (\tau-\bar{c}_1)\mathbb{E}_{a \sim \pi^*}\left[\bar{r}_a \right] + (1+\alpha_c)C_1\mathbb{E}_{a \sim \pi^*}\left[\bar{r}_a \right],
\end{equation*}
which holds iff:
\begin{equation*}
(\tau-\bar{c}_1)(\alpha_r-1)C_1 \geq (1+\alpha_c)C_1\mathbb{E}_{a\sim \pi^*}[\bar{r}_a].
\end{equation*}
Since $\mathbb{E}_{a\sim \pi^*}\left[ \bar{r}_a\right] \leq 1$, this holds if $1+\alpha_c \leq (\tau-\bar{c}_1) (\alpha_r-1)$.
\end{proof}
\begin{proposition}\label{proposition::bounding_term_I}
If $\delta = \frac{\epsilon}{4KT}$ for $\epsilon \in (0,1)$, $\alpha_r, \alpha_c \geq 1$ with $\alpha_c \leq \tau (\alpha_r -1)$, then with probability at least $1-\frac{\epsilon}{2}$, we have
\begin{equation*}
\sum_{t=1}^T \mathbb{E}_{a\sim \pi^*}[\bar{r}_a] - \mathbb{E}_{a \sim \pi_t}[u_a^r(t)] \leq 0
\end{equation*}
\end{proposition}
\begin{proof}
A simple union bound implies that $\mathbb{P}(\mathcal{E}) \geq 1-\frac{\epsilon}{2}$. Combining this observation with Lemma \ref{lemma::optimism} yields the result.
\end{proof}
Term $(ii)$ can be bound using the confidence intervals radii:
\begin{proposition}
\label{proposition::bounding_term_II}
If $\delta = \frac{\epsilon}{4KT}$ for an $\epsilon \in (0,1)$, then with probability at least $1-\frac{\epsilon}{2}$, we have
\begin{equation*}
\sum_{t=1}^T \mathbb{E}_{a\sim \pi_t}[u_a^r(t)] - \mathbb{E}_{a \sim \pi_t}[\bar{r}_{a}] \leq (\alpha_r+1) \left(2\sqrt{2TK\log(1/\delta)} + 4\sqrt{T\log(2/\epsilon)\log(1/\delta)} \right)
\end{equation*}
\end{proposition}
\begin{proof}
Under these conditions $\mathbb{P}(\mathcal{E}) \geq 1-
\frac{\epsilon}{2}$. Recall $u_a^r(t) = \widehat{r}_a(t) + \alpha_r\beta_a(t)$ and that conditional on $\mathcal{E}$, $\bar{r}_a \in [\widehat{r}_a(t) - \beta_a(t),\widehat{r}_a(t) + \beta_a(t)]$ for all $t \in [T]$ and $a \in \mathcal{A}$. Thus, for all $t$, we have
\begin{equation*}
\mathbb{E}_{a \sim \pi_t}[u_a^r(t)] - \mathbb{E}_{a \sim \pi_t}[\bar{r}_a] \leq (\alpha_r +1)\mathbb{E}_{a \sim \pi_t}[\beta_a(t)].
\end{equation*}
Let $\mathcal{F}_{t-1}$ be the sigma algebra defined up to the choice of $\pi_t$ and $a_t'$ be a random variable distributed as $\pi_t \mid \mathcal{F}_{t-1}$ and conditionally independent from $a_t$, i.e.,~$a'_t \perp a_t \mid \mathcal{F}_{t-1}$. Note that by definition the following equality holds:
\begin{equation*}
\mathbb{E}_{a \sim \pi_t}[\beta_a(t)] = \mathbb{E}_{a'_t \sim \pi_t}[\beta_a(t) \mid \mathcal{F}_{t-1}].
\end{equation*}
Consider the following random variables $A_t = \mathbb{E}_{a'_t \sim \pi_t} [\beta_{a'_t}(t) \mid \mathcal{F}_{t-1}]- \beta_{a_t}(t)$. Note that $M_t = \sum_{i=1}^t A_i$ is a martingale. Since $|A_t| \leq 2\sqrt{2 \log(1/\delta)}$, a simple application of Azuma-Hoeffding\footnote{We use the following version of Azuma-Hoeffding: if $X_n$, $n\geq 1$ is a martingale such that $|X_i - X_{i-1}| \leq d_i$, for $1 \leq i \leq n$, then for every $n \geq 1$, we have $\mathbb{P}(X_n > r) \leq \exp\left(-\frac{r^2 }{2\sum_{i=1}^n d_i^2}\right)$.} implies:
\begin{equation*}
\mathbb{P}\left(\underbrace{\sum_{t=1}^T \mathbb{E}_{a \sim \pi_t} [\beta_a(t)] \geq \sum_{t=1}^T \beta_{a_t}(t) + 4\sqrt{T\log(2/\epsilon)\log(1/\delta)}}_{\mathcal{E}_A^c}\right ) \leq \epsilon/2.
\end{equation*}
We can now upper-bound $\sum_{t=1}^T \beta_{a_t}(t)$. Note that $\sum_{t=1}^T \beta_{a_t}(t) = \sum_{a \in \mathcal{A}}\sum_{t=1}^T \mathbf{1}\{a_t=a\}\beta_a(t)$. We start by bounding for an action $a\in\mathcal A$:
\begin{align*}
\sum_{t=1}^T \mathbf{1}\{a_t=a\}\beta_a(t) = \sqrt{2\log(1/\delta)} \sum_{t=1}^{T_a(T)} \frac{1}{\sqrt{t}} \leq 2\sqrt{2T_a(T)\log(1/\delta)}.
\end{align*}
Since $\sum_{a\in\mathcal A } T_a(T) = T$ and by concavity of $\sqrt{ \cdot}$, we have
\begin{equation*}
\sum_{a\in\mathcal A} 2\sqrt{2T_a(T)\log(1/\delta)} \leq 2\sqrt{2TK\log(1/\delta)}.
\end{equation*}
Conditioning on the event $\mathcal{E} \cap \mathcal{E}_A$ whose probability satisfies $\mathbb{P}( \mathcal{E}\cap \mathcal{E}_A) \geq 1-\epsilon $ yields the result.
\end{proof}
We can combine these two results into our main theorem:
\begin{theorem}[Main Theorem]
If $\epsilon \in(0,1)$, $ \alpha_c=1$ and $\alpha_r = \frac{2}{\tau-\bar{c}_1} + 1$, then with probability at least $1-\epsilon$, Algorithm \ref{alg::optimism_pessimism} satisfies the following regret guarantee:
\begin{equation*}
\mathcal{R}_\Pi(T) \leq \left(\frac{2}{\tau-\bar{c}_1} +1\right)\left(2\sqrt{2TK\log(4KT/\epsilon)} + 4\sqrt{T\log(2/\epsilon)\log(4KT/\epsilon)} \right)
\end{equation*}
\end{theorem}
\begin{proof}
This result is a direct consequence of Propositions \ref{proposition::bounding_term_I} and \ref{proposition::bounding_term_II} by setting $ \delta = 4KT \epsilon$.
\end{proof}
\subsection{Multiple constraints}\label{section::multiple_constraints_appendix}
We consider the problem where the learner must satisfy $M$ constraints with threshold values $\tau_1, \cdots, \tau_M$. Borrowing from the notation in the previous sections, we denote by as $\{\bar{r}_a\}_{a\in \mathcal{A}}$ the mean reward signals and $\{ \bar{c}_a^{(i)} \}$ the mean cost signals for $i = 1,\cdots, M$. The full information optimal policy can be obtained by solving the following linear program:
\begin{align*}
\label{eq::no_noise_LP_multiple_constraints}\tag{P-M}
\max_{\pi \in \mathrm{\Delta}_K} &\; \sum_{a \in \mathcal{A}} \pi_a \bar{r}_a, \\
\text{s.t. } &\; \sum_{a \in \mathcal{A}} \pi_a \bar{c}^{(i)}_a \leq \tau_i \text{ for } i=1, \cdots, M.
\end{align*}
In order to ensure the learner's ability to produce a feasible policy at all times, we make the following assumption:
\begin{assumption}
The learner has knowledge of $\bar{c}_1^{(i)} < \tau_i$ for all $i = 1, \cdots, M$.
\end{assumption}
We denote by $\{ \widehat{r}_a \}_{a \in \mathcal{A}}$ and $\{ \widehat{c}_a^{(i)} \}_{a\in\mathcal{A}}$ for $i = 1, \cdots, M$ the empirical means of the reward and cost signals. We call $\{ u_a^r(t)\}_{a \in \mathcal{A}}$ to the upper confidence bounds for our reward signal and $\{ u_a^{c}(t, i)\}_{a \in \mathcal{A}}$ for $i = 1, \cdots, M$ the costs' upper confidence bounds:
\begin{equation*}
u_a^r(t) = \widehat{r}_a(t) + \alpha_r \beta_a(t), \qquad u_a^c(t, i) = \widehat{c}^{(i)}_a(t) + \alpha_c \beta_a(t),
\end{equation*}
where $\beta_a(t) = \sqrt{2\log(1/\delta)/T_a(t)}$, $\delta \in (0,1)$ as before. A straightforward extension of Algorithm \ref{alg::optimism_pessimism} considers instead the following $M-$constraints LP:
\begin{align*}
\label{eq::noisy_LP_multiple}
\tag{$\widehat{P-M}$}
&\max_{\pi\in\mathrm{\Delta}_K} \;\; \sum_{a \in \mathcal{A}} \pi_a \; u^r_a(t)\;\;\; \\
&\;\text{s.t.} \quad\; \sum_{a \in \mathcal{A}} \pi_a \; u_a^c(t, i)\leq \tau_i, \text{ for } i= 1, \cdots, M.
\end{align*}
We now generalize Lemma \ref{lemma::optimism}:
\begin{lemma}\label{lemma::optimisim_multiple}
Let $\alpha_r, \alpha_c\geq 1$ satisfying $\alpha_c \leq \min_i(\tau_i- \bar{c}^{(i)}_1) (\alpha_r-1)$. Conditioning on $\mathcal{E}_a(t)$ ensures that with probability $1-\delta$:
\begin{equation*}
\mathbb{E}_{a \sim \pi_t}\left[u_a^r(t)\right] \geq \mathbb{E}_{a \sim \pi^*}\left[\bar{r}_a \right].
\end{equation*}
\end{lemma}
\begin{proof}
The same argument as in the proof of Lemma \ref{lemma::optimism} follows through, the main ingredient is to realize that $\gamma_t$ satisfies the sequence of inequalities in the lemma with $\tau - \bar{c}_1$ substituted by $\min \tau_i - \bar{c}_1^{(i)}$.
\end{proof}
The following result follows:
\begin{theorem}[Multiple Constraints Main Theorem]
If $\epsilon \in(0,1)$, $ \alpha_c=1$ and $\alpha_r = \frac{2}{\min_i \tau_i-\bar{c}^{(i)}_1} + 1$, then with probability at least $1-\epsilon$, Algorithm \ref{alg::optimism_pessimism} satisfies the following regret guarantee:
\begin{equation*}
\mathcal{R}_\Pi(T) \leq \left(\frac{2}{\min_i\tau_i-\bar{c}^{(i)}_1} +1\right)\left(2\sqrt{2TK\log(4KT/\epsilon)} + 4\sqrt{T\log(2/\epsilon)\log(4KT/\epsilon)} \right)
\end{equation*}
\end{theorem}
\begin{proof}
The proof follows the exact same argument we used for the proof of Theorem~\ref{theorem::contrained_MAB} substituting $\tau - \bar{c}_1$ by $\min_i \tau_i -\bar{c}_1^{(i)}$.
\end{proof}
\subsection{Lower bound}
\label{section::lower_bound_MAB_appendix}
\input{lower_bounds}
\section{Related Work}
\label{sec:related-work}
\vspace{-0.1in}
As described in Section~\ref{sec:intro}, our setting is the closest to the one studied by~\cite{amani2019linear} and~\cite{Moradipari19SL}. They study a slightly different setting, in which the mean cost of the action that the agent takes should satisfy the constraint, i.e.,~$\langle x_t,\mu_*\rangle \leq \tau$, not the mean cost of the policy it computes, i.e.,~$\langle x_{\pi_t},\mu_*\rangle \leq \tau$, as in our case. Clearly, the setting studied in our paper is more relaxed, and thus, is expected to obtain more rewards.~\cite{Moradipari19SL} propose a TS algorithm for their setting and prove an $\widetilde{O}(d^{3/2}\sqrt{T}/\tau)$ regret bound for it. They restrict themselves to linear bandits, i.e.,~$\mathcal A_t=\mathcal A,\forall t\in[T]$, and the safe action being the origin, i.e.,~$x_0=\mathbf{0}$ and $c_0=0$. This is why $c_0$ does not appear in their bounds. They consider their action set to be any convex compact subset of $\mathbb R^d$ that contains the origin. Although later in their proofs, to guarantee that their algorithm does not violate the constraint in the first round, they require the action set to also contain the ball with radius $\tau/S$ around the origin. Therefore, our action set is more general than theirs. Moreover, unlike us, their action set does not allows their results to be immediately applicable to MAB. Our regret bound also has a better dependence on $d$ and $\log T$ than theirs, similar to the best regret results for UCB vs.~TS. However, their algorithm is TS, and thus, is less complex than ours. Although it can be still intractable, even when $\mathcal A$ is convex. They needed to do several approximations in order to make their algorithm tractable in their experiments.
In~\cite{amani2019linear}, reward and cost have the same unknown parameter $\theta_*$, and the cost is defined as $c_t=x_t^\top B\theta_*\leq\tau$, where $B$ is a known matrix. They derive and analyze an explore-exploit algorithm for this setting. Although our rate is better than theirs, i.e.,~$\widetilde{O}(T^{2/3})$, our algorithm cannot immediately give a $\widetilde{O}(\sqrt{T})$ regret for their setting, unless in special cases.
\section{Conclusions}
\label{sec:conclu}
\vspace{-0.1in}
We derived a UCB-style algorithm for a new constrained contextual linear bandit setting, in which the goal is to produce a sequence of policies with maximum expected cumulative reward, while each policy has an expected cost below a certain threshold $\tau$. We proved a $T$-round regret bound of $\widetilde{\mathcal{O}}(\frac{d\sqrt{T}}{\tau-c_0})$ for our algorithm, which shows that the difficulty of the problem depends on the difference between the constraint threshold and the cost of a known feasible action $c_0$. We further specialized our results to MAB and proposed and analyzed a computationally efficient algorithm for this setting. We also proved a lower-bound for our constrained bandit problem and provided simulations to validate our theoretical results. A future direction is to use the optimism-pessimism idea behind our algorithm in other constrained bandit settings, including deriving a UCB-style algorithm for the setting studied in~\cite{amani2019linear} and~\cite{Moradipari19SL}.
\section*{Broader Impact}
\section{Proofs of Section~\ref{sec:algo}}
\label{sec:proofs-algo-section}
\subsection{Proof of Proposition~\ref{prop:optimistic-reward-pessimistic-cost}}
\label{subsec:proof-prop-optimistic-reward}
\begin{proof}
We only prove the statement for the optimistic reward, $\widetilde{r}_{\pi,t}$. The proof for the pessimistic cost, $\widetilde{c}_{\pi,t}$, is analogous. From the definition of the confidence set $\mathcal{C}_t^r(\alpha_r)$ in~\eqref{eq:confidence-ellipsoids}, any vector $\theta \in \mathcal{C}_t^r(\alpha_r)$ can be written as $\widehat{\theta}_t + v$, where $v$ satisfying $\| v\|_{\Sigma_t} \leq \alpha_r \beta_t(\delta, d)$. Thus, we may write
\begin{align*}
\widetilde{r}_{\pi,t} &= \max_{\theta \in \mathcal{C}_t^r(\alpha_r)} \mathbb{E}_{x \sim \pi}[ \langle x, \theta \rangle ] = \max_{\theta \in \mathcal{C}_t^r(\alpha_r)} \langle x_\pi, \theta \rangle = \langle x_\pi, \widehat{\theta}_t \rangle + \max_{v:\|v\|_{\Sigma_t} \leq \alpha_r \beta_t(\delta, d)} \langle x_\pi, v \rangle \\
&\stackrel{\text{(a)}}{\leq} \langle x_\pi,\widehat{\theta}_t \rangle + \alpha_r \beta_t(\delta, d) \| x_\pi \|_{\Sigma_t^{-1}}.
\end{align*}
{\bf (a)} By Cauchy-Schwartz, for all $v$, we have $\langle x_{\pi}, v \rangle \leq \| x_{\pi}\|_{\Sigma_t^{-1}} \| v\|_{\Sigma_t}$. The result follows from the condition on $v$ in the maximum, i.e.,~$\| v \|_{\Sigma_t} \leq \alpha_r \beta_t(\delta,d)$.
Let us define $v^* := \frac{ \alpha_r \beta_t(\delta, d) \Sigma^{-1}_t x_\pi}{\| x_\pi \|_{\Sigma^{-1}_t}}$. This value of $v^*$ is feasible because
\begin{equation*}
\|v^*\|_{\Sigma_t} = \frac{\alpha_r \beta_t(\delta,d)}{\| x_\pi \|_{\Sigma^{-1}_t}} \sqrt{x_\pi^\top \Sigma_t^{-1} \Sigma_t \Sigma_t^{-1} x_\pi} = \frac{\alpha_r\beta_t(\delta,d)}{\|x_\pi\|_{\Sigma^{-1}_t}} \sqrt{x_\pi^\top\Sigma_t^{-1}x_\pi} = \alpha_r\beta_t(\delta, d).
\end{equation*}
We now show that $v^*$ also achieves the upper-bound in the above inequality resulted from Cauchy-Schwartz
\begin{equation*}
\langle x_\pi, v^* \rangle = \frac{\alpha_r \beta_t(\delta, d) x_\pi^\top \Sigma_t^{-1} x_\pi}{\| x_\pi \|_{\Sigma_t^{-1}}} = \alpha_r \beta_t(\delta, d) \| x_\pi \|_{\Sigma_t^{-1}}.
\end{equation*}
Thus, $v^*$ is the maximizer and we can write
\begin{align*}
\widetilde{r}_{\pi,t} = \langle x_\pi,\widehat{\theta}_t \rangle + \langle x_\pi,v^* \rangle = \langle x_\pi,\widehat{\theta}_t \rangle + \alpha_r \beta_t(\delta, d) \| x_\pi \|_{\Sigma_t^{-1}},
\end{align*}
which concludes the proof.
\end{proof}
\subsection{Proof of Proposition~\ref{prop:safe-set}}
\label{subsec:proof-safe-set}
\begin{proof}
Recall that $\tilde{c}_{\pi, t} = \frac{ \langle x_{\pi}^o, e_0\rangle c_0}{ \| x_0\| } + \langle x_{\pi}^{o, \perp}, \widehat{t}_{\pi}^{o, \perp}\rangle + \alpha_c \beta_t(\delta, d-1)\| x_{\pi}^{o, \perp} \|_{ (\Sigma^{o, \perp}_t)^{-1}}\leq \tau$.
Conditioned on the event $\mathcal{E}$ as defined in equation \ref{eq:high-prob-event}, it follows that:
\begin{align*}
|\langle x_{\pi}^{o, \perp} , \widehat{\mu}_t^{o, \perp} -\mu_*^{o, \perp}\rangle| &\leq \| \mu_*^{o, \perp} - \widehat{\mu}_t^{o, \perp} \|_{\Sigma_t^{o, \perp}}\| x_{\pi}\|_{(\Sigma^{o, \perp}_t)^{-1}} \\
&\leq \langle x_{\pi}^{o, \perp} , \widehat{\mu}_t^{o, \perp} -\mu_*^{o, \perp}\rangle \beta_t
(\delta, d-1) \| x_{\pi}\|_{(\Sigma^{o, \perp}_t)^{-1}}
\end{align*}
And therefore:
\begin{equation}
0 \leq \langle x_{\pi}^{o, \perp} , \widehat{\mu}_t^{o, \perp} -\mu_*^{o, \perp}\rangle + \beta_t
(\delta, d-1) \| x_{\pi}\|_{(\Sigma^{o, \perp}_t)^{-1}} \label{equation::prop_3_eq1}
\end{equation}
Observe that:
\begin{align}
c_{\pi} &= \frac{ \langle x_{\pi}^o, e_0\rangle c_0}{ \| x_0\| } + \langle x_{\pi}^{o, \perp}, \mu_*^{o, \perp}\rangle \notag\\
&\leq \underbrace{\frac{ \langle x_{\pi}^o, e_0\rangle c_0}{ \| x_0\| } + \langle x_{\pi}^{o, \perp}, \widehat{\mu}_{t}^{o, \perp}\rangle + \alpha_c \beta_t(\delta, d-1)\| x_{\pi}^{o, \perp} \|_{ (\Sigma^{o, \perp}_t)^{-1}}}_{\mathrm{I}}\label{equation::prop_3_eq2}
\end{align}
The last inequality holds by adding Inequality \ref{equation::prop_3_eq1} to Inequality \ref{equation::prop_3_eq2}. Since by assumption for all $\pi \in \Pi_t$ term $I \leq \tau$, we obtain that $c_\pi \leq \tau$. The result follows.
\end{proof}
\newpage
\section{Proofs of Section~\ref{section::lin_opt_pess_analysis}}
\label{sec:proofs-analysis-section}
\subsection{Proof of Lemma~\ref{lemma:bounding-4}}
\label{subsec:proof-Lemma-bounding-4}
We first state the following proposition that is used in the proof of Lemma~\ref{lemma:bounding-4}. This proposition is a direct consequence of Eq.~20.9 and Lemma~19.4 in~\cite{lattimore2018bandit}. Similar result has also been reported in the appendix of~\cite{amani2019linear}.
\begin{proposition}
\label{proposition:det_lemma}
For any sequence of actions $(x_1,\ldots,x_t)$, let $\Sigma_t$ be its corresponding Gram matrix defined by~\eqref{eq:Sigmas} with $\lambda \geq 1$. Then, for all $t\in[T]$, we have
\vspace{-0.15in}
\begin{small}
\begin{equation*}
\sum_{s=1}^T \| x_s \|_{\Sigma^{-1}_{s}} \leq \sqrt{2Td\log\big( 1+\frac{TL^2}{\lambda}\big)}.
\end{equation*}
\end{small}
\end{proposition}
We now state the proof of Lemma~\ref{lemma:bounding-4}.
\begin{proof}[Proof of Lemma~\ref{lemma:bounding-4}]
We prove this lemma through the following sequence of inequalities:
\vspace{-0.15in}
\begin{small}
\begin{align*}
\sum_{t=1}^T \langle x_t, \widetilde{\theta}_t\rangle - \langle x_t, \theta_* \rangle &\stackrel{\text{(a)}}{\leq} \sum_{t=1}^T \| x_t \|_{\Sigma_t^{-1}}\| \widetilde{\theta}_t - \theta_* \|_{\Sigma_t} \stackrel{\text{(b)}}{\leq} \sum_{t=1}^T (1+\alpha_r) \beta_t(\delta,d)\| x_t \|_{\Sigma_t^{-1}} \\
&\stackrel{\text{(c)}}{\leq} (1+\alpha_r)\beta_T(\delta,d) \sum_{t=1}^T \| x_t \|_{\Sigma_t^{-1}} \stackrel{\text{(d)}}{\leq}(1+\alpha_r)\beta_T(\delta,d) \sqrt{2Td\log\big(1+\frac{TL^2}{\lambda}\big)}
\end{align*}
\end{small}
\vspace{-0.15in}
{\bf (a)} This is by Cauchy-Schwartz.
{\bf (b)} This follows from the fact that $\widetilde{\theta}_t\in \mathcal{C}_t^r(\alpha_r)$ and we are on event $\mathcal E$.
{\bf (c)} This is because $\beta_t(\delta,d)$ is an increasing function of $t$, i.e.,~$\beta_T(\delta,d) \geq \beta_t(\delta,d),\;\forall t\in [T]$.
{\bf (d)} This is a direct result of Proposition~\ref{proposition:det_lemma}.
\end{proof}
\subsection{Proof of Lemma~\ref{lemma:inverse_norm_domination}}
\label{subsec:proof-Lemma-inverse-norm-domination}
\begin{proof}
In order to prove the desired result it is enough to show that:
\begin{equation*}
\left( x_{\pi}^{o, \perp}\right)^\top \left( \Sigma_t^{o, \perp}\right)^{\dagger} x_\pi^{o, \perp} \leq x_\pi^\top \Sigma_t^{-1}x_\pi
\end{equation*}
w.l.o.g. we can assume $x_o = e_1$, the first basis vector. Notice that in this case $\Sigma_t^{o, \perp}$ can be thought of as a submatrix of $\Sigma_t$ such that $\Sigma_t[2:, 2:] = \Sigma_t^{o, \perp}$, where $\Sigma_t[2:, 2:]$ denotes the submatrix with row and column indices from $2$ onwards.
Using the following formula for the inverse of a psd symmetric matrix:
\begin{equation*}
\begin{bmatrix}
Z & \delta\\
\delta^\top & A
\end{bmatrix} = \begin{bmatrix}
\frac{1}{D} & -\frac{ A^{-1}\delta}{D}\\
- \frac{\delta^\top A^{-1} }{D}&A^{-1} + \frac{ A^{1} \delta \delta^\top A^{-1}}{D}
\end{bmatrix}
\end{equation*}
Where $D = z- \delta^\top A^{-1} \delta$. In our case $D = \Sigma_t[1,1] - \Sigma_t[2:d]^\top \left( \Sigma_t^{o, \perp} \right)^{-1} \Sigma_t[2:d] \in \mathbb{R}$. Observe that since $\Sigma_t$ is PSD, $D \geq 0$. Therefore:
\begin{equation*}
\Sigma_t^{-1} = \begin{bmatrix}
1/D & -\frac{\left(\Sigma_t^{o, \perp}\right)^{-1} \Sigma_t[2, :d] }{D} \\
-\frac{\Sigma_t^\top [2:d]\left( \Sigma_t^{o, \perp}\right)^{-1} }{D} & \left( \Sigma_t^{o, \perp} \right)^{-1} + \frac{ \left( \Sigma_t^{o, \perp}\right)^{-1} \Sigma_t[2:d]\Sigma_t[2:d]\left(\Sigma_t^{o, \perp}\right)^{-1} }{D}
\end{bmatrix}
\end{equation*}
Then:
\begin{align*}
x_\pi^\top \left( \Sigma_t^{-1} \right)^{-1} x_\pi &= \frac{ x_\pi(1)^2 - 2x_\pi(1)\Sigma_t[2:d]^\top\left( \Sigma_t^{o, \perp} \right)^{-1} x_\pi[2:d]}{D} +\\
&\frac{ x_\pi[2:d]^\top \left(\Sigma_t^{o, \perp} \right)^{-1} \Sigma_t[2:d]\Sigma_t[2:d]^\top\left( \Sigma_t^{o, \perp} \right)^{-1} x_\pi[2:d] }{D} \\
&+ x_\pi[2:d]^\top \left( \Sigma_t^{o, \perp} \right)^{-1} x_\pi[2:d]\\
&\geq x_\pi[2:d]^\top \left( \Sigma_t^{o, \perp} \right)^{-1} x_\pi[2:d]
\end{align*}
The result follows by noting that $x_\pi[2:d] = x_\pi^{o, \perp}$.
\end{proof}
\subsection{Proof of Lemma~\ref{lemma:linear_bandits_optimism}}
\label{subsec:proof-Lemma-term-I}
\begin{proof}
For any policy $\pi$, we have
\begin{equation}
\label{eq:tempB0}
\widetilde{r}_{\pi,t} = \max_{\theta \in \mathcal{C}_t^r(\alpha_r)} \langle x_\pi,\theta \rangle \geq \langle x_\pi, \theta_* \rangle = r_\pi.
\end{equation}
If $\pi_t^* \in \Pi_t$, then by the definition of $\pi_t$ (Line~4 of Algorithm~\ref{alg:optimistic-pessimistic-LB}), we have
\begin{equation}
\label{eq:tempB1}
\widetilde{r}_{\pi_t,t} \geq \widetilde{r}_{\pi_t^*,t}.
\end{equation}
Combining~\eqref{eq:tempB0} and~\eqref{eq:tempB1}, we may conclude that $\widetilde{r}_{\pi_t,t} \geq r_{\pi_t^*}$ as desired.
We now focus on the case that $\pi_t^* \not\in \Pi_t$, i.e.,
\begin{equation*}
\widetilde{c}_{\pi_t^*,t} = \frac{\langle x_{\pi^*_t}^o,e_0 \rangle c_0}{\|x_0\|} + \langle x_{\pi^*_t}^{o,\perp},\widehat{\mu}^{o,\perp}_t \rangle + \alpha_c\beta_t(\delta,d-1) \| x_{\pi^*_t}^{o,\perp} \|_{(\Sigma_t^{o,\perp})^{-1}} > \tau.
\end{equation*}
We define a mixture policy $\widetilde{\pi}_t = \eta_t \pi_t^* + (1-\eta_t)\pi_0$, where $\pi_0$ is the policy that always selects the safe action $x_0$ and $\eta_t \in [0,1]$ is the maximum value of $\eta$ such that $\big(\eta\pi^*_t+(1-\eta)\pi_0\big) \in \Pi_t$. Conceptually, $\eta_t$ shows how close is the optimal policy $\pi^*_t$ to the set of safe policies $\Pi_t$.
By the definition of $\widetilde{\pi}_t$, we have
\begin{equation}
\label{eq:tempB2}
x^o_{\widetilde{\pi}_t} = \eta_t x^o_{\pi_t^*} + (1-\eta_t)x_0, \qquad x^{o,\perp}_{\widetilde{\pi}_t} = \eta_t x^{o,\perp}_{\pi_t^*},
\end{equation}
which allows us to write
\begin{align*}
\widetilde{c}_{\widetilde{\pi}_t,t} &= \frac{\eta_t\langle x_{\pi_t^*}^o,e_0 \rangle + (1-\eta_t) \langle x_0,e_0 \rangle}{\|x_0\|}\cdot c_0 + \eta_t \langle x_{\pi_t^*}^{o,\perp}, \widehat{\mu}^{o,\perp}_t \rangle + \eta_t\alpha_c\beta_t(\delta,d-1) \| x_{\pi_t^*}^{o,\perp} \|_{(\Sigma_t^{o,\perp})^{-1} } \\
&= \frac{(1-\eta_t) \langle x_0,e_0 \rangle c_0}{\|x_0\|} + \eta_t \widetilde{c}_{\pi_t^*,t}.
\end{align*}
From the definition of $\eta_t$, we have $\widetilde{c}_{\widetilde{\pi}_t,t}=\frac{(1-\eta_t) \langle x_0,e_0 \rangle c_0}{\|x_0\|} + \eta_t \widetilde{c}_{\pi_t^*,t}=\tau$, and thus, we may write
\begin{align}
\eta_t &= \frac{\tau - \frac{\langle x_0,e_0 \rangle c_0}{\|x_0\|}}{\widetilde{c}_{\pi_t^*,t} - \frac{\langle x_0,e_0 \rangle c_0}{\|x_0\|}} = \frac{\tau - c_0}{\frac{\langle x_{\pi_t^*}^o,e_0\rangle c_0}{\|x_0\|} + \langle x_{\pi_t^*}^{o,\perp}, \widehat{\mu}^{o,\perp}_t \rangle + \alpha_c\beta_t(\delta,d-1)\|x^{o,\perp}_{\pi_t^*}\|_{(\Sigma^{0, \perp}_t)^{-1}} - c_0} \nonumber \\
&= \frac{\tau - c_0}{\frac{\langle x_{\pi_t^*}^o,e_0 \rangle c_0}{\|x_0\|} + \langle x_{\pi_t^*}^{o,\perp},\mu_* \rangle + \langle x_{\pi_t^*}^{o, \perp}, \widehat{\mu}^{o,\perp}_t - \mu_* \rangle + \alpha_c\beta_t(\delta, d-1)\|x^{o,\perp}_{\pi_t^*}\|_{(\Sigma^{o, \perp}_t)^{-1}} - c_0} \nonumber \\
&\stackrel{\text{(a)}}{\geq} \frac{\tau - c_0}{\frac{\langle x_{\pi_t^*}^o, e_0 \rangle c_0}{\|x_0\|} + \langle x_{\pi_t^*}^{o,\perp},\mu_* \rangle + (1+\alpha_c)\beta_t(\delta,d-1)\|x^{o,\perp}_{\pi_t^*}\|_{(\Sigma_t^{o,\perp})^{-1}} - c_0} \nonumber \\
&\stackrel{\text{(b)}}{\geq} \frac{\tau - c_0}{\tau + (\alpha_c+1)\beta_t(\delta,d-1)\|x^{o,\perp}_{\pi_t^*}\|_{(\Sigma_t^{o,\perp})^{-1}} - c_0}.
\label{eq:tempB3}
\end{align}
{\bf (a)} This holds because
\begin{equation*}
\langle x^{o,\perp}_{\pi_t^*},\widehat{\mu}^{o,\perp}_t - \mu_* \rangle = \langle x^{o,\perp}_{\pi_t^*},\widehat{\mu}^{o,\perp}_t - \mu^{o,\perp}_* \rangle \leq \|\widehat{\mu}^{o,\perp}_t - \mu_*^{o,\perp}\|_{\Sigma^{o,\perp}_t} \|x^{o,\perp}_{\pi_t^*}\|_{(\Sigma^{o,\perp}_t)^{-1}} \leq \beta_t(\delta, d-1) \|x^{o,\perp}_{\pi_t^*}\|_{(\Sigma^{o, \perp}_t)^{-1}},
\end{equation*}
where the last inequality is because we are on the event $\mathcal E$.
{\bf (b)} This passage is due to the fact that the optimal policy $\pi^*_t$ is feasible, and thus, $\mathbb E_{x\sim\pi_t^*}[\langle x,\mu_* \rangle] \leq \tau$. Therefore, we may write
\begin{align*}
\mathbb E_{x\sim\pi_t^*}[\langle x,\mu_* \rangle] &= \mathbb E_{x\sim\pi_t^*}[\langle x^o,\mu_* \rangle] + \langle x_{\pi_t^*}^{o,\perp},\mu_* \rangle = \mathbb E_{x\sim\pi_t^*}[\langle \langle x,e_0 \rangle e_0,\mu_* \rangle] + \langle x_{\pi_t^*}^{o,\perp},\mu_* \rangle \\
&= \mathbb E_{x\sim\pi_t^*}[\langle \langle x,e_0 \rangle \frac{x_0}{\|x_0\|},\mu_* \rangle] + \langle x_{\pi_t^*}^{o,\perp},\mu_* \rangle = \frac{c_0}{\|x_0\|}\mathbb E_{x\sim\pi_t^*}[\langle x,e_0\rangle] + \langle x_{\pi_t^*}^{o,\perp},\mu_* \rangle \\
&= \frac{\langle x^o_{\pi_t^*},e_0 \rangle c_0}{\|x_0\|} + \langle x_{\pi_t^*}^{o,\perp},\mu_* \rangle \leq \tau.
\end{align*}
Since $\widetilde{\pi}_t \in \Pi_t$, we have
\begin{align}
\widetilde{r}_{\pi_t,t} &\geq \widetilde{r}_{\widetilde{\pi}_t,t} = \langle x_{\widetilde{\pi}_t},\widehat{\theta}_t \rangle + \alpha_r\beta_t(\delta,d)\|x_{\widetilde{\pi}_t}\|_{\Sigma_t^{-1}} = \langle x_{\widetilde{\pi}_t},\theta_* \rangle + \langle x_{\widetilde{\pi}_t},\widehat{\theta}_t - \theta_* \rangle + \alpha_r\beta_t(\delta,d)\|x_{\widetilde{\pi}_t}\|_{\Sigma_t^{-1}} \nonumber \\
&\stackrel{\text{(a)}}{\geq} \langle x_{\widetilde{\pi}_t},\theta_* \rangle + (\alpha_r - 1)\beta_t(\delta,d)\|x_{\widetilde{\pi}_t}\|_{\Sigma_t^{-1}} \stackrel{\text{(b)}}{\geq} \langle x_{\widetilde{\pi}_t},\theta_* \rangle + (\alpha_r - 1)\beta_t(\delta,d-1)\|x^{o,\perp}_{\widetilde{\pi}_t}\|_{(\Sigma^{o,\perp}_t)^{-1}} \nonumber \\
&\stackrel{\text{(c)}}{=} \eta_t \langle x_{\pi^*},\theta_* \rangle + (1-\eta_t)\langle x_0,\theta_* \rangle + \eta_t(\alpha_r-1)\beta_t(\delta,d-1)\|x^{o,\perp}_{\pi_t^*}\|_{(\Sigma^{o, \perp}_t)^{-1}} \nonumber \\
&\stackrel{\text{(d)}}{\geq} \eta_t \langle x_{\pi_t^*},\theta_* \rangle + \eta_t(\alpha_r-1)\beta_t(\delta,d-1)\|x^{o,\perp}_{\pi^*}\|_{(\Sigma^{o,\perp}_t)^{-1}} \nonumber \\
&\stackrel{\text{(e)}}{\geq} \underbrace{\Big(\frac{\tau - c_0}{\tau - c_0 + (\alpha_c+1) \beta_t(\delta, d-1) \|x^{o,\perp}_{\pi_t^*}\|_{(\Sigma_t^{o,\perp})^{-1}}}\Big) \Big(\langle x_{\pi_t^*},\theta_* \rangle + (\alpha_r-1)\beta_t(\delta,d-1) \|x^{o,\perp}_{\pi_t^*}\|_{(\Sigma^{o,\perp}_t)^{-1}}\Big)}_{C_0}.
\label{eq:tempB4}
\end{align}
{\bf (a)} This is because we may write
\begin{equation*}
|\langle x_{\widetilde{\pi}_t},\widehat{\theta}_t - \theta_* \rangle| \leq \|\widehat{\theta}_t - \theta_*\|_{\Sigma_t} \|x_{\widetilde{\pi}_t}\|_{\Sigma_t^{-1}} \leq \beta_t(\delta,d) \|x_{\widetilde{\pi}_t}\|_{\Sigma_t^{-1}},
\end{equation*}
where the last inequality is due to the fact that we are on the event $\mathcal E$. Thus, $\langle x_{\widetilde{\pi}_t},\widehat{\theta}_t - \theta_* \rangle \geq -\beta_t(\delta,d) \|x_{\widetilde{\pi}_t}\|_{\Sigma_t^{-1}}$.
{\bf (b)} This is a consequence of Lemma~\ref{lemma:inverse_norm_domination} stated in the paper and proved in Appendix~\ref{subsec:proof-Lemma-inverse-norm-domination}.
{\bf (c)} This is from the definition of $\widetilde{\pi}$ and Eq.~\ref{eq:tempB2}.
{\bf (d)} This is because $\eta_t\in [0,1]$ and from Assumption~\ref{ass:bounded-mean-reward-cost} we have that all expected rewards are positive (belong to $[0,1]$), and thus, $\langle x_0,\theta_* \rangle \geq 0$.
{\bf (e)} This is by lower-bounding $\eta_t$ from~\eqref{eq:tempB3}.
Let us define the shorthand notation $C_1:=\beta_t(\delta,d-1)\|x^{o,\perp}_{\pi_t^*}\|_{(\Sigma^{o,\perp}_t)^{-1}}$. Thus, we may write $C_0$ as
\begin{equation*}
C_0 = \frac{\tau - c_0}{\tau - c_0 + (1+\alpha_c)C_1}\times\big(\langle x_{\pi_t^*},\theta_* \rangle + (\alpha_r-1)C_1\big).
\end{equation*}
Note that $C_0 \geq \langle x_{\pi_t^*}, \theta_* \rangle = r_{\pi^*_t}$ (and as a results $\widetilde{r}_{\pi_t,t}\geq r_{\pi^*_t}$ as desired) iff:
\begin{equation*}
(\tau-c_0) r_{\pi_t^*} + (\tau - c_0) (\alpha_r - 1) C_1 \geq (\tau - c_0) r_{\pi_t^*} + (1 + \alpha_c) C_1 r_{\pi_t^*},
\end{equation*}
which holds iff: $(\tau-c_0)(\alpha_r-1)C_1 \geq (1+\alpha_c)C_1r_{\pi_t^*}$.
Since $r_{\pi_t^*}\leq 1$ from Assumption~\ref{ass:bounded-mean-reward-cost}, this holds iff: $1+\alpha_c \leq (\tau-c_0) (\alpha_r-1)$. This concludes the proof as for both cases of $\pi^*_t\in\Pi_t$ and $\pi^*_t\not\in\Pi_t$, we proved that $\widetilde{r}_{\pi_t,t}\geq r_{\pi_t^*}$.
\end{proof}
\subsection{Learning the safe policy's value}\label{section::safe_policy_value}
In this section we relax Assumption~\ref{ass:safe-action}, and instead assume we only have the knowledge of a safe arm, but not any knowledge of its value $c_0$.
If the cost of the safe arm $c_0$ is unknown, we start by taking the safe action $x_0$ for $T_0$ rounds to produce first an empirical mean estimator for $\hat{c}_9$. Notice that for all $\delta \in (0,1)$, $\hat{c}_0$ satisfies:
\begin{equation}\label{equation::helper_unknown_c0}
\mathbb{P}\left(\hat{c}_0 \leq c_0 - \sqrt{\frac{2 \log\left(1/\delta \right)}{T_0} } \right) \leq \delta
\end{equation}
Let $\tilde{c}_0 = \hat{c}_0 + \sqrt{\frac{2 \log\left(1/\delta \right)}{T_0} } $. By inequality~\ref{equation::helper_unknown_c0}, it follows that with probability at least $1-\delta$:
\begin{equation*}
\tilde{c}_0 \geq c_0
\end{equation*}
We select $T_0$ in an adaptive way. In other words, we do the following:
Let $\delta = \frac{1}{T^2}$. And let $\hat{c}_0(t)$ be the sample mean estimator of $c_0$, when using only $t$ samples. Similarly define $\tilde{c}_0(t) = \hat{c}_0(t) + \sqrt{\frac{2\log(1/\delta)}{t} }$ Let's condition on the event $\mathcal{E}$ that for all $t \in [T]$:
\begin{equation*}
|\hat{c}_0(t) - c_0| \leq \sqrt{\frac{ 2\log(1/\delta)}{t} }
\end{equation*}
By assumption $\mathbb{P}(\mathcal{E}) \geq 1-T2\delta = 1-\frac{2}{T}$. Let $T_0$ be the first time that $\tilde{c}_0(T_0) + 2\sqrt{\frac{ 2\log(1/\delta)}{T_0}} \leq \tau$.
Notice that in this case and conditioned on $\mathcal{E}$ and therefore on $\tilde{c}_0(T_0) \geq c_0$:
\begin{equation*}
\sqrt{ \frac{2 \log(1/\delta)}{T_0}} \leq \frac{\tau - c_0}{2} \quad\text{ i.e. }\quad T_0 \geq \frac{8\log(1/\delta)}{(\tau - c_0)^2}
\end{equation*}
In other words, this test does not stop until $T_0 \geq \frac{8\log(1/\delta)}{(\tau - c_0)^2}$. Now we see it won't take much longer than that to stop:
Conversely, let $T_0' \geq \frac{32\log(1/\delta)}{(\tau- c_0)^2}$. For any such $T_0'$ we observe that by conditioning on $\mathcal{E}$:
\begin{equation*}
\tilde{c}_0(T_0') + 2 \sqrt{\frac{ 2\log(1/\delta)}{T_0'} } \leq c_0 + 4 \sqrt{\frac{ 2\log(1/\delta)}{T_0'} }\leq \tau
\end{equation*}
Thus conditioned on $\mathcal{E}$, we conclude $\frac{8\log(1/\delta)}{(\tau - c_0)^2} \leq T_0 \leq \frac{32\log(1/\delta)}{(\tau- c_0)^2} $. Then,
Therefore $\hat{\delta}_c = \sqrt{ \frac{8 \log(1/\delta)}{T_0}}$ would serve as a conservative estimator for $\frac{\tau - c_0}{2}$ satisfying:
\begin{equation*}
\frac{\tau-c_0}{2} \leq \hat{\delta}_c \leq \tau - c_0
\end{equation*}
We proceed by warm starting our estimators for $\theta_*$ and $\mu_*$ using the data collected by playing $x_0$. However, instead of estimating $\mu_*^{o, \perp}$, we build an estimator for $\mu_*$ over all its directions, including $e_0$, similar to what OPLB does for $\theta_*$. We then set $\frac{\alpha_r}{\alpha_c} = 1/\hat\delta_c$ and run Algorithm~\ref{alg:optimistic-pessimistic-LB} for rounds $t > T_0$. Since the scaling of $\alpha_r$ w.r.t. $\alpha_c$ is optimal up to constants, the same arguments hold.
\section{Constrained Multi-Armed Bandits}
\label{section::constrained_multi_armed_bandit_setup}
\section{Constrained Multi-Armed Bandits}
\label{sec:constrained-MAB}
In this section, we specialize our results for contextual linear bandits to multi-armed bandits (MAB) and show that the structure of the MAB problem allows a computationally efficient implementation of the algorithm and an improvement in the regret bound.
In the MAB setting, the action set consists of $K$ arms $\mathcal{A}=\{1,\ldots,K\}$. Each arm $a\in [K]$ has a reward and a cost distribution with means $\bar{r}_a,\bar{c}_a\in [0,1]$. In each round $t\in[T]$, the agent constructs a policy $\pi_t$ over $\mathcal A$, pulls an arm $a_t\sim\pi_t$, and observes a reward-cost pair $(r_{a_t},c_{a_t})$ sampled i.i.d.~from the reward and cost distributions of arm $a_t$. Similar to the constrained contextual linear case, the goal of the agent is to produce a sequence of policies $\{\pi_t\}_{t=1}^T$ with maximum expected cumulative reward over $T$ rounds, i.e.,~$\sum_{t=1}^T\mathbb E_{a_t\sim\pi_t}[\bar{r}_{a_t}]$, while satisfying the {\bf\em linear constraint} $\mathbb E_{a_t\sim\pi_t}[\bar{c}_{a_t}] \leq \tau,\;\forall t\in[T]$. Moreover, arm $1$ is assumed to be the known safe arm, i.e.,~$\bar{c}_1 \leq \tau$.
{\bf Optimistic Pessimistic Bandit (OPB) Algorithm.} $\;$ Let $\{T_a(t)\}_{a=1}^K$ and $\{\widehat{r}_a(t),\widehat{c}_a(t)\}_{a=1}^K$ be the total number of times that arm $a$ has been pulled and the estimated mean reward and cost of arm $a$ up until round $t$. In each round $t\in[T]$, OPB relies on the high-probability upper-bounds on the mean reward and cost of the arms, i.e.,~$\{u_a^r(t),u_a^c(t)\}_{a=1}^K$, where $u_a^r(t) = \widehat{r}_a(t) + \alpha_r\beta_a(t)$, $u_a^c(t) = \widehat{c}_a(t) + \alpha_c\beta_a(t)$, $\beta_a(t) = \sqrt{2\log(1/\delta')/T_a(t)}$, and constants $\alpha_r,\alpha_c\geq 1$. In order to produce a feasible policy, OPB solves the following linear program (LP) in each round $t\in[T]$:
\vspace{-0.125in}
\begin{small}
\begin{equation}
\label{eq::noisy_LP}
\max_{\pi\in\Delta_K} \; \sum_{a\in\mathcal{A}}\pi_a \; u^r_a(t), \qquad\quad \text{s.t.} \; \sum_{a\in\mathcal{A}}\pi_a \; u_a^c(t) \leq \tau.
\end{equation}
\end{small}
\vspace{-0.125in}
As shown in~\eqref{eq::noisy_LP}, OPB selects its policy by being optimistic about reward (using an upper-bound for $r$) and pessimistic about cost (using an upper-bound for $c$). We report the details of OPB and its pseudo-code (Algorithm~\ref{alg::optimism_pessimism}) in Appendix~\ref{section::appendix_MAB_optimism_pessimism_algorithm}.
{\bf Computational Complexity of OPB.} $\;$ Unlike OPLB, whose optimization problem might be complex, OPB can be implemented extremely efficiently. Lemma~\ref{lemma::LP_support}, whose proof we report in Appendix~\ref{section::LP_structure_appendix}, show that~\eqref{eq::noisy_LP} always has a solution (policy) with support of at most $2$. This property allows us to solve~\eqref{eq::noisy_LP} in closed form, without a LP solver, and implement OPB quite efficiently.
\begin{lemma
\label{lemma::LP_support}
There exists a policy that solves~\eqref{eq::noisy_LP} and has at most $2$ non-zero entries.
\end{lemma}
{\bf Regret Analysis of OPB.} $\;$ We prove the following regret-bound for OPB in Appendix~\ref{section:regret_analysis_appendix}.
\begin{theorem}[Regret of OPB]
\label{theorem::contrained_MAB}
Let $\delta = 4KT\delta'$, $\alpha_c=1$, and $\alpha_r = 1+2/(\tau-\bar{c}_1)$. Then, with probability at least $1-\delta$, the regret of OPB satisfies
\vspace{-0.15in}
\begin{small}
\begin{equation*}
\mathcal{R}_\Pi(T) \leq \big(1 + \frac{2}{\tau-\bar{c}_1}\big) \times \big(2\sqrt{2KT\log(4KT/\delta)} + 4\sqrt{T\log(2/\delta)\log(4KT/\delta)}\big).
\end{equation*}
\end{small}
\vspace{-0.15in}
\end{theorem}
The main component in the proof of Theorem~\ref{theorem::contrained_MAB} is the following lemma, whose proof is reported in Appendix~\ref{section:regret_analysis_appendix}. This lemma is the analogous to Lemma~\ref{lemma:linear_bandits_optimism} in the contextual linear bandit case.
\begin{lemma}
\label{lemma::optimism}
If we set the parameters $\alpha_r$ and $\alpha_c$, such that $\alpha_r,\alpha_c\geq 1$ and $\alpha_c \leq (\tau-\bar{c}_1)(\alpha_r-1)$, then with high probability, for any $t\in[T]$, we have $\mathbb{E}_{a \sim \pi_t}\left[u_a^r(t)\right] \geq \mathbb{E}_{a \sim \pi^*}\left[\bar{r}_a \right]$.
\end{lemma}
Our contextual linear bandit formulation is general enough to include MAB. The regret analysis of OPLB (Theorem~\ref{theorem::main_theorem_linear}) yields a regret bound of order $\widetilde{\mathcal O}(\frac{K\sqrt{T}}{\tau-\bar{c}_1})$ for MAB. However, our OPB regret bound in Theorem~\ref{theorem::contrained_MAB} is of order $\widetilde{\mathcal O}(\frac{\sqrt{KT}}{\tau-\bar{c}_1})$, which shows a $\sqrt{K}$ improvement over simply casting MAB as an instance of contextual linear bandit and using the regret bound of OPLB.
{\bf Extension to $m$ Constraints.} $\;$ In this case, the agent receives $m$ cost signals after pulling each arm. The cost vector of the safe arm $\boldsymbol{c}_1$ satisfies $\boldsymbol{c}_1(i)<\tau_i,\forall i\in[m]$, where $\{\tau_i\}_{i=1}^m$ are the constraint thresholds. Similar to single-constraint OPB, multi-constraint OPB is also computationally efficient. The main reason is that the LP of $m$-constraint OPB has a solution with at most $m+1$ non-zero entries. We obtain a regret bound of $\widetilde{\mathcal{O}}(\frac{\sqrt{KT }}{ \min_i \tau_i - \boldsymbol{c}_1(i)})$ for $m$-constraint OPB in Appendix~\ref{section::multiple_constraints_appendix}.
{\bf Lower-bound.} $\;$ We also prove a mini-max lower-bound for this constrained MAB problem that shows no algorithm can attain a regret better than $\mathcal{O}(\max(\sqrt{KT}, \frac{1}{(\tau - \bar{c}_1)^2} ) )$. The formal statement of the lower-bound and the proof are reported in Appendix~\ref{section::lower_bound_MAB_appendix}.
\section{Problem Formulation}
\label{sec:setting}
We adopt the following notation. The set $\{1,\ldots,T\}$ is denoted by $[T]$. We represent the set of distributions with support over a compact set $\mathcal S$ by $\Delta_{\mathcal S}$. We denote by $\langle x,y \rangle:=x^\top y\in\mathbb R$, the inner product of two vectors $x,y\in\mathbb R^d$, and by $\|x\|:=\sqrt{x^\top x}$, the $\ell_2$-norm of vector $x$.
The setting we study in this paper is {\em contextual linear bandit} with {\em linear constraints}. In each round $t$, the agent is given an decision set $\mathcal A_t\subset{\mathbb R}^d$ from which it has to choose an action $x_t$. Upon taking action $x_t\in\mathcal A$, it observes a pair $(r_t,c_t)$, where $r_t=\langle x_t,\theta_*\rangle + \xi^r_t$ and $c_t=\langle x_t,\mu_*\rangle + \xi^c_t$ are the reward and cost signals, respectively. In the reward and cost definitions, $\theta_*\in{\mathbb R}^d$ and $\mu_*\in{\mathbb R}^d$ are the unknown {\em reward} and {\em cost parameters}, and $\xi^r_t$ and $\xi^c_t$ are reward and cost noise, satisfying conditions that will be specified soon. The agent selects its action $x_t\in\mathcal A_t$ in each round $t$ according to its policy $\pi_t\in\Delta_{\mathcal A_t}$ at that round, i.e.,~$x_t\sim\pi_t$.
The goal of the agent is to produce a sequence of policies $\{\pi_t\}_{t=1}^T$ with maximum {\em expected cumulative reward} over the course of $T$ rounds, while satisfying the {\bf\em linear constraint}
\begin{equation}
\label{eq:constraint}
\mathbb E_{x\sim\pi_t}[\langle x,\mu_* \rangle]\leq \tau,\quad\forall t\in[T], \qquad (\tau\geq 0 \;\; \text{is referred to as the \em constraint threshold}).
\end{equation}
Thus, the policy $\pi_t$ selected by the agent in each round $t\in [T]$ should belong to the set of {\em feasible policies} over the action set $\mathcal A_t$, i.e.,~$\Pi_t=\{\pi\in\Delta_{\mathcal A_t}:\mathbb E_{x\sim\pi}[\langle x,\mu_* \rangle]\leq \tau\}$. Maximizing the expected cumulative reward in $T$ rounds is equivalent to minimizing the $T$-round {\em constrained pseudo-regret},\footnote{In the rest of the paper, we simply refer to the $T$-round constrained pseudo-regret $\mathcal R_\Pi(T)$ as $T$-round regret.}
\begin{equation}
\label{eq:regret}
\mathcal R_\Pi(T) = \sum_{t=1}^T \mathbb E_{x\sim\pi_t^*}[\langle x,\theta_* \rangle] - E_{x\sim\pi_t}[\langle x,\theta_* \rangle],
\end{equation}
where $\pi_t,\pi^*_t\in\Pi_t\;\forall t\in[T]$ and $\pi^*_t$ is the {\em optimal feasible} policy at round $t$, i.e.,~$\pi^*_t\in\max_{\pi\in\Pi_t}\mathbb E_{x\sim\pi}[\langle x,\theta_* \rangle]$. The terms $\mathbb E_{x\sim\pi}[\langle x,\theta_* \rangle]$ and $\mathbb E_{x\sim\pi}[\langle x,\mu_* \rangle]$ in~\eqref{eq:constraint} and~\eqref{eq:regret} are the expected reward and cost of policy $\pi$, respectively. Thus, a feasible policy is the one whose expected cost is below the constraint threshold $\tau$, and the optimal feasible policy is a feasible policy with maximum expected reward. We use the shorthand notations $x_\pi := \mathbb{E}_{x \sim \pi}[x]$, $r_\pi:=\mathbb E_{x\sim\pi}[\langle x,\theta_* \rangle]$ and $c_\pi:=\mathbb E_{x\sim\pi}[\langle x,\mu_* \rangle]$ for the expected action, reward and cost of a policy $\pi$. With these shorthand notations, we may write the $T$-round pseudo-regret as $\mathcal R_\Pi(T)=\sum_{t=1}^T r_{\pi^*_t} - r_{\pi_t}$.
We make the following assumptions for our setting. The first four assumptions are standard in linear bandits. The fifth one is necessary to guarantee constraint satisfaction ({\em safety}).
\begin{assumption}
\label{ass:noise-sub-gaussian}
For all $t\in[T]$, the reward and cost noise random variables $\xi_t^r$ and $\xi_t^c$ are conditionally $R$-sub-Gaussian, i.e.,
\begin{align*}
&\mathbb{E}[\xi_t^r \mid \mathcal{F}_{t-1}] = 0, \qquad \mathbb{E}[\exp(\alpha \xi_t^r) \mid \mathcal{F}_{t-1}] \leq \exp(\alpha^2 R^2/2),\;\;\;\forall \alpha\in\mathbb R, \\
&\mathbb{E}[\xi_t^c \mid \mathcal{F}_{t-1}] = 0, \qquad \mathbb{E}[\exp(\alpha \xi_t^c) \mid \mathcal{F}_{t-1}] \leq \exp(\alpha^2 R^2/2),\;\;\;\forall \alpha\in\mathbb R,
\end{align*}
where $\mathcal F_t$ is the filtration that includes all the events $(x_{1:t+1},\xi^r_{1:t},\xi^c_{1:t})$ until the end of round $t$.
\end{assumption}
\begin{assumption}
\label{ass:bounded-reward-cost-param}
There is a known constant $S > 0$, such that $\| \theta_*\| \leq S$ and $\| \mu_*\| \leq S$.\footnote{The choice of the same upper-bounds for $\theta_*$ and $\mu_*$ is just for simplicity.}
\end{assumption}
\begin{assumption}
\label{ass:bounded-action}
The $\ell_2$-norm of all actions is bounded, i.e.,~$\max_{t\in[T]}\max_{x \in \mathcal{A}_t}\| x \| \leq L$.
\end{assumption}
\begin{assumption}
\label{ass:bounded-mean-reward-cost}
For all $t\in[T]$ and $x \in \mathcal{A}_t$, the mean rewards and costs are bounded, i.e.,~$\langle x, \theta_* \rangle \in [0,1]$ and $\langle x, \mu_* \rangle \in [0,1]$.
\end{assumption}
\begin{assumption}
\label{ass:safe-action}
There is a known safe action $x_0\in\mathcal A_t,\;\forall t\in[T]$ with known
cost $c_0$, i.e.,~$\langle x_0, \mu_* \rangle = c_0 < \tau$. We will show how the assumption of knowing $c_0$ can be relaxed later in the paper.
\end{assumption}
{\bf Notation:} We conclude this section with introducing another set of notations that will be used in the rest of the paper. We define the normalized safe action as $e_0:=x_0/\|x_0\|$ and the span of the safe action as $\mathcal{V}_o := \mathrm{span}(x_0) =\{\eta x_0 : \eta\in\mathbb R\}$. We denote by $\mathcal{V}_o^{\perp}$, the orthogonal complement of $\mathcal{V}_o$, i.e.,~$\mathcal{V}_o^{\perp}=\{x\in\mathbb R^d : \langle x,y\rangle=0,\;\forall y\in\mathcal{V}_o\}$.\footnote{In the case of $x_0 = \mathbf{0}\in\mathbb R^d$, we define $\mathcal{V}_o$ as the empty subspace and $\mathcal{V}_o^\perp$ as the whole $\mathbb{R}^d$.} We define the projection of a vector $x\in\mathbb R^d$ into the sub-space $\mathcal{V}_o$, as $x^o:=\langle x,e_0\rangle e_0$, and into the sub-space $\mathcal{V}_o^{\perp}$, as $x^{o,\perp} := x - x^o$. We also define the projection of a policy $\pi$ into $\mathcal{V}_o$ and $\mathcal{V}_o^{\perp}$, as $x_{\pi}^o := \mathbb{E}_{x \sim \pi}[x^o]$ and $x_{\pi}^{o, \perp} := \mathbb{E}_{x \sim \pi}[x^{o, \perp}]$.
\section{Optimistic-Pessimistic Linear Bandit Algorithm}
\label{sec:algo}
In this section, we propose an algorithm, called {\em optimistic-pessimistic linear bandit} (OPLB), whose pseudo-code is shown in Algorithm~\ref{alg:optimistic-pessimistic-LB}. Our OPLB algorithm balances a pessimistic assessment of the set of available policies, while acting optimistically within this set. Our principal innovation is the use of confidence intervals with asymmetric radii, proportional to $\alpha_r$ and $\alpha_c$, for the reward and cost signals. This will prove crucial in the regret analysis of the algorithm.
{\centering
\begin{minipage}{.9\linewidth}
\begin{algorithm}[H]
\textbf{Input:} \begin{small}Horizon $T$, Confidence Parameter $\delta$, Regularization Parameter $\lambda$, Constants $\alpha_r, \alpha_c \geq 1$\end{small} \\
\For{$t=1,\ldots,T$}{
1. Compute RLS estimates $\;\widehat{\theta}_t\;$ and $\;\widehat{\mu}_t^{o,\perp}$ \hfill {\em (see Eqs.~\ref{eq:param-est} to~\ref{eq:proj-est})} \\
2. Construct sets $\;\mathcal{C}_t^r(\alpha_r)\;$ and $\;\mathcal{C}_t^c(\alpha_c)$ \hfill {\em (see Eq.~\ref{eq:confidence-ellipsoids})} \\
3. Observe $\;\mathcal{A}_t\;$ and construct the (estimated) safe policy set $\;\Pi_t$ \hfill {\em (see Eq.~\ref{eq:safe-policy-set})} \\
4. Compute policy $\;(\pi_t,\widetilde{\theta}_t) = \argmax_{\pi \in \Pi_t,\;\theta \in \mathcal{C}_t^r(\alpha_r)} \mathbb{E}_{x \sim \pi}[ \langle x, \theta \rangle ]$\\
5. Take action $\;x_t \sim \pi_t\;$ and observe reward and cost $\;(r_t,c_t)$
}
\caption{Optimistic-Pessimistic Linear Bandit (OPLB)}
\label{alg:optimistic-pessimistic-LB}
\end{algorithm}
\end{minipage}
}
{\bf\em Line~1 of OPLB:} At each round $t\in[T]$, given the actions $\{x_s\}_{s=1}^{t-1}$, rewards $\{r_s\}_{s=1}^{t-1}$, and costs $\{c_s\}_{s=1}^{t-1}$ observed until the end of round $t-1$, OPLB first computes the $\ell_2$-regularized least-squares (RLS) estimates of $\theta_*$ and $\mu_*^{o,\perp}$ (projection of the cost parameter $\mu_*$ into the sub-space $\mathcal V_o^\perp$) as
\vspace{-0.15in}
\begin{small}
\begin{equation}
\label{eq:param-est}
\widehat{\theta}_t = \Sigma_t^{-1} \sum_{s=1}^{t-1}r_sx_s, \qquad\quad \widehat{\mu}_t^{o,\perp} = (\Sigma_t^{o,\perp})^{-1}\sum_{s=1}^{t-1}c_s^{o,\perp}x_s^{o,\perp},
\end{equation}
\end{small}
\vspace{-0.15in}
where $\lambda>0$ is the regularization parameter, and
\vspace{-0.15in}
\begin{small}
\begin{align}
\label{eq:Sigmas}
&\Sigma_t = \lambda I + \sum_{s=1}^{t-1}x_sx_s^\top, \qquad\quad \Sigma_t^{o,\perp} = \lambda I_{\mathcal V_o^\perp} + \sum_{s=1}^{t-1}x_s^{o,\perp}(x_s^{o,\perp})^\top, \\
&c^{o,\perp}_t = c_t - \frac{\langle x_t,e_0\rangle}{\|x_0\|}c_0, \qquad\quad I_{\mathcal V_o^\perp} = I_{d\times d} - \frac{1}{\|x_0\|^2}x_0x_0^\top.
\label{eq:proj-est}
\end{align}
\end{small}
\vspace{-0.15in}
In~\eqref{eq:Sigmas}, $\Sigma_t$ and $\Sigma_t^{o,\perp}$ are the Gram matrices of actions and projection of actions into the sub-space $\mathcal V_o^\perp$. Note that $\Sigma_t^{o, \perp}$ is a rank deficient matrix, but with abuse of notation, we use $(\Sigma_t^{o, \perp})^{-1}$ to denote its pseudo-inverse throughout the paper. In~\eqref{eq:proj-est}, $I_{\mathcal V_o^\perp}$ is the projection of the identity matrix, $I$, into $\mathcal V_o^\perp$, and $c^{o,\perp}_t$ is the noisy projection of the cost $c_t$ incurred by taking action $x_t$ into $\mathcal V_o^\perp$, i.e.,\footnote{In the derivation of~\eqref{eq:c-tilde-derivation}, we use the fact that $\langle x_t,\mu_*\rangle = \langle x_t^o+x_t^{o,\perp},\mu_*^o+\mu_*^{o,\perp}\rangle = \langle x_t^o,\mu_*^o\rangle + \langle x_t^{o,\perp},\mu_*^{o,\perp}\rangle$.}
\vspace{-0.15in}
\begin{small}
\begin{equation}
\label{eq:c-tilde-derivation}
c^{o,\perp}_t = \langle x_t^{o,\perp},\mu_*^{o,\perp}\rangle + \xi_t^c = \langle x_t,\mu_* \rangle - \langle x_t^o,\mu_*^o \rangle + \xi_t^c = c_t - \langle x_t^o,\mu_*^o \rangle = c_t - \frac{\langle x_t,e_0\rangle}{\|x_0\|}c_0.
\end{equation}
\end{small}
\vspace{-0.125in}
{\bf\em Line~2:} Using the RLS estimates $\widehat{\theta}_t$ and $\widehat{\mu}_t^{o,\perp}$ in~\eqref{eq:param-est}, OPLB constructs the two {\em confidence sets}
\vspace{-0.15in}
\begin{small}
\begin{equation}
\label{eq:confidence-ellipsoids}
\mathcal{C}_t^r(\alpha_r) = \big\{\theta \in \mathbb{R}^d: \|\theta -\widehat{\theta}_t\|_{\Sigma_t} \leq \alpha_r \beta_t(\delta, d)\big\}, \quad \mathcal{C}_t^c(\alpha_c) = \big\{ \mu \in \mathcal{V}_o^{\perp} : \| \mu - \widehat{\mu}^{o, \perp}_t\|_{\Sigma_t^{o,\perp}} \leq \alpha_c \beta_t(\delta, d-1)\big\},
\end{equation}
\end{small}
\vspace{-0.15in}
where $\alpha_r,\alpha_c\geq 1$ and $\beta_t(\delta,d)$ in the radii of these {\em confidence ellipsoids} is defined by the following theorem, originally proved in~\cite{abbasi2011improved}.
\begin{theorem}\label{theorem::yasin_theorem}[Thm.~2 in~\citealt{abbasi2011improved}]
Let Assumptions~\ref{ass:noise-sub-gaussian} and~\ref{ass:bounded-reward-cost-param} hold, $\widehat{\theta}_t$, $\widehat{\mu}_t^{o,\perp}$, $\Sigma_t$, and $\Sigma_t^{o,\perp}$ defined by~\eqref{eq:param-est} and~\eqref{eq:Sigmas}, and $\mathcal{C}_t^r(\cdot)$ and $\mathcal{C}_t^c(\cdot)$ defined by~\eqref{eq:confidence-ellipsoids}. Then, for a fixed $\delta \in (0,1)$ and
\vspace{-0.1in}
\begin{small}
\begin{equation}
\label{eq:ellipsoid-radius}
\beta_t(\delta,d) = R \sqrt{d\log\Big(\frac{1 + (t-1)L^2/\lambda}{\delta}\Big)} + \sqrt{\lambda}\;S,
\end{equation}
\end{small}
\vspace{-0.125in}
with probability at least $1-\delta$ and for all $t \geq 1$, it holds that $\theta_*\in\mathcal{C}_t^r(1)$ and $\mu_*^{o,\perp}\in\mathcal{C}_t^c(1)$.
\end{theorem}
Since $\alpha_r,\alpha_c\geq 1$, for all rounds $t\in[T]$, the sets $\mathcal{C}_t^r(\alpha_r)$ and $\mathcal{C}_t^c(\alpha_c)$ also contain $\theta_*$, the reward parameter, and $\mu_*^{o,\perp}$, the projection of the cost parameter into $\mathcal V_o^\perp$, respectively, with high probability.
Given these confidence sets, we define the {\em optimistic reward} and {\em pessimistic cost} of any policy $\pi$ in round $t$ as
\vspace{-0.225in}
\begin{small}
\begin{equation}
\label{eq:max-reward-cost}
\widetilde{r}_{\pi,t} := \max_{\theta\in\mathcal{C}_t^r(\alpha_r)} \mathbb{E}_{x \sim \pi}[\langle x,\theta\rangle], \qquad\qquad
\widetilde{c}_{\pi,t} := \frac{\langle x_{\pi}^o,e_0 \rangle c_0}{\| x_0 \|} + \max_{\mu\in\mathcal{C}_t^c(\alpha_c)} \mathbb{E}_{x\sim\pi}[\langle x,\mu \rangle].
\end{equation}
\end{small}
\vspace{-0.075in}
\begin{proposition}
\label{prop:optimistic-reward-pessimistic-cost}
We may write~\eqref{eq:max-reward-cost} in closed-form as \hfill {\em (proof in Appendix~\ref{subsec:proof-prop-optimistic-reward})}
\vspace{-0.15in}
\begin{small}
\begin{align}
\label{eq:optimistic-reward-closed-form}
\widetilde{r}_{\pi,t} &= \langle x_\pi,\widehat{\theta}_t \rangle + \alpha_r \beta_t(\delta,d) \| x_\pi\|_{\Sigma_t^{-1}}, \\ \widetilde{c}_{\pi,t} &= \frac{\langle x_\pi^o, e_0\rangle c_0 }{\|x_0\|} + \langle x_\pi^{o, \perp}, \widehat{\mu}^{o, \perp}_t \rangle + \alpha_c \beta_t(\delta,d-1) \| x_{\pi}^{o, \perp}\|_{(\Sigma_t^{o, \perp})^{-1}}.
\label{eq:pessimistic-cost-closed-form}
\end{align}
\end{small}
\vspace{-0.15in}
\end{proposition}
{\bf\em Line~3:} After observing the action set $\mathcal A_t$, OPLB constructs its (estimated) feasible (safe) policy set
\vspace{-0.15in}
\begin{small}
\begin{equation}
\label{eq:safe-policy-set}
\Pi_t = \{\pi \in \Delta_{\mathcal A_t} : \widetilde{c}_{\pi,t} \leq \tau\},
\end{equation}
\end{small}
\vspace{-0.175in}
where $\widetilde{c}_{\pi,t}$ is the pessimistic cost of policy $\pi$ in round $t$ defined by~\eqref{eq:pessimistic-cost-closed-form}. Note that $\Pi_t$ is not empty since $\pi_0$, the policy that plays the safe action $x_0$ with probability (w.p.)~$1$, is always in $\Pi_t$. This is because $x_{\pi_0}^o = x_0$, $x_{\pi_0}^{o,\perp} =0$, and $\frac{\langle x_{\pi_0}^o, e_0\rangle c_0}{\| x_0 \|} = c_0$. In the following proposition, whose proof is reported in Appendix~\ref{subsec:proof-safe-set}, we prove that all policies in $\Pi_t$ are feasible with high probability.
\begin{proposition}
\label{prop:safe-set}
With probability at least $1-\delta$, for all rounds $t\in[T]$, all policies in $\Pi_t$ are feasible.
\end{proposition}
{\bf\em Line~4:} The agent computes its policy, $\pi_t$, as the one that is safe (belongs to $\Pi_t$) and attains the maximum optimistic reward. We refer to $\widetilde{\theta}_t$ as the {\em optimistic reward parameter}. Thus, we write the optimistic reward of policy $\pi_t$ as $\widetilde{r}_{\pi_t,t} = \langle x_{\pi_t},\widetilde{\theta}_t \rangle$.
{\bf\em Line~5:} Finally, the agent selects an action $x_t\sim\pi_t$ and observes the reward-cost pair $(r_t,c_t)$.
{\bf Computational Complexity of OPLB.} $\;$ As shown in Line~4 of Algorithm~\ref{alg:optimistic-pessimistic-LB} and in Proposition~\ref{prop:optimistic-reward-pessimistic-cost}, in each round $t$, OPLB solves the following optimization problem:
\vspace{-0.15in}
\begin{small}
\begin{align}
\label{equation::opt_problem_linear}
\max_{\pi \in \Delta_{\mathcal{A}_t}}& \langle x_\pi, \widehat{\theta}_t \rangle + \alpha_r \beta_t(\delta,d) \| x_\pi\|_{\Sigma_t^{-1}} \\
\text{s.t. }& \frac{\langle x_\pi^o, e_0\rangle c_0 }{\|x_0\|} + \langle x_\pi^{o, \perp}, \widehat{\mu}^{o, \perp}_t \rangle + \alpha_c \beta_t(\delta,d-1) \| x_{\pi}^{o, \perp}\|_{(\Sigma_t^{o, \perp})^{-1}} \leq \tau. \nonumber
\end{align}
\end{small}
\vspace{-0.15in}
However, solving~\eqref{equation::opt_problem_linear} can be challenging. The bottleneck is computing the safe policy set $\Pi_t$, which is the intersection between $\Delta_{\mathcal{A}_t}$ and the ellipsoidal constraint.
\begin{remark}
The main challenge in obtaining a regret bound for OPLB is to ensure that optimism holds in each round $t$, i.e.,~the solution $(\pi_t,\widetilde\theta_t)$ of~\eqref{equation::opt_problem_linear} satisfy $\widetilde{r}_{\pi_t,t} = \langle x_{\pi_t},\widetilde\theta_t \rangle \geq r_{\pi^*_t}$. This is not obvious, since the (estimated) safe policy set $\Pi_t$ may not contain the optimal policy $\pi_t^*$. Our main algorithmic innovation is the use of asymmetric confidence intervals $\mathcal{C}_t^r(\alpha_r)$ and $\mathcal{C}_t^c(\alpha_c)$ for $\theta_*$ and $\mu^{o, \perp}_*$, which allows us to guarantee optimism, by appropriately selecting the ratio $\gamma = \alpha_r/\alpha_c$. Of course, this comes at the cost of scaling the regret by a factor $\gamma$. As it will be shown in our analysis in Section~\ref{section::lin_opt_pess_analysis}, $\gamma$ depends on the inverse gap $1/(\tau-c_0)$, which indicates when $\tau - c_0$ is small (the cost of the safe arm is close to the constraint threshold), the agent will have a difficult time to identify a safe arm and to compete against the optimal feasible policy $\pi_t^*$. We will formalize this in Lemma \ref{lemma:linear_bandits_optimism}.
\end{remark}
\begin{remark
If the cost of the safe arm $c_0$ is unknown, we start by taking the safe action $x_0$ for $T_0$ rounds to produce a conservative estimate $\hat\delta_c$ of $\tau - c_0$ that satisfies $\hat\delta_c \geq \frac{\tau - c_0}{2}$. We warm start our estimators for $\theta_*$ and $\mu_*$ using the data collected by playing $x_0$. However, instead of estimating $\mu_*^{o, \perp}$, we build an estimator for $\mu_*$ over all its directions, including $e_0$, similar to what OPLB does for $\theta_*$. We then set $\frac{\alpha_r}{\alpha_c} = 1/\hat\delta_c$ and run Algorithm~\ref{alg:optimistic-pessimistic-LB} for rounds $t > T_0$ (see Appendix~\ref{section::safe_policy_value} for more details).
\end{remark}
\section{Regret Analysis}
\label{section::lin_opt_pess_analysis}
In this section, we prove the following regret bound for OPLB (Algorithm~\ref{alg:optimistic-pessimistic-LB}).
\begin{theorem}[Regret of OPLB]
\label{theorem::main_theorem_linear}
Let $\alpha_c = 1$ and $\alpha_r = \frac{ 2+\tau-c_0}{\tau-c_0}$. Then, with probability at least $1-2\delta$, the regret of OPLB satisfies
\vspace{-0.15in}
\begin{small}
\begin{equation}
\label{eq:regret-OPLB}
\mathcal{R}_{\Pi}(T) \leq \frac{2L(\alpha_r+1)\beta_T(\delta, d)}{\sqrt{\lambda}}\sqrt{2T\log(1/\delta)} + (\alpha_r+1)\beta_T(\delta, d)\sqrt{2Td\log(1+\frac{TL^2}{\lambda})}.
\end{equation}
\end{small}
\vspace{-0.15in}
\end{theorem}
We start the proof of Theorem~\ref{theorem::main_theorem_linear}, by defining the following event that holds w.p.~at least $1-\delta$:
\vspace{-0.125in}
\begin{small}
\begin{equation}
\label{eq:high-prob-event}
\mathcal{E} := \big\{\|\widehat{\theta}_t - \theta_*\|_{\Sigma_t} \leq \beta_t(\delta, d) \; \wedge \; \|\widehat{\mu}_t^{o, \perp} - \mu_*^{o, \perp}\|_{\Sigma_t^{o,\perp}} \leq \beta_t(\delta, d-1), \; \forall t\in[T]\big\}.
\end{equation}
\end{small}
\vspace{-0.15in}
The regret $\mathcal{R}_{\Pi}(T)$ in~\eqref{eq:regret} can be decomposed as ($\widetilde{r}_{\pi_t,t}$ is the optimistic reward defined by Eq.~\ref{eq:max-reward-cost})
\vspace{-0.15in}
\begin{small}
\begin{equation}
\label{eq:regret-decomp}
\mathcal{R}_{\Pi}(T) = \underbrace{\sum_{t=1}^T r_{\pi_t^*} - \widetilde{r}_{\pi_t,t}}_{(\mathrm{I})} \; + \; \underbrace{\sum_{t=1}^T \widetilde{r}_{\pi_t,t} - r_{\pi_t}}_{(\mathrm{II})}.
\end{equation}
\end{small}
\vspace{-0.125in}
We first bound the term $(\mathrm{II})$ in~\eqref{eq:regret-decomp}. To bound $(\mathrm{II})$, we further decompose it as
\vspace{-0.15in}
\begin{small}
\begin{equation}
\label{eq:II-decomp}
(\mathrm{II}) = \underbrace{\sum_{t=1}^T \langle x_{\pi_t}, \widetilde{\theta}_t \rangle - \langle x_t, \widetilde{\theta}_t \rangle}_{(\mathrm{III})} + \underbrace{\sum_{t=1}^T \langle x_t, \widetilde{\theta}_t \rangle - \langle x_t, \theta_* \rangle}_{(\mathrm{IV})} + \underbrace{\sum_{t=1}^T \langle x_t, \theta_* \rangle - \langle x_{\pi_t}, \theta_* \rangle }_{(\mathrm{V})}.
\end{equation}
\end{small}
\vspace{-0.125in}
In the following lemmas, we first bound the sum of $(\mathrm{III})$ and $(\mathrm{V})$ terms, and then bound $(\mathrm{IV})$.
\begin{lemma}
\label{lemma:bounding-3+5}
On the event $\mathcal{E}$ defined by~\eqref{eq:high-prob-event}, for any $\gamma \in (0, 1)$, w.p.~at least $1-\gamma$, we have
\vspace{-0.125in}
\begin{small}
\begin{equation*}
(\mathrm{III}) + (\mathrm{V}) \leq \frac{2L(\alpha_r + 1)\beta_T(\delta, d)}{\sqrt{\lambda}}\cdot\sqrt{2 T \log(1/\gamma)}\;.
\end{equation*}
\end{small}
\end{lemma}
\vspace{-0.175in}
\begin{proof}
We write $(\mathrm{III}) + (\mathrm{V}) = \sum_{t=1}^T \langle x_{\pi_t} - x_t, \widetilde{\theta}_t - \theta_* \rangle$. By Cauchy-Schwartz, we have $|\langle x_{\pi_t} - x_t, \widetilde{\theta}_t - \theta_* \rangle | \leq \| x_{\pi_t} - x_t \|_{\Sigma^{-1}_t} \| \widetilde{\theta}_t - \theta_*\|_{\Sigma_t}$. Since $\widetilde{\theta}_t\in \mathcal{C}_t^r(\alpha_r)$, on event $\mathcal E$, we have $\|\widetilde{\theta}_t - \theta_*\|_{\Sigma_t} \leq (\alpha_r+1) \beta_t(\delta, d)$. Also from the definition of $\Sigma_t$, we have $\Sigma_t \succeq \lambda I$, and thus, $\| x_{\pi_t} - x_t \|_{\Sigma^{-1}_t} \leq \| x_{\pi_t} - x_t\|/\sqrt{\lambda} \leq 2L/\sqrt{\lambda}$. Therefore, $Y_t =\sum_{s=1}^t \langle x_{\pi_s} - x_s, \widetilde{\theta}_s - \theta_* \rangle$ is a martingale sequence with $|Y_t - Y_{t-1}| \leq 2L(\alpha_r + 1)\beta_t(\delta, d)/\sqrt{\lambda}$, for $t\in [T]$. By the Azuma–Hoeffding inequality and since $\beta_t$ is an increasing function of $t$, i.e.,~$\beta_t(\delta, d) \leq \beta_T(\delta, d),\;\forall t\in[T]$, w.p.~at least $1-\gamma$, we have $\mathbb{P}\big(Y_T \geq 2L(\alpha_r + 1) \beta_T(\delta, d)\sqrt{2T \log(1/\gamma)/\lambda}\big) \leq \gamma$, which concludes the proof.
\end{proof}
\begin{lemma}
\label{lemma:bounding-4}
On event $\mathcal{E}$, we have $(\mathrm{IV}) \leq (\alpha_r+1) \beta_T(\delta,d)\sqrt{2Td\log\big(1+\frac{TL^2}{\lambda}\big)}$. \end{lemma}
We report the proof of Lemma~\ref{lemma:bounding-4} in Appendix~\ref{subsec:proof-Lemma-bounding-4}. After bounding all the terms in $(\mathrm{II})$, we now process the term $(\mathrm{I})$ in~\eqref{eq:regret-decomp}. Before stating the main result for this term in Lemma~\ref{lemma:linear_bandits_optimism}, we need to prove the following lemma (proof in Appendix~\ref{subsec:proof-Lemma-inverse-norm-domination}).
\begin{lemma}
\label{lemma:inverse_norm_domination}
For any policy $\pi$, the following inequality holds:
\vspace{-0.125in}
\begin{small}
\begin{equation}
\label{equation::comparison_conf_bounds}
\| x_\pi^{o, \perp}\|_{(\Sigma_t^{o,\perp})^{-1}} \leq \| x_\pi \|_{\Sigma_t^{-1}}.
\end{equation}
\end{small}
\end{lemma}
In the following lemma, we prove that by appropriately setting the parameters $\alpha_r$ and $\alpha_c$, we can guarantee that at each round $t\in[T]$, OPLB selects an optimistic policy, i.e.,~a policy $\pi_t$, whose optimistic reward, $\widetilde{r}_{\pi_t,t}$, is larger than the reward of the optimal policy $r_{\pi^*_t}$, given the event $\mathcal E$. This means that with our choice of parameters $\alpha_r$ and $\alpha_c$, the term $(\mathrm{I})$ in~\eqref{eq:regret-decomp} is always non-positive.
\begin{lemma}
\label{lemma:linear_bandits_optimism}
On the event $\mathcal{E}$, if we set $\alpha_r$ and $\alpha_c$, such that $\alpha_r,\alpha_c\geq 1$ and $1+\alpha_c \leq (\tau-c_0) (\alpha_r-1)$, then for any $t\in[T]$, we have $\widetilde{r}_{\pi_t,t} \geq r_{\pi_t^*}$.
\end{lemma}
Here we provide a proof sketch for Lemma~\ref{lemma:linear_bandits_optimism}. The detailed proof is reported in Appendix~\ref{subsec:proof-Lemma-term-I}.
\begin{proof}[Proof Sketch]
We divide the proof into two cases, depending on whether in each round $t$, the optimal policy $\pi^*_t$ belongs to the (estimated) set of feasible policies $\Pi_t$, or not.
{\bf Case~yes
1.} $\;$ If $\pi_t^*\in\Pi_t$, then its optimistic reward is less than that of the policy $\pi_t$ selected at round $t$ (by the definition of $\pi_t$ on Line~4 of Algorithm~\ref{alg:optimistic-pessimistic-LB}), i.e.,~$\widetilde{r}_{\pi_t^*,t}\leq\widetilde{r}_{\pi_t,t}$. This together with the fact that the optimistic reward of any policy $\pi$ is larger than its expected reward, i.e.,~$\widetilde{r}_{\pi,t}\geq r_\pi$, gives us the desired result that $\widetilde{r}_{\pi_t,t}\geq r_{\pi^*_t}$.
{\bf Case~2.} $\;$ If $\pi_t^*\not\in\Pi_t$, then we define a mixture policy $\widetilde{\pi}_t=\eta_t\pi_t^*+(1-\eta_t)\pi_0$, where $\pi_0$ is the policy that always selects the safe action $x_0$ and $\eta_t\in[0,1]$ is the maximum value of $\eta$ for which the mixture policy belongs to the set of feasible actions, i.e.,~$\widetilde{\pi}_t\in\Pi_t$. Conceptually, we can think of $\eta_t$ as a measure for safety of the optimal policy $\pi_t^*$. Mathematically, $\eta_t$ is the value at which the pessimistic cost of the mixture policy equals to the constraint threshold, i.e.,~$\widetilde{c}_{\widetilde{\pi}_t,t} =\tau$. In the rest of the proof, we first write $\widetilde{c}_{\widetilde{\pi}_t,t}$ in terms of the pessimistic cost of the optimal policy as $\widetilde{c}_{\widetilde{\pi}_t,t}=(1-\eta_t)c_0+\eta_t\widetilde{c}_{\pi^*_t,t}$ ($c_0$ is the expected cost of the safe action $x_0$), and find a lower-bound for $\eta_t$ (see Eq.~\ref{eq:tempB3} in Appendix~\ref{subsec:proof-Lemma-term-I}). We then use the fact that since $\widetilde{\pi}_t\in\Pi_t$, its optimistic reward is less than that of $\pi_t$, i.e.,~$\widetilde{r}_{\pi_t,t}\geq \widetilde{r}_{\widetilde{\pi}_t,t}$, and obtain a lower-bound for $\widetilde{r}_{\widetilde{\pi}_t,t}$ as a function of $r_{\pi_t^*}$ (see Eq.~\ref{eq:tempB4} in Appendix~\ref{subsec:proof-Lemma-term-I}). Finally, we conclude the proof by using this lower-bound and finding the relationship between the parameters $\alpha_r$ and $\alpha_c$ for which the desired result $\widetilde{r}_{\pi_t,t}\geq r_{\pi_t^*}$ is obtained, i.e.,~$1+\alpha_c\leq (\tau-c_0)(\alpha_r-1)$.
\end{proof}
\begin{proof}[Proof of Theorem~\ref{theorem::main_theorem_linear}]
The proof follows from the fact that the term $(\mathrm{I})$ is negative (Lemma~\ref{lemma:linear_bandits_optimism}), and by combining the upper-bounds on the term $(\mathrm{II})$ from Lemmas~\ref{lemma:bounding-3+5} and~\ref{lemma:bounding-4}, and setting $\gamma = \delta$.
\end{proof}
\section{Supporting Lemmas}
\begin{lemma}\label{lemma::approximation_inverse_prob}
Let $x \in [0,1/2]$, and $\delta \in [-1/4, 1/4]$. Then:
\begin{equation*}
\left| \frac{1/2}{1/2+x+\delta} - \frac{1/2}{1/2+x}\right| \leq 4\delta
\end{equation*}
\end{lemma}
\begin{proof}
Let's start by considering the case when $\delta > 0$. Let $f_x(x) = \frac{1/2}{1/2+x} - \frac{1/2}{1/2+x+\delta} $. Notice that $f_x(x) \geq 0$ for all $x$. This function's derivative satisfies:
\begin{equation*}
\frac{\partial f_x(x)}{\partial x} = \frac{1/2}{(1/2+x+\delta)^2} - \frac{1/2}{(1/2+x)^2}
\end{equation*}
Therefore, and since $\frac{\partial f_x(x)}{\partial x} < 0$ the function $f_x$ is decreasing and therefore the maximizer of $f_x(x)$ for $x \in [0, \frac{1}{2}]$ happens at $x = 0$. In this case:
\begin{align*}
f_x(0) &= 1 - \frac{1/2}{1/2 + \delta} \\
&= 1 - \frac{1}{1 + 2\delta} \\
&= \frac{2\delta }{1+2\delta} \\
&\leq 2\delta
\end{align*}
Now let's consider the case when $\delta < 0$. Let $f_x(x) = \frac{1/2}{1/2+x+\delta} - \frac{1/2}{1/2 + x}$. Notice that $f_x(x) \geq 0$ for all $x$. This function's derivative satisfies:
\begin{equation*}
\frac{ \partial f_x(x)}{\partial x} = \frac{1/2}{(1/2+x)^2} - \frac{1/2}{(1/2+x+\delta)^2}
\end{equation*}
Therefore, and since $\frac{ \partial f_x(x)}{\partial x} < 0$ the function $f_x$ is decreasing and therefore the maximizer of $f_x(x)$ for $x \in [0,\frac{1}{2}]$ happens at $x= 0$. In this case:
\begin{align*}
f_x(0) &= \frac{1/2}{1/2 + \delta} - 1 \\
&= \frac{-\delta}{1/2 + \delta} \\
&\leq -4\delta
\end{align*}
The inequality follows because $1/2+ \delta \geq \frac{1}{4}$. The result follows.
\end{proof}
\section{LP structure}
Recall the optimal policy linear program \ref{eq::no_noise_LP}:
\begin{align*}\label{eq::no_noise_LP_appendix}\tag{P}
&\mathrm{maximize} \sum_{a \in \mathcal{A}} \pi_a \bar{r}_a \\
\text{s.t. } & \sum_{a \in \mathcal{A}} \pi_a \bar{o}_a \geq \tau, \quad \pi \in \mathrm{\Delta}_K\\
\end{align*}
Let $\lambda_1$ and $\lambda_2$ be the two Lagrange associated with the feasibility and the simplex constraints respectively. The lagrangian of \ref{eq::no_noise_LP} takes the form:
\begin{equation*}
L(\pi, \lambda_1, \lambda_2) = \sum_{a} \pi_a \bar{r}_a + \lambda_1\left(\sum_a \pi_a \bar{o}_a \right) + \lambda_2\left( \sum_a \pi_a - 1 \right)
\end{equation*}
Where $\lambda \geq 1$ and $\lambda_2 \in \mathbb{R}$. The dual function equals:
\begin{align*}
g(\lambda_1, \lambda_2) &= \max_{\pi \geq 0} \sum_a \pi_a \bar{r}_a + \lambda_1\left(\sum_a \pi_a \bar{o}_a - \tau \right) + \lambda_2 \left(\sum_a \pi_a - 1 \right) \\
&= \max_{\pi \geq 0} \left( \sum_a \pi_a \left( \bar{r}_a + \lambda_1 \bar{o}_a + \lambda_2 \right) \right)-\tau \lambda_1 -\lambda_2
\end{align*}
If for any $a \in \mathcal{A}$ the expression $\bar{r}_a + \lambda_1 \bar{o}_a + \lambda_2 > 0$, then the expression inside the max will go to infinity. Therefore the dual problem equals:
\begin{align*}\label{eq::no_noise_dual_appendix}\tag{Dual}
&\min -\tau \lambda_1 - \lambda_2 \\
\text{s.t. }& \bar{r}_a + \lambda_1 \bar{o}_a + \lambda_2 \leq 0 \quad \forall a\in\mathcal{A}\\
&\lambda_1 \geq 0, \quad \lambda_2 \in\mathbb{R}
\end{align*}
Alternatively this program can be written as:
\begin{align*}
&-\max \tau\lambda_1 + \lambda_2 \\
\text{s.t.} & \bar{r}_a + \lambda_1 \bar{o}_a + \lambda_2 \leq 0 \quad \forall a \in \mathcal{A}
\end{align*}
Let $(\lambda_1^*, \lambda_2^*)$ be the optimal solutions for this linear program. An easy inspection of the formula above yields the following relationship between $\lambda_1^*$ and $\lambda_2^*$:
\begin{equation*}
\lambda_2^*= \min_a -\bar{r}_a - \bar{o}_a \lambda_1^* = -\max_a (\bar{r}_a + \bar{o}_a \lambda_1^*)
\end{equation*}
This allows us to write the objective function in terms of $\lambda_1$ only. We drop the subscript $1$ for clarity. The objective becomes:
\begin{align*}
-\max_{\lambda \geq 0} \tau \lambda - \max_a (\bar{r}_a + \bar{o}_a \lambda) &= -\max_{\lambda \geq 0} \min_a \left( \lambda(\tau - \bar{o}_a ) - \bar{r}_a \right) \\
&= \min_{\lambda \geq 0} \max_a \left( \lambda(\bar{o}_a - \tau) + \bar{r}_a \right)
\end{align*}
It is easy to see from this equation that the existence of $a^*$ such that $\bar{o}_a \geq \tau$ is a requirement for primal feasibility. This formulation is easily interpretable. We can see that for all $\lambda \geq 0$, the value of $\max_a \lambda(\bar{o}_a - \tau) + \bar{r}_a$ upper bounds the value of any feasible policy.
\subsection{Multiple constraints}
\begin{lemma}\label{lemma::multiple_constraints_support}
The support of a multiple constraint problem equals ...
\end{lemma}
\section{Stability of the optimal solutions}
In this section we explore the stability properties of the optimal solutions of the linear programs \ref{eq::no_noise_LP} and \ref{eq::noisy_LP}. Observe that
\subsection{Bounding the dual variable}
The following LP solves for the $l_1$ norm of $\lambda$:
\begin{align*}
\min \lambda \\
a
\end{align*}
\section{Introduction}
\label{sec:intro}
A {\em multi-armed bandit} (MAB)~\citep{lai85asymptotically,auer02finitetime,lattimore2018bandit} is an online learning problem in which the agent acts by pulling arms. After an arm is pulled, the agent receives its {\em stochastic reward}. The goal of the agent is to maximize its expected cumulative reward without knowledge of the arms' distributions. To achieve this goal, the agent has to balance its {\em exploration} and {\em exploitation}: to decide when to {\em explore} and learn about the arms, and when to {\em exploit} and pull the arm with the highest estimated reward thus far. A \emph{stochastic linear bandit}~\citep{dani08stochastic,rusmevichientong10linearly,abbasi2011improved} is a generalization of MAB to the setting where each of (possibly) infinitely many arms is associated with a feature vector. The mean reward of an arm is the dot product of its feature vector and an unknown parameter vector, which is shared by all the arms. This formulation contains time-varying action (arm) sets and feature vectors, and thus, includes the {\em linear contextual bandit} setting. These models capture many practical applications spanning clinical trials~\citep{Villar15MA}, recommendation systems~\citep{Li10CB,balakrishnan2018using}, wireless networks~\citep{maghsudi2016multi}, sensors~\citep{washburn2008application}, and strategy games \citep{ontanon2013combinatorial}.
The most popular exploration strategies in stochastic bandits are {\em optimism in the face of uncertainty} (OFU)~\citep{auer02finitetime} and {\em Thompson sampling} (TS)~\citep{thompson33likelihood,agrawal13further,russo18tutorial} that are relatively well understood in both multi-armed and linear bandits~\citep{dani08stochastic,abbasi2011improved,agrawal13thompson,lattimore2018bandit}.
In many practical problems, the agent requires to satisfy certain operational constraints while maximizing its cumulative reward. Depending on the form of the constraints, several {\em constrained stochastic bandit} settings have been formulated and analyzed. One such setting is what is known as {\em knapsack bandits}. In this setting, pulling each arm, in addition to producing a reward signal, results in a random consumption of a global budget, and the goal is to maximize the cumulative reward before the budget is fully consumed (e.g.,~\citealt{badanidiyuru2013bandits,badanidiyuru2014resourceful,agrawal2014bandits,wu2015algorithms,agrawal2016linear}). Another such setting is referred to as {\em conservative bandits}. In this setting, there is a baseline arm or policy, and the agent, in addition to maximizing its cumulative reward, should ensure that at each round, the difference between its cumulative reward and that of the baseline remains below a predefined fraction of the baseline cumulative reward~\citep{wu2016conservative,kazerouni2017conservative,Garcelon20IA}. In these two settings, the constraint applies to a cumulative quantity (budget consumption or reward) over the entire run of the algorithm. Thus, the set of feasible actions at each round is a function of the history of the algorithm.
Another constrained bandit setting is where each arm is associated with two (unknown) distributions, generating reward and cost signals. The goal is to maximize the cumulative reward, while making sure that with high probability, the expected cost of the arm pulled at each round is below a certain threshold. Here the constraint is stage-wise, and unlike the last two settings, is independent of the history.~\citet{amani2019linear} and~\citet{Moradipari19SL} have recently studied this setting for linear bandits and derived and analyzed explore-exploit~\citep{amani2019linear} and Thompson sampling~\citep{Moradipari19SL} algorithms for it.
This setting is the closest to the one we study in this paper. In our setting, we also assume two distributions for each arm, one for reward and for cost. At each round the agent constructs a policy according to which it takes its action. The goal of the agent is to produce a sequence of policies with maximum expected cumulative reward, while making sure that the expected cost of the constructed policy (not the pulled arm) at each round is below a certain threshold. This is a linear constraint and can be easily extended to more constraints by having more cost distributions associated to each arm, one per each constraint. Compared to the previous setting, our constraint is more relaxed (from high-probability to expectation), and as a result, it would be possible for us to obtain a solution with larger expected cumulative reward. We will have a detailed discussion on the relationship between these two settings and the similarities and differences of our results with those reported in~\citet{amani2019linear} and~\citet{Moradipari19SL} in Section~\ref{sec:related-work}.
In this paper, we study the above setting for contextual linear bandits. After defining the setting in Section~\ref{sec:setting}, we propose an upper-confidence bound (UCB) algorithm for it, called {\em optimistic pessimistic linear bandit} (OPLB), in Section~\ref{sec:algo}. We prove an $\widetilde{\mathcal{O}}(\frac{d\sqrt{T}}{\tau-c_0})$ bound on the $T$-round regret of OPLB in Section~\ref{section::lin_opt_pess_analysis}, where $d$ is the action dimension and $\tau-c_0$ is the difference between the constraint threshold and the cost of a known feasible action. The action set considered in our contextual linear bandit setting is general enough to include MAB. However, in Section~\ref{sec:constrained-MAB}, we further specialize our results to MAB and propose a computationally efficient algorithm for this setting, called {\em optimistic pessimistic bandit} (OPB). We show that in the MAB case, there always exists a feasible optimal policy with probability mass on at most $m+1$ arms, where $m$ is the number of linear constraints. This property plays an important role in the computational efficiency of OPB. We prove a regret bound of $\widetilde{\mathcal{O}}(\frac{\sqrt{KT}}{\tau - c_0})$ for OPB in $K$-armed bandits, which is a $\sqrt{K}$ improvement over the regret bound we obtain by simply casting MAB as an instance of contextual linear bandit and using the regret bound of OPLB. We also prove a lower-bound for the problem studied in the paper and provide simulations to validate our theoretical results.
\subsection{The LP Structure}\label{section::LP_structure_appendix}
The main purpose of this section is to prove the optimal solutions of the linear program from (\ref{eq::noisy_LP}) are supported on a set of size at most $2$. This structural result will prove important to develop simple efficient algorithms to solve for solving it. Let's recall the form of the Linear program in \ref{eq::noisy_LP} is:
\begin{align*}
\max_{\pi \in \Delta_K} \sum_{a \in \mathcal{A}} \pi_a u^r_{a}(t) \\
\text{s.t. } \sum_{a \in \mathcal{A}} \pi_a u_a^c(t) \leq \tau
\end{align*}
Let's start by observing that in the case $K= 2$ with $\mathcal{A} = \{ a_1, a_2\}$ and $u_{a_1}^c(t) < \tau < u_{a_2}^c(t) $, the optimal policy $\pi^*$ is a mixture policy satisfying:
\begin{align}
\pi_{a_1}^* &= \frac{ u_{a_2}^c(t) - \tau }{u^c_{a_2}(t) - u^c_{a_1}(t)} \notag\\
\pi_{a_2}^* &= \frac{ \tau - u_{a_1}^c(t)}{u^c_{a_2}(t) - u^c_{a_1}(t)} \label{equation::optimal_policy_pair}
\end{align}
The main result in this section is the following Lemma:
\begin{lemma}[$\pi^*$ support]\label{lemma::LP_support_appendix} If (\ref{eq::noisy_LP}) is feasible, there exists an optimal solution with at most $2$ non-zero entries.
\end{lemma}
\begin{proof}
We start by inspecting the dual problem of (\ref{eq::noisy_LP}):
\begin{equation}\label{equation::dual_LP}
\min_{\lambda \geq 0} \max_{a} \lambda( \tau - u_a^c(t) ) + u_a^r(t) \tag{D}
\end{equation}
This formulation is easily interpretable. The quantity $\tau - u_a^c(t)$ measures the feasibility gap of arm $a$, while $u^r_a(t)$ introduces a dependency on the reward signal. Let $\lambda^*$ be the optimal value of the dual variable $\lambda$. Define $\mathcal{A}^*\subseteq \mathcal{A}$ as $\mathcal{A}^* = \arg\max_a \lambda^* (\tau - u^c_a(t) ) + u^r_a(t)$. By complementary slackness the set of nonzero entries of $\pi^*$ must be a subset of $\mathcal{A}^*$.
If $\left|\mathcal{A}^* \right| = 1$, complementary slackness immediately implies the desired result. If $a_1, a_2$ are two elements of $\mathcal{A}^*$, it is easy to see that:
\begin{equation*}
u^r_{a_1}(t) - \lambda^* u^c_{a_1}(t) = u^r_{a_2}(t) -\lambda^* u^c_{a_2}(t) ,
\end{equation*}
and thus,
\begin{equation}
\label{eq::dual_lambda_explicit}
\lambda^* = \frac{ u_{a_2}^r(t) - u^r_{a_1}(t)}{ u_{a_2}^c(t) - u_{a_1}^c(t)}
\end{equation}
If $\lambda^* = 0$, the optimal primal value is achieved by concentrating all mass on any of the arms in $\mathcal{A}^*$. Otherwise, plugging~\ref{eq::dual_lambda_explicit} back into the objective of (\ref{equation::dual_LP}) and rearranging the terms, we obtain
\begin{align*}
s
\end{align*}
\begin{align*}
\text{(D)}&= \lambda^*( \tau- u_{a_1}^c(t)) + u^r_{a_1}(t)\\
&= u^r_{a_1}(t)\left(\frac{ \tau - u_{a_1}^c(t) }{ u_{a_2}^c(t) - u_{a_1}^c(t)} \right) + u_{a_2}^r(t) \left(\frac{ u_{a_2}^c(t) - \tau }{ u_{a_2}^c(t) - u_{a_1}^c(t) } \right).
\end{align*}
If $u_{a_2}^c(t) \geq \tau \geq u_{a_1}^c(t)$, we obtain a feasible value for the primal variable $\pi_{a_1}^* = \frac{ \tau - u_{a_1}^c(t) }{ u_{a_2}^c(t) - u_{a_1}^c(t)} $, $\pi_{a_2}^* = \frac{ u_{a_2}^c(t) -\tau }{ u_{a_2}^c(t) - u_{a_1}^c(t)}$ and zero for all other $a \in \mathcal{A} \backslash \{ a_1, a_2 \}$. Since we have assumed (\ref{eq::noisy_LP}) to be feasible there must be either one arm $a^* \in \mathcal{A}^*$ satisfying $a^* = \arg\max_{a \in \mathcal{A}^*} u_{a}^r(t)$ and $u_{a^*}^c(t) \leq \tau$ or two such arms $a_1$ and $a_2$ in $\mathcal{A}^*$ that satisfy $u_{a_2}^c(t) \geq \tau \geq u_{a_1}^c(t)$, since otherwise it would be impossible to produce a feasible primal solution without having any of its supporting arms $a$ satisfying $u_a^c(t) \leq \tau$, there must exist an arm $a \in \mathcal{A}^*$ with $u_a^c(t) < \tau$. This completes the proof. \end{proof}
From the proof of Lemma \ref{lemma::LP_support} we can conclude the optimal policy is either a delta mass centered at the arm with the largest reward - whenever this arm is feasible - or it is a strict mixture supported on two arms.
A further consequence of Lemma~\ref{lemma::LP_support_appendix} is that it is possible to find the optimal solution $\pi^*$ to problem~\ref{eq::noisy_LP} by simply enumerating all pairs of arms $(a_i, a_j)$ and all singletons, compute their optimal policies (if feasible) using Equation~\ref{equation::optimal_policy_pair} and their values and selecting the feasible pair (or singleton) achieving the largest value. More sophisticated methods can be developed by taking into account elimination strategies to prune out arms that can be determined in advance not to be optimal nor to belong to an optimal pair. Overall this method is more efficient than running a linear programming solver on~(\ref{eq::noisy_LP}).
If we had instead $m$ constraints, a similar statement to Lemma \ref{lemma::LP_support} holds, namely it is possible to show the optimal policy will have support of size at most $m+1$. The proof is left as an exercise for the reader.
\section{Experiments}
\label{sec:experiments}
\vspace{-0.1in}
We run a set of experiments to show the behavior of OPB and validate our theoretical results. We consider a $K=4$-armed bandits in which the reward and cost distributions of the arms are Bernoulli with means $\bar r=(.1,.2,.4,.7)$ and $\bar c =(0,.4,.5,.2)$. So, the cost of the safe arm is $\bar c_1=0$. In Figures~\ref{fig:constrained_bandits1} to~\ref{fig:constrained_bandits3}, we gradually reduce the constraint threshold $\tau$, and as a result the complexity of the problem $\tau - \bar{c}_1$, and show the regret {\em (left)} and the cost {\em (middle)} and reward {\em (right)} evolution of OPB. All the results are averaged over $10$ runs and the shade is the $\pm .5$ standard deviation around the regret.
Our results show that the regret of OPB grows as we reduce $\tau$ {\em (left)}. They also indicate that the algorithm is successful in satisfying the constraint {\em (middle)} and reaching the optimal reward/performance {\em (right)}. In Figure~\ref{fig:constrained_bandits3}, the reason that the cost evolution of OPB is the same as that of the optimal policy {\em (middle)} is that in this case, the cost of the best arm (arm $4$) is equal to the constraint threshold $\tau=.2$.
\begin{wrapfigure}{r}{0.625\textwidth}
\vspace{-0.3in}
\begin{minipage}{0.625\textwidth
\centering\subfigure{\includegraphics[width=0.325\linewidth]{figs/constrained_regrets_tau_1.png}}
\centering\subfigure{\includegraphics[width=0.325\linewidth]{figs/cost_evolution_tau_1.png}}
\centering\subfigure{\includegraphics[width=0.325\linewidth]{figs/rewards_evolution_tau_1.png}}
\end{minipage}
\vspace{-4mm}
\caption{{Constraint Threshold $\;\tau = 1$.}}
\vspace{-2mm}
\label{fig:constrained_bandits1}
\begin{minipage}{0.625\textwidth
\centering\subfigure{\includegraphics[width=0.325\linewidth]{figs/constrained_regrets_tau_05.png}}
\centering\subfigure{\includegraphics[width=0.325\linewidth]{figs/cost_evolution_tau_05.png}}
\centering\subfigure{\includegraphics[width=0.325\linewidth]{figs/rewards_evolution_tau_05.png}}
\end{minipage}
\vspace{-4mm}
\caption{{Constraint Threshold $\;\tau = 0.5$.}}
\vspace{-2mm}
\label{fig:constrained_bandits2}
\begin{minipage}{0.625\textwidth
\centering\subfigure{\includegraphics[width=0.325\linewidth]{figs/constrained_regrets_tau_02.png}}
\centering\subfigure{\includegraphics[width=0.325\linewidth]{figs/cost_evolution_tau_02.png}}
\centering\subfigure{\includegraphics[width=0.325\linewidth]{figs/rewards_evolution_tau_02.png}}
\end{minipage}
\vspace{-4mm}
\caption{{Constraint Threshold $\;\tau = 0.2$.}}
\label{fig:constrained_bandits3}
\begin{center}
\begin{minipage}{0.625\textwidth}
\begin{center} \small{ \textbf{OPB.} Bernoulli arms. $\bar{r} = (.1, .2, .4, .7)$, $\bar{c}=(0, .4, .5, .2)$, $\bar{c}_1 = 0$.} \end{center}
\end{minipage}
\end{center}
\vspace{-0.225in}
\end{wrapfigure}
\subsection{Optimism Pessimism}\label{section::appendix_MAB_optimism_pessimism_algorithm}
Here we reproduce the full pseudo-code for OPB:
{\centering
\begin{minipage}{.9\linewidth}
\begin{algorithm}[H]
\textbf{Input:} Number of arms $K$, constants $\alpha_r, \alpha_c \geq 1$. \\
\For{$t=1, \ldots , T$}{
1. Compute estimates $\{u_a^r(t) \}_{a\in\mathcal A}$, $\{u_a^c(t) \}_{a\in\mathcal A}$. \\
2. Form the approximate LP (\ref{eq::noisy_LP}) using these estimates.\\
3. Find policy $\pi_t$ by solving~\eqref{eq::noisy_LP}.\\
4. Play arm $a \sim \pi_t$ \; \\%}
}
\caption{Optimism-Pessimism}
\label{alg::optimism_pessimism}
\end{algorithm}
\end{minipage}
}
Similar to the case of OPLB, we define $\Pi_t = \{ \pi \in \Delta_{\mathcal{A}} : \sum_{a \in \mathcal{A}} \pi_a u_a^c(t) \leq \tau \}$. We also define $\beta_a(0) = 0$ for all $a\in \mathcal{A}$.
\subsection{The LP Structure}\label{section::LP_structure_appendix}
The main purpose of this section is to prove the optimal solutions of the linear program from (\ref{eq::noisy_LP}) are supported on a set of size at most $2$. This structural result will prove important to develop simple efficient algorithms to solve for solving it. Let's recall the form of the Linear program in \ref{eq::noisy_LP} is:
\begin{align*}
\max_{\pi \in \Delta_K} \sum_{a \in \mathcal{A}} \pi_a u^r_{a}(t) \\
\text{s.t. } \sum_{a \in \mathcal{A}} \pi_a u_a^c(t) \leq \tau
\end{align*}
Let's start by observing that in the case $K= 2$ with $\mathcal{A} = \{ a_1, a_2\}$ and $u_{a_1}^c(t) < \tau < u_{a_2}^c(t) $, the optimal policy $\pi^*$ is a mixture policy satisfying:
\begin{align}
\pi_{a_1}^* &= \frac{ u_{a_2}^c(t) - \tau }{u^c_{a_2}(t) - u^c_{a_1}(t)} \notag\\
\pi_{a_2}^* &= \frac{ \tau - u_{a_1}^c(t)}{u^c_{a_2}(t) - u^c_{a_1}(t)} \label{equation::optimal_policy_pair}
\end{align}
The main result in this section is the following Lemma:
\begin{lemma}[$\pi^*$ support]\label{lemma::LP_support_appendix} If (\ref{eq::noisy_LP}) is feasible, there exists an optimal solution with at most $2$ non-zero entries.
\end{lemma}
\begin{proof}
We start by inspecting the dual problem of (\ref{eq::noisy_LP}):
\begin{equation}\label{equation::dual_LP}
\min_{\lambda \geq 0} \max_{a} \lambda( \tau - u_a^c(t) ) + u_a^r(t) \tag{D}
\end{equation}
This formulation is easily interpretable. The quantity $\tau - u_a^c(t)$ measures the feasibility gap of arm $a$, while $u^r_a(t)$ introduces a dependency on the reward signal. Let $\lambda^*$ be the optimal value of the dual variable $\lambda$. Define $\mathcal{A}^*\subseteq \mathcal{A}$ as $\mathcal{A}^* = \arg\max_a \lambda^* (\tau - u^c_a(t) ) + u^r_a(t)$. By complementary slackness the set of nonzero entries of $\pi^*$ must be a subset of $\mathcal{A}^*$.
If $\left|\mathcal{A}^* \right| = 1$, complementary slackness immediately implies the desired result. If $a_1, a_2$ are two elements of $\mathcal{A}^*$, it is easy to see that:
\begin{equation*}
u^r_{a_1}(t) - \lambda^* u^c_{a_1}(t) = u^r_{a_2}(t) -\lambda^* u^c_{a_2}(t) ,
\end{equation*}
and thus,
\begin{equation}
\label{eq::dual_lambda_explicit}
\lambda^* = \frac{ u_{a_2}^r(t) - u^r_{a_1}(t)}{ u_{a_2}^c(t) - u_{a_1}^c(t)}
\end{equation}
If $\lambda^* = 0$, the optimal primal value is achieved by concentrating all mass on any of the arms in $\mathcal{A}^*$. Otherwise, plugging~\ref{eq::dual_lambda_explicit} back into the objective of (\ref{equation::dual_LP}) and rearranging the terms, we obtain
\begin{align*}
s
\end{align*}
\begin{align*}
\text{(D)}&= \lambda^*( \tau- u_{a_1}^c(t)) + u^r_{a_1}(t)\\
&= u^r_{a_1}(t)\left(\frac{ \tau - u_{a_1}^c(t) }{ u_{a_2}^c(t) - u_{a_1}^c(t)} \right) + u_{a_2}^r(t) \left(\frac{ u_{a_2}^c(t) - \tau }{ u_{a_2}^c(t) - u_{a_1}^c(t) } \right).
\end{align*}
If $u_{a_2}^c(t) \geq \tau \geq u_{a_1}^c(t)$, we obtain a feasible value for the primal variable $\pi_{a_1}^* = \frac{ \tau - u_{a_1}^c(t) }{ u_{a_2}^c(t) - u_{a_1}^c(t)} $, $\pi_{a_2}^* = \frac{ u_{a_2}^c(t) -\tau }{ u_{a_2}^c(t) - u_{a_1}^c(t)}$ and zero for all other $a \in \mathcal{A} \backslash \{ a_1, a_2 \}$. Since we have assumed (\ref{eq::noisy_LP}) to be feasible there must be either one arm $a^* \in \mathcal{A}^*$ satisfying $a^* = \arg\max_{a \in \mathcal{A}^*} u_{a}^r(t)$ and $u_{a^*}^c(t) \leq \tau$ or two such arms $a_1$ and $a_2$ in $\mathcal{A}^*$ that satisfy $u_{a_2}^c(t) \geq \tau \geq u_{a_1}^c(t)$, since otherwise it would be impossible to produce a feasible primal solution without having any of its supporting arms $a$ satisfying $u_a^c(t) \leq \tau$, there must exist an arm $a \in \mathcal{A}^*$ with $u_a^c(t) < \tau$. This completes the proof. \end{proof}
From the proof of Lemma \ref{lemma::LP_support} we can conclude the optimal policy is either a delta mass centered at the arm with the largest reward - whenever this arm is feasible - or it is a strict mixture supported on two arms.
A further consequence of Lemma~\ref{lemma::LP_support_appendix} is that it is possible to find the optimal solution $\pi^*$ to problem~\ref{eq::noisy_LP} by simply enumerating all pairs of arms $(a_i, a_j)$ and all singletons, compute their optimal policies (if feasible) using Equation~\ref{equation::optimal_policy_pair} and their values and selecting the feasible pair (or singleton) achieving the largest value. More sophisticated methods can be developed by taking into account elimination strategies to prune out arms that can be determined in advance not to be optimal nor to belong to an optimal pair. Overall this method is more efficient than running a linear programming solver on~(\ref{eq::noisy_LP}).
If we had instead $m$ constraints, a similar statement to Lemma \ref{lemma::LP_support} holds, namely it is possible to show the optimal policy will have support of size at most $m+1$. The proof is left as an exercise for the reader.
\section{Proofs of Section~\ref{sec:algo}}
\label{sec:proofs-algo-section}
\subsection{Proof of Proposition~\ref{prop:optimistic-reward-pessimistic-cost}}
\label{subsec:proof-prop-optimistic-reward}
\begin{proof}
We only prove the statement for the optimistic reward, $\widetilde{r}_{\pi,t}$. The proof for the pessimistic cost, $\widetilde{c}_{\pi,t}$, is analogous. From the definition of the confidence set $\mathcal{C}_t^r(\alpha_r)$ in~\eqref{eq:confidence-ellipsoids}, any vector $\theta \in \mathcal{C}_t^r(\alpha_r)$ can be written as $\widehat{\theta}_t + v$, where $v$ satisfying $\| v\|_{\Sigma_t} \leq \alpha_r \beta_t(\delta, d)$. Thus, we may write
\begin{align*}
\widetilde{r}_{\pi,t} &= \max_{\theta \in \mathcal{C}_t^r(\alpha_r)} \mathbb{E}_{x \sim \pi}[ \langle x, \theta \rangle ] = \max_{\theta \in \mathcal{C}_t^r(\alpha_r)} \langle x_\pi, \theta \rangle = \langle x_\pi, \widehat{\theta}_t \rangle + \max_{v:\|v\|_{\Sigma_t} \leq \alpha_r \beta_t(\delta, d)} \langle x_\pi, v \rangle \\
&\stackrel{\text{(a)}}{\leq} \langle x_\pi,\widehat{\theta}_t \rangle + \alpha_r \beta_t(\delta, d) \| x_\pi \|_{\Sigma_t^{-1}}.
\end{align*}
{\bf (a)} By Cauchy-Schwartz, for all $v$, we have $\langle x_{\pi}, v \rangle \leq \| x_{\pi}\|_{\Sigma_t^{-1}} \| v\|_{\Sigma_t}$. The result follows from the condition on $v$ in the maximum, i.e.,~$\| v \|_{\Sigma_t} \leq \alpha_r \beta_t(\delta,d)$.
Let us define $v^* := \frac{ \alpha_r \beta_t(\delta, d) \Sigma^{-1}_t x_\pi}{\| x_\pi \|_{\Sigma^{-1}_t}}$. This value of $v^*$ is feasible because
\begin{equation*}
\|v^*\|_{\Sigma_t} = \frac{\alpha_r \beta_t(\delta,d)}{\| x_\pi \|_{\Sigma^{-1}_t}} \sqrt{x_\pi^\top \Sigma_t^{-1} \Sigma_t \Sigma_t^{-1} x_\pi} = \frac{\alpha_r\beta_t(\delta,d)}{\|x_\pi\|_{\Sigma^{-1}_t}} \sqrt{x_\pi^\top\Sigma_t^{-1}x_\pi} = \alpha_r\beta_t(\delta, d).
\end{equation*}
We now show that $v^*$ also achieves the upper-bound in the above inequality resulted from Cauchy-Schwartz
\begin{equation*}
\langle x_\pi, v^* \rangle = \frac{\alpha_r \beta_t(\delta, d) x_\pi^\top \Sigma_t^{-1} x_\pi}{\| x_\pi \|_{\Sigma_t^{-1}}} = \alpha_r \beta_t(\delta, d) \| x_\pi \|_{\Sigma_t^{-1}}.
\end{equation*}
Thus, $v^*$ is the maximizer and we can write
\begin{align*}
\widetilde{r}_{\pi,t} = \langle x_\pi,\widehat{\theta}_t \rangle + \langle x_\pi,v^* \rangle = \langle x_\pi,\widehat{\theta}_t \rangle + \alpha_r \beta_t(\delta, d) \| x_\pi \|_{\Sigma_t^{-1}},
\end{align*}
which concludes the proof.
\end{proof}
\subsection{Proof of Proposition~\ref{prop:safe-set}}
\label{subsec:proof-safe-set}
\begin{proof}
Recall that $\tilde{c}_{\pi, t} = \frac{ \langle x_{\pi}^o, e_0\rangle c_0}{ \| x_0\| } + \langle x_{\pi}^{o, \perp}, \widehat{t}_{\pi}^{o, \perp}\rangle + \alpha_c \beta_t(\delta, d-1)\| x_{\pi}^{o, \perp} \|_{ (\Sigma^{o, \perp}_t)^{-1}}\leq \tau$.
Conditioned on the event $\mathcal{E}$ as defined in equation \ref{eq:high-prob-event}, it follows that:
\begin{align*}
|\langle x_{\pi}^{o, \perp} , \widehat{\mu}_t^{o, \perp} -\mu_*^{o, \perp}\rangle| &\leq \| \mu_*^{o, \perp} - \widehat{\mu}_t^{o, \perp} \|_{\Sigma_t^{o, \perp}}\| x_{\pi}\|_{(\Sigma^{o, \perp}_t)^{-1}} \\
&\leq \langle x_{\pi}^{o, \perp} , \widehat{\mu}_t^{o, \perp} -\mu_*^{o, \perp}\rangle \beta_t
(\delta, d-1) \| x_{\pi}\|_{(\Sigma^{o, \perp}_t)^{-1}}
\end{align*}
And therefore:
\begin{equation}
0 \leq \langle x_{\pi}^{o, \perp} , \widehat{\mu}_t^{o, \perp} -\mu_*^{o, \perp}\rangle + \beta_t
(\delta, d-1) \| x_{\pi}\|_{(\Sigma^{o, \perp}_t)^{-1}} \label{equation::prop_3_eq1}
\end{equation}
Observe that:
\begin{align}
c_{\pi} &= \frac{ \langle x_{\pi}^o, e_0\rangle c_0}{ \| x_0\| } + \langle x_{\pi}^{o, \perp}, \mu_*^{o, \perp}\rangle \notag\\
&\leq \underbrace{\frac{ \langle x_{\pi}^o, e_0\rangle c_0}{ \| x_0\| } + \langle x_{\pi}^{o, \perp}, \widehat{\mu}_{t}^{o, \perp}\rangle + \alpha_c \beta_t(\delta, d-1)\| x_{\pi}^{o, \perp} \|_{ (\Sigma^{o, \perp}_t)^{-1}}}_{\mathrm{I}}\label{equation::prop_3_eq2}
\end{align}
The last inequality holds by adding Inequality \ref{equation::prop_3_eq1} to Inequality \ref{equation::prop_3_eq2}. Since by assumption for all $\pi \in \Pi_t$ term $I \leq \tau$, we obtain that $c_\pi \leq \tau$. The result follows.
\end{proof}
\newpage
\section{Proofs of Section~\ref{section::lin_opt_pess_analysis}}
\label{sec:proofs-analysis-section}
\subsection{Proof of Lemma~\ref{lemma:bounding-4}}
\label{subsec:proof-Lemma-bounding-4}
We first state the following proposition that is used in the proof of Lemma~\ref{lemma:bounding-4}. This proposition is a direct consequence of Eq.~20.9 and Lemma~19.4 in~\cite{lattimore2018bandit}. Similar result has also been reported in the appendix of~\cite{amani2019linear}.
\begin{proposition}
\label{proposition:det_lemma}
For any sequence of actions $(x_1,\ldots,x_t)$, let $\Sigma_t$ be its corresponding Gram matrix defined by~\eqref{eq:Sigmas} with $\lambda \geq 1$. Then, for all $t\in[T]$, we have
\vspace{-0.15in}
\begin{small}
\begin{equation*}
\sum_{s=1}^T \| x_s \|_{\Sigma^{-1}_{s}} \leq \sqrt{2Td\log\big( 1+\frac{TL^2}{\lambda}\big)}.
\end{equation*}
\end{small}
\end{proposition}
We now state the proof of Lemma~\ref{lemma:bounding-4}.
\begin{proof}[Proof of Lemma~\ref{lemma:bounding-4}]
We prove this lemma through the following sequence of inequalities:
\vspace{-0.15in}
\begin{small}
\begin{align*}
\sum_{t=1}^T \langle x_t, \widetilde{\theta}_t\rangle - \langle x_t, \theta_* \rangle &\stackrel{\text{(a)}}{\leq} \sum_{t=1}^T \| x_t \|_{\Sigma_t^{-1}}\| \widetilde{\theta}_t - \theta_* \|_{\Sigma_t} \stackrel{\text{(b)}}{\leq} \sum_{t=1}^T (1+\alpha_r) \beta_t(\delta,d)\| x_t \|_{\Sigma_t^{-1}} \\
&\stackrel{\text{(c)}}{\leq} (1+\alpha_r)\beta_T(\delta,d) \sum_{t=1}^T \| x_t \|_{\Sigma_t^{-1}} \stackrel{\text{(d)}}{\leq}(1+\alpha_r)\beta_T(\delta,d) \sqrt{2Td\log\big(1+\frac{TL^2}{\lambda}\big)}
\end{align*}
\end{small}
\vspace{-0.15in}
{\bf (a)} This is by Cauchy-Schwartz.
{\bf (b)} This follows from the fact that $\widetilde{\theta}_t\in \mathcal{C}_t^r(\alpha_r)$ and we are on event $\mathcal E$.
{\bf (c)} This is because $\beta_t(\delta,d)$ is an increasing function of $t$, i.e.,~$\beta_T(\delta,d) \geq \beta_t(\delta,d),\;\forall t\in [T]$.
{\bf (d)} This is a direct result of Proposition~\ref{proposition:det_lemma}.
\end{proof}
\subsection{Proof of Lemma~\ref{lemma:inverse_norm_domination}}
\label{subsec:proof-Lemma-inverse-norm-domination}
\begin{proof}
In order to prove the desired result it is enough to show that:
\begin{equation*}
\left( x_{\pi}^{o, \perp}\right)^\top \left( \Sigma_t^{o, \perp}\right)^{\dagger} x_\pi^{o, \perp} \leq x_\pi^\top \Sigma_t^{-1}x_\pi
\end{equation*}
w.l.o.g. we can assume $x_o = e_1$, the first basis vector. Notice that in this case $\Sigma_t^{o, \perp}$ can be thought of as a submatrix of $\Sigma_t$ such that $\Sigma_t[2:, 2:] = \Sigma_t^{o, \perp}$, where $\Sigma_t[2:, 2:]$ denotes the submatrix with row and column indices from $2$ onwards.
Using the following formula for the inverse of a psd symmetric matrix:
\begin{equation*}
\begin{bmatrix}
Z & \delta\\
\delta^\top & A
\end{bmatrix} = \begin{bmatrix}
\frac{1}{D} & -\frac{ A^{-1}\delta}{D}\\
- \frac{\delta^\top A^{-1} }{D}&A^{-1} + \frac{ A^{1} \delta \delta^\top A^{-1}}{D}
\end{bmatrix}
\end{equation*}
Where $D = z- \delta^\top A^{-1} \delta$. In our case $D = \Sigma_t[1,1] - \Sigma_t[2:d]^\top \left( \Sigma_t^{o, \perp} \right)^{-1} \Sigma_t[2:d] \in \mathbb{R}$. Observe that since $\Sigma_t$ is PSD, $D \geq 0$. Therefore:
\begin{equation*}
\Sigma_t^{-1} = \begin{bmatrix}
1/D & -\frac{\left(\Sigma_t^{o, \perp}\right)^{-1} \Sigma_t[2, :d] }{D} \\
-\frac{\Sigma_t^\top [2:d]\left( \Sigma_t^{o, \perp}\right)^{-1} }{D} & \left( \Sigma_t^{o, \perp} \right)^{-1} + \frac{ \left( \Sigma_t^{o, \perp}\right)^{-1} \Sigma_t[2:d]\Sigma_t[2:d]\left(\Sigma_t^{o, \perp}\right)^{-1} }{D}
\end{bmatrix}
\end{equation*}
Then:
\begin{align*}
x_\pi^\top \left( \Sigma_t^{-1} \right)^{-1} x_\pi &= \frac{ x_\pi(1)^2 - 2x_\pi(1)\Sigma_t[2:d]^\top\left( \Sigma_t^{o, \perp} \right)^{-1} x_\pi[2:d]}{D} +\\
&\frac{ x_\pi[2:d]^\top \left(\Sigma_t^{o, \perp} \right)^{-1} \Sigma_t[2:d]\Sigma_t[2:d]^\top\left( \Sigma_t^{o, \perp} \right)^{-1} x_\pi[2:d] }{D} \\
&+ x_\pi[2:d]^\top \left( \Sigma_t^{o, \perp} \right)^{-1} x_\pi[2:d]\\
&\geq x_\pi[2:d]^\top \left( \Sigma_t^{o, \perp} \right)^{-1} x_\pi[2:d]
\end{align*}
The result follows by noting that $x_\pi[2:d] = x_\pi^{o, \perp}$.
\end{proof}
\subsection{Proof of Lemma~\ref{lemma:linear_bandits_optimism}}
\label{subsec:proof-Lemma-term-I}
\begin{proof}
For any policy $\pi$, we have
\begin{equation}
\label{eq:tempB0}
\widetilde{r}_{\pi,t} = \max_{\theta \in \mathcal{C}_t^r(\alpha_r)} \langle x_\pi,\theta \rangle \geq \langle x_\pi, \theta_* \rangle = r_\pi.
\end{equation}
If $\pi_t^* \in \Pi_t$, then by the definition of $\pi_t$ (Line~4 of Algorithm~\ref{alg:optimistic-pessimistic-LB}), we have
\begin{equation}
\label{eq:tempB1}
\widetilde{r}_{\pi_t,t} \geq \widetilde{r}_{\pi_t^*,t}.
\end{equation}
Combining~\eqref{eq:tempB0} and~\eqref{eq:tempB1}, we may conclude that $\widetilde{r}_{\pi_t,t} \geq r_{\pi_t^*}$ as desired.
We now focus on the case that $\pi_t^* \not\in \Pi_t$, i.e.,
\begin{equation*}
\widetilde{c}_{\pi_t^*,t} = \frac{\langle x_{\pi^*_t}^o,e_0 \rangle c_0}{\|x_0\|} + \langle x_{\pi^*_t}^{o,\perp},\widehat{\mu}^{o,\perp}_t \rangle + \alpha_c\beta_t(\delta,d-1) \| x_{\pi^*_t}^{o,\perp} \|_{(\Sigma_t^{o,\perp})^{-1}} > \tau.
\end{equation*}
We define a mixture policy $\widetilde{\pi}_t = \eta_t \pi_t^* + (1-\eta_t)\pi_0$, where $\pi_0$ is the policy that always selects the safe action $x_0$ and $\eta_t \in [0,1]$ is the maximum value of $\eta$ such that $\big(\eta\pi^*_t+(1-\eta)\pi_0\big) \in \Pi_t$. Conceptually, $\eta_t$ shows how close is the optimal policy $\pi^*_t$ to the set of safe policies $\Pi_t$.
By the definition of $\widetilde{\pi}_t$, we have
\begin{equation}
\label{eq:tempB2}
x^o_{\widetilde{\pi}_t} = \eta_t x^o_{\pi_t^*} + (1-\eta_t)x_0, \qquad x^{o,\perp}_{\widetilde{\pi}_t} = \eta_t x^{o,\perp}_{\pi_t^*},
\end{equation}
which allows us to write
\begin{align*}
\widetilde{c}_{\widetilde{\pi}_t,t} &= \frac{\eta_t\langle x_{\pi_t^*}^o,e_0 \rangle + (1-\eta_t) \langle x_0,e_0 \rangle}{\|x_0\|}\cdot c_0 + \eta_t \langle x_{\pi_t^*}^{o,\perp}, \widehat{\mu}^{o,\perp}_t \rangle + \eta_t\alpha_c\beta_t(\delta,d-1) \| x_{\pi_t^*}^{o,\perp} \|_{(\Sigma_t^{o,\perp})^{-1} } \\
&= \frac{(1-\eta_t) \langle x_0,e_0 \rangle c_0}{\|x_0\|} + \eta_t \widetilde{c}_{\pi_t^*,t}.
\end{align*}
From the definition of $\eta_t$, we have $\widetilde{c}_{\widetilde{\pi}_t,t}=\frac{(1-\eta_t) \langle x_0,e_0 \rangle c_0}{\|x_0\|} + \eta_t \widetilde{c}_{\pi_t^*,t}=\tau$, and thus, we may write
\begin{align}
\eta_t &= \frac{\tau - \frac{\langle x_0,e_0 \rangle c_0}{\|x_0\|}}{\widetilde{c}_{\pi_t^*,t} - \frac{\langle x_0,e_0 \rangle c_0}{\|x_0\|}} = \frac{\tau - c_0}{\frac{\langle x_{\pi_t^*}^o,e_0\rangle c_0}{\|x_0\|} + \langle x_{\pi_t^*}^{o,\perp}, \widehat{\mu}^{o,\perp}_t \rangle + \alpha_c\beta_t(\delta,d-1)\|x^{o,\perp}_{\pi_t^*}\|_{(\Sigma^{0, \perp}_t)^{-1}} - c_0} \nonumber \\
&= \frac{\tau - c_0}{\frac{\langle x_{\pi_t^*}^o,e_0 \rangle c_0}{\|x_0\|} + \langle x_{\pi_t^*}^{o,\perp},\mu_* \rangle + \langle x_{\pi_t^*}^{o, \perp}, \widehat{\mu}^{o,\perp}_t - \mu_* \rangle + \alpha_c\beta_t(\delta, d-1)\|x^{o,\perp}_{\pi_t^*}\|_{(\Sigma^{o, \perp}_t)^{-1}} - c_0} \nonumber \\
&\stackrel{\text{(a)}}{\geq} \frac{\tau - c_0}{\frac{\langle x_{\pi_t^*}^o, e_0 \rangle c_0}{\|x_0\|} + \langle x_{\pi_t^*}^{o,\perp},\mu_* \rangle + (1+\alpha_c)\beta_t(\delta,d-1)\|x^{o,\perp}_{\pi_t^*}\|_{(\Sigma_t^{o,\perp})^{-1}} - c_0} \nonumber \\
&\stackrel{\text{(b)}}{\geq} \frac{\tau - c_0}{\tau + (\alpha_c+1)\beta_t(\delta,d-1)\|x^{o,\perp}_{\pi_t^*}\|_{(\Sigma_t^{o,\perp})^{-1}} - c_0}.
\label{eq:tempB3}
\end{align}
{\bf (a)} This holds because
\begin{equation*}
\langle x^{o,\perp}_{\pi_t^*},\widehat{\mu}^{o,\perp}_t - \mu_* \rangle = \langle x^{o,\perp}_{\pi_t^*},\widehat{\mu}^{o,\perp}_t - \mu^{o,\perp}_* \rangle \leq \|\widehat{\mu}^{o,\perp}_t - \mu_*^{o,\perp}\|_{\Sigma^{o,\perp}_t} \|x^{o,\perp}_{\pi_t^*}\|_{(\Sigma^{o,\perp}_t)^{-1}} \leq \beta_t(\delta, d-1) \|x^{o,\perp}_{\pi_t^*}\|_{(\Sigma^{o, \perp}_t)^{-1}},
\end{equation*}
where the last inequality is because we are on the event $\mathcal E$.
{\bf (b)} This passage is due to the fact that the optimal policy $\pi^*_t$ is feasible, and thus, $\mathbb E_{x\sim\pi_t^*}[\langle x,\mu_* \rangle] \leq \tau$. Therefore, we may write
\begin{align*}
\mathbb E_{x\sim\pi_t^*}[\langle x,\mu_* \rangle] &= \mathbb E_{x\sim\pi_t^*}[\langle x^o,\mu_* \rangle] + \langle x_{\pi_t^*}^{o,\perp},\mu_* \rangle = \mathbb E_{x\sim\pi_t^*}[\langle \langle x,e_0 \rangle e_0,\mu_* \rangle] + \langle x_{\pi_t^*}^{o,\perp},\mu_* \rangle \\
&= \mathbb E_{x\sim\pi_t^*}[\langle \langle x,e_0 \rangle \frac{x_0}{\|x_0\|},\mu_* \rangle] + \langle x_{\pi_t^*}^{o,\perp},\mu_* \rangle = \frac{c_0}{\|x_0\|}\mathbb E_{x\sim\pi_t^*}[\langle x,e_0\rangle] + \langle x_{\pi_t^*}^{o,\perp},\mu_* \rangle \\
&= \frac{\langle x^o_{\pi_t^*},e_0 \rangle c_0}{\|x_0\|} + \langle x_{\pi_t^*}^{o,\perp},\mu_* \rangle \leq \tau.
\end{align*}
Since $\widetilde{\pi}_t \in \Pi_t$, we have
\begin{align}
\widetilde{r}_{\pi_t,t} &\geq \widetilde{r}_{\widetilde{\pi}_t,t} = \langle x_{\widetilde{\pi}_t},\widehat{\theta}_t \rangle + \alpha_r\beta_t(\delta,d)\|x_{\widetilde{\pi}_t}\|_{\Sigma_t^{-1}} = \langle x_{\widetilde{\pi}_t},\theta_* \rangle + \langle x_{\widetilde{\pi}_t},\widehat{\theta}_t - \theta_* \rangle + \alpha_r\beta_t(\delta,d)\|x_{\widetilde{\pi}_t}\|_{\Sigma_t^{-1}} \nonumber \\
&\stackrel{\text{(a)}}{\geq} \langle x_{\widetilde{\pi}_t},\theta_* \rangle + (\alpha_r - 1)\beta_t(\delta,d)\|x_{\widetilde{\pi}_t}\|_{\Sigma_t^{-1}} \stackrel{\text{(b)}}{\geq} \langle x_{\widetilde{\pi}_t},\theta_* \rangle + (\alpha_r - 1)\beta_t(\delta,d-1)\|x^{o,\perp}_{\widetilde{\pi}_t}\|_{(\Sigma^{o,\perp}_t)^{-1}} \nonumber \\
&\stackrel{\text{(c)}}{=} \eta_t \langle x_{\pi^*},\theta_* \rangle + (1-\eta_t)\langle x_0,\theta_* \rangle + \eta_t(\alpha_r-1)\beta_t(\delta,d-1)\|x^{o,\perp}_{\pi_t^*}\|_{(\Sigma^{o, \perp}_t)^{-1}} \nonumber \\
&\stackrel{\text{(d)}}{\geq} \eta_t \langle x_{\pi_t^*},\theta_* \rangle + \eta_t(\alpha_r-1)\beta_t(\delta,d-1)\|x^{o,\perp}_{\pi^*}\|_{(\Sigma^{o,\perp}_t)^{-1}} \nonumber \\
&\stackrel{\text{(e)}}{\geq} \underbrace{\Big(\frac{\tau - c_0}{\tau - c_0 + (\alpha_c+1) \beta_t(\delta, d-1) \|x^{o,\perp}_{\pi_t^*}\|_{(\Sigma_t^{o,\perp})^{-1}}}\Big) \Big(\langle x_{\pi_t^*},\theta_* \rangle + (\alpha_r-1)\beta_t(\delta,d-1) \|x^{o,\perp}_{\pi_t^*}\|_{(\Sigma^{o,\perp}_t)^{-1}}\Big)}_{C_0}.
\label{eq:tempB4}
\end{align}
{\bf (a)} This is because we may write
\begin{equation*}
|\langle x_{\widetilde{\pi}_t},\widehat{\theta}_t - \theta_* \rangle| \leq \|\widehat{\theta}_t - \theta_*\|_{\Sigma_t} \|x_{\widetilde{\pi}_t}\|_{\Sigma_t^{-1}} \leq \beta_t(\delta,d) \|x_{\widetilde{\pi}_t}\|_{\Sigma_t^{-1}},
\end{equation*}
where the last inequality is due to the fact that we are on the event $\mathcal E$. Thus, $\langle x_{\widetilde{\pi}_t},\widehat{\theta}_t - \theta_* \rangle \geq -\beta_t(\delta,d) \|x_{\widetilde{\pi}_t}\|_{\Sigma_t^{-1}}$.
{\bf (b)} This is a consequence of Lemma~\ref{lemma:inverse_norm_domination} stated in the paper and proved in Appendix~\ref{subsec:proof-Lemma-inverse-norm-domination}.
{\bf (c)} This is from the definition of $\widetilde{\pi}$ and Eq.~\ref{eq:tempB2}.
{\bf (d)} This is because $\eta_t\in [0,1]$ and from Assumption~\ref{ass:bounded-mean-reward-cost} we have that all expected rewards are positive (belong to $[0,1]$), and thus, $\langle x_0,\theta_* \rangle \geq 0$.
{\bf (e)} This is by lower-bounding $\eta_t$ from~\eqref{eq:tempB3}.
Let us define the shorthand notation $C_1:=\beta_t(\delta,d-1)\|x^{o,\perp}_{\pi_t^*}\|_{(\Sigma^{o,\perp}_t)^{-1}}$. Thus, we may write $C_0$ as
\begin{equation*}
C_0 = \frac{\tau - c_0}{\tau - c_0 + (1+\alpha_c)C_1}\times\big(\langle x_{\pi_t^*},\theta_* \rangle + (\alpha_r-1)C_1\big).
\end{equation*}
Note that $C_0 \geq \langle x_{\pi_t^*}, \theta_* \rangle = r_{\pi^*_t}$ (and as a results $\widetilde{r}_{\pi_t,t}\geq r_{\pi^*_t}$ as desired) iff:
\begin{equation*}
(\tau-c_0) r_{\pi_t^*} + (\tau - c_0) (\alpha_r - 1) C_1 \geq (\tau - c_0) r_{\pi_t^*} + (1 + \alpha_c) C_1 r_{\pi_t^*},
\end{equation*}
which holds iff: $(\tau-c_0)(\alpha_r-1)C_1 \geq (1+\alpha_c)C_1r_{\pi_t^*}$.
Since $r_{\pi_t^*}\leq 1$ from Assumption~\ref{ass:bounded-mean-reward-cost}, this holds iff: $1+\alpha_c \leq (\tau-c_0) (\alpha_r-1)$. This concludes the proof as for both cases of $\pi^*_t\in\Pi_t$ and $\pi^*_t\not\in\Pi_t$, we proved that $\widetilde{r}_{\pi_t,t}\geq r_{\pi_t^*}$.
\end{proof}
\subsection{Learning the safe policy's value}\label{section::safe_policy_value}
In this section we relax Assumption~\ref{ass:safe-action}, and instead assume we only have the knowledge of a safe arm, but not any knowledge of its value $c_0$.
If the cost of the safe arm $c_0$ is unknown, we start by taking the safe action $x_0$ for $T_0$ rounds to produce first an empirical mean estimator for $\hat{c}_9$. Notice that for all $\delta \in (0,1)$, $\hat{c}_0$ satisfies:
\begin{equation}\label{equation::helper_unknown_c0}
\mathbb{P}\left(\hat{c}_0 \leq c_0 - \sqrt{\frac{2 \log\left(1/\delta \right)}{T_0} } \right) \leq \delta
\end{equation}
Let $\tilde{c}_0 = \hat{c}_0 + \sqrt{\frac{2 \log\left(1/\delta \right)}{T_0} } $. By inequality~\ref{equation::helper_unknown_c0}, it follows that with probability at least $1-\delta$:
\begin{equation*}
\tilde{c}_0 \geq c_0
\end{equation*}
We select $T_0$ in an adaptive way. In other words, we do the following:
Let $\delta = \frac{1}{T^2}$. And let $\hat{c}_0(t)$ be the sample mean estimator of $c_0$, when using only $t$ samples. Similarly define $\tilde{c}_0(t) = \hat{c}_0(t) + \sqrt{\frac{2\log(1/\delta)}{t} }$ Let's condition on the event $\mathcal{E}$ that for all $t \in [T]$:
\begin{equation*}
|\hat{c}_0(t) - c_0| \leq \sqrt{\frac{ 2\log(1/\delta)}{t} }
\end{equation*}
By assumption $\mathbb{P}(\mathcal{E}) \geq 1-T2\delta = 1-\frac{2}{T}$. Let $T_0$ be the first time that $\tilde{c}_0(T_0) + 2\sqrt{\frac{ 2\log(1/\delta)}{T_0}} \leq \tau$.
Notice that in this case and conditioned on $\mathcal{E}$ and therefore on $\tilde{c}_0(T_0) \geq c_0$:
\begin{equation*}
\sqrt{ \frac{2 \log(1/\delta)}{T_0}} \leq \frac{\tau - c_0}{2} \quad\text{ i.e. }\quad T_0 \geq \frac{8\log(1/\delta)}{(\tau - c_0)^2}
\end{equation*}
In other words, this test does not stop until $T_0 \geq \frac{8\log(1/\delta)}{(\tau - c_0)^2}$. Now we see it won't take much longer than that to stop:
Conversely, let $T_0' \geq \frac{32\log(1/\delta)}{(\tau- c_0)^2}$. For any such $T_0'$ we observe that by conditioning on $\mathcal{E}$:
\begin{equation*}
\tilde{c}_0(T_0') + 2 \sqrt{\frac{ 2\log(1/\delta)}{T_0'} } \leq c_0 + 4 \sqrt{\frac{ 2\log(1/\delta)}{T_0'} }\leq \tau
\end{equation*}
Thus conditioned on $\mathcal{E}$, we conclude $\frac{8\log(1/\delta)}{(\tau - c_0)^2} \leq T_0 \leq \frac{32\log(1/\delta)}{(\tau- c_0)^2} $. Then,
Therefore $\hat{\delta}_c = \sqrt{ \frac{8 \log(1/\delta)}{T_0}}$ would serve as a conservative estimator for $\frac{\tau - c_0}{2}$ satisfying:
\begin{equation*}
\frac{\tau-c_0}{2} \leq \hat{\delta}_c \leq \tau - c_0
\end{equation*}
We proceed by warm starting our estimators for $\theta_*$ and $\mu_*$ using the data collected by playing $x_0$. However, instead of estimating $\mu_*^{o, \perp}$, we build an estimator for $\mu_*$ over all its directions, including $e_0$, similar to what OPLB does for $\theta_*$. We then set $\frac{\alpha_r}{\alpha_c} = 1/\hat\delta_c$ and run Algorithm~\ref{alg:optimistic-pessimistic-LB} for rounds $t > T_0$. Since the scaling of $\alpha_r$ w.r.t. $\alpha_c$ is optimal up to constants, the same arguments hold.
\section{Supporting Lemmas}
\begin{lemma}\label{lemma::approximation_inverse_prob}
Let $x \in [0,1/2]$, and $\delta \in [-1/4, 1/4]$. Then:
\begin{equation*}
\left| \frac{1/2}{1/2+x+\delta} - \frac{1/2}{1/2+x}\right| \leq 4\delta
\end{equation*}
\end{lemma}
\begin{proof}
Let's start by considering the case when $\delta > 0$. Let $f_x(x) = \frac{1/2}{1/2+x} - \frac{1/2}{1/2+x+\delta} $. Notice that $f_x(x) \geq 0$ for all $x$. This function's derivative satisfies:
\begin{equation*}
\frac{\partial f_x(x)}{\partial x} = \frac{1/2}{(1/2+x+\delta)^2} - \frac{1/2}{(1/2+x)^2}
\end{equation*}
Therefore, and since $\frac{\partial f_x(x)}{\partial x} < 0$ the function $f_x$ is decreasing and therefore the maximizer of $f_x(x)$ for $x \in [0, \frac{1}{2}]$ happens at $x = 0$. In this case:
\begin{align*}
f_x(0) &= 1 - \frac{1/2}{1/2 + \delta} \\
&= 1 - \frac{1}{1 + 2\delta} \\
&= \frac{2\delta }{1+2\delta} \\
&\leq 2\delta
\end{align*}
Now let's consider the case when $\delta < 0$. Let $f_x(x) = \frac{1/2}{1/2+x+\delta} - \frac{1/2}{1/2 + x}$. Notice that $f_x(x) \geq 0$ for all $x$. This function's derivative satisfies:
\begin{equation*}
\frac{ \partial f_x(x)}{\partial x} = \frac{1/2}{(1/2+x)^2} - \frac{1/2}{(1/2+x+\delta)^2}
\end{equation*}
Therefore, and since $\frac{ \partial f_x(x)}{\partial x} < 0$ the function $f_x$ is decreasing and therefore the maximizer of $f_x(x)$ for $x \in [0,\frac{1}{2}]$ happens at $x= 0$. In this case:
\begin{align*}
f_x(0) &= \frac{1/2}{1/2 + \delta} - 1 \\
&= \frac{-\delta}{1/2 + \delta} \\
&\leq -4\delta
\end{align*}
The inequality follows because $1/2+ \delta \geq \frac{1}{4}$. The result follows.
\end{proof}
\section{LP structure}
Recall the optimal policy linear program \ref{eq::no_noise_LP}:
\begin{align*}\label{eq::no_noise_LP_appendix}\tag{P}
&\mathrm{maximize} \sum_{a \in \mathcal{A}} \pi_a \bar{r}_a \\
\text{s.t. } & \sum_{a \in \mathcal{A}} \pi_a \bar{o}_a \geq \tau, \quad \pi \in \mathrm{\Delta}_K\\
\end{align*}
Let $\lambda_1$ and $\lambda_2$ be the two Lagrange associated with the feasibility and the simplex constraints respectively. The lagrangian of \ref{eq::no_noise_LP} takes the form:
\begin{equation*}
L(\pi, \lambda_1, \lambda_2) = \sum_{a} \pi_a \bar{r}_a + \lambda_1\left(\sum_a \pi_a \bar{o}_a \right) + \lambda_2\left( \sum_a \pi_a - 1 \right)
\end{equation*}
Where $\lambda \geq 1$ and $\lambda_2 \in \mathbb{R}$. The dual function equals:
\begin{align*}
g(\lambda_1, \lambda_2) &= \max_{\pi \geq 0} \sum_a \pi_a \bar{r}_a + \lambda_1\left(\sum_a \pi_a \bar{o}_a - \tau \right) + \lambda_2 \left(\sum_a \pi_a - 1 \right) \\
&= \max_{\pi \geq 0} \left( \sum_a \pi_a \left( \bar{r}_a + \lambda_1 \bar{o}_a + \lambda_2 \right) \right)-\tau \lambda_1 -\lambda_2
\end{align*}
If for any $a \in \mathcal{A}$ the expression $\bar{r}_a + \lambda_1 \bar{o}_a + \lambda_2 > 0$, then the expression inside the max will go to infinity. Therefore the dual problem equals:
\begin{align*}\label{eq::no_noise_dual_appendix}\tag{Dual}
&\min -\tau \lambda_1 - \lambda_2 \\
\text{s.t. }& \bar{r}_a + \lambda_1 \bar{o}_a + \lambda_2 \leq 0 \quad \forall a\in\mathcal{A}\\
&\lambda_1 \geq 0, \quad \lambda_2 \in\mathbb{R}
\end{align*}
Alternatively this program can be written as:
\begin{align*}
&-\max \tau\lambda_1 + \lambda_2 \\
\text{s.t.} & \bar{r}_a + \lambda_1 \bar{o}_a + \lambda_2 \leq 0 \quad \forall a \in \mathcal{A}
\end{align*}
Let $(\lambda_1^*, \lambda_2^*)$ be the optimal solutions for this linear program. An easy inspection of the formula above yields the following relationship between $\lambda_1^*$ and $\lambda_2^*$:
\begin{equation*}
\lambda_2^*= \min_a -\bar{r}_a - \bar{o}_a \lambda_1^* = -\max_a (\bar{r}_a + \bar{o}_a \lambda_1^*)
\end{equation*}
This allows us to write the objective function in terms of $\lambda_1$ only. We drop the subscript $1$ for clarity. The objective becomes:
\begin{align*}
-\max_{\lambda \geq 0} \tau \lambda - \max_a (\bar{r}_a + \bar{o}_a \lambda) &= -\max_{\lambda \geq 0} \min_a \left( \lambda(\tau - \bar{o}_a ) - \bar{r}_a \right) \\
&= \min_{\lambda \geq 0} \max_a \left( \lambda(\bar{o}_a - \tau) + \bar{r}_a \right)
\end{align*}
It is easy to see from this equation that the existence of $a^*$ such that $\bar{o}_a \geq \tau$ is a requirement for primal feasibility. This formulation is easily interpretable. We can see that for all $\lambda \geq 0$, the value of $\max_a \lambda(\bar{o}_a - \tau) + \bar{r}_a$ upper bounds the value of any feasible policy.
\subsection{Multiple constraints}
\begin{lemma}\label{lemma::multiple_constraints_support}
The support of a multiple constraint problem equals ...
\end{lemma}
\section{Stability of the optimal solutions}
In this section we explore the stability properties of the optimal solutions of the linear programs \ref{eq::no_noise_LP} and \ref{eq::noisy_LP}. Observe that
\subsection{Bounding the dual variable}
The following LP solves for the $l_1$ norm of $\lambda$:
\begin{align*}
\min \lambda \\
a
\end{align*}
\section{Constrained Multi-Armed Bandits}
\label{section::constrained_multi_armed_bandit_setup}
\section{Experiments}
\label{sec:experiments}
\vspace{-0.1in}
We run a set of experiments to show the behavior of OPB and validate our theoretical results. We consider a $K=4$-armed bandits in which the reward and cost distributions of the arms are Bernoulli with means $\bar r=(.1,.2,.4,.7)$ and $\bar c =(0,.4,.5,.2)$. So, the cost of the safe arm is $\bar c_1=0$. In Figures~\ref{fig:constrained_bandits1} to~\ref{fig:constrained_bandits3}, we gradually reduce the constraint threshold $\tau$, and as a result the complexity of the problem $\tau - \bar{c}_1$, and show the regret {\em (left)} and the cost {\em (middle)} and reward {\em (right)} evolution of OPB. All the results are averaged over $10$ runs and the shade is the $\pm .5$ standard deviation around the regret.
Our results show that the regret of OPB grows as we reduce $\tau$ {\em (left)}. They also indicate that the algorithm is successful in satisfying the constraint {\em (middle)} and reaching the optimal reward/performance {\em (right)}. In Figure~\ref{fig:constrained_bandits3}, the reason that the cost evolution of OPB is the same as that of the optimal policy {\em (middle)} is that in this case, the cost of the best arm (arm $4$) is equal to the constraint threshold $\tau=.2$.
\begin{wrapfigure}{r}{0.625\textwidth}
\vspace{-0.3in}
\begin{minipage}{0.625\textwidth
\centering\subfigure{\includegraphics[width=0.325\linewidth]{figs/constrained_regrets_tau_1.png}}
\centering\subfigure{\includegraphics[width=0.325\linewidth]{figs/cost_evolution_tau_1.png}}
\centering\subfigure{\includegraphics[width=0.325\linewidth]{figs/rewards_evolution_tau_1.png}}
\end{minipage}
\vspace{-4mm}
\caption{{Constraint Threshold $\;\tau = 1$.}}
\vspace{-2mm}
\label{fig:constrained_bandits1}
\begin{minipage}{0.625\textwidth
\centering\subfigure{\includegraphics[width=0.325\linewidth]{figs/constrained_regrets_tau_05.png}}
\centering\subfigure{\includegraphics[width=0.325\linewidth]{figs/cost_evolution_tau_05.png}}
\centering\subfigure{\includegraphics[width=0.325\linewidth]{figs/rewards_evolution_tau_05.png}}
\end{minipage}
\vspace{-4mm}
\caption{{Constraint Threshold $\;\tau = 0.5$.}}
\vspace{-2mm}
\label{fig:constrained_bandits2}
\begin{minipage}{0.625\textwidth
\centering\subfigure{\includegraphics[width=0.325\linewidth]{figs/constrained_regrets_tau_02.png}}
\centering\subfigure{\includegraphics[width=0.325\linewidth]{figs/cost_evolution_tau_02.png}}
\centering\subfigure{\includegraphics[width=0.325\linewidth]{figs/rewards_evolution_tau_02.png}}
\end{minipage}
\vspace{-4mm}
\caption{{Constraint Threshold $\;\tau = 0.2$.}}
\label{fig:constrained_bandits3}
\begin{center}
\begin{minipage}{0.625\textwidth}
\begin{center} \small{ \textbf{OPB.} Bernoulli arms. $\bar{r} = (.1, .2, .4, .7)$, $\bar{c}=(0, .4, .5, .2)$, $\bar{c}_1 = 0$.} \end{center}
\end{minipage}
\end{center}
\vspace{-0.225in}
\end{wrapfigure}
\section{Introduction}
\label{sec:intro}
A {\em multi-armed bandit} (MAB)~\citep{lai85asymptotically,auer02finitetime,lattimore2018bandit} is an online learning problem in which the agent acts by pulling arms. After an arm is pulled, the agent receives its {\em stochastic reward}. The goal of the agent is to maximize its expected cumulative reward without knowledge of the arms' distributions. To achieve this goal, the agent has to balance its {\em exploration} and {\em exploitation}: to decide when to {\em explore} and learn about the arms, and when to {\em exploit} and pull the arm with the highest estimated reward thus far. A \emph{stochastic linear bandit}~\citep{dani08stochastic,rusmevichientong10linearly,abbasi2011improved} is a generalization of MAB to the setting where each of (possibly) infinitely many arms is associated with a feature vector. The mean reward of an arm is the dot product of its feature vector and an unknown parameter vector, which is shared by all the arms. This formulation contains time-varying action (arm) sets and feature vectors, and thus, includes the {\em linear contextual bandit} setting. These models capture many practical applications spanning clinical trials~\citep{Villar15MA}, recommendation systems~\citep{Li10CB,balakrishnan2018using}, wireless networks~\citep{maghsudi2016multi}, sensors~\citep{washburn2008application}, and strategy games \citep{ontanon2013combinatorial}.
The most popular exploration strategies in stochastic bandits are {\em optimism in the face of uncertainty} (OFU)~\citep{auer02finitetime} and {\em Thompson sampling} (TS)~\citep{thompson33likelihood,agrawal13further,russo18tutorial} that are relatively well understood in both multi-armed and linear bandits~\citep{dani08stochastic,abbasi2011improved,agrawal13thompson,lattimore2018bandit}.
In many practical problems, the agent requires to satisfy certain operational constraints while maximizing its cumulative reward. Depending on the form of the constraints, several {\em constrained stochastic bandit} settings have been formulated and analyzed. One such setting is what is known as {\em knapsack bandits}. In this setting, pulling each arm, in addition to producing a reward signal, results in a random consumption of a global budget, and the goal is to maximize the cumulative reward before the budget is fully consumed (e.g.,~\citealt{badanidiyuru2013bandits,badanidiyuru2014resourceful,agrawal2014bandits,wu2015algorithms,agrawal2016linear}). Another such setting is referred to as {\em conservative bandits}. In this setting, there is a baseline arm or policy, and the agent, in addition to maximizing its cumulative reward, should ensure that at each round, the difference between its cumulative reward and that of the baseline remains below a predefined fraction of the baseline cumulative reward~\citep{wu2016conservative,kazerouni2017conservative,Garcelon20IA}. In these two settings, the constraint applies to a cumulative quantity (budget consumption or reward) over the entire run of the algorithm. Thus, the set of feasible actions at each round is a function of the history of the algorithm.
Another constrained bandit setting is where each arm is associated with two (unknown) distributions, generating reward and cost signals. The goal is to maximize the cumulative reward, while making sure that with high probability, the expected cost of the arm pulled at each round is below a certain threshold. Here the constraint is stage-wise, and unlike the last two settings, is independent of the history.~\citet{amani2019linear} and~\citet{Moradipari19SL} have recently studied this setting for linear bandits and derived and analyzed explore-exploit~\citep{amani2019linear} and Thompson sampling~\citep{Moradipari19SL} algorithms for it.
This setting is the closest to the one we study in this paper. In our setting, we also assume two distributions for each arm, one for reward and for cost. At each round the agent constructs a policy according to which it takes its action. The goal of the agent is to produce a sequence of policies with maximum expected cumulative reward, while making sure that the expected cost of the constructed policy (not the pulled arm) at each round is below a certain threshold. This is a linear constraint and can be easily extended to more constraints by having more cost distributions associated to each arm, one per each constraint. Compared to the previous setting, our constraint is more relaxed (from high-probability to expectation), and as a result, it would be possible for us to obtain a solution with larger expected cumulative reward. We will have a detailed discussion on the relationship between these two settings and the similarities and differences of our results with those reported in~\citet{amani2019linear} and~\citet{Moradipari19SL} in Section~\ref{sec:related-work}.
In this paper, we study the above setting for contextual linear bandits. After defining the setting in Section~\ref{sec:setting}, we propose an upper-confidence bound (UCB) algorithm for it, called {\em optimistic pessimistic linear bandit} (OPLB), in Section~\ref{sec:algo}. We prove an $\widetilde{\mathcal{O}}(\frac{d\sqrt{T}}{\tau-c_0})$ bound on the $T$-round regret of OPLB in Section~\ref{section::lin_opt_pess_analysis}, where $d$ is the action dimension and $\tau-c_0$ is the difference between the constraint threshold and the cost of a known feasible action. The action set considered in our contextual linear bandit setting is general enough to include MAB. However, in Section~\ref{sec:constrained-MAB}, we further specialize our results to MAB and propose a computationally efficient algorithm for this setting, called {\em optimistic pessimistic bandit} (OPB). We show that in the MAB case, there always exists a feasible optimal policy with probability mass on at most $m+1$ arms, where $m$ is the number of linear constraints. This property plays an important role in the computational efficiency of OPB. We prove a regret bound of $\widetilde{\mathcal{O}}(\frac{\sqrt{KT}}{\tau - c_0})$ for OPB in $K$-armed bandits, which is a $\sqrt{K}$ improvement over the regret bound we obtain by simply casting MAB as an instance of contextual linear bandit and using the regret bound of OPLB. We also prove a lower-bound for the problem studied in the paper and provide simulations to validate our theoretical results.
\section{Problem Formulation}
\label{sec:setting}
We adopt the following notation. The set $\{1,\ldots,T\}$ is denoted by $[T]$. We represent the set of distributions with support over a compact set $\mathcal S$ by $\Delta_{\mathcal S}$. We denote by $\langle x,y \rangle:=x^\top y\in\mathbb R$, the inner product of two vectors $x,y\in\mathbb R^d$, and by $\|x\|:=\sqrt{x^\top x}$, the $\ell_2$-norm of vector $x$.
The setting we study in this paper is {\em contextual linear bandit} with {\em linear constraints}. In each round $t$, the agent is given an decision set $\mathcal A_t\subset{\mathbb R}^d$ from which it has to choose an action $x_t$. Upon taking action $x_t\in\mathcal A$, it observes a pair $(r_t,c_t)$, where $r_t=\langle x_t,\theta_*\rangle + \xi^r_t$ and $c_t=\langle x_t,\mu_*\rangle + \xi^c_t$ are the reward and cost signals, respectively. In the reward and cost definitions, $\theta_*\in{\mathbb R}^d$ and $\mu_*\in{\mathbb R}^d$ are the unknown {\em reward} and {\em cost parameters}, and $\xi^r_t$ and $\xi^c_t$ are reward and cost noise, satisfying conditions that will be specified soon. The agent selects its action $x_t\in\mathcal A_t$ in each round $t$ according to its policy $\pi_t\in\Delta_{\mathcal A_t}$ at that round, i.e.,~$x_t\sim\pi_t$.
The goal of the agent is to produce a sequence of policies $\{\pi_t\}_{t=1}^T$ with maximum {\em expected cumulative reward} over the course of $T$ rounds, while satisfying the {\bf\em linear constraint}
\begin{equation}
\label{eq:constraint}
\mathbb E_{x\sim\pi_t}[\langle x,\mu_* \rangle]\leq \tau,\quad\forall t\in[T], \qquad (\tau\geq 0 \;\; \text{is referred to as the \em constraint threshold}).
\end{equation}
Thus, the policy $\pi_t$ selected by the agent in each round $t\in [T]$ should belong to the set of {\em feasible policies} over the action set $\mathcal A_t$, i.e.,~$\Pi_t=\{\pi\in\Delta_{\mathcal A_t}:\mathbb E_{x\sim\pi}[\langle x,\mu_* \rangle]\leq \tau\}$. Maximizing the expected cumulative reward in $T$ rounds is equivalent to minimizing the $T$-round {\em constrained pseudo-regret},\footnote{In the rest of the paper, we simply refer to the $T$-round constrained pseudo-regret $\mathcal R_\Pi(T)$ as $T$-round regret.}
\begin{equation}
\label{eq:regret}
\mathcal R_\Pi(T) = \sum_{t=1}^T \mathbb E_{x\sim\pi_t^*}[\langle x,\theta_* \rangle] - E_{x\sim\pi_t}[\langle x,\theta_* \rangle],
\end{equation}
where $\pi_t,\pi^*_t\in\Pi_t\;\forall t\in[T]$ and $\pi^*_t$ is the {\em optimal feasible} policy at round $t$, i.e.,~$\pi^*_t\in\max_{\pi\in\Pi_t}\mathbb E_{x\sim\pi}[\langle x,\theta_* \rangle]$. The terms $\mathbb E_{x\sim\pi}[\langle x,\theta_* \rangle]$ and $\mathbb E_{x\sim\pi}[\langle x,\mu_* \rangle]$ in~\eqref{eq:constraint} and~\eqref{eq:regret} are the expected reward and cost of policy $\pi$, respectively. Thus, a feasible policy is the one whose expected cost is below the constraint threshold $\tau$, and the optimal feasible policy is a feasible policy with maximum expected reward. We use the shorthand notations $x_\pi := \mathbb{E}_{x \sim \pi}[x]$, $r_\pi:=\mathbb E_{x\sim\pi}[\langle x,\theta_* \rangle]$ and $c_\pi:=\mathbb E_{x\sim\pi}[\langle x,\mu_* \rangle]$ for the expected action, reward and cost of a policy $\pi$. With these shorthand notations, we may write the $T$-round pseudo-regret as $\mathcal R_\Pi(T)=\sum_{t=1}^T r_{\pi^*_t} - r_{\pi_t}$.
We make the following assumptions for our setting. The first four assumptions are standard in linear bandits. The fifth one is necessary to guarantee constraint satisfaction ({\em safety}).
\begin{assumption}
\label{ass:noise-sub-gaussian}
For all $t\in[T]$, the reward and cost noise random variables $\xi_t^r$ and $\xi_t^c$ are conditionally $R$-sub-Gaussian, i.e.,
\begin{align*}
&\mathbb{E}[\xi_t^r \mid \mathcal{F}_{t-1}] = 0, \qquad \mathbb{E}[\exp(\alpha \xi_t^r) \mid \mathcal{F}_{t-1}] \leq \exp(\alpha^2 R^2/2),\;\;\;\forall \alpha\in\mathbb R, \\
&\mathbb{E}[\xi_t^c \mid \mathcal{F}_{t-1}] = 0, \qquad \mathbb{E}[\exp(\alpha \xi_t^c) \mid \mathcal{F}_{t-1}] \leq \exp(\alpha^2 R^2/2),\;\;\;\forall \alpha\in\mathbb R,
\end{align*}
where $\mathcal F_t$ is the filtration that includes all the events $(x_{1:t+1},\xi^r_{1:t},\xi^c_{1:t})$ until the end of round $t$.
\end{assumption}
\begin{assumption}
\label{ass:bounded-reward-cost-param}
There is a known constant $S > 0$, such that $\| \theta_*\| \leq S$ and $\| \mu_*\| \leq S$.\footnote{The choice of the same upper-bounds for $\theta_*$ and $\mu_*$ is just for simplicity.}
\end{assumption}
\begin{assumption}
\label{ass:bounded-action}
The $\ell_2$-norm of all actions is bounded, i.e.,~$\max_{t\in[T]}\max_{x \in \mathcal{A}_t}\| x \| \leq L$.
\end{assumption}
\begin{assumption}
\label{ass:bounded-mean-reward-cost}
For all $t\in[T]$ and $x \in \mathcal{A}_t$, the mean rewards and costs are bounded, i.e.,~$\langle x, \theta_* \rangle \in [0,1]$ and $\langle x, \mu_* \rangle \in [0,1]$.
\end{assumption}
\begin{assumption}
\label{ass:safe-action}
There is a known safe action $x_0\in\mathcal A_t,\;\forall t\in[T]$ with known
cost $c_0$, i.e.,~$\langle x_0, \mu_* \rangle = c_0 < \tau$. We will show how the assumption of knowing $c_0$ can be relaxed later in the paper.
\end{assumption}
{\bf Notation:} We conclude this section with introducing another set of notations that will be used in the rest of the paper. We define the normalized safe action as $e_0:=x_0/\|x_0\|$ and the span of the safe action as $\mathcal{V}_o := \mathrm{span}(x_0) =\{\eta x_0 : \eta\in\mathbb R\}$. We denote by $\mathcal{V}_o^{\perp}$, the orthogonal complement of $\mathcal{V}_o$, i.e.,~$\mathcal{V}_o^{\perp}=\{x\in\mathbb R^d : \langle x,y\rangle=0,\;\forall y\in\mathcal{V}_o\}$.\footnote{In the case of $x_0 = \mathbf{0}\in\mathbb R^d$, we define $\mathcal{V}_o$ as the empty subspace and $\mathcal{V}_o^\perp$ as the whole $\mathbb{R}^d$.} We define the projection of a vector $x\in\mathbb R^d$ into the sub-space $\mathcal{V}_o$, as $x^o:=\langle x,e_0\rangle e_0$, and into the sub-space $\mathcal{V}_o^{\perp}$, as $x^{o,\perp} := x - x^o$. We also define the projection of a policy $\pi$ into $\mathcal{V}_o$ and $\mathcal{V}_o^{\perp}$, as $x_{\pi}^o := \mathbb{E}_{x \sim \pi}[x^o]$ and $x_{\pi}^{o, \perp} := \mathbb{E}_{x \sim \pi}[x^{o, \perp}]$.
\section{Optimistic-Pessimistic Linear Bandit Algorithm}
\label{sec:algo}
In this section, we propose an algorithm, called {\em optimistic-pessimistic linear bandit} (OPLB), whose pseudo-code is shown in Algorithm~\ref{alg:optimistic-pessimistic-LB}. Our OPLB algorithm balances a pessimistic assessment of the set of available policies, while acting optimistically within this set. Our principal innovation is the use of confidence intervals with asymmetric radii, proportional to $\alpha_r$ and $\alpha_c$, for the reward and cost signals. This will prove crucial in the regret analysis of the algorithm.
{\centering
\begin{minipage}{.9\linewidth}
\begin{algorithm}[H]
\textbf{Input:} \begin{small}Horizon $T$, Confidence Parameter $\delta$, Regularization Parameter $\lambda$, Constants $\alpha_r, \alpha_c \geq 1$\end{small} \\
\For{$t=1,\ldots,T$}{
1. Compute RLS estimates $\;\widehat{\theta}_t\;$ and $\;\widehat{\mu}_t^{o,\perp}$ \hfill {\em (see Eqs.~\ref{eq:param-est} to~\ref{eq:proj-est})} \\
2. Construct sets $\;\mathcal{C}_t^r(\alpha_r)\;$ and $\;\mathcal{C}_t^c(\alpha_c)$ \hfill {\em (see Eq.~\ref{eq:confidence-ellipsoids})} \\
3. Observe $\;\mathcal{A}_t\;$ and construct the (estimated) safe policy set $\;\Pi_t$ \hfill {\em (see Eq.~\ref{eq:safe-policy-set})} \\
4. Compute policy $\;(\pi_t,\widetilde{\theta}_t) = \argmax_{\pi \in \Pi_t,\;\theta \in \mathcal{C}_t^r(\alpha_r)} \mathbb{E}_{x \sim \pi}[ \langle x, \theta \rangle ]$\\
5. Take action $\;x_t \sim \pi_t\;$ and observe reward and cost $\;(r_t,c_t)$
}
\caption{Optimistic-Pessimistic Linear Bandit (OPLB)}
\label{alg:optimistic-pessimistic-LB}
\end{algorithm}
\end{minipage}
}
{\bf\em Line~1 of OPLB:} At each round $t\in[T]$, given the actions $\{x_s\}_{s=1}^{t-1}$, rewards $\{r_s\}_{s=1}^{t-1}$, and costs $\{c_s\}_{s=1}^{t-1}$ observed until the end of round $t-1$, OPLB first computes the $\ell_2$-regularized least-squares (RLS) estimates of $\theta_*$ and $\mu_*^{o,\perp}$ (projection of the cost parameter $\mu_*$ into the sub-space $\mathcal V_o^\perp$) as
\vspace{-0.15in}
\begin{small}
\begin{equation}
\label{eq:param-est}
\widehat{\theta}_t = \Sigma_t^{-1} \sum_{s=1}^{t-1}r_sx_s, \qquad\quad \widehat{\mu}_t^{o,\perp} = (\Sigma_t^{o,\perp})^{-1}\sum_{s=1}^{t-1}c_s^{o,\perp}x_s^{o,\perp},
\end{equation}
\end{small}
\vspace{-0.15in}
where $\lambda>0$ is the regularization parameter, and
\vspace{-0.15in}
\begin{small}
\begin{align}
\label{eq:Sigmas}
&\Sigma_t = \lambda I + \sum_{s=1}^{t-1}x_sx_s^\top, \qquad\quad \Sigma_t^{o,\perp} = \lambda I_{\mathcal V_o^\perp} + \sum_{s=1}^{t-1}x_s^{o,\perp}(x_s^{o,\perp})^\top, \\
&c^{o,\perp}_t = c_t - \frac{\langle x_t,e_0\rangle}{\|x_0\|}c_0, \qquad\quad I_{\mathcal V_o^\perp} = I_{d\times d} - \frac{1}{\|x_0\|^2}x_0x_0^\top.
\label{eq:proj-est}
\end{align}
\end{small}
\vspace{-0.15in}
In~\eqref{eq:Sigmas}, $\Sigma_t$ and $\Sigma_t^{o,\perp}$ are the Gram matrices of actions and projection of actions into the sub-space $\mathcal V_o^\perp$. Note that $\Sigma_t^{o, \perp}$ is a rank deficient matrix, but with abuse of notation, we use $(\Sigma_t^{o, \perp})^{-1}$ to denote its pseudo-inverse throughout the paper. In~\eqref{eq:proj-est}, $I_{\mathcal V_o^\perp}$ is the projection of the identity matrix, $I$, into $\mathcal V_o^\perp$, and $c^{o,\perp}_t$ is the noisy projection of the cost $c_t$ incurred by taking action $x_t$ into $\mathcal V_o^\perp$, i.e.,\footnote{In the derivation of~\eqref{eq:c-tilde-derivation}, we use the fact that $\langle x_t,\mu_*\rangle = \langle x_t^o+x_t^{o,\perp},\mu_*^o+\mu_*^{o,\perp}\rangle = \langle x_t^o,\mu_*^o\rangle + \langle x_t^{o,\perp},\mu_*^{o,\perp}\rangle$.}
\vspace{-0.15in}
\begin{small}
\begin{equation}
\label{eq:c-tilde-derivation}
c^{o,\perp}_t = \langle x_t^{o,\perp},\mu_*^{o,\perp}\rangle + \xi_t^c = \langle x_t,\mu_* \rangle - \langle x_t^o,\mu_*^o \rangle + \xi_t^c = c_t - \langle x_t^o,\mu_*^o \rangle = c_t - \frac{\langle x_t,e_0\rangle}{\|x_0\|}c_0.
\end{equation}
\end{small}
\vspace{-0.125in}
{\bf\em Line~2:} Using the RLS estimates $\widehat{\theta}_t$ and $\widehat{\mu}_t^{o,\perp}$ in~\eqref{eq:param-est}, OPLB constructs the two {\em confidence sets}
\vspace{-0.15in}
\begin{small}
\begin{equation}
\label{eq:confidence-ellipsoids}
\mathcal{C}_t^r(\alpha_r) = \big\{\theta \in \mathbb{R}^d: \|\theta -\widehat{\theta}_t\|_{\Sigma_t} \leq \alpha_r \beta_t(\delta, d)\big\}, \quad \mathcal{C}_t^c(\alpha_c) = \big\{ \mu \in \mathcal{V}_o^{\perp} : \| \mu - \widehat{\mu}^{o, \perp}_t\|_{\Sigma_t^{o,\perp}} \leq \alpha_c \beta_t(\delta, d-1)\big\},
\end{equation}
\end{small}
\vspace{-0.15in}
where $\alpha_r,\alpha_c\geq 1$ and $\beta_t(\delta,d)$ in the radii of these {\em confidence ellipsoids} is defined by the following theorem, originally proved in~\cite{abbasi2011improved}.
\begin{theorem}\label{theorem::yasin_theorem}[Thm.~2 in~\citealt{abbasi2011improved}]
Let Assumptions~\ref{ass:noise-sub-gaussian} and~\ref{ass:bounded-reward-cost-param} hold, $\widehat{\theta}_t$, $\widehat{\mu}_t^{o,\perp}$, $\Sigma_t$, and $\Sigma_t^{o,\perp}$ defined by~\eqref{eq:param-est} and~\eqref{eq:Sigmas}, and $\mathcal{C}_t^r(\cdot)$ and $\mathcal{C}_t^c(\cdot)$ defined by~\eqref{eq:confidence-ellipsoids}. Then, for a fixed $\delta \in (0,1)$ and
\vspace{-0.1in}
\begin{small}
\begin{equation}
\label{eq:ellipsoid-radius}
\beta_t(\delta,d) = R \sqrt{d\log\Big(\frac{1 + (t-1)L^2/\lambda}{\delta}\Big)} + \sqrt{\lambda}\;S,
\end{equation}
\end{small}
\vspace{-0.125in}
with probability at least $1-\delta$ and for all $t \geq 1$, it holds that $\theta_*\in\mathcal{C}_t^r(1)$ and $\mu_*^{o,\perp}\in\mathcal{C}_t^c(1)$.
\end{theorem}
Since $\alpha_r,\alpha_c\geq 1$, for all rounds $t\in[T]$, the sets $\mathcal{C}_t^r(\alpha_r)$ and $\mathcal{C}_t^c(\alpha_c)$ also contain $\theta_*$, the reward parameter, and $\mu_*^{o,\perp}$, the projection of the cost parameter into $\mathcal V_o^\perp$, respectively, with high probability.
Given these confidence sets, we define the {\em optimistic reward} and {\em pessimistic cost} of any policy $\pi$ in round $t$ as
\vspace{-0.225in}
\begin{small}
\begin{equation}
\label{eq:max-reward-cost}
\widetilde{r}_{\pi,t} := \max_{\theta\in\mathcal{C}_t^r(\alpha_r)} \mathbb{E}_{x \sim \pi}[\langle x,\theta\rangle], \qquad\qquad
\widetilde{c}_{\pi,t} := \frac{\langle x_{\pi}^o,e_0 \rangle c_0}{\| x_0 \|} + \max_{\mu\in\mathcal{C}_t^c(\alpha_c)} \mathbb{E}_{x\sim\pi}[\langle x,\mu \rangle].
\end{equation}
\end{small}
\vspace{-0.075in}
\begin{proposition}
\label{prop:optimistic-reward-pessimistic-cost}
We may write~\eqref{eq:max-reward-cost} in closed-form as \hfill {\em (proof in Appendix~\ref{subsec:proof-prop-optimistic-reward})}
\vspace{-0.15in}
\begin{small}
\begin{align}
\label{eq:optimistic-reward-closed-form}
\widetilde{r}_{\pi,t} &= \langle x_\pi,\widehat{\theta}_t \rangle + \alpha_r \beta_t(\delta,d) \| x_\pi\|_{\Sigma_t^{-1}}, \\ \widetilde{c}_{\pi,t} &= \frac{\langle x_\pi^o, e_0\rangle c_0 }{\|x_0\|} + \langle x_\pi^{o, \perp}, \widehat{\mu}^{o, \perp}_t \rangle + \alpha_c \beta_t(\delta,d-1) \| x_{\pi}^{o, \perp}\|_{(\Sigma_t^{o, \perp})^{-1}}.
\label{eq:pessimistic-cost-closed-form}
\end{align}
\end{small}
\vspace{-0.15in}
\end{proposition}
{\bf\em Line~3:} After observing the action set $\mathcal A_t$, OPLB constructs its (estimated) feasible (safe) policy set
\vspace{-0.15in}
\begin{small}
\begin{equation}
\label{eq:safe-policy-set}
\Pi_t = \{\pi \in \Delta_{\mathcal A_t} : \widetilde{c}_{\pi,t} \leq \tau\},
\end{equation}
\end{small}
\vspace{-0.175in}
where $\widetilde{c}_{\pi,t}$ is the pessimistic cost of policy $\pi$ in round $t$ defined by~\eqref{eq:pessimistic-cost-closed-form}. Note that $\Pi_t$ is not empty since $\pi_0$, the policy that plays the safe action $x_0$ with probability (w.p.)~$1$, is always in $\Pi_t$. This is because $x_{\pi_0}^o = x_0$, $x_{\pi_0}^{o,\perp} =0$, and $\frac{\langle x_{\pi_0}^o, e_0\rangle c_0}{\| x_0 \|} = c_0$. In the following proposition, whose proof is reported in Appendix~\ref{subsec:proof-safe-set}, we prove that all policies in $\Pi_t$ are feasible with high probability.
\begin{proposition}
\label{prop:safe-set}
With probability at least $1-\delta$, for all rounds $t\in[T]$, all policies in $\Pi_t$ are feasible.
\end{proposition}
{\bf\em Line~4:} The agent computes its policy, $\pi_t$, as the one that is safe (belongs to $\Pi_t$) and attains the maximum optimistic reward. We refer to $\widetilde{\theta}_t$ as the {\em optimistic reward parameter}. Thus, we write the optimistic reward of policy $\pi_t$ as $\widetilde{r}_{\pi_t,t} = \langle x_{\pi_t},\widetilde{\theta}_t \rangle$.
{\bf\em Line~5:} Finally, the agent selects an action $x_t\sim\pi_t$ and observes the reward-cost pair $(r_t,c_t)$.
{\bf Computational Complexity of OPLB.} $\;$ As shown in Line~4 of Algorithm~\ref{alg:optimistic-pessimistic-LB} and in Proposition~\ref{prop:optimistic-reward-pessimistic-cost}, in each round $t$, OPLB solves the following optimization problem:
\vspace{-0.15in}
\begin{small}
\begin{align}
\label{equation::opt_problem_linear}
\max_{\pi \in \Delta_{\mathcal{A}_t}}& \langle x_\pi, \widehat{\theta}_t \rangle + \alpha_r \beta_t(\delta,d) \| x_\pi\|_{\Sigma_t^{-1}} \\
\text{s.t. }& \frac{\langle x_\pi^o, e_0\rangle c_0 }{\|x_0\|} + \langle x_\pi^{o, \perp}, \widehat{\mu}^{o, \perp}_t \rangle + \alpha_c \beta_t(\delta,d-1) \| x_{\pi}^{o, \perp}\|_{(\Sigma_t^{o, \perp})^{-1}} \leq \tau. \nonumber
\end{align}
\end{small}
\vspace{-0.15in}
However, solving~\eqref{equation::opt_problem_linear} can be challenging. The bottleneck is computing the safe policy set $\Pi_t$, which is the intersection between $\Delta_{\mathcal{A}_t}$ and the ellipsoidal constraint.
\begin{remark}
The main challenge in obtaining a regret bound for OPLB is to ensure that optimism holds in each round $t$, i.e.,~the solution $(\pi_t,\widetilde\theta_t)$ of~\eqref{equation::opt_problem_linear} satisfy $\widetilde{r}_{\pi_t,t} = \langle x_{\pi_t},\widetilde\theta_t \rangle \geq r_{\pi^*_t}$. This is not obvious, since the (estimated) safe policy set $\Pi_t$ may not contain the optimal policy $\pi_t^*$. Our main algorithmic innovation is the use of asymmetric confidence intervals $\mathcal{C}_t^r(\alpha_r)$ and $\mathcal{C}_t^c(\alpha_c)$ for $\theta_*$ and $\mu^{o, \perp}_*$, which allows us to guarantee optimism, by appropriately selecting the ratio $\gamma = \alpha_r/\alpha_c$. Of course, this comes at the cost of scaling the regret by a factor $\gamma$. As it will be shown in our analysis in Section~\ref{section::lin_opt_pess_analysis}, $\gamma$ depends on the inverse gap $1/(\tau-c_0)$, which indicates when $\tau - c_0$ is small (the cost of the safe arm is close to the constraint threshold), the agent will have a difficult time to identify a safe arm and to compete against the optimal feasible policy $\pi_t^*$. We will formalize this in Lemma \ref{lemma:linear_bandits_optimism}.
\end{remark}
\begin{remark
If the cost of the safe arm $c_0$ is unknown, we start by taking the safe action $x_0$ for $T_0$ rounds to produce a conservative estimate $\hat\delta_c$ of $\tau - c_0$ that satisfies $\hat\delta_c \geq \frac{\tau - c_0}{2}$. We warm start our estimators for $\theta_*$ and $\mu_*$ using the data collected by playing $x_0$. However, instead of estimating $\mu_*^{o, \perp}$, we build an estimator for $\mu_*$ over all its directions, including $e_0$, similar to what OPLB does for $\theta_*$. We then set $\frac{\alpha_r}{\alpha_c} = 1/\hat\delta_c$ and run Algorithm~\ref{alg:optimistic-pessimistic-LB} for rounds $t > T_0$ (see Appendix~\ref{section::safe_policy_value} for more details).
\end{remark}
\section{Regret Analysis}
\label{section::lin_opt_pess_analysis}
In this section, we prove the following regret bound for OPLB (Algorithm~\ref{alg:optimistic-pessimistic-LB}).
\begin{theorem}[Regret of OPLB]
\label{theorem::main_theorem_linear}
Let $\alpha_c = 1$ and $\alpha_r = \frac{ 2+\tau-c_0}{\tau-c_0}$. Then, with probability at least $1-2\delta$, the regret of OPLB satisfies
\vspace{-0.15in}
\begin{small}
\begin{equation}
\label{eq:regret-OPLB}
\mathcal{R}_{\Pi}(T) \leq \frac{2L(\alpha_r+1)\beta_T(\delta, d)}{\sqrt{\lambda}}\sqrt{2T\log(1/\delta)} + (\alpha_r+1)\beta_T(\delta, d)\sqrt{2Td\log(1+\frac{TL^2}{\lambda})}.
\end{equation}
\end{small}
\vspace{-0.15in}
\end{theorem}
We start the proof of Theorem~\ref{theorem::main_theorem_linear}, by defining the following event that holds w.p.~at least $1-\delta$:
\vspace{-0.125in}
\begin{small}
\begin{equation}
\label{eq:high-prob-event}
\mathcal{E} := \big\{\|\widehat{\theta}_t - \theta_*\|_{\Sigma_t} \leq \beta_t(\delta, d) \; \wedge \; \|\widehat{\mu}_t^{o, \perp} - \mu_*^{o, \perp}\|_{\Sigma_t^{o,\perp}} \leq \beta_t(\delta, d-1), \; \forall t\in[T]\big\}.
\end{equation}
\end{small}
\vspace{-0.15in}
The regret $\mathcal{R}_{\Pi}(T)$ in~\eqref{eq:regret} can be decomposed as ($\widetilde{r}_{\pi_t,t}$ is the optimistic reward defined by Eq.~\ref{eq:max-reward-cost})
\vspace{-0.15in}
\begin{small}
\begin{equation}
\label{eq:regret-decomp}
\mathcal{R}_{\Pi}(T) = \underbrace{\sum_{t=1}^T r_{\pi_t^*} - \widetilde{r}_{\pi_t,t}}_{(\mathrm{I})} \; + \; \underbrace{\sum_{t=1}^T \widetilde{r}_{\pi_t,t} - r_{\pi_t}}_{(\mathrm{II})}.
\end{equation}
\end{small}
\vspace{-0.125in}
We first bound the term $(\mathrm{II})$ in~\eqref{eq:regret-decomp}. To bound $(\mathrm{II})$, we further decompose it as
\vspace{-0.15in}
\begin{small}
\begin{equation}
\label{eq:II-decomp}
(\mathrm{II}) = \underbrace{\sum_{t=1}^T \langle x_{\pi_t}, \widetilde{\theta}_t \rangle - \langle x_t, \widetilde{\theta}_t \rangle}_{(\mathrm{III})} + \underbrace{\sum_{t=1}^T \langle x_t, \widetilde{\theta}_t \rangle - \langle x_t, \theta_* \rangle}_{(\mathrm{IV})} + \underbrace{\sum_{t=1}^T \langle x_t, \theta_* \rangle - \langle x_{\pi_t}, \theta_* \rangle }_{(\mathrm{V})}.
\end{equation}
\end{small}
\vspace{-0.125in}
In the following lemmas, we first bound the sum of $(\mathrm{III})$ and $(\mathrm{V})$ terms, and then bound $(\mathrm{IV})$.
\begin{lemma}
\label{lemma:bounding-3+5}
On the event $\mathcal{E}$ defined by~\eqref{eq:high-prob-event}, for any $\gamma \in (0, 1)$, w.p.~at least $1-\gamma$, we have
\vspace{-0.125in}
\begin{small}
\begin{equation*}
(\mathrm{III}) + (\mathrm{V}) \leq \frac{2L(\alpha_r + 1)\beta_T(\delta, d)}{\sqrt{\lambda}}\cdot\sqrt{2 T \log(1/\gamma)}\;.
\end{equation*}
\end{small}
\end{lemma}
\vspace{-0.175in}
\begin{proof}
We write $(\mathrm{III}) + (\mathrm{V}) = \sum_{t=1}^T \langle x_{\pi_t} - x_t, \widetilde{\theta}_t - \theta_* \rangle$. By Cauchy-Schwartz, we have $|\langle x_{\pi_t} - x_t, \widetilde{\theta}_t - \theta_* \rangle | \leq \| x_{\pi_t} - x_t \|_{\Sigma^{-1}_t} \| \widetilde{\theta}_t - \theta_*\|_{\Sigma_t}$. Since $\widetilde{\theta}_t\in \mathcal{C}_t^r(\alpha_r)$, on event $\mathcal E$, we have $\|\widetilde{\theta}_t - \theta_*\|_{\Sigma_t} \leq (\alpha_r+1) \beta_t(\delta, d)$. Also from the definition of $\Sigma_t$, we have $\Sigma_t \succeq \lambda I$, and thus, $\| x_{\pi_t} - x_t \|_{\Sigma^{-1}_t} \leq \| x_{\pi_t} - x_t\|/\sqrt{\lambda} \leq 2L/\sqrt{\lambda}$. Therefore, $Y_t =\sum_{s=1}^t \langle x_{\pi_s} - x_s, \widetilde{\theta}_s - \theta_* \rangle$ is a martingale sequence with $|Y_t - Y_{t-1}| \leq 2L(\alpha_r + 1)\beta_t(\delta, d)/\sqrt{\lambda}$, for $t\in [T]$. By the Azuma–Hoeffding inequality and since $\beta_t$ is an increasing function of $t$, i.e.,~$\beta_t(\delta, d) \leq \beta_T(\delta, d),\;\forall t\in[T]$, w.p.~at least $1-\gamma$, we have $\mathbb{P}\big(Y_T \geq 2L(\alpha_r + 1) \beta_T(\delta, d)\sqrt{2T \log(1/\gamma)/\lambda}\big) \leq \gamma$, which concludes the proof.
\end{proof}
\begin{lemma}
\label{lemma:bounding-4}
On event $\mathcal{E}$, we have $(\mathrm{IV}) \leq (\alpha_r+1) \beta_T(\delta,d)\sqrt{2Td\log\big(1+\frac{TL^2}{\lambda}\big)}$. \end{lemma}
We report the proof of Lemma~\ref{lemma:bounding-4} in Appendix~\ref{subsec:proof-Lemma-bounding-4}. After bounding all the terms in $(\mathrm{II})$, we now process the term $(\mathrm{I})$ in~\eqref{eq:regret-decomp}. Before stating the main result for this term in Lemma~\ref{lemma:linear_bandits_optimism}, we need to prove the following lemma (proof in Appendix~\ref{subsec:proof-Lemma-inverse-norm-domination}).
\begin{lemma}
\label{lemma:inverse_norm_domination}
For any policy $\pi$, the following inequality holds:
\vspace{-0.125in}
\begin{small}
\begin{equation}
\label{equation::comparison_conf_bounds}
\| x_\pi^{o, \perp}\|_{(\Sigma_t^{o,\perp})^{-1}} \leq \| x_\pi \|_{\Sigma_t^{-1}}.
\end{equation}
\end{small}
\end{lemma}
In the following lemma, we prove that by appropriately setting the parameters $\alpha_r$ and $\alpha_c$, we can guarantee that at each round $t\in[T]$, OPLB selects an optimistic policy, i.e.,~a policy $\pi_t$, whose optimistic reward, $\widetilde{r}_{\pi_t,t}$, is larger than the reward of the optimal policy $r_{\pi^*_t}$, given the event $\mathcal E$. This means that with our choice of parameters $\alpha_r$ and $\alpha_c$, the term $(\mathrm{I})$ in~\eqref{eq:regret-decomp} is always non-positive.
\begin{lemma}
\label{lemma:linear_bandits_optimism}
On the event $\mathcal{E}$, if we set $\alpha_r$ and $\alpha_c$, such that $\alpha_r,\alpha_c\geq 1$ and $1+\alpha_c \leq (\tau-c_0) (\alpha_r-1)$, then for any $t\in[T]$, we have $\widetilde{r}_{\pi_t,t} \geq r_{\pi_t^*}$.
\end{lemma}
Here we provide a proof sketch for Lemma~\ref{lemma:linear_bandits_optimism}. The detailed proof is reported in Appendix~\ref{subsec:proof-Lemma-term-I}.
\begin{proof}[Proof Sketch]
We divide the proof into two cases, depending on whether in each round $t$, the optimal policy $\pi^*_t$ belongs to the (estimated) set of feasible policies $\Pi_t$, or not.
{\bf Case~yes
1.} $\;$ If $\pi_t^*\in\Pi_t$, then its optimistic reward is less than that of the policy $\pi_t$ selected at round $t$ (by the definition of $\pi_t$ on Line~4 of Algorithm~\ref{alg:optimistic-pessimistic-LB}), i.e.,~$\widetilde{r}_{\pi_t^*,t}\leq\widetilde{r}_{\pi_t,t}$. This together with the fact that the optimistic reward of any policy $\pi$ is larger than its expected reward, i.e.,~$\widetilde{r}_{\pi,t}\geq r_\pi$, gives us the desired result that $\widetilde{r}_{\pi_t,t}\geq r_{\pi^*_t}$.
{\bf Case~2.} $\;$ If $\pi_t^*\not\in\Pi_t$, then we define a mixture policy $\widetilde{\pi}_t=\eta_t\pi_t^*+(1-\eta_t)\pi_0$, where $\pi_0$ is the policy that always selects the safe action $x_0$ and $\eta_t\in[0,1]$ is the maximum value of $\eta$ for which the mixture policy belongs to the set of feasible actions, i.e.,~$\widetilde{\pi}_t\in\Pi_t$. Conceptually, we can think of $\eta_t$ as a measure for safety of the optimal policy $\pi_t^*$. Mathematically, $\eta_t$ is the value at which the pessimistic cost of the mixture policy equals to the constraint threshold, i.e.,~$\widetilde{c}_{\widetilde{\pi}_t,t} =\tau$. In the rest of the proof, we first write $\widetilde{c}_{\widetilde{\pi}_t,t}$ in terms of the pessimistic cost of the optimal policy as $\widetilde{c}_{\widetilde{\pi}_t,t}=(1-\eta_t)c_0+\eta_t\widetilde{c}_{\pi^*_t,t}$ ($c_0$ is the expected cost of the safe action $x_0$), and find a lower-bound for $\eta_t$ (see Eq.~\ref{eq:tempB3} in Appendix~\ref{subsec:proof-Lemma-term-I}). We then use the fact that since $\widetilde{\pi}_t\in\Pi_t$, its optimistic reward is less than that of $\pi_t$, i.e.,~$\widetilde{r}_{\pi_t,t}\geq \widetilde{r}_{\widetilde{\pi}_t,t}$, and obtain a lower-bound for $\widetilde{r}_{\widetilde{\pi}_t,t}$ as a function of $r_{\pi_t^*}$ (see Eq.~\ref{eq:tempB4} in Appendix~\ref{subsec:proof-Lemma-term-I}). Finally, we conclude the proof by using this lower-bound and finding the relationship between the parameters $\alpha_r$ and $\alpha_c$ for which the desired result $\widetilde{r}_{\pi_t,t}\geq r_{\pi_t^*}$ is obtained, i.e.,~$1+\alpha_c\leq (\tau-c_0)(\alpha_r-1)$.
\end{proof}
\begin{proof}[Proof of Theorem~\ref{theorem::main_theorem_linear}]
The proof follows from the fact that the term $(\mathrm{I})$ is negative (Lemma~\ref{lemma:linear_bandits_optimism}), and by combining the upper-bounds on the term $(\mathrm{II})$ from Lemmas~\ref{lemma:bounding-3+5} and~\ref{lemma:bounding-4}, and setting $\gamma = \delta$.
\end{proof}
\section{Constrained Multi-Armed Bandits}
\label{sec:constrained-MAB}
In this section, we specialize our results for contextual linear bandits to multi-armed bandits (MAB) and show that the structure of the MAB problem allows a computationally efficient implementation of the algorithm and an improvement in the regret bound.
In the MAB setting, the action set consists of $K$ arms $\mathcal{A}=\{1,\ldots,K\}$. Each arm $a\in [K]$ has a reward and a cost distribution with means $\bar{r}_a,\bar{c}_a\in [0,1]$. In each round $t\in[T]$, the agent constructs a policy $\pi_t$ over $\mathcal A$, pulls an arm $a_t\sim\pi_t$, and observes a reward-cost pair $(r_{a_t},c_{a_t})$ sampled i.i.d.~from the reward and cost distributions of arm $a_t$. Similar to the constrained contextual linear case, the goal of the agent is to produce a sequence of policies $\{\pi_t\}_{t=1}^T$ with maximum expected cumulative reward over $T$ rounds, i.e.,~$\sum_{t=1}^T\mathbb E_{a_t\sim\pi_t}[\bar{r}_{a_t}]$, while satisfying the {\bf\em linear constraint} $\mathbb E_{a_t\sim\pi_t}[\bar{c}_{a_t}] \leq \tau,\;\forall t\in[T]$. Moreover, arm $1$ is assumed to be the known safe arm, i.e.,~$\bar{c}_1 \leq \tau$.
{\bf Optimistic Pessimistic Bandit (OPB) Algorithm.} $\;$ Let $\{T_a(t)\}_{a=1}^K$ and $\{\widehat{r}_a(t),\widehat{c}_a(t)\}_{a=1}^K$ be the total number of times that arm $a$ has been pulled and the estimated mean reward and cost of arm $a$ up until round $t$. In each round $t\in[T]$, OPB relies on the high-probability upper-bounds on the mean reward and cost of the arms, i.e.,~$\{u_a^r(t),u_a^c(t)\}_{a=1}^K$, where $u_a^r(t) = \widehat{r}_a(t) + \alpha_r\beta_a(t)$, $u_a^c(t) = \widehat{c}_a(t) + \alpha_c\beta_a(t)$, $\beta_a(t) = \sqrt{2\log(1/\delta')/T_a(t)}$, and constants $\alpha_r,\alpha_c\geq 1$. In order to produce a feasible policy, OPB solves the following linear program (LP) in each round $t\in[T]$:
\vspace{-0.125in}
\begin{small}
\begin{equation}
\label{eq::noisy_LP}
\max_{\pi\in\Delta_K} \; \sum_{a\in\mathcal{A}}\pi_a \; u^r_a(t), \qquad\quad \text{s.t.} \; \sum_{a\in\mathcal{A}}\pi_a \; u_a^c(t) \leq \tau.
\end{equation}
\end{small}
\vspace{-0.125in}
As shown in~\eqref{eq::noisy_LP}, OPB selects its policy by being optimistic about reward (using an upper-bound for $r$) and pessimistic about cost (using an upper-bound for $c$). We report the details of OPB and its pseudo-code (Algorithm~\ref{alg::optimism_pessimism}) in Appendix~\ref{section::appendix_MAB_optimism_pessimism_algorithm}.
{\bf Computational Complexity of OPB.} $\;$ Unlike OPLB, whose optimization problem might be complex, OPB can be implemented extremely efficiently. Lemma~\ref{lemma::LP_support}, whose proof we report in Appendix~\ref{section::LP_structure_appendix}, show that~\eqref{eq::noisy_LP} always has a solution (policy) with support of at most $2$. This property allows us to solve~\eqref{eq::noisy_LP} in closed form, without a LP solver, and implement OPB quite efficiently.
\begin{lemma
\label{lemma::LP_support}
There exists a policy that solves~\eqref{eq::noisy_LP} and has at most $2$ non-zero entries.
\end{lemma}
{\bf Regret Analysis of OPB.} $\;$ We prove the following regret-bound for OPB in Appendix~\ref{section:regret_analysis_appendix}.
\begin{theorem}[Regret of OPB]
\label{theorem::contrained_MAB}
Let $\delta = 4KT\delta'$, $\alpha_c=1$, and $\alpha_r = 1+2/(\tau-\bar{c}_1)$. Then, with probability at least $1-\delta$, the regret of OPB satisfies
\vspace{-0.15in}
\begin{small}
\begin{equation*}
\mathcal{R}_\Pi(T) \leq \big(1 + \frac{2}{\tau-\bar{c}_1}\big) \times \big(2\sqrt{2KT\log(4KT/\delta)} + 4\sqrt{T\log(2/\delta)\log(4KT/\delta)}\big).
\end{equation*}
\end{small}
\vspace{-0.15in}
\end{theorem}
The main component in the proof of Theorem~\ref{theorem::contrained_MAB} is the following lemma, whose proof is reported in Appendix~\ref{section:regret_analysis_appendix}. This lemma is the analogous to Lemma~\ref{lemma:linear_bandits_optimism} in the contextual linear bandit case.
\begin{lemma}
\label{lemma::optimism}
If we set the parameters $\alpha_r$ and $\alpha_c$, such that $\alpha_r,\alpha_c\geq 1$ and $\alpha_c \leq (\tau-\bar{c}_1)(\alpha_r-1)$, then with high probability, for any $t\in[T]$, we have $\mathbb{E}_{a \sim \pi_t}\left[u_a^r(t)\right] \geq \mathbb{E}_{a \sim \pi^*}\left[\bar{r}_a \right]$.
\end{lemma}
Our contextual linear bandit formulation is general enough to include MAB. The regret analysis of OPLB (Theorem~\ref{theorem::main_theorem_linear}) yields a regret bound of order $\widetilde{\mathcal O}(\frac{K\sqrt{T}}{\tau-\bar{c}_1})$ for MAB. However, our OPB regret bound in Theorem~\ref{theorem::contrained_MAB} is of order $\widetilde{\mathcal O}(\frac{\sqrt{KT}}{\tau-\bar{c}_1})$, which shows a $\sqrt{K}$ improvement over simply casting MAB as an instance of contextual linear bandit and using the regret bound of OPLB.
{\bf Extension to $m$ Constraints.} $\;$ In this case, the agent receives $m$ cost signals after pulling each arm. The cost vector of the safe arm $\boldsymbol{c}_1$ satisfies $\boldsymbol{c}_1(i)<\tau_i,\forall i\in[m]$, where $\{\tau_i\}_{i=1}^m$ are the constraint thresholds. Similar to single-constraint OPB, multi-constraint OPB is also computationally efficient. The main reason is that the LP of $m$-constraint OPB has a solution with at most $m+1$ non-zero entries. We obtain a regret bound of $\widetilde{\mathcal{O}}(\frac{\sqrt{KT }}{ \min_i \tau_i - \boldsymbol{c}_1(i)})$ for $m$-constraint OPB in Appendix~\ref{section::multiple_constraints_appendix}.
{\bf Lower-bound.} $\;$ We also prove a mini-max lower-bound for this constrained MAB problem that shows no algorithm can attain a regret better than $\mathcal{O}(\max(\sqrt{KT}, \frac{1}{(\tau - \bar{c}_1)^2} ) )$. The formal statement of the lower-bound and the proof are reported in Appendix~\ref{section::lower_bound_MAB_appendix}.
\section*{Broader Impact}
\subsection{Optimism Pessimism}\label{section::appendix_MAB_optimism_pessimism_algorithm}
Here we reproduce the full pseudo-code for OPB:
{\centering
\begin{minipage}{.9\linewidth}
\begin{algorithm}[H]
\textbf{Input:} Number of arms $K$, constants $\alpha_r, \alpha_c \geq 1$. \\
\For{$t=1, \ldots , T$}{
1. Compute estimates $\{u_a^r(t) \}_{a\in\mathcal A}$, $\{u_a^c(t) \}_{a\in\mathcal A}$. \\
2. Form the approximate LP (\ref{eq::noisy_LP}) using these estimates.\\
3. Find policy $\pi_t$ by solving~\eqref{eq::noisy_LP}.\\
4. Play arm $a \sim \pi_t$ \; \\%}
}
\caption{Optimism-Pessimism}
\label{alg::optimism_pessimism}
\end{algorithm}
\end{minipage}
}
Similar to the case of OPLB, we define $\Pi_t = \{ \pi \in \Delta_{\mathcal{A}} : \sum_{a \in \mathcal{A}} \pi_a u_a^c(t) \leq \tau \}$. We also define $\beta_a(0) = 0$ for all $a\in \mathcal{A}$.
\section{Related Work}
\label{sec:related-work}
\vspace{-0.1in}
As described in Section~\ref{sec:intro}, our setting is the closest to the one studied by~\cite{amani2019linear} and~\cite{Moradipari19SL}. They study a slightly different setting, in which the mean cost of the action that the agent takes should satisfy the constraint, i.e.,~$\langle x_t,\mu_*\rangle \leq \tau$, not the mean cost of the policy it computes, i.e.,~$\langle x_{\pi_t},\mu_*\rangle \leq \tau$, as in our case. Clearly, the setting studied in our paper is more relaxed, and thus, is expected to obtain more rewards.~\cite{Moradipari19SL} propose a TS algorithm for their setting and prove an $\widetilde{O}(d^{3/2}\sqrt{T}/\tau)$ regret bound for it. They restrict themselves to linear bandits, i.e.,~$\mathcal A_t=\mathcal A,\forall t\in[T]$, and the safe action being the origin, i.e.,~$x_0=\mathbf{0}$ and $c_0=0$. This is why $c_0$ does not appear in their bounds. They consider their action set to be any convex compact subset of $\mathbb R^d$ that contains the origin. Although later in their proofs, to guarantee that their algorithm does not violate the constraint in the first round, they require the action set to also contain the ball with radius $\tau/S$ around the origin. Therefore, our action set is more general than theirs. Moreover, unlike us, their action set does not allows their results to be immediately applicable to MAB. Our regret bound also has a better dependence on $d$ and $\log T$ than theirs, similar to the best regret results for UCB vs.~TS. However, their algorithm is TS, and thus, is less complex than ours. Although it can be still intractable, even when $\mathcal A$ is convex. They needed to do several approximations in order to make their algorithm tractable in their experiments.
In~\cite{amani2019linear}, reward and cost have the same unknown parameter $\theta_*$, and the cost is defined as $c_t=x_t^\top B\theta_*\leq\tau$, where $B$ is a known matrix. They derive and analyze an explore-exploit algorithm for this setting. Although our rate is better than theirs, i.e.,~$\widetilde{O}(T^{2/3})$, our algorithm cannot immediately give a $\widetilde{O}(\sqrt{T})$ regret for their setting, unless in special cases.
\section{Conclusions}
\label{sec:conclu}
\vspace{-0.1in}
We derived a UCB-style algorithm for a new constrained contextual linear bandit setting, in which the goal is to produce a sequence of policies with maximum expected cumulative reward, while each policy has an expected cost below a certain threshold $\tau$. We proved a $T$-round regret bound of $\widetilde{\mathcal{O}}(\frac{d\sqrt{T}}{\tau-c_0})$ for our algorithm, which shows that the difficulty of the problem depends on the difference between the constraint threshold and the cost of a known feasible action $c_0$. We further specialized our results to MAB and proposed and analyzed a computationally efficient algorithm for this setting. We also proved a lower-bound for our constrained bandit problem and provided simulations to validate our theoretical results. A future direction is to use the optimism-pessimism idea behind our algorithm in other constrained bandit settings, including deriving a UCB-style algorithm for the setting studied in~\cite{amani2019linear} and~\cite{Moradipari19SL}.
\subsection{Regret analysis}\label{section:regret_analysis_appendix}
In order to show a regret bound for Algorithm \ref{alg::optimism_pessimism}, we start with the following regret decomposition:
\begin{align*}
\mathcal{R}_\Pi(T) &= \sum_{t=1}^T \mathbb{E}_{a\sim \pi^*}[\bar{r}_a] - \mathbb{E}_{a \sim \pi_t}[\bar{r}_{a}] \\
&=\underbrace{\left( \sum_{t=1}^T \mathbb{E}_{a\sim \pi^*}[\bar{r}_a] - \mathbb{E}_{a \sim \pi_t}[u_a^r(t)] \right)}_{(i)} +\underbrace{ \left(\sum_{t=1}^T \mathbb{E}_{a\sim \pi_t}[u^r_a(t)] - \mathbb{E}_{a \sim \pi_t}[\bar{r}_{a}] \right) }_{(ii)}.
\end{align*}
In order to bound $\mathcal{R}_\Pi(T)$, we independently bound terms $(i)$ and $(ii)$.
We start by bounding term (i). We proceed by first proving an Lemma~\ref{lemma::optimism}, the equivalent version of Lemma~\ref{lemma:linear_bandits_optimism} for the multi armed bandit problem.
\subsection{Proof of Lemma~\ref{lemma::optimism}}
\begin{proof}
Throughout this proof we denote as $\pi_0$ to the delta function over the safe arm $1$. We start by noting that under $\mathcal{E}$, and because $\alpha_r, \alpha_c \geq 1$, then:
\begin{equation}
\label{equation::confidence_interval_lower_bounds}
(\alpha_r-1)\beta_a(t) \leq \xi_a^r(t) \leq (\alpha_r + 1)\beta_a(t) \text{ } \forall a \quad \text{ and } \quad (\alpha_c-1)\beta_a(t) \leq \xi_a^c(t) \leq (\alpha_c+1)\beta_a(t) \text{ } \forall a \neq 0.
\end{equation}
If $\pi^*\in \Pi_t$, it immediately follows that:
\begin{equation}
\label{equation::feasible_lower_bound}
\mathbb{E}_{a\sim \pi^*}\left[\bar{r}_a \right] \leq \mathbb{E}_{a\sim \pi^*}\left[u_a^r(t)\right] \leq \mathbb{E}_{a \sim \pi_t}\left[ u_a^r(t)\right].
\end{equation}
Let's now assume $\pi^* \not\in \Pi_t$, i.e.,~$\mathbb{E}_{a\sim\pi^*}\left[u_a^c(t)\right] > \tau$. Let $\pi^* = \rho^* \bar{\pi}^* + (1-\rho)\pi_0$ with $\bar{\pi}^* \in \Delta_K[2:K]$\footnote{In other words, the support of $\bar{\pi}^*$ does not contain the safe arm $1$.}.
Consider a mixture policy $\widetilde{\pi}_t = \gamma_t \pi^* + (1-\gamma_t)\pi_0 = \gamma_t \rho^* \bar{\pi}^* + (1-\gamma_t \rho^*)\pi_0$, where $\gamma_t$ is the maximum $\gamma_t\in [0,1]$ such that $\widetilde{\pi}_t\in\Pi_t$. It can be easily established that
\begin{align*}
\gamma_t &= \frac{\tau-\bar{c}_1}{\rho^*\mathbb{E}_{a \sim \bar{\pi}^*}\left[u^c_a(t)\right] - \rho^*\bar{c}_1} =\frac{\tau - \bar{c}_1}{ \mathbb{E}_{a \sim \bar{\pi}^*}[\rho^*(\bar{c}_a + \xi_a^c(t) )] - \rho^* \bar{c}_1} \\
&\stackrel{(i)}{ \geq} \frac{\tau - \bar{c}_1}{\tau - \bar{c}_1 + \rho^* (1+\alpha_c)\mathbb{E}_{a \sim \bar{\pi}^*}[\beta_a(t)]}.
\end{align*}
{\bf (i)} is a consequence of~\eqref{equation::confidence_interval_lower_bounds} and of the observation that since $\pi^*$ is feasible $\rho^*\mathbb{E}_{a \sim \bar{\pi}^*}[\bar{c}_a] + (1-\rho^*)\bar{c}_1 \leq \tau$. Since $\widetilde{\pi}_t\in\Pi_t$, we have
\begin{align*}
\mathbb{E}_{a \sim \pi_t }[u_a^r(t)] &\geq \underbrace{\gamma_t \mathbb{E}_{a \sim \pi^*}[u_a^r(t)] + (1-\gamma_t)u^r_0(t)}_{\mathbb{E}_{a\sim \widetilde{\pi}_t}\left[ u_a^r(t)\right]} \\
&\stackrel{(ii)}{\geq} \frac{\tau - \bar{c}_1}{\tau - \bar{c}_1 + \rho^* (1+\alpha_c)\mathbb{E}_{a \sim \bar{\pi}^*}[\beta_a(t)]} \times \mathbb{E}_{a \sim \pi^*}[u_a^r(t)] \\
&= \frac{\tau-\bar{c}_1}{\tau -\bar{c}_1 + \rho^*(1+\alpha_c)\mathbb{E}_{a \sim \bar{\pi}^*}[\beta_a(t)]} \times \Big(\mathbb{E}_{a \sim \pi^*}[\bar{r}_a] + \mathbb{E}_{a \sim \pi^*}[\xi_a^r(t)]\Big) \\
&\stackrel{(iii)}{\geq} \frac{\tau - \bar{c}_1}{\tau -\bar{c}_1 +\rho^* (1+\alpha_c)\mathbb{E}_{a \sim \bar{\pi}^*}[\beta_a(t)]} \times \Big(\mathbb{E}_{a \sim \pi^*}[\bar{r}_a] + (\alpha_r-1)\mathbb{E}_{a \sim \pi^*}[\beta_a(t)]\Big) \\
&\stackrel{(iv)}{\geq}\underbrace{\frac{\tau-\bar{c}_1}{\tau -\bar{c}_1+ (1+\alpha_c)\mathbb{E}_{a \sim \pi^*}[\beta_a(t)]} \times \Big(\mathbb{E}_{a \sim \pi^*}[\bar{r}_a ] + (\alpha_r-1)\mathbb{E}_{a \sim \pi^*}[\beta_a(t)]\Big)}_{C_0}.
\end{align*}
{\bf (ii)} holds because $u_0^r(t)\geq 0$. {\bf (iii)} is a consequence of~\eqref{equation::confidence_interval_lower_bounds} and {\bf (iv)} follows because $\mathbb{E}_{a \sim \pi^*}[ \beta_a(t)] = \rho^* \mathbb{E}_{a \sim \bar{\pi}^*}[\beta_a(t)] + (1-\rho^*)\beta_0(t) \geq \rho^* \mathbb{E}_{a \sim \bar{\pi}^*}[\beta_a(t)]$ since $\beta_a(t) \geq 0$ for all $a$ and $t$.
Let $C_1 = \mathbb{E}_{a \sim \pi^*}[\beta_a(t)]$. The following holds:
\begin{equation*}
C_0 = \frac{\tau-\bar{c}_1}{\tau - \bar{c}_1 + (1+\alpha_c)C_1}\times\Big(\mathbb{E}_{a \sim \pi^*}[\bar{r}_a] + (\alpha_r-1)C_1\Big).
\end{equation*}
Note that $C_0 \geq \mathbb{E}_{a \sim \pi^*}\left[\bar{r}_a \right]$ iff:
\begin{equation*}
(\tau-\bar{c}_1) \mathbb{E}_{a \sim \pi^*}[\bar{r}_a] + (\tau-\bar{c}_1)(\alpha_r-1)C_1 \geq (\tau-\bar{c}_1)\mathbb{E}_{a \sim \pi^*}\left[\bar{r}_a \right] + (1+\alpha_c)C_1\mathbb{E}_{a \sim \pi^*}\left[\bar{r}_a \right],
\end{equation*}
which holds iff:
\begin{equation*}
(\tau-\bar{c}_1)(\alpha_r-1)C_1 \geq (1+\alpha_c)C_1\mathbb{E}_{a\sim \pi^*}[\bar{r}_a].
\end{equation*}
Since $\mathbb{E}_{a\sim \pi^*}\left[ \bar{r}_a\right] \leq 1$, this holds if $1+\alpha_c \leq (\tau-\bar{c}_1) (\alpha_r-1)$.
\end{proof}
\begin{proposition}\label{proposition::bounding_term_I}
If $\delta = \frac{\epsilon}{4KT}$ for $\epsilon \in (0,1)$, $\alpha_r, \alpha_c \geq 1$ with $\alpha_c \leq \tau (\alpha_r -1)$, then with probability at least $1-\frac{\epsilon}{2}$, we have
\begin{equation*}
\sum_{t=1}^T \mathbb{E}_{a\sim \pi^*}[\bar{r}_a] - \mathbb{E}_{a \sim \pi_t}[u_a^r(t)] \leq 0
\end{equation*}
\end{proposition}
\begin{proof}
A simple union bound implies that $\mathbb{P}(\mathcal{E}) \geq 1-\frac{\epsilon}{2}$. Combining this observation with Lemma \ref{lemma::optimism} yields the result.
\end{proof}
Term $(ii)$ can be bound using the confidence intervals radii:
\begin{proposition}
\label{proposition::bounding_term_II}
If $\delta = \frac{\epsilon}{4KT}$ for an $\epsilon \in (0,1)$, then with probability at least $1-\frac{\epsilon}{2}$, we have
\begin{equation*}
\sum_{t=1}^T \mathbb{E}_{a\sim \pi_t}[u_a^r(t)] - \mathbb{E}_{a \sim \pi_t}[\bar{r}_{a}] \leq (\alpha_r+1) \left(2\sqrt{2TK\log(1/\delta)} + 4\sqrt{T\log(2/\epsilon)\log(1/\delta)} \right)
\end{equation*}
\end{proposition}
\begin{proof}
Under these conditions $\mathbb{P}(\mathcal{E}) \geq 1-
\frac{\epsilon}{2}$. Recall $u_a^r(t) = \widehat{r}_a(t) + \alpha_r\beta_a(t)$ and that conditional on $\mathcal{E}$, $\bar{r}_a \in [\widehat{r}_a(t) - \beta_a(t),\widehat{r}_a(t) + \beta_a(t)]$ for all $t \in [T]$ and $a \in \mathcal{A}$. Thus, for all $t$, we have
\begin{equation*}
\mathbb{E}_{a \sim \pi_t}[u_a^r(t)] - \mathbb{E}_{a \sim \pi_t}[\bar{r}_a] \leq (\alpha_r +1)\mathbb{E}_{a \sim \pi_t}[\beta_a(t)].
\end{equation*}
Let $\mathcal{F}_{t-1}$ be the sigma algebra defined up to the choice of $\pi_t$ and $a_t'$ be a random variable distributed as $\pi_t \mid \mathcal{F}_{t-1}$ and conditionally independent from $a_t$, i.e.,~$a'_t \perp a_t \mid \mathcal{F}_{t-1}$. Note that by definition the following equality holds:
\begin{equation*}
\mathbb{E}_{a \sim \pi_t}[\beta_a(t)] = \mathbb{E}_{a'_t \sim \pi_t}[\beta_a(t) \mid \mathcal{F}_{t-1}].
\end{equation*}
Consider the following random variables $A_t = \mathbb{E}_{a'_t \sim \pi_t} [\beta_{a'_t}(t) \mid \mathcal{F}_{t-1}]- \beta_{a_t}(t)$. Note that $M_t = \sum_{i=1}^t A_i$ is a martingale. Since $|A_t| \leq 2\sqrt{2 \log(1/\delta)}$, a simple application of Azuma-Hoeffding\footnote{We use the following version of Azuma-Hoeffding: if $X_n$, $n\geq 1$ is a martingale such that $|X_i - X_{i-1}| \leq d_i$, for $1 \leq i \leq n$, then for every $n \geq 1$, we have $\mathbb{P}(X_n > r) \leq \exp\left(-\frac{r^2 }{2\sum_{i=1}^n d_i^2}\right)$.} implies:
\begin{equation*}
\mathbb{P}\left(\underbrace{\sum_{t=1}^T \mathbb{E}_{a \sim \pi_t} [\beta_a(t)] \geq \sum_{t=1}^T \beta_{a_t}(t) + 4\sqrt{T\log(2/\epsilon)\log(1/\delta)}}_{\mathcal{E}_A^c}\right ) \leq \epsilon/2.
\end{equation*}
We can now upper-bound $\sum_{t=1}^T \beta_{a_t}(t)$. Note that $\sum_{t=1}^T \beta_{a_t}(t) = \sum_{a \in \mathcal{A}}\sum_{t=1}^T \mathbf{1}\{a_t=a\}\beta_a(t)$. We start by bounding for an action $a\in\mathcal A$:
\begin{align*}
\sum_{t=1}^T \mathbf{1}\{a_t=a\}\beta_a(t) = \sqrt{2\log(1/\delta)} \sum_{t=1}^{T_a(T)} \frac{1}{\sqrt{t}} \leq 2\sqrt{2T_a(T)\log(1/\delta)}.
\end{align*}
Since $\sum_{a\in\mathcal A } T_a(T) = T$ and by concavity of $\sqrt{ \cdot}$, we have
\begin{equation*}
\sum_{a\in\mathcal A} 2\sqrt{2T_a(T)\log(1/\delta)} \leq 2\sqrt{2TK\log(1/\delta)}.
\end{equation*}
Conditioning on the event $\mathcal{E} \cap \mathcal{E}_A$ whose probability satisfies $\mathbb{P}( \mathcal{E}\cap \mathcal{E}_A) \geq 1-\epsilon $ yields the result.
\end{proof}
We can combine these two results into our main theorem:
\begin{theorem}[Main Theorem]
If $\epsilon \in(0,1)$, $ \alpha_c=1$ and $\alpha_r = \frac{2}{\tau-\bar{c}_1} + 1$, then with probability at least $1-\epsilon$, Algorithm \ref{alg::optimism_pessimism} satisfies the following regret guarantee:
\begin{equation*}
\mathcal{R}_\Pi(T) \leq \left(\frac{2}{\tau-\bar{c}_1} +1\right)\left(2\sqrt{2TK\log(4KT/\epsilon)} + 4\sqrt{T\log(2/\epsilon)\log(4KT/\epsilon)} \right)
\end{equation*}
\end{theorem}
\begin{proof}
This result is a direct consequence of Propositions \ref{proposition::bounding_term_I} and \ref{proposition::bounding_term_II} by setting $ \delta = 4KT \epsilon$.
\end{proof}
\subsection{Multiple constraints}\label{section::multiple_constraints_appendix}
We consider the problem where the learner must satisfy $M$ constraints with threshold values $\tau_1, \cdots, \tau_M$. Borrowing from the notation in the previous sections, we denote by as $\{\bar{r}_a\}_{a\in \mathcal{A}}$ the mean reward signals and $\{ \bar{c}_a^{(i)} \}$ the mean cost signals for $i = 1,\cdots, M$. The full information optimal policy can be obtained by solving the following linear program:
\begin{align*}
\label{eq::no_noise_LP_multiple_constraints}\tag{P-M}
\max_{\pi \in \mathrm{\Delta}_K} &\; \sum_{a \in \mathcal{A}} \pi_a \bar{r}_a, \\
\text{s.t. } &\; \sum_{a \in \mathcal{A}} \pi_a \bar{c}^{(i)}_a \leq \tau_i \text{ for } i=1, \cdots, M.
\end{align*}
In order to ensure the learner's ability to produce a feasible policy at all times, we make the following assumption:
\begin{assumption}
The learner has knowledge of $\bar{c}_1^{(i)} < \tau_i$ for all $i = 1, \cdots, M$.
\end{assumption}
We denote by $\{ \widehat{r}_a \}_{a \in \mathcal{A}}$ and $\{ \widehat{c}_a^{(i)} \}_{a\in\mathcal{A}}$ for $i = 1, \cdots, M$ the empirical means of the reward and cost signals. We call $\{ u_a^r(t)\}_{a \in \mathcal{A}}$ to the upper confidence bounds for our reward signal and $\{ u_a^{c}(t, i)\}_{a \in \mathcal{A}}$ for $i = 1, \cdots, M$ the costs' upper confidence bounds:
\begin{equation*}
u_a^r(t) = \widehat{r}_a(t) + \alpha_r \beta_a(t), \qquad u_a^c(t, i) = \widehat{c}^{(i)}_a(t) + \alpha_c \beta_a(t),
\end{equation*}
where $\beta_a(t) = \sqrt{2\log(1/\delta)/T_a(t)}$, $\delta \in (0,1)$ as before. A straightforward extension of Algorithm \ref{alg::optimism_pessimism} considers instead the following $M-$constraints LP:
\begin{align*}
\label{eq::noisy_LP_multiple}
\tag{$\widehat{P-M}$}
&\max_{\pi\in\mathrm{\Delta}_K} \;\; \sum_{a \in \mathcal{A}} \pi_a \; u^r_a(t)\;\;\; \\
&\;\text{s.t.} \quad\; \sum_{a \in \mathcal{A}} \pi_a \; u_a^c(t, i)\leq \tau_i, \text{ for } i= 1, \cdots, M.
\end{align*}
We now generalize Lemma \ref{lemma::optimism}:
\begin{lemma}\label{lemma::optimisim_multiple}
Let $\alpha_r, \alpha_c\geq 1$ satisfying $\alpha_c \leq \min_i(\tau_i- \bar{c}^{(i)}_1) (\alpha_r-1)$. Conditioning on $\mathcal{E}_a(t)$ ensures that with probability $1-\delta$:
\begin{equation*}
\mathbb{E}_{a \sim \pi_t}\left[u_a^r(t)\right] \geq \mathbb{E}_{a \sim \pi^*}\left[\bar{r}_a \right].
\end{equation*}
\end{lemma}
\begin{proof}
The same argument as in the proof of Lemma \ref{lemma::optimism} follows through, the main ingredient is to realize that $\gamma_t$ satisfies the sequence of inequalities in the lemma with $\tau - \bar{c}_1$ substituted by $\min \tau_i - \bar{c}_1^{(i)}$.
\end{proof}
The following result follows:
\begin{theorem}[Multiple Constraints Main Theorem]
If $\epsilon \in(0,1)$, $ \alpha_c=1$ and $\alpha_r = \frac{2}{\min_i \tau_i-\bar{c}^{(i)}_1} + 1$, then with probability at least $1-\epsilon$, Algorithm \ref{alg::optimism_pessimism} satisfies the following regret guarantee:
\begin{equation*}
\mathcal{R}_\Pi(T) \leq \left(\frac{2}{\min_i\tau_i-\bar{c}^{(i)}_1} +1\right)\left(2\sqrt{2TK\log(4KT/\epsilon)} + 4\sqrt{T\log(2/\epsilon)\log(4KT/\epsilon)} \right)
\end{equation*}
\end{theorem}
\begin{proof}
The proof follows the exact same argument we used for the proof of Theorem~\ref{theorem::contrained_MAB} substituting $\tau - \bar{c}_1$ by $\min_i \tau_i -\bar{c}_1^{(i)}$.
\end{proof}
\subsection{Lower bound}
\label{section::lower_bound_MAB_appendix}
\input{lower_bounds}
| {'timestamp': '2020-06-19T02:05:17', 'yymm': '2006', 'arxiv_id': '2006.10185', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10185'} | arxiv |
\section{Introduction}
\label{sec:introduction}
Billions of messages are sent online every day and hidden among them are millions of toxic and harmful messages. For instance, studies have shown that 17\% of internet users receive cyber-bullying messages (a type of toxic messages), with a disproportionate number of targets being women (19\%), low-income people (24\%), and homosexuals (34\%) \cite{hango2016cyberbullying}, and that 10\% of people develop depressive or suicidal thoughts as a result of these messages \cite{ADL2019}. This makes the development of accurate and efficient content moderation systems a high priority. Most of the studies so far have focused on single-line detection. In other words, the models developed look at each message individually and decide whether it should be classified as toxic or not. While such systems can be good at detecting toxic messages once they are written \cite{meanbirds,deeper,vanhee2018}, they cannot predict whether upcoming messages in a conversation will feature toxic content or not. This ability to flag interactions for moderation before they turn toxic would be hugely beneficial both for community moderators, allowing them to intervene more quickly and efficiently, and for users, preventing them from being targeted by toxic messages in the first place. This is the goal of the task of preemptive detection. It is however impossible to do when considering only a single message in isolation, and requires a model of the entire conversation.
In \cite{conversations}, the authors study the pragmatic devices used early in a conversation and their usefulness for preemptive detection. In this paper, we build upon their work by adding sentiment information \cite{subversive} to their model. Our intuition is that the sentiments expressed early in a conversation can help predict more accurately if it will degrade into toxicity later on or not. If true, this would run counter to the observations of \cite{conversations}, which found sentiment information to have no predictive power in this task. The rest of this paper is structured as follows. After a review of the relevant literature in section \ref{sec:background}, we will quickly go over the sentiment detection tool in Section \ref{sec:Sentiment}. In the same section we will also study how our sentiment features can be added to the system of \cite{conversations} and present the resulting preemptive detection tool. We will conduct an in-depth analysis of our results when using the dataset of \cite{conversations} in Section \ref{sec:results}. To expand on this study, we then perform a second set of experiments on another dataset in Section \ref{sec:other_context}. Finally, we draw conclusions on preemptive detectio and the use of sentiment information in Section \ref{sec:Conclusion}.
\section{Related Work}
\label{sec:background}
The challenge of toxic content detection in online conversations has been studied since 2012. Various topics have been covered, such as hate speech detection \cite{warner2012detecting,nobata2016abusive} and cyberbullying detection \cite{reynolds2011using,meanbirds,deepcyber2018}, and many architectures have been adapted and trained successfully for this task, including SVMs \cite{warner2012detecting,vanhee2018}, logistic regressions \cite{nobata2016abusive}, and neural networks \cite{deepcyber2018}. However, even the most recent work only focuses on single-line detection, meaning determining whether a comment that has already been posted is toxic or not by itself and outside the context of the conversation where it appears.
One of the first and only studies on toxicity prediction at the conversation level is that of \cite{conversations}. The authors showed that certain features in the first messages of a conversation, such as the use of first or second person pronouns and the presence of certain politeness strategies, can help predict if that conversation will remain healthy or if it will degrade and lead to toxic messages later on. Their work inspired the authors of \cite{preemptive}, who also worked on preemptive moderation. They trained and tested an SVM using TFIDF-weighted unigrams and bigrams as well as a BiLSTM using their own word embeddings. They were ultimately dissatisfied with their results, however the fact they focused only on words and didn't use more sophisticated features such as those in \cite{conversations} may be the cause. Finally, the authors of \cite{liu2018} did hostility presence and intensity prediction on Instagram comment threads using a variety of features, ranging from n-grams and word vectors to user activity and lexicons. The features are used to train a logistic regression model with L2 regularization. The authors conclude that there are four main predictors for hostility: the post author's history of receiving hostile comments, the presence of user-directed profanity in the thread, the number of distinct users posting comments in that thread, and the amount of hostility so far in a conversation. However, none of these studies examined the impact of sentiment information in preemptive detection, which will be the main focus of our paper.
\section{Conversation Model}
\label{sec:Sentiment}
\subsection{Sentiment Detection Tool}
\label{sub:sentimenttool}
The authors of \cite{subversive} implemented a sentiment detection system in order to study whether sentiment information can help detect toxic content in a subversive setting (where users deliberately misspell toxic words to mask them from keyword filters). They found that sentiment information did correlate to toxicity, and could be used to improve the accuracy of toxic message detection systems, both in a normal and in a subversive setting.
The sentiment detection tool implemented in that paper, which we will reuse in this one, is heavily inspired by previous works such as \cite{ohana2012case,nielsen2011new,tumsare2014opinion}, where the authors used sentiment lexicons, such as SentiWordNet or General Inquirer, to detect the sentiment of a message. Our tool combines three popular lexicons, namely SentiWordNet\footnote{\url{http://sentiwordnet.isti.cnr.it/}}, Afinn\footnote{\url{https://github.com/fnielsen/afinn}} and Bing Liu\footnote{\url{https://www.cs.uic.edu/~liub/FBS/sentiment-analysis.html}}. The authors found previously that these three lexicons have different strengths and weaknesses, and thus complement each other well. SentiWordNet is the biggest lexicon and assigns a positive and negative score between 0 and 1 to each word. Afinn assigns a single score between -5 and 5; scores under zero meaning the words are negative. The Bing Liu lexicon has a positive and a negative word list. The lexicons are combined by splitting each into lists of positive and negative words for each of four parts-of-speech (noun, verb, adverb, and adjective), and normalizing the sentiment scores between 0 and 1.
The sentiment detection tool begins by detecting sentiment-carrying idioms in the messages. For example, while the words "give" and "up" can both be neutral or positive, the idiom "give up" has a clear negative sentiment. Several of these idioms can be found in our lexicons, especially SentiWordNet (slightly over $60,000$). When detected, these idioms are marked so that our algorithm will handle them as single words. Next, it uses the NLTK \textit{wordpunkt\_tokenizer} to split messages into words, and the \textit{pos\_tagger} to get the part-of-speech of each word. Each word is then assigned a positive and a negative score, which is the sum of the score it has in the positive and negative lists of each of the three lexicons. A message is represented by the score of its three most positive words and its three most negative words. This gives us a total of 6 sentiment features for each message. For more details as to why the tool is built this way, please refer to \cite{subversive}.
\subsection{Model and features}
\label{sec:Features}
The authors of \cite{conversations} split their conversation pragmatic features into two categories: 13 politeness strategies and 6 rhetorical prompts. The first category focuses on the use of politeness, such as greetings, gratitude, or the use of "please", and of impoliteness, such as direct and strong disagreement or personal attacks. The second category captures six domain-specific conversation prompts, which are six clusters of conversations discovered by an unsupervised technique trained on a different dataset that includes similar types of discussions. A new message's distance to each of these six clusters gives the six prompt features. This gives a total of 19 features per message, and the authors compute them for the first two messages of a given conversation, thus getting a set of 38 features. Using these features, the authors train a logistic regression model to predict if a conversation will derail into toxicity based on its first two messages. The authors have made their code available publicly\footnote{https://github.com/CornellNLP/Cornell-Conversational-Analysis-Toolkit}. More details on these features and the regression model built from them can be found in the original article.
Our version of the model builds upon theirs by adding the 6 sentiment features measured by the sentiment tool for the same two messages. We also computed another sentiment feature representing the overall tone of the first two messages. This feature is computed by taking the sum of positive word scores of the first message and subtracting the sum of negative word scores to determine if the message is overall positive or negative, doing the same for the second message, and determining if the conversation starts with two positive messages, a positive followed by a negative, a negative followed by a positive, or two negative messages. This information is encoded as a one-hot vector of length 4. In total, there are thus 38 text features from \cite{conversations} and 16 sentiment features we added, for a total of 54 conversation features.
\begin{figure*}[b]
\centering
\includegraphics[width=0.48\textwidth]{Figures/neg_coefs_1.png}
\includegraphics[width=0.48\textwidth]{Figures/pos_coefs_1.png}
\caption{Feature importance when using 3 positive sentiment features and 3 negative sentiment features. The "(2nd)" refers to the feature on the second message, while its omission refers to the first message.}
\label{fig:feature1}
\end{figure*}
\subsection{Data and Training}
\label{sec:Data and Training}
The dataset created for \cite{conversations}, which is available publicly along with their code, is a set of user conversations taken from the edit pages of English Wikipedia. The authors used Persepctive API\footnote{https://www.perspectiveapi.com/} to pre-filter the conversations and keep only the ones with potentially toxic content. They further filtered to keep those conversations that started in a civil way, meaning that didn't have any toxic content in the first two messages. Moreover, they required conversation pairs, one derailing and one staying civil, from each Wikipedia page. This resulted in 1,270 conversation pairs from 582 different pages with an average length of 4.6 messages.
Our model is trained using \textit{Scikit-learn}'s \textit{LogisticRegression} and \textit{SelectPercentile}, with a grid search on hyperparameters \textit{C} between $10^{-4}$ and $10^4$ and \textit{percentile} between $10$ and $100$\footnote{\textit{C} representing the regularization and \textit{percentile} representing the percent of features to use.}. Training was done using a 5-fold cross validation. Apart from increasing the number of folds from 3 to 5 for more consistency between runs, all the training parameters are exactly the same as the ones in \cite{conversations}.
\begin{figure*}[h]
\centering
\includegraphics[width=0.48\textwidth]{Figures/neg_coefs_2.png}
\includegraphics[width=0.48\textwidth]{Figures/pos_coefs_2.png}
\caption{Feature importance when using 5 positive sentiment features and 2 negative sentiment features. }
\label{fig:feature2}
\end{figure*}
\section{Results and Analysis}
\label{sec:results}
As in \cite{conversations}, our experiments consist in taking a pair of conversations, looking at their first two messages, and predicting which of the two conversations will remain healthy and which one will derail into toxicity. All the results presented in the following section are the average of 10 separate runs, where we randomized the data split.
\subsection{Sentiment Features}
Our first experiment considers the predictive accuracy of sentiment information alone. In fact, the authors of \cite{conversations} did include the sentiment lexicon of \cite{Liu:2005} in their research, and used it to extract two sentiment features per message. Their features were "has negative" and "has positive", each being 1 if a negative or positive word from the lexicon was present in the message and 0 otherwise. However, after testing these features, they concluded that sentiment was barely better than random chance at predicting toxicity, and they didn't include them in their set of 38 text features.
The goal of our first experiment is thus to validate that the sentiment features are in fact predictors of upcoming toxic messages. We trained and tested the model using four setups: using the original sentiment features of \cite{conversations}, the sentiment word features, our tone features, and all sentiment features combined. The results are presented in \ref{tbl:baseline}.
\begin{table}[ht]
\centering
\begin{tabular}{l|c|c}
\hline
Test & Features & Accuracy \\ \hhline{=|=|=}
Original sentiment & 4 & 51.3 \\
Our sentiment & 12 & 55.7 \\
Our tone & 8 & 50.8 \\
All features & 24 & 55.8 \\
\hline
\end{tabular}
\caption{Prediction accuracy using sentiment features.}
\label{tbl:baseline}
\end{table}
Our results firstly confirm that the minimalist sentiment features of \cite{conversations} are nearly equivalent to a random chance guess. This is likely due to the fact that over 70\% of the messages containing a negative word also have a positive word, making it nearly impossible to discern a toxic message from a healthy one based on that information alone. Likewise, our tone information carries nearly no useful information. However, our more detailed word features do show an interesting predictive ability. Finally, combining all features together gives no gain compared to just using the word features; an unsurprising result, given that the other features seem to contain no predictive information.
This shows that, when it comes to sentiment information, it is not the overall sentiment of a message that is useful, but individual words. That level of detail is missing from both the original sentiment features (which only indicated whether positive or negative sentiment exist) and our tone features (which only indicate whether positive or negative sentiment is stronger). It is however present in the sentiment word features, which indicates the sentiment of the three most positive and most negative words of each message without making a judgment on whether the message overall is positive or negative. That finer level of granularity seems to be where the predictive information is found.
From this point forward, we will drop the tone features from our model, since they are not predictive of toxicity. This will leave 12 sentiment features and a total of 50 conversation features.
\subsection{All Features}
\label{sec:allfeats}
Our next experiment consists in training and testing our model with and without the sentiment features. The goal is to highlight the gain in prediction accuracy that comes from including sentiment features. The results of that experiment are given in Table \ref{tbl:mainresults}.
\begin{table}[ht]
\centering
\begin{tabular}{l|c|c}
\hline
Test & Features & Accuracy \\ \hhline{=|=|=}
Text features & 38 & 58.6 \\
Text + sentiment & 50 & 60.5 \\
\hline
\end{tabular}
\caption{Prediction accuracy with and without sentiment features.}
\label{tbl:mainresults}
\end{table}
In all 10 runs of our test, we found that the model including sentiment features consistently performs better than the one without. Our results using text features alone are consistent with those of \cite{conversations}, and adding sentiment features improves the prediction on average by 2\%. This is consistent with the findings in \cite{subversive}, where it was found that sentiment information improved toxicity prediction by 3\%.
\subsection{Predictive Features}
It is interesting to examine which sentiment features contribute the most information to the prediction of how a conversation will develop. To do this, we take the average norm of the coefficient score of the logistic regression for each of the 50 features over the 10 runs of our experiment. The most informative features are simply those with the highest positive or negative coefficients, while features with coefficients around 0 have no influence on the prediction.
We found that the most predictive features were consistent from run to run. They are listed in Figure \ref{fig:feature1}, along with their average coefficients. The top text features found match those identified in \cite{conversations}. In addition to those, four of the sentiment features are among the 14 most predictive features found by the regression model.
For predicting conversations that will feature toxic messages, the strength of the first and second most negative words in the first message and of the third most negative word in the second message are all strong predictors. This indicates that strong negative words in both first messages will likely cause the conversation to degrade. Combined with the fact that second-person pronoun use in both messages are also strong toxicity predictors, this may indicate conversations that begin with directed negative sentiments towards other participants.
On the other hand, only one of the sentiment features is among the strongest predictors of whether a conversation will remain healthy. It is the strength of the third most positive word in the second message. This is an interesting difference with the toxic case: while strong negative words are clear predictors of upcoming toxic messages, strong positive words are not predictors of healthy messages, but lower-ranked positive words are. This may indicate that abundance, not strength, of positive sentiment is what matters to predict health.
In order to verify that theory, we re-trained and re-tested our model several times using between 1 and 7 positive or negative sentiment features. The best combination we found was using 5 positive sentiment features and only 2 negative ones, and this 56-feature model offered an improvement of 1\% on prediction accuracy compared to the 50-feature model of Table \ref{tbl:mainresults}. The most predictive features in that test are shown in Figure \ref{fig:feature2}. For toxicity prediction, nothing has changed, save for the fact the third negative word of the second message has disappeared (as the feature is no longer part of the model) and the second negative word of the second message becomes the seventh most predictive feature (it was eighth previously). For health prediction, we can see that the newly-added features of the fourth and fifth positive words of the first message are now among the top predictors, beating out the third positive word from \ref{fig:feature1}. This confirms our earlier intuition.
\subsection{Case Studies}
Figure \ref{fig:quote} has an example of the first two messages of a conversation that was mispredicted as healthy using the text features alone, but was correctly predicted as leading to toxic messages by the classifier with sentiment features.
\begin{figure}[h]
\begin{quote}
(1) I'm sorry to say it, but I'm \underline{pretty} sure this is the only option left. This discussion has been so repetitive it's unbelievable. The mediation cabal has all but ceased, and the mediation of this talk page has \textbf{failed}. The RFC also did not work. I can see no other way to reslve the issue other than ArbCom. What does everyone else think?
(2) It's a \underline{pretty} \textbf{useless} process. Mostly Admins listing Hebrew as a language, or displaying Israeli symbols on their user pages will respond they have no \textbf{problem} with the biased edits. \textbf{Worst}-case they ban you for suggesting the article needed comment or some type of oversight.
\end{quote}
\caption{First two messages of a derailing conversation, with major good words underlined and major bad words in bold.}
\label{fig:quote}
\end{figure}
The first message uses the first person and apologizes, both text features that predict a healthy conversation, and no other predictive text features are present in either message. As a result, the text-based system predicts they will lead to a healthy conversation. In reality, this conversation eventually degrades into the users attacking each other with messages such as: "[username] actually blames others", "it's your problem", "you are just trying to find an excuse to take jabs at me" and eventually "[username] shut up".
When taking sentiment information into account, the picture is quite different. Both messages contain only a single strong positive sentiment word, the word "pretty" (score of 0.59). The other positive words are very weak, and the fourth and fifth positive words of the first message are "all" and "think" (scores of 0.04 and 0.02 respectively). On the other hand, the first message has two strong negative words, "failed" (score of 0.47) and "unbelievable" (score of 0.46), and the second message has three even stronger ones, "useless", "problem" and "worst" (scores of 0.67, 0.60, and 0.78 respectively). Negative features dominate these messages, and as a result our model predicts correctly that this conversation will derail into toxicity.
This example highlights one reason why the top positive words are not predictors of health: they can be used as modifiers to enhance negative words, as is the case of the word "pretty" in "pretty useless". We believe another reason the strongest positive words are not good predictors is sarcasm, which uses one or two very strongly positive words to convey a negative message. However, we found no examples of sarcasm in our dataset, so we could not confirm that hypothesis.
\begin{figure}[h]
\begin{quote}
(1) not vandilism
(2) \underline{well} sorry about replacing bands.but you \textbf{dumb} \textbf{cunt} fireworks is also a punk pop band
\end{quote}
\caption{First two messages of a derailing conversation, with major good words underlined and major bad words in bold.}
\label{fig:quote2}
\end{figure}
The sample conversation of Figure \ref{fig:quote2} is an example of the impact of strong negative words. The second message in particular contains an apology (positive indicator), the strong positive word "well" (score of 0.46), and uses the second person (negative indicator). However, most people will pinpoint the two negative words as the strongest indicators this conversation will degrade. In fact, if those words were removed from the message, it would become a much more civil conversation. This illustrates how one or two strongly negative words can change the tone of a message and the flow of a conversation.
\section{Gaming Chat Moderation}
\label{sec:other_context}
\begin{figure*}
\centering
\includegraphics[width=0.48\textwidth]{Figures/neg_coefs_3.png}
\includegraphics[width=0.48\textwidth]{Figures/pos_coefs_3.png}
\caption{Feature importance in the gaming chat dataset. The number in parenthesis refers to the message's position before the reported message.}
\label{fig:feature3}
\end{figure*}
To validate the generality of our results, we decided to apply our model to a completely different setting from Wikipedia talk pages: live in-game chat conversations from a popular video game\footnote{The dataset was provided by Two Hat Research Corp. with permission from the gaming company. The data was pseudonymized and users have agreed to have their chat used for moderation purposes. The data can not be shared publicly due to its sensitive nature.}. This dataset consists of 26,964 different conversations of up to 50 messages, with most messages being very short, around 4 words only. This makes it very different from the Wikipedia dataset, in which conversations are on average less than 5 messages long but messages are on average 58 words long. The last message of each conversation was reported by a user, and then a decision was made by a community moderator to either take action on the reported message or ignore the report. The dataset is balanced, with 54\% of messages moderated and 46\% ignored.
There are several other significant differences with the Wikipedia dataset. Unlike an edit discussion which has a well-identified initial message, a gaming chat conversation begins when the chat room is created and is continuously ongoing after that, with players joining and leaving at will. The dataset's 50-message conversations are actually composed of the reported message and the previous 49 messages. Moreover, the Wikipedia dataset contains mostly two- to four-person conversations, while very often over a dozen players can chat simultaneously (together or in intertwined separate discussions) and be present in the 50-message conversation.
The purpose of this experiment is slightly different from the previous one: while we still want to determine if it is possible to predict if a conversation will derail into toxicity (meaning in this case that it will need moderation) from earlier messages, and to measure which text and sentiment features are the strongest predictors of this, we are no longer working with conversation pairs. Consequently, instead of choosing which of two conversations is most likely to go awry, we predict for each conversation individually if it will go awry or not, which is a much harder problem. Moreover, since the first message in a conversation is not the first message of the chatroom, we are not making a prediction from the beginning of a conversation but from an arbitrary point in the middle of it. Finally, taking only the first two messages as before would represent on average 8 words, which is not enough information to make a prediction from. Consequently, we use instead the 10 messages prior to the reported comment to predict whether the unseen final message will be toxic and require moderator action or not. This is thus a true preemptive detection challenge as well as a predictive moderation challenge: based on 10 messages, we are predicting whether an unseen 11th message will be moderated or not.
We will use the same 19 text features and 7 (5 positive and 2 negative) sentiment features per message as before. However, with 10 messages instead of 2, this means our model will have 260 features as input instead of 50. Moreover, we expect that message chronology will be a lot more important in a 10-message sequence than with 2 messages. Consequently, we decided to try two different models. The first one is the same logistic regression model as before. The second model is a recurrent neural network, specifically a uni-directional GRU with a kernel of 40 and a linear layer taking the final state of the GRU and producing a binary output. A recurrent neural network is a natural choice for a problem with a lot of features where chronology is important, and a similar model was used in \cite{subversive} for single-line toxicity detection and found to works well.
The data was randomly split 70/20/10 into training/validation/testing sets. We once again did 10 training and testing runs, using a different random split each time and 5-fold cross-validation within each run. Average results over all 10 runs are presented in Table \ref{tbl:gamingchatresults}. These results confirm that adding sentiment information helps improve the prediction of toxic conversations. The gain is greater for the logistic regression model, which in fact fails to make a prediction better than random chance without sentiment information. The RNN fares better, probably because it can better handle the large number and sequential nature of the features, but it still gains 1\% by including sentiment information.
\begin{table}[ht]
\centering
\begin{tabular}{l|c|c|c}
\hline
Model & Features & Accuracy & F1 score\\ \hhline{=|=|=|=}
Regression & 190 & 50.9\% & 0.556 \\
Regression & 260 & 57.4\% & 0.564\\
RNN & 190 & 60.6\% & 0.686 \\
RNN & 260 & 61.7\% & 0.691 \\
\hline
\end{tabular}
\caption{Results for both models using text features alone (190 features) or text and sentiment features (260 features).}
\label{tbl:gamingchatresults}
\end{table}
As before, we use the average coefficient score of each feature over the 10 runs to rank the features by predictive importance. The top features are shown in Figure \ref{fig:feature3}. There are some differences with the results of the Wikipedia test. Most notably, the subjunctive feature\footnote{Expressions such as "would you" and "could you".} is a strong predictor of healthy conversations in this experiment. Looking more closely, this feature is predictive of unmoderated conversations two-thirds of the times it appears; however, it appears in less than 1\% of chat conversations. This difference is therefore not significant in practice.
On the other hand, the coherent aspects with the previous experiment are very interesting. In both experiments, the features 'has hedge'\footnote{'Has hedge' refers to the presence of hedges, or mitigating words, like 'think', 'almost', 'rather', etc. This differs from the feature 'hedges', which looks for dependencies and requires the subject of the message to express this hedge.}, the use of 1st person pronouns, and indirect greetings\footnote{The presence of words like 'hey', 'hello' or 'hi'.}, are indicators of healthy conversations, while strong negative-sentiment words are indicators of an upcoming toxic comment that will need to be moderated. Moreover, unlike with the 'subjunctive' feature, these features all occur in a significant number of the conversation. This confirms that the method is generalizable and can be applied to different types of online conversations.
Next, we considered the question of which messages in the conversation contain the most predictive features. To this end, we considered the 26 (10\%) most predictive positive and negative features, and grouped them per message. The results, given in Table \ref{tbl:msgfeat}, show that features predicting both health and toxicity can be found throughout the conversation. However, while health predictors are distributed evenly in the conversation, toxicity predictors are concentrated in the final three messages. This indicates that a healthy conversation is an ongoing process, but a few bad messages can very quickly turn the tides of the conversation and lead to toxic messages being posted. This also indicates a limit to preemptive moderation: long-term predictions are not valid, and one must focus on clues in the latest messages. To confirm this, we ran the experiment again using only 3 messages before the reported message instead of 10. The results are almost identical to before: the logistic regression classification has an accuracy of 57.7\% with sentiment and 51.7\% without, while the RNN has an accuracy of 61.8\% with sentiment and 60.9\% without. It seems clear, then, that the previous seven messages did not contribute significantly to the prediction accuracy.
\begin{table}[ht]
\centering
\begin{tabular}{l|c|c|c|c|c|c|c|c|c|c}
\hline
Mess & 10 & 9 & 8 & 7 & 6 & 5 & 4 & 3 & 2 & 1 \\
\hhline{=|=|=|=|=|=|=|=|=|=|=}
Pos & 3 & 3 & 3 & 2 & 1 & 2 & 4 & 3 & 3 & 2 \\
Neg & 2 & 2 & 1 & 3 & 2 & 1 & 3 & 6 & 2 & 4\\
\hline
\end{tabular}
\caption{Number of positive and negative predictive features per message before the reported message.}
\label{tbl:msgfeat}
\end{table}
\section{Conclusion}
\label{sec:Conclusion}
In this paper, we studied how sentiment information can be used as a feature for the tasks of preemptive toxicity detection. We conducted this study using the sentiment detection tool developed in previous work \cite{subversive}, the conversation features and logistic classifier of \cite{conversations}, and two very different online conversation datasets. The results of our experiments allow us to draw some important conclusions that can guide both future research and practical implementations of preemptive detection tools:
\begin{enumerate}
\item Sentiment information is indeed a predictor of toxicity. Using it improves a system's performance by between 1\% and 6\%, which is consistent with previous results in \cite{subversive}. This notably runs counter to previously-published results from other authors that indicated that sentiment information performs no better as a predictor of toxic messages than random chance.
\item Sentiment information is found at a fine granularity, at the individual word level. Using coarser information, such as overall message sentiment, is not informative. This may explain the above-mentioned contrary previously-published results.
\item It takes a lot of weak positive words to maintain a healthy conversation, but only a few strong negative words can turn a conversation toxic.
\item The features that are predictive of health and toxicity are consistent between very different formats of conversations, and a preemptive detection system is therefore generalizable to multiple different online communities.
\item A conversation turns negative very quickly, and consequently negative predictors are concentrated in the few most recent messages. This puts a natural limit to the range of preemptive detection. This range limit seems to be of 3 messages in our results.
\end{enumerate}
The tasks of preemptive toxicity detection are still in its infancy, and there is still a lot of room for research. For example, work so far has focused on using regular conversation features as predictors. Future work could look at adding toxic text features such as insults and curse words, or even using the output of single-line toxicity detection tools as features.
\section*{Acknowledgments}
This research was made possible by the financial, material, and technical support of Two Hat Security Research Corp., and the financial support of the Canadian research organization MITACS.
| {'timestamp': '2020-06-19T02:03:39', 'yymm': '2006', 'arxiv_id': '2006.10145', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10145'} | arxiv |
\section*{Abstract}
The recent outbreak of COVID-19 has taken the world by surprise, forcing lockdowns and straining public health care systems. COVID-19 is known to be a highly infectious virus, and infected individuals do not initially exhibit symptoms, while some remain asymptomatic. Thus, a non-negligible fraction of the population can, at any given time, be a hidden source of transmissions. In response, many governments have shown great interest in smartphone contact tracing apps that help automate the difficult task of tracing all recent contacts of newly identified infected individuals. However, tracing apps have generated much discussion around their key attributes, including system architecture, data management, privacy, security, proximity estimation, and attack vulnerability. In this article, we provide the first comprehensive review of these much-discussed tracing app attributes. We also present an overview of many proposed tracing app examples, some of which have been deployed countrywide, and discuss the concerns users have reported regarding their usage. We close by outlining potential research directions for next-generation app design, which would facilitate improved tracing and security performance, as well as wide adoption by the population at large.
\section{Introduction}
\label{sec:Intro}
The year 2020 will be forever marked in history by the worldwide outbreak of the pandemic caused by Severe Acute Respiratory Syndrome Coronavirus 2 (SARS-CoV-2) a.k.a COVID-19. As the virus began to spread globally, the World Health Organisation (WHO) declared on the 30th of January 2020 that COVID-19 was a Public Health Emergency of International Concern (PHEIC) [1]. The virus outbreak has changed the lifestyle of everyone around the world forcing governments to mandate lockdowns, recommend self-isolation, stipulate work-from-home policies, instigate strict social distancing criteria, and deploy emergency health responses - the latter including substantial new infrastructure for the treatment and mass testing of the population at large. All these measures are aimed at decreasing the rate of spread of the virus and leading to a so-called \emph{`flattening of the curve'}\footnote{Flattening of the curve aims to decrease the infection rate so that the available health resources remain compatible with the infected caseload.} until an approved vaccine/treatment is developed.
COVID-19 is more infectious compared to other known viruses (such as SARS and MERS) albeit with a lower mortality rate. Furthermore, a COVID-19 carrier
can be contagious without experiencing any symptoms. Thus, by the time the carrier actually \emph{tests} positive they may have already spread the virus to many others who came in contact with them. This necessitates a process called `contact tracing,' to identify individuals who had close contact with the positive carrier, as these individuals may themselves now be infected.
Contact tracing is normally accomplished through a manual interview of the infected individuals, conducted by the health authorities. The aim of the interview is to collect contacts the infected individual had with other individuals in the past 14-21 days (identified as the incubation period for COVID-19). The health officials can then use that information to compute a risk-score for each of the contacts, based on the context (e.g., indoors/outdoors), duration, and proximity (distance between the contacts).
However, it is challenging for people to accurately recall each person that they may have met in the last three weeks. Besides, an infected individual might have infected many persons that they cannot identify, for example, contact with unknown persons standing in a supermarket checkout queue. Moreover, many subsequent interviews require a considerable workforce of health officials trained in the art of manual contact tracing.
In this context, researchers have been focusing on technological solutions to automate the contact tracing process with the aim of quickly and reliably identifying contacts that might be at significant infection risk. The ubiquity of smartphones and their ability to keep track of their location (e.g., via GPS and WiFi), along with their in-built Bluetooth interface allowing communication and proximity detection with nearby smartphones, makes them ideal devices for automated and reliable contact tracing. As a result, many smartphone contact tracing apps have been proposed, with some already deployed.\footnote{MIT Technology Review has a list of 25 such apps that have been developed and are being used in many countries \cite{mit}} Using the Bluetooth interface these tracing apps automatically collect the contact data of their users - data to be subsequently used in the future event of a user being identified as infected with COVID-19.
The introduction of contact tracing apps has led to a debate regarding their architecture, data management, efficacy, privacy, and security~\cite{V2020,bbc, duball, jennings, palmer, farrell}. Most of these apps claim to be privacy-preserving - meaning that they do not reveal any Personally Identifiable Information (PII), identity, or location information of the contacts without explicit user permission.
Indeed, privacy concerns associated with contact tracing apps are one of the factors that influence their adoption \cite{Redmiles}. Another primary concern of privacy advocates is the extent to which the apps can be re-purposed to track their users, and how the collected data may be used when the current pandemic ends.
This article describes the salient features of current contact tracing apps and provides insights into their privacy and security implications. Our article is based on public information about current tracing apps, and our understanding of the evolving protocols being designed for upcoming apps. Existing surveys on contact tracing apps~\cite{LG20, 672} are either not comprehensive or focus only on user privacy~\cite{T20}. The work in \cite{KBS20} describes formal notions of tracing app design. Our work differs from \cite{KBS20} in that we discuss not only vulnerabilities and privacy issues in design but also implementation and usability issues.
The remainder of this article is organised as follows. In Section \ref{sec:Arch}, we classify the tracing apps in three main architectures as centralised, decentralised, or hybrid. Section \ref{sec:Privacy} discusses the security, privacy, and data management implications of these different architectures. In Section~\ref{sec:proximity}, we highlight the Bluetooth Low Energy (BLE)-based proximity estimation technique used in most of the tracing apps. The most common attacks and vulnerabilities that could affect tracing apps in discussed in Section~\ref{sec:Attacks}. In Section~\ref{sec:apps} a more detailed analysis of the most widely discussed apps is presented, and some common user concerns associated with these apps analysed in Section~\ref{sec:commonconcerns}. In Section~\ref{sec:future} potential future research directions are given. Finally, Section \ref{sec:concl} concludes this article.
\begin{figure}[htb]
\centering
\includegraphics[width=0.75\textwidth]{figures/MainArch.pdf}
\caption{Tracing apps centralised architecture}
\label{fig:mainArch}
\end{figure}
\section{System Architecture}
\label{sec:Arch}
The type of architecture adopted for the data collection aspects of tracing apps has been a matter of much discussion due to both security and privacy concerns. We will discuss three distinct system architectures commonly used or proposed for developing COVID-19 tracing applications. These are the \textbf{centralised}, the \textbf{decentralised}, and the \textbf{hybrid} approaches that combine features from both the centralised and the decentralised architectures.
Our classification criteria consider how the server is used and what data is required (or stored) by it. We now discuss each of the three architectures detailing their salient features. We will discuss some specific tracing apps that employ each of our three architectures in a later section.
\subsection{Centralised}
\label{sec:cen}
Figure \ref{fig:mainArch} shows the main entities and interactions of a centralised architecture. We note that the centralised architecture we describe is based on the Bluetrace protocol \cite{bluetraceWhitepaper}. The initial requirement for the app is that a user has to pre-register with the central server. The server generates a privacy-preserving Temporary ID (TempID) for each device. This TempID is then encrypted with a secret key (known only to the central server authority) and sent to the device. Devices exchange these TempIDs (in Bluetooth encounter messages) when they come in close contact with each other. Once a user tests positive, they can volunteer to upload all of their stored encounter messages to the central server. The server maps the TempIDs in these messages to individuals to identify at-risk contacts. More details on the centralised architecture's key processes are now given.
\subsubsection{Registration Phase}
Figure~\ref{fig:register} shows the steps required to register a user in a centralised architecture. A user downloads the app (steps 1 and 2) and registers details such as name, mobile phone number, age bracket, and postcode with the server (step 3). The server verifies the mobile number by sending a One Time Password (OTP) by SMS (steps 4 and 5). Upon verification, the server computes a TempID (step 6), which is only valid for a short time (Bluetrace recommended expiry time is 15 min). The TempID and the expiry time are then transmitted to the user's app.
\begin{figure}[htb]
\centering
\includegraphics[width=0.48\textwidth]{figures/Registration.pdf}
\caption{Centralised tracing app registration process}
\label{fig:register}
\end{figure}
\subsubsection{Registering encounters/contacts information}\label{Cen-EncMessage}
Once a user comes in contact with another app user, they exchange an ``Encounter Message" using Bluetooth, as presented in Figure~\ref{fig:operation}. An encounter message comprises the exchange of TempID, Phone Model, and Transmit Power (TxPower) (steps 1 and 3). Each device also records the Received Signal Strength Indicator (RSSI) and the timestamp of the message delivery (steps 2 and 4). Note that phone numbers are not included in these messages. Since the TempIDs are generated and encrypted by the server they do not reveal any of the app user's personal information. Thus, both app users have a symmetric record of the encounter that is stored on their respective phones' local storage. The protocol uses a temporary blacklist to avoid a user registering duplicated contacts. Thus, once a user receives an Encounter Message, the app automatically blacklists the sender for a short time.
\begin{figure}[htb]
\centering
\includegraphics[width=0.7\textwidth]{figures/Operation.pdf}
\caption{Centralised tracing app contact exchange operation}
\label{fig:operation}
\end{figure}
\subsubsection{Uploading encounters data}
All encounter records are stored locally and are not automatically uploaded to the server. Figure~\ref{fig:notification} shows the application flow when a user tests positive for COVID-19 (step 1). The health official confirms whether the user has the tracing app installed, and flags the user as infected (step 2). The encounter data upload is voluntary. If the user agrees to upload the data, the health official sets this up in the back-end server, and the server generates an OTP for verification (step 3). Once verified, the encounter data is uploaded to the server (step 4).
\begin{figure}[htb]
\centering
\includegraphics[width=0.7\textwidth]{figures/Notification.pdf}
\caption{Centralised tracing app notification}
\label{fig:notification}
\end{figure}
\subsubsection{Server-side processing of the uploaded data}
The server iterates through the list of encounter messages, decrypting each TempID with its secret key. This TempID is then mapped to the user's mobile number. The server uses the TxPower and RSSI values to approximate the distance (proximity) separating the users during the reported encounter. The proximity estimation can also be performed locally on the phone, but this has battery usage implications. This proximity data, in conjunction with the timestamps, is used to ascertain the risk profile (closeness and duration) of the encounter (step 5, Figure \ref{fig:notification}). A list is prepared with all the required information (step 6) for further processing by the relevant health official (step 7).
\begin{figure*}[htb]
\centering
\includegraphics[width=0.9\textwidth]{figures/de-overview.pdf}
\caption{Tracing apps decentralised architecture.}
\label{fig:de-overview}
\end{figure*}
To summarise: In the centralised architecture, the central server plays a key role in performing core functionalities such as storing encrypted PII information, generating anonymous TempIDs, risk analysis, and notifications for close contacts. This accumulation of responsibilities raises privacy concerns that are discussed in detail in Section \ref{sec:Privacy}. The server is assumed trusted in this architecture, with some countries introducing strict privacy-protection regulations for safeguarding the use and life cycle of the collected data \cite{regulation1}.
\subsection{Decentralised}
\label{sec:dec}
In contrast to the centralised architecture, the decentralised architecture proposes to move core functionalities to the user devices, leaving the server with minimal involvement in the contact tracing process. The idea is to enhance user privacy by generating anonymous identifiers at the user devices (keeping real user identities secret from the other users as well as the server) and processing the exposure notifications on individual devices instead of the centralised server. We discuss the privacy and security implications of this design in Section \ref{sec:Privacy}.
We take the Private Automated Contact Tracing protocol (PACT) \cite{pact-ec} as a base to describe the decentralised architecture. The decentralised approach does not require app users to `pre-register' before use, thus avoiding the storage of any PII with the server. Devices generate their random seeds (used as input for a pseudorandom function), which are used in combination with the current time to generate privacy-preserving pseudonyms or `chirps' with a very short lifetime of about 1 min (see Figure~\ref{fig:de-overview}). These chirps are subsequently periodically exchanged with other devices that come in close contact. Once a user is positively diagnosed with COVID-19, they can volunteer to upload their seeds and the relevant time information to a central server.
This is in contrast to the centralised architecture where the complete list of encounter messages is uploaded. Uploading of seeds, instead of all used chirps, improves latency and provides improved bandwidth utilisation.
The central server only acts as a rendezvous point, akin to a bulletin board to advertise the seeds of the infected users. This server is considered `honest-but-curious'. Other app users can download these seeds to reconstruct the chirps (by using timestamps) that were sent by the infected users. The server, as well as other users, cannot derive any identifying details just by knowing the seeds and chirps. Only the other app users can perform a risk analysis to check if they are exposed for a long enough duration. This one-way lookup against the downloaded seeds restricts the server's functionality and alleviates some of the privacy risks (see Section \ref{sec:Privacy}). More details on the decentralised architecture's key processes are now given.
\subsubsection{App Installation}
COVID-19 tracing apps that adopt the decentralised architecture do not necessarily require an interactive registration process during the app installation stage. The app installation process only verifies a user's smartphone and deploys a random seed generation algorithm that is not linked to the phone (see Figure~\ref{fig:de-install}).
\begin{figure}[htb]
\centering
\includegraphics[width=0.7\textwidth]{figures/de-install.pdf}
\caption{Decentralised tracing app installation process}
\label{fig:de-install}
\end{figure}
\subsubsection{Generating seeds, chirps and exchanging chirps}
\label{De-Chirps}
Once the decentralised tracing app is installed, the seed is generated (with an expiry period of one hour) by the user's device (see Figure~\ref{fig:de-encounter}). This seed and the current time are subsequently used in a pseudorandom function to generate the chirp.
\begin{figure}[htb]
\centering
\includegraphics[width=0.7\textwidth]{figures/de-encounter.pdf}
\caption{Decentralised tracing app encounter exchange}
\label{fig:de-encounter}
\end{figure}
The chirps are not linked to an individual or their phone - so in principle, they are anonymous. The app generates new chirps with a time granularity of 1 min.
These are broadcasted every few seconds via the Bluetooth beacon. In the listener's phone, the app will automatically store all chirps received (step 4 in Figure~\ref{fig:de-encounter} ). The information stored in the receiving app includes the chirp, the timestamp when the chirp is received, and the maximum RSSI value. Identical chirps received within 1 min are ignored.
Note the critical difference from the centralised architecture where TempIDs are created by the server - in the decentralised case, the seeds and chirps are generated at the device.
\subsubsection{Uploading encounters data}
\label{De-upload}
If a user is diagnosed positive, they are given a unique ``permission number" by the relevant authority to authorise the upload of all used seeds that are locally stored in their phone (illustrated in Figure~\ref{fig:de-trace}), as well as the creation and expiry times of the seeds. Note, the server in the decentralised architecture only gets the seeds associated with a single identified user. This is to be compared with the centralised architecture where the complete contact list (with TempIDs) of all encountered individuals is uploaded to the server.
\begin{figure}[htb]
\centering
\includegraphics[width=0.7\textwidth]{figures/de-trace.pdf}
\caption{Decentralised tracing app tracing process}
\label{fig:de-trace}
\end{figure}
\begin{figure*}[htb]
\centering
\includegraphics[width=0.9\textwidth]{figures/Hybrid_Main.pdf}
\caption{Hybrid tracing app architecture}
\label{fig:hybrid}
\end{figure*}
\subsubsection{The contact tracing process}
\label{De-tracing}
Contrary to the centralised architecture, the tracing process in the decentralised architecture is performed locally by the app user on their device (instead of the central server). The app users can communicate with the server, typically once per day, to download any seeds uploaded by infected users. Given such seeds are downloaded (step 8 in Figure~\ref{fig:de-trace}), the user's app then reconstructs all the corresponding chirps (using pseudorandom calculations based on the seeds and discrete-time intervals between the start and expiry time). Finally, the app performs a lookup to check if any of the reconstructed chirp information appears in its local encounter chirp log. If so, proximity and duration times are then derived (based on timestamps and RSSI values) for risk analysis purposes. No human intervention is required.
\subsection{Hybrid}
\label{sec:hybrid}
In the centralised architecture, the server performs all the complex tasks, e.g., TempID calculations, encryption, decryption, risk analysis, and notifications of alerts for the at-risk contacts. On the other hand, all these functionalities are delegated to devices in the decentralised architecture, keeping the server only as a bulletin board for lookup purposes. The hybrid architecture proposes that these functionalities are split between the server and the devices. More specifically, the TempID generation and management remain decentralised (i.e., handled by devices) to ensure privacy and anonymisation, whilst the risk analysis and notifications should be the responsibility of the centralised server. There are three main reasons for performing the tracing process at the server: \textit{i}) In the decentralised architecture, the server is unaware of the number of at-risk users as the devices make this risk analysis without taking the server into consideration. Thus, the server does not have any statistical information and is unable to run any data analytics to identify exposure clusters. \textit{ii}) Risk analysis and notifications are considered a sensitive process that should be handled by the authorities, keeping the existing infrastructure resources and state of the pandemic in mind. \textit{iii}) The uploaded encounter information from infected users is not made available to the other users but retained only at the server. This is to avoid user de-anonymisation attacks (details in Section \ref{sec:linkage}) possible in the decentralised architecture.
Figure \ref{fig:hybrid} shows the interaction sequence in the hybrid architecture based on the Desire protocol \cite{Desire}. This protocol requires the user's app registration process to assign a unique device ID without recording any PII. Devices then cryptographically generate and exchange Ephemeral IDs with other devices over BLE. For each received EphID, two un-linkable Private Encounter Tokens (PETs) are generated and stored to represent an encounter. Once a user has tested positive, a list of the locally generated PETs is uploaded to the server. Any device can now send their second generated PET tokens to the server, which then performs risk analysis and notification. The server cannot infer any identifying information from the PETs, and all communication between the server and devices is routed through a proxy or anonymisation network. More details on the hybrid architecture's key processes are now given.
\begin{figure}[htb]
\centering
\includegraphics[width=0.48\textwidth]{figures/Hybrid_Registration.pdf}
\caption{Hybrid tracing app registration process}
\label{fig:hybridRegister}
\end{figure}
\subsubsection{Installation and registration}
The registration process in the hybrid architecture requires a two-step authentication process, wherein the phone number is verified by the OTP, and the app is verified through an authorisation token issued by the server. Figure \ref{fig:hybridRegister} shows the process. As the server is not allowed to store any PII, it deletes the phone number after verification. The server then assigns the app a unique ID and generates an encryption key that is sent to the app. The server then deletes the encryption key. The client, in the future, will identify themself using this ID.
\subsubsection{Generating and exchanging Ephemeral IDs}
\begin{figure}[htb]
\centering
\includegraphics[width=0.8\textwidth]{figures/Hybrid_encounter.pdf}
\caption{Hybrid tracing app encounter process}
\label{fig:hybridEncounter}
\end{figure}
In the operation phase, the device generates a new Ephemeral ID (EphID) using the Diffie Hellman key exchange mechanism \cite{DH}, which is valid for typically 15 min and synchronised with the Bluetooth MAC address rotation interval. The device starts broadcasting this EphID (= $g^a$) through Bluetooth. Once an EphID is received from another device (say with exponent b), the app generates two PETs \{PET1 = $H('1'| g^{a.b})$, PET2 = $H('2'| g^{a.b})\}$. The app maintains two tables, referred to as upload and query tables. One PET is stored in the query table, and the other one, along with the time and duration of the contact, is stored in the upload table.
\begin{figure}[htb]
\centering
\includegraphics[width=0.8\textwidth]{figures/Hybrid_notification.pdf}
\caption{Hybrid tracing app notification process}
\label{fig:hybridNotification}
\end{figure}
\subsubsection{Uploading Encounter data}
Once a user is diagnosed with COVID-19, explicit consent is required for the data upload. The user uploads ID, encryption key, and PETs in the upload table along with time and duration values (steps 1-3 Figure \ref{fig:hybridNotification}). The server records these PET values and associated data and uses the encryption key to update the user record (status).
\subsubsection{Contact tracing process}
Any user who wants to check their risk exposure to an infected case uploads the PETs in the query table to the server by using a proxy or anonymisation network (step 5 Figure \ref{fig:hybridNotification}). The server performs risk analysis by matching the PETs from the query table with the PETs uploaded by the infected user. Using the time and duration values, the server evaluates whether the user is at-risk or not. Any at-risk user is notified through the app to contact the health authority. Note that the server is not able to identify any user based solely on their PET values.
\subsection{Architecture summary}
We have discussed the three base architectures employed for developing applications for contact tracing purposes. The architectures are categorised based on the functionality and level of privacy preservation at the central server. In the centralised architecture, the server manages the security keys, generation of anonymous IDs, contact risk analysis, and notification processes. All these roles are transferred to the devices in the decentralised architecture while the server acts simply as a bulletin board. The hybrid architecture tries to balance the load on the server and improve privacy preservation by splitting functionalities between the end-user device and the server.
One distinct advantage of using an architecture that pushes the risk analysis and notification process to the centralised server (i.e., both centralised and hybrid architectures) is that health officials can decide the rate of notifications depending on the pandemic circumstances (e.g., the availability of test kits). On the other hand, decentralised and hybrid architectures aim to keep the user identities secret from the central server. A server security breach in this latter architecture would, therefore, result in lower information leakage.
\section{Data Management, Privacy and Security}
\label{sec:Privacy}
One of the major issues in any tracing application is management, privacy, and security of the data that is collected. The European Data Protection Board issued a statement on the importance of protecting personal data while fighting COVID-19 and flagged articles of the General Data Protection Regulation that provide the legal grounds for processing personal data in the context of epidemics \cite{aruna1}. In addition, some Governments' have passed special privacy protections laws aimed at addressing privacy issues \cite{aruna2}. To comply with these requirements, the tracing apps need to use a multitude of techniques, across the three distinct phases of their operation: i) Registration, ii) Operation, and iii) Positive case identification phases, depending on:
\begin{itemize}
\item What data is produced and by whom?
\item What data is exchanged between whom and when?
\item What data is stored where and by whom?
\item Who can access what piece of data?
\end{itemize}
In this section, we will first discuss the data life cycle for the three architectures described in Section \ref{sec:Arch} and then focus on the privacy and security issues associated with these architectures. We consider three key stakeholders in the attack ecosystem; i) the government ii) the administrator controlling the central server (referred to as server for brevity), and iii) malicious users. All architectures assume that health authorities\footnote{Health authorities include health officials, testing centres, and allied facilities managing COVID-19.
}
already know the real identities of all positive cases as all uploads are authorised through the health authorities to prevent fake data being uploaded.
\begin{table*}[ht]
\footnotesize
\centering
\caption{Data storage for centralised tracing architecture}
\label{table:DLC-C}
\begin{tabular}{ |c|l|l|l| }
\hline
Storage & Registration phase & Operation phase & Positive case identification phase
\\
\hline
Server & Phone Number, Name, & Generates and stores & List and contact details of all
\\
& Age range, ZIP code & TempIDs for each user & i) positive cases
\\
& & &ii) close contacts of each positive case
\\
\hline
Devices & - & Own TempID \& Phone model& -
\\
& & Encounter messages received from contacts&
\\
& &(TempIDs of contact, time stamp, RSSI &
\\
& &TxPower, Phone model) &
\\
\hline
\end{tabular}
\end{table*}
\begin{table*}[ht]
\footnotesize
\centering
\caption{Data storage for decentralised tracing architecture}
\label{table:DLC-D}
\begin{tabular}{ |c|l|l|l| }
\hline
Storage & Registration phase & Operation phase & Positive case identification phase
\\
\hline
Server & - & - & Seeds (and validity period) received from all positive cases
\\
& & &
\\
\hline
Devices & - & Generates own seeds and chirps& Seeds for all positive cases received from the server
\\
& & &
\\
& &Chirps received from contacts,& Generates chirps based on seeds/validity period of positive cases
\\
& &time stamp, RSSI &
\\
\hline
\end{tabular}
\end{table*}
\subsection{Data management}
\label{sec:data}
Details of data storage in the centralised architectures appear in Table \ref{table:DLC-C}. The server is responsible for i) storing PII collected when a user registers, ii) generating, storing and transferring the TempIDs to all registered users periodically (after every 15 min for example), and iii) maintaining a list of all individuals who are diagnosed as positive and their close contacts. In contrast, the user device, after receiving the TempID from the server, carries out the following two tasks: i) it generates, exchanges and stores the contacts it has had with peers for a specified period of time, usually 21 days, and ii) upon request, it shares contact data it has stored with the server with the consent of the user.
Data storage details for the decentralised architectures are presented in Table \ref{table:DLC-D}. The user devices are responsible for generating the hourly seed and computing the chirps based on the seed and the current time. In addition, they are responsible for exchanging and storing these chirps, the RSSI, and the received timestamp information with peers. There is also the option for the device to store additional metadata, such as location information. The server plays a limited role compared to the centralised architecture. It is only called into action when a user is diagnosed as COVID-19 positive and voluntarily uploads the seeds and time validity data as described in Section ~\ref{De-Chirps}. This data, stored at the server, can now be used for lookup by other users who have come in contact with the infected user, by reconstructing the chirps using the seeds.
\begin{table*}[ht]
\footnotesize
\centering
\caption{Data storage for hybrid tracing architecture}
\label{table:DLC-H}
\begin{tabular}{ |c|l|l|l| }
\hline
Storage & Registration phase & Operation phase & Positive case identification phase
\\
\hline
Server & Device ID & Device ID & Stores PETs (and validity period) received from all positive cases
\\
& & & Stores metadata about positive cases
\\
& & & Stores query PETs from other users
\\
\hline
Devices & Device ID, & Generates and store own EphID & -
\\
& & &
\\
& Encryption key & Maintain two tables of PETs &
\\
& &Stores timestamp, duration &
\\
& &and signal strength for PETs &
\\
\hline
\end{tabular}
\end{table*}
Table \ref{table:DLC-H} shows data storage during the various phases of hybrid tracing architecture. In the operation phase, the devices store all encounters as PET entries in two different tables. The server records the device IDs (with blank metadata such as risk score, notified or not, etc.). The server only obtains the PETs from users who have tested positive and volunteers to upload this information. Another significant difference from the decentralised architecture is that these PETs are not transferred to other devices; rather, other devices upload their PETs from their query table for a risk analysis to be carried out by the server.
\subsection{Privacy}
The success of any automatic contact tracing app depends on several factors, including: how seamlessly and accurately it can capture close contacts. Another factor is the confidence the users have about their privacy and security when using the app. A naive approach for contact tracing could be to develop a privacy-agnostic system that advertises and exchanges the mobile phone numbers of the participants and periodically registers their location with a centralised server \cite{pact-ec}. Such an application would raise serious privacy concerns, and would likely not be accepted by users. Therefore, all the architectures have privacy protection built-in. However, the amount of protection provided differs considerably and depends on the attack models, trust assumptions, and the protection measures they adopt \cite{Fraunhofer}.
In the previous section, we discussed the data management aspects highlighting the source and storage of different types of data in the three architectures. From a privacy perspective, we classify the data that is to be stored into three categories: i) PII of participants (e.g., names, phone numbers, whether they have tested positive to the virus or not, etc.), ii) Contact advertisement messages (pseudonyms exchanged between devices), and iii) Social/proximity graphs; an indication of the interactions between users and the people they came into close contact with. Each data category has different privacy implications.
We first explore the smartphone's privacy implications, as it is typically less secure than a server. In this case, attacks like theft or coercion (a user being forced or persuaded) will result in the content stored in the smartphone being revealed. This type of threat is present in all of the architectures. However, the difference between the different architectures is what is stored on the smartphones (see Tables \ref{table:DLC-C}, \ref{table:DLC-D}, \ref{table:DLC-H}). Data that may be stored on devices, such as details of encounter messages, is considered to be less sensitive, as this information cannot be used to directly identify the contacts.
In a centralised architecture, the servers have access to all three types of data. Therefore, if access to the servers is compromised by malicious users, it would be possible to identify all individuals and their contacts, therefore jeopardising their privacy.
Hence, centralised architectures need to provide adequate protection of the servers to guarantee user privacy.
In the decentralised architecture, all users can access the public server to download the list of seeds and calculate the chirps used by an infected user. However, as these seeds are uploaded together with their expiry periods, they can result in the unauthorised identification of infected individuals using other side-channel information. For example, malicious persons/apps/organisations can keep collecting the ephemeral identifiers and the seeds from reported cases and link the identifiers/chirps with the accessed auxiliary information. Also, as only an infected user uploads seeds to the server, a traffic analysis attack, launched by a malicious user who can eavesdrop, would be able to identify a COVID-19 positive user uploading seeds to the server. These attacks are discussed further in section \ref{sec:Attacks}.
The hybrid architecture adopts additional advanced privacy enhancement methods such as secret sharing \cite{secretSharing}, decisional Diffie-Hellman (DDH) \cite{ddh}, and private set intersection \cite{PSI}\footnote{Readers are encouraged to follow the provided references for details of these privacy preserving, secret sharing techniques.}. In general, a user's secret is shared by the user and the server. Furthermore, part of the infection risk analysis is computed at the server using privacy preserving secret sharing. Therefore, if one party is compromised, the entire secret or risk analysis result will not be revealed. These privacy enhancement methods help protect the identity of infected users from being revealed by malicious users or compromised servers. However, these enhanced privacy protections still cannot prevent the users' PII getting de-anonymised if a malicious user can successfully access data collected from side-channel context information.
\subsection{Security}
The notion of security encompasses limiting an adversary's abilities to introduce false negatives and false positives in the system, in addition to ensuring system integrity and availability. The motivation for carrying out an attack varies and can range from political and ideological to financial. In the context of contact tracing, an attacker may aim to inject erroneous entries or cause a denial of service.
As all three architectures discussed in this article involve a centralised server, it is pertinent to explore the specific security threats for each of the architectures. The potential security threat depends on what data originates from a server, what data is shared and accessible to a server and in what form the data is collected and stored (e.g., pseudonymous, encrypted, unencrypted). Furthermore, it depends on the modus operandi of the server, namely whether it is i) A trusted server, ii) An honest-but-curious server, iii) A compromised/malicious server, or iv) A colluding server.
A malicious/compromised server can disrupt all types of communications or inject false exposure notifications in all architectures. Similarly, a colluding server can liaise with other malicious entities to perform user de-anonymisation.
In the centralised architecture, the server is considered trusted. It is responsible for storing users' PII and managing security keys used to encrypt/decrypt TempIDs. This poses the risk of data theft if the server gets compromised, a general threat against any centralised server. In this context, the server application needs to run in a trusted environment and use appropriate authentication and access control mechanisms. All information exchanged between the server and the user's smartphone as well as between the server and the health officials needs to be authorised and secure. Thus, centralised architectures only consider malicious users in their attack models and aim to keep the information of all users secure to prevent loss of users' privacy as described in Section \ref{sec:linkage}. This ensures that no malicious third party can access any information sent/received or exfiltrate information. However, malicious users in centralised architectures could exploit the un-authenticated BLE contact information exchanged between devices to spread incorrect contact information by relaying or replaying. This type of attack, discussed further in Section \ref{sec:replay}, would result in false positives during the contact tracing process, forcing users to be incorrectly notified as close contacts.
Decentralised and hybrid architectures, on the other hand, assume an honest-but-curious server that performs all the tasks assigned to it and passively harvests sensitive data, if available. The attack model considers the government and the server to be untrustworthy and only reveals users' identities to the health authorities. As mentioned earlier, the primary user concern relates to the government using the data for purposes other than contact tracing. Therefore, these architectures aim to hide the user identities and generate anonymous IDs for the devices, thereby preventing the ability of the server to link IDs to user information. The decentralised architecture delegates data management to users' smartphones, making the solution more robust against a single point of failure/attack, such as the central server. However, the decentralised architecture still requires a minimally functioning central server. Therefore, it will be vulnerable to a much lower number of server-based attacks. In decentralised architectures, anonymous IDs are uploaded to the server, which are then potentially accessible by other smartphones for matching. Thus an honest-but-curious server will not be able to learn any PII, link the anonymous IDs or build social graphs unless it has access to some side-channel information. In case of a data breach, there will be no impact as the attackers only have access to the seeds/tokens of infected users, which are already public.
A malicious user, on the other hand, can still cause false positives by relaying the chirps and launch Denial of Service (DoS) attacks by broadcasting fake but correctly formatted advertisements.
The hybrid architecture carries out the contact risk analysis and notification processes at the server. This prevents any re-identification/de-anonymisation attacks, as discussed in Section \ref{sec:Attacks}. In addition, the hybrid architecture provides additional mechanisms to hide user identities from the server while enabling centralised matching of contacts. Similar to the decentralised architectures, it proposes the generation of ephemeral IDs at the devices. The rationale is that devices keep full control over their secret identifiers, making them less susceptible to breaches at the server.
\section{Proximity Estimation}
\label{sec:proximity}
The chance of becoming infected with COVID-19 increases with prolonged and close contact with an infected person. Hence, estimations of distance (a.k.a proximity) and the duration of contact are important pieces of information used to assess the potential spread of infection. Contact tracing apps aim to record such encounters. A smartphone-based automated contact tracing system mainly utilises two (sensor) technologies: GPS and Bluetooth, for proximity estimation\footnote{We note that WiFi can also be used for limited proximity estimation \cite{WiFi}. However, it requires the necessary infrastructure support and setup.}.
GPS used in navigation systems can provide reasonably accurate location information within the margin of error, especially when used outdoors. However, the storage of absolute location information comes with privacy costs if transferred to the server. Moreover, GPS is not suitable for proximity estimation in COVID apps for several reasons: i) GPS performs poorly in heavily built-up outdoor spaces such as the CBD; ii) GPS does not generally work indoors and, when it works, provides very low accuracy and iii) it consumes power rapidly and can drain the mobile battery quickly if used for a prolonged period.
The Bluetooth interface present in most modern mobile phones is able to capture the Received Signal Strength Indicator (RSSI) values, assisting in proximity estimation \cite{BTProximity}. The wireless signal emitted from a transmitter decays/attenuates as it travels through the air. Equation \ref{eq:1} shows this behaviour where the average $RSSI$ (in dBm) at a distance $d$ from the transmitter is given by
\begin{equation}
\label{eq:1}
RSSI (dBm) = RSSI_{(d_o)}(dBm) -10 n \mathrm log_{10}(d/d_o)
\end{equation}
where $RSSI_{(d_o)}$ is the average RSSI (in dBm) at the reference distance of 1m, and $n$ is the path loss exponent \cite{rappaport}.
The receiver can approximately estimate how far away the transmitter is by recording the RSSI values. However, there are several issues with proximity estimation solely based on RSSI values. The wireless signal can be influenced by several factors other than distance. The objects in the operating environment\footnote{Some of the environmental factors are captured by variation in the path loss exponent $n$.} such as furniture, walls, people, etc. in the path between a sender and a receiver impact the signal attenuation. Other wireless signals using the same frequency may also cause interference and further attenuate the signal. Besides, different mobile phones transmit Bluetooth signals with different power levels, affecting the distance estimation \cite{rssi}. Finally, transmission patterns from the same phone vary based on the phone's orientation (specifically its antenna) and the presence or absence of a phone case. These effects can be somewhat mitigated by calibrating the RSSI values/signal attenuation based on known transmit powers.
However, we should be clear that any mitigation strategy aimed at countering the above-mentioned negative impacts on proximity accuracy can only have a limited impact in real-world channel conditions. We must bear in mind that Eq.~\ref{eq:1} represents a simple shadowing model with two free parameters - the path loss exponent and the variance of the noise signal. These unknowns can lead to important uncertainty in the proximity determination. Whilst it is true that a formal location-error analysis on a log-normal shadowing channel can be achieved even in the presence of a-priori unknown values for the path loss exponent and noise variance \cite{malaney}, we do need to understand the limitations of such information-theoretic constructs. Formal analyses of Eq.~\ref{eq:1} leads to Cramer-Rao Bounds on the location accuracy of order a few meters, but due to the implicit model dependence the accuracy in practice can be substantially larger. Claims of ``guaranteed'' accuracy of order 1m by any current app should therefore be considered with some scepticism. Along these same lines, we should note there could be other channel models that better describe how signal strength varies with distance in real-world scenarios. It could well be the case that models with more than the two free parameters are required. Further, it is very likely that the usefulness of any such model is dependent on both time and geographical location. However, as we discuss later when we consider future research directions, it should be possible in future tracing apps, built on new hardware platforms (delivering nanosecond timing accuracy), to truly deliver 1m accuracy with a very high degree of confidence.
To summarise, with the techniques used by current apps for proximity estimation, there would still be many false positives and false negatives. The proximity estimate may indicate close contact, whereas the actual contact is far off or erroneously indicates that it is far off when it is nearby. Similarly, a close contact as perceived by distance estimation does not always translate into an exposed case as there may be a wall/obstruction between the two individuals (e.g., two adjacent apartments), or the contact has occurred in open space where chances of infection are lower. However, getting false positives is not as disastrous, as they only result in additional tests for these false cases. False negatives are a more significant issue as these are considered a missed opportunity to register contact with a positive case. However, we believe that the data from these apps, in conjunction with other contextual information obtained during the interview, would help health professionals to make better decisions.
\section{Attacks}
\label{sec:Attacks}
In this section, we will cover some of the possible attacks that can be launched against different app architectures.
\subsection{Replay/Relay Attack}
\label{sec:replay}
For these attacks, the goal of an adversary is to force the users to store misleading contact information, resulting in false positives. This is achieved by forwarding any message received from honest users at the same or a different location. The adversary requires minimal resources to launch this attack but may use directional antennas to extend the area of its influence further.
A relay/replay attack is the simplest of the attacks that can be launched against users of a tracing app. An adversary can capture the advertised message by a user and immediately relay the captured message at the same location, extending the range of the message, or replay it at another location later on. Note that we classify an attack in this category if the replayed/relayed message has a valid ID (the TempID or chirp); otherwise, it is categorised as a DoS attack (discussed later in Section \ref{sec:dos}).
As the TempID has a short expiry time in centralised systems (Bluetrace recommended 15 min),
the replay attack can be launched before the expiry of the advertised TempID.
If any person who has received this replay message tests positive, the originator will be identified as a close contact of the affected person (false positive) and may be asked to get tested. A more focused attack is also possible if the replay attack is executed near an epidemic testing clinic or a treatment ward/hospital. Individuals already diagnosed with COVID-19 therefore register the replayed messages as a close contact.
The decentralised version has marked differences in behaviour when viewed with the lens of replay/relay attacks. The chirp generation mechanism, as discussed in Section \ref{De-Chirps}, involves using a seed that is valid for 1 hour. The current timestamp randomises the chirps with 1-minute precision. Finally, the receiver records the time at which each chirp is received. During the tracing process, described in Section \ref{De-tracing}, the app validates the received timestamp of each stored chirp with the time of creation of each reconstructed chirp, only accepting the received chirp as valid if these two times approximately match. This mechanism provides safeguards against the replay attack. Theoretically, it can still be launched within 1 minute of the chirp message's expiry time. Relay attacks can still be effective as these are not delayed, resulting in valid chirps.
With hybrid architectures, it is still possible to launch relay attacks, as symmetric information would still exist in the PET tables, maintained by two hosts with a malicious relay. However, the replay attacks are not possible as only one of the users would receive the replayed EphID, and the calculated PETs would only exist for the receiver of the replayed message. If that receiver tests positive, the uploaded replayed PETs would not match with any other PET.
Another difference between the centralised and the decentralised architectures w.r.t. the replay attack is the scope of potential targets. In the centralised version, the victim is the originator \emph{(a single person)} of the message being replayed while in the decentralised version, victims are the \emph{multiple} recipients of the replayed message. If the originator tests positive, he/she will upload the seeds to the server (see Section \ref{De-upload}). The recipients of the replay messages will identify themselves as close contacts with the originator by comparing the originator's uploaded encounter chirps. On the other hand, in the centralised version, if any person who has received the replay/relay message tests positive, the originator is falsely identified as a close contact. On the other hand, the relay attack has the same purview in all architectures, affecting both the originator and the recipient of the relayed encounter message.
\subsection{Wireless device tracking}
\label{subsec:device-tracking}
The attacker's goal in this type of attack is to track the device by the BLE information broadcast by the COVID-19 tracing apps.
Consider a shopping mall that wants to track the general movement pattern of its customers. It can deploy BLE nodes, like Apple's iBeacons, strategically throughout the entire shopping centre, passively listening for advertisements from tracing apps. These nodes can send the captured BLE messages to a central tracking server for further processing. The tracking server can now use simple triangulation~\cite{triangulation} and timestamps to estimate the location of each device. This enables tracking, even recording how much time each customer (device) spends in each store.
For apps that use the centralised architecture, TempIDs and phone model information can be used to to uniquely identify a device. Since TempIDs are changed after a short time (typically 10-15min), tracking a device beyond the point where the device starts advertising a new TempID would require extra intelligence to link the two TempIDs (also see Section \ref{CO Attack}) to the same device, advertising the same phone model. In the decentralised architecture, chirps with a 1-minute lifetime provide limited opportunity for tracking. The tracking server can still enumerate the total number of users in the area, however it is difficult to track the movement of a device without a phone model. The tracking, in this case, would be applicable to limited scenarios e.g., a few customers in a shop or if user’s device is stationery.
Hybrid architectures behave like the centralised architecture as the devices advertise EphID with a lifetime of 15 minutes, making it possible to track a device based on EphIDs.
\subsection{Location confirmation}
\label{sec:locationConf}
In this attack, the attackers' goal is to discover the presence of a user in a known location/environment, such as a neighbourhood. The BLE advertisements and information contained in the exchange of encounter messages in the centralised architecture can be used to confirm a user's location. For example, assume that Alice is the only one in her family who owns an iPhone 9, and this is known to an adversary, Eve. Eve can confirm whether Alice is at home by listening to the encounter messages that include Alice's phone model information. One simple way to mitigate this issue is to include the mobile model number in the registration process. This way, the server still has the required model number information for proximity calculations (see Section \ref{sec:proximity}), and the phone model number can now be excluded from the encounter messages. A location confirmation attack is not possible in decentralised or hybrid architectures due to the use of ephemeral chirps/IDs and the suppression of user/device linking information.
\subsection{Enumeration Attack}
\label{sec:Enum}
The primary goal of this attack is to count the number of users who have tested positive. Enumeration refers to any user's ability to estimate the number of users infected with COVID-19, who have volunteered to upload their contact tracing data to the server. Note that enumeration does not include the server's ability to count the number of positive cases. In the centralised architecture, the information regarding positive cases and their close contacts remains within the server, therefore preventing users from enumerating.
\begin{figure}[htb]
\centering
\includegraphics[width=0.6\textwidth]{figures/BloomFilter.pdf}
\caption{Encoding chirps into a Bloom Filter.}
\label{fig:bloomfilter}
\end{figure}
In the decentralised architecture, each positive case uploads all of their seed from the last 21 days (21 days x 24 seeds per day = 504 seeds). All app users can download the list of all seeds from the server and can estimate the number of positive cases. One option to conceal this information is to calculate all the chirps at the server and store these in a bloom filter (\cite{Boston} and Section \ref{sec:dp3t-2}). This bloom filter (see Figure \ref{fig:bloomfilter}) is then retrieved by the app to check for matches with their contact chirps, without revealing other details. The enumeration attack can also be mitigated, in the decentralised architecture, if the infected user is provided with the capability to redact some contact information while uploading their contacts. Enumeration attacks are not possible in the hybrid architecture as the server conceals the list of infected user IDs from other users.
\subsection{Denial of Service}
\label{sec:dos}
The goal of this attack is to consume the resources (battery, bandwidth, processing, etc.) available in the system (user mobile, server). In this regard, we discuss the issue of an adversary injecting bogus encounter messages/chirps into the contact tracing environment. This is done with the following, potentially malafide intentions:
\begin{itemize}
\item Consume mobile device storage and battery (all three architectures)
\item Cause an upload of these bogus messages to the server once a user tests positive (centralised and hybrid only)
\item Increase processing time at the server (centralised and hybrid only)
\item Increase processing time at the mobile device (more profound in the decentralised architecture as all chirps (including the bogus ones) need to be compared with the reconstructed chirps)
\end{itemize}
\begin{figure*}[htb]
\centering
\includegraphics[width=0.9\textwidth]{figures/Deanonymization.pdf}
\caption{Linkage attack for decentralised architecture.}
\label{fig:deanonimizing}
\end{figure*}
Note that in the centralised version, the server will process the bogus encounter messages, but will discard these after the server completes a validity check. On the other hand, in the decentralised version, there is no way to check the validity of the received chirp if it is correctly formatted.
\subsection{De-anonymising the users/Linkage attack}
\label{sec:linkage}
In this attack, a user aims to de-anonymise another user's identity by correlating the anonymous broadcast data with information gathered through side-channels. This can be achieved by linking the anonymous ID with the user's identity in what is known as a linkage attack. Most contact tracing apps have been designed with data and user privacy in mind. However, in the decentralised architecture, it is still possible to identify users once they test positive to the virus. Figure~\ref{fig:deanonimizing} presents the steps required to launch the attack. User A uses a decentralised app that records the details of his encounters with other persons (day/time/duration/location/gender, etc.) (step 5). If this user receives an alert (step 6), he/she can easily identify the infected user by comparing the reconstructed chirps (step 7). This can be achieved by looking at the time stamp (and duration) of the chirps and comparing his/her collected records (step 8). Some malicious record keeping can also be done automatically by a modified app that collects location information using GPS/WiFi etc.
For the centralised architecture, it is possible to de-anonymise close contacts, but it is hard to de-anonymise a positive case since an app user is not provided with a list of TempIDs for comparison. A positive case can still be identified if a user who is in isolation and has only met one person receives a close contact notification. TempIDs can easily be associated with a user by referring to the advertised mobile model number. The duration of contact and an isolated encounter will increase the chances of linking TempIDs with a particular user. Similarly, a Sybil attack~\cite{douceur2002sybil} can also be launched whereby an attacker can deploy multiple devices and only use a single device for a short time. If the user receives a notification from the server on one of his/her devices, the user can narrow the linkage attack to a short time window when that device was active.
An attacker can launch another kind of linkage attack, called a Paparazzi attack \cite{V2020} \cite{V2020a} in decentralised apps using passive BLE devices. When a user tests positive, the server receives the seeds, which are, in turn, sent to the users, including the attacker. The attacker reconstructs chirps and combines this data with that obtained from the passive BLE devices. It can then track the positive case throughout the contagion period. Similar to the Paparazzi attack, attackers can trace infected users by deploying a large number of passive BLE devices while colluding with the server. This is referred to as an Orwell attack \cite{ABIV2020}.
Hybrid protocols are generally considered un-linkable as these do not share the PETs from infected users with other users, and they perform risk analysis and notification in a similar manner to the centralised version.
\subsection{Abuse of app}
\label{sec:abuseApp}
The goal of this type of attack is to mislead the tracing app with information produced through incorrect usage of the app. All tracing apps, whether based on centralised, decentralised, or hybrid architectures, are prone to user abuse. A recent Google Maps experiment is referred to, in which a user carted 99 mobile phones down an empty road, and Google Maps responded by showing high congestion \cite{GmapsHack}. Similarly, a tracing app cannot recognise if a phone is being carried by its owner, someone else, or tied to a pet running in the park \cite{oxymoron}.
New measures could be introduced to circumvent these activities, such as using other existing sensors on the phone to record activity or perform gait recognition. However, from a privacy perspective, capturing greater quantities of contextual or personal data may result in privacy guarantees being lowered.
\subsection{Carryover attack}
\label{CO Attack}
This attack is supplementary to the device tracking attack discussed in \ref{subsec:device-tracking}. An attacker aims to continue the device tracking period beyond the anonymous ID expiration time. Most devices randomise their Bluetooth MAC addresses to avoid device tracking. The temporary identifiers (TempIDs and chirp) also get changed after a short time. An address carryover attack \cite{becker2019tracking} is possible when the changeover time of a Bluetooth MAC address and the temporary identifier are not synchronised. For example, let us assume that the TempID gets changed every 15 min, while the Bluetooth MAC changes every 10 min. A listener can easily link the multiple Bluetooth MAC addresses advertised within the lifetime of the same TempID. Conversely, a TempID change can be linked to the same Bluetooth address. Full synchronisation of temporary ephemeral identifiers and the Bluetooth random MAC address change are proposed in some of the apps. The changeover synchronisation, however, requires support from the OS Bluetooth module.
Note that even when the changeover of multiple identifiers is fully synchronised, a careful listener can still link different Bluetooth addresses (or temporary IDs) for wireless tracking by analysing the disappearance of an identifier and its immediate replacement by a new one. However, in our vulnerability analysis of apps (in Section \ref{sec:apps}), we do not consider this case.
\subsection{Disclosure of social graph }
\label{sec:socialGraph}
A social graph illustrates the interaction between individuals by representing the individuals as nodes, and connection between the nodes as edges indicating that these users may have been in close proximity. An attacker can build the social graph by mining the available data to infer the contact profiles of users. Disclosure of the social graph or even a part of it is undesirable, however some countries such as India have done so despite concerns from civil society. Both centralised and decentralised systems are vulnerable to the disclosure of (partial) social graphs.
In a decentralised system, if a malicious server wants to know whether an infected user A and target user B were in contact, it sends the seeds uploaded by A along with some other fake seeds to B. Now, by using a side-channel, if it observes that B has received an alert or gone into isolation, then it can say that A and B had been in contact. In the centralised architecture, positive cases can choose to upload their contacts to the server. A malicious server can construct part of the social graph (positive cases and their close contacts) because it knows the mapping between the TempIDs and individuals. Construction of a complete social graph is impossible unless the server is powerful enough to control the communication network and later perform huge data mining tasks. In any of the discussed architectures, it is to be noted that a malicious server cannot disclose the interaction between individuals who neither tested positive nor have been in contact with other positive patients. Theoretically, an attacker could steal several phones and possibly correlate symmetric encounters across users.
To hide the social graph construction by the server, apps from the centralised and hybrid categories have introduced additional measures (such as random, independent uploads of contact identifiers/EphIDs, maintaining separate upload and query identifiers, using zero knowledge proofs \cite{ZKP} to store anonymized social graph at the server~\cite{792} etc.). Some of these measures will be discussed in Section \ref{sec:apps} where we explore different protocols and apps in detail.
\section{Analysis of Specific Apps and Protocols}
\label{sec:apps}
\begin{figure*}[htb]
\centering
\includegraphics[width=0.65\textwidth]{figures/covid_615.pdf}
\caption{Summary of apps and protocols.}
\label{fig:covid-summary}
\end{figure*}
Above, we discussed the salient features, capabilities, and exposure to different kinds of attacks for the three broad architectures, which have been proposed for contact tracing applications. In this section, we delve into the instantiation of these architectures and introduce various tracing apps and protocols that are being proposed, developed, and deployed in many countries. We divide this discussion into three sections, each covering a different system architecture. To keep the discussions concise, we only focus on the salient features of each app/protocol and highlight any additional measures introduced on top of the corresponding base architecture. Figure \ref{fig:covid-summary} illustrates the protocols and the apps discussed in this section. Additionally, we provide an attack matrix (Table \ref{table:Attacks}) that highlights possible attacks on each app/protocol that is part of our discussion.
\subsection{Apps/Protocols based on centralised architecture}
In Section \ref{sec:Arch}, we explained the centralised architecture that was based on the Bluetrace \cite{bluetraceWhitepaper} protocol. ROBERT \cite{robert} is a similar protocol that relies on a centralised architecture. We will provide an overview of the TraceTogether (Singapore) \cite{opentraceGit} and CovidSafe (Australia) \cite{covidsafeGit} apps which are based on the Bluetrace protocol, and the StopCovid (France) app \cite{stopcovid} which implements the ROBERT protocol. The Aarogya Setu (India) is another instantiation of the centralised architecture and uses both Bluetooth and GPS.
\subsubsection{TraceTogether}
\label{sec:traceTogether}
The TraceTogether app launched by the Singaporean government in March 2020, was among the first contract tracing apps deployed to the general public. The source code of the reference implementation, OpenTrace, has been released in the public domain \cite{opentraceGit}. We only detail one additional BlueTrace protocol feature that has been implemented in the TraceTogether app but which was omitted in the centralised architecture description presented in Section \ref{sec:Arch}. The server issues forward-dated TempIDs to each device instead of a single TempID. This is to ensure that each device has a supply of valid TempIDs even when the Internet connection is unstable.
\subsubsection{CovidSafe (AU)}
\label{sec:covidSafe}
CovidSafe was released by the Australian government on 26th April 2020, with the source code for both Android and iOS clients released on 8th May 2020 \cite{covidSafe-Source}. Covid-Safe follows the Bluetrace protocol and exhibits many similar characteristics to the TraceTogether app, including vulnerability to the different types of attacks listed in Table \ref{table:Attacks}.
The two apps differ in the lifeTime of TempIDs. TraceTogether
uses a value of 15 minutes as recommended in the BlueTrace protocol specifications, while CovidSafe employs 2 hours. This makes CovidSafe more vulnerable to replay attacks. The relative advantage of CovidSafe over TraceTogether is that the devices do not have to download TempIDs frequently. Another difference between the two apps is in the backend infrastructure. While TraceTogether uses Google Cloud to provide the backend services, CovidSafe makes use of Amazon AWS servers that are located within Australia.
\subsubsection{StopCovid - ROBERT}
\label{sec:stopCovidROBERT}
ROBust and privacy-presERving proximity Tracing protocol (ROBERT) is a centralised tracing app protocol, that is jointly developed by researchers at INRIA (France) and Fraunhofer (Germany)~\cite{robert}. The StopCovid app, which is under development in France at the time of writing and is expected to be available in June 2020, will use the ROBERT protocol. The source code for the StopCovid app is already available \cite{stopCovid-Source}.
The main difference between the BlueTrace and ROBERT protocols is the type of user data that is stored on the server. While the former stores PII, the latter only stores anonymous identifiers referred to as EphIDs, thus providing a level of privacy.
The protocols also differ in the notification process, i.e., how the at-risk users are notified. ROBERT requires all users to frequently check their used EphIDs with the server to determine if they are flagged as at-risk. In contrast, with BlueTrace, health authorities could proactively notify at-risk users. The notification process is possible because BlueTrace can map the TempIDs to the collected personal information.
In ROBERT, a positively identified user uploads the EphIDs in a staggered and random order.
This is in contrast with the BlueTrace protocol, where all contacts are uploaded in one go. This is done to break the link of contacts with the same person and to prevent the server from conducting social graph analysis. However, analysing the network traffic exchanged by a device may potentially allow an adversary to link the reports together.
\subsubsection{Aarogya Setu}
\label{sec:aarogyaSetu}
Aarogya Setu is an app deployed in India based on the centralised architecture.
The code for their Android app was released (iOS and server code not yet available) on 26th May 2020 \cite{setu-Source}.
In addition to collecting PII and contact data, this app also gathers location data (GPS coordinates) and self-assessment data (responses provided by an individual to the self-assessment test)~\cite{setu2}.
It performs data analytics on the gathered information to indicate how many positive cases are within 500m to 10km of a user's current location. Users can upload the trace data if they are COVID-19 positive, or they fail the self-assessment test.
In contrast to other apps, the government of India has made it mandatory for all government employees and those living in disease containment zones to install the Aarogya Setu app
\subsection{Apps/Protocols based on decentralised architecture}
In this section, we first briefly discuss the Apple/Google alliance for providing APIs and OS-level support for privacy-preserving contact tracing. Next, we provide a short review of the Private Automated Contact Tracing (PACT) protocol by MIT \cite{pact-ec}, which was used as the basis for describing the decentralised system architecture in Section \ref{sec:dec}. Another protocol sharing the same name, PACT (Privacy-sensitive protocols And mechanisms for mobile Contact Tracing), developed by a team from the University of Washington \cite{chan2020pact}, is also discussed. To distinguish the two PACT protocols, we use the nomenclature: “PACT West-coast” (by UoW) and “PACT East-coast” (by MIT). Other contact tracing protocols including DP-3T \cite{DP-3T}, TCN \cite{TCN}, Hamagen \cite{Hamagen}, COVID Safe Paths \cite{pksp} and Pronto-C2 \cite{ABIV2020} are also covered in this section.
\subsubsection{Apple/Google Exposure Notification APIs}
Apple and Google \cite{Apple, Google} have joined hands to support privacy-preserving contact tracing by developing an exposure notification system. Their proposed tracing mechanism matches with the decentralised architecture described earlier in Section \ref{sec:dec}. Their system was planned to be rolled out in two phases. During the first phase,
on 20th May 2020, APIs were released to support apps developed by health authorities, intended to work seamlessly on iOS and Android devices. This is designed to help manage issues related to BLE scanning and advertisements faced by current apps \cite{bluetraceWhitepaper}. Apps based on recently released APIs by Apple and Google can use the proposed Associated Encrypted Metadata (AEM) during the exposure notification service. AEM is a privacy-preserving encrypted metadata that includes transmit power to aid in collecting more accurate proximity estimation results.
In the second phase, Apple/Google plan to incorporate OS-level support to help broader adaptation by eliminating the need for an app to perform contact tracing.
An app called SwissCoviD, discussed later in Section \ref{sec:swissCovid}, was released on 25th May 2020 for pilot testing by the DP-3T team \cite{DP-3T}. SwissCoviD is based on the Apple/Google APIs. Similarly, an open-source app called Corona-Warn-App \cite{CoronaWarn} has been released on 16th June, 2020 in Germany that is based on these APIs. Another project named Aurora \cite{aurora} is under development by the PathCheck team to utilise the APIs developed by Apple/Google. Moreover, many existing apps, including some from the centralised category, have already started exploring ways to migrate their existing code base to the APIs released by Apple/Google.
\subsubsection{PACT (East-coast)}
\label{sec:PACT-EAST}
The PACT (East-coast) protocol design was used as the basis to explain the decentralised architecture, including installation, encounter exchange, and the tracing process in Section \ref{sec:dec}. A research collaboration led by MIT~\cite{pact-mit} developed this protocol.
In addition to locally stored seed data (used to generate chirps) and chirp data (including received time and its signal strength), the PACT (East-coast) also allows the user to optionally store extra metadata, such as location information, in its local log file while receiving a chirp. The location data can help determine the place of contact, for example, a restaurant or a park. This optional metadata can help reduce false positives and increase system accuracy by involving more contextual information.
\subsubsection{CovidSafe - PACT (West-coast) }
\label{sec:PACT-WEST}
Privacy-sensitive protocols And mechanisms for mobile Contact Tracing - PACT (West-coast) \cite{chan2020pact} is a tracing protocol proposed by researchers from the University of Washington.
The core mobile tracing function uses a very similar process, compared with the baseline decentralised systems used in the PACT East-coast app, in which all personal data is locally stored (and encrypted) on the phone, devices broadcast pseudorandom IDs, and it is voluntary for a user to publish/upload the data. PACT (West-coast) adopts a different key-based generation mechanism to generate the pseudorandom ID used for broadcasting. A 128-bit key is initially fed into the pseudorandom generator, and a 256-bit length output is generated (take SHA-256 as an example). The half-length of that result (128-bit) is used as the temporary pseudorandom ID within a specified period $[t_0+dt \cdot i, t_0+dt \cdot (i+1)]$ and the other half is used as the input for the next pseudorandom generator. This key-chain design saves storage, storing fewer seeds than the PACT (East-coast) app. Afterwards, those pseudorandom IDs are broadcast and collected, similarly to the PACT (East-coast).
Like all decentralised protocols, PACT (West-coast) is also susceptible to the linkage, and enumerations attacks (discussed in Section \ref{sec:Attacks}), as the seeds from infected users are uploaded to the server and later on shared with all users.
CovidSafe (UoW) app~\cite{uow-CovidSafe}, for which the beta version was released in May 2020, is based on the PACT (West-coast) protocol.
\subsubsection{SwissCoviD - DP-3T}
\label{sec:swissCovid}
Decentralised Privacy-Preserving Proximity Tracing (DP-3T) \cite{DP-3T} is a protocol specification based on the decentralised architecture proposed by a consortium of universities and organisations from Europe led by EPFL, Switzerland. A pilot app named SwissCovid \cite{swissCovid} was released on 25th May, 2020\footnote{This is the first official release that is based on APIs developed by Apple/Google}. There are two versions covered in the specifications, we explain the `low cost' version here, while the other `un-linkable' version is covered in the next section.
The protocol is very similar in functionality to the base decentralised architecture discussed earlier (Section \ref{sec:dec}). A daily key is generated by each device, using the hash-chain from the previous daily key, and then used to generate the EphIDs. Messages are exchanged with other devices which come in contact over Bluetooth containing these EphIDs with expiry information and coarse time (date). The exchanged data remains in local storage until a user tests positive. Health officials determine the contagious window, i.e., at what time a positive case is contagious and might infect others. Identified users only upload their daily keys starting from this date. Once data is uploaded, the infected user changes their random key for generating future daily keys to prevent future tracking/identification. Other users download the daily keys uploaded by the infected user and compare their stored EphIDs with EphIDs reconstructed from the infected person's daily keys. The risk analysis process is thus performed locally on individual devices. The app notifies the user if they are found to be in close contact and asks for permission to upload their daily keys.
\subsubsection{DP-3T Unlinkable}
\label{sec:dp3t-2}
The DP-3T specification document \cite{DP-3T} also has a second version called an `Un-linkable' design. This design is in response to the claims that the decentralised design is subject to Linkage and Enumeration attacks, discussed in Section \ref{sec:Attacks}, as the daily keys for infected users are made available to all other devices.
The primary change in this design is that the daily keys uploaded by infected users are converted into their corresponding EphIDs by the server. The server hashes these values in a Cuckoo filter \cite{cuckoo} before advertising these to the other users. The users can still check whether their received EphIDs that are cryptographically hashed with the received time, and whether these match any entry in the Cuckoo filter or not. The user cannot access other information, including how many or which other EphIDs have been encoded in the Cuckoo filter.
The processing time at the server increases compared with the low-cost version of DP-3T. Also, the Cuckoo filter needs to be carefully designed to minimise the chances of false positives, while false negatives are not possible with this filter.
This design also enables users to selectively upload encounters (by suppression/redaction of some encounters) in the upload phase.
Another proposed feature is to use k-out-of-n secret sharing to minimise the chance of EphID collection during short periods of contact. A contact has to collect at least k advertisements to reconstruct an EphID successfully. This
restricts the effective EphIDs to contacts that are made for a sufficient duration.
\subsubsection{CovidWatch - TCN}
\label{sec:covidWatchTCN}
Researchers from Stanford University and Waterloo University have been developing Covid-Watch \cite{covidWatch}. At the time of writing, this app is still in a pilot phase. The source code is publicly available~\cite{CovidWatchSource} and it follows the TCN (Temporary Contact Number) Coalition protocol~\cite{TCN}.
The TCN protocol generates the keychain, such that each key (seed) derived from the master key generates one unique temporary contact number (chirp). Like other decentralised protocols, TCN only uploads the compact seed data (the Master key, the expiry time, etc.) to the server rather than the entire list of TCNs. All seeds that belong to a report can be proven/verified by the server as they are generated and bound to the same master key. Malicious entities can potentially launch a linkage attack (see Section~\ref{sec:linkage}) to find out the linkable TCNs by observing multiple TCNs from the reports that use the same master key. Therefore, frequent master key rotation can be performed to make TCNs un-linkable from different reports. However, this increases the number of keys that need to be maintained, raising the issue of scalability. An app thus needs to consider the trade-off between scalability and linkability while selecting the master key rotation period.
\subsubsection{Pronto-C2}
\label{sec:prontoC2}
Researchers from the University of Salerno, Italy proposed the Pronto-C2 contact tracing system \cite{ABIV2020}. It is a decentralised app that lets the devices communicate anonymously with each other while hiding these communications from the central server, averting mass surveillance.
At the heart of the protocol are two cryptographic tools: the Diffie Hellman (DH) Key exchange \cite{DH} discussed in Section \ref{sec:hybrid} and blind signatures \cite{C83}. A secret $sk_A\in Z_p$ and the ephemeral ID $eph_A = g^{sk_A}$ are generated by Alice's device and stored in the server. The address $addr_A$ is noted by the device where its generated ephemeral ID is stored on the server (this storage can also be realised using a blockchain).
The device broadcasts this address and receives addresses from other devices in its vicinity. This is contrary to decentralised designs that share ephemeral IDs. Alice stores the tuple $(eph_{A,i}, sk_{A,i}, addr_A, t)$ when it receives the $eph_B$ from Bob. Here $sk_{A,i}$ is the secret key from the previous update $i$, and $t$ contains auxiliary information like BLE signal strength, time, etc.
If Alice tests positive, she fetches the ephemeral ID of each contact from her contact list. For Bob, a contact, she receives $eph_B$ using the $addr_B$. Alice calculates $K'= eph_{B}^{sk_A}$ which is the DH key between herself and Bob, and a key $K = H(K'||eph_A||eph_B)$. She then sends the (blinded) information of $K$ to an authentication server, which appends a blind signature to $K$. The signature prevents DoS attacks and ensures that the authorisation server cannot perform social graph analysis.
A user $Y$ who wishes to test their risk can download the ephemeral IDs from their contact list in address $addr_X$. They then compute the DH key $K'$ between themselves and the ephemeral ID $Eph_X$ at $addr_X$. It computes $K= H(K'|| Eph_X||Eph_Y])$. $Y$ downloads the recently available keys (of infected individuals) from the server and checks if $K$ belongs to this set. If a match is found, then the user is at risk. The devices communicate with the server using anonymous channels like TOR to prevent linking ephemeral keys to users.
\subsubsection{Hamagen}
\label{sec:hamagen}
The Hamagen application is developed by Israel's Ministry of Health. Hamagen is different from many other contact tracing applications in that it does not rely on recording encounters with other phones in the vicinity using Bluetooth. The application cross-checks the GPS history of a mobile phone with the historical geographical data of identified cases from the Ministry of Health. The check is conducted locally on the individual's mobile phone. Each individual's location data does not leave their device, and neither is it sent to a third party. The app will periodically (currently set to hourly) download a file containing an anonymised list of locations that were visited by individuals diagnosed with COVID-19 over the past 14 days. This file is sourced from the Ministry of Health and populated with data showing those people who have undergone epidemiological investigation using the various tools available to the Ministry. The application then cross-references these locations (including timestamps) with the location data stored locally on the individual's device. Should the application discover that there is a possibility that the individual has been at the same place and at the same time as a diagnosed case, a notification is shown on the phone with the details of the location and times where the individual may have been exposed to a positive case. The phone user has the option to review the notification. If the message is perceived to be incorrect, e.g., if the user was not at the noted location at the stated time, the user can indicate that the information is false. If the user confirms their presence at the contact location, they are directed to the Ministry of Health's website for information on what to do next.
The application must be given access to the location history (GPS data) of the phone and the list of cellular base stations and WiFi access points encountered over the past two weeks. This information is stored in SQLite. The app also requires Internet access to periodically download an updated file from the Ministry of Health server. The application source code has been developed using React Native and is open-source on GitHub~\cite{Hamagen}.
\subsubsection{COVID Safe Paths}
\label{sec:COVIDSafePaths}
The PathChecks team \cite{pathCheck} has developed this app and its source code for Andriod and iOS and has made it publicly available \cite{pksp}. The app is similar to the Hamagen in functionality as it also employs logging of GPS location trajectories. A browser-based map tool called ``Safe Places" has also been released that can interact with the Safe Paths app. The diagnosed users can voluntarily share their location trails with the health authorities using the Safe Places map tool. Other users can download the anonymised and aggregated data sets of public locations to check whether they have come in contact with an identified individual, without uploading their path trajectories.
\begin{table*}[ht]
\footnotesize
\centering
\caption[Attacks]{Possible Attacks on Tracing Apps and Protocols \footnotemark}
\label{table:Attacks}
\begin{tabular}{ |c|c|c|c|c|c|c|c|c|c|}
\hline
Section & Tracing & Replay/ & Wireless & Location & Enumeration & DoS & Linkage & Carryover & Social\\
No. & Apps \& Protocols & Relay & tracking & confirmation & & & & & graph
\\
\hline
\ref{sec:traceTogether} & Trace Together &\Checkmark & \Checkmark & \Checkmark & $\times$ & \Checkmark& \Checkmark& \Checkmark &Easy
\\
& (BlueTrace) & & & & & & & &
\\
\hline
\ref{sec:covidSafe} & CovidSafe (AU) &\Checkmark & \Checkmark & \Checkmark & $\times$ & \Checkmark& \Checkmark& \Checkmark &Easy
\\
& (BlueTrace) & & & & & & & &
\\
\hline
\ref{sec:stopCovidROBERT} & StopCovid &\Checkmark & \Checkmark & $\times$ & $\times$ & \Checkmark& \Checkmark& $\times$ &$\times$
\\
& (ROBERT) & & & & & & & &
\\
\hline
\ref{sec:aarogyaSetu} & Aarogya Setu & \Checkmark & \Checkmark & \Checkmark & \Checkmark & \Checkmark & $\bigcirc$ &$\bigcirc$ & Easy
\\
\hline
\hline
\ref{sec:PACT-EAST} & PACT (East Coast) & Limited Replay & \Checkmark & $\times$ & \Checkmark & \Checkmark & \Checkmark & \Checkmark & Difficult
\\
& & \Checkmark Relay & & & & & & &
\\
\hline
\ref{sec:PACT-WEST} & CovidSafe (UoW)&Limited Replay & \Checkmark & $\times$ & \Checkmark &\Checkmark & \Checkmark & $\times$ & Difficult
\\
& (PACT-West Coast) &\Checkmark Relay & & & & & & &
\\
\hline
\ref{sec:swissCovid} & SwissCovid - DP-3T &\Checkmark &\Checkmark & $\times$ & \Checkmark &\Checkmark &\Checkmark &\Checkmark &Difficult\\
& (low cost) & & & & & & & &
\\
\hline
\ref{sec:dp3t-2} & DP-3T &\Checkmark & \Checkmark & $\times$ & $\times$ &\Checkmark & $\times$ &\Checkmark &Difficult\\
& (unlinkable) & & & & & & & &
\\
\hline
\ref{sec:covidWatchTCN} & CovidWatch & \Checkmark & \Checkmark & $\times$ & $\times$ & \Checkmark &\Checkmark & $\times$ &Difficult
\\
& (TCN) & & & & & & & &
\\
\hline
\ref{sec:prontoC2} & Pronto-C2 &\Checkmark &\Checkmark & $\times$ &$\times$ & \Checkmark &\Checkmark& $\bigcirc$ &$\times$
\\
\hline
\ref{sec:hamagen} & Hamagen & $\times$ & $\times$ & $\times$ & $\times$ & $\times$ & \Checkmark & $\times$ & $\times$
\\
\hline
\ref{sec:COVIDSafePaths} & COVID Safe Paths & $\times$ & $\times$ & $\times$ & $\times$ & $\times$ & \Checkmark & $\times$ & $\times$
\\
\hline
\hline
\ref{sec:desire} & DESIRE &\Checkmark Relay only & \Checkmark & $\times$ & $\times$ &\Checkmark &$\times$ & $\times$ & Difficult
\\
\hline
\ref{sec:contracor}& ConTra Corona & \Checkmark & \Checkmark & $\times$ & $\times$ & \Checkmark & $\times$ & $\times$ & Difficult
\\
\hline
\ref{sec:epione} & EpiOne & \Checkmark& \Checkmark &$\times$ &$\times$ & \Checkmark &\Checkmark &\Checkmark & $\times$
\\
\hline
\end{tabular}
\end{table*}
\footnotetext{Abuse of the app (Section \ref{sec:abuseApp}) is common for all apps/protocols, hence not shown in Table \ref{table:Attacks}. $\bigcirc$ denotes not enough information is available}
\subsection{Apps/Protocols based on hybrid architecture}
Hybrid protocols (Section \ref{sec:hybrid}) have been proposed to combine features of both centralised and decentralised architectures. We discuss three reference protocols in this section, DESIRE \cite{Desire}, ConTra Corona \cite{contra} and EpiOne \cite{epione}.
\subsubsection{DESIRE}
\label{sec:desire}
The explanation of the hybrid architecture in Section \ref{sec:hybrid} is based on the DESIRE protocol specification \cite{Desire}. The use of cryptographically generated PETs gives users more control while keeping these different from the advertised EphIDs. This avoids the potential harvesting of contact data for social graph analysis. All data stored at the server is encrypted with keys which are stored at the clients' devices. This protects the client data in case the server has a data breach.
The risk analysis and notification are handled by the server (instead of the clients as in the case of decentralised versions), which limits the likelihood of other users launching Enumeration and Linkage attacks.
\subsubsection{ConTra Corona}
\label{sec:contracor}
ConTra Corona\cite{contra} is a hybrid protocol proposed by German researchers from the FZI Research Center for Information Technology and Karlsruhe Institute of Technology. Contra Corona improves privacy protection by mitigating the linkage attacks that can be launched on decentralised apps. This is achieved by adopting a DDH key-exchange mechanism to verify the data upload process for a person diagnosed with COVID-19. Additionally, Contra Corona proposes strict server separation by employing three different servers; the submission server, the matching server, and the notification server.
The Contra Corona proposal is significantly different from the base hybrid architecture (based on the DESIRE protocol). However, the underlying assumptions are the same. Devices generate their IDs, and the centralised server(s), are responsible for the risk-analysis and notification process.
Each user generates a warning identifier ($wid$) for each day based on their real identifier (e.g., name). For each $wid$, the device computes 96 $sid$'s (regarded as seed identifiers) encrypted with the submission server's public key and $pid$ (pseudorandom identifier encrypted and hashed based on $sid$). $pid$ and $sid$ are uploaded to the submission server. Initially, the submission server collects all users' $(sid,pid)$ pairs. Once the submission server has accumulated sufficient client pairs, it shuffles these and then sends them to the matching server (this helps to mitigate the enumeration attack). If the matching server receives a $pid$ uploaded by one of the infected users, the matching server looks up the respective $sid$ of all potentially contaminated users and sends them to the notification server. Finally, the notification server decrypts the $sid$ to recover the user's warning identifier ($wid$) and publishes the $wid$ list. All users regularly fetch the $wid$ list from the notification server and compare it with the $wid$s (stored locally) that they have used for the previous 28 days.
Contra Corona protocol utilises n-out-of-k secret sharing of $pid$ (n is taken as 15 and k as 45) and selects a random identifier $m$ (for example, $m$ may be taken as the Bluetooth MAC address). One secret share of $pid$ is broadcasted every minute. Users who received and accumulated 15 such broadcasts sharing secrets of the same user $m$ can reconstruct the $pid$ of that contact event and further store that contact event on the device.
ConTra Corona's privacy enhancement is based on the premise that the servers are non-colluding, and all communication channels are anonymised or authenticated. The submission server is assumed to be the most trusted component as it stores all the matching $(sid,pid)$ pairs of identifiers that are generated by each user. The additional encryption and randomisation are used to prevent disclosure of infected user's status to other users. The protocol also requires the health authority to verify the source integrity of the report (uploaded by the infected person) to decrease the false negatives in the system (and also prevent the DoS attack).
\subsubsection{EpiOne}
\label{sec:epione}
EpiOne \cite{epione} has been proposed by a team of researchers led by the University of California at Berkeley to protect against linkage and social graph analysis attacks discussed in Section \ref{sec:Attacks}. At the time of writing, the source code has not been made available. At the heart of the protocol is a cryptographic technique known as Private Set Intersection (PSI)\cite{PSI, CLR17}.
At a high level, devices generate and share random IDs (tokens) using a seed. Each device maintains sent and received token lists. If a user tests positive, they upload their seeds through the health officials who use the server to construct their sent tokens. A user who wants to check his close contacts and server must follow a private set intersection protocol to check if there is an intersection between received tokens and those maintained at the server. The user is notified once a match is found. The private set intersection protocol guarantees that neither the user nor the server knows the complete set of tokens, thus preventing social graph analysis.
At a more fundamental level, EpiOne consists of two servers, a collection server with the healthcare officials and an untrusted verification server.
Before the start of the protocol, all participants, including the users, healthcare professionals and verification server first agree on the security parameters.
The verification server generates a public/private secret key pair and publishes the corresponding public key. Every user can choose a random seed and derive the tokens using input seed, the day, and the time slot within the day. This is useful because the verification server can, later on, reconstruct the token if it knows the corresponding seed.
When users come into contact with each other, they exchange tokens. The list of tokens sent and received are stored on the mobile device. When a user tests positive, it uploads the encrypted seeds (encrypted with the verification server's public key) to the collection server maintained by health officials. The health officials, in turn, shuffle the encrypted seeds and send them to the verification server that can decrypt the seeds and reconstruct all the tokens.
A user can find out if they were in close proximity to a positive COVID case by computing securely (using Private set intersection protocol) the cardinality of the intersection between the two sets of tokens. The server neither reveals the set of tokens of positive cases (preventing enumeration attack), nor does the user reveal the set of tokens they received from other users (preventing social graph construction).
\begin{table*}[ht]
\footnotesize
\centering
\caption{Comparison of factors affecting device battery usage}
\label{table:Battery}
\begin{tabular}{ |c|l|l|l|l| }
\hline
Architecture & Encounter exchanges & Downloads from server& Data upload to server & Processing at device
\\
& & & (Once for a positive case) &
\\
\hline
Centralised & BLE periodic exchange & Periodic download & Upload all encounter & Minimal processing
\\
& of short messages& of TempIDs & messages for the &
\\
& (TempIDs) &(once in 15 min) & past 21 days &
\\
\hline
Decentralised &BLE periodic exchange & Download of seeds& Upload seeds used & High processing
\\
& of short messages& for positive cases& for the past & device periodically generates
\\
& (Chirps) &(once in 24 hours) & 21 days & seeds/chirps
\\
\hline
Hybrid &BLE periodic exchange& - & Upload PETs used for & High processing
\\
& of short messages& &the past 21 days & device periodically generates
\\
& (EphIDs) & & *Upload PETs for risk & EphIDs and calculates,
\\
& & & analysis by server & two PETs for each EphID
\\
\hline
\end{tabular}
\end{table*}
\section{Common user concerns}
\label{sec:commonconcerns}
The COVID-19 tracing applications have seen increased adoption in many countries; for example, more than 5 million users downloaded the CovidSafe (AU) app within two weeks of its initial release in Australia. Similarly, downloads for the Indian tracing app Aarogya Setu have crossed the 114 million mark. Generally, the number of downloads for an app is used as an indicator for user acceptability. However, we argue that this is not a sufficient metric to gauge the impact or effectiveness of a contact-tracing app. We require additional information such as the number of close contacts identified through the data captured by an app and the associated false positive/false negative rates. Typically, health officials undertake manual contact tracing in conjunction with the app data to find out the close contacts for an identified case. Three distinct possibilities exist in this regard:
a) The contacts identified by the app matches exactly with the manual tracing process; App has achieved its objective, and the data is used as confirmation.
b) The contacts identified by the app are more than those identified by the manual tracing process; App has achieved its objective and proved its effectiveness.
c) The contacts identified by the app are less than those identified by the manual tracing process; The performance of the app is questionable.
However, as of this writing, there is no openly available data that can be used for impact analysis and measuring the effectiveness of any of these apps.
Authors in \cite{T&P} has discussed several concerns associated with the use of these contact tracing apps. We discussed concerns related to user data privacy and security in Sections \ref{sec:Privacy} and \ref{sec:Attacks}. In this section, we focus on some of the additional concerns from user's perspective.
\subsection{Battery Usage}
Excessive battery consumption is a recurring problem for mobile apps. Mobile battery consumption is affected by many factors such as app processor utilisation, frequency, the scale of data management, and the number of messages exchanged, etc. Most tracing apps rely on the BLE communication protocol to exchange information with peers, while other apps use regular cellular or Wifi connections to communicate with servers. The BLE protocol allows the app to exchange a small amount of data with peers periodically. On the other hand, communication with the server relies on traditional secure application protocols, e.g., HTTPs. The main impact on the battery utilisation for these protocols is related to the number of information exchanges with the server. Table \ref{table:Battery} shows the comparison of different factors that affect mobile battery consumption. For the apps that rely on a centralised architecture, a fixed-sized message is retrieved from the server periodically to get a new TempID.
In contrast, for the decentralised version, there is no periodic data retrieval during the operation stage. Data is only downloaded once the server publishes the seeds uploaded by a positive case. The app nevertheless checks for any new download after every 24 hours. The upload rate of decentralised apps is lower than centralised counterparts. In decentralised cases, the upload consists of all seeds used during the past 21 days, whereas the centralised apps upload all encounter messages captured in the last 21 days. Centralised apps perform better in terms of processing at the devices as this involves minimal processing compared with the decentralised apps that need to generate and maintain seeds (after every 1 hour) and chirps (after every 1 min). For the hybrid architecture, devices generate EphIDs as well as two PETs for each received EphID. Hybrid apps upload the highest amount of data to the server: PETs from identified positive cases and Query PETs from all other users, collected for the purpose of checking their risk status. On the other hand, download from the server is lower compared with other architectures.
Battery consumption is also affected by the execution aspect, as an app that runs in the foreground demands more power than an app that runs in the background. Typically this design choice is dependant on the operating system support for these apps. As a case in point, CovidSafe and TraceTogether IoS apps face these documented issues when the app is running in the background~\cite{bluetraceWhitepaper}. Google and Apple, the two leading smartphone operating system providers, have teamed up to provide exposure notification APIs that improve the tracing application integration with the operating system. These APIs are expected to improve the apps' development process and reduce power consumption.
\subsection{Compatibility of OS versions and different apps}
Developing an app that works in all smartphone models is not a trivial task. Smartphones run different versions of the operating system (OS), Android and iOS being the two dominant OSs. Most of the tracing apps have been developed for the newer OS versions; for example, both TraceTogether and CovidSafe require iOS version 10 or higher. TraceTogether requires Android 5.1 or higher, while CovidSafe works on Android 6.0 or higher. CovidSafe requires the newer OS versions for security reasons and improved Bluetooth capabilities \cite{covidsafeHelp}.
A secondary concern is cross-app compatibility. Consider a case when a user of an app released for a specific geographic region travels to areas where another app has been deployed. It is not clear how an app would behave if a second tracing app is installed on the same device due to the architectural differences discussed earlier.
\subsection{Consent withdrawal}
\label{sec:consent}
Consent withdrawal refers to the ability of a user to stop participating in data sharing. Consent withdrawal provides a guarantee that users can delete their data or eliminate their existence from the tracing app ecosystem whenever they wish.
We consider next the consent withdrawal process at various stages of the app operation.
\begin{itemize}
\item \emph{Data collection phase}: Since the encounter data is only locally stored at the user devices (for a limited period of 21 days for instance), deleting an app implies the removal of all encounter data from the device immediately without transfer to a server. Additionally, for the centralised architecture, app deletion is assumed to result in the removal of all personal data captured at the registration stage. However, as the encounter data exchange is symmetric, other active users would have encounter messages/chirps stored in their devices for 21 days. Similarly, for the hybrid architecture, if a user withdraws consent and deletes the local data, PETs generated using their broadcasted EphIDs would remain in the local storage of contacts.
\item \emph{Data already uploaded to the server}: If a user voluntarily uploads data to the server after testing positive, and subsequently wants to exercise consent withdrawal, can the system support it? In the centralised architecture, the uploaded data consists of encounter information from all close contacts of the positive case. The server processes this data and then alert close contacts. As this contact data is not transferred to the close contacts, the server can easily remove the uploaded data as it has already been utilised.
In terms of systems, the deletion of such data and provision of a receipt or feedback to the user is technically feasible.
In the case of the decentralised architecture, the consent withdrawal process is more involved as the uploaded seeds from an infected user are made available to other app users for self-checking. If the infected user requests data deletion, the server can remove the stored data, but it is not clear how the seeds already transferred to other devices (and the reconstructed chirps) can be immediately expunged from these devices (transferred seeds are always removed after 21 days). As discussed earlier, the use of bloom filters for encoding hashed chirps at the server could provide an additional level of data protection (Section \ref{sec:Enum}). For the hybrid case, if a user withdraws consent after uploading the PETs, the server can remove the PETs as these are not transferred to other users.
\item \emph{End of pandemic}: Most of the authorities managing tracing apps have indicated that the app data collected would be removed once the system gets de-activated at the end of the pandemic, often referred as the sunset clause, unless a user requests explicit earlier removal of their stored data. However, `end of the pandemic' is a vague term. Proposals such as DP-3T have an automatic mechanism for the removal of data from the server and the clients after a fixed period.
\end{itemize}
\subsection{Transparency}
There is a genuine public concern about the nature of information being collected from the user's smartphone and its usage by various parties. There are two essential approaches to achieving transparency. The first option is to make the source code of the app open. Publishing the app source code improves transparency and trust in the system, as the implemented privacy and security features can be scrutinised by the research and academic community. Although this is the preferred option, public source code is not a panacea to ensure security. Many risks arise from system configurations and the use of a wider system that is not readily observable from the source code analysis. It would also be useful to ensure that the code is subjected to periodic review and trusted third-party audits.
While transparency is a key to wider adoption by the end-users, it is essential to note that ultimately a degree of trust is required in the use of any mobile app. This includes trusting the developers, the independent test and verification team, the operators and owners of the service, and importantly, the companies providing essential components such as the mobile phone operating systems.
Finally, all functional apps should be accompanied by a Privacy Impact Assessment (PIA). To the best of our knowledge, among the apps that have been covered in this article, only CovidSafe (AU) and DP-3T are accompanied by a PIA \cite{PIACovidSafe} \cite{lsts}.
\section{Future Directions}
\label{sec:future}
The current COVID-19 crisis has started the trend of using a virus tracking app at scale. We could have been better prepared for a pandemic of this proportions if these applications had been in place, fully tried and tested before the onset of the pandemic. There is already a flurry of research activities around the globe to develop the next-generation tracking applications ready for instant deployment should the world face a similar, or potentially even more dangerous pandemic. We consider some future research directions next.
In considering research areas for future tracing applications, it is probably best to consider near-term development, say the next five years, with more ``blue sky” type research pushed to post 5-year horizon. For the near-term, we identify the following as some important topics.
\begin{itemize}
\item \textit{Improvement in proximity accuracy}: Current challenges related to proximity accuracy have been highlighted in our earlier discussions. The Bluetooth technology was not designed with location or proximity determination as a critical part of the design process. However, the latest version of BLE released in 2020 has added features which will be helpful for next-generation apps. Additionally, new ``Bluetooth-like” protocols should be designed with an emphasis on location/proximity services during the inception phase.
Antenna design should be part of this process, allowing for not only distance accuracy but also direction-finding. Indeed, direction-finding is embedded as part of the Bluetooth 5.1 protocol albeit with low accuracy. Currently, no Covid19 tracing app has included such direction capabilities within their proximity analysis. The use of time-of-arrival metrics could also be used as hardware technology improves, and sub-nanosecond timing becomes commonplace within devices. Indeed, several smartphone manufacturers have moved to embed a dedicated Ultra-Wideband (UWB) chipset - specifically with Bluetooth proximity analyses in mind. Compared to the small bandwidth utilised by Bluetooth (2MHz), UWB utilises 500MHz, potentially resulting in cm-type precision for the proximity determination.
Research on fusing radio data with other location information garnered from other sensors embedded on the phone, such as location-designed WiFi, Enhanced-GPS, gyroscopes, accelerometers, and magnetometers is promising to improve the proximity accuracy.
These sensors could be aided by advances in software solutions such as advanced digital processing for location tracking and artificial intelligence-based algorithms. One can imagine new ``proximity” designs specifically aimed at integrating all relevant hardware, software, and protocol design into a single chip.
\item \textit{A fully decentralised architecture for infection tracing}: One of the ``takeaway messages” from the COVID-19 crisis is that privacy concerns have to be addressed for wider adoption by the public. None of the applications we have described above can be considered as encompassing a fully decentralised architecture - they all use a central server to differing degrees, usually under the control of a governing authority. Research on a fully decentralised system using some form of a peer-to-peer network to facilitate privacy-preserving information sharing amongst the user-devices should be pursued.
\item \textit{Artificial Intelligence-based algorithms}: AI algorithms are increasingly being used as the processing power within phones improves. The use of such algorithms in aiding the decision-making process of infection likelihood is obvious. Via metrics such as true infection identification, missed detections, and false-positive outcomes, the algorithms can become “live” in the sense that they dynamically adapt and self-improve in their reliability and accuracy. We anticipate much research in this area, especially with the integration of AI and the decentralised architecture.
\end{itemize}
In a post-5-year time scale, research outcomes are harder to predict. Much depends on the hardware development and the emergence of new technologies that are touted to become available. However, perhaps the most exciting of these emerging technologies lies in the quantum arena.
\begin{itemize}
\item Quantum computing \cite{quantumComputing} is considered by many to be on the threshold of a breakthrough both in development and in commercialisation. Future research on tracing solutions that exploit the use of the exponentially more powerful computing resources afforded by quantum computing should commence now. These could include quantum-based artificial learning algorithms and advanced Monte-Carlo or particle filter type tracking solutions. In this paradigm, information from the phones will be sent to a central quantum computer for processing.
\item Quantum sensing \cite{quantumSensing} is another area of current research that is also touted to bring major advances in the coming years. This technology exploits hypersensitivity embedded in quantum entanglement as a source of improved timing, network synchronisation, accelerometer accuracy, and location accuracy, to name a few. Clearly, all these issues could be brought to the contact tracing arena to maximise the overall performance and efficacy of the applications.
\item Quantum communications \cite{quantumComm} is the most advanced of all the new quantum applications, at least in the sense of deployment. Commercial offerings in the quantum communications area already exist, and proof-of-principle deployment in space has already occurred. The major impact of this technology on tracing applications will likely be in the advanced communications security and enhanced privacy protections it offers. In principle, if properly deployed, security and privacy in future virus-tracking applications will be unconditional – hacking and unauthorised access to virus-tracking data will be made obsolete.
\end{itemize}
\section{Conclusions}
\label{sec:concl}
The COVID-19 pandemic continues to affect the way of life of everyone. The contact tracing apps are likely to play a vital role in aiding health authorities quickly identify individuals that may have been exposed to the virus. The imminent interest and adoption of tracing app technology will improve the tracing capability of health authorities; however, as this article highlighted, it is not a silver bullet. These apps still face many concerns from users, data protection agencies, and researchers. The main concerns are related to the user data management, potentially non-trivial false positive and negative instances, and the security and privacy issues of these apps. Guided by these concerns, this article presented an overview of the three common tracing app architectures: centralised, decentralised, and hybrid; and an overview of popular apps within these categories. Additionally, the paper focused on the privacy and security aspects, mapping attacks that could be possibly performed in each of the three architectures. This article also elucidates some other users' concerns regarding battery drain, compatibility, consent withdrawal, and transparency. Finally, we discussed some of the near and long term future research directions.
We note that each architecture has pros and cons, different attack models and protections, varying complexity of implementation, and operating costs. The adoption of a particular architecture, by a government, is based on familiarity with technology, integration with existing tracing processes, and ease of deployment. On the other hand, the adoption of an app by users is voluntary. The users have their due concerns regarding the privacy and security of their PII collected through these apps. The adoption rate by users can be increased significantly if complete transparency and legislative guarantees against misuse of data originating from this ecosystem can be assured by the authorities.
We also highlight that government agencies and service providers such as ISPs, and large corporations such as Apple/Google can already track people by using traditional apps and technologies such as WiFi connections, the cellular communication tower areas, GPS navigation apps and a whole range of cameras deployed across cities. Since many users already install a myriad of apps on their phones or smart watches (games, social media, etc.) without knowing the security/privacy implications, installing a tracing app that primarily aims at helping in a noble cause of keeping the community safe from spreading the COVID-19 disease, in the opinion of the authors, should not cause undue concern.
We hope that this article will aid the research community to understand various technological and cybersecurity aspects of tracing apps and help users and agencies to make a more informed decision about the voluntary adoption of an app offered in their geographical areas.
\section*{Acknowledgements}
The authors thank Michelle Malaney and Xiaoyu Ai for their help in preparing this manuscript for publication. This work has been supported by the Cyber Security Research Centre Limited (CSCRC) whose activities are partially funded by the Australian Government's Cooperative Research Centres Programme.
\bibliographystyle{IEEEtran}
| {'timestamp': '2020-07-28T02:28:18', 'yymm': '2006', 'arxiv_id': '2006.10306', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10306'} | arxiv |
\section{Introduction}
Deep learning has achieved significant progress on a wide range of complex tasks~\cite{en9} mainly in terms of some metrics on prediction accuracy. However, high accuracy alone is often not sufficient to characterize the performance in real applications, where
uncertainty is pervasive because of various facts such as incomplete knowledge, ambiguities, and contradictions. Accurate quantification of uncertainty is crucial to derive a robust prediction rule.
For example, an accurate uncertainty estimate can reduce the occurrence of accidents in medical diagnosis~\cite{leibig2017leveraging}, warn users in time in self-driving systems~\cite{michelmore2020uncertainty}, reject low-confidence predictions~\cite{cosentino2019generative},
and better meet consumers' order needs of internet services especially on special events~\cite{zhu2017deep}. In general, there are two main types of uncertainty, \textit{aleatoric} uncertainty and \textit{epistemic} uncertainty~\cite{der2009aleatory}. \textit{Aleatoric} uncertainty captures inherent data noise (e.g., sensor noise), while \textit{epistemic} uncertainty is considered to be caused by model parameters and structure, which can be reduced by providing enough data.
Though important, it is highly nontrivial to properly characterize uncertainty. Deep neural networks (DNNs) typically produce point estimates of parameters and predictions, and are insufficient to characterize uncertainty because of their deterministic functions~\cite{Gal2016Uncertainty}. It has been widely observed that the modern neural networks are not properly calibrated and often tend to produce over-confident predictions~\citep{amodei2016concrete,guo2017calibration}.
An effective uncertainty estimation is to directly model the predictive distribution with the observed data in a Bayesian style~\cite{mackay1992practical}. But performing Bayesian inference on deep networks is still a very challenging task, where the networks define highly nonlinear functions and are often over-parameterized~\cite{wang2019function,shi2017kernel}.
The uncertainty estimates of Bayesian neural networks (BNNs) may lead to an inaccurate uncertainty quantification because of either model misspecification or the use of approximate inference~\citep{Kuleshov}. Besides, BNNs are computationally more expensive and slower to train in practice, compared to non-Bayesian NNs. For example, a simple method of MC-Dropout directly captures uncertainty without changing the network structure~\cite{gal2016dropout}. But the uncertainty quantification of MC-Dropout can be inaccurate, as will be seen in the empirical results in this paper.
Apart from BNNs, some methods have been developed to incorporate the variance term into NNs to estimate the predictive uncertainty. For instance, \citep{Kendall} proposed a heteroscedastic neural network (HNN) to combine both model uncertainty and data uncertainty simultaneously, getting the mean and variance by designing two outputs in the last layer of the network. Based on HNN, \citep{Lakshminarayanan} described a simple and scalable method for estimating predictive uncertainty from ensembled HNNs, named as \textit{deep ensemble}.
But the ensembled model is usually computationally expensive especially when the model structure is complex.
An alternative way to obtain accurate predictive uncertainty is to calibrate the inaccurate uncertainties.
Early attempts were made to use the scaling and isotonic regression techniques to calibrate the supervised learning predictions of traditional models, such as SVMs, neural networks and decision trees~\cite{platt1999probabilistic,niculescu2005predicting}.
For regression tasks, the prediction intervals are calibrated based on the proportion of covering ground truths.
Recently, \citep{guo2017calibration,Kuleshov} adopted a post-processing step to adjust the output probabilities of the modern neural networks based on the temperature scaling and non-parametric isotonic regression techniques.
Such \textit{post-processing} methods can be directly applied to both BNNs and DNNs without model modifications.
But they need to train an auxiliary model and rely on an additional validation dataset.
Moreover, the isotonic regression tends to overfit especially for small datasets~\cite{song2019distribution}.
\citep{pearce2018high,Thiagarajan} directly incorporated a calibration error to loss functions to obtain the calibrated prediction intervals at the specific confidence level.
Predetermining the specific confidence level can be regarded as the ``point calibration'' and its calibration model needs to be retrained when the confidence level is changed.
\cite{song2019distribution} proposed an extension to the post-processing procedure of the isotonic regression, using Gaussian Processes (GPs) and Beta link functions. This method improves calibration at the distribution level compared to existing post-processing methods, but is computationally expensive because of the GPs.
In this paper, we propose a new way to obtain the calibrated predictive uncertainty of regression tasks at the global quantile level --- it derives a distribution matching strategy and gets the well-calibrated distribution which can output predictive uncertainties at all confidence levels.
Specifically, we minimize the maximum mean discrepancy (MMD)~\cite{gretton2012kernel} to reduce the distance between the predicted probability uncertainty and true one.
We show that the calibration error of our model asymptotically converges to zero when the sample size is sufficiently large. Extensive empirical results on the regression and time-series forecasting tasks show the effectiveness and flexibility of our method.
\section{Preliminaries}
In this section, we introduce some preliminary knowledge of calibrated regressor and maximum mean discrepancy, as well as the notations used in the sequel.
\subsection{Calibrated Regressor}
Let us denote a predictive regression model as $f$: $x \rightarrow y$, where ${x}\in \mathbb{R}^{d}$ and ${y} \in \mathbb{R}$ are random variables. We use $\Theta$ to denote the parameters of $f$. We learn a proposed regression model given a labeled dataset $\left\{\left(x_{i}, y_{i}\right)\right\}_{i=1}^N$ with $N$ samples.
To obtain more detailed uncertainty of the output distribution, a calibrated regressor outputs the cumulative distribution function~(CDF) $F_i$ by the predictive distribution
for each input $x_i$.
When evaluating the calibration of regressors, the inverse function of CDF $F_i^{-1}:[0,1] \rightarrow \hat{y_i} $ is used to denote the quantile function:
\begin{equation}
F_{i}^{-1}(p)=\inf \left\{y: p \leq F_{i}(y)\right\}.
\end{equation}
Intuitively, the calibrated regressor should produce calibrated prediction intervals (PIs).
For example, given the probability $95\%$, the calibrated regressor should output the prediction interval that approximately covers $95\%$ of ground truths in the long run.
Formally, we define a \emph{well-calibrated} regressor~\cite{dawid1982well,Kuleshov} if the following condition holds, for all $p\in[0,1]$,
\begin{equation}\frac{\sum_{i=1}^{N} \mathbb{I}\left\{y_{i} \leq F_{i}^{-1}(p)\right\}}{N} \rightarrow p, \text{when } N \rightarrow\infty,
\end{equation}
where $\mathbb{I}(\cdot)$ is the indicator function that equals to $1$ if the predicate holds
otherwise $0$.
More generally, for a prediction interval $[F_{i}^{-1}(p_1), F_{i}^{-1}(p_2)]$, there is a similar definition of two-sided calibration as follows:
\begin{equation}
\frac{\sum_{i=1}^{N} \mathbb{I}\left\{F_{i}^{-1}\left(p_{1}\right) \leq y_{i} \leq F_{i}^{-1}\left(p_{2}\right)\right\}}{N} \rightarrow p_{2}-p_{1} \quad\text { for all } p_1,p_2 \in[0,1]
\label{eqn:cali_two}
\end{equation}
as $N \rightarrow \infty$.
For this task, the previous methods applied the post-processing techniques~\cite{Kuleshov,guo2017calibration} or added a regularized loss~\cite{pearce2018high,Thiagarajan}.
But when we want to get PIs with different confidence levels, we need to retrain the
model because the confidence level is predetermined in the loss function.
In contrast, we argue that the key challenge for the calibrated regression is getting the well-calibrated distribution. Based on this principle, our method utilizes the distribution matching strategy and aims to directly get a calibrated predictive distribution, which can naturally output well-calibrated CDF and PIs for each input $x_i$.
\subsection{Maximum Mean Discrepancy}
Our method adopts maximum mean discrepancy (MMD) to perform distribution matching. Specifically, MMD is defined via the Hilbert space embedding of distributions, known as kernel mean embedding~\cite{gretton2012kernel}. Formally, given a probability distribution, the kernel mean embedding represents it as an element in a reproducing kernel Hilbert space (RKHS).
An RKHS $\mathcal{F}$ on $\mathcal{X}$ with the kernel function $k$ is a Hilbert space of functions $g: \mathcal{X}\rightarrow \mathbb{R}$.
We use $\phi({x})=k({x}, \cdot)$ to represent the feature map of ${x}$. The expectation of embedding on its feature map is defined as:
\begin{equation}\mu_{X}:=\mathbb{E}_{X}[\phi(X)]=\int_{\Omega} \phi({x}) P(d {x}).
\end{equation}
This kernel mean embedding can be used for density estimation and two-sample test~\cite{gretton2012kernel}.
Based on the Hilbert space embedding, the maximum mean discrepancy (MMD) estimator was developed to distinguish two distributions $P$ and $Q$~\cite{gretton2012kernel}.
Formally, the MMD measure is defined as follows:
\begin{equation}
L_{m}(P, Q)=\left\|\mathbb{E}_{X}(\phi(P))-\mathbb{E}_{X}(\phi(Q))\right\|_{\mathcal{F}}.
\end{equation}
The MMD estimator is guaranteed to be unbiased and has nearly minimal variance among unbiased estimators~\citep{li2015generative}.
Moreover, it was shown that $L_{m}(P,Q)=0$ if and only if $P = Q$~\cite{gretton2012kernel}.
We conduct a hypothesis test with null hypotheses $H_0: P = Q$, and the alternative hypotheses $H_1: P \neq Q$ if $L_{m}(P, Q) > c_{\alpha}$ for some chosen threshold $c_{\alpha}>0$. With a characteristic kernel function (e.g., the popular RBF kernels), the MMD measure can be used to distinguish the two different distributions and have been applied to generative modeling~\cite{li2017mmd,li2015generative}.
In practice, the MMD objective can be estimated using the empirical kernel mean embeddings:
\begin{equation}\hat{L}_{m}^{2}(P,Q) = \left\|\frac{1}{N} \sum_{i=1}^{N}\phi({x}_{1i})-\frac{1}{M}\sum_{j=1}^{M}\phi({x}_{2j})\right\|^{2}_{\mathcal{F}},
\label{eqn:l_m}
\end{equation}
where ${x}_{1i}$ and ${x}_{2j}$ are independent random samples drawn from the distributions $P$ and $Q$ respectively.
\section{Calibrated Regression with Maximum Mean Discrepancy}
We now present the uncertainty calibration with the maximum mean discrepancy and then plug it into the proposed calibrated regression model. We also give the theoretical guarantee to show the effectiveness of our uncertainty calibration strategy.
\subsection{Uncertainty Calibration with Distribution Matching}
Specifically in this part, we use $P$ and $Q$ to represent the unknown true distribution and predictive distribution of our regression model respectively.
The distribution matching strategy of our uncertainty calibration model is to directly minimize the kernel embedding measure defined by MMD in Eqn.~\eqref{eqn:l_m}.
The specific goal is to let the predictive distribution $Q$ converge asymptotically to the unknown target distribution $P$ so that we can get the calibrated CDFs $\{F_i\}$.
The strategy is to minimize the MMD distance measure
between the regression ground-truth targets $\{y_1,\cdots,y_n\}$ and random samples $\{\hat{y}_1,\cdots,\hat{y}_n\}$ from the predictive distribution $Q$. The specific form of the MMD distance loss $L_{m}$ is:
\begin{equation}
L^{2}_{m}(P,Q) := \left\|\frac{1}{N} \sum_{i=1}^{N}\phi({y}_{i})-\frac{1}{N}\sum_{j=1}^{N}\phi({\hat{y}}_{j})\right\|^{2}_{\mathcal{F}}.
\label{eqn:lm}
\end{equation}
We use a mixture of $k$ kernels spanning multiple ranges for our experiments:
\begin{equation}k\left(x, x^{\prime}\right)=\sum_{i=1}^{K} k_{\sigma_{i}}\left(x, x^{\prime}\right),\end{equation}
where $k_{\sigma_{i}}$ is an RBF kernel and the bandwith parameter $\sigma_{i}$ can be chosen simple values such as 2,4,8, etc. The kernel was proved to be characteristic, and it can maximize the two-sample test power and low test error~\cite{gretton2012optimal}. In general, a mixture of five kernels or more is sufficient to obtain good results.
With the incorporation of this MMD loss, we learn the calibrated predictive probability distribution and the obtained uncertainties can be generalized to arbitrary confidence levels without retraining.
In theory, under $H_0: P = Q$, the predictive distribution $Q$ will converge asymptotically to the true distribution $P$ as sample size $N \rightarrow \infty$, which is why minimizing MMD loss is effective for uncertainty calibration.
Leveraging our distribution matching strategy, the uncertainty calibration can be achieved by narrowing the gap between $P$ and $Q$.
Formally, we have the following theoretical result:
\begin{theorem}
Suppose that the predictive distribution $Q$ has the sufficient ability to approximate the true unknown distribution $P$, given data is i.i.d. Eqn.~\eqref{equ:thero1} holds by minimizing the MMD loss $L_{\mathrm{m}}=\left\|\mu_{x_1}-\mu_{x_2}\right\|_{\mathcal{F}}$ in our proposed methodology as the sample size $N \rightarrow \infty$
\begin{equation}
\frac{\sum_{i=1}^{N} \mathbb{I}\left\{y_{i} \leq F_{i}^{-1}(p)\right\}}{N} \rightarrow p \quad\text { for all } p \in[0,1]
\label{equ:thero1}
\end{equation}
\end{theorem}
\begin{proof}
$L_{m}(P, Q) = 0$ if and only if $P = Q$ when $\mathcal{F}$ is a unit ball in a universal RKHS~\citep{gretton2012kernel}. Under $H_0: P = Q$, the predictive distribution $Q(x)$ will converge asymptotically to the unknown true distribution $P(x)$ as the sample size $N \rightarrow \infty$ by minimizing the MMD loss $L_m$. Further, Eqn.~\eqref{equ:thero1} holds according to the obtained predictive distribution. Because the confidence level $p$ is exactly equal to the proportion of samples $\{y_1,\cdots,y_n\}$ covered by the prediction interval.
\end{proof}
This theoretical result can be generalized to the two side calibration condition defined in Eqn.~\eqref{eqn:cali_two} and we defer the details to Appendix \ref{appendix:two-sided theorem}.
\subsection{Calibrated Regression with MMD}
To represent the model uncertainty, we use a heteroscedastic neural network (HNN) to get the predictive distribution and outputs the predicted mean $\mu(x)$ and the variance $\sigma^2(x)$ in the final layer, which can combine epistemic uncertainty and aleatoric uncertainty in one model~\citep{nix1994estimating,Kendall}.
Based on this representation model, we use a two-stage learning framework which optimizes the two objectives one by one, namely the negative log likelihood loss $L_{h}$ and the uncertainty calibration loss $L_{m}$.
In the first stage, the optimal model parameters
can be learned by minimizing negative log-likelihood loss~(NLL):
\begin{equation}
{L}_{{h}}(\Theta) =\sum_{i=1}^{N}\frac{\log \sigma_{\Theta}^{2}({x_i})}{2}+\frac{\left(y_i-\mu_{\Theta}({x_i})\right)^{2}}{2 \sigma_{\Theta}^{2}({x_i})}+\text { constant }.
\end{equation}
In practice, to improve numerical stability, we optimize the following equivalent form:
\begin{equation}
{L}_{{h}}(\Theta)=\sum_{i=1}^{N} \frac{1}{2} \exp \left(-s_{i}\right)\left(y_i-\mu_{\Theta}({x_i})\right)^{2}+\frac{1}{2} s_{i}, \quad s_{i}:=\log \sigma_{\Theta}^{2}(x_i).
\label{eqn:l_h}
\end{equation}
Although the Gaussian assumption is a bit restrictive above, we found that the method performs satisfactorily well in our experiments.
In the second stage, we minimize the uncertainty calibration loss with MMD, i.e., Eqn.~\eqref{eqn:lm}.
The overall procedure is two-stage:
\begin{equation}
\begin{array}{l}
\text { step 1: } \quad \min _{\Theta} {L}_{{h}}(\Theta ; y, {f}(x)),\\
\text { step 2: } \quad \min _{\Theta} {L}_{{m}}\left(\Theta ; y, {f}(x)\right),
\end{array}
\label{eqn:obj}
\end{equation}
where $L_{m}$ is the loss function of distribution matching objective, and $L_{h}$ is the loss function of distribution estimation. We detail the whole process of the framework in Algorithm~\ref{alg:Framwork}.
The main merits of the two-stage learning are to 1) utilize the representation capability of the HNN model in the first stage and 2) learn the calibrated predictive distribution via the distribution matching strategy in the second stage. Compared with the bi-level learning algorithm used in~\cite{Kuleshov} which iterates the two stages for several times, our method runs with one time iteration of the two stages, which reduces the computation cost of the kernel-based MMD component.
\textbf{Comparison with Post-processing Calibration Methods}
The previous post-processing methods~\cite{Kuleshov,Thiagarajan,pearce2018high} calibrate the uncertainty outputs of the input dataset without any model modifications and needs to be retrained when the confidence level is changed. In contrast, the proposed distribution matching with MMD, albeit also regarded as a post-processing procedure, learns the calibrated predictive model, which means practitioners are not required to retrain the model but can enjoy the calibration performance.
\begin{algorithm}[htb]
\caption{ Deep calibrated reliable regression model.}
\label{alg:Framwork}
\begin{algorithmic}[1]
\REQUIRE ~~\\
Labeled training data and kernel bandwidth parameters \\
\ENSURE ~~\\
Trained mean $\mu(x_i)$ and variance $\sigma(x_i)$ for the predictive distribution
\WHILE{not converged
\STATE Compute $\mu(x_i)$ and $\log \sigma(x_i)$
\STATE Compute NLL loss $L_h$ by Eqn.~\eqref{eqn:l_h}
\STATE Update model parameters $\Theta = \arg \min _{\Theta} \mathrm{L}_{{h}}(\Theta ; y, f(x))$ by SGD
\ENDWHILE
\WHILE{not converged
\STATE Compute $\mu(x_i)$ and $\log \sigma(x_i)$, randomly sampling data $\{\hat{y_i}\}_{i=1}^{N}$ from predictive distrbution
\STATE Compute MMD loss $L_m$ by Eqn.~\eqref{eqn:lm}
\STATE Update model parameters $\Theta = \arg \min _{\Theta} \mathrm{L}_{{m}}(\Theta ; y, f(x))$ by SGD
\ENDWHILE
\RETURN a trained model $f(x)$;
\end{algorithmic}
\end{algorithm}
\section{Experiments}
In this section, we compare the proposed method with several strong baselines on the regression and time-series forecasting tasks in terms of predictive uncertainty.
The time-series forecasting task models multiple regression sub-problems in sequence and the tendency along the sliding windows can be used to examine the obtained predictive uncertainty.
Then we show the sensitivity analysis and the time efficiency of our proposed method.
\vspace{-0.3cm}
\subsection{Datasets and Experimental Settings}
\textbf{Baselines} We compare with several competitive baselines, including MC-Dropout~(MCD)~\citep{gal2016dropout}, Heteroscedastic Neural Network~(HNN)~\citep{Kendall}, Deep Ensembles~(Deep-ens)~\citep{Lakshminarayanan}, Ensembled Likehood~(ELL), MC-Dropout Likelihood~(MC NLL), Deep Gaussian Processes~(DGP)~\cite{salimbeni2017doubly} and the post-hoc calibration method using isotonic regression~(ISR)~\citep{Kuleshov}. ELL and MC NLL are our proposed variants inspired by Deep Ensemble. The variance of ELL is computed by predictions from multiple networks during the training phase, and the variance of MC NLL is computed by multiple random predictions based on MC-Dropout during the training phase. Details of these compared methods can be found in Appendix~\ref{sec:appendix-baseline}.
\textbf{Hyperparameters}
For all experimental results, we report the averaged results and std. errors obtained from 5 random trials.
The details of hyperparameters setting can be found in Appendix \ref{appendix:hyperparameters}.
\textbf{Datasets} We use several public datasets from UCI repository~\cite{Dua:2019} and Kaggle~\cite{Yannis:2017}: 1) for the time-series task: Pickups, Bike-sharing, PM2.5, Metro-traffic and Quality; 2) for the regression task: Power Plant, Protein Structure, Naval Propulsion and wine. The details of the datasets can be found in Appendix~\ref{sec:appendix-dataset}.
\textbf{Evaluation Metrics}
We evaluate the performance using two metrics: 1) RMSE for the prediction precision; and 2) the calibration error. The calibration error is the absolute difference between true confidence and empirical coverage probability. We use two variants: the expectation of coverage probability error (ECPE) and the maximum value of coverage probability error (MCPE). We put the detailed definitions of the metrics in Appendix~\ref{appendix:metric}.
\vspace{-0.3cm}
\subsection{Results of Time-series Forecasting Tasks}
For time-series forecasting tasks, we construct an LSTM model with two hidden layers (128 hidden units and 64 units respectively) and a linear layer for making the final predictions. The size of the sliding window is 5 and the forecasting horizon is 1. Take the Bike-sharing dataset as an example, the bike sharing data of the past five hours will be used to predict the data of one hour in the future.
All datasets are split into 70\% training data and 30\% test data.
\begin{table}[ht]
\centering
\begin{tabular}{|l|l|l|l|l|l|l|l|l|l|}
\hline
\toprule[1pt]
Dataset & Metric\ &MCD & HNN & Deep-ens & MC NLL \\ \midrule[1pt]
\multirow{2}{*}{Metro-traffic}
& ECPE\ & 0.304$\pm$0.005 & 0.102$\pm$0.002 &0.100$\pm$0.001 &0.142$\pm$0.010 \\
& MCPE\ &0.505$\pm$0.011 & 0.162$\pm$0.003 &0.160$\pm$0.002 &0.235$\pm$0.014 \\
& RMSE\ &523.6$\pm$6.725 &556.3$\pm$3.332 &\textbf{508.9$\pm$1.288} &631.6$\pm$14.23 \\
\hline
\multirow{2}{*}{Bike-sharing}
& ECPE\ &0.258$\pm$0.011 &0.054$\pm$0.002 &0.038$\pm$0.001 &0.119$\pm$0.013\\
& MCPE\ &0.432$\pm$0.020 &0.089$\pm$0.004 &0.066$\pm$0.008 &0.206$\pm$0.022\\
& RMSE\ &38.86$\pm$0.141 &40.71$\pm$0.542 &\textbf{37.60$\pm$0.355} &61.57$\pm$1.624 \\
\hline
\multirow{2}{*}{Pickups}
& ECPE\ &0.246$\pm$0.017 & 0.078$\pm$0.001 & 0.064$\pm$0.006 & 0.088$\pm$0.016\\
& MCPE\ &0.408$\pm$0.025 & 0.117$\pm$0.005 & 0.098$\pm$0.011 & 0.136$\pm$0.010\\
& RMSE\ &350.3$\pm$6.562 &359.8$\pm$3.421 &336.4$\pm$1.653 & 526.8$\pm$9.214\\
\hline
\multirow{2}{*}{PM2.5}
& ECPE\ &0.331$\pm$0.013 &0.022$\pm$0.001 &0.026$\pm$0.003 &0.081$\pm$0.010\\
& MCPE\ &0.550$\pm$0.025 &0.050$\pm$0.004 &0.060$\pm$0.004 &0.151$\pm$0.027\\
& RMSE\ &70.95$\pm$2.629 &58.81$\pm$0.372 &60.24$\pm$0.114 &66.77$\pm$3.613 \\
\hline
\multirow{2}{*}{Air-quality}
& ECPE\ &0.329$\pm$0.005 &0.058$\pm$0.003 &0.045$\pm$0.001 &0.111$\pm$0.004\\
& MCPE\ &0.561$\pm$0.008 &0.091$\pm$0.006 &0.072$\pm$0.002 &0.178$\pm$0.004\\
& RMSE\ &81.16$\pm$0.111 &\textbf{79.60$\pm$0.254} &80.03$\pm$0.236 &87.12$\pm$0.971 \\
\midrule[1pt]
Dataset & Metric & ELL & DGP & ISR & proposed\\ \midrule[1pt]
\multirow{2}{*}{Metro-traffic}
&ECPE &0.048$\pm$0.017 &0.115$\pm$0.007 &0.032$\pm$0.002 & \textbf{0.017$\pm$0.001} \\
&MCPE &0.075$\pm$0.027 &0.192$\pm$0.013 &0.051$\pm$0.003 & \textbf{0.036$\pm$0.002}\\
&RMSE &613.5$\pm$18.63 &646.4$\pm$0.302 &556.3$\pm$3.332 &545.5$\pm$4.225 \\
\hline
\multirow{2}{*}{Bike-sharing}
& ECPE &0.027$\pm$0.003 &0.121$\pm$0.003 &0.042$\pm$0.002 &\textbf{0.006$\pm$0.001}\\
& MCPE &0.048$\pm$0.055 &0.213$\pm$0.005 &0.066$\pm$0.005 &\textbf{0.019$\pm$0.002}\\
& RMSE &52.50$\pm$2.901 &55.39$\pm$0.397 &40.71$\pm$0.542 &37.93$\pm$0.334\\
\hline
\multirow{2}{*}{Pickups}
& ECPE & 0.018$\pm$0.008 &0.098$\pm$0.003 &0.049$\pm$0.002 &\textbf{0.008$\pm$0.001}\\
& MCPE & 0.038$\pm$0.016 &0.160$\pm$0.005 &0.075$\pm$0.004 &\textbf{0.023$\pm$0.001}\\
& RMSE &\textbf{325.9$\pm$11.23} &440.3$\pm$3.469 &359.8$\pm$3.421 &346.9$\pm$4.652\\
\hline
\multirow{2}{*}{PM2.5}
& ECPE &0.080$\pm$0.007 &0.061$\pm$0.006 &0.023$\pm$0.002 &\textbf{0.010$\pm$0.000}\\
& MCPE &0.119$\pm$0.011 &0.149$\pm$0.014 &0.057$\pm$0.006 &\textbf{0.035$\pm$0.003}\\
& RMSE &61.09$\pm$0.434 &61.44$\pm$2.113 &58.81$\pm$0.372 &\textbf{57.43}$\pm$0.332\\
\hline
\multirow{2}{*}{Air-quality}
& ECPE &0.018$\pm$0.005 &0.102$\pm$0.002 &0.030$\pm$0.001 &\textbf{0.010$\pm$0.001}\\
& MCPE &0.04$\pm$0.008 &0.181$\pm$0.003 &0.044$\pm$0.005 &\textbf{0.026$\pm$0.001}\\
& RMSE &90.01$\pm$0.566 &86.05$\pm$0.210 &79.60$\pm$0.254 &80.69$\pm$0.292\\
\hline
\end{tabular}
\caption{The forecast and calibration error scores of each method on different datasets. Each row corresponds to the results of a specific method in a particular metric.}
\label{tab:my_label_cali_t}
\end{table}
\vspace{-0.15cm}
\begin{figure}[htbp]
\vspace{-0.5cm}
\centering
\subfigure[Dataset: Air Quality.]{
\begin{minipage}[t]{0.45\linewidth}
\centering
\includegraphics[width=1\linewidth]{air_quality_ce.pdf}
\end{minipage}%
}%
\subfigure[Dataset: Bike Sharing.]{
\begin{minipage}[t]{0.45\linewidth}
\centering
\includegraphics[width=1\linewidth]{bike_sharing_ce.pdf}
\end{minipage}%
}
\centering
\vspace{-0.2cm}
\caption{For the time-series forecasting task, we plot the expected confidence vs observed confidence for all methods. The closer to the diagonal line, the uncertainty calibration is better. The results of other datasets can be found in Appendix.}
\vspace{-0cm}
\label{fig:cali_t_ce}
\end{figure}
Table \ref{tab:my_label_cali_t} present the results of all the methods, including the forecast and calibration errors.
We can see that our method with the MMD distribution matching strategy achieves the accurate forecasting results on par with the strong baselines in terms of RMSE\footnote{In Table \ref{tab:my_label_rse} in the Appendix, we also show the results in other metrics, such as $R^{2}$, SMAPE, etc., which have a similar conclusion.}, but significantly outperforms the baselines in the uncertainty calibration, in terms of ECPE and MCPE on all data-sets. Besides, we prefer prediction intervals as tight as possible while accurately covering the ground truth in regression tasks. We measure the sharpness using the width of prediction intervals, which is detailed in Appendix \ref{appendix:metric}. And
our method also gets a relatively tighter prediction interval through the reported calibration sharpness from Table \ref{tab:my_label_acc_t1} in the Appendix.
In addition, the ensemble method is second only to ours, due to the powerful ability of the ensemble of multiple networks. But when the network complexity is greater than the data complexity, the computation of the ensemble method is quite expensive, while our method can also be applied to more complex NNs.
Figure \ref{fig:cali_t_ce} shows the proportion that PIs covering ground truths at different confidence levels. The result of our model is closest to the diagonal line, which indicates the best uncertainty calibration among all methods.
Figure~\ref{fig:cali_t_pi} shows the predictions and corresponding 95\% prediction intervals. The intervals are visually sharp and accurately cover the ground truths.
\begin{figure}
\vspace{-0.6cm}
\centering
\subfigure[Dataset: Air Quality.]{
\begin{minipage}[t]{0.48\linewidth}
\centering
\includegraphics[width=1\linewidth]{air_quality_pi.pdf}
\end{minipage}%
}%
\subfigure[Dataset: Bike Sharing.]{
\begin{minipage}[t]{0.48\linewidth}
\centering
\includegraphics[width=1\linewidth]{bike_sharing_pi.pdf}
\end{minipage}%
}
\centering
\caption{Calibrated forecasting: Displayed prediction intervals (PIs) obtained at the 95\% confidence level by our proposed method in a time-series. As shown in the figure, the prediction intervals are also sharp while accurately covering the ground truth. The results of other datasets can be found in Appendix.}
\vspace{-0.5cm}
\label{fig:cali_t_pi}
\end{figure}
\vspace{-0.3cm}
\subsection{Results of Regression Tasks}
\vspace{-0.3cm}
For regression tasks, we used a fully connected neural network with two hidden layers (256 hidden units) and each layer has a ReLU activation function. The size of our networks is close to the previous works~\cite{gal2016dropout, Kuleshov, Lakshminarayanan} on regression problems. We evaluate on four UCI datasets varying in size from 4,898 to 45,730 samples. We randomly split 80\% of each data-set for training and the rest for testing. Table \ref{tab:my_label_reg} presents the results of all methods, where we can draw similar
conclusions as in the time-series forecasting tasks. The forecast results of our method is competitive in terms of RMSE and the calibration error of our method is significantly smaller than existing methods. Figure \ref{fig:cali_reg} reflects that the uncertainty calibration performance of each method at different confidence levels in general regression tasks and we find that our method significantly improves calibration.
\begin{table}[ht]
\centering
\begin{tabular}{|l|l|l|l|l|l|}
\hline
\toprule[1pt]
Dataset & Metric & MCD & HNN & Deep-ens & MC NLL \\ \midrule[1pt]
\multirow{3}{*}{Power Plant}
& ECPE &0.235$\pm$0.021 & 0.094$\pm$0.002 &0.084$\pm$0.004 &0.095$\pm$0.004 \\
& MCPE &0.386$\pm$0.038 & 0.151$\pm$0.007 &0.142$\pm$0.001 &0.153$\pm$0.004 \\
& RMSE &\textbf{3.792$\pm$0.171} &3.843$\pm$0.165 &3.945$\pm$0.150 &3.936$\pm$0.158 \\
\hline
\multirow{3}{*}{Protein Structure}
& ECPE &0.365$\pm$0.011 &0.042$\pm$0.006 &0.049$\pm$0.001 &0.086$\pm$0.005 \\
& MCPE &0.635$\pm$0.021 &0.071$\pm$0.005 &0.084$\pm$0.002 &0.138$\pm$0.005 \\
& RMSE &\textbf{4.088$\pm$0.014} &4.337$\pm$0.021 &4.255$\pm$0.010 &4.574$\pm$0.018 \\
\hline
\multirow{3}{*}{Naval Propulsion}
& ECPE &0.175$\pm$0.077 & 0.038$\pm$0.006 & 0.270$\pm$0.016 & 0.216$\pm$0.042 \\
& MCPE &0.283$\pm$0.116 & 0.065$\pm$0.007 & 0.431$\pm$0.025 & 0.344$\pm$0.047 \\
& RMSE &0.001$\pm$0.000 & 0.001$\pm$0.000 & 0001$\pm$0.000 & 0.001$\pm$0.001 \\
\hline
\multirow{3}{*}{Wine}
& ECPE &0.235$\pm$0.021 &0.041$\pm$0.003 &0.012$\pm$0.001 &0.046$\pm$0.006 \\
& MCPE &0.386$\pm$0.038 &0.082$\pm$0.013 &0.034$\pm$0.004 &0.095$\pm$0.011 \\
& RMSE &0.732$\pm$0.041 &0.705$\pm$0.038 &\textbf{0.672$\pm$0.040} &0.683$\pm$0.064 \\
\hline
\midrule[1pt]
Dataset & Metric & ELL &DGP &ISR & proposed\\
\midrule[1pt]
\multirow{3}{*}{Power Plant}
& ECPE &0.019$\pm$0.025 &0.094$\pm$0.005 &0.062$\pm$0.003 & \textbf{0.007$\pm$0.001} \\
& MCPE &0.035$\pm$0.037 &0.158$\pm$0.008 &0.105$\pm$0.003 & \textbf{0.024$\pm$0.003}\\
& RMSE &4.186$\pm$0.184 &4.181$\pm$0.009 &3.843$\pm$0.165 &3.819$\pm$0.112 \\
\hline
\multirow{3}{*}{Protein Structure}
& ECPE &0.038$\pm$0.009 &0.020$\pm$0.002 &0.014$\pm$0.006 &\textbf{0.006$\pm$0.000}\\
& MCPE &0.075$\pm$0.016 &0.036$\pm$0.004 &0.027$\pm$0.010 &\textbf{0.024$\pm$0.002}\\
& RMSE &4.519$\pm$0.019 &4.950$\pm$0.011 &4.337$\pm$0.021 &4.556$\pm$0.012\\
\hline
\multirow{3}{*}{Naval Propulsion}
& ECPE & 0.059$\pm$0.034 &0.115$\pm$0.007 &0.021$\pm$0.003 &\textbf{0.012$\pm$0.001}\\
& MCPE & 0.117$\pm$0.051 &0.192$\pm$0.012 &0.036$\pm$0.010 &\textbf{0.030$\pm$0.004}\\
& RMSE & 0.002$\pm$0.001 &0.001$\pm$0.000 &0.001$\pm$0.000 &\textbf{0.001$\pm$0.000}\\
\hline
\multirow{3}{*}{Wine}
& ECPE &0.073$\pm$0.009 &0.178$\pm$0.003 &0.083$\pm$0.006 &\textbf{0.008$\pm$0.002}\\
& MCPE &0.103$\pm$0.011 &0.300$\pm$0.006 &0.127$\pm$0.008 &\textbf{0.024$\pm$0.004}\\
& RMSE &0.684$\pm$0.061 &0.754$\pm$0.031 &0.705$\pm$0.038 &0.705$\pm$0.035\\
\hline
\end{tabular}
\caption{The calibration error scores of uncertainty evaluation and RMSE for each method on different datasets, each row has the results of a specific method in a particular metric. Our method improves calibration and outperforms all baselines}
\label{tab:my_label_reg}
\end{table}
\vspace{-0.3cm}
\begin{figure}[htbp]
\vspace{-0.7cm}
\centering
\subfigure[Dataset: Naval Propulsion.]{
\begin{minipage}[t]{0.48\linewidth}
\centering
\includegraphics[width=1\linewidth]{propulsion_ce.pdf}
\end{minipage}%
}%
\subfigure[Dataset: Protein Structure.]{
\begin{minipage}[t]{0.48\linewidth}
\centering
\includegraphics[width=1\linewidth]{protein_ce.pdf}
\end{minipage}%
}
\centering
\caption{For the regression task,we plot the expected confidence vs observed confidence for all methods. The closer to the diagnoal line, the uncertainty calibration is better. The results of other datasets can be found in Appendix.}
\label{fig:cali_reg}
\end{figure}
\vspace{-0.3cm}
\subsection{Computation Efficiency}
\vspace{-0.25cm}
We analyze the time complexity on the type of methods that generate the uncertainty distribution,
these methods are relatively computationally expensive: DGP, Deep Ensembles, ELL and our proposed method. For the regression task, these four methods use the same network structure with a fully connected neural network (256 hidden units) at each hidden layer. The training and inference of DGP is performed using a doubly stochastic variational inference algorithm~\cite{salimbeni2017doubly}. As can be seen in Figure~\ref{fig:eff}, DGP is the most time-consuming, the training time increases almost linearly as the number of network layers increases. The computation time of our method is the least among all methods when model complexity becomes higher, and can also keep low calibration error. This result coheres our argument that our method is not computationally expensive compared to the baseline methods.
\vspace{-0.3cm}
\begin{figure}[htbp]
\centering
\subfigure[Computation time.]{
\begin{minipage}[t]{0.45\linewidth}
\centering
\includegraphics[width=1\linewidth]{compute_time.pdf}
\end{minipage}%
}%
\subfigure[Calibration errror.]{
\begin{minipage}[t]{0.45\linewidth}
\centering
\includegraphics[width=1\linewidth]{compute_time_pre.pdf}
\end{minipage}%
}
\centering
\caption{The computation time (log seconds) of four methods during model training phase (left) and calibration error of different models (right) on the wine dataset on GTX1080Ti. We can see that our method is also effective in computing efficiency and calibration for more complex models.}
\label{fig:eff}
\end{figure}
\vspace{-0.3cm}
\section{Conclusion and Discussions}
We present a flexible and effective uncertainty calibration method with the MMD distribution matching strategy for regression and time-series forecasting tasks.
Our method is guaranteed to produce well-calibrated predictions given sufficient data under mild assumptions.
Extensive experimental results show that our method can produce reliable predictive distributions, and obtain the well-calibrated and sharp prediction intervals.
There are several directions for future investigation. Firstly, the Gaussian likelihood may be too-restrictive sometimes and one could use a mixture distribution or a complex network, e.g., mixture density network~\citep{bishop1994mixture} as a base model.
Secondly, our calibration strategy can be extended to classification tasks. But the challenge we need to overcome is the impact of batch-size and binning on the performance of MMD.
Thirdly, the kernels used in the MMD definition can be defined on other data structures, such as graphs and time-series~\cite{hofmann2008kernel}.
Finally, it is interesting to investigate on the sample size for a given task. Specifically, we provide an asymptotic analysis on well-calibration, while in practice we only have finite data. \cite{gretton2012kernel} shows that MMD has performance guarantees at finite sample sizes, based on uniform convergence bounds. For our method, regardless of whether or not $p=q$, the empirical MMD converges in probability at rate $O((m+n)^{-\frac{1}{2}})$ to its population value, where $m$ and $n$ respectively represent the number of samples sampled from $P$ and $Q$. So a further investigation on the bound of our method is worth considering in the future work.
\section*{Statement of Potential Broader Impact}
Uncertainty exists in many aspects of our daily life, which plays a critical role in the application of modern machine learning methods.
Unreliable uncertainty quantification may bring \textit{safety and reliability} issues in these applications like medical diagnosis, autonomous driving, and demand forecasting.
Despite deep learning has achieved impressive accuracies on many tasks, NNs are poor to provide accurate predictive uncertainty.
Machine learning models should provide accurate confidence bounds (i.e., uncertainty estimation) on these safety-critical tasks.
This paper aims to solve the problem of inaccurate predictive quantification for regression models. Our method produces the well-calibrated predictive distribution while achieving the high-precision forecasting for regression tasks, and naturally generate reliable prediction intervals at any confidence level we need.
Our proposal has a positive impact on a variety of tasks using the regression models. For example, our proposed model produces more accurate demand forecasting based on the historical sales data for a retail company, which can calculate the safety stock to make sure you don't lose customers. We believe that it is necessary to consider the uncertainty calibration for many machine learning models, which will improve the \textit{safety and reliability} of machine learning and deep learning methods.
\section*{Acknowledgement}
We would like to thank the anonymous reviewers for their useful comments, especially for review 1 and review 3. Part of this work was done when the first two authors were working at RealAI. This work was supported by the National Key Research and Development Program of China (No.2017YFA0700904), NSFC Projects (Nos. 61620106010, U19B2034, U1811461), Beijing Academy of Artificial Intelligence (BAAI), Tsinghua-Huawei Joint Research Program, a grant from Tsinghua Institute for Guo Qiang, Tiangong Institute for Intelligent Computing, and the NVIDIA NVAIL Program with GPU/DGX Acceleration.
| {'timestamp': '2020-10-29T01:12:09', 'yymm': '2006', 'arxiv_id': '2006.10255', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10255'} | arxiv |
\section{Introduction}
\IEEEPARstart{U}{ltrasound} (US) is a low-cost, non-invasive and portable imaging modality, and it has been widely used in the clinical routine, especially for obstetrics and gynaecology as it does not involve ionizing radiation.
However, ultrasound scanners produce images suffering from limited spatial resolution, signal-to-noise ratio and tissue contrast, which make the interpretation of images very difficult.
Clinical ultrasound practice relies exclusively on sonographer expertise in navigating a hand-held probe and visual inspection of the acquired images; and an extensive training is required for being able to conduct such clinical examinations.
The current education is mostly based on training on real patients, under the guidance of expert specialists.
This form of education is inefficient due to time consumption of both specialists and patients and involve difficulties in finding volunteers especially when rare pathologies are concerned.
Indeed, after completing the one year education students will only have seen up to 80\% of possible pathologies~\cite{kohn2004ves}.
Learning from real ultrasound images offline for training is an alternative option that does not require volunteers. However, this approach does not allow interactive training and is highly restricted to the available clinical images.
Computer-assisted ultrasound simulation can aid training, especially important for rare pathologies, which are still vital to identify.
New scenarios of any given case can be simulated with transformations on pre-collected data, and different imaging parameters and conditions can be simulated from the same data.
Furthermore, computerized simulations would allow for training in a real-time virtual-reality environment with complex anatomical scenarios and various pathologies, from which the medical students can obtain in-depth knowledge of possible clinical scenarios during training.
Wave propagation, convolution and ray-based methods are the three major techniques for US simulation.
Wave-based approaches~\cite{verweij2014, treeby2012modeling} model ultrasound propagation in tissue by solving complex acoustic wave equations.
Therefore, these approaches are relatively slow and not suitable for real-time applications.
Convolution-based~\cite{jensen1996field} methods approximate the ultrasound interactions as a spatial impulse response (point-spread function, PSF), which is then convolved with a representation of sub-wavelength tissue structures, known as \emph{scatterers}, under the assumption that the acoustic field is linear.
This can realistically reproduce typical ultrasound noisy texture, known as speckle, caused by the constructive and destructive inference of echoes scattered by countless tissue scatterers.
On the one hand, speckle can be seen as noise that degrades tissue contrast~\cite{tay2010ultrasound}, but on the other hand, it can help distinguish tissues and identify pathologies~\cite{alessandrini2011restoration}.
Restoration of this granular pattern is not only important for visual realism in a simulation scenario, but also for preserving structural and diagnostic information about the tissue.
Ray-based methods~\cite{burger2012real,mattausch2018realistic} simulate the propagation of ultrasonic wavefront as rays using computed graphics techniques, which allows to simulate interactions such as refractions and reflections, while simulating speckle using a PSF convolution with a texture representing scatterers.
Using stochastic and sophisticated interaction models with Monte-Carlo ray sampling, this was shown in~\cite{mattausch2018realistic} to lead to impressively realistic US images even at real-time framerates.
There are recent works that use deep learning, and in particular generative adversarial networks, for ultrasound image synthesis~\cite{hu2017freehand, tom2018simulating}.
Nevertheless, these works aim to synthesize isolated individual images, without any intermediate (physical space) representation or parametrization, they are not designed for simulating images with speckle motion coherent with underlying physical motion, and therefore may not be applicable in a real-time, interactive simulation framework where temporal continuity of simulated frames is utmost important.
In other words, for an infinitesimal movement of the probe to one side should result in the image moving infinitesimally to the other side.
If every image is generated somewhat independently, this behaviour and the visual fluidity cannot be guaranteed.
Whereas, using a fixed scatterer representation, the above condition can be satisfied.
Such tissue representations can also allow scene editing operations such as copying and adding anatomy in the scatterer domain avoids any image artifacts, as shown in~\cite{mattausch2017image}.
The problem with using scatterers in simulations is that such tissue representations are not known a priori.
Assuming it can be modeled as a PSF convolution, finding a representation from observed US data can then be posed as a blind deconvolution problem.
There has been several approaches and approximations to this problem, including inverse problem based solutions~\cite{chen2015compressive}, variational methods~\cite{zhao2016joint, alessandrini2011expectation}, and filtering techniques~\cite{michailovich2007blind, taxt1995restoration}.
Different from our motivation of ultrasound simulation, however, the above methods aim for image denoising / restoration to achieve higher contrast or quality for better diagnostic information.
An iterative solution to the regularized deconvolution problem was proposed in~\cite{mattausch2017image} by solving the inverse problem jointly for multiple acquisitions of the same tissue, which are obtained efficiently with electronic beam steering.
This allows to overconstrain the problem with observations from multiple PSFs.
Discrete scatterer reconstructions were performed on a fine Cartesian grid in order to approximate sub-wavelength particles, where sparsity was enforced by using an $\ell_1$-norm regularization.
However, solving such inverse problem is computationally and memory-wise only possible for small patches, which were tiled in~\cite{mattausch2017image} over the imaging field, and still required hours to days to solve for a single image.
Accordingly, such a method is not efficient and scalable for scans of many images or to apply in 3D.
Scatterers can alternatively be estimated as statistical distributions of random variables.
A pipeline for generating synthetic echocardiographic ultrasound sequences was presented in~\cite{alessandrini2015pipeline}.
This was later extended to simulate vendor specific US images for speckle tracking algorithms~\cite{alessandrini2017realistic}.
For this purpose, a scatterer space was populated with randomly sampled 3D cloud points, whose amplitudes were assigned according to the template B-Mode images after the compensation for the log-compression.
Simulated speckle statistics were reported to be in good agreement with the known fitting distributions.
This approach however does not take the point spread function, and therefore the constructive and destructive interference between scatterers into account, and sampling from B-mode (similarly from RF envelope) assumes scatterers all contributing non-negatively, which is not the case for modulated RF nature of typical US PSF.
A simple Gaussian-parametrized model was fit to the inverse-problem reconstructed scatterers in~\cite{mattausch2015scatterer}.
This method was demonstrated for homogeneous tissues that other instances of the same tissue can be obtained with the found model for simulating new images, which are however reported as lack of visual variety of real tissues in~\cite{mattausch2018realistic}.
For a given statistical model for scatterer distribution, we propose herein to estimate distribution parameter maps directly from observed ultrasound images.
This can be used to instantiate new scatterer maps that would reproduce the original images when input to a convolution-based simulation.
As the estimated parameter maps would represent a physical tissue space, they could be used to simulate new images faithfully with varying imaging conditions, viewing directions, and other imaging parameter variations.
Due to the power of deep neural networks in learning patterns of visual inputs, we propose to learn the mapping between simulated images and parameter maps by training a convolutional neural network.
\section{Background}
\subsection{Forward Problem of Ultrasound Simulation}
Based on the first order Born approximation (weak scattering) for soft tissues~\cite{jensen1993deconvolution}, the interaction between ultrasound field and tissue scatterers can be formulated as a 2D convolution model in discrete domain:
\begin{equation}
\mathbf{I}[l,a] = \mathbf{g}[l,a]*\mathbf{h}[l,a] + \bm{\gamma}[l,a],
\label{eq:forward_model}
\end{equation}
with radio-frequency (RF) US image intensity $\mathbf{I}[l,a]$, scatterer intensity $\mathbf{g}[l,a]$, spatial variant point spread function (PSF) $\mathbf{h}[l,a]$ and noise term $\bm{\gamma}[l,a]$.
$[l,a]$ are the lateral and axial coordinates with respect to the probe origin, elevational thickness is ignored here.
Ultrasound point spread function can be approximated with a two dimensional Gaussian kernel modulated by a cosine function in the axial direction~\cite{burger2012real}, i.e.:
\begin{equation}
\mathbf{h}[l,a] = e^{-\frac{l^2}{\sigma_l^2}-\frac{a^2}{\sigma_a^2}} \cos(2\pi f_c a),
\label{eq:psf}
\end{equation}
where $f_c$ is the transducer center frequency, $\sigma_l$ and $\sigma_a$ determines the Gaussian shape along the lateral and axial direction.
Due to nonuniform focusing and aperture, the PSF in US imaging is often assumed to be spatial-variant mainly along the axial direction~\cite{nagy1998restoring, mattausch2017image, alessandrini2011restoration}.
Some recent works model PSF as continuously non-stationary blurring, such as based on semigroup theory~\cite{michailovich2017non} and with the diffraction effects during wave propagation~\cite{besson2019physical}.
For deconvolution tasks, PSF has often been assumed to be patchwise invariant, an approach we also adopt in this paper.
\subsection{Inverse Problem of Scatterer Reconstruction}
Eq.~(\ref{eq:forward_model}) can be equivalently written in a matrix-vector form as $\mathbf{Ax} + \mathbf{n} = \mathbf{b}$ with the convolutional matrix $\mathbf{A} \in \mathbb{R}^{M \times N}$ associated with PSF, a vector of scatterer amplitudes $\mathbf{x} \in \mathbb{R}^{N}$, RF image intensities $\mathbf{b} \in \mathbb{R}^{M}$ and the acquisition noise term $\mathbf{n} \in \mathbb{R}^{M}$.
Assuming that $N=M$ and imposing no constraints on $\mathbf{x}$, a solution of this system of linear equations is referred to as the tissue reflectivity function (TRF)~\cite{taxt1995restoration, zhao2016joint}.
To mitigate ill-posed nature of this deconvolution problem, regularization is typically imposed to introduce a prior knowledge about the solution.
Wiener filter~\cite{hundt1980digital} is a common choice for efficient image deconvolution, which solves the inverse problem based on $\ell_2$-norm regularization of the solution magnitude.
Other regularizations have been also widely explored, such as a $\ell_1$ or $\ell_p$-norm based on the assumption of Laplacian~\cite{michailovich2007blind} and generalized Gaussian distribution~\cite{alessandrini2011restoration} for the TRF $\mathbf{x}$.
Several computationally efficient methods have been proposed for TRF deconvolution with sophisticated forward models, such as axially varying kernels~\cite{florea2018axially}, physical model accounting for diffraction effects~\cite{besson2019physical}.
However, such TRF representation is difficult to attribute to a physical quantity and without any constraints on $\mathbf{x}$, the Wiener filter solution may overfit to the observation $\mathbf{b}$, e.g. a slight change in acquisition parameters may yield largely different TRF estimates.
For image simulation purpose, estimated discrete scatterer map $\mathbf{x}$ needs to have sufficiently fine resolution to approximate the underlying continuum of scatterers, hence $N\gg M$.
Mauttausch et al.~\cite{mattausch2017image} used the $\ell_1$ norm, favoring sparse scatterer map.
Assuming a Laplacian noise distribution for $n$, the objective is formulated as follows:
\begin{equation}
\mathbf{\hat{x}} = \arg \min_\mathbf{x} ||\mathbf{Ax}-\mathbf{b}||_1 + \lambda||\mathbf{x}||_1, \quad \textrm{s.t.} \, \mathbf{x}\geq 0,
\end{equation}
with a regularization parameter $\lambda$.
This formulation, known as regularized least absolute deviations (RLAD), allows more robust solution with respect to outliers in the error function, which could be caused by wave interactions other than scattering, e.g. directional reflections.
\section{Methods} \label{Sec: methods}
For US simulation, we aim to find a tissue representation from observed image, which can be used to simulate the same tissue with varying imaging conditions.
Rather than estimating a deterministic scatterer locations and amplitudes by solving a large-scale inverse problem, we proposed to impose a statistical model on the scatterer distribution and infer corresponding parameters from the observation.
We learn the mapping from a single US image to its parameter map in a supervised manner.
The required paired data are generated by simulation, since no ground truth of tissue scatterer is available.
An overview of our proposed pipeline, referred as ScatParam, can be seen in Fig.1(a).
\begin{figure*}
\centering
\minipage{0.7\textwidth}
\centering
\includegraphics[width=1\linewidth]{pipeline_new.png}
\caption*{(a)}
\endminipage
\hfill
\minipage{0.3\textwidth}
\centering
\includegraphics[width=1\linewidth]{network_architecture.png}
\caption*{(b)}
\endminipage
\caption{(a) Illustration of the proposed pipeline, note that PSF and scatterer maps are sampled for each training pair. (b) ScatParam CNN: we use stride of 2 to downsample axial dimension with image size indicated on the left for each layer, while the number of filters is shown on top of each layer.
}
\label{fig:pipeline}
\end{figure*}
\subsection{Statistical Model of Scatterer Distribution}
We assume that each tissue type can be parametrized by a model with three parameters $(\rho_s, \mu_s, \sigma_s)$, the parameter $\rho_s\in[0,1]$ for scatterer density, the mean $\mu_s$ and standard deviation $\sigma_s$ for scatterer amplitude modeled to be normally distributed.
Scatterer maps are sampled as follows: for each pixel, a Bernoulli distributed random variable is sampled, where the pixel takes the value one with probability $\rho_s$ and zero with $1-\rho_s$. For non-zero pixels, their amplitudes are sampled from a Gaussian distribution $\mathcal{N}(\mu_s, \sigma_s)$.
Tissue scattering strength is controlled by the mean, while $\sigma_s$ models random fluctuations around that mean.
Since we only consider fully developed speckles, we set $\rho_s$ to a fixed value satisfying the Rayleigh criterion; herein set to a minimum of 100 scatterers per $\textrm{mm}^2$ for a fully-developed speckle pattern~\cite{oosterveld1985texture}.
The Rayleigh criterion and distribution statistics for estimating interference with isolated scatterers~\cite{oosterveld1985texture} has only been studied for scatterers distributed randomly at continuum spatial locations.
Typical convolution based simulation packages, such as Filed\,II~\cite{jensen1996field} and SIMUS~\cite{shahriari2018meshfree}, accordingly use scatterer representations with floating-point locations in continuum domain.
Reconstructing these on a discrete map therefore necessitate a sufficiently high grid resolution to approximate the continuum.
Following~\cite{mattausch2017image} we choose to use an isotropic grid spacing (i.e.\ Cartesian grid) with the native axial resolution of the raw RF data, which inherently also satisfies the Nyquist criterion for lateral sampling.
For instance, for a sampling frequency of 40 MHz and speed-of-sound of 1540 m/s, we use a scatterer map with a resolution of roughly $20\,\mu$m and with 5\% of the pixels populated with scatterers, resulting in a scatterer density of 130 per $\textrm{mm}^2$.
\subsection{Training Set Generation}
Since scatterers are an abstract tissue representation, no point-wise ground truth exists, thus we create network training data by means of simulation.
For parameter map generation, we use random synthetic shapes by overlapping irregular geometric shapes, with a procedure similar to~\cite{vishnevskiy2019deep}, where random coarse gray-scale patterns are interpolated at a finer resolution and finally thresholding them to create random shapes, as exemplified in Fig.~\ref{fig:training_images}(a).
These aim to represent a rich variety of potential tissue structures without assuming particular anatomical priors, both to be invariant to any anatomical assumptions and region-of-interest as well as to allow the network for better generalization.
We assume uniform distribution for Gaussian mean: $\mu_s \sim \mathcal{U}(0,1)$ and a fixed Gaussian standard deviation $\sigma_s=0.05$.
We assign one sampled mean value to each region, assuming the scatterers in each tissue region following the same distribution.
The scatterer maps are sampled according to the procedure described in Section~\ref{Sec: methods}(A).
RF images are generated by convolving a sampled scatterer map with a PSF.
We assume spatially invariant PSFs for image patches, allowing very fast US image generation.
PSFs are sampled from the analytic expression in Eq.~(\ref{eq:psf}), with the transducer center frequency $f_c = 6$ MHz, the sampling frequency $f_s = 40$\,MHz and normalized by its $\ell_2$ norm.
The vertical and axial spreading are uniformly sampled from $\sigma_l^2 \in [0.2,1]$ $\textrm{mm}^2$ and $\sigma_a^2 \in [0.02,0.05]$ $\textrm{mm}^2$.
The images are then corrupted by additive Gaussian noise.
The noise level was uniformly sampled in the interval $[2, 20]\%$ of the average signal value.
The envelope images are used as the input to the neural network, which are taken as the absolute value of Hilbert transform of RF images, illustrated in Fig.~\ref{fig:training_images}(b).
For training, 4000 parameter maps of 64$\times$128 pixels with the random geometric shapes above were first generated offline.
Then on-the-fly during each training batch, random scatterer maps were spatially sampled from a random subset of the parameter maps, following which PSF convolution and envelope detection (Hilbert transform) were also carried out on-the-fly for each training image.
\begin{figure}
\centering
\minipage{0.16\textwidth}
\centering
\includegraphics[width=1\linewidth]{gt_imgs.png}
\caption*{(a)}
\endminipage
\minipage{0.16\textwidth}
\centering
\includegraphics[width=1\linewidth]{env_imgs.png}
\caption*{(b)}
\endminipage
\minipage{0.16\textwidth}
\centering
\includegraphics[width=1\linewidth]{nn_imgs.png}
\caption*{(b)}
\endminipage
\caption{Generation of training images: (a)~scatterer parameter maps, (b)~envelope images simulated with scatterers sampled from the corresponding parameter maps, and (c)~the corresponding parameter maps estimated by our method. }
\label{fig:training_images}
\end{figure}
\subsection{Network Architecture and Training}
The general network architecture for ScatParam is illustrated in Fig.~\ref{fig:pipeline}(b).
An encoder-decoder network is used to extract features from the input US image and estimate its corresponding parameter map, used for scatterer map sampling.
The model comprises an encoder and a decoder part along the axial direction, with skip connections between the corresponding layers.
This design choice is due to very low lateral resolution in US imaging being $10-20$ times lower than the axial.
Parameter maps are estimated at a coarser axial resolution than input envelope images, assuming spatially smooth tissue content.
This facilitates a more efficient utilization of network weights and hence inference power.
Our preliminary experiments with equally high resolution in encoder and decoder did not indicate results substantially superior to our presented architecture.
We use strided convolution to perform layer pooling and upsampling.
Exponential linear unit activation~\cite{clevert2015fast} is used at each layer except the output layer, which is linear.
The network is trained using Adam optimizer~\cite{kingma2014adam} with a learning rate of $10^{-4}$, minimizing the $\ell_1$-norm based loss function between the true $\mathbf{x}$ and estimated parameter maps $\hat{\mathbf{x}}$ given the acquisition $\mathbf{y}$ as the input:
\begin{equation}
L(\Theta) = \mathbb{E} \|\mathbf{x} - \hat{\mathbf{x}}(\mathbf{y};\Theta)\|_1,
\end{equation}
with the network parameters $\Theta$, the empirical average $\mathbb{E}$ over the training sampling procedure.
The batch size is set to 16.
The network is trained for 20000 iterations.
The proposed pipeline shown in Fig.~\ref{fig:pipeline} is summarized as follows:
\begin{enumerate}
\item Data generation: simulation of synthetic ultrasound images involves scatterer map sampling and convolution with point spread functions;
\item Offline training: a convolutional neural network is trained with the simulated paired data for parameter map estimation;
\item Scatterer distribution estimation and sampling: for each observation, a scatterer map is sampled from the estimated distribution parameter map for synthesizing new images;
\item Convolution-based simulation: the sampled scatterer map is fed into the convolution based simulator, which generates images with desired imaging parameters in real time.
\end{enumerate}
\section{Experiments and Results} \label{experiments}
We study our proposed method comparatively to its alternatives with experiments conducted on numerical simulations of synthetic phantoms, as well as on actual data acquired from a gelatin phantom and in vivo tissue.
Given the background above, we consider three alternatives to compare our method against:
\begin{itemize}
\item Sampling scatterers from envelope image ({\bf SampleEnv}): This is an adaptation of the method proposed in~\cite{alessandrini2015pipeline} for sampling continuous scatterers from log-uncompressed B-mode images.
We herein adapt this to sample on discrete scatterer maps and, for better accuracy, we use the original envelope images instead, as we have access to them.
Background (non-myocardial) scatterer amplitudes in~\cite{alessandrini2015pipeline} were updated at each simulation step using the corresponding input image. Treating scatterers as physical tissue-embedded entities, we herein keep their amplitudes fixed while their spatial locations may change, similarly to the works on displacement tracking and elastography.
\item Tissue reflectivity function ({\bf TRF}) : This is the simple Wiener filter estimation to the deconvolution inverse problem~\cite{jensen1994nonparametric, taxt1995restoration}.
We use a spatially constant filter kernel, as the PSF computed or estimated at the center of the imaged field of view.
\item Iterative scatterer reconstruction ({\bf ScatRec})~\cite{mattausch2017image} : This is an inverse problem based approach is referred here as ScatRec~\cite{mattausch2017image}, which reconstructs scatterer map based on a single observation.
\item Deep Learning based estimation of parametric scatterer maps ({\bf ScatParam}) : This is our proposed method trained on simulated images, as detailed in the previous section.
\end{itemize}
For deconvolution based methods, TRF and ScatRec, in simulated data we used the known PSF from the simulations and for acquired data, we used a cepstrum-domain PSF estimation method described in~\cite{mattausch2016image}, followed by least square fitting to the known parametric form in Eq.~(\ref{eq:psf}) to project them on our PSF model manifold, which our trained network is better conditioned on.
Since different scatterer representations cannot be compared directly and no ground truth is available, we evaluated the performance of scatterer estimation on the envelope images simulated from the estimated scatterer maps.
For re-synthesizing images, we used the same forward simulation for all the methods, namely a discrete image-space convolution of the scatterers estimated by any particular method with the same depth-dependent PSFs estimated for deconvolution based methods.
The convolution was implemented in Matlab to operate separately for each PSF on rows of image pixels.
\subsection{Evaluation Metrics}
Several evaluation metrics are utilized to assess the simulation performance and compare our method ScatParam with SampleEnv, TRF, and ScatRec.
Three image-based metrics, mean image intensity (I), signal-to-noise ratio (SNR), contrast-to-noise ratio (CNR) and one histogram based metric, Kullback-Leibler (KL) divergence, are used to calculate the mismatch between ground truth and simulated envelope images.
\textbf{Mean Image Intensity (I)} can capture any global intensity shift in the simulated images, which can be caused by systematic biases in constructive or destructive interference when the scatterers are not distributed truly stochastically or in a view-dependent way.
For instance, if the scatterers estimated from one direction align in a structured way, when the object is imaged from an oblique direction (e.g., with the half-wavelength projected on the rotation angle aliased with the structure), these scatterers may then interfere with each other mostly destructively, creating an artificial intensity drop in the image.
The change in mean image intensity is calculated as follows
\begin{equation}
\Delta \textrm{I} = \frac{|\textrm{I}_t-\textrm{I}_s|}{\textrm{I}_t}, \quad \textrm{with} \quad \textrm{I} = \frac{1}{N} \sum_{j=1...N} s_j,
\end{equation}
where $s_j$ denotes the image intensity value at the $j$-th pixel, and
$N$ is the number of pixels.
$\textrm{I}_t$ and $\textrm{I}_s$ are the mean image intensities of ground truth and simulated image, respectively.
Hereafter, the subscript $t$ refers to the ground truth and $s$ to a simulated image.
\textbf{Signal-to-noise Ratio (SNR)} measures the global statistics of signal-and-noise ratio.
For the simulation purpose, we aim at reproducing the images at the same SNR level as the ground truth.
Any mismatch in SNR is then quantified as follows
\begin{equation}
\Delta \textrm{SNR} = \frac{|\textrm{SNR}_t-\textrm{SNR}_s|}{\textrm{SNR}_t}, \quad \textrm{with} \quad \textrm{SNR} = \frac{\mu}{\sigma},
\end{equation}
where $\mu$ and $\sigma$ denote the mean and standard deviation of envelope image intensities.
\textbf{Contrast-to-noise ratio (CNR)} mismatch is defined similarly as
\begin{equation}
\Delta \textrm{CNR} = \frac{|\textrm{CNR}_t-\textrm{CNR}_s|}{\textrm{CNR}_t}, \quad \textrm{with} \quad \textrm{CNR} = \frac{|\mu_{s1}-\mu_{s2}|}{\sigma_{s1}+\sigma_{s2}},
\end{equation}
where $\mu_{s1}$, $\mu_{s2}$, $\sigma_{s1}$, and $\sigma_{s2}$ denote the means and standard deviations of the image intensities within two contrasting regions.
This metric is clinically relevant, as incorrect tissue contrast in the simulated images may lead to the learning of false diagnostic cues during medical training.
\textbf{Kullback-Leibler (KL) divergence} compares the statistics between the histograms of two images as follows:
\begin{equation}
\textrm{KL} (h_s || h_t) = \sum_{l=1...D} h_s[l] \log\left(\frac{h_s[l]}{h_t[l]}\right),
\end{equation}
where $h_t$ and $h_s$ are the normalized histograms of the true and simulated images respectively. The number of histogram bins $D$ is set herein to $50$.
Histogram statistics are widely explored for tissue characterization~\cite{shankar1993use, tsui2008classification}.
Hence, a large discrepancy in the histograms could indicate a mismatch in the speckle pattern appearance.
Since computing histograms over the whole image could miss local speckle texture information, we calculate a KL divergence metric locally within patches (herein non-overlapping patches of $3\times3\,\textrm{mm}^2$ corresponding to 10\,$\lambda$ per dimension) and report herein the metric mean over all patches.
For calculating $\Delta$SNR, $\Delta$CNR and KL divergence, simulated image ($s$) is normalized (or brightness equalized) with respect to ground truth image ($t$) by multiplying a factor $\frac{\sum_j t_j}{\sum_j s_j}$ similarly to~\cite{mattausch2017image}, to eliminate effects in these metrics from any global intensity shift, which is captured separately by $\Delta \textrm{I}$.
\subsection{Synthetic Data}
This experiment evaluates the invariance of the reconstructed scatterer maps to various US imaging parameters.
To that end, we used simulated images from Field\,II with controllable imaging conditions.
A numerical phantom of $15\times15\,\textrm{mm}^2$ with a 3\,mm circular inclusion was simulated for imaging at 6.0\,MHz center frequency, with a 128 element 40\,mm linear transducer, a single transmit focus at the center, and dynamic receive focusing.
The phantom is placed 15\,mm away from the transducer to avoid near field effects.
We evaluate the simulation results for
1) phantom rotation, which emulates imaging a region of interest from different viewing directions;
2) phantom compression, which emulates image plausibility under potential tissue deformation, e.g. induced by probe compression.
\subsubsection{Rotation Experiment}
In this experiment, we evaluate the invariance of the reconstructed scatterer maps to phantom rotation.
For this, the box phantom were rotated around the phantom center with varying angles.
Fig.~\ref{fig:rotation_inclusion} illustrates the results for the rotated views.
\begin{figure}
\includegraphics[width=1\linewidth]{exp_rotation_results.png}
\caption{Simulated images of the numerical phantom for views rotated by $15^{\circ}$, $30^{\circ}$, and $45^{\circ}$.}
\label{fig:rotation_inclusion}
\end{figure}
The images are cropped to the region of interest.
The top row shows the ground truth envelope images simulated by Field II for varying rotation angles ranging from $0^{\circ}$ to $45^{\circ}$ with a $15^{\circ}$ increment.
For ScatRec, the image intensity drastically decreases with increasing rotation angle and the phantom almost disappears for $45^{\circ}$ due to destructive interference, as reported in~\cite{mattausch2017image}.
The images simulated by SampleEnv appear dark, whereas the image mean intensity remains similar to the ground truth images for TRF and ScatParam during rotation.
It can be well observed that the reconstruction of the proposed ScatParam is robust for different viewing angles.
We evaluate the simulation performance quantitatively for the above experiment by investigating the error for rotations with $1^\circ$ increments, with the results plotted in Fig.~\ref{fig:rotation_inclusion_err_curves}.
\begin{figure}
\includegraphics[width=1\linewidth]{exp_rotation_err_curves.png}
\caption{Performance with respect to rotation angle in terms of normalize mean image intensity difference ($\Delta \textrm{I}$ (\%)), signal-to-noise ratio difference ($\Delta \textrm{SNR}$ (\%)), contrast-to-noise ratio difference ($\Delta \textrm{CNR}$ (\%)) and histogram difference (KL divergence).}
\label{fig:rotation_inclusion_err_curves}
\end{figure}
ScatRec is close to the ground truth near $0^\circ$ given any metric, but it deviates largely from the ground truth at larger rotation angles, which corroborates the visual observations above.
The errors for SampleEnv are consistently high irrespective of rotation, indicating not a successful scatterer reconstruction.
In general, the error metrics of TRF vary without any pattern, remaining relatively similar across the angles, except a large variance in CNR.
This is in agreement with the observation in Fig.~\ref{fig:rotation_inclusion} that the tissue contrast in the $15^\circ$ rotated view of TRF is diminished.
The metrics for ScatParam exhibit minor fluctuations and remain overall relatively low and thus superior compared to the other methods.
Tab~\ref{tab:quant_results_rotation_circluar}. summarizes the mean, median and maximum error across the $1^\circ$ increment results in Fig.~\ref{fig:rotation_inclusion_err_curves}.
ScatParam is seen to achieve the lowest error overall, nearly $30 \%$ lower than the second best method in $\Delta \textrm{CNR}$ and KL divergence, demonstrating the representativeness and robustness of the estimated scatterer map with respect to probe rotation.
\begin{table}
\setlength{\tabcolsep}{2pt}
\caption{Mean (mean), median (med), and maximum (max) errors for rotations between $0^\circ$ and $45^\circ$ with $1^\circ$ increments. Bold number indicates the smallest value per column. }
\label{tab:quant_results_rotation_circluar}
\centering
\scalebox{0.9}{
\begin{tabular}{c|rrr|rrr|rrr|rrr}
Metric & \multicolumn{3}{c|}{$\Delta \textrm{I}$ (\%)} & \multicolumn{3}{c|}{$\Delta \textrm{SNR}$ (\%)} & \multicolumn{3}{c|}{$\Delta \textrm{CNR}$ (\%)} & \multicolumn{3}{c}{KL $(\times10^{-2})$} \\
\hline
\rowcolor{Gray}
&mean &med &max &mean &med &max &mean &med &max &mean &med &max \\
\hline
SampleEnv &50.1 &50.2 &50.8 & 11.9 & 11.7 & 17.7 & 16.3 & 16.6 & 22.4 & 20.4 & 20.7 & 25.5 \\
\hline
TRF & 9.1 & 8.6 & 18.1 &4.0 &3.7 &8.4 & 9.4 & 8.0 & 31.0 &16.7 &16.5 &24.1\\
\hline
ScatRec & 59.6 & 68.0 & 86.9 &3.4 &2.8 &13.1 &27.2 &22.7 &57.5 &22.2 &18.2 &44.2 \\
\hline
ScatParam & \bf{5.7} & \bf{7.4} & \bf{11.0} &\bf{2.3} &\bf{1.8} &\bf{6.9} & \bf{6.6} &\bf{5.2} &\bf{19.5} &\bf{12.5} &\bf{12.3} &\bf{19.3}
\end{tabular}}
\end{table}
\subsubsection{Compression Experiment}
With this, we investigate the invariance of reconstructed scatterer maps with respect to physical deformation.
An axial phantom compression was simulated by interpolating the estimated scatterer maps on grids deformed by varying levels of axial strain $e$.
Simulated images with all methods at $e=\{10,30,50\}\%$ compression are shown in Fig.~\ref{fig:compression_inclusion}.
\begin{figure}
\includegraphics[width=1\linewidth]{exp_compression_results.png}
\caption{Simulated images of the numerical phantom for axial compressions of 10\%, 30\%, and 50\% strain.}
\label{fig:compression_inclusion}
\end{figure}
The images simulated by TRF are corrupted by aliasing artifacts.
The simulation results of SampleEnv and ScatRec look similar with reduced intensity and degraded speckle pattern for large compression strain.
The simulated images by ScatParam are visually closest to the ground truth images in terms of speckle appearance and contrast, but slightly hyperechoic for large compression.
We investigate the simulation errors for compression ranging from $e=10$\% to $e=50$\% with $1$\% increments in Fig.~\ref{fig:compression_inclusion_err_curves}.
\begin{figure}
\includegraphics[width=1\linewidth]{exp_compression_err_curves.png}
\caption{Performance evolution with increasing axial strain $e$ in terms of difference in image mean intensity ($\Delta \textrm{I}$~(\%)), signal-to-noise ratio ($\Delta \textrm{SNR}$~(\%)), contrast-to-noise ratio ($\Delta \textrm{CNR}$~(\%)) and histogram difference (KL).}
\label{fig:compression_inclusion_err_curves}
\end{figure}
Similarly to the rotation experiment, the error metrics of ScatRec increase proportionally with increasing compression, whereas our method performs consistently superior.
SampleEnv and TRF yield large errors, especially in $\Delta \textrm{CNR}$ and KL divergence metrics.
The observations are supported by numerical results shown in Tab.~\ref{tab:quant_results_compression_circular}, reporting the mean, minimum, and maximum errors for the above plots.
Our proposed method ScatParam is seen to be superior in terms of $\Delta$SNR, $\Delta$CNR, and KL divergence.
It achieves approximately $78 \%$ lower error in the mean $\Delta \textrm{SNR}$, $68 \%$ in the mean $\Delta \textrm{CNR}$ and $28 \%$ in the mean KL divergence compared to the second best method.
TRF achieves $6 \%$ lower error than ScatParam in the mean $\Delta$I here.
\begin{table}
\setlength{\tabcolsep}{2pt}
\caption{Mean (mean), median (med) and maximum (max) errors across 10\% to 50\% strain with 1\% increments. Bold number indicates the smallest value per column.}
\label{tab:quant_results_compression_circular}
\centering
\scalebox{0.9}{
\begin{tabular}{c|rrr|rrr|rrr|rrr}
Metric & \multicolumn{3}{c|}{$\Delta \textrm{I}$ (\%)} & \multicolumn{3}{c|}{$\Delta \textrm{SNR}$ (\%)} & \multicolumn{3}{c|}{$\Delta \textrm{CNR}$ (\%)} & \multicolumn{3}{c}{KL $(\times10^{-2})$} \\
\hline
\rowcolor{Gray}
&mean &med &max &mean &med &max &mean &med &max &mean &med &max \\
\hline
SampleEnv &38.5 &39.4 &46.3 & 12.7 & 13.3 & 16.2 &17.6 & 17.2 & 24.5 & 16.6 & 16.5 & 21.4 \\
\hline
TRF & \bf{24.4} & \bf{24.1} & \bf{36.1} &8.3 &9.3 &13.3 & 21.5 & 22.2 & 26.9 &20.3 &20.4 &26.6 \\
\hline
ScatRec & 25.6 & 27.1 & 38.3 &12.9 &13.1 &22.1 & 14.6 & 14.6 & 24.9 & 18.9 &19.9 &32.3 \\
\hline
ScatParam & 26.0 & 25.1 & 41.7 &\bf{1.8} &\bf{1.6} &\bf{8.0} & \bf{4.7} &\bf{4.1} &\bf{13.9} &\bf{11.9} & \bf{11.7} &\bf{16.6}
\end{tabular}}
\end{table}
\subsection{Gelatin Phantom}
Next we investigate the performance of our method for a real ultrasound scan of a gelatin phantom with corn starch as the scattering medium.
A circular inclusion is made by adding twice as high as the concentration of starch in the background.
The beamformed RF images are collected by a Fukuda Denshi UF-760AG ultrasound machine with a linear probe FUT-LA385-12P.
The results in the top row of Fig.~\ref{fig:gelatin_results}(a) show an excellent agreement of ScatRec with the ground truth image, as expected from an overconstrained optimization, while the SampleEnv and TRF results exhibiting speckle textures different than the ground truth.
\begin{figure*}
\centering
\minipage{0.7\textwidth}
\centering
\includegraphics[width=1\linewidth]{gelatin_results.png}
\caption*{(a)}
\endminipage
\hfill
\minipage{0.3\textwidth}
\centering
\includegraphics[width=1\linewidth]{gelatin_rotation_histogram.png}
\caption*{(b)}
\endminipage
\caption{(a) With scatterers estimated from the gelatin phantom, images simulated at $0^{\circ}$ (top) and $45^{\circ}$ (top). (b)~Histogram of the ground truth and rotated views inside the area shown by a red rectangle in one sample image. Quantifying the difference between the ground truth and simulated image histograms using KL divergence indicates to the following errors: $0.101$ for SampleEnv, $0.593$ for TRF, $0.588$ for ScatRec, and $0.032$ for ScatParam.}
\label{fig:gelatin_results}
\end{figure*}
Our proposed method ScatParam generates images almost indistinguishable from the observation in terms of speckle texture and tissue contrast.
The experiment is further evaluated with quantitative metrics in Tab.~\ref{tab:gelatin_phatom}.
\begin{table}
\setlength{\tabcolsep}{2pt}
\caption{Quantitative evaluation metrics for the gelatin phantom. Bold number indicates the smallest error per column.}
\label{tab:gelatin_phatom}
\centering
\begin{tabular}{c|r|r|r|r}
\textbf{Method} & $\Delta \textrm{I}$ (\%) & $\Delta \textrm{SNR}$ (\%) & $\Delta \textrm{CNR}$ (\%) &KL ($\times 10^{-2}$) \\ \hline
SampleEnv & 44.0 & 19.2 & 13.3 & 25.5 \\
\hline
TRF & 5.0 & 10.0 & 24.0 & 21.2 \\
\hline
ScatRec &\bf{1.7} & \bf{0.6} & \bf{1.3} & \bf{2.7}\\
\hline
ScatParam & 7.4 & 0.9 & 8.1 & 17.0
\end{tabular}
\end{table}
ScatRec achieves the closest match to the ground truth image, as its scatterer estimation overfits to the observed phantom image.
Comparing the remaining three, ScatParam yields CNR, SNR, and KL divergence metrics lower than TRF and SampleEnv, indicating that our method better preserves contrast and intensity distribution.
The bottom row in Fig.~\ref{fig:gelatin_results}(a) shows the simulated $45^{\circ}$ rotated views of the phantom.
For an isotropic scattering phantom, the mean echo and speckle texture statistics would be invariant to the viewing direction and hence, after rotation, a speckle appearance similar to the initial view is expected.
Such coherence pattern may naturally not stay pixel-wise constant after, e.g., rotation, therefore no pixel-wise error metric was employed.
Similarly to the rotation experiment of Field II, the image simulated by ScatRec appears hypoechoic for $45^{\circ}$ angle, while the speckle pattern of TRF is severely distorted.
The ground truth rotated views are not obtained here.
Nevertheless, we evaluated the results by comparing the histogram of the observed $0^{\circ}$ envelope image to the histograms of the rotated envelope images (after brightness equalization) for the homogeneous region inside the red rectangle depicted in Fig.~\ref{fig:gelatin_results}(a).
Here Rayleigh statistics serve as an important criterion for assessing ultrasound speckle texture, as the envelope intensity should follow a Rayleigh distribution for fully developed speckles~\cite{goodman1975statistical}.
The histogram of ScatEnv closely follows the observed ground truth histogram, i.e.\ an ideal Rayleigh distribution, consistent with the observation reported in~\cite{alessandrini2015pipeline}.
Nevertheless, our approach ScatParam is seen to have an even better agreement with the observed pattern; indeed, with an over 3-folds lower KL divergence score as listed in the figure caption.
\subsection{In Vivo Experiment}
For this purpose, beamformed RF data from an in-vivo scan of the liver was collected.
Scatterer representations were estimated for the imaged region using all four methods presented.
Fig.~\ref{fig:invivo_images} depicts the results simulated in the acquisition configuration of $0^\circ$ and simulating a rotation of $45^\circ$.
\begin{figure*}
\centering
\includegraphics[width=1\linewidth]{invivo_results.png}
\caption{Images simulated in the original $0^\circ$ configuration from scatterers estimated from an in vivo liver image~(top), estimated scatterer maps, with only a random 8\% shown for sake of visualization~(middle), and the images simulated from the same scatterers after a rotation of $45^\circ$~(bottom). B-mode images are shown here, in contrast to all other images in this paper showing envelope images.}
\label{fig:invivo_images}
\end{figure*}
At $0^\circ$, all methods perform somewhat similarly, with SampleEnv slightly hypoechoic, TRF misrepresenting speckle texture, and ScatRec reconstructing an exact replica, as expected.
Noticeably, given the dynamic compression for B-mode images presented for the in-vivo experiment, the loss of brightness in the image generated by ScatEnv is less prominent compared to the previous experiments showing envelope images.
At $45^\circ$, however, SampleEnv and ScatRec both become very hypoechoic and preserve very little structural detail, and TRF becomes overly hyperechoic with the speckle pattern almost disappeared -- indicating that these three all did not estimate robust scatterer representations.
In contrast, our method ScatParam emulates the image rotation realistically despite the change in PSF, preserving mean intensity as well as structural detail and contrast, after rotation.
Assuming a homogeneous isotropic structure for the liver tissue (marked with a red rectangule in Fig.~\ref{fig:invivo_images}), a histogram comparison is also performed to compare post-rotation speckle appearance to the original image.
Given the clear difference in mean intensities, a raw B-mode histogram comparison indicates the superiority of ScatParam, by a large margin.
For a comparison of the speckle texture alone, we therefore first brightness equalized the images (cf.\ Fig.~\ref{fig:invivo_rotation}(a)) and then performed the histogram comparison.
\begin{figure}
\centering
\minipage{0.45\textwidth}
\centering
\includegraphics[width=1\linewidth]{exp_invivo_rotation_patch.png}
\caption*{(a)}
\endminipage
\hfill
\minipage{0.3\textwidth}
\centering
\includegraphics[width=1\linewidth]{exp_invivo_rotation_hist.png}
\caption*{(b)}
\endminipage
\caption{(a) Image patches in the red marked region in Fig.~\ref{fig:invivo_images}(a) for the $0^\circ$ view (top) and the $45^\circ$ view (bottom). Envelope images after brightness equalization are shown here. (b) Histogram of the ground truth patch compared with the simulated rotated patches, showing a best match with ScatParam.
Quantifying the difference between the ground truth and simulated image histograms using KL divergence indicates to the following errors: $0.040$ for SampleEnv, $0.059$ for TRF, $0.018$ for ScatRec, and $0.004$ for ScatParam.}
\label{fig:invivo_rotation}
\end{figure}
As seen in Fig.~\ref{fig:invivo_rotation}(b), ScatParam histogram even after after rotation closely matches to that of original ground truth image histogram, following an ideal Rayleigh distribution.
KL divergence results reported in Fig.~\ref{fig:invivo_rotation} caption corroborate with this observation.
\section{Discussion}
In this work, we demonstrated a learning based approach for probabilistic scatterer estimation in the context of realistic ultrasound image simulation.
The proposed framework ScatParam involves sparse scatterer model with Gaussian distribution for scatterer amplitude and estimation of the Gaussian mean directly from US envelope images by neural network.
Similar isotropic scatterer distributions were used in several earlier works, e.g.~\cite{jensen1996field, alessandrini2011restoration, burger2012real, mattausch2017image, alessandrini2015pipeline, bamber1980ultrasonic}.
In our preliminary experiments for estimating parameter maps of both mean and standard deviation, we have found that different such combinations may generate similar image outputs, making such double parameter estimation ill-posed.
Therefore, in this work we fixed the standard deviation and estimated only the mean value.
In addition, we assumed a fixed density value for our model, since it is shown that in case of fully developed speckles the tissue characteristics are not affected by density~\cite{thijssen1990texture}.
Estimating scatterer density in addition to the amplitude mean could allow us to distinguish between partially and fully developed speckles; nevertheless, we observed comparable performance with only mean estimation for both numerical simulations and in-vivo experiments presented herein.
For complex in-vivo scatterer distributions more sophisticated models may be required.
For example, for muscle fibers, anisotropic parametrizations such as with tensor, wavelet, or frequency-domain representations may be more suitable. Indeed, instead of hand-crafted parametric models, (arbitrary) distributions could potentially be parametrized using a neural network to be inferred from observed images.
In the paper, we have conducted several experiments evaluating the invariance of tissue properties with geometric transformations, which is of great importance for ensuring plausible simulation of the same tissue content under different imaging conditions.
Rotation and axial compression are chosen, since they well represent the clinical examinations such as transducer in-plane tilting and compression.
Furthermore, these experimental scenarios model potential variation in speckle appearance from directional changes (isotropy) and concentration changes (axial strain) in scatterer configurations.
In comparison to other deconvolution algorithms, our method does not require PSF estimation in advance.
It was reported in~\cite{mattausch2017image} that accurate PSF estimation is needed as input to an inverse problem based method, analogously important for the Wiener filter and other deconvolution algorithms.
Our trained CNN is able to capture the PSF information in the form of different speckle textures in input images, hence estimated parameter maps would be independent of imaging system.
One can produce visually plausible images without considering PSF as in the method SampleEnv.
However, the simulated speckle statistics with SampleEnv herein are not fully in agreement with the observations, since by dismissing the modulated nature of PSF and thereby any destructive interference, SampleEnv cannot fully model the interference between scatterers.
Setting scatterer amplitudes directly using envelope intensities causes the incorrect translation of speckle variations into scatterer maps, i.e. higher amplitude scatterers lumped around the peaks of speckles. This leads to brighter hyperechoic and darker hypoechoic regions even after PSF convolution. Such granular appearance is less visible after dynamic range compression in B-mode images, e.g. in Fig. 8, whereas these and resulting overall intensity reduction become apparent in the envelope images shown for the rest of the experimental results. Note that we present envelope images, as they allow easier interpretation of speckle patterns and imaging physics, where effects of methodological choices on the results are not masked by any graymap transform.
We herein chose Wiener filtering as a basic deconvolution baseline for TRF, with low computation and memory requirements. The results with artifacts and reduced contrast of TRF indicate that the use of the same low resolution of the input RF image in the output scatterers hinder interpolation in the scatterer domain after transformations, such as compressions. Although there are more recent forms of TRF, e.g. ~\cite{florea2018axially, besson2019physical}, ScatRec~\cite{mattausch2017image} was chosen herein as a state-of-the-art baseline performing a sophisticated deconvolution approach as an optimization of an inverse-problem definition; with a suitable model, i.e. norms and regularizers; with depth-dependent PSF; non-negative scatterer constraint; and with a higher solution scatterer resolution than the RF image domain. Regardless of baselines, our results indicate that our learning based solution ScatParam as a fast-implementable network solution performs satisfactorily for image simulation and without requiring complex convolution modeling, PSF estimation, iterative optimization, or any other complex processing steps.
Note that using only Gaussian noise model for the training samples, ScatParam is able to successfully estimate scatterer parametrezations for no-noise numerical experiments as well as unknown-noise phantom and in-vivo examples, potentially indicating the robustness of the proposed parametrization and the respectively trained NN to an assumed noise model.
Underconstrained inverse problem based approaches can be improved by using multiple measurements of the same tissue with different imaging parameters.
A successful example was illustrated in~\cite{mattausch2017image}, where ScatRec with multiple observations from beam steering is shown to be more robust to viewing angle changes.
However, the aligned beam-steered images are in general not available from clinical scanners, let alone raw RF data.
Our method takes envelope images as input and can thus accept clinical B-Mode images with slight modification of network training.
For a fair comparison, we herein used the single view version of inverse problem, i.e.\ ScatRec1 in~\cite{mattausch2017image}.
In this work any ultrasound image appearance is attributed solely to isotropic scattering, where attenuation variations and coherent reflections are not considered.
For instance, all the methods compared in Fig.~\ref{fig:gelatin_results}(a) attribute the slight attenuation in the original image behind the gelatin inclusion (after a depth of 40\,mm) to some form of lower scattering amplitude, thereby resulting in the attenuation not correctly reproduced in the rotated images, e.g.\ extending diagonally rather than vertically. This demonstrates the need to take directional attenuation and reflections into account during any scatterer estimation process, which should be a focus of future studies.
Furthermore, any potential reflections at anatomical boundaries, i.e. between supra-wavelength structures, would also be attributed to result from the reconstructed scatterers, which may then incorrectly reproduce the tissue from different viewing angles.
In all our numerical examples, any such reflections were thus avoided.
The gelatin phantom was made with isotropic scatterers and for the in-vivo example the liver was chosen for its relatively homogeneous speckle appearance. Phantom and in-vivo evaluations were conducted within small regions-of-interest selected in line with our assumptions.
But, for instance in the presented ultrasound acquisitions, the directional reflection from the isoechoic inclusion in the gelatin phantom and reflections at muscle boundaries in the in-vivo liver image appear similarly after rotation, which is suboptimal as reflection effects should be direction-dependent.
Nevertheless, it may be possible to separate the directional dependent image content prior to capturing only scattering effects as described herein.
One can then simulate such directional wave interactions at a later time using ray tracing techniques~\cite{burger2012real, mattausch2018realistic}.
For instance, reflection boundaries could be detected and removed using a simple phase symmetry (PS) algorithm~\cite{hacihaliloglu2009bone}, which is designed to estimate directional reflections at tissue boundaries such as bone surfaces, as thin hairline structures. In a way similar to estimating and compensating for reflections, acoustic attenuation can indeed also be reconstructed a-priori~\cite{rau2019attenuation} in order to spatially normalize incident acoustic energy to decouple its effect from our reconstructed scatterer amplitudes.
Our network training takes approximately 6 hours on Nvidia Titan XP GPU.
Once trained, our network can estimate scatterer maps in milliseconds at inference time, for arbitrary input image size (as being a fully convolutional network architecture).
In contrast, the inverse problem based approach takes approximately 2 hours for one image from a single view.
For multiple (beam-steered) observations, the computation time would increase exponentially, quickly making this method infeasible for large images and 3D volumes.
\section{Conclusion}
We have demonstrated a learning-based technique to efficiently estimate the distribution of tissue scatterer representation, which can then be fed directly into convolution- or ray-tracing-based simulation techniques~\cite{burger2012real, mattausch2018realistic} to simulate realistic images for sonographer training.
The proposed network is trained only with synthetic images generated with random shapes and spatial invariant convolution.
In comparison to the state-of-the-art methods, we demonstrate with numerical simulations the proposed estimation pipeline being robust for simulating images at different viewing angles and tissue deformations.
The method is further evaluated on a tissue-mimicking gelatin phantom and an in-vivo liver image, demonstrating the generalization ability of our network to real ultrasound scans.
\ifCLASSOPTIONcaptionsoff
\newpage
\fi
\bibliographystyle{IEEEtran}
| {'timestamp': '2020-06-19T02:04:22', 'yymm': '2006', 'arxiv_id': '2006.10166', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10166'} | arxiv |
\section*{Acknowledgment}
This research was supported by the EU-supported Hungarian national grant GINOP-2.3.2-15-2016-00037 titled ``Internet of Living Things'' and by grant TUDFO/47138-1/2019-ITM of the Ministry for Innovation and Technology, Hungary.
\section*{Appendix}\label{sec:appendix}
\begingroup
\setlength{\tabcolsep}{3pt}
\renewcommand{1.1}{1}
\begin{sidewaystable}[!hp]
\centering
\caption{Significance test results for method level - Algorithms}
\resizebox{\textwidth}{!}{
\begin{tabular}{|l|r|r|r|r|r|r|r|r|r|r|}
\hline
& \multicolumn{1}{c|}{\textit{NaiveBayes}} & \multicolumn{1}{c|}{\textit{NaiveBayesMultinomial}} & \multicolumn{1}{c|}{\textit{Logistic}} & \multicolumn{1}{c|}{\textit{SGD}} & \multicolumn{1}{c|}{\textit{SimpleLogistic}} & \multicolumn{1}{c|}{\textit{VotedPerceptron}} & \multicolumn{1}{c|}{\textit{DecisionTable}} & \multicolumn{1}{c|}{\textit{OneR}} & \multicolumn{1}{c|}{\textit{J48}} & \multicolumn{1}{c|}{\textit{RandomForest}}\\
\hline
\textit{NaiveBayesMultinomial} & 0.900 (1.2814) & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} \\
\hline
\textit{Logistic} & 0.129 (4.0704) & \textbf{0.007} (5.352) & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} \\
\hline
\textit{SGD} & \textbf{0.045} (4.5980) & \textbf{0.002} (5.8795) & 0.900 (0.5276) & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} \\
\hline
\textit{SimpleLogistic} & 0.053 (4.5227) & \textbf{0.002}(5.8041) & 0.900 (0.4523) & 0.900 (0.0754) & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} \\
\hline
\textit{VotedPerceptron} & 0.900 (1.8844) & 0.900 (0.6030) & \textbf{0.001} (5.9548) & \textbf{0.001}(6.4825) & \textbf{0.001} (6.4071) & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} \\
\hline
\textit{DecisionTable} & \textbf{0.045} (4.5980) & \textbf{0.002} (5.8795) & 0.900 (0.5276) & 0.900 (0.0000) & 0.900 (0.0754) & \textbf{0.001} (6.4825) & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} \\
\hline
\textit{OneR} & 0.302 (3.5428) & \textbf{0.027} (4.8242) & 0.900 (0.5276) & 0.900 (1.0553) & 0.900 (0.9799) & \textbf{0.006} (5.4272) & 0.900 (1.0553) & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} \\
\hline
\textit{J48} & \textbf{0.023} (4.8995) & \textbf{0.001} (6.1810) & 0.900 (0.8292) & 0.900 (0.3015) & 0.900 (0.3769) & \textbf{0.001} (6.7840) & 0.900 (0.3015) & 0.900 (1.3568) & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} \\
\hline
\textit{RandomForest} & \textbf{0.001} (7.6131) & \textbf{0.001} (8.8943) & 0.302 (3.5426) & 0.546 (3.0151) & 0.513 (3.0905) & \textbf{0.001} (9.4976) & 0.546 (3.0151) & 0.129 (4.0704) & 0.679 (2.7136) & \cellcolor[rgb]{ .851. .851. .851} \\
\hline
\textit{RandomTree} & \textbf{0.019} (4.9749) & \textbf{0.001} (6.2564) & 0.900 (0.9045) & 0.900 (0.3769) & 0.900 (0.4523) & \textbf{0.001} (6.8594) & 0.900 (0.3769) & 0.900 (1.4322) & 0.900 (0.0754) & 0.712 (2.6382) \\
\hline
\end{tabular}
}
\label{tab:sign_res_method_ml}
\end{sidewaystable}
\endgroup
\begingroup
\setlength{\tabcolsep}{3pt}
\renewcommand{1.1}{1}
\begin{sidewaystable}[htbp]
\centering
\caption{Significance test results for class level - Algorithms}
\resizebox{\textwidth}{!}{
\begin{tabular}{|l|r|r|r|r|r|r|r|r|r|r|}
\hline
& \multicolumn{1}{c|}{\textit{NaiveBayes}} & \multicolumn{1}{c|}{\textit{NaiveBayesMultinomial}} & \multicolumn{1}{c|}{\textit{Logistic}} & \multicolumn{1}{c|}{\textit{SGD}} & \multicolumn{1}{c|}{\textit{SimpleLogistic}} & \multicolumn{1}{c|}{\textit{VotedPerceptron}} & \multicolumn{1}{c|}{\textit{DecisionTable}} & \multicolumn{1}{c|}{\textit{OneR}} & \multicolumn{1}{c|}{\textit{J48}} & \multicolumn{1}{c|}{\textit{RandomForest}} \\
\hline
\textit{NaiveBayesMultinomial} & 0.900 (1.1307) & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} \\
\hline
\textit{Logistic} & 0.169 (3.9196) & 0.646 (2.7890) & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} \\
\hline
\textit{SGD} & 0.169 (3.9196) & 0.646 (2.7890) & 0.900 (0.0000) & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} \\
\hline
\textit{SimpleLogistic} & \textbf{0.019} (4.9749) & 0.191 (3.8443) & 0.900 (1.0553) & 0.900 (1.0553) & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} \\
\hline
\textit{VotedPerceptron} & 0.900 (1.8844) & 0.546 (3.0151) & \textbf{0.002} (5.8041) & \textbf{0.002} (5.8041) & \textbf{0.001} (6.8594) & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} \\
\hline
\textit{DecisionTable} & \textbf{0.004} (5.5780) & 0.063 (4.4473) & 0.900 (1.6583) & 0.900 (1.6583) & 0.900 (0.6030) & \textbf{0.001} (7.4624) & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} \\
\hline
\textit{OneR} & 0.878 (2.2613) & 0.900 (1.1307) & 0.900 (1.6583) & 0.900 (1.6583) & 0.679 (2.7136) & 0.113 (4.1458) & 0.406 (3.3166) & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} \\
\hline
\textit{J48} & 0.369 (3.3920) & 0.878 (2.2613) & 0.900 (0.5276) & 0.900 (0.5276) & 0.900 (1.5829) & \textbf{0.009} (5.2764) & 0.900 (2.1860) & 0.900 (1.1307) & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} \\
\hline
\textit{RandomForest} & 0.900 (0.7538) & 0.900 (0.3769) & 0.479 (3.1659) & 0.479 (3.1659) & 0.098 (4.2212) & 0.712 (2.6382) & \textbf{0.027} (4.8242) & 0.900 (1.5076) & 0.712 (2.6382) & \cellcolor[rgb]{ .851. .851. .851} \\
\hline
\textit{RandomTree} & 0.900 (1.6583) & 0.900 (0.5276) & 0.878 (2.2613) & 0.878 (2.2613) & 0.406 (3.3166) & 0.302 (3.5428) & 0.169 (3.9196) & 0.900 (0.6030) & 0.900 (1.7337) & 0.900 (0.9045) \\
\hline
\end{tabular}
}
\label{tab:sign_res_class_ml}
\end{sidewaystable}
\endgroup
\begingroup
\setlength{\tabcolsep}{3pt}
\renewcommand{1.1}{1}
\begin{sidewaystable}[htbp]
\centering
\caption{Significance test results for projected - Algorithms}
\resizebox{\textwidth}{!}{
\begin{tabular}{|l|r|r|r|r|r|r|r|r|r|r|}
\hline
& \multicolumn{1}{c|}{\textit{NaiveBayes}} & \multicolumn{1}{c|}{\textit{NaiveBayesMultinomial}} & \multicolumn{1}{c|}{\textit{Logistic}} & \multicolumn{1}{c|}{\textit{SGD}} & \multicolumn{1}{c|}{\textit{SimpleLogistic}} & \multicolumn{1}{c|}{\textit{VotedPerceptron}} & \multicolumn{1}{c|}{\textit{DecisionTable}} & \multicolumn{1}{c|}{\textit{OneR}} & \multicolumn{1}{c|}{\textit{J48}} & \multicolumn{1}{c|}{\textit{RandomForest}} \\
\hline
\textit{NaiveBayesMultinomial} & 0.900 (0.6784) & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} \\
\hline
\textit{Logistic} & \textbf{0.003} (5.7287) & \textbf{0.001} (6.4071) & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} \\
\hline
\textit{SGD} & \textbf{0.001} (7.0101) & \textbf{0.001} (7.6885) & 0.900 (1.2814) & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851}\\
\hline
\textit{SimpleLogistic} & \textbf{0.006} (5.4272) & \textbf{0.001} (6.1056) & 0.900 (0.3015) & 0.900 (1.5829) & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} \\
\hline
\textit{VotedPerceptron} & 0.900 (1.8091) & 0.778 (2.4875) & 0.169 (3.9196) & \textbf{0.011} (5.2011) & 0.271 (3.6181) & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} \\
\hline
\textit{DecisionTable} & \textbf{0.001} (7.6885) & \textbf{0.001} (8.3669) & 0.900 (1.9598) & 0.900 (0.6784) & 0.878 (2.2613) & \textbf{0.002} (5.8795) & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} \\
\hline
\textit{OneR} & \textbf{0.005} (5.5026) & \textbf{0.001} (6.1810) & 0.900 (0.2261) & 0.900 (1.5076) & 0.900 (0.0754) & 0.242 (3.6935) & 0.900 (2.1860) & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} \\
\hline
\textit{J48} & \textbf{0.001} (5.9548) & \textbf{0.001} (6.6332) & 0.900 (0.2261) & 0.900 (1.0553) & 0.900 (0.5276) & 0.113 (4.1458) & 0.900 (1.7337) & 0.900 (0.4523) & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} \\
\hline
\textit{RandomForest} & \textbf{0.001} (7.4624) & \textbf{0.001} (8.1408) & 0.900 (1.7337) & 0.900 (0.4523) & 0.900 (2.0352) & \textbf{0.003} (5.6533) & 0.900 (0.2261) & 0.900 (1.9598) & 0.900 (1.5076) & \cellcolor[rgb]{ .851. .851. .851} \\
\hline
\textit{RandomTree} & \textbf{0.005} (5.5026) & \textbf{0.001} (6.1810) & 0.900 (0.2261) & 0.900 (1.5076) & 0.900 (0.0754) & 0.242 (3.6935) & 0.900 (2.1860) & 0.900 (0.0000) & 0.900 (0.4523) & 0.900 (1.9598) \\
\hline
\end{tabular}
}
\label{tab:sign_res_projected_ml}
\end{sidewaystable}
\endgroup
\begingroup
\setlength{\tabcolsep}{3pt}
\renewcommand{1.1}{1}
\begin{sidewaystable}[htbp]
\centering
\caption{Significance test results for file level - Algorithms}
\resizebox{\textwidth}{!}{
\begin{tabular}{|l|r|r|r|r|r|r|r|r|r|r|}
\hline
& \multicolumn{1}{c|}{\textit{NaiveBayes}} & \multicolumn{1}{c|}{\textit{NaiveBayesMultinomial}} & \multicolumn{1}{c|}{\textit{Logistic}} & \multicolumn{1}{c|}{\textit{SGD}} & \multicolumn{1}{c|}{\textit{SimpleLogistic}} & \multicolumn{1}{c|}{\textit{VotedPerceptron}} & \multicolumn{1}{c|}{\textit{DecisionTable}} & \multicolumn{1}{c|}{\textit{OneR}} & \multicolumn{1}{c|}{\textit{J48}} & \multicolumn{1}{c|}{\textit{RandomForest}} \\
\hline
\textit{NaiveBayesMultinomial} & 0.900 (1.8844) & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} \\
\hline
\textit{Logistic} & 0.129 (4.0704) & 0.900 (2.1860) & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} \\
\hline
\textit{SGD} & 0.900 (0.1508) & 0.900 (2.0352) & 0.098 (4.2212) & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} \\
\hline
\textit{SimpleLogistic} & 0.148 (3.9950) & 0.900 (2.1106) & 0.900 (0.0754) & 0.113 (4.1458)& \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} \\
\hline
\textit{VotedPerceptron} & 0.900 (1.2060) & 0.513 (3.0905) & \textbf{0.009} (5.2764) & 0.900 (1.0553) & \textbf{0.011} (5.2011) & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} \\
\hline
\textit{DecisionTable} & 0.443 (3.2412) & 0.900 (1.3568) & 0.900 (0.8292) & 0.369 (3.3920) & 0.900 (0.7538) & 0.063 (4.4473) & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} \\
\hline
\textit{OneR} & 0.148 (3.9950) & 0.900 (2.1106) & 0.900 (0.0754) & 0.113 (4.1458) & 0.900 (0.0000) & \textbf{0.011} (5.2011) & 0.900 (0.7538) & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} \\
\hline
\textit{J48} & 0.513 (3.0905) & 0.900 (1.2060) & 0.900 (0.9799) & 0.443 (3.2412) & 0.900 (0.9045) & 0.085 (4.2965) & 0.900 (0.1508) & 0.900 (0.9045) & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} \\
\hline
\textit{RandomForest} & 0.098 (4.2212) & 0.845 (2.3367) & 0.900 (0.1508) & 0.073 (4.3719) & 0.900 (0.2261) & \textbf{0.006} (5.4272) & 0.900 (0.9799) & 0.900 (0.2261) & 0.900 (1.1307) & \cellcolor[rgb]{ .851. .851. .851} \\
\hline
\textit{RandomTree} & 0.098 (4.2212) & 0.845 (2.3367) & 0.900 (0.1508) & 0.073 (4.3719) & 0.900 (0.2261) & \textbf{0.006} (5.4272) & 0.900 (0.9799) & 0.900 (0.2261) & 0.900 (1.1307) & 0.900 (0.0000) \\
\hline
\end{tabular}
}
\label{tab:sign_res_file_ml}
\end{sidewaystable}
\endgroup
\section{Dataset Creation} \label{approach}
In this section, we introduce the methodology we used to create the dataset.
We carried out the data processing in multiple steps using the toolchain shown in Figure~\ref{fig:toolchain}.
Each of these steps -- and their corresponding components -- are detailed in their dedicated sections below.
\begin{figure}[htb!]
\centering
\includegraphics[width=\textwidth]{fig/toolchain.png}
\caption{The components of the process}
\label{fig:toolchain}
\end{figure}
\subsection{Collecting Data}
First, we save data about the selected projects via the GitHub API.
This is necessary, because while the data is continuously changing on GitHub due to the activities in the projects, we need a consistent data source for the analysis.
The data we save includes the list of users assigned to the repository (Contributors), the open and closed bug reports (Issues), and all of the commits.
For open issues, we stored only the date of their creation.
For closed issues, we stored the creation date, closing date, and the hash of the fixing commits with their commit dates.
Additionally, we focused exclusively on bug related issues, so closed bugs that were not referenced from any commit were not stored.
This filtering is based on the issue labels provided by GitHub and the set of labels we manually selected for each project.
The data we stored about the commits includes the identifier of the contributor, the parent(s) of the commit, and the affected files with their corresponding changes.
All this raw information is stored in an XML format, ready for further processing.
\subsection{Processing Raw Data} \label{sec:processingrawdata}
While the data saved from GitHub includes all commits, we only need the ones that relate to the bug reports.
These commits are then divided into different subsets, as depicted in Figure~\ref{fig:issue}.
Green nodes are directly referencing the bug report (fixing intention).
Gray nodes are commits applied between the first fix and the last fix but not referencing the bug id in their commit log messages.
One extra commit taken into consideration is the one right before the first fix (colored with orange).
This commit holds the state when the source code is buggy (not fixed yet), thus a snapshot (source code analysis) will be performed at that point too.
Although the orange node represents the latest state where the bug is not fixed yet, the blue nodes also contain the bug so we mark the source code elements as buggy in these versions too.
These blue markings are important for distinguishing commits that are involved in multiple bugs at the same time.
We have to perform code analysis on the orange and green commits to construct dataset entries.
Two entries are created for every source code element they contain: one with the state (metrics) right before the fix was applied, and one with the state when the bug was fixed.
At green commits except the last one, we do not need to perform a full code analysis, since at those points we are only interested in extracting the affected source code elements.
Amongst the selected commits, some further ones can occur that need to be removed because they are no longer available through Git (deleted, merged).
Moreover, we do not only search for links from the direction of commits but also from the direction of issues (bug reports).
When considering a bug report, we can find a commit id showing that the bug was closed in that specific commit.
At this point, the full list is constructed as a text file, which has all the commit ids (hash) for a selected project to undergo static analysis.
\begin{figure}
\includegraphics[width=\textwidth]{fig/issue.png}
\caption{The relationship between the bug reports and commits}
\label{fig:issue}
\end{figure}
\subsection{Source Code Analysis} \label{sec:sourcecodeanalysis}
After gathering the appropriate versions of the source code for a given project, feature extraction can begin.
This component wraps the results of the OpenStaticAnalyzer tool that computes the source code metrics and determines the positions of the source code elements.
Results are generated in a graph format, which contains the files, classes, and methods with the computed data that includes different software product metrics (described in Section~\ref{metrics}).
At this point we have all the raw data desired, including the source code elements located in the project and all the bug related information.
\subsection{Extracting the Number of Bugs}
The next step is to link the two data sets -- the results of the code analysis and the data gathered from GitHub -- and extract the characteristics of the bugs.
Here, we determine the source code elements affected by the commits and the number of bugs in each commit for file, class, and method levels.
To determine the affected source code parts, an approach similar to the SZZ algorithm~\cite{williams2008szz} is used.
However, we do not want to detect the fix inducing commits, only the mapping between the fixing code snippets and source code elements.
For this purpose, we used the diff files -- from the GitHub data we saved -- that contain the differences between two source code versions in a unified diff format.
An example unified diff file snippet is shown below.
\begin{verbatim}
--- /path/to/original ''timestamp''
+++ /path/to/new ''timestamp''
@@ -1,4 +1,4 @@
+Added line
-Deleted line
This part of the
document has stayed the
same
\end{verbatim}
Each diff contains a header information specifying the starting line number and the number of affected lines.
Using this information, we can get the range of the modification (for a given file pair: original and new).
To obtain a more accurate result, we subtracted the unmodified code lines from this range.
Although the diff files generated by GitHub contain additional information about which method is affected, it does not carry enough information because the difference can affect multiple source code elements (overlapping cases that are not handled by GitHub).
Thus, there is no further task but to examine the source code elements in every modified file and identify which ones of them are affected by the changes.
The method uses the source code element positions, i.e., source line mappings from the output of the OpenStaticAnalyzer tool.
We identified the source code elements by their fully qualified names that involve the name of the package, the class, the method, the type of the parameters, and the type of the return value.
Next, we take the commits that were selected by the ``Processing Raw Data'' step and mark the code sections affected by the bug in these commits.
We do this by accumulating the modifications on the issue level and collecting the fully qualified names of the elements.
Then, the algorithm marks the source code elements in the appropriate versions that will be entries in the dataset (touched in order to fix a bug).
If a source code element in a specific version is marked by multiple issues, then it contains multiple bugs in that version.
The dataset for files, classes, and methods are exported into three different files in a simple CSV format.
The first row of these files contains the header information, namely the commit id, the qualified name and the bug cardinality.
Further lines store the data of the source code elements according to the header.
\subsection{Combining CSV files}
Now, the CSV outputs of OpenStaticAnalyzer and the previously described CSV output can be merged.
In this phase, we attach the source code elements that are entries in the dataset to the calculated metrics.
The output of this step is also a CSV file for each type of source code element, containing the hash code of the version, unique identifiers of the source code elements, identifiers of metrics, rule violation groups, and bug cardinality (the number of bugs located in the source code elements).
One entry is equivalent to one source code element at a given time (the same source code element can occur more than once with a different commit id -- hash).
\subsection{Filtering}\label{sec:filtering}
This data set we compiled so far can contain various entries that complicate further investigations.
As the data set should be suitable for studying the connection between different metrics and bug occurrences, it should serve as a practical input for different machine learning algorithms.
It is possible, however, to have entries in the dataset that have the same metric values with different number of bugs assigned to them.
For example, let us consider a buggy method $f$ with metric values $M_{f_1}$.
After the bugfix, the metric values of $f$ is changed to $M_{f_2}$.
Similarly, let us consider another buggy method $g$ with metric values $M_{g_1}$ and $M_{g_2}$, respectively.
These two methods could contain two different bugs that are present in a system for distinct periods of time.
In this case, the dataset would contain 4 entries: $M_{f_1}$, $M_{f_2}$, $M_{g_1}$, $M_{g_2}$, where $M_{f_1}$ and $M_{g_1}$ are buggy and $M_{f_2}$ and $M_{g_2}$ are non-buggy entries.
If any of these metric values are equal (e.g. $M_{f_1}=M_{g_2}$ or $M_{g_1}=M_{g_2}$), then redundancy occurs that can influence the accuracy of machine learning for bug prediction (overfitting, contradicting records).
To solve this issue, we used different approaches to filter the raw dataset and eliminate the redundant entries.
We tried various methods to reduce the noise in the learning set, whose entries are classified into either buggy or not buggy.
\begin{itemize}
\item \textbf{Removal}: keep the entries located in the class with the larger cardinality (e.g., for a 10:20 distribution, the result is 0:20)
\item \textbf{Subtract}: reduce the number of entries in the class with the larger cardinality by removing as many entries as the cardinality of the smaller class (e.g., for a 10:20 distribution, the result is 0:10)
\item \textbf{Single}: remove the entries of the class with the smaller cardinality and hold only one entry from the larger one (e.g., for a 10:20 distribution, the result is 0:1)
\item \textbf{GCF}: divide the number of entries of both classes by their greatest common factor (or greatest common divisor) and retain only the resulting amounts of entries from the classes (e.g., for a 10:20 distribution, the result is 1:2)
\end{itemize}
Each selected approach can seriously modify the result set, thus we investigated all four options and additionally the basic case when no filtering was applied.
Tables~\ref{filteringresultsmethod},~\ref{filteringresultsclass}, and~\ref{filteringresultsfile} present average F-measure values calculated for all of the machine learning algorithms we used for all of the projects.
From these tables we can see that the Single and GCF methods performed quite similarly but were less effective than Subtract or Removal.
We employed a statistical significance test, namely the Friedman test~\cite{friedman1940comparison} with a threshold of $\alpha=0.05$ to assess the significance of the differences between the averages, as it was done similarly in previous bug prediction studies~\cite{herbold2018comparative, ghotra2015revisiting}.
Our data does not follow normal distribution, it consists of dependent samples and we have five paired groups, thus the Friedman test is the appropriate choice.
The null hypothesis is that the multiple paired samples have the same distribution.
The tests resulted in very low $p$ values ($p_{method}=5.32\text{e-}80$, $p_{class}=2.03\text{e-}77$, $p_{file}=1.83\text{e-}40$); therefore, we reject the null hypothesis which means the distributions are not equal.
Then, we applied the Nemenyi post-hoc test~\cite{nemenyi} ($\alpha=0.05$) that is usually used after a null hypothesis is rejected to gain more insight on the significance of the differences.
The critical value for 5 groups and 176 samples (11 machine learning algorithms $\times$ 16 databases) based on the studentized range table is $q_{crit}=3.9$.
Tables~\ref{filteringresultsmethod_sig},~\ref{filteringresultsclass_sig}, and~\ref{filteringresultsfile_sig} list the resulted $p$ values with the corresponding rank difference in parentheses.
Let us consider the method level F-measure values in Table~\ref{filteringresultsmethod} where Removal has the highest average F-measure (0.5773) and Subtract is a close second (0.5717).
In Table~\ref{filteringresultsmethod_sig}, the results of the significance tests for method level show that the $p$ value of the test between Subtract and No filter is below the threshold ($p=0.001<\alpha=0.05$); therefore, the difference is significant and with Subtract having a higher average F-measure (0.5717) than No filter (0.5317), we can state that it is significantly better.
We can conclude the same when comparing Subtract with Single ($p=0.001<\alpha=0.05$) or with GCF ($p=0.001<\alpha=0.05$).
The $p$ value between Subtract and Removal is $p=0.210>\alpha=0.05$ which is not significant.
Similar results can be concluded for class level and for file level as well.
We can state that the Removal and Subtract methods performed significantly better than the other methods in all three cases.
The difference between the Removal and Subtract methods is not significant.
We speculate that a disadvantage to Single is that it drops the multiplicity of the records (i.e., the weight information).
The problem with GCF, on the other hand, is that it will only perform filtering when the greatest common factor is not one, and that it does not eliminate the noise completely (i.e., it will keep at least one entry from both classes).
Removal removes the noise entirely, but it suffers from the fact that it ignores the minority.
The Subtract method, however, neutralizes the positive and negative entries with identical feature vectors.
This means that it removes the noise while also keeping the weight of the records, so this filtering method seems to be the best choice.
Presenting all the five different sets would be lengthy, thus we will only present the results achieved by the Subtract method.
\begin{table}[H]
\caption{Filtering results at method level}
\fontsize{10pt}{12pt}\selectfont
\def1.1{1}
\centering
\setlength{\tabcolsep}{6pt}
\begin{tabular}{|l|c|c|c|}
\hline
\textbf{Method} & \textbf{Precision} & \textbf{Recall} & \textbf{F-Measure} \\ \hline
No filter & 0.5553 & 0.5501 & 0.5317 \\
Removal & 0.6070 & 0.5963 & 0.5773 \\
Subtract & 0.5974 & 0.5893 & 0.5717 \\
Single & 0.5495 & 0.5448 & 0.5250 \\
GCF & 0.5445 & 0.5408 & 0.5218 \\ \hline
\end{tabular}
\label{filteringresultsmethod}
\end{table}
\begin{table}[H]
\caption{Significance test results for method level filtering}
\fontsize{8pt}{10pt}\selectfont
\def1.1{1}
\centering
\setlength{\tabcolsep}{6pt}
\begin{tabular}{|l|c|c|c|c|}
\hline
& \multicolumn{1}{c|}{\textit{No filter}} & \multicolumn{1}{c|}{\textit{Removal}} & \multicolumn{1}{c|}{\textit{Subtract}} & \multicolumn{1}{c|}{\textit{Single}} \\
\hline
\textit{Removal} & \textbf{0.001} (16.8763) & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} \\
\hline
\textit{Subtract} & \textbf{0.001} (13.8729) & 0.210 (3.0034) & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} \\
\hline
\textit{Single} & 0.736 (1.6686) & \textbf{0.001} (18.5449) & \textbf{0.001} (15.5414) & \cellcolor[rgb]{ .851. .851. .851} \\
\hline
\textit{GCF} & \textbf{0.020} (4.2906) & \textbf{0.001} (21.1669) & \textbf{0.001} (18.1635) & 0.343 (2.6220) \\
\hline
\end{tabular}
\label{filteringresultsmethod_sig}
\end{table}
\begin{table}[H]
\caption{Filtering results at class level}
\fontsize{10pt}{12pt}\selectfont
\def1.1{1}
\centering
\setlength{\tabcolsep}{6pt}
\begin{tabular}{|l|c|c|c|}
\hline
\textbf{Method} & \textbf{Precision} & \textbf{Recall} & \textbf{F-Measure} \\ \hline
No filter & 0.5265 & 0.5235 & 0.5128 \\
Removal & 0.5567 & 0.5528 & 0.5419 \\
Subtract & 0.5541 & 0.5499 & 0.5393 \\
Single & 0.5236 & 0.5206 & 0.5090 \\
GCF & 0.5221 & 0.5201 & 0.5077 \\ \hline
\end{tabular}
\label{filteringresultsclass}
\end{table}
\begin{table}[H]
\caption{Significance test results for class level filtering}
\fontsize{8pt}{10pt}\selectfont
\def1.1{1}
\centering
\setlength{\tabcolsep}{6pt}
\begin{tabular}{|l|c|c|c|c|}
\hline
& \multicolumn{1}{c|}{\textit{No filter}} & \multicolumn{1}{c|}{\textit{Removal}} & \multicolumn{1}{c|}{\textit{Subtract}} & \multicolumn{1}{c|}{\textit{Single}} \\
\hline
\textit{Removal} & \textbf{0.0010} (15.9228) & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} \\
\hline
\textit{Subtract} & \textbf{0.0010} (15.3984) & 0.9000 (0.5244) & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} \\
\hline
\textit{Single} & 0.9000 (0.7628) & \textbf{0.0010} (16.6856) & \textbf{0.0010} (16.1612) & \cellcolor[rgb]{ .851. .851. .851} \\
\hline
\textit{GCF} & \textbf{0.0496} (3.8615) & \textbf{0.0010} (19.7844) & \textbf{0.0010} (19.2599) & 0.1828 (3.0988) \\
\hline
\end{tabular}
\label{filteringresultsclass_sig}
\end{table}
\begin{table}[H]
\caption{Filtering results at file level}
\fontsize{10pt}{12pt}\selectfont
\def1.1{1}
\centering
\setlength{\tabcolsep}{6pt}
\begin{tabular}{|l|c|c|c|}
\hline
\textbf{Method} & \textbf{Precision} & \textbf{Recall} & \textbf{F-Measure} \\ \hline
No filter & 0.5160 & 0.5117 & 0.4883 \\
Removal & 0.5451 & 0.5414 & 0.5194 \\
Subtract & 0.5407 & 0.5371 & 0.5147 \\
Single & 0.5187 & 0.5148 & 0.4910 \\
GCF & 0.5172 & 0.5129 & 0.4889 \\ \hline
\end{tabular}
\label{filteringresultsfile}
\end{table}
\begin{table}[H]
\caption{Significance test results for file level filtering}
\fontsize{8pt}{10pt}\selectfont
\def1.1{1}
\centering
\setlength{\tabcolsep}{6pt}
\begin{tabular}{|l|c|c|c|c|}
\hline
& \multicolumn{1}{c|}{\textit{No filter}} & \multicolumn{1}{c|}{\textit{Removal}} & \multicolumn{1}{c|}{\textit{Subtract}} & \multicolumn{1}{c|}{\textit{Single}} \\
\hline
\textit{Removal} & \textbf{0.0010} (14.2066) & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} \\
\hline
\textit{Subtract} & \textbf{0.0010} (13.2055) & 0.9000 (1.0011) & \cellcolor[rgb]{ .851. .851. .851} & \cellcolor[rgb]{ .851. .851. .851} \\
\hline
\textit{Single} & 0.0682 (3.6947) & \textbf{0.0010} (10.5119) & \textbf{0.0010} (9.5107) & \cellcolor[rgb]{ .851. .851. .851} \\
\hline
\textit{GCF} & 0.9000 (0.3576) & \textbf{0.0010} (13.8490) & \textbf{0.0010} (12.8479) & 0.1262 (3.3371) \\
\hline
\end{tabular}
\label{filteringresultsfile_sig}
\end{table}
\subsection{Classification and Resampling}\label{sec:resampling}
As trying to predict the exact number of bugs in a given source code element would be much more difficult -- and would presumably require much larger datasets -- we chose to restrict our study to predicting a boolean ``flag'' for the presence of any bugs.
Thus, we applied only classification algorithms, and to do so, classes need to be formed from the bug numbers.
For the binary classification, we selected instances with zero bugs into one class (non-buggy), and the remaining ones~--~with one or more bugs~--~into the second class (buggy).
Another problem we faced is that imbalanced learning sets could be formed from the dataset, where the positive or negative entries are in a majority which could also be misleading for model training.
For example, the ratio of buggy and non-buggy source code elements or files can be totally different.
To handle this issue at the machine learning level, we used random under sampling~\cite{he2009learning,wang2013using} to obtain an equivalent number of elements in the two categories.
For instance, if we have a final set as a corpus at method level that contains 10 buggy methods and 50 non-buggy methods, we use random under sampling for the non-buggy set to decrease the number of samples and balance the ratio to 10-10.
The training process -- using this random under sampling -- is repeated multiple times and finally, an average is calculated.
Without random under sampling, the machine learning algorithms achieved very high precision, recall, and F-measure values (e.g., by classifying all elements as non-buggy) because a significantly large difference was usually present in the number of entries for the two classes (non-buggy vs buggy).
For this reason, we present only the results achieved by using random under sampling.
\subsection{The BugHunter Dataset}\label{sec:dataset}
As a result and a main contribution, we constructed a novel kind of bug dataset that contains before/after fix states of source code elements at file, class, and method levels.
We produced a dataset for every project (see Table~\ref{tab:projects}) and also a combined one with all the projects included.
In Table~\ref{tab:metadata}, we collected the general metadata about the dataset which is scattered throughout in the paper.
The \emph{Ratio of the faulty entries} varies between the different granularity levels due to the nature of the bug-fixing changes.
For example, on method level it is more common to split a method into multiple parts or to introduce new methods to the source code during a fix, which results in more non-buggy entries than buggy, hence the low ratio.
On class level, however, the ratio is closer to 1.0 because it is less likely to create a new class in order to fix a bug.
Furthermore, on class and file levels, a new factor also contributes to the ratio.
Because classes and files represent a larger part of the source code than methods, it happens that in a fixed state of a bug the containing class or file contains other bugs as well.
In these cases, the entries related to the fixed state are marked as faulty in the dataset, which results in higher ratio values, above 1.0 in the case of files.
The resulting BugHunter Dataset 1.0 is available as an online appendix at:
\noindent
\url{http://www.inf.u-szeged.hu/~ferenc/papers/BugHunterDataSet/}
or
\noindent
\url{http://dx.doi.org/10.17632/8tx7kjbkg4.2}
\medskip
\noindent
The \texttt{BugHunterDataset-1.0.zip} file contains the dataset in CSV format as described above.
The directory named \texttt{full} contains the unfiltered database.
The remaining four directories, namely \texttt{gcf}, \texttt{remove}, \texttt{single}, and \texttt{subtract} contain the results of the different filtering methods.
Each of these directories contain 15 subdirectories -- one for each subject system -- and an additional directory named \texttt{all} which contains the summarized dataset.
Three CSV files are placed in these directories for file, class, and method levels, respectively.
There is also a fourth CSV file in each directory, called \texttt{method-p.csv} which contains the method level dataset extended with an additional column, the name of the parent class (see Section~\ref{sec:rq2}).
Additionally, the \texttt{appendix.zip} file contains the analysis results presented in Section~\ref{evaluation} in spreadsheet files.
\begin{table}[H]
\caption{BugHunter Dataset metadata}
\fontsize{8pt}{10pt}\selectfont
\def1.1{1}
\centering
\setlength{\tabcolsep}{6pt}
\begin{tabular}{|l|C{4,5cm}|}
\hline
\textbf{Type} & bug prediction dataset\\
\hline
\textbf{Granularity} & file, class, method \\
\hline
\textbf{Number of projects} & 15 \\
\hline
\textbf{Number of metrics} & static source code metrics (66), \newline code duplication metrics (8), \newline code smell metrics (35) \\
\hline
\textbf{Number of entries} & file: 70,088 \newline class: 84,562 \newline method: 159,078 \\
\hline
\textbf{Ratio of the faulty entries} & file: 1.03 (35,507/34,581) \newline class: 0.95 (41,098/43,475) \newline method: 0.59 (58,810/100,268) \\
\hline
\end{tabular}
\label{tab:metadata}
\end{table}
\subsection{Validation} \label{validation}
When constructing a dataset in an automatic way, one always has to validate the constructed set.
As seen previously, this kind of generated data should always be handled with mistrust~\cite{githubpromises}.
We chose the mid-sized project JUnit for such manual validation, which contains 90 bug reports (6 open and 84 closed) and a total of 72 referencing commits to the bugs, thus this project seems to be suitable for manual validation investing a reasonable amount of effort.
We validated the 84 closed bug reports manually to verify whether the bugs are valid, and whether the matching algorithm works well.
Table~\ref{validationresults} summarizes our findings.
\begin{table}[htb!]
\centering
\begin{tabular}{|c|c|c|c|c|}
\hline
Closed bugs & Bugs in dataset & Commits & Java code & Commit mismatch \\ \hline
84 & 37 & 72 & 61 & 5 \\ \hline
\end{tabular}
\caption{Validation results}
\label{validationresults}
\end{table}
From the total number of closed bugs, only 37 are present in the dataset because many fixing commits are not related to the source code (e.g., documentation) or Java code (e.g., bug in build XML).
This is shown in the Java code column of the table that summarizes the number of commits that contain Java language code (61).
These commits that include code are referencing 37 bugs, thus at least one bug exists that is referenced from multiple commits according to the pigeonhole principle.
We found 5 ``commit mismatch'' cases in total, where only comments were modified in the source code -- this means 7 entries in the dataset.
The dataset created for JUnit has 734 entries in total (92 files, 216 classes and 426 methods), thus a very small (0.95\%) number of entries was incorrectly included.
Out of the 734 entries, 286 are not related to test code (43 files, 77 classes, and 166 methods).
Based on this, we can presume that our validated dataset can be an appropriate corpus for further investigations and that our bug extraction mechanism is working quite reliably.
\subsection{Relationship of files and classes}
In case of Java, there is usually one class per \textit{.java} file.
We examined how true this is for our subject projects.
We randomly chose 100 commits that we analyzed from each project and we counted the number of classes in each file, not including test files.
After we calculated the frequency of these values for each commit, we calculated the average frequency (see Figure~\ref{fig:distofclassesinfiles}).
The diagram shows that most of the files contain only a single class (865), but there is a significant number of files with more than one class (120 files with 2 classes, 46 files with 3 classes, etc.).
Although we have a larger set of metrics on class level than on file level, we cannot associate a file to a single class due to the one-to-many relationship between them.
\begin{figure}[htb!]
\centering
\includegraphics[width=\textwidth]{fig/distofclassesinfiles.pdf}
\caption{Distribution of the number of classes in a Java file}
\label{fig:distofclassesinfiles}
\end{figure}
\subsection{Computational cost of extending the dataset}
Extending the dataset comes with computational cost that depends on multiple factors.
Adding a new project to the dataset requires the project to have bug reports with bug-fixing commits.
Finding such projects is time-consuming, because it mostly requires manual work to select good candidates (see Section~\ref{sec:chosenprojects}).
The most critical step is to collect appropriate bugs.
For this initial dataset, we collected projects from GitHub, since its API makes it easy to gather the required information about bugs automatically.
The actual run-time of this step depends on the size of the project, e.g. number of commits and number of bug reports, but for the selected 15 projects, it took just a few hours to save the required data.
Selecting bugs manually would take considerably more time.
GitHub has a limit on the number of API requests per hour which increased the total run-time.
It is possible to collect data from other sources, although it may require a different amount of work.
The most time and resource consuming task is the source code analysis.
We used the OpenStaticAnalyzer tool which performs deep static analysis; therefore, it requires more resources than a simple parser tool.
During this step, we extract the static source code metrics and the source code positions of the classes and methods, as described in Sections~\ref{sec:processingrawdata} and \ref{sec:sourcecodeanalysis}, respectively.
The computational cost of this step highly depends on the number of bug-fixing commits, the size of the source code, and the analyzer tool.
It took days to analyze each of the nearly 10,000 bug-fixing commits.
There are other tools that could be used to extract the source code positions and other tools to compute metrics with potentially less run-time, but the tool we used produces a wide range of metrics and rule violations accurately in a well processable format.
The next step, determining the buggy source code elements, is a simple algorithm that does not require much resources.
The run-time here mostly depends on the number of bug-fixing commits.
It took only a few hours for the 15 projects.
For example, to process a smaller project such as jUnit, it took around 2 hours of machine time: 10 minutes to download the data from GitHub, 110 minutes to analyze 107 versions of the project (on average 1 minute per version) and around 2 minutes to produce the bug dataset entries.
Regarding a larger project, Elasticsearch, it took around 6 hours to download the data from GitHub, around 1,600 hours to analyze 4,881 versions of the project (on average 20 minutes per version) and it took around 90 minutes to produce the bug dataset.
At this point, the data is ready to be added to the dataset.
The last step is to match the format of the dataset (see Section~\ref{sec:dataset}).
Since the dataset consist of CSV files, it is very easy to extend it with new projects or with additional bugs for the projects that are already present.
\section{Conclusions and Future Work} \label{conclusion}
In this study, we developed a method that generates a bug dataset whose entries are source code elements touched by bugfixes mined from GitHub.
The entries represent before and after states of source code elements on which bug fixes were applied.
The presented approach allows the simultaneous processing of several publicly available projects located on GitHub, thereby resulting in the production of a large -- and automatically expandable -- dataset.
In contrast, previous studies have dealt with only a few large-scale datasets, which were created under strict individual management.
Additionally, our dataset contains new source code metrics compared to other datasets, allowing the examination of the relationship between these metrics and software bugs.
Furthermore, manual examinations showed the reliability of our approach, so the adaptation of project-specific labels to the presence of bugs remains the only non-automatic step.
Our initial adaptation of 15 suitable Java projects lead to the construction of the current dataset, which is one of our main -- publicly available -- contributions.
During empirical evaluations, we showed that the dataset can be used for further investigations such as bug prediction.
For this purpose, we used several machine learning algorithms at three different granularity levels (method, class, file) from which the method-level prediction achieved the highest F-measure values.
As a novel kind of experiment, we also investigated whether the method-level metrics projected to the class level are better predictors than the class-level metrics themselves, and found a significant improvement in the results.
As potential future work, we are planning to expand the dataset with additional projects and even additional data sources, such as SourceForge and Bitbucket.
Supporting different external bug tracking systems is another option for extending our approach.
We will also dedicate more attention to the concrete prediction models we generate, as this study focused solely on showing the conceptual usability of our dataset.
\section{Evaluation} \label{evaluation}
To evaluate the usefulness of our new bug dataset, we created bug prediction models by using machine learning algorithms.
During the training, we used 10-fold cross validation to measure the accuracy of the models.
To compare the models, we used precision, recall, and F-measure metrics that are defined as follows:
\bigskip
\noindent
\begin{center}
$precision = \dfrac{TP}{TP + FP}$ \hspace{50pt}
$recall = \dfrac{TP}{TP + FN} $ \\
\end{center}
\begin{center}
$F-measure = 2\cdot \dfrac{ precision \cdot recall}{precision + recall}$, \\
\end{center}
\noindent where \textit{TP} (True Positive) is the number of methods/classes/files that were predicted as faulty and observed as faulty, \textit{FP} (False Positive) is the number of methods/classes/files that were predicted as faulty but observed as not faulty, \textit{FN} (False Negative) is the number of methods/classes/files that were predicted as non-faulty but observed as faulty.
We used the following algorithms from the Weka library to find out how they perform on our dataset:
\begin{itemize}
\setlength\itemsep{-0.3em}
\item NaiveBayes
\item NaiveBayesMultinomial
\item Logistic
\item SGD
\item SimpleLogistic
\item VotedPerceptron
\item DecisionTable
\item OneR
\item J48 (C4.5)
\item RandomForest
\item RandomTree
\end{itemize}
We have 3 source code levels (method, class, file), 15 chosen projects (plus the summarized dataset), and 11 machine learning algorithms, implying that full tables with the obtained results would be too large to present in the paper, thus we introduce only the best algorithms here for the overall dataset.
Please note that the online appendix (see Section~\ref{sec:dataset} for the Web link) contains all the analysis results in spreadsheet files.
\subsection{First Research Question}\label{sec:rq1}
The first research question we will answer is the following:
\bigskip
\fbox{
\parbox{\textwidth - 45pt}{
\textbf{RQ1:} \textit{Is the constructed dataset usable for bug prediction purposes?}
}
}
\bigskip
To answer RQ1, we present the best results obtained by different machine learning algorithms at method, class, and file level.
Similar to Section~\ref{sec:filtering}, we used the Friedman test and the Nemenyi post-hoc test to check whether the distributions of the samples are equal or not.
We observed the same, very low $p$ values ($p_{method}=1.21\text{e-}14$, $p_{class}=1.54\text{e-}07$, $p_{projected}=3.77\text{e-}14$, $p_{file}=1.06\text{e-}05$), thus the distributions are not equal.
With $\alpha=0.05$, the critical value in this case for 11 groups (machine learning algorithms) and 16 samples (databases) based on the studentized range table is $q_{crit}=5.256$.
Due to the size of the tables, we do not include them here, instead, the complete tables are available in the Appendix (see Tables~\ref{tab:sign_res_method_ml},~\ref{tab:sign_res_class_ml},~\ref{tab:sign_res_projected_ml}, and~\ref{tab:sign_res_file_ml}).
\subsubsection{Method level}
We trained models to use method level metrics to predict future failures at method level.
The results are shown in Table~\ref{methodtop5} containing the best five algorithms selected by F-measure values.
The fifth best algorithm with 0.5983 F-measure value is DecisionTable~\cite{Kohavi1995}.
The SimpleLogistic algorithm resulted a slightly higher F-measure (0.6031).
SimpleLogistic algorithm builds linear logistic regression models that uses automatic attribute selection~\cite{Landwehr2005}.
The first three algorithms are all from the tree family.
J48~\cite{Quinlan1993} that uses pruned or unpruned C4.5 decision tree to build a model is the second best algorithm (0.6119).
The third and the first algorithms also use trees to produce prediction models.
RandomForest (0.6319) builds a forest from RandomTrees to get a slightly better result than RandomTree (0.6110).
The results of the statistical tests in Table~\ref{tab:sign_res_method_ml} show that the differences between the top five algorithms are not statistically significant ($p>\alpha=0.05$) but the difference between the worst (NaiveBayes, NaiveBayesMultinomial and VotedPerceptron) and the best performing algorithms are significant.
\begin{table}[H]
\caption{TOP 5 machine learning algorithms for method level based on F-measure}
\fontsize{10pt}{12pt}\selectfont
\def1.1{1}
\centering
\setlength{\tabcolsep}{6pt}
\begin{tabular}{|l|c|c|c|}
\hline
\textbf{Algorithm} & \textbf{Precision} & \textbf{Recall} & \textbf{F-Measure} \\ \hline
trees.RandomForest & 0.6335 & 0.6324 & 0.6319 \\
trees.J48 & 0.6147 & 0.6134 & 0.6119 \\
trees.RandomTree & 0.6115 & 0.6113 & 0.6110 \\
functions.SimpleLogistic & 0.6062 & 0.6043 & 0.6031 \\
rules.DecisionTable & 0.6138 & 0.6073 & 0.5983 \\ \hline
\end{tabular}
\label{methodtop5}
\end{table}
At method level, trees were performing the best and can result up to 0.6319 when considering F-measure values.
We also investigated the results by projects and found that specific projects performed worse than others.
Android Universal Image Loader and Ceylon were the worst, both when considering precision, recall, or F-measure.
Achieved F-measure values depend highly upon the project itself.
A possible factor that plays role in this is the size of the built corpus.
These projects have a smaller training corpus and more inconsistency in the feature vectors, consequently it is harder to build a well-performing prediction model.
This phenomenon does not appear only at method level but at class and file level too, since at these levels even less entries are created in the dataset.
The best F-measure values (over 0.75 in one case) achieved on different projects are demonstrated in Table~\ref{tab:bestbyproject_method}.
\begin{table}[H]
\caption{The best F-measure values by projects at method level}
\fontsize{10pt}{12pt}\selectfont
\def1.1{1}
\centering
\setlength{\tabcolsep}{6pt}
\begin{tabular}{|l|c|c|}
\hline
\textbf{Project} & \textbf{F-measure} & \textbf{Algorithm} \\ \hline
antlr4 & 0.7573 & trees.RandomForest \\
BroadleafCommerce & 0.7366 & trees.RandomForest \\
hazelcast & 0.7170 & trees.RandomForest \\
mct & 0.6876 & trees.RandomForest \\
oryx & 0.6678 & trees.RandomForest \\
junit & 0.6638 & rules.DecisionTable \\
all & 0.6622 & trees.RandomForest \\
netty & 0.6412 & trees.RandomForest \\
elasticsearch & 0.6411 & trees.RandomForest \\
orientdb & 0.6236 & trees.RandomForest \\
titan & 0.6216 & functions.SGD \\
neo4j & 0.6086 & functions.Logistic \\
mcMMO & 0.5815 & trees.RandomForest \\
MapDB & 0.5610 & functions.SimpleLogistic \\
Android-Universal-Image-Loader & 0.5569 & functions.SGD \\
ceylon-ide-eclipse & 0.5395 & trees.RandomTree \\ \hline
\end{tabular}
\label{tab:bestbyproject_method}
\end{table}
\subsubsection{Class level}
When considering class level, we have quite a different set of algorithms in the top five than in the case of methods.
Furthermore, the precision, recall, and F-measure values differ significantly from those we obtained at method level.
We suspect that the main reason behind this is the different set of metrics used to build models, thus to predict the possibility of occurring bugs in a class.
At class level, simple logistic, decision table, and SGD were the best.
Function and rule based groups of machine learning algorithms can be emphasized as the best when considering class level.
The best machine learning algorithms at class level are shown in Table~\ref{fmeasureclasstop5} with F-measure values around 0.56.
In Table~\ref{tab:sign_res_class_ml}, the results of the significance tests show that the best algorithm, SimpleLogistic with 0.5685 F-measure, achieved significantly better results than the worst two algorithms that are not in the top five (NaiveBayes $p=0.019$ and VotedPerceptron $p=0.001$).
Between the top five algorithms, the differences are not significant ($p>\alpha=0.05$).
The low F-measures values suggest that one cannot build efficient prediction models at class level.
\begin{table}[H]
\caption{TOP 5 machine learning algorithms for class level based on F-measure}
\fontsize{10pt}{12pt}\selectfont
\def1.1{1}
\centering
\setlength{\tabcolsep}{6pt}
\begin{tabular}{|l|c|c|c|}
\hline
\textbf{Algorithm} & \textbf{Precision} & \textbf{Recall} & \textbf{F-Measure} \\ \hline
functions.SimpleLogistic & 0.5760 & 0.5763 & 0.5685 \\
rules.DecisionTable & 0.5703 & 0.5705 & 0.5637 \\
functions.SGD & 0.5718 & 0.5676 & 0.5626 \\
functions.Logistic & 0.5561 & 0.5552 & 0.5537 \\
trees.J48 & 0.5531 & 0.5530 & 0.5520 \\ \hline
\end{tabular}
\label{fmeasureclasstop5}
\end{table}
\begin{table}[H]
\caption{The best F-measure values by projects at class level}
\fontsize{10pt}{12pt}\selectfont
\def1.1{1}
\centering
\setlength{\tabcolsep}{6pt}
\begin{tabular}{|l|c|c|}
\hline
\textbf{Project} & \textbf{F-measure} & \textbf{Algorithm} \\ \hline
BroadleafCommerce & 0.7400 & trees.RandomForest \\
oryx & 0.7095 & functions.SGD \\
junit & 0.6639 & rules.DecisionTable \\
hazelcast & 0.6175 & trees.RandomTree \\
MapDB & 0.6138 & functions.SimpleLogistic \\
orientdb & 0.6132 & functions.SimpleLogistic \\
mct & 0.5825 & functions.SGD \\
elasticsearch & 0.5817 & rules.DecisionTable \\
all & 0.5803 & rules.DecisionTable \\
ceylon-ide-eclipse & 0.5789 & rules.DecisionTable \\
antlr4 & 0.5685 & rules.OneR \\
mcMMO & 0.5670 & functions.SGD \\
titan & 0.5614 & functions.SimpleLogistic \\
netty & 0.5537 & functions.Logistic \\
neo4j & 0.5413 & functions.SimpleLogistic \\
Android-Universal-Image-Loader & 0.4713 & bayes.NaiveBayes \\ \hline
\end{tabular}
\label{tab:bestbyproject_class}
\end{table}
However, we present the F-measure values of individual projects in Table~\ref{tab:bestbyproject_class}.
Considering these F-measure values, we can see the same phenomenon as in the case of methods.
McMMO, Android Universal Image Loader, and Neo4J are in the worst 5, which supports the previous experience according to which different projects provide different amount of ``munition'' for predicting faults.
The best case, however, provides an F-measure of 0.74.
\subsubsection{File level}
In Java context, a public class is almost equivalent to a file with a \textit{'.java'} extension.
However, despite the fact that we compute a different set of metrics for class and file level, the results are quite similar.
Since we operate on a different set of metrics at class and file level, this explains that different machine learning algorithms performed the best.
The best algorithms for this level use tree-based approaches to predict bugs as it is shown in Table~\ref{fmeasurefiletop5}.
Similar to class level, the differences between the top five algorithms are not considered significant ($p>\alpha=0.05$), as can be seen in Table~\ref{tab:sign_res_file_ml}.
The best performing algorithm, achieving an F-measure value of 0.5476, is RandomTree.
The top five algorithms achieved significantly better results compared to the worst algorithm (VotedPerceptron).
Between the top five algorithms, the differences are not considered significant ($p>\alpha=0.05$).
\begin{table}[H]
\caption{TOP 5 machine learning algorithms for file level based on F-measure}
\fontsize{10pt}{12pt}\selectfont
\def1.1{1}
\centering
\setlength{\tabcolsep}{6pt}
\begin{tabular}{|l|c|c|c|}
\hline
\textbf{Algorithm} & \textbf{Precision} & \textbf{Recall} & \textbf{F-Measure} \\ \hline
trees.RandomTree & 0.5484 & 0.5484 & 0.5476 \\
trees.RandomForest & 0.5458 & 0.5461 & 0.5455 \\
functions.Logistic & 0.5528 & 0.5474 & 0.5367 \\
rules.OneR & 0.5358 & 0.5359 & 0.5348 \\
functions.SimpleLogistic & 0.5491 & 0.5474 & 0.5321 \\ \hline
\end{tabular}
\label{fmeasurefiletop5}
\end{table}
We also present the F-measure values obtained on projects in Table~\ref{tab:bestbyproject_file}.
The takeaway remains the same, Android Universal Image Loader and Neo4J are located in the worst five projects again.
On the other hand, Broadleaf Commerce, Oryx, and Hazelcast seem to be appropriate to use in model building.
The best F-measure value is over 0.77.
\begin{table}[H]
\caption{The best F-measure values by projects at file level}
\fontsize{10pt}{12pt}\selectfont
\def1.1{1}
\centering
\setlength{\tabcolsep}{6pt}
\resizebox{\textwidth}{!}{
\begin{tabular}{|l|c|c|}
\hline
\textbf{Project} & \textbf{F-measure} & \textbf{Algorithm} \\ \hline
BroadleafCommerce & 0.7741 & trees.RandomForest \\
oryx & 0.6458 & bayes.NaiveBayesMultinomial \\
hazelcast & 0.6417 & trees.RandomTree \\
all & 0.6234 & trees.RandomTree \\
orientdb & 0.6200 & rules.DecisionTable \\
elasticsearch & 0.6073 & trees.RandomTree \\
ceylon-ide-eclipse & 0.5857 & trees.J48 \\
titan & 0.5793 & functions.SimpleLogistic \\
mcMMO & 0.5702 & trees.RandomForest \\
MapDB & 0.5525 & rules.OneR \\
junit & 0.5484 & rules.OneR \\
netty & 0.5344 & trees.RandomTree \\
antlr4 & 0.5212 & trees.RandomForest \\
neo4j & 0.5138 & rules.DecisionTable \\
Android-Universal-Image-Loader & 0.4781 & rules.DecisionTable \\
mct & 0.4576 & functions.Logistic \\ \hline
\end{tabular}
}
\label{tab:bestbyproject_file}
\end{table}
\vspace{6pt}
\setlength\parindent{0pt}
\resizebox{\textwidth}{!}{
\fbox{
\parbox{\textwidth - 15pt}{
\textbf{Answering RQ1:} \textit{
Considering the results we obtained, we can state that creating bug prediction models at method level is more successful than at file and class levels if we consider the full dataset.
We also showed the diversion in F-measure values by projects, which strengthens our assumption that not all projects are capable of providing an appropriate training set.
We can obtain F-measure values on separate projects up to 0.7573, 0.7400, and 0.7741 at method, class and file level, respectively, which is promising.
In our next research question, we accomplish an experiment and its results are even better.
However, even without knowing that there is a better solution, we can answer this research question in a positive manner and say that the constructed dataset is usable for bug prediction.
}
}
}
}
\vspace{6pt}
\setlength\parindent{15pt}
\subsection{Second Research Question}\label{sec:rq2}
The dataset contains the bug information on both method and class levels, and we also know the containing relationships between classes and methods.
However, since classes have a different source code metrics set than methods, a question arose: can we (and more importantly, should we) use method level metrics to predict faulty classes?
The second research question we will answer is the following:
\vspace{6pt}
\setlength\parindent{0pt}
\fbox{
\parbox{\textwidth - 15pt}{
\textbf{RQ2:} \textit{Are the method level metrics projected to class level better predictors than the class level metrics themselves?}
}
}
\vspace{6pt}
\setlength\parindent{15pt}
We carried out an experiment where we projected the results of the method-level learning to the class level.
During the cross-validation of the method level learning, we used the containing classes of the methods to calculate the confusion matrix from the number of classes classified as buggy and non-buggy.
Classes containing at least one buggy method were considered as buggy.
We compared this result with the result of the class-level prediction.
The results in Table~\ref{aggregatedresults} show that the projection method performs much better than the prediction with class level metrics.
We applied the Wilcoxon-signed-rank test~\cite{wilcoxon1945individual} (a non-parametric paired test for dependent samples), with a threshold of $Z_{crit}=1.96$ (for a two-tailed test with $\alpha=0.05$) to check whether the difference is significant.
We also calculated the effect size of these tests with the Pearson correlation coefficient (Pearson's r) from the formula $r=\frac{Z}{\sqrt{N}}$, where $N$ is the total number of samples and $Z$ is the z-score of the test~\cite{rosenthal1994parametric}.
According to Cohen~\cite{cohen1992power}, the effect size is considered small if $r\approx0.1$, medium if $r\approx0.3$ or large if $r\approx0.5$.
After the test, we can confirm that the difference between the projection method and the prediction with class level metrics is significant ($Z=10.9>Z_{crit}=1.96$) and the effect size is considered large ($r=0.58$).
We suspect that this is due to the generality of class-level metrics, which are therefore not powerful enough to effectively distinguish source code bugs.
Although the bug information for methods does not include all bugs that affect the containing class (e.g. change of fields, interfaces or superclasses), method level metrics are more useful for bug prediction.
The results of the significance tests between the different machine learning algorithms is displayed in Table~\ref{tab:sign_res_projected_ml}.
The best performing algorithm is RandomForest with 0.7405 F-measure and it is significantly better than the worst three algorithms that are not displayed in Table~\ref{aggregatedresults} (NaiveBayes $p=0.001$; NaiveBayesMultinomial $p=0.001$; VotedPerceptron $p=0.003$).
The difference between the top five algorithms is not considered significant ($p>\alpha=0.05$).
\begin{table}[H]
\caption{The results of projected learning}
\fontsize{8pt}{10pt}\selectfont
\def1.1{1}
\centering
\setlength{\tabcolsep}{3pt}
\begin{tabular}{|c|c|c|c|c|c|c|}
\hline
\multirow{2}{*}{\textbf{Algorithm}} & \multicolumn{2}{|c|}{\textbf{Precision}} & \multicolumn{2}{|c|}{\textbf{Recall}} & \multicolumn{2}{|c|}{\textbf{F-Measure}} \\ \cline{2-7}
& Projected & Class & Projected & Class & Projected & Class \\ \hline
trees.RandomForest & 0.7471 & 0.5336 & 0.7370 & 0.5336 & 0.7405 & 0.5334 \\ \hline
trees.RandomTree & 0.7421 & 0.5381 & 0.7273 & 0.5380 & 0.7330 & 0.5376 \\ \hline
functions.SGD & 0.7441 & 0.5718 & 0.7288 & 0.5676 & 0.7322 & 0.5626 \\ \hline
rules.DecisionTable & 0.7425 & 0.5703 & 0.7404 & 0.5705 & 0.7309 & 0.5637 \\ \hline
trees.J48 & 0.7390 & 0.5531 & 0.7250 & 0.5530 & 0.7290 & 0.5520 \\ \hline
\end{tabular}
\label{aggregatedresults}
\end{table}
When using the projection approach to predict bugs in classes, the F-measure values reach 0.74.
As an extension of the answer to RQ1, we can provide the above described mechanism to locate class level bugs with a higher accuracy in a software system.
\vspace{6pt}
\setlength\parindent{0pt}
\fbox{
\parbox{\textwidth - 15pt}{
\textbf{Answering RQ2:} \textit{
Using method level metrics for class level bug prediction performed the best in our study.
This fact also contributes to the answer given for RQ1.
Furthermore, method level metrics are better predictors when projected to class level than class level metrics by themselves.
}
}
}
\vspace{6pt}
\setlength\parindent{15pt}
\subsection{Third Research Question}\label{sec:rq3}
The third research question we will answer is the following:
\vspace{6pt}
\setlength\parindent{0pt}
\fbox{
\parbox{\textwidth - 15pt}{
\textbf{RQ3:} Is the \emph{BugHunter Dataset} more powerful and expressive than the \emph{GitHub Bug Dataset}, which is constructed with the traditional approach?
}
}
\vspace{6pt}
\setlength\parindent{15pt}
Comparing the expressive power of different datasets is a harsh task since the various datasets were created with different purposes, they often have only few independent variables in common.
The projects included in these datasets are different as well.
Therefore, we provide an objective comparison between our previously published traditional bug dataset, the \emph{GitHub Bug Dataset}~\cite{toth2016public} and the \emph{BugHunter Dataset} in the following.
These two datasets include exactly the same 15 projects and the set of independent variables are common and also calculated in the same way with the same tool.
We used the same machine learning algorithms to build prediction models.
This way, it is quite straightforward to compare the expressiveness and compactness of these datasets.
\begin{table}[H]
\caption{Comparison of the size of the datasets}
\fontsize{8pt}{10pt}\selectfont
\def1.1{1}
\centering
\setlength{\tabcolsep}{3pt}
\begin{tabular}{|c|r|r|r|r|r|r|r|r|r|}
\hline
\multirow{2}{*}{\textbf{Project}} & \multicolumn{3}{c|}{\textbf{Method}} & \multicolumn{3}{c|}{\textbf{Class}} & \multicolumn{3}{c|}{\textbf{File}} \\ \cline{2-10}
& Trad & BH & Rate & Trad & BH & Rate & Trad & BH & Rate \\ \hline
Android-U.-I.-L. & 432 & 325 & 1.33 & 73 & 156 & 0.47 & 63 & 145 & 0.43 \\
antlr4 & 3,640 & 840 & 4.33 & 479 & 314 & 1.53 & 411 & 347 & 1.18 \\
BroadleafCommerce & 14,651 & 4,709 & 3.11 & 1,593 & 2,957 & 0.54 & 1,719 & 2,969 & 0.58 \\
ceylon-ide-eclipse & 8,787 & 2,087 & 4.21 & 1,611 & 1,275 & 1.26 & 700 & 946 & 0.74 \\
elasticsearch & 34,324 & 35,862 & 0.96 & 5,908 & 24,994 & 0.24 & 3,035 & 17,724 & 0.17 \\
hazelcast & 21,642 & 32,973 & 0.66 & 3,412 & 19,845 & 0.17 & 2,228 & 14,913 & 0.15 \\
junit & 2,441 & 462 & 5.28 & 731 & 316 & 2.31 & 309 & 177 & 1.75 \\
MapDB & 2,913 & 1,456 & 2.00 & 331 & 899 & 0.37 & 138 & 482 & 0.29 \\
mcMMO & 2,531 & 1,184 & 2.14 & 301 & 732 & 0.41 & 267 & 678 & 0.39 \\
mct & 9,836 & 105 & 93.68 & 1,887 & 66 & 28.59 & 413 & 52 & 7.94 \\
neo4j & 30,256 & 7,030 & 4.30 & 5,899 & 3,701 & 1.59 & 3,278 & 2,934 & 1.12 \\
netty & 8,312 & 11,171 & 0.74 & 1,143 & 5,677 & 0.20 & 914 & 4,023 & 0.23 \\
orientdb & 17,013 & 9,445 & 1.80 & 1,847 & 4,134 & 0.45 & 1,503 & 3,564 & 0.42 \\
oryx & 2,506 & 810 & 3.09 & 533 & 598 & 0.89 & 281 & 536 & 0.52 \\
titan & 8,424 & 785 & 10.73 & 1,468 & 428 & 3.43 & 976 & 378 & 2.58 \\ \hline \hline
\textbf{Total} & 167,708 & 109,244& \textbf{1.54} & 27,216 & 66,092 & \textbf{0.41} & 16,235 & 49,868 & \textbf{0.33} \\ \hline
\end{tabular}
\label{tab:num_of_entries_method}
\end{table}
Firstly, we compare the size of the datasets expressed with the number of entries located in the datasets.
Table~\ref{tab:num_of_entries_method} shows the number of entries at method, class, and file level.
The number of entries contained in the traditional dataset are listed in the ``Trad'' column.
The ``BH'' column represents the number of entries in the BugHunter dataset, while ``Rate'' is calculated as follows:
$$Rate = \frac{\#\ of\ entries\ in\ the\ traditional\ dataset}{\#\ of\ entries\ in\ the\ BugHunter\ dataset}$$
The obtained rate is higher than 1.0 for most of the projects in case of the method level, which shows that the new approach contains less entries at this level.
A rate of \emph{1.54} is achieved at method level, \emph{0.41} at class level, and \emph{0.33} at file level.
It is important to note that the traditional dataset encompasses data for only a six-month long interval which has the most bugs in it.
On the other hand, the BugHunter dataset contains information from the beginning of the project up to September, 2017.
One would expect that the new approach will contain less entries than the traditional one since the BugHunter dataset contains only the entries which were affected by a closed bug.
However, the traditional dataset only depends on the size (number of files, classes, and methods) of the projects included.
In contrast, the BugHunter dataset highly depends on the number of closed bugs in the system (large projects can have small amount of reported bugs).
Even if no feature development was performed on a project (the size of the project remains quasi-same: in general no new files and classes are added, only modified) the number of closed bugs imply more entries in the BugHunter dataset, while size is not affected in any way in the traditional dataset.
To sum up, we cannot clearly decide whether the new dataset is more compact; however it is clearly visible that BugHunter could compress the bug related information at method level.
We achieved an F-measure value of 0.6319 at method level (see~Table~\ref{tab:pred_cap_method}) and the composed dataset contains 58,464 less entries than the traditional one.
In both datasets, the number of entries are sufficient to build a predictive model from; however we should investigate the predictive capabilities first to conclude our findings related to expressive power and compactness.
In the following, we present tables that capture the differences of the prediction capabilities between the two datasets (using F-measures, as before).
Tables~\ref{tab:pred_cap_method},~\ref{tab:pred_cap_class},~\ref{tab:pred_cap_file}, and~\ref{tab:pred_cap_projected} present machine learning results for method, class, file levels and also the F-measure values for the projected method level predictors, respectively.
The complete tables are not presented here due to lack of space, however average, standard deviation, min, and max values are calculated and included in the tables which provide a general picture for the comparison.
The \texttt{appendix.zip} file supplied as an online appendix (see Section~\ref{sec:dataset}) contains the complete tables with all F-measure values.
For the sake of clarity, we describe how we obtained the averages presented here in the paper in detail.
First, since the traditional dataset consists of multiple versions with bugs from six-months long intervals, for each project we selected the version from the traditional dataset that has the most number of bugs assigned to them.
After collecting the machine learning results of the selected versions, we calculated average F-measure values for each algorithm we used.
Then we ranked the algorithms based on these averages and we selected the one with the highest average value.
We used this average value for the traditional dataset in the comparison.
From the BugHunter dataset, we used the average F-measure value of the previously selected algorithm calculated on the results obtained after applying the Subtract filtering.
We performed this process for method, class, file, and projected levels separately.
\begin{table}[!h]
\caption{Predictive capabilities - Method Level}
\fontsize{8pt}{10pt}\selectfont
\def1.1{1}
\centering
\setlength{\tabcolsep}{3pt}
\begin{tabular}{|c|r|r|r|r|}
\hline
\textbf{Dataset} & \textbf{Avg.} & \textbf{Std.dev.} & \textbf{Min} & \textbf{Max} \\ \hline
BugHunter & 0.6319 & 0.0836 & 0.3376 & 0.7573 \\ \hline
Traditional & 0.7348 & 0.0789 & 0.4019 & 0.8339 \\ \hline
\end{tabular}
\label{tab:pred_cap_method}
\end{table}
\begin{table}[!h]
\caption{Predictive capabilities - Class Level}
\fontsize{8pt}{10pt}\selectfont
\def1.1{1}
\centering
\setlength{\tabcolsep}{3pt}
\begin{tabular}{|c|r|r|r|r|}
\hline
\textbf{Dataset} & \textbf{Avg.} & \textbf{Std.dev.} & \textbf{Min} & \textbf{Max} \\ \hline
BugHunter & 0.5685 & 0.0704 & 0.3572 & 0.7400 \\ \hline
Traditional & 0.7710 & 0.0869 & 0.3446 & 0.8331 \\ \hline
\end{tabular}
\label{tab:pred_cap_class}
\end{table}
\begin{table}[!h]
\caption{Predictive capabilities - File Level}
\fontsize{8pt}{10pt}\selectfont
\def1.1{1}
\centering
\setlength{\tabcolsep}{3pt}
\begin{tabular}{|c|r|r|r|r|}
\hline
\textbf{Dataset} & \textbf{Avg.} & \textbf{Std.dev.} & \textbf{Min} & \textbf{Max} \\ \hline
BugHunter & 0.5147 & 0.0749 & 0.3328 & 0.7741 \\ \hline
Traditional & 0.6058 & 0.1076 & 0.2882 & 0.8247 \\ \hline
\end{tabular}
\label{tab:pred_cap_file}
\end{table}
\begin{table}[!h]
\caption{Predictive capabilities - Projected}
\fontsize{8pt}{10pt}\selectfont
\def1.1{1}
\centering
\setlength{\tabcolsep}{3pt}
\begin{tabular}{|c|r|r|r|r|}
\hline
\textbf{Dataset} & \textbf{Avg.} & \textbf{Std.dev.} & \textbf{Min} & \textbf{Max} \\ \hline
BugHunter & 0.7405 & 0.0914 & 0.3178 & 0.8386 \\ \hline
Traditional & 0.7831 & 0.0716 & 0.4399 & 0.8825 \\ \hline
\end{tabular}
\label{tab:pred_cap_projected}
\end{table}
On the traditional dataset, the machine learning algorithms performed better, achieving higher F-measure values in every case.
The two kinds of datasets differ fundamentally, because they are constructed with two different methods.
For the traditional dataset, we divided the history of the projects into six-month long intervals by selecting release versions from the GitHub repository.
We collected the reported bugs from these intervals and we assigned the buggy source code elements to these release versions based on the bugfixes.
Then we used the state of the source code elements from these selected versions to assemble the bug dataset.
This method was used in several previous studies~\cite{bugprediction,gyimothy2005empirical}.
It is necessary, because the bugs are reported usually after releasing a version, thus at the time of the release there are too few bugs to construct a bug dataset.
For the bug assignment, we used a heuristic method - similar to other studies~\cite{gyimothy2005empirical} - where we assigned each bug to the latest selected version before the bug was reported into the issue tracking system.
This method leads to some uncertainty in the dataset, because it could happen that the bug is not yet present in the assigned version.
Table~\ref{tab:uncertainty_trad} shows some characteristics of this uncertainty.
\begin{table}[!h]
\caption{Uncertainty in the traditional dataset}
\fontsize{10pt}{12pt}\selectfont
\def1.1{1}
\centering
\setlength{\tabcolsep}{5pt}
\begin{tabular}{|l|c|c|c|}
\hline
\textbf{Project} & \textbf{\begin{tabular}[c]{@{}c@{}}Average \\ days\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}Average commits\\ before reported\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}Average commits\\ before fixed\end{tabular}} \\ \hline
Android-U.-I.-L. & 78.78 & 179.04 & 22.82 \\
antlr4 & 83.73 & 94.83 & 66.21 \\
BroadleafCommerce & 96.40 & 524.88 & 116.74 \\
ceylon-ide-eclipse & 136.05 & 442.00 & 20.22 \\
elasticsearch & 93.85 & 1,004.60 & 382.79 \\
hazelcast & 84.61 & 1,905.88 & 143.54 \\
junit & 91.94 & 76.71 & 171.09 \\
MapDB & 102.09 & 150.47 & 25.06 \\
mcMMO & 108.71 & 289.83 & 41.72 \\
mct & 64.00 & 203.00 & 55.93 \\
neo4j & 39.53 & 535.77 & 189.30 \\
netty & 83.65 & 411.60 & 48.96 \\
orientdb & 99.21 & 568.76 & 179.30 \\
oryx & 63.00 & 104.42 & 3.40 \\
titan & 51.35 & 65.91 & 59.85 \\ \hline
\end{tabular}
\label{tab:uncertainty_trad}
\end{table}
The second column is the average number of days elapsed between the date of the release and the date of the bugs reported.
The maximum that could occur is 180 days, because we used intervals around 6 months long.
We can see that these averages are quite high, the overall average is 85 days.
The third column is the average number of commits contributed to the project between the release commit an the date of the bugs reported.
These values vary for each project, because it depends on the developers' activity.
For some projects (Elasticsearch, Hazelcast) it could mean thousands of modifications before the bug was reported.
The more commits are performed, the higher the probability that the source code element became buggy after the release.
The fourth column shows the average number of commits performed from the time when the bug was reported and when the fix was applied.
These numbers are much smaller, which also demonstrates that bugs are fixed relatively fast.
This fast corrective behavior causes before and after fix states to be less different for the BugHunter approach.
Consequently, less difference in metric values makes building a precise prediction model more difficult.
The uncertainty is also visualized in Figures~\ref{fig:bh_vs_trad} and~\ref{fig:bh_vs_trad2} for the sake of better comprehension.
The first timeline (traditional dataset) shows a case when the actual bug occurred after Release~\#1, then the bug was reported and finally fixed before Release~\#2.
In this case, the source code elements touched by the bug are included in the dataset with a buggy label.
This dataset is created with the state captured at the time of Release~\#1.
However, these source code elements became buggy after Release~\#1, thus the dataset marked them buggy at that point incorrectly.
This error comes from the methodology itself which could be leveraged by narrowing the time window (which is 6 months wide traditionally).
On the other hand, 6 months interval is not an unwitting choice.
If we narrow down the time window, we will also have less bugs for an interval, which results in a more unbiased dataset, thus only less powerful predictive models can be built.
It would be important to see how many source code elements were marked as buggy incorrectly, however this cannot be easily measured since the exact time of the bug occurrence cannot be determined (we only know the time when a bug was reported).
\begin{figure}[htb!]
\begin{center}
\includegraphics[width=0.9\textwidth]{fig/uncertainty_traditional.png}
\caption{Traditional approach}
\label{fig:bh_vs_trad}
\end{center}
\end{figure}
\begin{figure}[htb!]
\begin{center}
\includegraphics[width=0.9\textwidth]{fig/uncertainty_new.png}
\caption{BugHunter approach}
\label{fig:bh_vs_trad2}
\end{center}
\end{figure}
The new BugHunter approach (see Figure~\ref{fig:bh_vs_trad2}), however, is free from the uncertainty mentioned above because it uses only the buggy and the fully fixed states of the bug related source code elements.
This way, the produced bug dataset is more precise, hence it is more appropriate for machine learning.
Therefore, we cannot clearly state that the traditional dataset is better, even despite the higher F-measure values.
The difference between the values of the two dataset is around 0.10 at method level, 0.21 at class level, and 0.09 at file level.
Projecting method level metrics to class level achieved almost as high an F-measure value (0.7405) as in the traditional case (0.7831).
The difference is only 0.04, yet it is on a much more precise dataset.
\vspace{6pt}
\setlength\parindent{0pt}
\fbox{
\parbox{\textwidth - 15pt}{
\textbf{Answering RQ3:} \textit{
Traditional datasets include a high risk when labeling source code elements as buggy since the elements may become buggy after the release version.
This injects false labeling into the training set, which might end up in deceptive machine learning results (as successfully predicting a bad label is not correct).
Unfortunately, the number of incorrectly labeled source code elements cannot be determined since we only know the time when a bug was reported, we do not know the exact time when it was inserted into the system.
These facts make it really hard to take one dataset and state that it is better for bug prediction.
}
}
}
\vspace{6pt}
\setlength\parindent{15pt}
\section{Data Source} \label{datasource}
To address our research objectives, this section briefly introduces the version control system used (Git), its corresponding source code hosting service (GitHub), and their main functionalities that are closely related to the creation of linkage data between bugs and source code elements.
Afterwards, we enumerate the chosen projects and give some further insight on the reasons why we chose them as our subject systems.
\subsection{GitHub}
GitHub is one of today's most popular source code hosting services.
It is used by several major open-source teams for managing their projects like Node.js, Ruby on Rails, Spring Framework, Zend Framework, and Jenkins, among others.
GitHub offers public and private Git repositories for its users, with some collaborative services, e.g., built-in bug and issue tracking systems.
Bug reporting is supported by the fact that any GitHub user can add an issue, and collaborators can even label these issues for further categorization.
The system provides some basic labels, such as ``bug'', ``duplicate'', and ``enhancement'', but these tags can be customized if required.
In an optimal case, the collaborators review these reports and label them with the proper labels, for instance, the bug reports with the ``bug'' label.
The most important feature of bug tracking is that we can refer to an issue from the log message of a commit by using the unique identifier of the issue, thereby identifying a connection between the source code and the reported bug.
GitHub has an API\footnote{\url{https://developer.github.com/v3/}} that can be used for managing repositories from other systems, or query information about them.
This information includes events, feeds, notifications, gists, issues, commits, statistics, and user data.
\begin{table}[h]
\caption{The number of repositories created between 01-01-2013 and 07-09-2017 for the top~10 languages}
\def1.1{1}
\centering
\setlength{\tabcolsep}{6pt}
\begin{tabular}{l|c}
\hline
\textbf{Language} & \textbf{Number of repositories} \\ \hline
JavaScript & 2,019,215 \\
Java & 1,465,168 \\
Ruby & 1,379,225 \\
Python & 1,014,760 \\
PHP & 983,479 \\
C & 737,314 \\
C++ & 619,914 \\
CSS & 568,493 \\
C\# & 282,092 \\
Shell & 263,350 \\ \hline
\end{tabular}
\label{tab:githubarchivedata}
\end{table}
With the GitHub Archive\footnote{\url{https://www.gharchive.org/}} project that also uses this API, we can get up-to-date statistics about the public repositories.
For instance, Table~\ref{tab:githubarchivedata} presents the number of repositories created between 1 January 2013 and 7 September 2017, grouped by the main programming languages they use (only the top 10 languages are shown).
Our approach uses Java repositories (the second most used platform on GitHub) to gather a proper information base for constructing a bug dataset.
Although extracting basic information from GitHub is easy, some version control features are hard to deal with, especially during the linking process when we try to match source code elements to bugs.
For example, Git provides a powerful branching mechanism by supporting the creation, deletion, and selection of branches.
In our case, we have to handle different branches because a fixing commit most often occurs on other -- so called ``topic'' -- branches and not on the master branch.
Fortunately, the projects we analyzed often solved this problem by merging.
During the merge, isomorphic commits are generated and placed on the master branch, thus all the desired analysis can be done by taking only the master branch with a given version as input.
Another example is forking a repository, which is used world-wide.
In our experiment, we do not handle forks, since it would have encumbered the above mentioned linking process and we would not gain significant additional information since bugs are often corrected in the original repository.
These details can be viewed as our underlying assumptions regarding the usage of GitHub.
\subsection{The Chosen Projects}\label{sec:chosenprojects}
We considered several criteria when searching for appropriate projects on GitHub.
First of all, we searched for projects written in Java, especially larger ones, because those are more suitable for this kind of analysis.
It was also important to have an adequate number of issues labeled as bugs, and the number of references from the log messages to certain commits is also a crucial factor (this is how we can link source code elements to bugs).
Additionally, we preferred projects that are still actively maintained.
Logged-in users can give a star for any repository and bookmark selected ones to follow.
The number of stars and watches applied to repositories forms a ranking between them, which we will refer to as ``popularity'' in the following.
We performed our search for candidate projects mainly based on popularity and activity.
We also found many projects during the search that would have fulfilled most aspects, had the developers not used an external bug tracker system -- something we could not support yet.
In the end, we selected the 15 projects listed in Table~\ref{tab:projects} based on the previously mentioned criteria.
As the descriptions show, these projects cover different domains; a good practice when the goal is creating a general dataset.
The table contains the following additional data about the projects:
\begin{description}
\item[Stars] the number of stars a project received on GitHub
\item[Forks] the number of forks of a project on GitHub
\item[kLOC] the thousand lines of code a project had at September, 2017
\end{description}
Recently, the repository of the Ceylon project was moved to a new location and the old repository is not available anymore.
Due to this reason we could not obtain the total number of stars and the total number of forks of this repository, resulting the low values in the table.
\begin{table}[htb!]
\caption{The selected projects and their descriptions}
\scriptsize
\def1.1{1}
\centering
\setlength{\tabcolsep}{6pt}
\begin{tabular}{|C{1,5cm}C{1,5cm}C{1,5cm}|p{7cm}|}
\hline
\multicolumn{3}{|c|}{\textbf{Project Name}} & \multirow{2}{*}{\textbf{Description}} \\% \cline{1-3}
\textbf{Stars} & \textbf{Forks} & \textbf{kLOC} & \\ \hline
\multicolumn{3}{|c|}{Android Universal Image Loader\tablefootnote{\url{https://github.com/nostra13/Android-Universal-Image-Loader}}} & \multirow{2}{=}{An Android library that assists the loading of images.}\\
16,521 & 6,357 & 13 & \\ \hline
\multicolumn{3}{|c|}{ANTLR v4\tablefootnote{\url{https://github.com/antlr/antlr4}}} & \multirow{3}{=}{A popular software in the field of language processing. It is a powerful parser generator for reading, processing, executing, or translating structured text or binary files.}\\
\multirow{2}{*}{6,030} & \multirow{2}{*}{1,559} & \multirow{2}{*}{68} & \\
& & & \\ \hline
\multicolumn{3}{|c|}{Elasticsearch\tablefootnote{\url{https://github.com/elastic/elasticsearch}}} & \multirow{2}{=}{A popular RESTful search engine.}\\
42,685 & 14,303 & 995 & \\ \hline
\multicolumn{3}{|c|}{jUnit\tablefootnote{\url{https://github.com/junit-team/junit4}}} & \multirow{2}{=}{A Java framework for writing unit tests.}\\
7,536 & 2,826 & 43 & \\ \hline
\multicolumn{3}{|c|}{MapDB\tablefootnote{\url{https://github.com/jankotek/MapDB}}} & \multirow{2}{=}{A versatile, fast and easy to use database engine in Java.}\\
3,700 & 745 & 68 & \\ \hline
\multicolumn{3}{|c|}{mcMMO\tablefootnote{\url{https://github.com/mcMMO-Dev/mcMMO}}} & \multirow{2}{=}{An RPG game based on Minecraft. }\\
511 & 448 & 42 & \\ \hline
\multicolumn{3}{|c|}{Mission Control Technologies\tablefootnote{\url{https://github.com/nasa/mct}}} & \multirow{4}{=}{Originally developed by NASA for the space flight operations. It is a real-time monitoring and visualization platform that can be used for monitoring any other data as well.}\\
\multirow{3}{*}{818} & \multirow{3}{*}{280} & \multirow{3}{*}{204} & \\
& & & \\
& & & \\ \hline
\multicolumn{3}{|c|}{Neo4j\tablefootnote{\url{https://github.com/neo4j/neo4j}}} & \multirow{2}{=}{The world's leading graph database with high performance.}\\
6,643 & 1,636 & 1,027 & \\ \hline
\multicolumn{3}{|c|}{Netty\tablefootnote{\url{https://github.com/netty/netty}}} & \multirow{2}{=}{An asynchronous event-driven networking framework.}\\
20,006 & 9,128 & 380 & \\ \hline
\multicolumn{3}{|c|}{OrientDB\tablefootnote{\url{https://github.com/orientechnologies/orientdb}}} & \multirow{2}{=}{A popular document-based NoSQL graph database. Mainly famous for its speed and scalability.}\\
3,919 & 792 & 621 & \\ \hline
\multicolumn{3}{|c|}{Oryx 2\tablefootnote{\url{https://github.com/OryxProject/oryx}}} & \multirow{2}{=}{An open-source software with machine learning algorithms that allows the processing of huge data sets.}\\
1,633 & 388 & 34 & \\ \hline
\multicolumn{3}{|c|}{Titan\tablefootnote{\url{https://github.com/thinkaurelius/titan}}} & \multirow{2}{=}{A high-performance, highly scalable graph database.}\\
4,931 & 1,015 & 108 & \\ \hline
\multicolumn{3}{|c|}{Eclipse plugin for Ceylon\tablefootnote{\url{https://github.com/eclipse/ceylon-ide-eclipse}}} & \multirow{2}{=}{An Eclipse plugin which provides a Ceylon IDE.}\\
56 & 30 & 181 & \\ \hline
\multicolumn{3}{|c|}{Hazelcast\tablefootnote{\url{https://github.com/hazelcast/hazelcast}}} & \multirow{2}{=}{A platform for distributed data processing.}\\
3,211 & 1,169 & 949 & \\ \hline
\multicolumn{3}{|c|}{Broadleaf Commerce\tablefootnote{\url{https://github.com/BroadleafCommerce/BroadleafCommerce}}} & \multirow{2}{=}{A framework for building e-commerce websites.}\\
1,266 & 1,020 & 322 & \\ \hline
\end{tabular}
\label{tab:projects}
\end{table}
\begin{table}[htb!]
\caption{Statistics about the selected projects}
\scriptsize
\def1.1{1.5}
\centering
\setlength{\tabcolsep}{4pt}
\begin{tabular}{|l|rrrrrr|}
\hline
& \textbf{TNC} & \textbf{NCRB} & \textbf{NBR} & \textbf{NOBR} & \textbf{NCBR} & \textbf{ANCBR} \\ \hline
\textbf{Android Universal I. L.} & 1,025 & 52 & 90 & 15 & 75 & 0.69 \\
\textbf{ANTLR v4} & 6,526 & 162 & 179 & 23 & 156 & 1.04 \\
\textbf{Elasticsearch} & 28,815 & 2,807 & 4,494 & 207 & 4,287 & 0.65 \\
\textbf{jUnit} & 2,192 & 72 & 90 & 6 & 84 & 0.86 \\
\textbf{MapDB} & 2,062 & 167 & 244 & 16 & 228 & 0.73 \\
\textbf{mcMMO} & 4,765 & 268 & 664 & 8 & 656 & 0.41 \\
\textbf{Mission Control T.} & 977 & 15 & 46 & 9 & 37 & 0.40 \\
\textbf{Neo4j} & 49,979 & 781 & 1,268 & 116 & 1,152 & 0.68 \\
\textbf{Netty} & 8,443 & 956 & 2,240 & 33 & 2,207 & 0.43 \\
\textbf{OrientDB} & 15,969 & 722 & 1,522 & 250 & 1,272 & 0.57 \\
\textbf{Oryx} & 1,054 & 69 & 67 & 2 & 65 & 1.06 \\
\textbf{Titan} & 4,434 & 93 & 135 & 8 & 127 & 0.73 \\
\textbf{Eclipse p. for Ceylon} & 7,984 & 316 & 923 & 82 & 841 & 0.38 \\
\textbf{Hazelcast} & 24,380 & 3,030 & 3,882 & 120 & 3,762 & 0.81 \\
\textbf{Broadleaf Commerce} & 14,920 & 1,051 & 703 & 28 & 675 & 1.56 \\ \hline
\end{tabular}
\label{tab:projectstat}
\end{table}
Besides knowing each project's domain, further descriptors can help us get a more precise understanding.
Table~\ref{tab:projectstat} provides a more accurate picture of the projects by showing different characteristics (related to the repositories) for each project.
This table sums up the occurrences of various bug reports and commits of the projects present at September, 2017.
Considering the total number of commits (TNC) is a good starting point to show the scale and activity of the projects.
The number of commits referencing a (closed) bug (NCRB) shows how many commits out of TNC referenced a bug by using the pattern '\textit{\#x}' in their commit log messages, where \textit{x} is a number that uniquely identifies the proper issue that is labeled as a bug~\cite{mockus2000identifying}.
NCBR (Number of Closed Bug Reports) is also important, since we only consider closed bug reports and the corresponding commits in this context.
The abbreviations we used stand for the following:
\begin{description}
\item[TNC] Total Number of Commits
\item[NCRB] Number of Commits Referencing a Bug
\item[NBR] Number of Bug Reports
\item[NOBR] Number of Open Bug Reports
\item[NCBR] Number of Closed Bug Reports
\item[ANCBR] Average Number of Commits per closed Bug Reports (NCRB/NCBR)
\end{description}
\begin{figure}
\centering
\includegraphics[width=\textwidth]{fig/issueswithncommits.pdf
\caption{The number of bug reports with the corresponding number of commits}
\label{fig:issueswithncommits}
\end{figure}
It is apparent that the projects are quite different according to the number of bug reports and the lines of code they have.
NCRB is always lower than NCBR except in three cases (ANTLR v4, Oryx, Broadleaf Commerce) which means that not all bug reports have at least one referencing commit to fix the bug.
This is possible since closing a bug is viable not only from a commit but directly from GitHub's Web user interface without committing anything.
Figure \ref{fig:issueswithncommits} depicts the number of commits for each closed bug report.
One insight here is that the rate of closed bug reports is high where not even a single commit is present to fix the bug.
There are several possible causes for this, for example, the bug report is not referred from the commit's log message, or the error has already been fixed.
\begin{figure}
\centering
\includegraphics[width=\textwidth]{fig/numberofcommits.pdf
\caption{The number of commits per projects}
\label{fig:numberofcommits}
\end{figure}
Figure~\ref{fig:numberofcommits} shows the ratio of the number of commits per projects, illustrating the activity and the size of the projects.
Neo4j is dominant if we consider only the number of commits, however bug report related activities are slight.
The presented figures show the variability of the selected software systems, which ensures the construction of a heterogeneous dataset.
\section{Introduction} \label{introduction}
The characterization of buggy source code elements is a popular research area these days.
Programmers tend to make mistakes despite the assistance provided by different integrated development environments, and errors may also occur due to frequent changes in the code and inappropriate specifications; therefore, it is important to get more and/or better tools to help the automatic detection of errors \cite{johnson2013don}.
For automatic recognition of unknown faulty code elements, it is a prerequisite to characterize the already known ones.
During software development, programmers use a wide variety of tools, including bug tracking, task management, and version control systems.
There are numerous commercial and open-source software systems available for these purposes.
Furthermore, different web services are built to meet these needs.
The most popular ones like SourceForge, Bitbucket, and GitHub fulfill the above mentioned functionalities.
They usually provide several services, such as source code hosting and user management.
Their APIs make it possible to retrieve various kinds of data, e.g., they provide support for the examination of the behavior or the co-operation of users or even for analyzing the source code itself.
Since most of these services include bug tracking, it raises the idea to use this information in the characterization of buggy source code parts~\cite{bugcenter}.
To do so, the bug reports managed by these source code hosting providers must be connected to the appropriate source code parts~\cite{wu2011relink}.
A common practice in version control systems is to describe the changes in a comment belonging to a commit (log message) and often provide the identifier of the associated bug report which the commit is supposed to fix~\cite{githubpromises}.
This can be used to identify the faulty versions of the source code~\cite{ibugs,dallmeier2007extraction}.
Processing diff files can help us obtain the code sections affected by the bug~\cite{versioncontrol}.
We can use source code metrics~\cite{metrichistorybug}, for which we only need a tool that is able to produce them.
To build a dataset containing useful buggy code element characterization information, we chose GitHub, since it hosts several regularly maintained projects and also a well defined API that makes it possible to implement an automatic data retrieval tool.
We selected 15 Java projects as our subject systems, which differ in many ways from each other (size, domain, number of bugs reported) to cover a wide and general set of systems.
Previously published datasets follow a traditional concept to create a dataset that serves as a benchmark for testing bug prediction techniques~\cite{bugprediction,jureczko2010towards}.
These datasets include all code elements~--~both buggy and non-buggy~--~from one or more versions of the analyzed system.
In this work, we created a new approach that collects before-fix and after-fix snapshots of source code elements (and their characteristics) that were affected by bugs and does not consider those code elements that were not touched by bugs.
This kind of dataset helps to capture the changes in software product metrics when a bug is being fixed.
Thus, we can learn from the differences in source code metrics between faulty and non-faulty code elements.
As far as we know, there exists no other bug dataset yet that tries to capture this before-fix and after-fix state.
Our new dataset is called \emph{BugHunter Dataset} and it is freely available (see Section~\ref{sec:dataset}).
It can serve as a new kind of benchmark for testing different bug prediction methods since we included a wide range of source code metrics to describe the previously detected bugs in the chosen systems.
We took all reported bugs stored in the bug tracking system into consideration.
We used the usual methodology of connecting commits to bugs by analyzing the log messages and by looking for clues that would unambiguously identify the bug that was the intended target of the corresponding fixing commit(s).
Commit diffs helped us detect which source code elements were modified by a given change set, thus the code elements which had to be modified in order to fix the bug.
The first version of this work was published in our earlier conference paper~\cite{gyimesi2015characterization}.
Since then, we have extended the list of subject projects (one project was replaced because it contained template files with \textit{.java} extension which undermined the source code analysis) and we have also expanded the time interval of the analysis of the projects' history to cover three additional years (from 2014 to 2017).
Furthermore, we have refined our technique and we have incorporated method level bug information into our dataset as well.
The dataset we present in this paper has not been published before.
Here we also performed experiments to check whether our novel dataset is suitable for bug prediction purposes.
During this investigation, we collected bug characterization metrics at three source code levels (file, class, method).
After the dataset was constructed, we used different machine learning algorithms to analyze the usefulness of the dataset.
We also performed a novel kind of experiment in which we assessed whether the method level metrics are better predictors when projected to class level than the class level metrics themselves.
An important aspect to investigate is how the bug prediction models built from the novel dataset compare to the ones which used the traditional datasets as corpus.
However, this comparison is hard in its nature due to the variability in multiple factors.
One major problem is the difference in the corpus itself.
The list of the included projects vary from dataset to dataset.
In our previous work, we constructed a traditional dataset, the \emph{GitHub Bug Dataset}~\cite{toth2016public}, which consists of the same 15 projects we also included in our novel bug dataset.
This gives an opportunity to assess if there is any difference in the bug prediction capabilities of these two datasets.
To emphasize the research artifact contribution and the research questions, we highlighted them in the following box.
\bigskip
\noindent
\fbox{
\parbox{\textwidth-16pt}{
\textbf{Research artifact:} A freely available novel dataset containing source code metrics of buggy Java source code elements (file, class, method) before and after bug fixes were applied to them.
\smallskip
\textbf{RQ1:} Is the constructed dataset usable for bug prediction purposes?
\smallskip
\textbf{RQ2:} Are the method level metrics projected to class level better predictors than the class level metrics themselves?
\smallskip
\textbf{RQ3:} Is the \emph{BugHunter Dataset} more powerful and expressive than the \emph{GitHub Bug Dataset}, which is constructed with the traditional approach?
}
}
\bigskip
The rest of the paper is structured as follows.
In Section~\ref{related} we discuss related work.
We present some statistics about GitHub and the projects that we have chosen for this work in Section~\ref{datasource}.
Next, we introduce the metrics used for bug characterization in Section~\ref{metrics}.
We describe our approach for generating and validating the dataset in detail in Section~\ref{approach}.
Then, we evaluate it by applying different machine learning algorithms in Section~\ref{evaluation}, where we also address our research questions.
In Section~\ref{threats}, we present the threats to validity.
Finally, we conclude and describe some future work directions in Section~\ref{conclusion}.
\section{Metrics}\label{metrics}
A software metric is a quantified measure of a property of a software project.
By using a set of different metrics, we can measure the properties of a project objectively from various points of view.
Metrics can be obtained from the source code, from the project management system, or even from the execution traces of the source code.
We can deduce higher-level software characteristics from lower level ones~\cite{qualitymodel}, such as the maintainability of the source code or the distribution of defects, but they can be also used to build a cost estimation model, apply performance optimization, or to improve activities supporting software quality~\cite{Boehm2000,ban2018prediction,ban2014recognizing}.
In this work, we used static source code metrics (also known as software product metrics).
The area of object-oriented source code metrics has been researched for many years~\cite{chidamber1994metrics,basili1996validation,bruntink2004predicting}, thus no wonder that several tools exist for measuring them.
These tools are suitable for detailed examination of systems written in various programming languages.
The source code metrics provide information about the size, inheritance, coupling, cohesion, or complexity of the code.
We used the \emph{OpenStaticAnalyzer}\footnote{\url{https://github.com/sed-inf-u-szeged/OpenStaticAnalyzer}} tool to obtain various software product metrics for the selected systems.
The full list of the object-oriented metrics we used is shown in Table~\ref{tab:metrics}.
The last three columns of the table indicate the kind of elements the given metric is calculated for, namely method, class, and file.
The presence of `X' indicates that the metric is calculated for the given source code level.
Most of the blanks in the table come from the fact that the metric is defined only for a given level.
For instance, \textit{Weighted Methods per Class} cannot be interpreted for methods and files.
Other blanks come from the limitations of the used static source code analyzer (i.e. OpenStaticAnalyzer).
\begin{table}[H]
\caption{Source code metrics used for characterization}
\scriptsize
\def1.1{0.65}
\centering
\setlength{\tabcolsep}{6pt}
\begin{tabular}{|l|l|c|c|c|}
\hline
\textbf{Abbreviation} & \textbf{Full name} & \textbf{Method} & \textbf{Class} & \textbf{File} \\ \hline
CLOC & Comment Lines of Code & X & X & X\\
LOC & Lines of Code & X & X & X\\
LLOC & Logical Lines of Code & X & X & X\\
\hline
NL & Nesting Level & X & X & \\
NLE & Nesting Level Else-If & X & X & \\
NII & Number of Incoming Invocations & X & X & \\
NOI & Number of Outgoing Invocations & X & X & \\
CD & Comment Density & X & X & \\
DLOC & Documentation Lines of Code & X & X & \\
TCD & Total Comment Density & X & X & \\
TCLOC & Total Comment Lines of Code & X & X & \\
NOS & Number of Statements & X & X & \\
TLOC & Total Lines of Code & X & X & \\
TLLOC & Total Logical Lines of Code & X & X & \\
TNOS & Total Number of Statements & X & X & \\
\hline
McCC & McCabe's Cyclomatic Complexity & X & & X\\
\hline
PDA & Public Documented API & & X & X\\
PUA & Public Undocumented API & & X & X\\
\hline
HCPL & Halstead Calculated Program Length & X & & \\
HDIF & Halstead Difficulty & X & & \\
HEFF & Halstead Effort & X & & \\
HNDB & Halstead Number of Delivered Bugs & X & & \\
HPL & Halstead Program Length & X & & \\
HPV & Halstead Program Vocabulary & X & & \\
HTRP & Halstead Time Required to Program & X & & \\
HVOL & Halstead Volume & X & & \\
MIMS & Maintainability Index (Microsoft version) & X & & \\
MI & Maintainability Index (Original version) & X & & \\
MISEI & Maintainability Index (SEI version) & X & & \\
MISM & Maintainability Index (SourceMeter version) & X & & \\
NUMPAR & Number of Parameters & X & & \\
\hline
LCOM5 & Lack of Cohesion in Methods 5 & & X & \\
WMC & Weighted Methods per Class & & X & \\
CBO & Coupling Between Object classes & & X & \\
CBOI & Coupling Between Object classes Inverse & & X & \\
RFC & Response set For Class & & X & \\
AD & API Documentation & & X & \\
DIT & Depth of Inheritance Tree & & X & \\
NOA & Number of Ancestors & & X & \\
NOC & Number of Children & & X & \\
NOD & Number of Descendants & & X & \\
NOP & Number of Parents & & X & \\
NA & Number of Attributes & & X & \\
NG & Number of Getters & & X & \\
NLA & Number of Local Attributes & & X & \\
NLG & Number of Local Getters & & X & \\
NLM & Number of Local Methods & & X & \\
NLPA & Number of Local Public Attributes & & X & \\
NLPM & Number of Local Public Methods & & X & \\
NLS & Number of Local Setters & & X & \\
NM & Number of Methods & & X & \\
NPA & Number of Public Attributes & & X & \\
NPM & Number of Public Methods & & X & \\
NS & Number of Setters & & X & \\
TNA & Total Number of Attributes & & X & \\
TNG & Total Number of Getters & & X & \\
TNLA & Total Number of Local Attributes & & X & \\
TNLG & Total Number of Local Getters & & X & \\
TNLM & Total Number of Local Methods & & X & \\
TNLPA & Total Number of Local Public Attributes & & X & \\
TNLPM & Total Number of Local Public Methods & & X & \\
TNLS & Total Number of Local Setters & & X & \\
TNM & Total Number of Methods & & X & \\
TNPA & Total Number of Public Attributes & & X & \\
TNPM & Total Number of Public Methods & & X & \\
TNS & Total Number of Setters & & X & \\
\hline
\end{tabular}
\label{tab:metrics}
\end{table}
One special metric category is provided by source code duplication detection~\cite{roy2009comparison}.
OpenStaticAnalyzer is able to detect Type-1 (exact copy of code, not considering white spaces and comments) and Type-2 clones (syntactically identical copy of code where variable, function or type identifiers can be different; also not considering white spaces and comments) in software systems~\cite{bellon2007comparison} and also supports clone management tasks, such as:
\begin{itemize}
\item Clone tracking: clones are tracked during the source code analysis of consecutive revisions of the analyzed software system.
\item Calculating clone metrics: a wide set of clone related metrics is calculated to describe the properties of a clone in the system (for example, risk of a clone or the effort needed to eliminate the clone from the system).
\end{itemize}
Basic clone related metrics that are calculated for methods and classes are presented in Table~\ref{tab:clone_metrics}.
\begin{table}[H]
\caption{Clone metrics used for characterization}
\scriptsize
\def1.1{1.1}
\centering
\setlength{\tabcolsep}{6pt}
\begin{tabular}{|l|l|}
\hline
\textbf{Abbreviation} & \textbf{Full name} \\ \hline
CC & Clone Coverage \\
CCL & Clone Classes \\
CCO & Clone Complexity \\
CI & Clone Instances \\
CLC & Clone Line Coverage \\
CLLC & Clone Lines of Code \\
LDC & Lines of Duplicated Code \\
LLDC & Logical Lines of Duplicated Code \\ \hline
\end{tabular}
\label{tab:clone_metrics}
\end{table}
OpenStaticAnalyzer also provides a coding rule violation detection module.
The presence of rule violations in a source code element can cause errors~\cite{boogerd2008assessing} in a later phase (can easily be a ticking bomb); thus the number of different rule violations located in the source code element can serve as good predictors and the dataset encapsulates this information too.
\section{Related Work} \label{related}
\subsection{Bug Localization and Source Code Management}
Many approaches have been presented dealing with bug characterization and localization~\cite{saha2013improving,wang2014version,davies2012using}.
Zhou et al. published a study describing BugLocator~\cite{bugcenter}, a tool that detects the relevant source code files that need to be changed in order to fix a bug.
BugLocator uses textual similarities (between initial bug report and the source code) to rank potentially fault-prone files.
Prior information about former bug reports is stored in a bug database.
Ranking is based on the assumption that descriptions with high similarities imply that the related files are highly similar too.
A similar ranking is done by Rebug-Detector~\cite{bugsfromsourcecode}, a tool made by Wang et al. for detecting related bugs from source code using bug information.
The tool focuses on overridden and overloaded method similarities.
In our study, we constructed a dataset that stores information about formerly buggy code elements that are now fixed, thus the same method could be applied by using source code metrics for detecting similar source code elements that are possibly fault-prone.
ReLink~\cite{wu2011relink} was developed to explore missing links between code changes committed in version control systems and the fixed bugs.
This tool could be helpful for software engineering research based on linkage data, such as software defect prediction.
ReLink mines and analyzes information like bug reporter, description, comments, and date from a bug tracking database and then tries to pair the bug with the appropriate source code files based on the set of source code information extracted from a version control system.
Most of the studies dealing with this kind of linkage data use the SZZ algorithm, which has been improved over the years \cite{kim2006automatic,williams2008szz}.
This approach uses file level textual features to extract extra information between bugs and the source code itself.
We characterized the set of bugs in a given system at file, class, and method levels by assigning different source code metrics to the source code elements (methods, classes, and files) affected by bugs.
Other approaches try to link information retrieved from only version control and bug tracking systems \cite{fischer2003populating,mockus2000identifying}.
Kalliamvakou et al. mined GitHub repositories to investigate their characteristics and their qualities~\cite{githubpromises}.
They presented a detailed study discussing different project characteristics, such as (in)activity, while also involving further research questions -- e.g., whether a project is standalone or part of a more massive system.
Results showed that the extracted data can serve as a good input for various investigations, however one must use them with caution and always verify the usefulness and reliability of the data.
It is a good practice to choose projects with many developers and commits, but it should always be kept in mind that the most important point is to choose projects that fit well for one's own purpose.
In our case, we have tried to create a dataset that is large, reliable (through some manual validation) and general enough for testing different bug prediction techniques \cite{catal2009systematic,porter1990empirically,ostrand2005predicting,ma2006statistical,zhou2006empirical}, while still being created in an automatic way.
Mining software repositories can be a harsh task when an automatic mechanism is used to construct a large set of data based on the information gathered from a distributed software repository.
As we used GitHub to address our research questions, we paid extra attention to prevent and avoid pitfalls.
Bird et al.~\cite{mininggit} presented a study on distributed version control systems -- focusing mainly on Git -- that examined their usage and the available set of data (such as whether the commits are removable, modifiable, movable).
The main purpose of the paper was to draw attention to pitfalls and help researchers to avoid them during the processing and analysis of a mined information set.
Many research papers showed that using a bug tracking system improves the quality of the software system under development.
Bangcharoensap et al. introduced a method to locate the buggy files in a software system very quickly using the bug reports managed by the bug tracking system~\cite{eclipsebugs}.
The presented method contains three different approaches to rank the fault-prone files, namely: (a) Text mining, which ranks files based on the textual similarity between a bug report and the source code itself, (b) Code mining, which ranks files based on prediction of the potential buggy module using source code product metrics, and (c) Change history, which ranks files based on prediction of the fault-prone module using change process metrics.
They used the gathered project data collected on the Eclipse platform to investigate the efficiency of the proposed approaches and showed that they are indeed suitable to locate buggy files.
Furthermore, bug reports with a short description and many specific words greatly increase the effectiveness of finding the ``weak points'' of the system.
Similarly to our study, Ostrand et al. investigated fault prediction by using source code metrics.
However, only file level was considered as the finest granularity unit~\cite{ostrand2007automating}, while we have built a toolchain to also support class and method levels.
In addition to the above presented methods, a significant change in source code metrics can also indicate that the relevant source code files contain potential bugs \cite{gyimothy2005empirical}.
Couto et al. presented a paper that shows the possible relationship between changed source code metrics (used as predictors) and bugs as well~\cite{metrichistorybug}.
They described an experiment to discover more robust evidences towards causality between software metrics and the occurrence of bugs.
Although our method does not include this specific information, we still aim to show that considering methods as basic elements and including them in a dataset is also a way for building a working corpus for bug prediction techniques.
\subsection{Public Datasets}
The previously mentioned approaches use self-made datasets for their own purposes, as illustrated in the work of Kalliamvakou et al. too~\cite{githubpromises}.
Bug prediction techniques and approaches can be presented and compared in different ways; however, there are some basic points that can serve as common components~\cite{li2018progress}.
One common element can be a dataset used for the evaluation of the various approaches.
\emph{PROMISE}
\cite{shirabad2005promise} is a repository of datasets out of which several ones contain bugs gathered from open-source and also from closed-source industrial software systems.
Amongst others it includes the NASA MDP dataset, which was used in many research studies and also criticized for containing erroneous data~\cite{shepperd2013data,petric2016jinx}.
The PROMISE repository also contains an extensively referenced dataset created by Jureczko~\cite{jureczko2010towards}, which provides object-oriented metrics as well as bug information for the source code elements (classes).
This latter one includes open-source projects such as Apache Ant, Apache Camel, JEdit, Apache Lucene, forming a dataset containing 48 releases of 15 projects.
The main purpose of these datasets is to support prediction methods and summarize bugs and their characterizations extracted from various projects.
Many research papers used datasets from the PROMISE repository as an input for their investigations.
A similar dataset for bug prediction came to be commonly known as the \emph{Bug prediction dataset\footnote{\url{http://bug.inf.usi.ch/}}}~\cite{bugprediction}.
The reason for creating this dataset was mainly inspired by the idea of measuring the performance of the different prediction models and also comparing them to each other.
This dataset handles the bugs and the relevant source code parts at class level, i.e., the bugs are assigned to classes.
As we have already mentioned, we do not only focus on file and class levels, but on method-level elements as well.
Zimmermann et al.~\cite{zimmermann2007predicting} used Eclipse as the input for a study dealing with defect prediction.
They investigated whether the complexity metrics have the power to detect fault prone points in the system at package and file level.
During the study, they constructed a public dataset\footnote{\url{https://www.st.cs.uni-saarland.de/softevo/bug-data/eclipse/}} that is still available.
It contains different source code metrics and a subset of the files/packages is marked as ``buggy'' if it contained any bugs in the interval between two releases.
A recent study showed that code smells also play a significant role in bug prediction \cite{hall2014some} but the constructed dataset is not public.
In our dataset, we also include code smell metrics to enhance its usefulness.
\emph{iBUGS}~\cite{dallmeier2007extraction} provides a complex environment for testing different automatic defect localization methods.
Information describing the bugs comes from both version control systems and from bug tracking systems.
iBUGS used the following three open-source projects to extract the bugs from (the numbers of extracted bugs are in parentheses):
AspectJ -- an extension for the Java programming language to support aspect oriented programming (223);
Rhino -- a JavaSript interpreter written in Java (32); and
Joda-Time -- a quality replacement (extension) for the Java date and time classes (8).
The authors attempted to generate the iBUGS dataset in an automatic way and they compared the generated set to the manually validated set of bugs~\cite{ibugs}.
iBUGS is a framework aimed more towards bug localization and not a standalone dataset containing source code elements and their characterizations (i.e., metrics).
The \emph{Bugcatchers}~\cite{hall2014some} dataset is created by Hall et al. which is not only a bug dataset, but also contains bad smells detected in the subject systems.
The selected three systems are Eclipse JDT Core, ArgoUML, and Apache Commons.
The dataset is built and evaluated at file level.
The \emph{ELFF} dataset~\cite{Shippey2016Esem} is a recent dataset proposed by Shippey et al.
They experienced that only a few method level datasets exist, thus they created a dataset whose entries are methods.
Additionally, they also made class level datasets publicly available.
They used Boa~\cite{dyer2013boa} to mine SourceForge repositories and collect as many candidates as they can, selecting 23 projects out of 50,000 that fulfilled their criteria (number of closed bugs, bugs are referenced from commits, etc.).
They only kept projects with SVN version control systems which narrows down their candidate set.
They used the classic and well-defined SZZ algorithm~\cite{sliwerski2005changes} to find linkage between bugs and the corresponding source code elements.
The \emph{Had-oops!} dataset~\cite{Harman:2014ssbse} is constructed by a new approach presented by Harman et al.
They analyzed 8 consecutive Hadoop versions and investigated the impact of chronology on fault prediction performance.
They used Support Vector Machines (SVMs) with the Genetic Algorithm (for configuration) to build prediction models at class level.
For a given version, they constructed a prediction model from all the previous versions and a model from only the current version and compared which one performed better.
Results are not straightforward since they found early versions preferable in many cases as opposed to models built on recent versions.
Moreover, using all versions is not always better than using only the current version to build a model from.
The \emph{Mutation-aware fault prediction dataset} is a result of an experiment carried out by Bowes et al. on using mutation metrics as independent variables for fault prediction~\cite{Bowes:2016ISSTA}.
They used 3 software systems from which 2 projects (Eclipse and Apache) were open-source and one was closed.
They used the popular PITest (or simply, PIT~\cite{pitest}) to obtain the set of mutation metrics that were included in the final dataset.
Besides the mutation metrics, some static source code metrics (calculated by JHawk~\cite{jhawk}) were also included in the dataset for comparison purposes.
This dataset is also built at class level.
The \emph{GitHub Bug Dataset} is a recent dataset that includes class and file level static source code metrics~\cite{toth2016public} for 15 Java systems gathered from GitHub.
Besides size, documentation, object-oriented, and complexity metrics, the dataset also contains code duplication and coding rule violation metrics.
This dataset is our previous work that was still constructed in the ``traditional'' way.
In Table~\ref{tab:datasetcharacteristics}, we compare the main characteristics of the mentioned datasets.
Our goal was to pick the strong aspects of all the previous datasets and put them together, as its positive effects are described by Li et al.~\cite{li2019multiple}.
Although the discussed works successfully made use of their datasets, an extended dataset can serve as a good basis for further investigations.
Our dataset includes various projects from GitHub and includes numerous static source code metrics and stores a large number of entries in fine granularity (file, class, and method level as well).
Furthermore, we also experimented with chronology, although in a different way compared to Harman et al~\cite{Harman:2014ssbse}.
The differences between the traditional datasets and the proposed novel dataset are summarized in Table~\ref{tab:datasetcomparison}.
See Section~\ref{sec:processingrawdata} for details about the process of selecting the bug related data for the novel dataset.
The detailed comparison can be found in Section~\ref{sec:rq3}.
\begin{table}[H]
\caption{Comparison of the two types of datasets}
\fontsize{7pt}{8pt}\selectfont
\centering
\setlength{\tabcolsep}{3pt}
\begin{tabular}{|l|C{3.8cm}|C{3.8cm}|}
\hline
\textbf{Feature} & \textbf{Traditional} & \textbf{Novel} \\
\hline
\textit{Included time interval} & Usually 6 months & Entire project history \\
\hline
\textit{Included source code elements} & All the elements from a single version & Only the modified elements right before and after bug-fixes \\
\hline
\textit{Assumptions} & Source code elements that are not included in any bug-fix are non-faulty & No assumptions needed \\
\hline
\textit{Uncertainty} & The source code elements are faulty in the latest release version before the bug-fix and non-faulty after the fix & The source code elements are faulty right before the bug-fix and fixed afterwards \\
\hline
\end{tabular}
\label{tab:datasetcomparison}
\end{table}
\begin{table}[H]
\caption{Comparison of the datasets}
\fontsize{7pt}{8pt}\selectfont
\centering
\setlength{\tabcolsep}{3pt}
\begin{tabular}{|X{3,5cm}|l|X{3,8cm}|l|l|}
\hline
\textbf{Project} & \textbf{Level of bugs} & \textbf{Bug characteristics} & \textbf{\# of projects} \\ \hline
\emph{NASA MDP Dataset} & class & static source code metrics & 11 \\ \hline
\emph{Jureczko Dataset} & class & static source code metrics & 15 \\ \hline
\emph{Bug prediction dataset} & class & static source code metrics, process metrics & 5 \\ \hline
\emph{Eclipse dataset} & file, package & complexity metrics & 1 \\ \hline
\emph{iBUGS} & N/A & bug-fix size properties, AST fingerprints & 3 \\ \hline
\emph{Bugcatchers} & file & code smells & 3 \\ \hline
\emph{ELFF} & class, method & static source code metrics & 23 \\ \hline
\emph{Had-oops!} & class & static source code metrics & 1 \\ \hline
\emph{Mutation-aware fault prediction dataset} & class & static source code metrics, mutation metrics & 3 \\ \hline
\emph{GitHub Bug Dataset} & file, class & static source code metrics, code duplication metrics, code smell metrics & 15 \\ \hline
\emph{Novel dataset} & file, class, method & static source code metrics, code duplication metrics, code smell metrics & 15 \\ \hline
\end{tabular}
\label{tab:datasetcharacteristics}
\end{table}
\section{Threats to Validity}\label{threats}
In this section, we briefly describe the threats to validity.
Firstly, we present the construct validity, then the internal and external validity threats.
\subsection{Threats to Construct Validity}
When constructing a dataset in an automatic way, there are always some possible threats to validity.
We validated our matching algorithm on JUnit, which was fair in size.
However, investigating the validity of the matching in other systems could have revealed additional findings.
As we have seen, commit mismatches can occur during this process, which can distort the final bug dataset.
However, manually validating all bugs and the corresponding commits would have been an enormous task.
Deciding which source code elements are faulty and which are not can also cause a construct validity threat.
We consider a source code element faulty before the corresponding bug is fixed (the source code element had to be modified in that fix) and after the corresponding bug report is present.
The source code element can already be faulty before the report and can have multiple changes in that period; and it can be faulty also after the last fix, but we do not know the issue at that time, which can also distort the measurements.
Unfortunately, these uncertainties cannot be solved, since there are no further data to rely on.
\subsection{Threats to Internal Validity}
It would be meaningful to use multiple static source code analyzers in order to decrease the threats to internal validity caused by measuring source code element characteristics with only one tool.
However, it would mean much more work, and even then, additional manual validations would be needed to decide which tool measures a given metric more precisely, which often depends on interpreting the conceptual definitions.
\subsection{Threats to External Validity}
Currently, the constructed dataset consists of 15 projects which may limit the capabilities of the bug prediction models.
Selecting more projects to be included in the dataset would increase the generalizability of the built bug prediction models.
Considering additional source hosting platforms (SourceForge, Bitbucket, GitLab) would also increase the external validity of the dataset.
Widely used and accepted programming constructs and structures can vary from programming language to programming language.
Using different constructs may have a significant result on the calculated metric values.
Selecting projects written in different programming languages, not only Java software systems, could further strengthen the generalizability of our method.
| {'timestamp': '2020-06-19T02:04:03', 'yymm': '2006', 'arxiv_id': '2006.10158', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10158'} | arxiv |
\section{Related Work and Conclusion}
NCF \cite{NCF} is a pioneer work of employing DNNs into recommender systems which fuses a GMF and an MLP together to learn the user/item representation. Inspired by attention's success in computer vision, image and NLP, many researchers have also employed all kinds of attention mechanisms in recommendation models to capture diverse user preferences more precisely. For example, AFM \cite{AFM} adds an attention-based pooling layer after the pairwise feature interaction layer, to achieve content-aware recommendation. As our model, DIN \cite{DIN} also imports user/item features and introduces a local activation unit to learn user representations adaptively w.r.t. different candidate items. Similarly, NAIS \cite{NAIS} assigns different attentions to each historical item of a user to generate adaptive user representations which bring better recommendation results. FDSA \cite{FSA} applies self-attention mechanism to refine user representations which are generated based on item features.
We propose a novel recommendation model ACAM in this paper, which first represents users and items with fine-grained attribute embeddings, and then augments user representations and item representations simultaneously by an attribute-level co-attention module. Such augmented representations are proven beneficial to performance gains through our extensive experiments.
\bibliographystyle{ACM-Reference-Format}
\section{Introduction}
Encouraged by the success of deep neural networks (DNNs) in computer vision, image and natural language processing (NLP) ect., many researchers also imported DNNs to improve recommender systems. In these deep recommendation models, \emph{attention} mechanism has also been employed broadly for recommendation performance gains \cite{NAIS,DIN,SARec,DKR}. Although these attention-based models have been proven effective, the following problems restrict the further enhancement of recommendation performance. First, some of them \cite{NAIS,SARec} only employ coarse attention on item-level, i.e., each item is directly represented by a single embedding based on which user presentations are generated. Such coarse-grained embeddings can not represent users and items thoroughly. Second, although some models \cite{DIN,DKR} incorporate item features (attributes), also known as item \emph{knowledge}, to improve the expressive ability of user/item representations, they only apply attention mechanism on user side.
Given these problems, we propose a novel deep recommendation model with attribute-level co-attention, namely \emph{ACAM} (Attribute-level Co-Attention Model). ACAM demonstrates superior performance due to the following merits. First, its item representations and user representations are generated based on a set of \emph{attribute embeddings} rather than a single embedding, where the attributes are distilled from open knowledge graphs (KGs) as side information. Second, the co-attention module in ACAM captures the correlations between different attribute embeddings to augment user/item representations. As we know, there may exist correlations between different item attributes, indicating the latent relationships between items. For example, in movie attributes, actor \emph{Stallone} is more correlated to genre \emph{action film}, and actor \emph{GONG Li} is more correlated to director \emph{ZHANG Yimou}. Therefore, the latent relationships between the target users and the candidate items are uncovered precisely by the user/item representations augmented based on attribute correlations, resulting in enhanced recommendation performance. Furthermore, we add an objective of knowledge graph embedding (KGE) into the loss function to lean better attribute embeddings.
In summary, we have the following contributions in this paper:
1. We propose an attribute-level co-attention mechanism in a deep recommendation model, to capture the correlations between different user/item attributes sophisticatedly, and then augment user/item representations simultaneously which are helpful for recommendation performance enhancement.
2. Our extensive experiments demonstrate our model's superiority over some state-of-the-art deep models including previous attention-based recommendation models, which apparently justify the effectiveness of incorporating attribute embeddings and employing attribute-level co-attention to co-augment user representations and item representations.
\section{Model Description}
The task addressed by ACAM is top-n recommendation of implicit feedback \cite{NCF,NAIS}. To generate the top-n recommendation list, the target $u$ should be coupled with each candidate item $v$ and input into the model to compute $\hat{y}_{uv}$, which quantifies the probability that $u$ likes $v$, i.e., $u$ has a positive feedback to $v$.
\begin{figure}[!htb]
\center
\includegraphics[width=3in]{framework.pdf}
\vspace{-0.4cm}
\caption{The proposed model's framework.}\label{fig:frame}
\vspace{-0.3cm}
\end{figure}
As shown in Fig. \ref{fig:frame}, ACAM can be divided into three layers, i.e., embedding layer, co-attention layer and prediction layer. In the embedding layer, both $u$ and $v$ are represented by a representation matrix on attribute-level, rather than a single vector (embedding) as previous models \cite{NCF,NAIS,SARec}. Then, $u$'s representation and $v$'s representation are co-augmented based on the correlations (attentions) between different attributes captured by an attribute-level co-attention module. In the last prediction layer, a multi-layer perceptron (MLP) is built and fed with $u$'s representation and $v$'s representation to compute $\hat{y}_{uv}$.
\vspace{-0.1cm}
\subsection{Embedding Layer}
\subsubsection{Generating Item Representation}
In general, most items and their attributes (e.g., the actor and director of movies) in an open domain can be fetched from large-scale KGs, which constitute knowledge triplets formed as $<h,r,t>$. The head entity ($h$) is just an item, the relation ($r$) corresponds to an attribute and the tail entity ($t$) is an attribute value. For example, a triplet $<Rocky, starred, Stallone>$ describes that \emph{Stallone} is an actor of movie \emph{Rocky}. The shared attribute values well indicate the latent relationships between different items \cite{DIN,DKR}.
Therefore, $M$ significant attributes (values) $\{a_1,a_2,...,a_M\}$ are first selected to represent an item in ACAM. The $a_i$'s embedding is denoted as $\boldsymbol{a}_i\in\mathbb{R}^{d}$ ($1\leq i\leq M$). We further use an item embedding (head entity embedding), denoted as $\boldsymbol{a}_0$, to supplement the representation of an item. For the convenience of the following introduction, $\boldsymbol{a}_0$ is also regarded as an attribute embedding. Thus, an item's representation is enriched into a matrix of $(M+1)\times d$, as shown in Fig. \ref{fig:frame}.
Please note that an attribute may have multiple values corresponding to different tail entities in KGs. For example, a movie generally involves many actors and each actor corresponds to an entity in KGs and has a unique embedding. Thus, for an attribute with multiple values, we average all of its value embeddings (tail entity embeddings) as its attribute embedding.
\vspace{-0.1cm}
\subsubsection{Generating User Representation}
A user in ACAM is represented by the recent $L$ items that he/she has interacted with, denoted as $\mathcal{L}=\{v_1, v_2, …, v_L\}$. As the candidate item's representation, each interacted item $v_j (1\leq j\leq L)$ in $\mathcal{L}$ is also represented by the union of its $M+1$ attribute embeddings. Therefore, the target user $u$'s representation is enriched to be a cube (tensor) of $(M+1)\times L\times d$, denoted as $\boldsymbol{\tilde{E}}_u$. For those users with less than $L$ historical interactions, we fill paddings in their representations.
Next, we need to extract the features of $\boldsymbol{\tilde{E}}_u$ and compress it into a matrix. It is not only to reduce trainable parameters but also to feed the co-attention layer (module) conveniently. To this end, we aggregate the $i$-th attribute embeddings of $u$'s historical items as $u$'s $i$-th attribute embedding through an attention network. Specifically, we adopt a weighted sum pooling as
\vspace{-0.1cm}
\begin{equation}\label{eq:att}
\vspace{-0.1cm}
\boldsymbol{a}^u_i=\sum\limits_{j=1}^L FFN(\boldsymbol{a}^j_i\oplus\boldsymbol{a}^v_i)\boldsymbol{a}^j_i
\end{equation}
where $\boldsymbol{a}^u_i$ is regarded as $u$'s $i$-th ($0\leq i\leq M$) attribute embedding, and $FFN(\boldsymbol{a}^j_i\oplus\boldsymbol{a}^v_i)$ is the computation of a feed-forward network fed with the concatenation of item's attribute embedding $\boldsymbol{a}^j_i$ and $\boldsymbol{a}^v_i$. Thus, $u$'s representation consists of $M+1$ attribute embeddings computed by Eq. \ref{eq:att}. Such user representations vary given different candidate recommended items, which have been proven more helpful for recommendation performance gains than fixed user representations \cite{DKR,NAIS}.
\vspace{-0.1cm}
\subsection{Co-attention Layer}
In this layer, both $u$'s and $v$'s attribute-based representations are simultaneously augmented by a co-attention module of symmetrical neural architecture, as shown in Fig. \ref{fig:frame}.
Specifically, each of $u$'s attribute embeddings, i.e., $\boldsymbol{a}_i^u$, is adjusted as the weighted sum of all $u$'s attribute embeddings (denoted as $\boldsymbol{a}_j^u$) where the weight (attention) of $\boldsymbol{a}_j^u$ is computed based on the correlation between $\boldsymbol{a}_j^u$ and $\boldsymbol{a}_i^v$. To adjust $v$'s attribute embedding $\boldsymbol{a}_i^v$, we just use the symmetric operation. Such adjustment makes the embeddings of two correlated attributes more closer to each other. As a result, the user/item representations generated based on such adjusted attribute embeddings induce more precise recommendations. For example, it makes a movie starring \emph{Stallone} easier to be recommended to a user who have watched many action films.
Formally, we first denote $u$'s representations and $v$'s representations respectively as
\vspace{-0.1cm}
$$
\vspace{-0.1cm}
\boldsymbol{E}_a^u=[\boldsymbol{a}_0^u,\boldsymbol{a}_1^u,...,\boldsymbol{a}_M^u],\quad
\boldsymbol{E}_a^v=[\boldsymbol{a}_0^v,\boldsymbol{a}_1^v,...,\boldsymbol{a}_M^v]
$$
Then, we take nonlinear transformation to obtain the key matrices $\boldsymbol{K}^u, \boldsymbol{K}^v\in \mathbb{R}^{(M+1)\times d_K}$ and value matrices $\boldsymbol{V}^u,\boldsymbol{V}^v\in\mathbb{R}^{(M+1)\times d_V}$ based on $\boldsymbol{E}_a^u$ and $\boldsymbol{E}_a^v$ as
\vspace{-0.1cm}
\begin{equation}
\vspace{-0.1cm}
\begin{split}
&\boldsymbol{K}^u=\text{tanh}(\boldsymbol{E}_a^{u\top} \boldsymbol{W}^u_K+\boldsymbol{b}^u_K), \boldsymbol{V}^u=\text{tanh}(\boldsymbol{E}_a^{u\top}\boldsymbol{W}^u_V+\boldsymbol{b}^u_V)\\
&\boldsymbol{K}^v=\text{tanh}(\boldsymbol{E}_a^{v\top} \boldsymbol{W}^v_K+\boldsymbol{b}^v_K), \boldsymbol{V}^v=\text{tanh}(\boldsymbol{E}_a^{v\top}\boldsymbol{W}^v_V+\boldsymbol{b}^v_V)
\end{split}
\end{equation}
where $\boldsymbol{W}^u_K, \boldsymbol{W}^v_K\in \mathbb{R}^{d \times d_K}, \boldsymbol{W}^u_V, \boldsymbol{W}^v_V\in \mathbb{R}^{d \times d_V}$ are transformation weight matrices, and $\boldsymbol{b}^u_K, \boldsymbol{b}^v_K \in \mathbb{R}^{d_K}, \boldsymbol{b}^u_V, \boldsymbol{b}^v_V \in \mathbb{R}^{d_V}$ are transformation bias vectors. Next, we obtain a co-attention map
$
\boldsymbol{S} = \boldsymbol{K}^u \boldsymbol{K}^{v\top}
$, which is a square matrix of $(M+1)\times (M+1)$ and each entry $\boldsymbol{S}_{ij}$ quantifies the affinity between $u$'s $i$-th attribute and $v$'s $j$-th attribute, i.e., the correlation between $\boldsymbol{a}_i^u$ and $\boldsymbol{a}_j^v$. Accordingly, $\boldsymbol{S}$ stores attribute-level attentions.
Based on $\boldsymbol{V}^u,\boldsymbol{V}^v$ along with $\boldsymbol{S}$, all $u$'s and $v$'s representations are revised as
\vspace{-0.1cm}
\begin{equation}\label{eq:U1}
\vspace{-0.1cm}
\boldsymbol{U} = \text{softmax}_{col}(\boldsymbol{S})^{\top} \boldsymbol{V}^u, \boldsymbol{V} = \text{softmax}_{row}(\boldsymbol{S}) \boldsymbol{V}^v
\end{equation}
where $\boldsymbol{U}, \boldsymbol{V}\in\mathbb{R}^{(M+1)\times d_V}$, and each row of them represents an adjusted attribute embedding. And $\text{softmax}_{col}(\cdot)$ and $\text{softmax}_{row}(\cdot)$ represent the softmax computation in terms of column and row, respectively.
In order to reduce the number of trainable parameters in ACAM, we set $\boldsymbol{K}^u=\boldsymbol{V}^u, \boldsymbol{K}^v=\boldsymbol{V}^v,d=d_K=d_V$ in our experiments. It has been proven that such reduction does not affect the final recommendation performance.
The last operation in this layer is to use sum pooling\footnote{It was proven that sum pooling is a bit better than max/min/avg pooling through our experiments.} in terms of column to compress matrices $\boldsymbol{U},\boldsymbol{V}$ into the final representations of $u$ and $v$ as
\vspace{-0.1cm}
\begin{equation}\label{eq:U2}
\vspace{-0.1cm}
\boldsymbol{r}_u = \text{sum}_{col} (\boldsymbol{U}), \quad
\boldsymbol{r}_v = \text{sum}_{col} (\boldsymbol{V})
\end{equation}
In ACAM's prediction layer, the final score $\hat{y}_{uv}$ is computed through an MLP of three layers fed with the concatenation of $\boldsymbol{r}_u$, $\boldsymbol{r}_v$, $(\text{avg}_{row}(\boldsymbol{E}_a^u))^\top$ and $(\text{avg}_{row}(\boldsymbol{E}_a^v))^\top$, where $\text{avg}_{row}(\cdot)$ is the average operation in terms of row.
\vspace{-0.1cm}
\subsection{Model Training}
As we introduced before, the item embedding $\boldsymbol{a}_0$ and attribute embedding $\boldsymbol{a}_i(1\leq i \leq M)$ are the basis of computing $\hat{y}_{uv}$. Besides the cross-entropy loss as in \cite{NCF,NAIS}, we further use a KGE objective to learn $\boldsymbol{a}_0$ and $\boldsymbol{a}_i$ better, since an item and an attribute value correspond to a head entity and a tail entity in a KG, respectively. Specifically, we adopt the objective of transH \cite{transH} model since it learns many-to-many relations effectively. Therefore, we minimize the following objective function to learn ACAM's parameters:
\vspace{-0.1cm}
\begin{equation}\label{eq:loss}
\small
\vspace{-0.1cm}
\begin{split}
&\mathcal{O}=-\sum\limits_{(u,v)\in\mathcal{Y}}\big[y_{uv}\log\hat{y}_{uv}
+(1-y_{uv})\log(1-\hat{y}_{uv})\big]+\\
& \lambda_1\sum_{<h,r,t >\in \mathcal{K}} \Vert (\boldsymbol{h}-\boldsymbol{w}_r^\top\boldsymbol{hw}_r)+\boldsymbol{d}_r-(\boldsymbol{t}-\boldsymbol{w}_r^\top\boldsymbol{tw}_r)\Vert _2^2 +
\lambda_2 \Vert\Theta\Vert^{2}
\end{split}
\vspace{-0.1cm}
\end{equation}
where $\mathcal{Y}$ is the union of observed user-item interactions and the negative feedbacks, and $\mathcal{K}$ is the observed triplet set in the KG. The head entity's embedding $\boldsymbol{h}$ and the tail entity's embedding $\boldsymbol{t}$ in the second term are used as $\boldsymbol{a}_0$ and $\boldsymbol{a}_i$, respectively. And $\boldsymbol{w}_r$ and $\boldsymbol{d}_r$ are the hyperplane and translation vector in transH, respectively.
\section{Model Evaluation}
\vspace{-0.1cm}
\subsection{Experiment Settings}
\subsubsection{Dataset Description}
We conducted our experiments against two realistic datasets, i.e, Douban movies and NetEase songs\footnote{Douban: https://movie.douban.com, NetEase: https://music.163.com}. The statistics of these two datasets are listed in Table \ref{tab:stat}.
We fetched Douban movies' attribute values from a large-scale Chinese KG CN-DBpedia \cite{CNDB}. In our experiments, we selected four significant attributes ($M=4$) for the two datasets, i.e., actor, director, writer and genre for Douban movies, and singer, album, composer and lyricist for NetEase songs. To reproduce our experiment results conveniently, we have published our datasets and ACAM's source code on \url{https://github.com/DeqingYang/ACAM-model}.
\begin{table}[!htb]
\vspace{-0.2cm}
\centering
\caption{Statistics of the two experiment datasets.} \label{tab:stat}
\vspace{-0.4cm}
\begin{tabular}{|c c c c |}
\hline
dataset & user number & item number & interaction number
\\
\hline
Douban & 4,965 & 41,785 & 958,425
\\
NetEase & 115,995 & 19,981 & 2,399,638
\\
\hline
\end{tabular}
\vspace{-0.2cm}
\end{table}
For each user, we truncated his/her recent 10 interactions as the positive samples in test set, and the rest interactions as the positive samples in training set. We also used \emph{negative sampling} \cite{NCF} to collect negative samples for each user. Note that we inclined to those popular items (with high rating scores or more reviews) when selecting negative samples in random, to avoid such cases that a user did not rate/review an item just due to the unawareness of the item. In both model training and prediction, each positive sample was paired with 4 negative samples, which is the general setting in previous models \cite{NCF,NAIS}.
\subsubsection{Compared Models}
\textbf{NCF} \cite{NCF}: This is a DNN-based recommendation model consisting of a GMF
(generalized matrix factorization) layer and an MLP, where each user and item is represented only by a single embedding.
\textbf{NAIS} \cite{NAIS}: This is an attention-based recommendation model in which only user representations are refined by attention mechanism, and each item is represented by a single embedding.
\textbf{AFM} \cite{AFM}: It is a neural version of FM which adds an attention-based pooling layer after the pairwise feature interaction layer.
\textbf{FDSA} \cite{FSA}: This sequential recommendation model also incorporates feature-level representations but uses self-attention mechanism to only refine user representations rather than item representations.
\textbf{RippleNet} \cite{ripple}: It is a representative KG-based recommendation model, which was compared with ACAM to highlight ACAM's strengths in knowledge (attribute) exploitation.
\textbf{DIN} \cite{DIN}: It also imports various features to enrich user/item representations. Furthermore, it uses the attention mechanism similar to NAIS to adjust user representations only.
In the following display of experiment results, we adopt three popular metrics evaluating top-n recommendation or ranking, i.e., HR@n (Hit Ratio), nDCG@n (Normailzed Discounted Cumulative Gain) and RR (Reciprocal Rank). To avoid statistics bias, all model's performance are reported as the average scores of 3 runnings. All baselines' hyper-parameters were set to the optimal values in their origin papers.
\begin{table*}[!htb]
\vspace{-0.2cm}
\small
\begin{center}
\caption{All models' top3/5/10 performance for the two recommendation tasks.}\label{tab:res}
\vspace{-0.4cm}
\begin{tabular}
{|p{5pt}|p{26pt}|p{20pt}|p{24pt}|p{20pt}|p{25pt}|p{22pt}|p{26pt}|p{22pt}|p{20pt}|p{24pt}|p{20pt}|p{25pt}|p{22pt}|p{26pt}|p{22pt}|}
\hline
\multirow{2}{*}{$L$}&\multirow{2}{*}{\textbf{Model}}& \multicolumn{7}{c|}{Douban movie} &\multicolumn{7}{c|}{NetEase song}\\
\cline{3-16}
& & HR@3 & \footnotesize{nDCG@3} &HR@5 & \footnotesize{nDCG@5} & HR@10& \footnotesize{nDCG@10} &RR & HR@3 & \footnotesize{nDCG@3} &HR@5 & \footnotesize{nDCG@5} & HR@10& \footnotesize{nDCG@10} & RR\\
\hline\hline
\multirow{8}{*}{3}&NCF & 0.8417 & 0.8483 & 0.7998 & 0.8113 & 0.7074 & 0.7492 & 0.9279 & 0.7903 & 0.7984 & 0.7689 &0.7723 & 0.6893 & 0.7193 & 0.8952\\
\cline{2-16}
&NAIS & 0.8443 & 0.8531 & 0.8112 & 0.8253 & 0.6768 & 0.7291 & 0.9336 & 0.7998 & 0.8027 & 0.7772 & 0.7824 & 0.6747 & 0.7140 & 0.8963\\
\cline{2-16}
&AFM & 0.8399 & 0.8455 & 0.8080 & 0.8220 & 0.7091 & 0.7499 & 0.9228 & 0.8304 & 0.8358 & 0.8112 & 0.8104 & \textbf{0.7405} & 0.7708 & 0.9194\\
\cline{2-16}
&FDSA & 0.8625 & 0.8690 & 0.8257 & 0.8437 & \textbf{0.7208} & {0.7598} & 0.9394 & 0.8101 & 0.8119 & 0.7949 & 0.8011 & 0.7339 & 0.7574 & 0.8994\\
\cline{2-16}
&\footnotesize{RippleNet} & 0.7966 & 0.8012 & 0.7694 & 0.7743 & 0.6588 & 0.7009 & 0.8957 & 0.8025 & 0.8042 & 0.7848 & 0.7901 & 0.7185 & 0.7437 & 0.8951\\
\cline{2-16}
&DIN & 0.8322 & 0.8407 & 0.7982 & 0.8023 & 0.6453 & 0.7028 & 0.9234 & 0.7892 & 0.7936 & 0.7658 & 0.7704 & 0.6723 & 0.6950 & 0.8949\\
\cline{2-16}
&ACAM & \textbf{0.8680} & \textbf{0.8737} & \textbf{0.8324} & \textbf{0.8477} & 0.7137 & \textbf{0.7613} & \textbf{0.9495} & \textbf{0.8541} & \textbf{0.8576} & \textbf{0.8267} & \textbf{0.8377} & {0.7379} & \textbf{0.7733} & \textbf{0.9301}\\
\hline\hline
\multirow{8}{*}{10}&NCF & 0.8335 & 0.8105 & 0.8011 & 0.8165 & 0.7003 & 0.7449 & 0.8491 & 0.7929 & 0.7875 & 0.7654 &0.7785 & 0.6980 & 0.7177 & 0.8694 \\
\cline{2-16}
&NAIS & 0.8595 & 0.8694 & 0.8313 & 0.8440 & 0.6875 & 0.7417 & 0.9449 & 0.8026 & 0.8051 & 0.7823 & 0.7844 & 0.6774 & 0.7165 & 0.8971 \\
\cline{2-16}
&AFM & 0.8246 & 0.8306 & 0.8041 & 0.8105 & 0.7015 & 0.7404 & 0.9163 & 0.8289 & 0.8343 & 0.8073 & 0.8090 & 0.7410 & 0.7692 & 0.9186 \\
\cline{2-16}
&FDSA & 0.8588 & 0.8644 & 0.8292 & 0.8425 & \textbf{0.7203} & {0.7629} & 0.9353 & 0.8325 & 0.8278 & 0.8184 & 0.8257 & \textbf{0.7516} & {0.7725} & 0.9178 \\
\cline{2-16}
&\footnotesize{RippleNet} & 0.8173 & 0.8224 & 0.7964 & 0.8002 & 0.6726 & 0.7172 & 0.9104 & 0.7894 & 0.7921 & 0.7670 & 0.7704 & 0.7116 & 0.7359 & 0.8904 \\
\cline{2-16}
&DIN & 0.8325 & 0.8335 & 0.8002 & 0.8047 & 0.6579 & 0.7098 & 0.9105 & 0.7865 & 0.7906 & 0.7723 & 0.7796 & 0.6812 & 0.7065 & 0.8994 \\
\cline{2-16}
&ACAM & \textbf{0.8682} & \textbf{0.8739} & \textbf{0.8325} & \textbf{0.8478} & {0.7139} &\textbf{0.7634} & \textbf{0.9504} & \textbf{0.8615} & \textbf{0.8642} & \textbf{0.8305} & \textbf{0.8423} & 0.7498 & \textbf{0.7802} & \textbf{0.9317}\\
\hline
\end{tabular}
\end{center}
\vspace{-0.2cm}
\end{table*}
\vspace{-0.1cm}
\subsection{Evaluation Results}
\subsubsection{Hyper-parameter Sensitivity}
At first, we list the settings of some important hyper-parameters in our experiments in Table \ref{tab:para}. The results of hyper-parameter tuning are not displayed due to space limitation.
ACAM and other models incorporating attributes enhance their performance a little when more significant attributes are fed, but ACAM still keeps its superiority. In Table \ref{tab:res}, we only display the results of $L=3$ and $L=10$ towards the two recommendation tasks. We did not focus on the scenario of $L=1$ because a user's preference can not be inferred precisely by only one historical interacted item. Given that many users' preferences may vary as time elapses, using too many historical items to represent a user would induce noises, so we neglected the cases of $L>10$. We also find that almost all models only improve their performance a bit when $L$ increases from 3 to 10. It implies that using 3 recent historical items to represent a user is adequate for many models to generate precise results. In addition, ACAM achieves the best performance when $\lambda_1$ is small, implying that too large weight of KGE objective will bias the synthetic objective of Eq. \ref{eq:loss}.
\begin{table}[!htb]
\vspace{-0.2cm}
\centering
\caption{Hyper-parameter settings.} \label{tab:para}
\vspace{-0.4cm}
\begin{tabular}{|c c c c c c|}
\hline
dataset & $d/d_K/d_V$ & $M$ & $L$ & $\lambda_1$ & $\lambda_2$ \\
\hline
Douban & 512 & 4 & 3,10 & 0.1 & 0.001 \\
NetEase & 512 & 4 & 3,10 & 0.05 & 0.001 \\
\hline
\end{tabular}
\vspace{-0.2cm}
\end{table}
\vspace{-0.1cm}
\subsubsection{Recommendation Performance Comparison}
Table \ref{tab:res} displays all compared models' top3/5/10 recommendation performance on the two datasets. We find that ACAM outperforms NCF from the table, which justifies the effectiveness of incorporating attribute embeddings. ACAM's superiority over NAIS shows that the fine-grained user/item representations based on attribute embeddings can improve the effectiveness of attention-based models. It also justifies the rationale of augmenting item representations and user representations simultaneously by co-attention mechanism. Although AFM also captures the interactions (correlations) between different features (attributes) through attention mechanism, it does not perform well as ACAM. It shows that ACAM's co-attention mechanism captures the correlations between different attributes better than AFM's attention in terms of recommendation performance. Although FDSA and DIN also incorporate feature embeddings to enrich user/item representations, they do not perform well as ACAM, implying that co-refining user representations and item representations by co-attention mechanism is more effective than only refining user representations by attention mechanism (DIN) or self-attention mechanism (FDSA). Although RippleNet is a state-of-the-art KG-based recommendation model, it is also inferior than ACAM, showing that ACAM's co-attention mechanism exploits item knowledge (attributes) more effectively.
| {'timestamp': '2020-06-19T02:07:21', 'yymm': '2006', 'arxiv_id': '2006.10233', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10233'} | arxiv |
\section{Introduction}
For almost 100 years following the introductory article of Kermack, McKendrick (1927), the SIR (Susceptible-Infected-Recovered) model has remained the primary tool of analysis for epidemiological studies and has inspired a considerable number of extensions [see e.g. Hethcote (2000), Brauer,Castillo-Chavez (2001),Vynnicky et al. (2010), for general review]. In recent applications to the Coronavirus propagation however, these SIR-type models tend to
produce results and forecasts that lack robustness and show variation across models.
This paper introduces a common representation of SIR-type stochastic epidemiological models to facilitate the comparison between models and their outcomes. This representation is a discrete time transition model, which is used to define a typology of epidemiological models with respect to the number of states (compartments) and their interpretation.
The discrete time transition model is characterized by a transition matrix, which determines the probabilities of transitions between the states distinguished in an epidemiological model. As such, it can easily accommodate individual and aggregate count data sampled at various frequencies. On the contrary, a discretization bias arises when a continuous time
deterministic differential system is adapted to data sampled at fixed intervals.
In particular, the discretization bias affects the estimated collective immunity ratio, which causes its reliability and even its existence to be questionable. Moreover, a time discretized SIR-type model is shown to provide different results in an application to data sampled at different frequencies, such as the daily or weekly frequencies, due to its inconsistency with respect to the time unit. The same limitation concerns the reproduction number, which is a commonly used epidemiological parameter. We also comment on the constrained specifications of some SIR-type models, with the potentially complex dynamics of infection probabilities being determined from very few parameters. The transition model allows us to avoid these and other limitations revealed in the commonly used epidemiological models and discussed in the paper.
When aggregate counts are observed, all SIR-type models are shown to have a (Gaussian) (pseudo) nonlinear state space representation, which is convenient for statistical inference. We show that a quasi-maximum likelihood (QML) estimation method can be applied to the pseudo state space representation and easily implemented with an extended, or unscented Kalman filter used for approximating the unobserved state probabilities.
The paper is organized as follows.
The stochastic transition model is introduced in Section 2. First, we define the stochastic framework of individual histories, which is next transformed into a deterministic dynamic model, for the cross-sectional count aggregates over a large number of individuals. Section 3 examines the features of the 2-state SI and 3-state SIR models. We perform the sensitivity analysis to see how the peak of new infections and the time-to-peak depend on the propagation parameters. In Section 4, the (pseudo) state space representation of an epidemiological is derived for statistical inference. In Section 5, we discuss the case when the propagation parameters display either a deterministic, or stochastic variation over time. We show that these extensions of the model can also be examined in a (pseudo) state space framework. Section 6 concludes.
The typology of SIR type models with 2, 3 and 4 states is given in Appendix 1. Proofs are gathered in Appendix 2.
\section{Contagion Modelling}
This section introduces a general specification that encompasses the main epidemiological SIR-type models. It is a discrete time stochastic transition model that allows for modelling of individual histories during an epidemic without the limitations revealed in the deterministic epidemiological models.
In particular, we point that the time discretized version of a continuous time SIR-type model depends on the time unit and needs to be re-adjusted for the sampling frequency of the data. Moreover, the reproduction number computed from the time discretized model depends on the time unit as well and takes a different value when computed from daily or weekly data. We also show a difficulty with inference based on a continuous time model of frequencies.
\subsection{The Stochastic Transition Model}
We consider a large panel of individual histories $Y_{i,t},i=1,..,N, t=0,..,T$, where the variable $Y$ is qualitative multinomial with $J$ alternatives denoted by $j=1,...,J$. These alternatives are the states of infection, recovery or death, depending on the model specification (or compartments in the epidemiological terminology). The discrete time $t$ is assumed to be measured in days, as daily data are often used in epidemiological studies.
\medskip
\noindent {\bf Assumption A1:} The individual histories are such that:
i) The variables $Y_{i,t},i=1,..,N$ at time $t$ fixed have the same marginal (i.e. cross-sectional) distributions. This common distribution depends on time $t$ and is discrete. It is determined by the vector $p(t)$ of size $J$ with components:
$$ p_j(t) = P(Y_{i,t}=j),\; j=1,..,J.$$
\noindent These components are non-negative and sum up to 1 .
ii) The processes ($Y_{i,t},t=1,.,T),i=1,..,N $ are independent, heterogeneous Markov processes of order 1, with common transition probabilities. The transitions from date $t-1$ to date $t$ are characterized by the $J \times J$ transition matrix $\Pi[p(t-1)]$. This matrix has nonnegative elements and each of its rows sums up to 1.
\medskip
The vector $p(t)$ represents the cross-sectional (marginal) probabilities of states. In practice, the cross-sectional probability $p(t)$ is close to the cross-sectional frequency $f(t)$, computed from the values of $Y_{i,t}$. Then, transition matrix $\Pi[p(t-1)]$ is close to $\Pi[f(t-1)]$. However the transitions between states have to be defined with respect to $p(t-1)$ to remain independent of the population size.
\medskip
\noindent {\bf Assumption A2:} i) The epidemic starts at time 0.
ii) At time 0 all individuals are in state $j=1$, which is interpreted as the susceptible compartment.
\medskip
Under Assumptions A1 and A2, the individual histories $Y_{i,t}$ are independent and identically distributed. Therefore, the individuals are exchangeable, i.e. have similar risk factors (homogenous population).
The initial condition also implies nonstationary evolutions of the processes of individual histories over time. This nonstationarity and the time dependence of the transition matrix through $p(t-1)$ only are the distinct characteristics of a SIR-type model. There is one exception, however. When the SIR model is a homogenous Markov process, the transition matrix $\Pi$ is independent of $p(t-1)$.
In general however, the transition matrix $\Pi$ is time dependent. Then, the type of epidemiological model is determined by the number of states, their interpretations, and the structure of the transition matrix. More specifically, the elements of the transition matrix can be either zeros, constants, or functions of marginal probabilities $p(t-1)$ in the presence of time dependence. The models differ with respect to the form of those functions and of the components of $p(t-1)$, which are their arguments.
The examples of commonly used SIR-type specifications are described in Appendix 1. Although most of the SIR-type models are heterogeneous Markov models, the homogeneous Markov model mentioned above can be used for either the local analysis (see Section 2.2), or for deriving the lower and upper bounds on the trajectories of marginal probabilities $p(t)$. Those bounds are mainly determined by the maximum (resp. minimum) of moduli of all eigenvalues of $\Pi[p(t-1)]$, called the Lyapunov exponents, over time $t$.
\subsection{The Deterministic Model}
Assumptions A1 and A2 defining the stochastic dynamics of $Y_{i,t}$ lead to a deterministic nonlinear recursive model for the dynamics of marginal probabilities $p(t)$. This deterministic representation is obtained by applying the Bayes formula and is given by:
\begin{equation}
p(t)= \Pi \, [p(t-1)]' p(t-1), \; t=1,..,T,
\end{equation}
\noindent with initial condition: $p(0)= (1,0,..,0)'$. As shown in Section 4, system (2.1) can be used as a system of estimating equations for statistical inference.
System (2.1) can be rewritten to define the dynamics of changes in marginal probabilities:
\begin{equation}
\Delta p(t) = p(t)-p(t-1) = \{ \Pi \,[p(t-1)]- Id \} p(t-1),
\end{equation}
\noindent where $Id$ denotes the identity matrix. The equation (2.2) highlights the role of the generator: $\Pi \,[p(t-1)]- Id$, in determining the changes in marginal probabilities $\Delta p(t)$.
\medskip
Remark 1: Discretization bias.
A major part of literature concerns epidemiological models written as deterministic differential systems in continuous time. A continuous time analogue of the deterministic model (2.2) is:
\begin{equation}
dp(t)/dt = \{ \Pi [p(t)] - Id \} p(t) .
\end{equation}
\noindent In general, the system of equations (2.2) is not the exact time discretized version of the continuous time system
(2.3) [see Appendix 2 for the rational recursive system]. Thus, due to the nonlinearities in the dynamics, a chaos effect can arise and induce considerably different evolutions of $p(t)$ defined from (2.2) and (2.3), especially over the medium run.
To highlight the differences between the discrete and continuous time modelling, let us consider the 2-state SIS model with a linear force of infection, i.e. a linear function $\pi$ (see Remark 1). The probability of being infected $p_2(t)$ satisfies
the following recursive equation \footnote{Coefficients $\beta, \gamma$ are assumed constrained to ensure that $p_2(t)$ takes values between 0 and 1, for any $p_2(t-1)$ in [0,1].}:
$$ p_2(t)=[\beta p_2(t-1)] [1-p_2(t-1)] + (1- \gamma) p_2(t-1),$$
\noindent in discrete time and
$$ d p_2(t)/dt= (\beta- \gamma) p_2(t) - \gamma p_2(t)^2, $$
\noindent in continuous time.
Even though both equations look similar and contain the same parameter symbols, the following differences can be pointed out:
\medskip
\noindent i) The discrete time version of SIS is not time consistent, as $p_2(t)$ at lag 2 derived by recursive substitution is a quartic function of $p_2(t-2)$. Hence, this specification needs to be modified whenever the unit of time separating the observations changes. In practice, this means that a specification valid for daily data is not valid for weekly data. On the contrary, the continuous time version of SIS is time consistent.
\medskip
\noindent ii) The parameters $\beta$ and $\gamma$ in both the discrete and continuous time SIS models given above depend on the selected time unit too. In the continuous time model however, $\beta$ and $\gamma$ are multiplied by the same factor when the time unit is changed. Then, the so-called reproduction number $R_0= \beta/\gamma$ is invariant with respect to the time unit. As the discrete time model is not time consistent, $R_0$ computed directly from the time discretized model is not invariant with respect to the time unit either. Hence, different values of $R_0$ are obtained from daily and weekly data. Any result obtained from the time discretized differential equation (called the Euler discretization) and interpreted in the continuous time framework needs to be interpreted with caution. This finding calls into question the reliability of the reproduction number $R_0$ and some of its transforms, such as the asymptotic value $p_2(\infty)$, which are important components of epidemiological studies.
\medskip
Remark 2: Non-differentiability of a continuous time frequency model
It is common to write the epidemiological model as a differential system of frequencies $f(t)$, instead of marginal probabilities $p(t)$, as:
\begin{equation}
df(t)/dt= [\Pi [f(t)] -Id] f(t).
\end{equation}
\noindent This differential system is not compatible with the set of admissible values of vectors $f(t)$ \footnote{It is also the case when a stochastic feature is introduced by replacing the deterministic differential equation by a stochastic one, such as a multivariate Jacobi process to account for the positivity and unit mass restrictions on the components of $f(t)$ [see, Admani et al. (2018), Jiang et al. (2011), El Koufi et al. (2019) for examples of stochastic differential epidemic models and Gourieroux,Jasiak (2006) for the multivariate Jacobi process].}. The components of $f(t)$ are not continuously valued functions, as they take on values equal to the multiples of $1/N$, which implies the non-differentiability of function $f(t)$. Therefore, an epidemiological model of this type cannot provide accurate results. Moreover, as the model is deterministic, it cannot take into account the ex-ante uncertainty about the vectors $f(t)$, which are random.
\subsection{Local Expansions}
Let us now examine the dynamics of marginal probabilities of states $p(t)$.
The analysis of their evolution during an epidemic can be simplified if we focus on either the beginning, or the end of the epidemic and consider local expansions.
\medskip
\noindent {\bf 2.3.1 Beginning of the epidemic}
At time $t=0$, the initial value is: $p(0)=(1,0,..,0)'$. Below, we consider expansions of orders 1 and 2 of the recursive system (2.1) in a neighbourhood of $p(0)$.
\medskip
\noindent {\bf i) First-Order Expansion}:
The first-order expansion is:
\begin{equation}
p(t)= \Pi[ p(0)]' p(t-1),
\end{equation}
\noindent which corresponds to a homogeneous Markov model with transition matrix $\Pi [p(0)]$. It can be solved analytically as:
\begin{equation}
p(t)= \Pi \,[p(0)]^{'t} p(0),
\end{equation}
\noindent We find that locally the components of marginal probabilities $p(t)$ are combinations of exponential functions (and also of sine functions, cosine functions, which can possibly be multiplied by polynomials, if some eigenvalues of $\Pi \,[p(0)]$ are complex and/or multiple). Their dynamics are constrained by the specific form of matrix $\Pi[p(0)]$, which is a transition matrix. More specifically, all components of $p(t)$ have to take values between 0 and 1. In order to satisfy this restriction, locally, the marginal probability $p_1(t)$ is exponentially decreasing over time, whereas marginal probabilities of other states $p_j(t),\; j=2,..,J$ are exponentially increasing over time.
\medskip
\noindent {\bf ii) Second-Order Expansion}
The second order expansion leads to the dynamic system:
\begin{equation}
p(t)= \{ \Pi \,[p(0)] + \sum_{j=1}^J d \Pi \,[p(0)]/d p_j \, p_j(t-1) \} ' p(t-1),
\end{equation}
\noindent which is a Riccati quadratic recursive system.
\noindent {\bf 2.3.2 End of the epidemic}
In general, the epidemiological models include some absorbing states, such as the states of deceased, or recovered (see the examples in Section 3 and Appendix 1). In this case, the sequence of marginal probabilities $p(t)$ has a limit when $t \rightarrow \infty: p(\infty)$, say. If there is only one absorbing state $J $, say, we get
$p(\infty)= (0,0,..,1)'$. Then, the first- and second-order expansions can be performed in a neighbourhood of $p(\infty)$, yielding dynamic approximations systems analogous to systems (2.5) and (2.7).
The early phases of the epidemic, which are characterized by expansions given in Section 2.3.1. are illustrated in
Section 4. Expansions derived in Section 2.3.2 can be used
for other research objectives, such as determining the level of collective immunity.
\setcounter{equation}{0}\def4.\arabic{equation}{3.\arabic{equation}}
\section{Examples}
Let us now study the dynamic properties of two commonly used epidemiological models, which are the SI and SIR models (see Appendix 1) in the framework of a discrete time transition model. We derive the dynamic equations of marginal probabilities and describe their behavior at the beginning and the end of an epidemic.
\subsection{SI Model}
\noindent {\bf 3.1.1 The deterministic model}
\medskip
\noindent The transition model representation of the deterministic SI model involves the following $2 \times 2$ transition matrix:
row 1, S: $1-\pi(p_2)$; $\pi(p_2)$.
row 2, I: 0, 1.
\noindent The state I of infected, still infectious and immunized is the absorbing state. Function $\pi$ is the contagion function (called the {\bf force of infection}) that satisfies the following assumption:
\medskip
\noindent {\bf Assumption A3:} $\pi$ is a non-decreasing function of $p_2$, which takes values between 0 and 1.
\medskip
The value $\pi(0)$ can be interpreted as an exogenous component of the contagion. In an open economy, it can be due to the effect of tourism, international trade and migration. In a closed economy, such as the world in its entirety, it can be set equal to zero. There is a {\bf strict (endogeneous) contagion} effect if function $\pi$ is strictly increasing.
\medskip
\noindent {\bf Example 1:} A common specification of the force of infection $\pi$ is the linear function: $\pi(p_2)=b \, p_2$, where parameter $b$ takes values between 0 and 1, or a logistic function of $p_2$:
$$\pi(p_2)= \exp(a+b p_2)/[ 1+ exp(a+b p_2)],$$
\noindent where coefficient $b$ is non-negative. In the logistic force of infection the exogenous infection rate is measured by: $\exp a/[1+ \exp a]$ and the strict endogenous contagion effect by parameter $b$. Other functional forms have also been considered in the growth literature and obtained, for instance, by replacing $p_2$ by a power of $p_2$ in the expressions given above [see e.g. Richards(1959), Kuhi et al. (2003), Table 1, Brandenburg (2019), Wu et al. (2020), Harvey, Kattuman (2020)].
The form of the transition matrix given above leads to the following nonlinear recursive equation of order 1 for the marginal probability of being infected:
\begin{equation}
p_2(t)= \pi(p_2(t-1))[1-p_2(t-1)] + p_2(t-1).
\end{equation}
\medskip
\noindent {\bf Proposition 1:} Under Assumption A3, $p_2(t)$ is a non-decreasing function of time with exponential lower and upper bounds:
$1-[1-\pi(0)]^t \leq p_2(t) \leq 1-[1-\pi(1)]^t$.
\noindent It tends to 1 when $t \rightarrow \infty$.
\medskip
\noindent Proof:
\noindent i) It is non-decreasing, as $p_2(t) - p_2(t-1)$ is non-negative.
\noindent ii) The bounds are obtained by observing that $p_2(t)$ is an increasing function of $\pi$.
\noindent iii) Since $p_2(t)$ is non-decreasing and bounded by 1, it converges to a value $p_2(\infty)$. This limit is equal to 1, by considering (3.1) at $t=\infty$.
\noindent QED
\medskip
In particular, if there is no contagion effect i.e. if $\pi(p_2)$ is constant and equal to $\pi$, then the marginal probability of being infected is: $p_2(t) =1-[1-\pi]^t$.
\medskip
\noindent {\bf 3.1.2 Expansions}
\medskip
It is interesting to consider the expansions of the dynamics of the probability of being infected in the SI model at the beginning of the contagion,i.e. when $p_2$ is close to zero, or at the end of the contagion, i.e. when $p_2$ is close to 1.
\medskip
\noindent i) Beginning of the contagion
A second-order expansion leads to:
\begin{equation}
p_2(t)-p_2(t-1) \propto [\pi(0)+d \pi(0)/dp \, p_2(t-1)] [1-p_2(t-1)].
\end{equation}
\medskip
\noindent ii) End of the contagion
The second-order expansion in a neighbourhood of $p_2=1$ yields:
\begin{equation}
p_2(t)-1= [\pi(1)+d \pi(1)/dp \, [p_2(t-1)-1]] [1-p_2(t-1)] + p_2(t-1)-1.
\end{equation}
Both approximations lead to discrete time logistic recursive equations for the probability of being infected $p_2(t)$ and the probability of not being infected $1-p_2(t)$, respectively.
\medskip
\noindent {\bf 3.1.3 Continuous time analogue}
\medskip
\noindent The continuous time analogue of the recursive equation (3.2) is:
\begin{equation}
d p_2(t)/dt= (\alpha + \beta p_2(t)) (1- p_2(t)),
\end{equation}
\noindent where $\alpha= \pi(0), \beta= d \pi(0)/ dp$ are both nonnegative.
\noindent Equation (3.4) can be solved analytically.
\medskip
\noindent {\bf Proposition 2:} i) Assuming that the beginning of the epidemics is at time $t=0$, the solution of equation (3.4) is:
$$p_2(t)= [\alpha \exp[(\alpha + \beta)t]- \alpha]/[\alpha \exp[( \alpha+ \beta) t] + \beta].$$
ii) If $\beta > \alpha$, the solution is such that the derivative $d p_2(t)/dt$ attains the maximum when $p_2(t)= (\beta- \alpha)/(2 \beta)$. The time-to- inflection is reached at $t^*= \log (\beta/\alpha)/(\alpha+\beta)$.
\medskip
\noindent Proof: see Appendix 2.
\medskip
It follows that the probability of being infected $p_2(t)$ is a logistic function of time. Moreover, if the strict contagion effect is large as compared to the exogenous component of the contagion, there is a peak in the changes of ratios of infected individuals over time. The size and timing of the peak depend on the propagation parameters. However, the SI model has only two parameters, which is insufficient to independently determine the peak, the time to peak and other characteristics such as the flatness of the curve at the peak (the so-called "plateau" effect) as well as the asymmetry of the curve with respect to the peak.
These above outcomes of the SI model (3.1) are based on a local expansion of the initial nonlinear recursive equation and are therefore valid at the beginning of an epidemic only. The length of the time episode over which such an expansion is valid depends on function $\pi$, and also on the values of parameters $a, b$ in the parametric SI model in Example 1.
\medskip
\noindent {\bf 3.1.4 Sensitivity Analysis}
\medskip
Let us consider below the parametric SI model in Example 1 and illustrate graphically its dynamics. At time 0, we fix the probability of being infected $p_2(0)=0$ and set the parameters $\alpha, \beta$, where $\alpha >0 , \beta>0$ equal to $\alpha =0.005, \beta = 0.85$.
Figure 1 below displays the dynamic of solution $p(t)$ which satisfies the continuous time SI model (3.4), i.e. with the logistic evolution given in Proposition 2, and its discrete time Euler approximation at the beginning of an epidemic given in equation(3.2). It is computed with the same values of parameters $\alpha, \beta$ given above. Figure 1 shows that the discrete time approximation (3.2) can be very misleading when it is used for forecasting over a medium or long run.
\medskip
[Insert Figure 1: Evolutions of $p(t)$, SI Model]
\medskip
\noindent When $\beta < \alpha$, we get an increasing concave curve that tends to 1. When $\beta > \alpha$, as in Figure 1, we get an exponential convex increase for small $t$, followed by an increasing concave pattern of convergence to 1.
The evolutions of changes of $p(t)$ are shown in Figure 2:
\medskip
[Insert Figure 2: Evolutions of Changes in p(t), SI Model]
\medskip
\noindent When $\beta > \alpha$, we get a hump-shaped pattern with the curve decreasing at a slower rate after the peak than increasing before the peak.
\noindent We complete the sensitivity analysis of the main features of the SI model by examining the size of peak (Figure 3) and the time-to-inflection (Figure 4).
\medskip
[Insert Figure 3: Size of Peak, SI Model]
\medskip
[Insert Figure 4: Time to Inflection, SI Model]
\subsection{SIR model}
\noindent {\bf 3.2.1 The model}
Let us now consider the SIR model (see Appendix 1) with three states: S for Susceptible; I for Infected, infectious, not immunized; R for Recovered, immunized and no longer infectious. Its transition model representation involves the $3 \times 3$ transition matrix, which is triangular and given by:
row 1, S: $1- \pi(p_2)$; $\pi(p_2)$ ; 0
row 2, I : 0, $p_{22}$; $p_{23}$
row3,R : 0; 0; 1
\medskip
\noindent where $p_{23}$ is strictly positive, and R is the absorbing state.
\medskip
In the limiting case $p_{23}=0$, the $2 \times 2$ North-West subset of the transition matrix corresponds to the SI model discussed in Section 3.1. There are two absorbing states in the SIR model: I and R. State R cannot be reached starting from an initial state S of susceptible individuals.
\medskip
\noindent The marginal probabilities of states I and R satisfy two linearly independent estimating equations:
\begin{eqnarray}
p_2(t) & = & \pi[p_2(t-1)][1-p_2(t-1)-p_3(t-1)] +p_{22} p_2(t-1), \\
p_3(t) & = & p_{23} p_2(t-1) + p_3(t-1). \nonumber
\end{eqnarray}
\noindent From the second equation of system (3.5),we get:
\begin{equation}
p_2(t-1)=[p_3(t)-p_3(t-1)]/ p_{23},
\end{equation}
\noindent and by substituting into the first equation, we derive the recursive equation satisfied by $p_3(t)$:
\begin{eqnarray}
p_3(t) &= &p_3(t-1) + \pi[(p_3(t-1)-p_3(t-2))/p_{23}] [p_{23}-p_3(t-1) +(1-p_{23}) p_3(t-2)]\nonumber \\
& + & p_{22} [p_3(t-1)-p_3(t-2)].
\end{eqnarray}
\medskip
\noindent {\bf Proposition 3} i) The sequence $p_1(t)$ [resp. $p_3(t)$] is decreasing [resp. increasing].
ii) The sequence $p_3(t)$ satisfies a nonlinear recursive equation of order 2.
iii) The sequence $p_2(t)$ is a linear moving average of order 1 in $p_3(t+1)$.
\medskip
\noindent The higher order of temporal dependence in $p_3(t)$ is due to the interpretation of state I as a transitory state between S and R. Thus, the dynamics of $p_3(t)$ has to account for both the entries into and exits from the state I.
Let us now discuss the behaviour of marginal probabilities p(t) when t tends to infinity. Since $p_3(t)$ is increasing, and it is upper bounded by 1, its limit is $p_3(\infty)$, say. From equation (3.6), it follows that the limit of $p_2(t)$ is zero. Then, by taking into account the first equation of (3.5), we get:
\medskip
\noindent {\bf Lemma 1:} When $t \rightarrow \infty$,
i) $p_2(t)\rightarrow 0$.
ii) If $\pi(0)$ is different from 0, $p_3(t) \rightarrow 1$.
iii) If $\pi(0)=0, p_3(t)$ might tend to a limiting value $p_3(\infty) < 1$.
\medskip
Determining the conditions for such a convergence to $p_3(\infty)$, which is strictly less than 1 and computing this limiting value, which is interpreted as the level of {\bf collective immunity} are common topics in the epidemiological literature. Due to the time discretisation bias (see Remark 1), estimation errors on a long run parameter $p_3(\infty)$ are large in an early phase of epidemic. Hence, the estimated ratio of collective immunity and even its existence may be unreliable.
\medskip
\noindent {\bf 3.2.2 Homogeneous Markov}
As mentioned Section in 3.1, it is interesting to consider the homogeneous Markov chain, obtained when function $\pi$ is constant (no contagion). Then the evolution of $p(t)$ is driven by a linear recursive equation of order 1: $p(t)= \Pi' p(t-1)$, where $\Pi$ is a triangular matrix with eigenvalues: $1-\pi, p_{22}, 1$. The following proposition is obtained:
\medskip
\noindent {\bf Proposition 4}: For a constant $\pi$, we have: $p(t)= A (1-\pi)^t + B p_{22}^t+ C$,
where $A, B, C$ are 3-dimensional vectors.
\medskip
\noindent The effects of entries into and exits from state I induce the two driving exponential functions.
\medskip
\noindent When function $\pi$ is not constant, the decreasing sequence $p_1(t)$ and increasing sequence $p_3(t)$ take values between their analogues computed from a homogeneous Markov chain with $\pi=\pi(0)$ and $\pi=\pi(1)$, respectively.
\medskip
\noindent {\bf 3.2.3 Local expansion}
At the beginning of an epidemic the probability of being infected $p_2(t)$ is close to 0. Then, the estimating equations can be
replaced by second-order discrete or continuous deterministic systems of Riccati type. Some of these Riccati systems have closed-form solutions that involve transcendental functions [see Miller (2012), Harko et al. (2014)]. However these analytical solutions have complicated expressions. Alternatively, they can be derived by simulation methods, which are easy to perform in the SIR model.
\medskip
\setcounter{equation}{0}\def4.\arabic{equation}{4.\arabic{equation}}
\noindent {\bf 3.2.4 Sensitivity Analysis}
Let us assume a linear function $\pi(p_2) = a + b p_2$, where $a>0, b>0, a+b <1$. Then the SIR model involves 3 independent parameters, and is expected to provide more flexibility than the SI model, due to the additional parameter $p_{23}$. Below, we perform a sensitivity analysis similar to that in Section 3.1.4 and focused on series $p_2(t)$. Parameters $ a, b, p_{23}$ are set equal to $a=0.005, b=0.85, p_{23}=0.5$.
\medskip
[Insert Figure 5: Evolution of $p_2(t)$, SIR Model]
\medskip
[Insert Figure 6 : Evolution of Change in $p_2(t)$, SIR Model]
\medskip
The timing of a peak is determined by parameter $a$ as shown below. We hold parameter $b=0.85$ constant and change the values of parameter $a$ in Figure 7.
\medskip
[Insert Figure 7 : Timing of Peak, $a$ varying, SIR Model]
\medskip
\noindent Next, parameter $a=0.005$ is held constant and the values of parameter $b$ are allowed to vary. The size of peak is determined by parameter $b$ as shown in Figure 8 below.
\medskip
[Insert Figure 8: Size of Peak, $b$ varying, SIR model]
\section{Statistical Inference}
This section present the methods of inference for the discrete time transition model.
Let us now consider a parametric transition matrix $\Pi [ p(t-1); \theta]$, with parameter vector $\theta$, and assume that the empirical frequencies $f(t),t=1,..,T$ are observed. In addition, we assume that the parametric model is well specified.
\subsection{Distribution of frequencies}
Under Assumptions A1, A2, these frequencies converge at rate $1/\sqrt{N}$ to their theoretical counterparts and are asymptotically normal. Thus we can write:
\begin{equation}
f(t)=p(t) + u(t),
\end{equation}
\noindent where the errors are Gaussian with mean zero and the variance-covariance matrix at lag $h$ given below [Gourieroux, Jasiak (2020)]:
\begin{equation}
Cov[u(t),u(t-h)]=(1/N) \{ \Pi(t-1,h) diag[p(t-h)] - p(t) p(t-h)'\},
\end{equation}
\noindent where: $\Pi(t-1,h)=\Pi[p(t-1)]...\Pi[ p(t-h)]$.
\subsection{(Pseudo) State space representation}
System (4.1) resembles a measurement equation in a state space system with the measurement variable $f(t)$, measurement error $u(t)$, and the following system of transition equations for the state variable $p(t)$,:
\begin{equation}
p(t)= \Pi[p(t-1); \theta]' p(t-1).
\end{equation}
However, the system of equations (4.3) and (4.1) does not fully satisfy the definition of a state space representation because the measurement errors $u(t)$ are
serially correlated, as shown in equation (4.2).
This difficulty is easily circumvented by assuming a pseudo Gaussian distribution for the errors $u_t'$, and disregarding the autocorrelation. Their variance-covariance matrix at time $t$ can be assumed equal to an identity matrix $Id$ (Ordinary Least Squares approach) or an unknown constant matrix $\Omega$ (Weighted Least Squares approach), or even the true expression of $V(u_t)$ can be considered. Upon this change of autocovariance structure, a (pseudo) state space representation is obtained.
The pseudo state space representation can be estimated by the Gaussian quasi-maximum likelihood (QML). The quasi-maximum likelihood approach has also an interpretation in terms of estimating equations and asymptotic least squares [see, Berkson (1944), Godambe, Thompson (1974), McRae (1977), Kalbfleisch et al. (1983), Hardin, Hilbe (2003), Miller, Judge (2015)]. As the asymptotic theory is established for $T$ fixed and $N \rightarrow \infty$, the QML and weighted least squares
methods provide consistent estimators of parameter vector $\theta$, which are not fully efficient as the true structure of autocovariances of errrors $u_t$ has not been taken into account [see, Gourieroux, Jasiak (2020), Appendix 2].
In practice, the QML estimates \footnote{As the QML approach does not account for the structure of the variance-covariance matrix of the $u(t)$'s it can be improved by replacing a "moment" estimator by a GMM estimator.} of $\theta$ can be computed numerically from an extended, or unscented Kalman Filter \footnote{see, e.g. Song, Grizzle (1995), Krener (2003) for the Extended Kalman Filter.} applied to the (pseudo) state space model.
\medskip
The estimation approach outlined above remains valid when some frequencies $f_j(t)$ are missing (see Gourieroux, Jasiak(2020) for an application to inference on latent counts of infected and undetected (asymptomatic) individuals).
The extended Kalman filter provides information on the uncertainty of estimates and predictions. This uncertainty has to be taken into account, especially at the early ascending phase of an epidemic, when the number of observations is small, the quality of data is rather poor and the parameter of interest, such as the peak, is distant in time from the period of observations. Then, the confidence and prediction intervals are rather wide and the statistician has to interpret the results with caution [see e.g. Viboud et al. (2016), Chowell et al. (2019) for studies at early stages].
The extended Kalman filter is suitable as an updating algorithm of estimates and forecasts [Nihan, Davis (1987)]. This is especially important at the beginning of the epidemic, when each newly arrived observation is very informative.
\section{Models with Time Dependent Parameters}
\subsection{The modelling}
The simple epidemiological models can be easily extended to allow for time dependent parameters, obtained by replacing $\theta$ by $a(t), b$, say, to distinguish the time dependent parameter vector from the constant parameters. Then, their transition model representation involves the transition matrix $\Pi [p(t-1),a(t),b]$. The time dependent propagation parameters can, for instance, capture the time varying implementation of social distancing measures and the compliance with these measures [see e.g. DiDomenico et al. (2020), Alvares et al. (2020)]. Such an extended model can be written also in the (pseudo) state space representation and estimated by using the methods given in the previous Section. The (pseudo) state space representations depend on the assumptions on the evolution of parameter vector $a(t)$. At least three types of modelling approaches can be considered.
\medskip
i) {\bf Dynamics of $a(t)$ left unspecified}
\noindent The state space representation comprises the measurement equation:
$$f(t)=p(t) + u(t), $$
\noindent and the transition equations:
$$p(t)= \Pi[ p(t-1), a(t), b]' p(t-1).$$
\noindent The state variables are the marginal probabilities $p(t)$ and parameters $a(t)$ while $b$ is the vector of constant parameter. They can be jointly estimated and the state variables filtered by the extended Kalman filter, under an identification condition. In particular, the order condition: $(J-1)(T-1) \geq T \, dim \, a + dim \, b$ has to be satisfied.
\medskip
ii) {\bf Stochastic evolution of $a(t)$}
\noindent An alternative model has the same measurement equation and extends the previous state space representation system as it includes additional transitions such as:
$$a(t)= \phi a(t-1) + v(t),$$
\noindent where the errors $v(t)$ are Gaussian noises independent of the measurement errors $u(t)$ and $|\phi|<1$ for stationarity.
\noindent Under this representation, the state variables are the marginal probabilities $p(t)$ and parameters $a(t)$, and $b$ is the constant parameter vector. The extended Kalman Filter can be used to jointly estimate $b$ and filter the components of $a(t)$.
\medskip
iii) {\bf Exogenous information on $a(t)$}
If the indicators $x(t)$ of social distancing are available, such as counts of travellers [see, Hurtacsu et al. (2020)] and the daily numbers of fines for disobeying the social distancing rules, the model can be extended to include $x(t)$. Then, the model is similar to the representation above with the autoregressive dynamic replaced by an equation such as:
$$a(t)=C x(t) + v(t)$$
\noindent where $C$ is a row vector of constant coefficients to be estimated and $v(t)$ are Gaussian noises independent of the measurement errors $u(t)$.
\medskip
\medskip
\noindent {\bf 5.2 Logistic model with stochastic contagion parameter}
Let us now examine the limiting case of time independent stochastic parameters, which is
a very special case of stochastic dynamics and consider the logistic model of Proposition 2. The stochastic parameters are introduced to account for heterogeneity of infection patterns. For ease of exposition, we assume a discrete heterogeneity distribution with weights $q_k, k=1,...,K$ on values $(\alpha_k, \beta_k), \;k=1,...,K$ [see, Gourieroux et al.(1996), Yan, Chowell (2019)]. Then, equation (3.4) is written conditional on $\alpha, \beta$ and defines the evolution of $p_{2,k}(t)$ for values $\alpha_k, \beta_k$. Next, these evolutions need to be re-integrated with respect to $\alpha, \beta$, in order to find the marginal probability of being infected $p_2(t)$ as follows:
$$ p_2(t) = \sum_{k=1}^K q_k p_{2,k}(t) = \sum_{k=1}^K \{ q_k [\alpha_k [\exp (\alpha_k + \beta_k)t] - \alpha_k]\, /\, [\alpha_k \exp [(\alpha_k + \beta_k) t ] +\beta_k] \}. $$
\noindent We get a convex combination of logistic functions \footnote{used as a basis of functions in neural networks.}. This additive specification implies that $p_2(t)$ cannot follow a quadratic differential equation such as (3.4). There is a double heterogeneity i) in coefficients $\alpha$, which means that there exist multiple initial exogenous clusters of infection of different sizes, ii) in coefficients $\beta$, which means that the speeds of propagation of each cluster are different. This model is not a special case of (SI)$^K$
[see Appendix 1] as there is no contagion between the sub-populations $k$ and only contagion within is allowed.
The presence of heterogeneity in a logistic model generates the following effects:
i) several peaks can appear in the changes in $p_2(t)$ over time. This is the wave effect [Witham (1974), Gourieroux et al. (1996)], due to different propagation parameters of each wave.
ii) the persistence of $p_2(t)$ increases due to the additive representation. This is a well-known long memory effect revealed in Granger, Joyeux (1980) for linear autoregressive models that also exist in nonlinear logistic models [see Sattenspiel (1990)].
Below, a three-wave pattern is illustrated in Figure 9 for the following
parameter values: $\alpha = 0.015, 0.0005, 0.0001$, $\beta = 0.95, 0.85, 0.75$
\medskip
[Insert Figure 9: Three-Wave Infection Pattern]
\medskip
We observe the three waves with the highest peak due to the first wave. We also observe a persistence effect as the decline following the first peak is slower than the declines of each wave separately.
\section{Concluding Remarks}
Contrary to the major part of literature on epidemiological models, which considers deterministic continuous time models of counts of individuals in various compartments (states), we consider stochastic models in discrete time for variables representing individual histories [see also Allen (1994), Das et al.(2011) for discrete time approach]. The proposed discrete time transition model has the following advantages:
i) It eliminates the lack of consistency between time discretized continuous time models with respect to the time unit. In the continuous time setup, it also eliminates the assumption of differentiability of aggregate counts, which are discrete variables. This is especially important in the early phase of an epidemic when some of these counts are small.
ii) The stochastic model allows us to combine aggregate count variables and individual medical histories of patients under medical care.
iii) The stochastic component allows us for deriving not only the point, but also interval forecast. This is important at the beginning of an epidemic when the number of observations is small and the results are less reliable.
iv) The estimation of the transition model can be performed by applying an extended Kalman filter to its (pseudo) state space representation.
\newpage
{\bf {\Large REFERENCES}} \\
\noindent Admani,J., Hattaf, K.,and N., Yousfi (2018); Dynamical Behaviour of a Stochastic SIRS Epidemic Model,Journal of Mathematical and Computational Science,8,421-431. \\
\noindent Allen, L. (1994): Some Discrete-Time SI, SIR and SIS Epidemic Models, Mathematical Biosciences, 124, 83-105. \\
\noindent Alvarez, F., Argente, D. and F. Lippi (2020): A Simple Planning Problem for
COVID-19 Lockdown, LUISS and Einaudi Institute for Economics and Finance DP. \\
\noindent Atkeson, A. (2020): What Will Be the Economic Impact of Covid-19 in the US? Rough Estimates of Disease Scenarios, NBER Working Paper 26867. \\
\noindent Berkson, J. (1944): Application of the Logistic Function to Bio-Assay, JASA, 339- 357.\\
\noindent Brandenburg,H.(2019):Quadratic Growth During the 2019 Novel Coronavirus Epidemic,arXiv.\\
\noindent Brauer, F. and C. Castillo-Chavez (2001): Mathematical Models in Population Biology and Epidemiology,Springer,New York. \\
\noindent Chowell, G., Tariq, A., and J.M. Hyman (2019):A Novel Sub-Epidemic Modeling Framework for Short Term Forecasting Epidemic Waves, BMC Med.,17,1-19. \\
\noindent Das, P., Mukherjee, D., and A., Sarkar (2011): Study of an SI Epidemic Model with Nonlinear Incidence Rate: Discrete and Stochastic Version, Applied Mathematics and Computation,218,2509-2515.\\
\noindent DiDomenico, L., Pullano, G., Coletti, P., Hens, N. and V. Colizza (2020):Expected Impact of School Closure and Telework to Mitigate COVID-19 Epidemic in France, www.epicx-lab.com/covid-19.html]. \\
\noindent El Koufi, A., Adnani, J., Bennar, A. and N. Yousfi (2019): Analysis of a Stochastic SIR Model with Vaccination and
Nonlinear Incidence Rate, International Journal of Differential Equations,Vol 2019, ID 9275051. \\
\noindent Feng, Z., Huang, W., and C, Castillo-Chavez (2005): Global Behaviour of a Multi Group SIS Epidemic Model with Age Structure, Journal of Differential Equations, 218,292-314.\\
\noindent Godambe, V. and M. Thompson (1974): Estimating Equations in the Presence of a Nuisance Parameter, Annals of Statistics, 3, 568-576. \\
\noindent Gourieroux, C., and J.,Jasiak (2006): Multivariate Jacobi Process with Smoothed Transition, Journal of Econometrics,131,475-505. \\
\noindent Gourieroux, C. and J. Jasiak (2007): Econometrics of Individual Risks: Credit, Insurance and Marketing, Princeton University Press. \\
\noindent Gourieroux, C. and J.,Jasiak (2020): Time Varying Markov Processes with Partially Observed Aggregate Data: An Application to Coronavirus, Arxiv 2005.04500. \\
\noindent Gourieroux, C. and I. Peaucelle (1996): Diffusion and Wave Effects, Annales d'Economie et de Statistique, 44, 191-217.\\
\noindent Granger, C. and A. Joyeux (1980): "An Introducction to Long Memory Time Series Models and Fractional Differencing", Journal of Time Series Analysis, 1 , 15-29.
\noindent Hardin, J. and J. Hilbe (2003): "Generalized Estimating Equations", Chapman Hall. \\
\noindent Harko, T., Lobo, F. and M. Mak (2014): Exact Analytical Solutions of the Susceptible-Infected-Recovered Epidemic Model and of the SIR Model with Equal Death and Birth Rates,Applied Mathematics and Computation,236,184-194. \\
\noindent Harvey, A., and P. Kattuman (2020): "Time Series Models Based on Growth Curves with Applications to Forecasting Coronavirus", Covid Economics, 24, 126-157. \\
\noindent Hethcote, H. (2000): The Mathematics of Infectious Diseases,SIAM Review, 42, 599-653. \\
\noindent Hortescu, A., Liu, J. and T., Schwieg (2020): Estimating the Fraction of Unreported Infections in Epidemics with a Known Epicenter:An Application to COVID-19,DP University Chicago. \\
\noindent Jiang, D., Yu, J., Ji, C. and N., Shi (2011): Asymptotic Behaviour of Global Positive Solution to a Stochastic SIR Model,Mathematical and Computer Modelling,54,221-232. \\
\noindent Kalbfleisch, J., Lawless, J., and W. Vollmer(1983): Estimation in Markov Models from Aggregate data,Biometrics,39,907-919. \\
\noindent Kermack, W., and A. McKendrick (1927): A Contribution to the Mathematical Theory of Epidemics,Proceedings of the Royal Statistical Society, A, 115,700-721. \\
\noindent Korolev, I. (2020): Estimating the Parameters of the SEIRD Model
for COVID-19 Using the Deaths Data, Department of Economics, Binghamton University DP. \\
\noindent Krener, A. (2003): The Convergence of the EKF, Directions in Mathematical Systems: Theory and Optimization, 173-182, Springer. \\
\noindent Kuhi, D., Kebraeb, E., Lopez, S. and J., France (2003): An Evaluation of Different Growth Functions for Describing the Profile of Live Weight with Age in Meat and Egg Strains of Chicken,Poultry Science,82,1536-1543.\\
\noindent McFadden, D. (1984): Econometric Analysis of Qualitative Response Models,in Handbook of Econometrics,Vol 2,1395-1457, Elsevier. \\
\noindent McRae, E. (1977): Estimation of Time Varying Markov Processes with Aggregate Data,Econometrica, 45,183-198. \\
\noindent Meng, X., and L., Chen (2008): The Dynamics of a New SIR Epidemic Model Concerning Pulse Vaccination Strategy,Applied Mathematics and Computation,197,582-597.\\
\noindent Miller, J. (2012): A Note on the Derivation of Epidemic Final Sizes,Bulletin of Mathematical Biology, 74, Section 4.1. \\
\noindent Miller,J. and G. Judge (2015): "Information Recovery in a Dynamic Statistical Markov Model", Econometrics, Vol 3/2, 187-198. \\
\noindent Nihan, N. and G., Davis (1987): Recursive Estimation of Origin-Destination Matrices From Input/Output Counts, Transpn. Research,218,149-163.\\
\noindent Richards, F. (1959): A Flexible Growth Function for Empirical Use",J.Exp.Bot.,10,290-301. \\
\noindent Sattenspeil, L. (1990): Modeling the Spread and Persistence of Infectious Disease in Human Populations", Yearbook of Physical Antropology.\\
\noindent Song, Y. and J. Grizzle (1995): The Extended Kalman Filter as a Local Asymptotic Observer, Estimation and Control, 5, 59-78. \\
\noindent Toda, A. (2020): Susceptible-Infected-Recovered (SIR): Dynamics
of COVID-19 and Economic Impact, ArXiv:2003.11221v2 \\
\noindent Tchuenche,J., Nwagwo,A and R;, Levins (2007): Global Behaviour of an SIR Epidemic Model with Time Delay, Mathematical Methods in Applied Sciences,30,733-749.\\
\noindent Verity et al. (2020): Generalized Estimates of the Severity of Coronavirus Disease 2019: A Model Based Analysis, online. \\
\noindent Viboud C., Simonsen, L., Chowell, G. (2016): A Generalized Growth Model to Characterize the Early Ascending Phase of Infectious Disease Outbreaks,Epidemics,15,27-37. \\
\noindent Vynnicky,.E., and White,R. (eds)(2010): An Introduction to Infectious Disease Modelling, Oxford Univ. Press. \\
\noindent Witham, G. (1974): Linear and Nonlinear Waves, Wiley. \\
\noindent Wu, K., Darcet, D., Wang, Q. and D., Sornette (2020): Generalized Logistic Growth Modelling of the COVID-19 Outbreak in 29 Provinces in China and in the Rest of the World,DP ETH Zurich .\\
\noindent Wu, K., Zheng, J., and J.,Chen (2020):Utilize State Transition Matrix Model to Predict the Novel Coronavirus Infection Peak and Patient Distribution, ArXiv. \\
\noindent Zhang,I.,and Z., Ma (2003): Global Dynamics of a SEIR Epidemic model with Saturating Contact Rate,Mathematical Biosciences,185,15-32.\\
\noindent Yan, P., and G. Chowell (2019): Quantitative Methods for Investigating Infectious Disease Outbreaks, Springer.
\newpage
\begin{center}{\bf Appendix A.1}\end{center}
\begin{center} {\bf Structural Epidemiological Models}
\end{center}
\noindent This Appendix presents a typology of basic epidemiological models that can serve as building blocks of more complex specifications. The difference between the basic models are with respect to:
\medskip
i) the number of states ( compartments) and their interpretations as S= susceptible, E=exposed, I =infected, R =recovered, D=deceased.
ii) The number and types of virus propagation sources
iii) The location of zeros in the transition matrix (i.e. the causal structure)
iv) The structure of time dependent transition probabilities.
\noindent We provide below the transition probabilities along with the state interpretations. The time dependent transition probabilities are denoted by $\pi$ and are functions of (lagged) marginal probabilities $p(t)$.
\noindent The models described below are the following:
2-state: SI model, SIS model
3-state:SIR model
4-state : SIRD model, SEIR model, SIR model, (SI)$^2$ model, S,IU ,ID, R model.
\noindent The interpretations of states and the form of transition matrices are given below.
\medskip
\noindent 2-state SI model
\noindent S= susceptible,I= infected,being immunized and staying infectious for the S people
\noindent row 1,S: $\pi_{11}(p_2), \pi_{12}(p_2)$
\noindent row 2, I : 0,1
\noindent One absorbing state,one source of infection.
\medskip
\noindent 2-state SIS model
\noindent S:susceptible, I infected, can recover, but without being immunized.
\noindent row 1,S: $\pi_{11}(p_2)$, $\pi_{12}(p_2)$
\noindent row 2,I: $p_{21}, p_{22}$, with $p_{21}>0$.
One source of infection, no absorbing state;a non degenerate stationary solution
can exist [see e.g. Allen (1994), Feng et al (2005) for the use of SIS model].
\medskip
\noindent 3-state SIR model
\noindent S=susceptible, I= infected, infectious, not immunized, R=recovered, no longer infectious,immunized.
\noindent row1,S: $\pi_{11}(p_2), \pi_{12}(p_2), \pi_{13}(p_2)$
\noindent row 2, I: 0, $p_{22}, p_{23}$
\noindent row 3, R: 0,0,1
\noindent One absorbing state,one source of infection [see e.g. Tchenchue et al.(2003), Meng,Chen(2008),Jiang et al. (2011), Toda (2020)].
\medskip
\noindent 4-state SIRD model
\noindent S=susceptible, I=infected, not immunized,infectious, R=recovered, no longer infectious, immunized, D=deceased.
\medskip
\noindent row 1, S: $\pi_{11}(p_2), \pi_{12}(p_2), \pi_{13}(p_2), p_{14}$
\noindent row 2, I : 0, $p_{22}, p_{23}, p_{24}$
\noindent row 3, R: 0,0, $p_{33}, p_{34}$
\noindent row 4, D: 0,0,0,1
\noindent One absorbing state, one propagation source.
\medskip
\noindent 4-state (SI)$^2$
\noindent The population is divided into 2 sub-populations, as region 1 \& region 2, male \& female, young \& old. It is easily extended to any number of regions.
\medskip
\noindent $S_j$ =susceptible of type $j$, $I_j$= infected, immunized, infectious of type $j$.
\noindent row 1, $S_1$: $\pi_{11}(p_3,p_4), 0, \pi_{13}(p_3,p_4),0$
\noindent row 2, $S_2$: 0, $\pi_{22}(p_3,p_4), 0, \pi_{24}(p_3,p_4)$
\noindent row 3, $I_1$: 0,0,1,0
\noindent row 4,$I_2$: 0,0,0,1
\noindent Two absorbing states,two propagation sources [see e.g. Feng et al. (2005)].
\medskip
\noindent 4-state SEIR
\noindent S=susceptible
E= exposed, but not yet infectious (there is a latency period), not immunized,
I = infected and infectious, not immunized,
R=recovered,no longer infectious,immunized.
\medskip
\noindent row 1,S: $\pi_{11}(p_3), \pi_{12}(p_3), 0, 0$
\noindent row 2,E: 0, $p_{22}, p_{23}, 0$
\noindent row 3,I: 0, 0, $p_{33}, p_{34}$
\noindent row 4,R: 0,0,0,1
\noindent One absorbing state,one propagation source [see e.g. Zhang,Ma (2003)].
\medskip
\noindent 4-state: S IU ID R
\noindent S=susceptible
\noindent IU:infected,infectious, not immunized,undetected
\noindent ID: infected,infectious, not immunized,detected
\noindent R:recovered,no longer infectious, immunized
\medskip
\noindent row 1, S : $\pi_{11}(p_2,p_3), \pi_{12}(p_2,p_3), \pi_{13}(p_2,p_3), p_{14}$
\noindent row 2, IU: 0, $p_{22}, p_{23}, p_{24}$
\noindent row 3, ID: 0, 0, $p_{33}, p_{34}$
\noindent row 4, R: 0, 0, 0, 1
\noindent One absorbing state, two propagation sources [see e.g. Gourieroux, Jasiak (2020)].
\medskip
These structural models can be extended by considering other states, such as the birth
\footnote{In transition models the state birth is usually introduced to balance the deaths and to provide stationary evolutions of the processes [see e.g. Harko et al. (2014)]. This ad-hoc introduction of births is not relevant at the beginning of the epidemic when the interest is in determining the nonstationary dynamic at the beginning of the epidemic, rather than in the long run equilibrium. Second, there is no increased count of births (known 9 months earlier) in order to offset the
increasing number of deaths due to coronavirus.} to offset the future number of deaths due to coronavirus, the types of medical treatment of patients in hospitals, the severity (asymptomatic (mild), symptomatic, high), or the detection (contact tracing, influenza like illness surveillance, tests, etc) [see, e.g. Verity et al. (2020)]. The models can also be extended by combining the basic models as building blocks to construct a 5-state model such as the SEIRD [see e.g. Korolev(2020)], or S IU ID R D, a 6-state model such as the
S$IU^2$, $ID^2$ , R, or $(SIR)^2$. The structure of the transition matrix can also be modified to account for the possibility that a fraction of recovered individuals is not entirely immunized and can be infected twice.
\medskip
\newpage
\begin{center}{\bf Appendix A.2}\end{center}
\begin{center} {\bf Rational Recursive Equations}
\end{center}
This Appendix shows the exact solution and the exact time discretization of the probability to be infected in a continuous time SI model. We provide below the results for a general one-dimensional Riccati equation in continuous time written on a series $x(t)$. Then, the results can be applied to the special case $x(t)= p_2(t)$.
\medskip
\noindent i) {\bf The differential equation}
\noindent This differential equation is:
$$ dx(t)/dt= - \lambda (x(t)-a) (x(t)-b) /(a-b), $$
\noindent where $\lambda$ is strictly positive.
\medskip
\noindent ii) {\bf The solution}
\noindent Since:
$$ (a-b)/[(x(t)-a)(x(t)-b)]= 1/(x(t)-a) -1/(x(t)-b), $$
\noindent we deduce:
$$ dx(t)[1/(x(t)-a) -1/(x(t)-b)]=- \lambda dt,$$
\noindent and by integration:
$$ |x(t)-a|/|x(t)-b|= exp(- \lambda t) |x(0)-a|/|x(0)-b|.$$
The form of this relation implies that the trajectory $x(t)$ and the starting value $x(0)$ satisfy always the same relationship with respect to a and b, that is $x(t)$ is in the interval (a,b) (resp. below, above), if $x(0)$ is in this interval (resp. below, above). Therefore, we can disregard the absolute values to get:
$$ (x(t)-a)/(x(t)-b) =exp(- \lambda t) (x(0)-a)/(x(0)-b),$$
\noindent for any nonnegative $t$.
This implies a logistic expression for $x(t)$:
$$ x(t)= [a-b k exp(-\lambda t)]/[1- k exp(-\lambda t)],$$
\noindent where: $k= (x(0)-a)/(x(0)-b)$.
\medskip
\noindent iii) {\bf The exact time discretized recursive model}
We deduce that the exact time discretized counterpart corresponds to a rational transform of $x(t-1)$. More precisely, we get:
$$x(t)= \{ a[x(t-1)-b]-b[x(t-1)-a] exp(-\lambda )\}/\{[x(t-1)-b]-[x(t-1)-a] exp(-\lambda)\}.$$
\noindent This rational recursive equation, which is the exact time discetization, differs from the crude Euler discretization.
\medskip
\noindent iv) {\bf Special case}
The results above can be computed for equation (3.4) with:
$ \lambda= \beta >0$, $a=- \alpha/\beta, b=1$. Without an exogenous source of infection: $\alpha=0$ ,the interval $(a,b)$ is the interval (0,1), $x(t)=p_2(t)$ is decreasing and tends to 0 when t tends to infinity, for any starting value $p_2(0)$.
\newpage
\begin{center}
\begin{figure}[h]
\centering
\includegraphics[width=12cm,angle = 0]{Fig1final.pdf}
\caption{Evolution of $p(t)$, SI Model}
\end{figure}
\end{center}
\newpage
\begin{center}
\begin{figure}[h]
\centering
\includegraphics[width=12cm,angle = 0]{Fig2final.pdf}
\caption{Evolution of Changes in $p(t)$, SI Model}
\end{figure}
\end{center}
\newpage
\begin{center}
\begin{figure}[h]
\centering
\includegraphics[width=12cm,angle = 0]{Fig3final.pdf}
\caption{Size of Peak, SI Model}
\end{figure}
\end{center}
\newpage
\begin{center}
\begin{figure}[h]
\centering
\includegraphics[width=12cm,angle = 0]{Fig4final.pdf}
\caption{Time to Inflection, SI Model}
\end{figure}
\end{center}
\newpage
\begin{center}
\begin{figure}[h]
\centering
\includegraphics[width=12cm,angle = 0]{Fig5final.pdf}
\caption{Evolution of $p_2(t)$, SIR Model}
\end{figure}
\end{center}
\newpage
\begin{center}
\begin{figure}[h]
\centering
\includegraphics[width=12cm,angle = 0]{Fig6final.pdf}
\caption{Evolutions of Changes in $p_2(t)$, SIR Model}
\end{figure}
\end{center}
\newpage
\begin{center}
\begin{figure}[h]
\centering
\includegraphics[width=12cm,angle = 0]{Fig7final.pdf}
\caption{Timing of Peak, $a$ varying, SIR Model}
\end{figure}
\end{center}
\newpage
\begin{center}
\begin{figure}[h]
\centering
\includegraphics[width=12cm,angle = 0]{Fig8final.pdf}
\caption{Size of Peak, $b$ varying, SIR Model}
\end{figure}
\end{center}
\newpage
\begin{center}
\begin{figure}[h]
\centering
\includegraphics[width=12cm,angle = 0]{Figfinal9.pdf}
\caption{Three-Wave Infection Pattern}
\end{figure}
\end{center}
\end{document}
| {'timestamp': '2020-06-19T02:08:19', 'yymm': '2006', 'arxiv_id': '2006.10265', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10265'} | arxiv |
\section{Introduction} \label{sect:introduction}
Human body pose estimation from images or video plays a central role in various applications such as health tracking, sign language recognition, and gestural control. This task is challenging due to a wide variety of poses, numerous degrees of freedom, and occlusions. Recent work \cite{DeepHighResolutionPosePaper}\cite{PifPafPaper} has shown significant progress on pose estimation. The common approach is to produce heatmaps for each joint along with refining offsets for each coordinate. While this choice of heatmaps scales to multiple people with minimal overhead, it makes the model for a single person considerably larger than is suitable for real-time inference on mobile phones. In this paper, we address this particular use case and demonstrate significant speedup of the model with little to no quality degradation.
In contrast to heatmap-based techniques, regression-based approaches, while less computationally demanding and more scalable, attempt to predict the mean coordinate values, often failing to address the underlying ambiguity. Newell \etal \cite{stacked_hourglass} have shown that the stacked hourglass architecture gives a significant boost to the quality of the prediction, even with a smaller number of parameters. We extend this idea in our work and use an encoder-decoder network architecture to predict heatmaps for all joints, followed by another encoder that regresses directly to the coordinates of all joints. The key insight behind our work is that the heatmap branch can be discarded during inference, making it sufficiently lightweight to run on a mobile phone.
\section{Model Architecture and Pipeline Design}
\label{sect:architecture}
\subsection{Inference pipeline}
\label{subsect:inference}
During inference, we employ a detector-tracker setup (see Figure \ref{fig:blazepose_pipeline}), which shows excellent real-time performance on a variety of tasks such as hand landmark prediction \cite{MediaPipeHandsAIBlog} and dense face landmark prediction \cite{facemesh}. Our pipeline consists of a lightweight body pose detector followed by a pose tracker network. The tracker predicts keypoint coordinates, the presence of the person on the current frame, and the refined region of interest for the current frame. When the tracker indicates that there is no human present, we re-run the detector network on the next frame.
\begin{figure}
\centering
\includegraphics[width=\linewidth]{BlazePose_pipeline.png}
\caption{\protect\centering Inference pipeline. See text.}
\label{fig:blazepose_pipeline}
\end{figure}
\subsection{Person detector}
The majority of modern object detection solutions rely on the Non-Maximum Suppression (NMS) algorithm for their last post-processing step. This works well for rigid objects with few degrees of freedom. However, this algorithm breaks down for scenarios that include highly articulated poses like those of humans, \eg people waving or hugging. This is because multiple, ambiguous boxes satisfy the intersection over union (IoU) threshold for the NMS algorithm. To overcome this limitation, we focus on detecting the bounding box of a relatively rigid body part like the human face or torso. We observed that in many cases, the strongest signal to the neural network about the position of the torso is the person's face (as it has high-contrast features and has fewer variations in appearance). To make such a person detector fast and lightweight, we make the strong, yet for AR applications valid, assumption that the head of the person should always be visible for our single-person use case.
\begin{wrapfigure}{r}{0pt}
\centering
\includegraphics[width=0.4\linewidth]{Virtuvian_aligned.png}
\caption{\protect\centering Vitruvian man aligned via our detector vs. face detection bounding box. See text for details.}
\label{fig:virtuvian}
\end{wrapfigure}
As a consequence, we use a fast on-device face detector \cite{BlazeFace} as a proxy for a person detector. This face detector predicts additional person-specific alignment parameters: the middle point between the person's hips, the size of the circle circumscribing the whole person, and incline (the angle between the lines connecting the two mid-shoulder and mid-hip points).
\subsection{Topology}
We present a new topology using 33 points on the human body by taking the superset of those used by BlazeFace\cite{BlazeFace}, BlazePalm\cite{MediaPipeHandsAIBlog}, and Coco\cite{CocoPaper}. This allows us to be consistent with the respective datasets and inference networks.
\begin{figure}
\centering
\includegraphics[width=0.5\linewidth]{Topology33.png}
\caption{\protect\centering 33 keypoint topology.}
\label{fig:bb_33topology}
\end{figure}
In contrast with the OpenPose\cite{OpenPosePaper} and Kinect\cite{Kinect} topologies, we use only a minimally sufficient number of keypoints on the face, hands, and feet to estimate rotation, size, and position of the region of interest for the subsequent model. The topology we use is shown in Figure \ref{fig:bb_33topology}. For additional information, please see Appendix A.
\subsection{Dataset}
Compared to the majority of existing pose estimation solutions that detect keypoints using heatmaps, our tracking-based solution requires an initial pose alignment. We restrict our dataset to those cases where either the whole person is visible, or where hips and shoulders keypoints can be confidently annotated. To ensure the model supports heavy occlusions that are not present in the dataset, we use substantial occlusion-simulating augmentation. Our training dataset consists of 60K images with a single or few people in the scene in common poses and 25K images with a single person in the scene performing fitness exercises. All of these images were annotated by humans.
\subsection{Neural network architecture}
The pose estimation component of our system predicts the location of all 33 person keypoints, and uses the person alignment proposal provided by the first stage of the pipeline (Section \ref{subsect:inference}).
We adopt a combined heatmap, offset, and regression approach, as shown in Figure \ref{fig:tracker_net}. We use the heatmap and offset loss only in the training stage and remove the corresponding output layers from the model before running the inference. Thus, we effectively use the heatmap to supervise the lightweight embedding, which is then utilized by the regression encoder network. This approach is partially inspired by Stacked Hourglass approach of Newell et al. \cite{stacked_hourglass}, but in our case, we stack a tiny encoder-decoder heatmap-based network and a subsequent regression encoder network.
\begin{figure}
\centering
\includegraphics[width=0.8\linewidth]{PoseTrackerNet.png}
\caption{Network architecture. See text for details.}
\label{fig:tracker_net}
\end{figure}
We actively utilize skip-connections between all the stages of the network to achieve a balance between high- and low-level features. However, the gradients from the regression encoder are not propagated back to the heatmap-trained features (note the gradient-stopping connections in Figure \ref{fig:tracker_net}). We have found this to not only improve the heatmap predictions, but also substantially increase the coordinate regression accuracy.
\subsection{Alignment and occlusions augmentation}
A relevant pose prior is a vital part of the proposed solution. We deliberately limit supported ranges for the angle, scale, and translation during augmentation and data preparation when training. This allows us to lower the network capacity, making the network faster while requiring fewer computational and thus energy resources on the host device.
Based on either the detection stage or the previous frame keypoints, we align the person so that the point between the hips is located at the center of the square image passed as the neural network input. We estimate rotation as the line $L$ between mid-hip and mid-shoulder points and rotate the image so $L$ is parallel to the y-axis. The scale is estimated so that all the body points fit in a square bounding box circumscribed around the body, as shown in Figure \ref{fig:virtuvian}. On top of that, we apply 10\% scale and shift augmentations to ensure the tracker handles body movements between the frames and distorted alignment.
\begin{wrapfigure}{r}{0pt}
\centering
\includegraphics[height=0.5\linewidth]{upper2_crop.jpg}
\caption{\protect\centering BlazePose results on upper-body case}
\label{fig:upperbody}
\end{wrapfigure}
To support the prediction of invisible points, we simulate occlusions (random rectangles filled with various colors) during training and introduce a per-point visibility classifier that indicates whether a particular point is occluded and if the position prediction is deemed inaccurate. This allows tracking a person constantly even for cases of significant occlusions, like upper body-only or when the majority of person body is out of scene as shown on Figure \ref{fig:upperbody}.
\section{Experiments} \label{sect:experiments}
To evaluate our model's quality, we chose OpenPose \cite{OpenPosePaper} as a baseline. To that end, we manually annotated two in-house datasets of 1000 images, each with 1--2 people in the scene. The first dataset, referred to as AR dataset, consist of a wide variety of human poses in the wild, while the second is comprised of yoga/fitness poses only. For consistency, we only used MS Coco \cite{CocoPaper} topology with 17 points for evaluation, which is a common subset of both OpenPose and BlazePose. As an evaluation metric, we use the Percent of Correct Points with 20\% tolerance ([email protected]) (where we assume the point to be detected correctly if the 2D Euclidean error is smaller than 20\% of the corresponding person's torso size). To verify the human baseline, we asked two annotators to re-annotate the AR dataset independently and obtained an average [email protected] of 97.2.
\begin{table}[ht]
\begin{center}
\ra{1.2}
\begin{tabular}{llll}
\toprule
\thead{Model} & \thead{FPS} & \thead{AR Dataset, \\ [email protected]} & \thead{Yoga Dataset, \\ [email protected]} \\
\midrule
OpenPose (body only) & 0.4\tablefootnote{Desktop CPU with 20 cores (Intel i9-7900X)} & \textbf{87.8} & 83.4 \\
BlazePose Full & 10\tablefootnote{Pixel 2 Single Core via XNNPACK backend\label{XNNPACK_EVAL}} & 84.1 & \textbf{84.5} \\
BlazePose Lite & \textbf{31}\textsuperscript{\getrefnumber{XNNPACK_EVAL}} & 79.6 & 77.6 \\
\bottomrule
\end{tabular}
\end{center}
\caption{BlazePose vs OpenPose}
\label{tbl:more_speed}
\end{table}
We trained two models with different capacities: BlazePose Full (6.9 MFlop, 3.5M Params) and BlazePose Lite (2.7 MFlop, 1.3M Params). Although our models show slightly worse performance than the OpenPose model on the AR dataset, BlazePose Full outperforms OpenPose on Yoga/Fitness use cases. At the same time, BlazePose performs 25--75 times faster on a \emph{single mid-tier phone CPU} compared to OpenPose on a \emph{20 core desktop} CPU\cite{OpenPoseBenchmark} depending on the requested quality.
\section{Applications} \label{sect:applications}
\begin{figure}
\centering
\includegraphics[width=0.49\linewidth, height=0.49\linewidth]{yoga1.png}
\includegraphics[width=0.49\linewidth, height=0.49\linewidth]{yoga2.png}
\includegraphics[width=0.49\linewidth, height=0.49\linewidth]{jumper1_crop.png}
\includegraphics[width=0.49\linewidth, height=0.49\linewidth]{dancer2_crop.png}
\caption{\protect\centering BlazePose results on yoga and fitness poses.}
\label{fig:yoga1}
\end{figure}
We developed this new, on-device, single person-specific human pose estimation model to enable various performance-demanding use cases such as Sign Language, Yoga/Fitness tracking and AR. This model works in near-realtime on a mobile CPU and can be sped up to super-realtime latency on a mobile GPU. As its 33 keypoint topology is consistent with BlazeFace\cite{BlazeFace} and BlazePalm\cite{MediaPipeHandsAIBlog}, it can be a backbone for subsequent hand pose\cite{MediaPipeHandsAIBlog} and facial geometry estimation\cite{facemesh} models.
Our approach natively scales to a bigger number of keypoints, 3D support, and additional keypoint attributes, since it is not based on heatmaps/offset maps and therefore does not require an additional full-resolution layer per each new feature type.
{\small
\bibliographystyle{ieee_fullname}
| {'timestamp': '2020-06-19T02:06:13', 'yymm': '2006', 'arxiv_id': '2006.10204', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10204'} | arxiv |
\section{Introduction}
\vspace*{-2mm}
The overparameterization of modern deep neural networks (DNNs) has resulted in not only remarkably good generalization performance on unseen data \cite{46649,neyshabur2018the,belkin2019reconciling} but also guarantees
that gradient descent learning can find the global minimum of their highly nonconvex loss functions \cite{du2018gradient, NIPS2019_8893, allen2019learning, zou2018stochastic, arora2019fine}.
From these successes, a natural question arises: What happens when we take overparameterization to the limit by allowing the width of a DNN's hidden layers to go to infinity?
Surprisingly, the analysis of such an (impractical) DNN becomes analytically tractable.
Indeed, recent work has shown that the training dynamics of (infinite-width) DNNs under gradient flow is captured by a constant kernel called the \emph{Neural Tangent Kernel} (NTK) that evolves according to a linear ordinary differential equation (ODE) \cite{jacot2018neural,lee2019wide,arora2019exact}.
Every DNN architecture and parameter initialization produces a distinct NTK. The original NTK was derived from the Multilayer Perceptron (MLP)\cite{jacot2018neural} and was soon followed by kernels derived from Convolutional Neural Networks (CNTK) \cite{arora2019exact, yang2019scaling}, Residual DNNs \cite{huang2020deep}, and Graph Convolutional Neural Networks (GNTK) \cite{du2019graph}. In \cite{yang2020tensor}, a general strategy to obtain the NTK of any architecture is provided.
{\bf\em In this paper, we extend the NTK concept to the important class of overparametrized Recurrent Neural Networks (RNNs)}, a fundamental DNN architecture for processing sequential data.
We show that RNN in its infinite-width limit converges to a kernel that we dub the {\bf\em Recurrent Neural Tangent Kernel} (RNTK). The RNTK provides high performance for various machine learning tasks, and an analysis of the properties of the kernel provides useful insights into the behavior of RNNs in the following overparametrized regime. In particular, we derive and study the RNTK to answer the following theoretical questions:
{\bf\em Q: Can the RNTK extract long-term dependencies between two data sequences?}~
RNNs are known to underperform at learning long-term dependencies due to the gradient vanishing or exploding \cite{279181}.
Attempted ameliorations have included orthogonal weights \cite{arjovsky2016unitary, jing2017tunable, henaff2016recurrent} and gating such as in Long Short-Term Memory (LSTM) \cite{hochreiter1997long} and Gated Recurrent Unit (GRU) \cite{gru} RNNs.
We demonstrate that the RNTK can detect long-term dependencies with proper initialization of the hyperparameters, and moreover, we show how the dependencies are extracted through time via different hyperparameter choices.
{\bf\em Q: Do the recurrent weights of the RNTK reduce its representation power compared to other NTKs?}~
An attractive property of an RNN that is shared by the RNTK is that it can deal with sequences of different lengths via weight sharing through time.
This enables the reduction of the number of learnable parameters and thus more stable training at the cost of reduced representation power.
We prove the surprising fact that employing tied vs.\ untied weights in an RNN {\em does not} impact the analytical form of the RNTK.
{\bf\em Q: Does the RNTK generalize well?}~
A recent study has revealed that the use of an SVM classifier with the NTK, CNTK, and GNTK kernels outperforms other classical kernel-based classifiers and trained finite DNNs on small data sets (typically fewer than 5000 training samples) \cite{lee2020finite,arora2019exact,Arora2020Harnessing,du2019graph}.
We extend these results to RNTKs to demonstrate that the RNTK outperforms a variety of classic kernels, NTKs {\em and} finite RNNs for time series data sets in both classification and regression tasks.
Carefully designed experiments with data of varying lengths demonstrate that the RNTK's performance accelerates beyond other techniques as the difference in lengths increases.
Those results extend the empirical observations from \cite{arora2019exact,Arora2020Harnessing,du2019graph,lee2020finite} into finite DNNs, NTK, CNTK, and GNTK comparisons by observing that their performance-wise ranking depends on the employed DNN architecture.
\iffalse
\sa{ here is what I think we should say here: 1. \cite{Arora2020Harnessing,du2019graph} have found that NTK,CNTK and GNTK outperforms other methods in small datasets 2. Meanwhile, \cite{arora2019exact} found that CNTK underperform trained finite CNNs in large data sets (CFAR 10) 3. \cite{lee2020finite} did experiments on large datasets and found that fully connected networks also outperforms finite fully connected networks in large datasets, but CNTK underperform finite ones, consistent with \cite{arora2019exact} result 4. Conclusion: the ability of generalization is related to network architecture 5. our story: on small datasets, RNTK outperforms finite RNNs. ALSO, it outperforms other kernels. So the main point is that we say what is this architecture dependency (RNTK > finite) and meanwhile, it outperforms other kernels }
\sa{in addition to that 56 datasets which data are of the same length, we provide another experiment when data are of different length and we show that RNTK is better there too compared to other kernels when zero padding is used.}
\randall{maybe we put only 2 3 sentences here and refer to the appendix for the bigger paragraph with details ?} \jw{I think the transition is OK}
\fi
We summarize our contributions as follows:
{\bf [C1]}
We derive the analytical form for the RNTK of an overparametrized RNN at initialization using rectified linear unit (ReLU) and error function (erf) nonlinearities for arbitrary data lengths and number of layers (Section \ref{RNTKconvergence_sinlelayer}).
{\bf [C2]}
We prove that the RNTK remains constant during (overparametrized) RNN training and that the dynamics of training are simplified to a set of ordinary differential equations (ODEs) (Section \ref{stability}).
{\bf [C3]}
When the input data sequences are of equal length, we show that the RNTKs of weight-tied and weight-untied RNNs converge to the same RNTK (Section~\ref{sec:weight-sharing}).
{\bf [C4]}
Leveraging our analytical formulation of the RNTK, we empirically demonstrate how correlations between data at different times are weighted by the function learned by an RNN for different sets of hyperparameters. We also offer practical suggestions for choosing the RNN hyperparameters for deep information propagation through time (Section~\ref{sensitiviy}).
{\bf [C5]}
We demonstrate that the RNTK is eminently practical by showing its superiority over classical kernels, NTKs, and finite RNNs
in exhaustive experiments on time-series classification and regression with both synthetic and 56 real-world data sets (Section 4).
\vspace*{-2mm}
\section{Background and Related Work}
\vspace*{-2mm}
{\bf Notation.}
We denote $ [ n ] = \{1, \dots, n\}$, and ${\bm{I}}_d$ the identity matrix of size $d$. $[{\bm{A}}]_{i,j}$ represents the $(i,j)$-th entry of a matrix, and similarly $[{\bm{a}}]_i$ represents the $i$-th entry of a vector.
We use $\phi(\cdot): \mathbb{R} \rightarrow \mathbb{R}$ to represent the activation function that acts coordinate wise on a vector and $\phi'$ to denote its derivative.
We will often use the rectified linear unit (ReLU) $\phi(x) = \mathrm{max}(0,x)$ and error function (erf) $\phi(x) = \frac{2}{\sqrt{\pi}} \int_0^x e^{-z^2} dz$ activation functions.
$\mathcal{N}({\bm{\mu}}, {\bm{\Sigma}})$ represents the multidimensional Gaussian distribution with the mean vector ${\bm{\mu}}$ and the covariance matrix ${\bm{\Sigma}}$.
{\bf Recurrent Neural Networks (RNNs).}~
Given an input sequence data
${\bm{x}} = \{{\bm{x}}_t\}_{t = 1}^{T}$ of length $T$ with data at time $t$, ${\bm{x}}_t\in\mathbb{R}^m$, a {\em simple RNN} \cite{ElmanRNN} performs the following recursive computation at each layer $\ell$ and each time step $t$
\begin{align}
{\bm{g}}^{\left(\ell,t\right)}({\bm{x}}) = {\bm{W}}^{\left(\ell\right)}{\bm{h}}^{\left(\ell,t-1\right)}({\bm{x}}) + {\bm{U}}^{\left(\ell\right)}{\bm{h}}^{\left(\ell-1,t\right)}({\bm{x}}) + {\bm{b}}^{\left(\ell\right)}, \hspace{20pt}
{\bm{h}}^{\left(\ell,t\right)}({\bm{x}}) &= \phi\left( {\bm{g}}^{\left(\ell,t\right)}({\bm{x}}) \right),
\nonumber
\end{align}
where ${\bm{W}}^{(\ell)} \in \mathbb{R}^{n \times n}$, $ {\bm{b}}^{(\ell)} \in \mathbb{R}^{n}$ for $\ell \in [L]$, $ {\bm{U}}^{(1)} \in \mathbb{R}^{n \times m} $ and $ {\bm{U}}^{(\ell)} \in \mathbb{R}^{n \times n}$ for $\ell \ge 2$ are the RNN parameters.
${\bm{g}}^{\left(\ell,t\right)}({\bm{x}})$ is the pre-activation vector at layer $\ell$ and time step $t$, and
${\bm{h}}^{\left(\ell,t\right)}({\bm{x}})$ is the after-activation (hidden state).
For the input layer $\ell=0$, we define ${\bm{h}}^{\left(0,t\right)}({\bm{x}}) := {\bm{x}}_t$.
${\bm{h}}^{(\ell,0)}({\bm{x}})$ as the initial hidden state at layer $\ell$ that must be initialized to start the RNN recursive computation.
The output of an $L$-hidden layer RNN with linear read out layer is achieved via
\begin{align}
f_\theta({\bm{x}}) &= {\bm{V}} {\bm{h}}^{(L,T)}({\bm{x}}) , \nonumber
\end{align}
where ${\bm{V}} \in \mathbb{R}^{d \times n}$. Figure~\ref{fig:rnn} visualizes an RNN unrolled through time.
\begin{figure}[t!]
\centering
\begin{minipage}{0.7\linewidth}
\resizebox{0.9\textwidth}{!}{%
\begin{tikzpicture}[object/.style={thin,double,<->}]
\tikzstyle{main}=[rectangle, minimum width = 16.3mm, minimum height = 7mm, thick, draw =black!80, node distance = 5mm]
\tikzstyle{main2}=[circle, minimum size = 10mm, thick, draw =black!80, node distance = 5mm]
\tikzstyle{connect}=[-latex, thick]
\tikzstyle{box}=[rectangle, draw=black!100]
\node[main] (hlt) [] {\small${\bm{h}}^{(2,2)}$};
\node[main] (hltm) [left=1.3cm of hlt] {\small ${\bm{h}}^{(2,1)}({\bm{x}})$};
\node[main] (hltp) [right=1.3cm of hlt] {\small ${\bm{h}}^{(2,3)}({\bm{x}})$};
\node[main] (hlmt) [below=0.5cm of hlt] {\small ${\bm{h}}^{(1,2)}({\bm{x}})$};
\node[main] (hlmtm) [below=0.5cm of hltm] {\small ${\bm{h}}^{(1,1)}({\bm{x}})$};
\node[main] (hlmtp) [below=0.5cm of hltp] {\small ${\bm{h}}^{(1,3)}({\bm{x}})$};
\coordinate[right=0.8cm of hltp] (hltpp);
\coordinate[right=0.8cm of hlmtp] (hlmtpp);
%
%
\coordinate[above=0.5cm of hltm] (hlptm);
\coordinate[above=0.5cm of hlt] (hlpt);
\coordinate[above=0.5cm of hltp] (hlptp);
\path (hltm) edge [connect] node[above] {\small${\bm{W}}^{(2)}$}(hlt)
(hlt) edge [connect] node[above] {\small${\bm{W}}^{(2)}$}(hltp)
(hlmtm) edge [connect] node[above] {\small${\bm{W}}^{(1)}$}(hlmt)
(hlmt) edge [connect] node[above] {\small${\bm{W}}^{(1)}$}(hlmtp)
(hlmt) edge [connect] node[above] {\small${\bm{W}}^{(1)}$} (hlmtp)
(hltp) edge [connect] (hltpp)
(hlmtp) edge [connect] (hlmtpp)
%
%
(hltm) edge [connect] (hlptm)
(hlt) edge [connect] (hlpt)
(hltp) edge [connect] (hlptp)
%
(hlmtm) edge [connect] node[right] {\small${\bm{U}}^{(2)}$}(hltm)
(hlmt) edge [connect] node[right] {\small${\bm{U}}^{(2)}$}(hlt)
(hlmtp) edge [connect] node[right] {\small${\bm{U}}^{(2)}$} (hltp)
;
\node[rectangle, inner sep=.5mm,draw=black!100, fit= (hlt), fill=blue,opacity=.2](t) {};
\node[rectangle, inner sep=1.7mm,draw=black!100, fit= (hltm)(hltp)(hltpp), fill=red,opacity=.2](t) {};
\node[main] (hltz) [left=1.3cm of hltm] {\small ${\bm{h}}^{(2,0)}({\bm{x}})$};
\node[main] (hlmtz) [left=1.3cm of hlmtm] {\small ${\bm{h}}^{(1,0)}({\bm{x}})$};
\path (hltz) edge [connect] node[above] {\small${\bm{W}}^{(2)}$}(hltm)
(hlmtz) edge [connect] node[above] {\small${\bm{W}}^{(1)}$}(hlmtm)
;
\node[rectangle, inner sep=1.mm,draw=black!100, fit= (hltz), fill=green,opacity=.2](t) {};
\node[rectangle, inner sep=1.mm,draw=black!100, fit= (hlmtz), fill=green,opacity=.2](t) {};
\node[main] (xtm) [below=0.5cm of hlmtm] {\small ${\bm{x}}_{1}$};
\node[main] (xt) [below=0.5cm of hlmt] {\small ${\bm{x}}_{2}$};
\node[main] (xtp) [below=0.5cm of hlmtp] {\small ${\bm{x}}_{3}$};
\path (xtm) edge [connect] node[right] {\small${\bm{U}}^{(1)}$}(hlmtm)
(xt) edge [connect] node[right] {\small${\bm{U}}^{(1)}$}(hlmt)
(xtp) edge [connect] node[right] {\small${\bm{U}}^{(1)}$}(hlmtp);
\end{tikzpicture}}
\end{minipage}
\begin{minipage}{0.24\linewidth}
\caption{ \small
Visualization of a simple RNN that highlights a cell (purple), a layer (red) and the initial hidden state of each layer (green). (Best viewed in color.)
\vspace{-3mm}
}
\label{fig:rnn}
\end{minipage}
\end{figure}
{\bf Neural Tangent Kernel (NTK).}~
Let $f_{\theta}({\bm{x}}) \in \mathbb{R}^d$ be the output of a DNN with parameters $\theta$. For two input data sequences ${\bm{x}}$ and ${\bm{x}}'$, the NTK is defined as \cite{jacot2018neural}
\begin{align}
\widehat{\Theta}_s({\bm{x}},{\bm{x}}') = \langle \nabla_{\theta_s}f_{\theta_s}({\bm{x}}) , \nabla_{\theta_s}f_{\theta_s}({\bm{x}}')\rangle, \nonumber
\end{align}
where $f_{\theta_s}$ and $\theta_s$ are the network output and parameters during training at time s.\footnote{We use $s$ to denote time here, since $t$ is used to index the time steps of the RNN inputs.
} Let $\mathcal{X}$ and $\mathcal{Y}$ be the set of training inputs and targets, $\ell(\widehat{y},y): \mathbb{R}^d\times \mathbb{R}^d \rightarrow \mathbb{R}^+$ be the loss function, and $\mathcal{L} = \frac{1}{{|\mathcal{X}|} } \sum_{({\bm{x}},{\bm{y}}) \in \mathcal{X}\times \mathcal{Y}} \ell(f_{\theta_s}({\bm{x}}), {\bm{y}}) $ be the the empirical loss. The evolution of the parameters $\theta_s$ and output of the network $f_{\theta_s}$ on a test input using gradient descent with infinitesimal step size (a.k.a gradient flow) with learning rate $\eta$ is given by
\begin{align}
\frac{\partial \theta_s}{\partial s} &= -\eta\nabla_{\theta_s} f_{\theta_s}(\mathcal{X})^T \nabla_{f_{\theta_s}(\mathcal{X})} \mathcal{L} \label{ODE1} \\
\frac{\partial f_{\theta_s}({\bm{x}})}{\partial s} &= -\eta \nabla_{\theta_s}f_{\theta_s}({\bm{x}}) \nabla_{\theta_s}f_{\theta_s}(\mathcal{X})^T\nabla_{f_{\theta_s}(\mathcal{X})} \mathcal{L} = -\eta\widehat{\Theta}_s({\bm{x}},\mathcal{X}) \nabla_{f_{\theta_s}(\mathcal{X})} \mathcal{L}.
\label{ODE2}
\end{align}
Generally, $ \widehat{\Theta}_s({\bm{x}},{\bm{x}}')$, hereafter referred to as the empirical NTK, changes over time during training, making the analysis of the training dynamics difficult.
When $f_{\theta_s}$ corresponds to an infinite-width MLP, \cite{jacot2018neural} showed that $\widehat{\Theta}_s({\bm{x}},{\bm{x}}')$ converges to a limiting kernel at initialization and stays constant during training, i.e.,
\begin{align}
\underset{n \rightarrow \infty}{\mathrm{lim}} \widehat{\Theta}_s({\bm{x}},{\bm{x}}') = \underset{n \rightarrow \infty}{\mathrm{lim}} \widehat{\Theta}_0({\bm{x}},{\bm{x}}') := \Theta({\bm{x}},{\bm{x}}') \,\,\,\, \forall s\,, \nonumber
\end{align}
which is equivalent to replacing the outputs of the DNN by their first-order Taylor expansion in the parameter space \cite{lee2019wide}. With a mean-square error (MSE) loss function, the training dynamics in (\ref{ODE1}) and (\ref{ODE2}) simplify to a set of linear ODEs, which coincides with the training dynamics of kernel ridge regression with respect to the NTK when the ridge term goes to zero.
A nonzero ridge regularization can be conjured up by adding a regularization term $\frac{\lambda^2}{2} \| \theta_s - \theta_0 \|_2^2$ to the empirical loss \cite{hu2019simple}.
\vspace*{-2mm}
\section{The Recurrent Neural Tangent Kernel}
\vspace*{-2mm}
We are now ready to derive the RNTK. We first prove the convergence of an RNN at initialization to the RNTK in the infinite-width limit and discuss various insights it provides. We then derive the convergence of an RNN after training to the RNTK.
Finally, we analyze the effects of various hyperparameter choices on the RNTK.
Proofs of all of our results are provided in the Appendices.
\vspace*{-2mm}
\subsection{RNTK for an Infinite-Width RNN at Initialization}
\label{RNTKconvergence_sinlelayer}
\vspace*{-2mm}
First we specify the following parameter initialization scheme that follows previous work on NTKs~\cite{jacot2018neural}, which is crucial to our convergence results:
\begin{gather}
\hspace{-6pt}{\bm{W}}^{(\ell)} \hspace{-2pt}=\hspace{-2pt} \frac{\sigma_w^{\ell}}{\sqrt{n}} {\mathbf{W}}^{(\ell)},\,\,\,\,
{\bm{U}}^{(1)} \hspace{-2pt}=\hspace{-2pt} \frac{\sigma_u^1}{\sqrt{m}}{\mathbf{U}}^{(1)},\,\,\,\,
{\bm{U}}^{(\ell)} \hspace{-2pt}=\hspace{-2pt} \frac{\sigma_u^{\ell}}{\sqrt{n}} {\mathbf{U}}^{(\ell)} ( \ell \hspace{-2pt}\ge\hspace{-2pt} 2 ),\,\,\,\,
{\bm{V}} \hspace{-2pt}=\hspace{-2pt} \frac{\sigma_v}{\sqrt{n}} {\mathbf{V}},\,\,\,\,
{\bm{b}}^{(\ell)} \hspace{-2pt}=\hspace{-2pt} \sigma_b {\mathbf{b}}^{(\ell)}\,,\label{eq:ntk-init-1}
\end{gather}
where
\begin{align}
[{\mathbf{W}}^{\ell}]_{i,j},
\,\,
[{\mathbf{U}}^{(\ell)}]_{i,j},
\,\,
[{\mathbf{V}}]_{i,j},
\,\,
[{\mathbf{b}}^{(\ell)}]_i \sim \mathcal{N}(0,1)\,.\label{eq:ntk-init-2}
\end{align}
We will refer to~(\ref{eq:ntk-init-1}) and~(\ref{eq:ntk-init-2}) as the {\it NTK initialization}. The choices of the hyperparameters $\sigma_w$, $\sigma_u$, $\sigma_v$ and $\sigma_b$ can significantly impact RNN performance, and we discuss them in detail in Section \ref{sensitiviy}.
For the initial (at time $t=0$) hidden state at each layer $\ell$, we set ${\bm{h}}^{(\ell,0)}({\bm{x}})$ to an i.i.d.\ copy of $\mathcal{N}(0, \sigma_h)$~\cite{wang2018a}
. For convenience, we collect all of the learnable parameters of the RNN into $\theta = \mathrm{vect}\big[\{\{{\mathbf{W}}^{(\ell)},{\mathbf{U}}^{(\ell)},{\mathbf{b}}^{(\ell)}\}_{\ell = 1}^{L} , {\mathbf{V}} \} \big]$.
The derivation of the RNTK at initialization is based on the correspondence between Gaussian initialized, infinite-width DNNs and Gaussian Processes (GPs), known as the DNN-GP. In this setting every coordinate of the DNN output tends to a GP as the number of units/neurons in the hidden layer (its width) goes to infinity. The corresponding DNN-GP kernel is computed as
\begin{align}
\mathcal{K}({\bm{x}},{\bm{x}}') = \mathop{{\mathbb{E}}}_{\theta \sim \mathcal{N}}\big[ [f_{\theta}({\bm{x}})]_i \boldsymbol{\cdot} [f_{\theta}({\bm{x}}')]_i \big], \hspace{1mm} \forall i \in [d]. \label{NNGP}
\end{align}
First introduced for a single-layer, fully-connected neural network by \cite{neal1996priors}, recent works on NTKs have extended the results for various DNN architectures \cite{lee2017deep, duvenaud2014avoiding,novak2018bayesian, garrigaalonso2018deep,yang2019tensor}, where in addition to the output, all pre-activation layers of the DNN tends to a GPs in the infinite-width limit.
In the case of RNNs, each coordinate of the RNN pre-activation ${\bm{g}}^{(\ell,t)}({\bm{x}})$ converges to a centered GP depending on the inputs with kernel
\begin{align}
\Sigma^{(\ell,t,t')}({\bm{x}},{\bm{x}}') = \mathop{{\mathbb{E}}}_{\theta \sim \mathcal{N}} \big[ [{\bm{g}}^{(\ell,t)}({\bm{x}})]_i \boldsymbol{\cdot} [{\bm{g}}^{(\ell,t')}{({\bm{x}}')}]_i \big]\, \,\, \forall i \in [n]. \label{eq:rnn-gp}
\end{align}
As per \cite{yang2019scaling}, the gradients of random infinite-width DNNs computed during backpropagation are also Gaussian distributed. In the case of RNNs, every coordinate of the vector ${\bm{\delta}}^{(\ell,t)}({\bm{x}}) := \sqrt{n} \big( \nabla_{{\bm{g}}^{(\ell,t)}({\bm{x}})} f_{\theta}({\bm{x}}) \big)$ converges to a GP with kernel
\begin{align}
\Pi^{(\ell,t,t')}({\bm{x}},{\bm{x}}') = \mathop{{\mathbb{E}}}_{\theta \sim \mathcal{N}} \big[ [{\bm{\delta}}^{(\ell,t)}({\bm{x}})]_i \boldsymbol{\cdot} [{\bm{\delta}}^{(\ell,t')}({\bm{x}}')]_i \big]\, \,\, \forall i \in [n].\label{eq:rnn-ggp}
\end{align}
Both convergences occur independently of the coordinate index $i$ and for inputs of possibly different lengths, i.e., $T\neq T'$.
With (\ref{eq:rnn-gp}) and (\ref{eq:rnn-ggp}), we now prove that an infinite-width RNN at initialization converges to the limiting RNTK.
\begin{thm} \label{RNTK}
Let ${\bm{x}}$ and ${\bm{x}}'$ be two data sequences of potentially different lengths $T$ and $T'$, respectively. Without loss of generality, assume that $T \leq T'$, and let $ \tau := T' - T$. Let $n$ be the number of units in the hidden layers, the empirical RNTK for an $L$-layer RNN with NTK initialization converges to the following limiting kernel as $n \rightarrow \infty$
\begin{align}
\underset{n \rightarrow \infty}{\mathrm{lim}} \widehat{\Theta}_0({\bm{x}},{\bm{x}}') = \Theta({\bm{x}},{\bm{x}}') = \Theta^{(L,T,T')} ({\bm{x}},{\bm{x}}')\otimes {\bm{I}}_d\,,
\end{align}
where
\begin{align}
\Theta^{(L,T,T')}({\bm{x}},{\bm{x}}') = \left( \sum_{\ell = 1}^{L} \sum_{t = 1}^{T} \left( \Pi^{(\ell,t,t+ \tau)}({\bm{x}},{\bm{x}}') \boldsymbol{\cdot} \Sigma^{(\ell,t,t+ \tau)}({\bm{x}},{\bm{x}}') \right) \right) + \mathcal{K}({\bm{x}},{\bm{x}}')\,,\label{eq:rntk}
\end{align}
with
$\mathcal{K}({\bm{x}},{\bm{x}}')$,
$\Sigma^{(\ell,t,t+ \tau)}({\bm{x}},{\bm{x}}')$, and
$\Pi^{(\ell,t,t+ \tau)}({\bm{x}},{\bm{x}}')$ defined in
(\ref{NNGP})--(\ref{eq:rnn-ggp}).
\end{thm}
{\bf Remarks.}~
Theorem \ref{RNTK} holds generally for any two data sequences, including different lengths ones.
This highlights the RNTK's ability to produce a similarity measure $\Theta({\bm{x}},{\bm{x}}')$ even if the inputs are of different lengths, without resorting to heuristics such as zero padding the inputs to the to the max length of both sequences.
Dealing with data of different length is in sharp contrast to common kernels such as the classical radial basis functions, polynomial kernels, and current NTKs. We showcase this capability below in Section~\ref{sec:exp}.
To visualize Theorem~\ref{RNTK}, we plot in the left plot in Figure~\ref{fig:convergence} the convergence of a single layer, sufficiently wide RNN to its RNTK with the two simple inputs ${\bm{x}}=\{1,-1,1\}$ of length 3 and ${\bm{x}}'=\{{\rm cos}(\alpha) , {\rm sin}(\alpha)\}$ of length 2, where $\alpha= [0, 2 \pi]$.
For an RNN with a sufficiently large hidden state ($n=1000$), we see clearly that it converges to the RNTK ($n=\infty$).
\begin{figure}[t]
\begin{minipage}{0.5\linewidth}
\begin{minipage}{0.1\linewidth}
\rotatebox{90}{$\,\,\,\,\,\,\,\,\,\, \widehat{\Theta}_0(x,x')$}
\end{minipage}
\begin{minipage}{0.60\linewidth}
\centering
\includegraphics[width=\textwidth]{./figures/convergence_different_length.pdf}\\
$\alpha$
\end{minipage}
\end{minipage}
\begin{minipage}{0.5\linewidth}
\begin{minipage}{0.1\linewidth}
\rotatebox{90}{\small $\,\,\,\,\,\,\,\,\,\,\,\,\,\, \log(\|\frac{\Theta-\widehat{\Theta}_0}{\Theta} \|)$}
\end{minipage}
\begin{minipage}{0.60\linewidth}
\centering
\includegraphics[width=\textwidth]{./figures/convergence_same_length.pdf}\\
$\log(n)$
\end{minipage}
\end{minipage}
\caption{
\small Empirical demonstration of a wide, single-layer RNN converging to its limiting RNTK. {\bf Left}: convergence for a pair of different-length inputs ${\bm{x}} = \{ 1,-1,1 \}$ and ${\bm{x}}' = \{\cos(\alpha), \sin(\alpha)\}$, with varying $\alpha = [0,2\pi]$.
The vertical axis corresponds to the RNTK values for different values of $\alpha$. {\bf Right}: convergence of weight-tied and weight-untied single layer RNN to the same limiting RNTK with increasing width (horizontal axis). The vertical axis corresponds to the average of the log-normalized error between the empirical RNTK computed using finite RNNs and the RNTK for 50 Gaussian normal signals of length $T = 5$.
}
\label{fig:convergence}
\end{figure}
{\bf RNTK Example for a Single-Layer RNN.}~
We present a concrete example of Theorem~\ref{RNTK} by showing how to recursively compute the RNTK for a single-layer RNN; thus we drop the layer index for notational simplicity.
{\bf\em We compute and display the RNTK for the general case of a multi-layer RNN in
Appendix \ref{appendix:multi-layer}}.
To compute the RNTK $\Theta^{(T,T')}({\bm{x}},{\bm{x}}')$, we need to compute the GP kernels $\Sigma^{(t,t+ \tau)}({\bm{x}},{\bm{x}}')$ and $\Pi^{(t,t+ \tau)}({\bm{x}},{\bm{x}}')$.
We first define the operator $\mathrm{V}_{\phi}\big[{\bm{K}} \big]$ that depends on the nonlinearity $\phi(\cdot)$ and a positive semi-definite matrix ${\bm{K}}\in\mathbb{R}^{2 \times 2}$
\begin{align} \label{op:defin}
\mathrm{V}_{\phi}\big[{\bm{K}} \big] = {\mathbb{E}} [\phi({\textnormal{z}}_1)\boldsymbol{\cdot}\phi({\textnormal{z}}_2)], \qquad ({\textnormal{z}}_1,{\textnormal{z}}_2) \sim \mathcal{N}(0,{\bm{K}}) \,.
\end{align}
Following \cite{yang2019scaling},
we obtain the analytical recursive formula for the GP kernel $\Sigma^{(t,t+ \tau)}({\bm{x}},{\bm{x}}')$ for a single layer RNN as
\begin{align}
\Sigma^{(1,1)}({\bm{x}},{\bm{x}}') &= \sigma_w^2\sigma_h^2 1_{({\bm{x}} = {\bm{x}}')} + \frac{\sigma_u^2 }{m} \langle {\bm{x}}_{1},{\bm{x}}'_{1} \rangle + \sigma_b^2 \label{rec:1}\\
\Sigma^{(t,1)}({\bm{x}},{\bm{x}}') &= \frac{\sigma_u^2 }{m} \langle {\bm{x}}_{t},{\bm{x}}'_{1} \rangle + \sigma_b^2 && t > 1\\ \Sigma^{(1,t')}({\bm{x}},{\bm{x}}') &= \frac{\sigma_u^2 }{m} \langle {\bm{x}}_{1},{\bm{x}}'_{t'} \rangle + \sigma_b^2 && t' > 1\\
\Sigma^{(t,t')}({\bm{x}},{\bm{x}}') &= \sigma_w^2\mathrm{V}_{\phi}\big[ {\bm{K}}^{(t,t')}({\bm{x}},{\bm{x}}') \big]+ \frac{\sigma_u^2 }{m} \langle {\bm{x}}_{t},{\bm{x}}'_{t'} \rangle + \sigma_b^2 \hspace{1mm} \label{rec:2} && t,t'>1\\
\mathcal{K}({\bm{x}},{\bm{x}}') &= \sigma_v^2\mathrm{V}_{\phi}\big[ {\bm{K}}^{(T+1,T'+1)}({\bm{x}},{\bm{x}}') \big], \label{rec:3}
\end{align}
where
\begin{align} \label{Kdef}
{\bm{K}}^{(t,t')}({\bm{x}},{\bm{x}}') &= \left[ {\begin{array}{cc} \Sigma^{(t-1,t-1)}({\bm{x}},{\bm{x}}) & \Sigma^{(t-1,t'-1)}({\bm{x}},{\bm{x}}') \\ \Sigma^{(t-1 ,t'-1)}({\bm{x}},{\bm{x}}') & \Sigma^{(t'-1,t'-1)}({\bm{x}}',{\bm{x}}') \\ \end{array} } \right].
\end{align}
Similarly, we obtain the analytical recursive formula for the GP kernel $\Pi^{(t,t+ \tau)}({\bm{x}},{\bm{x}}')$ as
\begin{align}
\Pi^{(T,T')}({\bm{x}},{\bm{x}}') &= \sigma_v^2 \mathrm{V}_{\phi'}\big[ {\bm{K}}^{(T+1,T+\tau+1)} ({\bm{x}},{\bm{x}}') \big]\\
\Pi^{(t,t+\tau)}({\bm{x}},{\bm{x}}') &= \sigma_w^2 \mathrm{V}_{\phi'}\big[ {\bm{K}}^{(t+1,t+\tau+1)} ({\bm{x}},{\bm{x}}') \big]\Pi^{(t+1,t+1+\tau)}({\bm{x}},{\bm{x}}') &&t \in [T-1] \label{rec:4}\\
\Pi^{(t,t')}({\bm{x}},{\bm{x}}') &= 0 &&t'-t \ne \tau.
\end{align}
For $\phi = \mathrm{ReLU}$ and $\phi = \mathrm{erf}$, we provide analytical expressions for $\mathrm{V}_{\phi}\big[{\bm{K}} \big]$ and $ \mathrm{V}_{\phi'}\big[{\bm{K}} \big]$
in Appendix
\ref{appendix:analytical}.
These yield an explicit formula for the RNTK that enables fast and point-wise kernel evaluations.
For other activation functions, one can apply the Monte Carlo approximation to obtain $\mathrm{V}_{\phi}\big[{\bm{K}} \big]$ and $ \mathrm{V}_{\phi'}\big[{\bm{K}} \big]$ \cite{novak2018bayesian}.
\vspace*{-2mm}
\subsection{RNTK for an Infinite-Width RNN during Training} \label{stability}
\vspace*{-2mm}
We prove that an infinitely-wide RNN, not only at initialization but also {\it during} gradient descent training, converges to the limiting RNTK at initialization.
\begin{thm} \label{RNTKstability}
Let $n$ be the number of units of each RNN's layer.
Assume that $ \Theta(\mathcal{X},\mathcal{X})$ is positive definite on $\mathcal{X}$ such that $ \lambda_{\mathrm{min}}(\Theta(\mathcal{X},\mathcal{X})) > 0 $. Let $\eta^{*} := 2 \big(\lambda_{\mathrm{min}}(\Theta(\mathcal{X},\mathcal{X})) + \lambda_{\mathrm{max}}(\Theta(\mathcal{X},\mathcal{X}) \big)\big)^{-1}$. For an $L$-layer RNN with NTK initialization as in (\ref{eq:ntk-init-1}), (\ref{eq:ntk-init-2}) trained under gradient flow (recall (\ref{ODE1}) and (\ref{ODE2})) with $\eta < \eta^*$, we have with high probability
\begin{align}
\underset{s}{\mathrm{sup}} \frac{\| \theta_s - \theta_0 \|_2}{\sqrt{n}},\underset{s}{\mathrm{sup}} \| \widehat{\Theta}_s(\mathcal{X},\mathcal{X}) - \widehat{\Theta}_0(\mathcal{X},\mathcal{X}) \|_2 = \mathcal{O}\left(\frac{1}{\sqrt{n}}\right). \nonumber
\end{align}
\end{thm}
{\bf Remarks.}~
Theorem~\ref{RNTKstability} states that the training dynamics of an RNN in the infinite-width limit as in (\ref{ODE1}), (\ref{ODE2}) are governed by the RNTK derived from the RNN at its initialization.
Intuitively, this is due to the NTK initialization (\ref{eq:ntk-init-1}), (\ref{eq:ntk-init-2}) which positions the parameters near a local minima, thus minimizing the amount of update that needs to be applied to the weights to obtain the final parameters.
\begin{figure}[t]
\centering
\begin{minipage}{0.05\linewidth}
\rotatebox{90}{ $\frac{s(t)}{\max_t s(t)}$}
\end{minipage}
\foreach \b in {w,u,b,h}{
\begin{minipage}{0.22\linewidth}
\centering
\includegraphics[width=\linewidth]{./figures/relu_different_sigma\b.eps}
\end{minipage}
}\\[3mm]
\begin{minipage}{0.05\linewidth}
\rotatebox{90}{ $\frac{s(t)}{\max_t s(t)}$}
\end{minipage}
\foreach \b in {w,u,b,h}{
\begin{minipage}{0.22\linewidth}
\centering
\includegraphics[width=\linewidth]{./figures/erf_different_sigma\b.eps}\\
$t$
\end{minipage}
}
\caption{\small
Per time step $t$ (horizontal axis) sensitivity analysis (vertical axis) of the RNTK for the ReLU (top row) and erf (bottom row) activation functions for various weight noise hyperparameters.
We also experiment with different RNTK hyperparameters in each of the subplots, given by the subplot internal legend.
Clearly, the ReLU (top-row) provides a more stable kernel across time steps (highlighted by the near constant sensitivity through time). On the other hand, erf (bottom row) sees a more erratic behavior either focusing entirely on early time-steps or on the latter ones.
}
\label{fig:sensitivity}
\end{figure}
\vspace*{-2mm}
\subsection{
RNTK for an Infinite-Width RNN Without Weight Sharing}
\label{sec:weight-sharing}
\vspace*{-2mm}
We prove that, in the infinite-width limit, an RNN without weight sharing (untied weights), i.e., using independent new weights ${\mathbf{W}}^{(\ell,t)}$, ${\mathbf{U}}^{(\ell,t)}$ and ${\mathbf{b}}^{(\ell,t)}$ at each time step $t$, converges to the same RNTK as an RNN with weight sharing (tied weights).
First, recall that it is a common practice to use weight-tied RNNs, i.e., in layer $\ell$, the weights ${\mathbf{W}}^{(\ell)}$, ${\mathbf{U}}^{(\ell)}$ and ${\mathbf{b}}^{(\ell)}$ are the same across all time steps $t$. This practice conserves memory and reduces the number of learnable parameters.
We demonstrate that, when using untied-weights, the RNTK formula remains unchanged.
\begin{thm}
\label{thm:weight-untied}
For inputs of the same length,
an RNN with untied weights converges to the same RNTK as an RNN with tied weights in the infinite-width ($n\rightarrow\infty$) regime.
\end{thm}
{ \bf Remarks.}~
Theorem~\ref{thm:weight-untied} implies that weight-tied and weight-untied RNNs have similar behaviors in the infinite-width limit. It also suggests that existing results on the simpler, weight-untied RNN setting may be applicable for the more general, weight-tied RNN.
The plot on the right side of Figure~\ref{fig:convergence} empirically demonstrates the convergence of both the weight-tied and weight-untied RNNs to the RNTK with increasing hidden layer size $n$;
moreover, the convergence rates are similar.
\vspace*{-2mm}
\subsection{Insights into the Roles of the RNTK's Hyperparameters} \label{sensitiviy}
\vspace*{-2mm}
Our analytical form for the RNTK is fully determined by a small number of hyperparameters, which contains the various weight variances collected into $\mathcal{S} = \{ \sigma_w,
\sigma_u,\sigma_b,\sigma_h\}$ and the activation function.\footnote{From (\ref{rec:1}) to (\ref{rec:4}) we emphasize that $\sigma_v$ merely scales the RNTK and does not change its overall behavior.}
In standard supervised-learning settings, one often performs cross-validation to select the hyperparameters. However, since kernel methods become computationally intractable for large datasets, we seek a more computationally friendly alternative to cross-validation. Here we conduct a novel exploratory analysis that provides new insights into the impact of the RNTK hyperparameters on the RNTK output and suggests a simple method to select them a priori in a deliberate manner.
To visualize the role of the RNTK hyperparameters, we introduce the {\it sensitivity} $s(t)$ of the RNTK of two input sequences
${\bm{x}}$ and ${\bm{x}}'$ with respect to the input ${\bm{x}}_t$ at time $t$
\begin{align}
s(t) = \|\nabla_{{\bm{x}}_t} \Theta({\bm{x}},{\bm{x}}') \|_2\,.\label{eq:rntk-gradient}
\end{align}
Here, $s(t)$ indicates how sensitive the RNTK is to the data at time $t$, i.e., ${\bm{x}}_t$, in presence of another data sequence ${\bm{x}}'$.
Intuitively, large/small $s(t)$ indicates that the RNTK is relatively sensitive/insensitive to the input ${\bm{x}}_t$ at time $t$.
The sensitivity is crucial to understanding to which extent the RNTK prediction is impacted by the
input at each time step. In the case where some time indices have a small sensitivity, then any input variation in those corresponding times will not alter the RNTK output and thus will produce a metric that is invariant to those changes.
This situation can be beneficial or detrimental based on the task at hand. Ideally, and in the absence of prior knowledge on the data, one should aim to have a roughly constant sensitivity across time in order to treat all time steps equally in the RNTK input comparison.
Figure \ref{fig:sensitivity} plots the normalized sensitivity $s(t)/{\rm max}_t(s(t))$ for two data sequences of the same length $T = 100$, with $s(t)$ computed numerically for ${\bm{x}}_t, {\bm{x}}'_t \sim \mathcal{N}(0,1)$. We repeated the experiments 10000 times; the mean of the sensitivity is shown in Figure \ref{fig:sensitivity}. Each of the plots shows the changes of parameters $\mathcal{S}_{\rm ReLU} = \{ \sqrt{2},1,0,0\}$ for $\phi = \rm ReLU$ and $\mathcal{S}_{\rm erf} = \{ 1,0.01,0.05,0\}$ for $\phi = \rm erf$.
From Figure \ref{fig:sensitivity} we first observe that both $\mathrm{ReLU}$ and $\mathrm{erf}$ show
similar per time step sensitivity measure $s(t)$ behavior around the hyperparameters $\mathcal{S}_{\rm ReLU}$ and $\mathcal{S}_{\rm erf}$. If one varies any of the weight variance parameters, the sensitivity exhibits a wide range of behavior, and in particular with $\rm erf$.
We observe that $\sigma_w$ has a major influence on $s(t)$. For $\rm ReLU$, a small decrease/increase in $\sigma_w$ can lead to over-sensitivity of the RNTK to data at the last/first times steps, whereas for $\rm erf$, any changes in $\sigma_w$ leads to over-sensitivity to the last time steps.
Another notable observation is the importance of $\sigma_h$, which is usually set to zero for RNNs. \cite{wang2018a} showed that a non-zero $\sigma_h$ acts as a regularization that improves the performance of RNNs with the $\rm ReLU$ nonlinearity.
From the sensitivity perspective, a non-zero $\sigma_h$ results in reducing the importance of the first time steps of the input. We also see the same behavior in $\rm erf$, but with stronger changes as $\sigma_h$ increases. Hence whenever one aims at reinforcing the input pairwise comparisons, such parameters should be favored.
This sensitivity analysis provides a practical tool for RNTK hyperparameter tuning. In the absence of knowledge about the data, hyperparameters should be chosen to produce the least time varying sensitivity. If given a priori knowledge, hyperparameters can be selected that direct the RNTK to the desired time-steps.
\vspace*{-2mm}
\section{Experiments}
\vspace*{-2mm}
\label{sec:exp}
We now empirically validate the performance of the RNTK compared to classic kernels, NTKs, and trained RNNs on both classification and regression tasks using a large number of time series data sets.
Of particular interest is the capability of the RNTK to offer high performance even on inputs of different lengths.
\iffalse
\begin{table}
\centering
\caption{Summary of time series classification results on 56 real-world data sets. RNTK outperforms all other kernels that we consider as well as several trained RNNs, including GRU, across all metrics. Lower Friedman ranking and higher Average accuracy (Acc. mean), P90/95, and Percentage of Maximum Accuracy (PMA) indicated better performance. See Appendix \ref{appendix:experiments} for detailed description of the metrics. }
{
\begin{adjustbox}{width=\columnwidth,center}
\begin{tabular}{lccccccc}
\toprule
\textbf{} & \textbf{RNTK} & \textbf{NTK} & \textbf{RBF} &\textbf{Polynomial} & \textbf{Gaussian RNN} & \textbf{Identity RNN} & \textbf{GRU}\\ \hline
Acc. mean $\uparrow$ & \textbf{80.44}\% & 78.29\% & 78.46\% & 78.68\% & 57.34\% & 64.68\% & 70.58\%\\
Acc. std & 16.08\% & 16.82\% & 16.76\% & 16.58\% &26.29\%& 18.11\%& 22.70\% \\
P90 $\uparrow$ & \textbf{92.45\%} & 86.79\% & 88.68\% & 81.13\% & 30.19\% & 45.28\% & 64.15\% \\
P95 $\uparrow$ & \textbf{81.13\%} & 69.81\% & 77.36\% & 66.04\% & 18.87\% & 22.64\% & 49.06\% \\
PMA $\uparrow$ & \textbf{97.29\%} & 94.64\% & 94.89\% & 93.91\% & 68.54\% & 79.90\% & 85.24\% \\
Friedman Rank $\downarrow$ & \textbf{2.35} & 2.96 & 2.90 & 3.60 & 5.81 & 5.16 & 4.15 \\
\bottomrule
\end{tabular}
\end{adjustbox}
}
\label{tab:real-data-svm}
\end{table}
\fi
\iffalse
\begin{table}
\centering
\caption{Summary of time series classification results on 56 real-world data sets. The RNTK outperforms classical kernels, the NTK, and trained RNNs across all metrics. See Appendix \ref{appendix:experiments} for detailed description of the metrics. }
\vspace{-5pt}
{
\begin{adjustbox}{width=\columnwidth,center}
\begin{tabular}{lccccccc}
\toprule
\textbf{} & \textbf{RNTK} & \textbf{NTK} & \textbf{RBF} &\textbf{Polynomial} & \textbf{Gaussian RNN} & \textbf{Identity RNN} & \textbf{GRU}\\ \hline
Acc. mean $\uparrow$ & \textbf{79.60}\% \textbf{$\pm$ 15.98}\% & 77.96\% $\pm$ 16.13\% & 78.44\% $\pm$ 16.38\% & 78.02\% $\pm$ 15.98\% & 54.93\% $\pm$ 26.13\% & 63.99\% $\pm$ 19.40 \% & 69.56\% $\pm$ 22.43\\
P90 $\uparrow$ & \textbf{88.57\%} & 84.29\% & \textbf{88.57}\% & 85.71\% & 30.00\% & 42.86\% & 60.00\% \\
P95 $\uparrow$ & \textbf{75.71\%} & 68.57\% & 72.86\% & 67.14\% & 20.00\% & 22.86\% & 45.71\% \\
PMA $\uparrow$ & \textbf{96.49\%} & 94.46\% & 95.13\% & 94.63\% & 66.32\% & 78.92\% & 84.33\% \\
Friedman Rank $\downarrow$ & \textbf{2.59} & 2.96 & 2.96 & 3.34 & 5.77 & 5.23 & 4.23 \\
\bottomrule
\end{tabular}
\end{adjustbox}
}
\label{tab:real-data-svm}
\end{table}
\fi
\begin{table}
\centering
\caption{Summary of time series classification results on 56 real-world data sets. The RNTK outperforms classical kernels, the NTK, and trained RNNs across all metrics. See Appendix \ref{appendix:experiments} for detailed description of the metrics. }
\vspace{-0pt}
{
\begin{adjustbox}{width=\columnwidth,center}
\begin{tabular}{lccccccc}
\toprule
\textbf{} & \textbf{RNTK} & \textbf{NTK} & \textbf{RBF} &\textbf{Polynomial} & \textbf{Gaussian RNN} & \textbf{Identity RNN} & \textbf{GRU}\\ \hline
Acc. mean $\uparrow$ & \textbf{80.15}\% \textbf{$\pm$ 15.99}\% & 77.74\% $\pm$ 16.61\% & 78.15\% $\pm$ 16.59\% & 77.69\% $\pm$ 16.40\% & 55.98\% $\pm$ 26.42\% & 63.08\% $\pm$ 19.02 \% & 69.50\% $\pm$ 22.67\\
P90 $\uparrow$ & \textbf{92.86\%} & 85.71\% & 87.60\% & 82.14\% & 28.57\% & 42.86\% & 60.71\% \\
P95 $\uparrow$ & \textbf{80.36\%} & 66.07\% & 75.00\% & 67.86\% & 17.86\% & 21.43\% & 46.43\% \\
PMA $\uparrow$ & \textbf{97.23\%} & 94.30\% & 94.86\% & 94.23\% & 67.06\% & 78.22\% & 84.31\% \\
Friedman Rank $\downarrow$ & \textbf{2.38} & 3.00 & 2.89 & 3.46 & 5.86 & 5.21 & 4.21 \\
\bottomrule
\end{tabular}
\end{adjustbox}
}
\label{tab:real-data-svm}
\end{table}
{\bf Time Series Classification.}~
The first set of experiments considers time series inputs of the same lengths from 56 datasets in the UCR time-series classification data repository \cite{Dau_2019}.
We restrict ourselves to selected data sets with fewer than $1000$ training samples and fewer than $1000$ time steps ($T$) as kernel methods become rapidly intractable for larger datasets.
We compare the RNTK with a variety of other kernels, including the Radial Basis Kernel (RBF), polynomial kernel, and NTK \cite{jacot2018neural}, as well as finite RNNs with Gaussian, identity \cite{relu_rnn} initialization, and GRU \cite{gru}.
We use $\phi = \rm ReLU$ for both the RNTKs and NTKs.
For each kernel, we train a C-SVM \cite{CC01a} classifier, and for each finite RNN we use gradient descent training.
For model hyperparameter tuning, we use 10-fold cross-validation. Details on the data sets and experimental setup are available in Appendix \ref{appendix:exp-classification}.
We summarize the classification results over all 56 datasets in
Table~\ref{tab:real-data-svm}; detailed results on each data set is available in Appendix \ref{appendix:exp-regression}.
We see that the RNTK outperforms not only the classical kernels but also the NTK and trained RNNs in all metrics.
The results demonstrate the ability of RNTK to provide increased performances compare to various other methods (kernels and RNNs). The superior performance of RNTK compared to other kernels, including NTK, can be explained by the internal recurrent mechanism present in RNTK, allowing time-series adapted sample comparison. In addition, RNTK also outperforms RNN and GRU. As the datasets we consider are relative small in size, finite RNNs and GRUs that typically require large amount of data to succeed do not perform well in our setting. An interesting future direction would be to compare RNTK to RNN/GRU on larger datasets.
\begin{figure}[t]
\centering
\begin{minipage}{0.02\textwidth}
\rotatebox{90}{\;\;\;\;\;\; {\small SNR}}
\end{minipage}
\begin{minipage}{0.23\textwidth}
\centering
\subfloat[Sinusoidal signal]{\includegraphics[width=\linewidth]{./figures/anew.eps} \label{fig4a} }\\
{\small $T_{\rm var}$}
\end{minipage}\hfil
\begin{minipage}{0.23\textwidth}
\centering
\subfloat[Sinusoidal signal]{\includegraphics[width=\linewidth]{./figures/bnew.eps} \label{fig4b}}\\
{\small $\sigma_n$}
\end{minipage}\hfil
\begin{minipage}{0.23\textwidth}
\centering
\subfloat[Google stock value]{\includegraphics[width=\linewidth]{./figures/cnew.eps} \label{fig4c}}\\
{\small $T_{\rm var}$}
\end{minipage}
\begin{minipage}{0.23\textwidth}
\centering
\subfloat[Google stock value]{\includegraphics[width=\linewidth]{./figures/dnew.eps} \label{fig4d}}\\
{\small $N_{\rm train}$}
\end{minipage}
\caption{\small
Performance of the RNTK on
the synthetic sinusoid and real-world Google stock price data sets compared to three other kernels.
We vary the input lengths (a,c), the input noise level (b), and training set size (d).
We compute the average SNR by repeating each experiment 1000 times.
The RNTK clearly outperforms all of the other kernels under consideration.
Figure~4b suggests that the RNTK performs better when input noise level is low demonstrating one case where time recurrence from RNTK might be sub-optimal as it collects and accumulate the high noise from each time step as opposed to other kernels treating each independently.
}
\label{fig:differentlength}
\end{figure}
{\bf Time Series Regression.}~
We now validate the performance of the RNTK on time series inputs of {\it different} lengths on both synthetic data and real data. For both scenarios, the target is to predict the next time-step observation of the randomly extracted windows of different length using kernel ridge regression.
We compare the RNTK to other kernels, the RBF and polynomial kernels and the NTK. We also compare our results with a data independent predictor that requires no training, that is simply to predict the next time step with previous time step (PTS).
For the synthetic data experiment, we simulate 1000 samples of one period of a sinusoid and add white Gaussian noise with default $\sigma_n = 0.05$.
From this fixed data, we extract training set size $N_{\rm train} = 20$ segments of uniform random lengths in the range of $[ T_{\rm fixed}, T_{\rm fixed} + T_{\rm var}]$ with $T_{\rm fixed} = 10$.
We use standard kernel ridge regression for this task. The test set is comprised of $N_{\rm test} = 5000$ obtained from other randomly extracted segments, again of varying lengths.
For the real data, we use $975$ days of the Google stock value in the years 2014--2018.
As in the simulated signal setup above, we extract $N_{\rm train}$ segments of different lengths from the first 700 days and test on the $N_{\rm test}$ segments from days 701 to 975. Details of the experiment are available in Appendix \ref{exp:reg}.
We report the predicted signal-to-noise ratio (SNR) for both datasets in Figures \ref{fig4a} and \ref{fig4c} for various values of $T_{\rm var}$.
We vary the noise level and training set size for fixed $T_{\rm var} = 10$ in Figures \ref{fig4b} and \ref{fig4d}.
As we see from Figures~\ref{fig4a} and \ref{fig4c}, the RNTK offers substantial performance gains compared to the other kernels, due to its ability to naturally deal with variable length inputs.
Moreover, the performance gap increases with the amount of length variation of the inputs $T_{\rm var}$.
Figure~\ref{fig4d} demonstrates that, unlike the other methods, the RNTK maintains its performance even when the training set is small.
Finally, Figure~\ref{fig4c} demonstrates that the impact of noise in the data on the regression performance
is roughly the same for all models but becomes more important for RNTK with a large $\sigma_n$; this might be attributed to the recurrent structure of the model allowing for a time propagation and amplification of the noise for very low SNR.
These experiments demonstrate the distinctive advantages of the RNTK over classical kernels, and NTKs for input data sequences of varying lengths.
In the case of PTS, we expect the predictor to outperform kernel methods when learning from the training samples is hard, due to noise in the data or small training size which can lead to over fitting. In Figure~\ref{fig4a} RNTK and Polynomial kernels outperforms PTS for all values of $T_{\rm var}$, but for larger $T_{\rm var}$, NTK and RBF under perform PTS due to the increasing detrimental effect of zero padding. For the Google stock value, we see a superior performance of PTS with respect to all other kernel methods due to the nature of those data heavily relying on close past data.
However, RNTK is able to reduce the effect of over-fitting, and provide the closest results to PTS among all kernel methods we employed, with increasing performance as the number of training samples increase.
\vspace*{-2mm}
\section{Conclusions}
\vspace*{-2mm}
In this paper, we have derived the RNTK based on the architecture of a simple RNN.
We have proved that, at initialization, after training, and without weight sharing, any simple RNN converges to the same RNTK. This convergence provides new insights into the behavior of infinite-width RNNs, including how they process different-length inputs, their training dynamics, and the sensitivity of their output at every time step to different nonlinearities and initializations.
We have highlighted the RNTK's practical utility by demonstrating its superior performance on time series classification and regression compared to a range of classical kernels, the NTK, and trained RNNs. There are many avenues for future research, including developing RNTKs for gated RNNs such as the LSTM~\cite{hochreiter1997long} and investigating which of our theoretical insights extend to finite RNNs.
\section*{Acknowledgments}
This work was supported by NSF grants CCF-1911094, IIS-1838177, and IIS-1730574; ONR grants N00014-18-12571, N00014-20-1-2787, and N00014-20-1-2534; AFOSR grant FA9550-18-1-0478; and a Vannevar Bush Faculty Fellowship, ONR grant N00014-18-1-2047.
\section{Introduction}
\vspace*{-2mm}
The overparameterization of modern deep neural networks (DNNs) has resulted in not only remarkably good generalization performance on unseen data \cite{46649,neyshabur2018the,belkin2019reconciling} but also guarantees
that gradient descent learning can find the global minimum of their highly nonconvex loss functions \cite{du2018gradient, NIPS2019_8893, allen2019learning, zou2018stochastic, arora2019fine}.
From these successes, a natural question arises: What happens when we take overparameterization to the limit by allowing the width of a DNN's hidden layers to go to infinity?
Surprisingly, the analysis of such an (impractical) DNN becomes analytically tractable.
Indeed, recent work has shown that the training dynamics of (infinite-width) DNNs under gradient flow is captured by a constant kernel called the \emph{Neural Tangent Kernel} (NTK) that evolves according to a linear ordinary differential equation (ODE) \cite{jacot2018neural,lee2019wide,arora2019exact}.
Every DNN architecture and parameter initialization produces a distinct NTK. The original NTK was derived from the Multilayer Perceptron (MLP)\cite{jacot2018neural} and was soon followed by kernels derived from Convolutional Neural Networks (CNTK) \cite{arora2019exact, yang2019scaling}, Residual DNNs \cite{huang2020deep}, and Graph Convolutional Neural Networks (GNTK) \cite{du2019graph}. In \cite{yang2020tensor}, a general strategy to obtain the NTK of any architecture is provided.
{\bf\em In this paper, we extend the NTK concept to the important class of overparametrized Recurrent Neural Networks (RNNs)}, a fundamental DNN architecture for processing sequential data.
We show that RNN in its infinite-width limit converges to a kernel that we dub the {\bf\em Recurrent Neural Tangent Kernel} (RNTK). The RNTK provides high performance for various machine learning tasks, and an analysis of the properties of the kernel provides useful insights into the behavior of RNNs in the following overparametrized regime. In particular, we derive and study the RNTK to answer the following theoretical questions:
{\bf\em Q: Can the RNTK extract long-term dependencies between two data sequences?}~
RNNs are known to underperform at learning long-term dependencies due to the gradient vanishing or exploding \cite{279181}.
Attempted ameliorations have included orthogonal weights \cite{arjovsky2016unitary, jing2017tunable, henaff2016recurrent} and gating such as in Long Short-Term Memory (LSTM) \cite{hochreiter1997long} and Gated Recurrent Unit (GRU) \cite{gru} RNNs.
We demonstrate that the RNTK can detect long-term dependencies with proper initialization of the hyperparameters, and moreover, we show how the dependencies are extracted through time via different hyperparameter choices.
{\bf\em Q: Do the recurrent weights of the RNTK reduce its representation power compared to other NTKs?}~
An attractive property of an RNN that is shared by the RNTK is that it can deal with sequences of different lengths via weight sharing through time.
This enables the reduction of the number of learnable parameters and thus more stable training at the cost of reduced representation power.
We prove the surprising fact that employing tied vs.\ untied weights in an RNN {\em does not} impact the analytical form of the RNTK.
{\bf\em Q: Does the RNTK generalize well?}~
A recent study has revealed that the use of an SVM classifier with the NTK, CNTK, and GNTK kernels outperforms other classical kernel-based classifiers and trained finite DNNs on small data sets (typically fewer than 5000 training samples) \cite{lee2020finite,arora2019exact,Arora2020Harnessing,du2019graph}.
We extend these results to RNTKs to demonstrate that the RNTK outperforms a variety of classic kernels, NTKs {\em and} finite RNNs for time series data sets in both classification and regression tasks.
Carefully designed experiments with data of varying lengths demonstrate that the RNTK's performance accelerates beyond other techniques as the difference in lengths increases.
Those results extend the empirical observations from \cite{arora2019exact,Arora2020Harnessing,du2019graph,lee2020finite} into finite DNNs, NTK, CNTK, and GNTK comparisons by observing that their performance-wise ranking depends on the employed DNN architecture.
\iffalse
\sa{ here is what I think we should say here: 1. \cite{Arora2020Harnessing,du2019graph} have found that NTK,CNTK and GNTK outperforms other methods in small datasets 2. Meanwhile, \cite{arora2019exact} found that CNTK underperform trained finite CNNs in large data sets (CFAR 10) 3. \cite{lee2020finite} did experiments on large datasets and found that fully connected networks also outperforms finite fully connected networks in large datasets, but CNTK underperform finite ones, consistent with \cite{arora2019exact} result 4. Conclusion: the ability of generalization is related to network architecture 5. our story: on small datasets, RNTK outperforms finite RNNs. ALSO, it outperforms other kernels. So the main point is that we say what is this architecture dependency (RNTK > finite) and meanwhile, it outperforms other kernels }
\sa{in addition to that 56 datasets which data are of the same length, we provide another experiment when data are of different length and we show that RNTK is better there too compared to other kernels when zero padding is used.}
\randall{maybe we put only 2 3 sentences here and refer to the appendix for the bigger paragraph with details ?} \jw{I think the transition is OK}
\fi
We summarize our contributions as follows:
{\bf [C1]}
We derive the analytical form for the RNTK of an overparametrized RNN at initialization using rectified linear unit (ReLU) and error function (erf) nonlinearities for arbitrary data lengths and number of layers (Section \ref{RNTKconvergence_sinlelayer}).
{\bf [C2]}
We prove that the RNTK remains constant during (overparametrized) RNN training and that the dynamics of training are simplified to a set of ordinary differential equations (ODEs) (Section \ref{stability}).
{\bf [C3]}
When the input data sequences are of equal length, we show that the RNTKs of weight-tied and weight-untied RNNs converge to the same RNTK (Section~\ref{sec:weight-sharing}).
{\bf [C4]}
Leveraging our analytical formulation of the RNTK, we empirically demonstrate how correlations between data at different times are weighted by the function learned by an RNN for different sets of hyperparameters. We also offer practical suggestions for choosing the RNN hyperparameters for deep information propagation through time (Section~\ref{sensitiviy}).
{\bf [C5]}
We demonstrate that the RNTK is eminently practical by showing its superiority over classical kernels, NTKs, and finite RNNs
in exhaustive experiments on time-series classification and regression with both synthetic and 56 real-world data sets (Section 4).
\vspace*{-2mm}
\section{Background and Related Work}
\vspace*{-2mm}
{\bf Notation.}
We denote $ [ n ] = \{1, \dots, n\}$, and ${\bm{I}}_d$ the identity matrix of size $d$. $[{\bm{A}}]_{i,j}$ represents the $(i,j)$-th entry of a matrix, and similarly $[{\bm{a}}]_i$ represents the $i$-th entry of a vector.
We use $\phi(\cdot): \mathbb{R} \rightarrow \mathbb{R}$ to represent the activation function that acts coordinate wise on a vector and $\phi'$ to denote its derivative.
We will often use the rectified linear unit (ReLU) $\phi(x) = \mathrm{max}(0,x)$ and error function (erf) $\phi(x) = \frac{2}{\sqrt{\pi}} \int_0^x e^{-z^2} dz$ activation functions.
$\mathcal{N}({\bm{\mu}}, {\bm{\Sigma}})$ represents the multidimensional Gaussian distribution with the mean vector ${\bm{\mu}}$ and the covariance matrix ${\bm{\Sigma}}$.
{\bf Recurrent Neural Networks (RNNs).}~
Given an input sequence data
${\bm{x}} = \{{\bm{x}}_t\}_{t = 1}^{T}$ of length $T$ with data at time $t$, ${\bm{x}}_t\in\mathbb{R}^m$, a {\em simple RNN} \cite{ElmanRNN} performs the following recursive computation at each layer $\ell$ and each time step $t$
\begin{align}
{\bm{g}}^{\left(\ell,t\right)}({\bm{x}}) = {\bm{W}}^{\left(\ell\right)}{\bm{h}}^{\left(\ell,t-1\right)}({\bm{x}}) + {\bm{U}}^{\left(\ell\right)}{\bm{h}}^{\left(\ell-1,t\right)}({\bm{x}}) + {\bm{b}}^{\left(\ell\right)}, \hspace{20pt}
{\bm{h}}^{\left(\ell,t\right)}({\bm{x}}) &= \phi\left( {\bm{g}}^{\left(\ell,t\right)}({\bm{x}}) \right),
\nonumber
\end{align}
where ${\bm{W}}^{(\ell)} \in \mathbb{R}^{n \times n}$, $ {\bm{b}}^{(\ell)} \in \mathbb{R}^{n}$ for $\ell \in [L]$, $ {\bm{U}}^{(1)} \in \mathbb{R}^{n \times m} $ and $ {\bm{U}}^{(\ell)} \in \mathbb{R}^{n \times n}$ for $\ell \ge 2$ are the RNN parameters.
${\bm{g}}^{\left(\ell,t\right)}({\bm{x}})$ is the pre-activation vector at layer $\ell$ and time step $t$, and
${\bm{h}}^{\left(\ell,t\right)}({\bm{x}})$ is the after-activation (hidden state).
For the input layer $\ell=0$, we define ${\bm{h}}^{\left(0,t\right)}({\bm{x}}) := {\bm{x}}_t$.
${\bm{h}}^{(\ell,0)}({\bm{x}})$ as the initial hidden state at layer $\ell$ that must be initialized to start the RNN recursive computation.
The output of an $L$-hidden layer RNN with linear read out layer is achieved via
\begin{align}
f_\theta({\bm{x}}) &= {\bm{V}} {\bm{h}}^{(L,T)}({\bm{x}}) , \nonumber
\end{align}
where ${\bm{V}} \in \mathbb{R}^{d \times n}$. Figure~\ref{fig:rnn} visualizes an RNN unrolled through time.
\begin{figure}[t!]
\centering
\begin{minipage}{0.7\linewidth}
\resizebox{0.9\textwidth}{!}{%
\begin{tikzpicture}[object/.style={thin,double,<->}]
\tikzstyle{main}=[rectangle, minimum width = 16.3mm, minimum height = 7mm, thick, draw =black!80, node distance = 5mm]
\tikzstyle{main2}=[circle, minimum size = 10mm, thick, draw =black!80, node distance = 5mm]
\tikzstyle{connect}=[-latex, thick]
\tikzstyle{box}=[rectangle, draw=black!100]
\node[main] (hlt) [] {\small${\bm{h}}^{(2,2)}$};
\node[main] (hltm) [left=1.3cm of hlt] {\small ${\bm{h}}^{(2,1)}({\bm{x}})$};
\node[main] (hltp) [right=1.3cm of hlt] {\small ${\bm{h}}^{(2,3)}({\bm{x}})$};
\node[main] (hlmt) [below=0.5cm of hlt] {\small ${\bm{h}}^{(1,2)}({\bm{x}})$};
\node[main] (hlmtm) [below=0.5cm of hltm] {\small ${\bm{h}}^{(1,1)}({\bm{x}})$};
\node[main] (hlmtp) [below=0.5cm of hltp] {\small ${\bm{h}}^{(1,3)}({\bm{x}})$};
\coordinate[right=0.8cm of hltp] (hltpp);
\coordinate[right=0.8cm of hlmtp] (hlmtpp);
%
%
\coordinate[above=0.5cm of hltm] (hlptm);
\coordinate[above=0.5cm of hlt] (hlpt);
\coordinate[above=0.5cm of hltp] (hlptp);
\path (hltm) edge [connect] node[above] {\small${\bm{W}}^{(2)}$}(hlt)
(hlt) edge [connect] node[above] {\small${\bm{W}}^{(2)}$}(hltp)
(hlmtm) edge [connect] node[above] {\small${\bm{W}}^{(1)}$}(hlmt)
(hlmt) edge [connect] node[above] {\small${\bm{W}}^{(1)}$}(hlmtp)
(hlmt) edge [connect] node[above] {\small${\bm{W}}^{(1)}$} (hlmtp)
(hltp) edge [connect] (hltpp)
(hlmtp) edge [connect] (hlmtpp)
%
%
(hltm) edge [connect] (hlptm)
(hlt) edge [connect] (hlpt)
(hltp) edge [connect] (hlptp)
%
(hlmtm) edge [connect] node[right] {\small${\bm{U}}^{(2)}$}(hltm)
(hlmt) edge [connect] node[right] {\small${\bm{U}}^{(2)}$}(hlt)
(hlmtp) edge [connect] node[right] {\small${\bm{U}}^{(2)}$} (hltp)
;
\node[rectangle, inner sep=.5mm,draw=black!100, fit= (hlt), fill=blue,opacity=.2](t) {};
\node[rectangle, inner sep=1.7mm,draw=black!100, fit= (hltm)(hltp)(hltpp), fill=red,opacity=.2](t) {};
\node[main] (hltz) [left=1.3cm of hltm] {\small ${\bm{h}}^{(2,0)}({\bm{x}})$};
\node[main] (hlmtz) [left=1.3cm of hlmtm] {\small ${\bm{h}}^{(1,0)}({\bm{x}})$};
\path (hltz) edge [connect] node[above] {\small${\bm{W}}^{(2)}$}(hltm)
(hlmtz) edge [connect] node[above] {\small${\bm{W}}^{(1)}$}(hlmtm)
;
\node[rectangle, inner sep=1.mm,draw=black!100, fit= (hltz), fill=green,opacity=.2](t) {};
\node[rectangle, inner sep=1.mm,draw=black!100, fit= (hlmtz), fill=green,opacity=.2](t) {};
\node[main] (xtm) [below=0.5cm of hlmtm] {\small ${\bm{x}}_{1}$};
\node[main] (xt) [below=0.5cm of hlmt] {\small ${\bm{x}}_{2}$};
\node[main] (xtp) [below=0.5cm of hlmtp] {\small ${\bm{x}}_{3}$};
\path (xtm) edge [connect] node[right] {\small${\bm{U}}^{(1)}$}(hlmtm)
(xt) edge [connect] node[right] {\small${\bm{U}}^{(1)}$}(hlmt)
(xtp) edge [connect] node[right] {\small${\bm{U}}^{(1)}$}(hlmtp);
\end{tikzpicture}}
\end{minipage}
\begin{minipage}{0.24\linewidth}
\caption{ \small
Visualization of a simple RNN that highlights a cell (purple), a layer (red) and the initial hidden state of each layer (green). (Best viewed in color.)
\vspace{-3mm}
}
\label{fig:rnn}
\end{minipage}
\end{figure}
{\bf Neural Tangent Kernel (NTK).}~
Let $f_{\theta}({\bm{x}}) \in \mathbb{R}^d$ be the output of a DNN with parameters $\theta$. For two input data sequences ${\bm{x}}$ and ${\bm{x}}'$, the NTK is defined as \cite{jacot2018neural}
\begin{align}
\widehat{\Theta}_s({\bm{x}},{\bm{x}}') = \langle \nabla_{\theta_s}f_{\theta_s}({\bm{x}}) , \nabla_{\theta_s}f_{\theta_s}({\bm{x}}')\rangle, \nonumber
\end{align}
where $f_{\theta_s}$ and $\theta_s$ are the network output and parameters during training at time s.\footnote{We use $s$ to denote time here, since $t$ is used to index the time steps of the RNN inputs.
} Let $\mathcal{X}$ and $\mathcal{Y}$ be the set of training inputs and targets, $\ell(\widehat{y},y): \mathbb{R}^d\times \mathbb{R}^d \rightarrow \mathbb{R}^+$ be the loss function, and $\mathcal{L} = \frac{1}{{|\mathcal{X}|} } \sum_{({\bm{x}},{\bm{y}}) \in \mathcal{X}\times \mathcal{Y}} \ell(f_{\theta_s}({\bm{x}}), {\bm{y}}) $ be the the empirical loss. The evolution of the parameters $\theta_s$ and output of the network $f_{\theta_s}$ on a test input using gradient descent with infinitesimal step size (a.k.a gradient flow) with learning rate $\eta$ is given by
\begin{align}
\frac{\partial \theta_s}{\partial s} &= -\eta\nabla_{\theta_s} f_{\theta_s}(\mathcal{X})^T \nabla_{f_{\theta_s}(\mathcal{X})} \mathcal{L} \label{ODE1} \\
\frac{\partial f_{\theta_s}({\bm{x}})}{\partial s} &= -\eta \nabla_{\theta_s}f_{\theta_s}({\bm{x}}) \nabla_{\theta_s}f_{\theta_s}(\mathcal{X})^T\nabla_{f_{\theta_s}(\mathcal{X})} \mathcal{L} = -\eta\widehat{\Theta}_s({\bm{x}},\mathcal{X}) \nabla_{f_{\theta_s}(\mathcal{X})} \mathcal{L}.
\label{ODE2}
\end{align}
Generally, $ \widehat{\Theta}_s({\bm{x}},{\bm{x}}')$, hereafter referred to as the empirical NTK, changes over time during training, making the analysis of the training dynamics difficult.
When $f_{\theta_s}$ corresponds to an infinite-width MLP, \cite{jacot2018neural} showed that $\widehat{\Theta}_s({\bm{x}},{\bm{x}}')$ converges to a limiting kernel at initialization and stays constant during training, i.e.,
\begin{align}
\underset{n \rightarrow \infty}{\mathrm{lim}} \widehat{\Theta}_s({\bm{x}},{\bm{x}}') = \underset{n \rightarrow \infty}{\mathrm{lim}} \widehat{\Theta}_0({\bm{x}},{\bm{x}}') := \Theta({\bm{x}},{\bm{x}}') \,\,\,\, \forall s\,, \nonumber
\end{align}
which is equivalent to replacing the outputs of the DNN by their first-order Taylor expansion in the parameter space \cite{lee2019wide}. With a mean-square error (MSE) loss function, the training dynamics in (\ref{ODE1}) and (\ref{ODE2}) simplify to a set of linear ODEs, which coincides with the training dynamics of kernel ridge regression with respect to the NTK when the ridge term goes to zero.
A nonzero ridge regularization can be conjured up by adding a regularization term $\frac{\lambda^2}{2} \| \theta_s - \theta_0 \|_2^2$ to the empirical loss \cite{hu2019simple}.
\vspace*{-2mm}
\section{The Recurrent Neural Tangent Kernel}
\vspace*{-2mm}
We are now ready to derive the RNTK. We first prove the convergence of an RNN at initialization to the RNTK in the infinite-width limit and discuss various insights it provides. We then derive the convergence of an RNN after training to the RNTK.
Finally, we analyze the effects of various hyperparameter choices on the RNTK.
Proofs of all of our results are provided in the Appendices.
\vspace*{-2mm}
\subsection{RNTK for an Infinite-Width RNN at Initialization}
\label{RNTKconvergence_sinlelayer}
\vspace*{-2mm}
First we specify the following parameter initialization scheme that follows previous work on NTKs~\cite{jacot2018neural}, which is crucial to our convergence results:
\begin{gather}
\hspace{-6pt}{\bm{W}}^{(\ell)} \hspace{-2pt}=\hspace{-2pt} \frac{\sigma_w^{\ell}}{\sqrt{n}} {\mathbf{W}}^{(\ell)},\,\,\,\,
{\bm{U}}^{(1)} \hspace{-2pt}=\hspace{-2pt} \frac{\sigma_u^1}{\sqrt{m}}{\mathbf{U}}^{(1)},\,\,\,\,
{\bm{U}}^{(\ell)} \hspace{-2pt}=\hspace{-2pt} \frac{\sigma_u^{\ell}}{\sqrt{n}} {\mathbf{U}}^{(\ell)} ( \ell \hspace{-2pt}\ge\hspace{-2pt} 2 ),\,\,\,\,
{\bm{V}} \hspace{-2pt}=\hspace{-2pt} \frac{\sigma_v}{\sqrt{n}} {\mathbf{V}},\,\,\,\,
{\bm{b}}^{(\ell)} \hspace{-2pt}=\hspace{-2pt} \sigma_b {\mathbf{b}}^{(\ell)}\,,\label{eq:ntk-init-1}
\end{gather}
where
\begin{align}
[{\mathbf{W}}^{\ell}]_{i,j},
\,\,
[{\mathbf{U}}^{(\ell)}]_{i,j},
\,\,
[{\mathbf{V}}]_{i,j},
\,\,
[{\mathbf{b}}^{(\ell)}]_i \sim \mathcal{N}(0,1)\,.\label{eq:ntk-init-2}
\end{align}
We will refer to~(\ref{eq:ntk-init-1}) and~(\ref{eq:ntk-init-2}) as the {\it NTK initialization}. The choices of the hyperparameters $\sigma_w$, $\sigma_u$, $\sigma_v$ and $\sigma_b$ can significantly impact RNN performance, and we discuss them in detail in Section \ref{sensitiviy}.
For the initial (at time $t=0$) hidden state at each layer $\ell$, we set ${\bm{h}}^{(\ell,0)}({\bm{x}})$ to an i.i.d.\ copy of $\mathcal{N}(0, \sigma_h)$~\cite{wang2018a}
. For convenience, we collect all of the learnable parameters of the RNN into $\theta = \mathrm{vect}\big[\{\{{\mathbf{W}}^{(\ell)},{\mathbf{U}}^{(\ell)},{\mathbf{b}}^{(\ell)}\}_{\ell = 1}^{L} , {\mathbf{V}} \} \big]$.
The derivation of the RNTK at initialization is based on the correspondence between Gaussian initialized, infinite-width DNNs and Gaussian Processes (GPs), known as the DNN-GP. In this setting every coordinate of the DNN output tends to a GP as the number of units/neurons in the hidden layer (its width) goes to infinity. The corresponding DNN-GP kernel is computed as
\begin{align}
\mathcal{K}({\bm{x}},{\bm{x}}') = \mathop{{\mathbb{E}}}_{\theta \sim \mathcal{N}}\big[ [f_{\theta}({\bm{x}})]_i \boldsymbol{\cdot} [f_{\theta}({\bm{x}}')]_i \big], \hspace{1mm} \forall i \in [d]. \label{NNGP}
\end{align}
First introduced for a single-layer, fully-connected neural network by \cite{neal1996priors}, recent works on NTKs have extended the results for various DNN architectures \cite{lee2017deep, duvenaud2014avoiding,novak2018bayesian, garrigaalonso2018deep,yang2019tensor}, where in addition to the output, all pre-activation layers of the DNN tends to a GPs in the infinite-width limit.
In the case of RNNs, each coordinate of the RNN pre-activation ${\bm{g}}^{(\ell,t)}({\bm{x}})$ converges to a centered GP depending on the inputs with kernel
\begin{align}
\Sigma^{(\ell,t,t')}({\bm{x}},{\bm{x}}') = \mathop{{\mathbb{E}}}_{\theta \sim \mathcal{N}} \big[ [{\bm{g}}^{(\ell,t)}({\bm{x}})]_i \boldsymbol{\cdot} [{\bm{g}}^{(\ell,t')}{({\bm{x}}')}]_i \big]\, \,\, \forall i \in [n]. \label{eq:rnn-gp}
\end{align}
As per \cite{yang2019scaling}, the gradients of random infinite-width DNNs computed during backpropagation are also Gaussian distributed. In the case of RNNs, every coordinate of the vector ${\bm{\delta}}^{(\ell,t)}({\bm{x}}) := \sqrt{n} \big( \nabla_{{\bm{g}}^{(\ell,t)}({\bm{x}})} f_{\theta}({\bm{x}}) \big)$ converges to a GP with kernel
\begin{align}
\Pi^{(\ell,t,t')}({\bm{x}},{\bm{x}}') = \mathop{{\mathbb{E}}}_{\theta \sim \mathcal{N}} \big[ [{\bm{\delta}}^{(\ell,t)}({\bm{x}})]_i \boldsymbol{\cdot} [{\bm{\delta}}^{(\ell,t')}({\bm{x}}')]_i \big]\, \,\, \forall i \in [n].\label{eq:rnn-ggp}
\end{align}
Both convergences occur independently of the coordinate index $i$ and for inputs of possibly different lengths, i.e., $T\neq T'$.
With (\ref{eq:rnn-gp}) and (\ref{eq:rnn-ggp}), we now prove that an infinite-width RNN at initialization converges to the limiting RNTK.
\begin{thm} \label{RNTK}
Let ${\bm{x}}$ and ${\bm{x}}'$ be two data sequences of potentially different lengths $T$ and $T'$, respectively. Without loss of generality, assume that $T \leq T'$, and let $ \tau := T' - T$. Let $n$ be the number of units in the hidden layers, the empirical RNTK for an $L$-layer RNN with NTK initialization converges to the following limiting kernel as $n \rightarrow \infty$
\begin{align}
\underset{n \rightarrow \infty}{\mathrm{lim}} \widehat{\Theta}_0({\bm{x}},{\bm{x}}') = \Theta({\bm{x}},{\bm{x}}') = \Theta^{(L,T,T')} ({\bm{x}},{\bm{x}}')\otimes {\bm{I}}_d\,,
\end{align}
where
\begin{align}
\Theta^{(L,T,T')}({\bm{x}},{\bm{x}}') = \left( \sum_{\ell = 1}^{L} \sum_{t = 1}^{T} \left( \Pi^{(\ell,t,t+ \tau)}({\bm{x}},{\bm{x}}') \boldsymbol{\cdot} \Sigma^{(\ell,t,t+ \tau)}({\bm{x}},{\bm{x}}') \right) \right) + \mathcal{K}({\bm{x}},{\bm{x}}')\,,\label{eq:rntk}
\end{align}
with
$\mathcal{K}({\bm{x}},{\bm{x}}')$,
$\Sigma^{(\ell,t,t+ \tau)}({\bm{x}},{\bm{x}}')$, and
$\Pi^{(\ell,t,t+ \tau)}({\bm{x}},{\bm{x}}')$ defined in
(\ref{NNGP})--(\ref{eq:rnn-ggp}).
\end{thm}
{\bf Remarks.}~
Theorem \ref{RNTK} holds generally for any two data sequences, including different lengths ones.
This highlights the RNTK's ability to produce a similarity measure $\Theta({\bm{x}},{\bm{x}}')$ even if the inputs are of different lengths, without resorting to heuristics such as zero padding the inputs to the to the max length of both sequences.
Dealing with data of different length is in sharp contrast to common kernels such as the classical radial basis functions, polynomial kernels, and current NTKs. We showcase this capability below in Section~\ref{sec:exp}.
To visualize Theorem~\ref{RNTK}, we plot in the left plot in Figure~\ref{fig:convergence} the convergence of a single layer, sufficiently wide RNN to its RNTK with the two simple inputs ${\bm{x}}=\{1,-1,1\}$ of length 3 and ${\bm{x}}'=\{{\rm cos}(\alpha) , {\rm sin}(\alpha)\}$ of length 2, where $\alpha= [0, 2 \pi]$.
For an RNN with a sufficiently large hidden state ($n=1000$), we see clearly that it converges to the RNTK ($n=\infty$).
\begin{figure}[t]
\begin{minipage}{0.5\linewidth}
\begin{minipage}{0.1\linewidth}
\rotatebox{90}{$\,\,\,\,\,\,\,\,\,\, \widehat{\Theta}_0(x,x')$}
\end{minipage}
\begin{minipage}{0.60\linewidth}
\centering
\includegraphics[width=\textwidth]{./figures/convergence_different_length.pdf}\\
$\alpha$
\end{minipage}
\end{minipage}
\begin{minipage}{0.5\linewidth}
\begin{minipage}{0.1\linewidth}
\rotatebox{90}{\small $\,\,\,\,\,\,\,\,\,\,\,\,\,\, \log(\|\frac{\Theta-\widehat{\Theta}_0}{\Theta} \|)$}
\end{minipage}
\begin{minipage}{0.60\linewidth}
\centering
\includegraphics[width=\textwidth]{./figures/convergence_same_length.pdf}\\
$\log(n)$
\end{minipage}
\end{minipage}
\caption{
\small Empirical demonstration of a wide, single-layer RNN converging to its limiting RNTK. {\bf Left}: convergence for a pair of different-length inputs ${\bm{x}} = \{ 1,-1,1 \}$ and ${\bm{x}}' = \{\cos(\alpha), \sin(\alpha)\}$, with varying $\alpha = [0,2\pi]$.
The vertical axis corresponds to the RNTK values for different values of $\alpha$. {\bf Right}: convergence of weight-tied and weight-untied single layer RNN to the same limiting RNTK with increasing width (horizontal axis). The vertical axis corresponds to the average of the log-normalized error between the empirical RNTK computed using finite RNNs and the RNTK for 50 Gaussian normal signals of length $T = 5$.
}
\label{fig:convergence}
\end{figure}
{\bf RNTK Example for a Single-Layer RNN.}~
We present a concrete example of Theorem~\ref{RNTK} by showing how to recursively compute the RNTK for a single-layer RNN; thus we drop the layer index for notational simplicity.
{\bf\em We compute and display the RNTK for the general case of a multi-layer RNN in
Appendix \ref{appendix:multi-layer}}.
To compute the RNTK $\Theta^{(T,T')}({\bm{x}},{\bm{x}}')$, we need to compute the GP kernels $\Sigma^{(t,t+ \tau)}({\bm{x}},{\bm{x}}')$ and $\Pi^{(t,t+ \tau)}({\bm{x}},{\bm{x}}')$.
We first define the operator $\mathrm{V}_{\phi}\big[{\bm{K}} \big]$ that depends on the nonlinearity $\phi(\cdot)$ and a positive semi-definite matrix ${\bm{K}}\in\mathbb{R}^{2 \times 2}$
\begin{align} \label{op:defin}
\mathrm{V}_{\phi}\big[{\bm{K}} \big] = {\mathbb{E}} [\phi({\textnormal{z}}_1)\boldsymbol{\cdot}\phi({\textnormal{z}}_2)], \qquad ({\textnormal{z}}_1,{\textnormal{z}}_2) \sim \mathcal{N}(0,{\bm{K}}) \,.
\end{align}
Following \cite{yang2019scaling},
we obtain the analytical recursive formula for the GP kernel $\Sigma^{(t,t+ \tau)}({\bm{x}},{\bm{x}}')$ for a single layer RNN as
\begin{align}
\Sigma^{(1,1)}({\bm{x}},{\bm{x}}') &= \sigma_w^2\sigma_h^2 1_{({\bm{x}} = {\bm{x}}')} + \frac{\sigma_u^2 }{m} \langle {\bm{x}}_{1},{\bm{x}}'_{1} \rangle + \sigma_b^2 \label{rec:1}\\
\Sigma^{(t,1)}({\bm{x}},{\bm{x}}') &= \frac{\sigma_u^2 }{m} \langle {\bm{x}}_{t},{\bm{x}}'_{1} \rangle + \sigma_b^2 && t > 1\\ \Sigma^{(1,t')}({\bm{x}},{\bm{x}}') &= \frac{\sigma_u^2 }{m} \langle {\bm{x}}_{1},{\bm{x}}'_{t'} \rangle + \sigma_b^2 && t' > 1\\
\Sigma^{(t,t')}({\bm{x}},{\bm{x}}') &= \sigma_w^2\mathrm{V}_{\phi}\big[ {\bm{K}}^{(t,t')}({\bm{x}},{\bm{x}}') \big]+ \frac{\sigma_u^2 }{m} \langle {\bm{x}}_{t},{\bm{x}}'_{t'} \rangle + \sigma_b^2 \hspace{1mm} \label{rec:2} && t,t'>1\\
\mathcal{K}({\bm{x}},{\bm{x}}') &= \sigma_v^2\mathrm{V}_{\phi}\big[ {\bm{K}}^{(T+1,T'+1)}({\bm{x}},{\bm{x}}') \big], \label{rec:3}
\end{align}
where
\begin{align} \label{Kdef}
{\bm{K}}^{(t,t')}({\bm{x}},{\bm{x}}') &= \left[ {\begin{array}{cc} \Sigma^{(t-1,t-1)}({\bm{x}},{\bm{x}}) & \Sigma^{(t-1,t'-1)}({\bm{x}},{\bm{x}}') \\ \Sigma^{(t-1 ,t'-1)}({\bm{x}},{\bm{x}}') & \Sigma^{(t'-1,t'-1)}({\bm{x}}',{\bm{x}}') \\ \end{array} } \right].
\end{align}
Similarly, we obtain the analytical recursive formula for the GP kernel $\Pi^{(t,t+ \tau)}({\bm{x}},{\bm{x}}')$ as
\begin{align}
\Pi^{(T,T')}({\bm{x}},{\bm{x}}') &= \sigma_v^2 \mathrm{V}_{\phi'}\big[ {\bm{K}}^{(T+1,T+\tau+1)} ({\bm{x}},{\bm{x}}') \big]\\
\Pi^{(t,t+\tau)}({\bm{x}},{\bm{x}}') &= \sigma_w^2 \mathrm{V}_{\phi'}\big[ {\bm{K}}^{(t+1,t+\tau+1)} ({\bm{x}},{\bm{x}}') \big]\Pi^{(t+1,t+1+\tau)}({\bm{x}},{\bm{x}}') &&t \in [T-1] \label{rec:4}\\
\Pi^{(t,t')}({\bm{x}},{\bm{x}}') &= 0 &&t'-t \ne \tau.
\end{align}
For $\phi = \mathrm{ReLU}$ and $\phi = \mathrm{erf}$, we provide analytical expressions for $\mathrm{V}_{\phi}\big[{\bm{K}} \big]$ and $ \mathrm{V}_{\phi'}\big[{\bm{K}} \big]$
in Appendix
\ref{appendix:analytical}.
These yield an explicit formula for the RNTK that enables fast and point-wise kernel evaluations.
For other activation functions, one can apply the Monte Carlo approximation to obtain $\mathrm{V}_{\phi}\big[{\bm{K}} \big]$ and $ \mathrm{V}_{\phi'}\big[{\bm{K}} \big]$ \cite{novak2018bayesian}.
\vspace*{-2mm}
\subsection{RNTK for an Infinite-Width RNN during Training} \label{stability}
\vspace*{-2mm}
We prove that an infinitely-wide RNN, not only at initialization but also {\it during} gradient descent training, converges to the limiting RNTK at initialization.
\begin{thm} \label{RNTKstability}
Let $n$ be the number of units of each RNN's layer.
Assume that $ \Theta(\mathcal{X},\mathcal{X})$ is positive definite on $\mathcal{X}$ such that $ \lambda_{\mathrm{min}}(\Theta(\mathcal{X},\mathcal{X})) > 0 $. Let $\eta^{*} := 2 \big(\lambda_{\mathrm{min}}(\Theta(\mathcal{X},\mathcal{X})) + \lambda_{\mathrm{max}}(\Theta(\mathcal{X},\mathcal{X}) \big)\big)^{-1}$. For an $L$-layer RNN with NTK initialization as in (\ref{eq:ntk-init-1}), (\ref{eq:ntk-init-2}) trained under gradient flow (recall (\ref{ODE1}) and (\ref{ODE2})) with $\eta < \eta^*$, we have with high probability
\begin{align}
\underset{s}{\mathrm{sup}} \frac{\| \theta_s - \theta_0 \|_2}{\sqrt{n}},\underset{s}{\mathrm{sup}} \| \widehat{\Theta}_s(\mathcal{X},\mathcal{X}) - \widehat{\Theta}_0(\mathcal{X},\mathcal{X}) \|_2 = \mathcal{O}\left(\frac{1}{\sqrt{n}}\right). \nonumber
\end{align}
\end{thm}
{\bf Remarks.}~
Theorem~\ref{RNTKstability} states that the training dynamics of an RNN in the infinite-width limit as in (\ref{ODE1}), (\ref{ODE2}) are governed by the RNTK derived from the RNN at its initialization.
Intuitively, this is due to the NTK initialization (\ref{eq:ntk-init-1}), (\ref{eq:ntk-init-2}) which positions the parameters near a local minima, thus minimizing the amount of update that needs to be applied to the weights to obtain the final parameters.
\begin{figure}[t]
\centering
\begin{minipage}{0.05\linewidth}
\rotatebox{90}{ $\frac{s(t)}{\max_t s(t)}$}
\end{minipage}
\foreach \b in {w,u,b,h}{
\begin{minipage}{0.22\linewidth}
\centering
\includegraphics[width=\linewidth]{./figures/relu_different_sigma\b.eps}
\end{minipage}
}\\[3mm]
\begin{minipage}{0.05\linewidth}
\rotatebox{90}{ $\frac{s(t)}{\max_t s(t)}$}
\end{minipage}
\foreach \b in {w,u,b,h}{
\begin{minipage}{0.22\linewidth}
\centering
\includegraphics[width=\linewidth]{./figures/erf_different_sigma\b.eps}\\
$t$
\end{minipage}
}
\caption{\small
Per time step $t$ (horizontal axis) sensitivity analysis (vertical axis) of the RNTK for the ReLU (top row) and erf (bottom row) activation functions for various weight noise hyperparameters.
We also experiment with different RNTK hyperparameters in each of the subplots, given by the subplot internal legend.
Clearly, the ReLU (top-row) provides a more stable kernel across time steps (highlighted by the near constant sensitivity through time). On the other hand, erf (bottom row) sees a more erratic behavior either focusing entirely on early time-steps or on the latter ones.
}
\label{fig:sensitivity}
\end{figure}
\vspace*{-2mm}
\subsection{
RNTK for an Infinite-Width RNN Without Weight Sharing}
\label{sec:weight-sharing}
\vspace*{-2mm}
We prove that, in the infinite-width limit, an RNN without weight sharing (untied weights), i.e., using independent new weights ${\mathbf{W}}^{(\ell,t)}$, ${\mathbf{U}}^{(\ell,t)}$ and ${\mathbf{b}}^{(\ell,t)}$ at each time step $t$, converges to the same RNTK as an RNN with weight sharing (tied weights).
First, recall that it is a common practice to use weight-tied RNNs, i.e., in layer $\ell$, the weights ${\mathbf{W}}^{(\ell)}$, ${\mathbf{U}}^{(\ell)}$ and ${\mathbf{b}}^{(\ell)}$ are the same across all time steps $t$. This practice conserves memory and reduces the number of learnable parameters.
We demonstrate that, when using untied-weights, the RNTK formula remains unchanged.
\begin{thm}
\label{thm:weight-untied}
For inputs of the same length,
an RNN with untied weights converges to the same RNTK as an RNN with tied weights in the infinite-width ($n\rightarrow\infty$) regime.
\end{thm}
{ \bf Remarks.}~
Theorem~\ref{thm:weight-untied} implies that weight-tied and weight-untied RNNs have similar behaviors in the infinite-width limit. It also suggests that existing results on the simpler, weight-untied RNN setting may be applicable for the more general, weight-tied RNN.
The plot on the right side of Figure~\ref{fig:convergence} empirically demonstrates the convergence of both the weight-tied and weight-untied RNNs to the RNTK with increasing hidden layer size $n$;
moreover, the convergence rates are similar.
\vspace*{-2mm}
\subsection{Insights into the Roles of the RNTK's Hyperparameters} \label{sensitiviy}
\vspace*{-2mm}
Our analytical form for the RNTK is fully determined by a small number of hyperparameters, which contains the various weight variances collected into $\mathcal{S} = \{ \sigma_w,
\sigma_u,\sigma_b,\sigma_h\}$ and the activation function.\footnote{From (\ref{rec:1}) to (\ref{rec:4}) we emphasize that $\sigma_v$ merely scales the RNTK and does not change its overall behavior.}
In standard supervised-learning settings, one often performs cross-validation to select the hyperparameters. However, since kernel methods become computationally intractable for large datasets, we seek a more computationally friendly alternative to cross-validation. Here we conduct a novel exploratory analysis that provides new insights into the impact of the RNTK hyperparameters on the RNTK output and suggests a simple method to select them a priori in a deliberate manner.
To visualize the role of the RNTK hyperparameters, we introduce the {\it sensitivity} $s(t)$ of the RNTK of two input sequences
${\bm{x}}$ and ${\bm{x}}'$ with respect to the input ${\bm{x}}_t$ at time $t$
\begin{align}
s(t) = \|\nabla_{{\bm{x}}_t} \Theta({\bm{x}},{\bm{x}}') \|_2\,.\label{eq:rntk-gradient}
\end{align}
Here, $s(t)$ indicates how sensitive the RNTK is to the data at time $t$, i.e., ${\bm{x}}_t$, in presence of another data sequence ${\bm{x}}'$.
Intuitively, large/small $s(t)$ indicates that the RNTK is relatively sensitive/insensitive to the input ${\bm{x}}_t$ at time $t$.
The sensitivity is crucial to understanding to which extent the RNTK prediction is impacted by the
input at each time step. In the case where some time indices have a small sensitivity, then any input variation in those corresponding times will not alter the RNTK output and thus will produce a metric that is invariant to those changes.
This situation can be beneficial or detrimental based on the task at hand. Ideally, and in the absence of prior knowledge on the data, one should aim to have a roughly constant sensitivity across time in order to treat all time steps equally in the RNTK input comparison.
Figure \ref{fig:sensitivity} plots the normalized sensitivity $s(t)/{\rm max}_t(s(t))$ for two data sequences of the same length $T = 100$, with $s(t)$ computed numerically for ${\bm{x}}_t, {\bm{x}}'_t \sim \mathcal{N}(0,1)$. We repeated the experiments 10000 times; the mean of the sensitivity is shown in Figure \ref{fig:sensitivity}. Each of the plots shows the changes of parameters $\mathcal{S}_{\rm ReLU} = \{ \sqrt{2},1,0,0\}$ for $\phi = \rm ReLU$ and $\mathcal{S}_{\rm erf} = \{ 1,0.01,0.05,0\}$ for $\phi = \rm erf$.
From Figure \ref{fig:sensitivity} we first observe that both $\mathrm{ReLU}$ and $\mathrm{erf}$ show
similar per time step sensitivity measure $s(t)$ behavior around the hyperparameters $\mathcal{S}_{\rm ReLU}$ and $\mathcal{S}_{\rm erf}$. If one varies any of the weight variance parameters, the sensitivity exhibits a wide range of behavior, and in particular with $\rm erf$.
We observe that $\sigma_w$ has a major influence on $s(t)$. For $\rm ReLU$, a small decrease/increase in $\sigma_w$ can lead to over-sensitivity of the RNTK to data at the last/first times steps, whereas for $\rm erf$, any changes in $\sigma_w$ leads to over-sensitivity to the last time steps.
Another notable observation is the importance of $\sigma_h$, which is usually set to zero for RNNs. \cite{wang2018a} showed that a non-zero $\sigma_h$ acts as a regularization that improves the performance of RNNs with the $\rm ReLU$ nonlinearity.
From the sensitivity perspective, a non-zero $\sigma_h$ results in reducing the importance of the first time steps of the input. We also see the same behavior in $\rm erf$, but with stronger changes as $\sigma_h$ increases. Hence whenever one aims at reinforcing the input pairwise comparisons, such parameters should be favored.
This sensitivity analysis provides a practical tool for RNTK hyperparameter tuning. In the absence of knowledge about the data, hyperparameters should be chosen to produce the least time varying sensitivity. If given a priori knowledge, hyperparameters can be selected that direct the RNTK to the desired time-steps.
\vspace*{-2mm}
\section{Experiments}
\vspace*{-2mm}
\label{sec:exp}
We now empirically validate the performance of the RNTK compared to classic kernels, NTKs, and trained RNNs on both classification and regression tasks using a large number of time series data sets.
Of particular interest is the capability of the RNTK to offer high performance even on inputs of different lengths.
\iffalse
\begin{table}
\centering
\caption{Summary of time series classification results on 56 real-world data sets. RNTK outperforms all other kernels that we consider as well as several trained RNNs, including GRU, across all metrics. Lower Friedman ranking and higher Average accuracy (Acc. mean), P90/95, and Percentage of Maximum Accuracy (PMA) indicated better performance. See Appendix \ref{appendix:experiments} for detailed description of the metrics. }
{
\begin{adjustbox}{width=\columnwidth,center}
\begin{tabular}{lccccccc}
\toprule
\textbf{} & \textbf{RNTK} & \textbf{NTK} & \textbf{RBF} &\textbf{Polynomial} & \textbf{Gaussian RNN} & \textbf{Identity RNN} & \textbf{GRU}\\ \hline
Acc. mean $\uparrow$ & \textbf{80.44}\% & 78.29\% & 78.46\% & 78.68\% & 57.34\% & 64.68\% & 70.58\%\\
Acc. std & 16.08\% & 16.82\% & 16.76\% & 16.58\% &26.29\%& 18.11\%& 22.70\% \\
P90 $\uparrow$ & \textbf{92.45\%} & 86.79\% & 88.68\% & 81.13\% & 30.19\% & 45.28\% & 64.15\% \\
P95 $\uparrow$ & \textbf{81.13\%} & 69.81\% & 77.36\% & 66.04\% & 18.87\% & 22.64\% & 49.06\% \\
PMA $\uparrow$ & \textbf{97.29\%} & 94.64\% & 94.89\% & 93.91\% & 68.54\% & 79.90\% & 85.24\% \\
Friedman Rank $\downarrow$ & \textbf{2.35} & 2.96 & 2.90 & 3.60 & 5.81 & 5.16 & 4.15 \\
\bottomrule
\end{tabular}
\end{adjustbox}
}
\label{tab:real-data-svm}
\end{table}
\fi
\iffalse
\begin{table}
\centering
\caption{Summary of time series classification results on 56 real-world data sets. The RNTK outperforms classical kernels, the NTK, and trained RNNs across all metrics. See Appendix \ref{appendix:experiments} for detailed description of the metrics. }
\vspace{-5pt}
{
\begin{adjustbox}{width=\columnwidth,center}
\begin{tabular}{lccccccc}
\toprule
\textbf{} & \textbf{RNTK} & \textbf{NTK} & \textbf{RBF} &\textbf{Polynomial} & \textbf{Gaussian RNN} & \textbf{Identity RNN} & \textbf{GRU}\\ \hline
Acc. mean $\uparrow$ & \textbf{79.60}\% \textbf{$\pm$ 15.98}\% & 77.96\% $\pm$ 16.13\% & 78.44\% $\pm$ 16.38\% & 78.02\% $\pm$ 15.98\% & 54.93\% $\pm$ 26.13\% & 63.99\% $\pm$ 19.40 \% & 69.56\% $\pm$ 22.43\\
P90 $\uparrow$ & \textbf{88.57\%} & 84.29\% & \textbf{88.57}\% & 85.71\% & 30.00\% & 42.86\% & 60.00\% \\
P95 $\uparrow$ & \textbf{75.71\%} & 68.57\% & 72.86\% & 67.14\% & 20.00\% & 22.86\% & 45.71\% \\
PMA $\uparrow$ & \textbf{96.49\%} & 94.46\% & 95.13\% & 94.63\% & 66.32\% & 78.92\% & 84.33\% \\
Friedman Rank $\downarrow$ & \textbf{2.59} & 2.96 & 2.96 & 3.34 & 5.77 & 5.23 & 4.23 \\
\bottomrule
\end{tabular}
\end{adjustbox}
}
\label{tab:real-data-svm}
\end{table}
\fi
\begin{table}
\centering
\caption{Summary of time series classification results on 56 real-world data sets. The RNTK outperforms classical kernels, the NTK, and trained RNNs across all metrics. See Appendix \ref{appendix:experiments} for detailed description of the metrics. }
\vspace{-0pt}
{
\begin{adjustbox}{width=\columnwidth,center}
\begin{tabular}{lccccccc}
\toprule
\textbf{} & \textbf{RNTK} & \textbf{NTK} & \textbf{RBF} &\textbf{Polynomial} & \textbf{Gaussian RNN} & \textbf{Identity RNN} & \textbf{GRU}\\ \hline
Acc. mean $\uparrow$ & \textbf{80.15}\% \textbf{$\pm$ 15.99}\% & 77.74\% $\pm$ 16.61\% & 78.15\% $\pm$ 16.59\% & 77.69\% $\pm$ 16.40\% & 55.98\% $\pm$ 26.42\% & 63.08\% $\pm$ 19.02 \% & 69.50\% $\pm$ 22.67\\
P90 $\uparrow$ & \textbf{92.86\%} & 85.71\% & 87.60\% & 82.14\% & 28.57\% & 42.86\% & 60.71\% \\
P95 $\uparrow$ & \textbf{80.36\%} & 66.07\% & 75.00\% & 67.86\% & 17.86\% & 21.43\% & 46.43\% \\
PMA $\uparrow$ & \textbf{97.23\%} & 94.30\% & 94.86\% & 94.23\% & 67.06\% & 78.22\% & 84.31\% \\
Friedman Rank $\downarrow$ & \textbf{2.38} & 3.00 & 2.89 & 3.46 & 5.86 & 5.21 & 4.21 \\
\bottomrule
\end{tabular}
\end{adjustbox}
}
\label{tab:real-data-svm}
\end{table}
{\bf Time Series Classification.}~
The first set of experiments considers time series inputs of the same lengths from 56 datasets in the UCR time-series classification data repository \cite{Dau_2019}.
We restrict ourselves to selected data sets with fewer than $1000$ training samples and fewer than $1000$ time steps ($T$) as kernel methods become rapidly intractable for larger datasets.
We compare the RNTK with a variety of other kernels, including the Radial Basis Kernel (RBF), polynomial kernel, and NTK \cite{jacot2018neural}, as well as finite RNNs with Gaussian, identity \cite{relu_rnn} initialization, and GRU \cite{gru}.
We use $\phi = \rm ReLU$ for both the RNTKs and NTKs.
For each kernel, we train a C-SVM \cite{CC01a} classifier, and for each finite RNN we use gradient descent training.
For model hyperparameter tuning, we use 10-fold cross-validation. Details on the data sets and experimental setup are available in Appendix \ref{appendix:exp-classification}.
We summarize the classification results over all 56 datasets in
Table~\ref{tab:real-data-svm}; detailed results on each data set is available in Appendix \ref{appendix:exp-regression}.
We see that the RNTK outperforms not only the classical kernels but also the NTK and trained RNNs in all metrics.
The results demonstrate the ability of RNTK to provide increased performances compare to various other methods (kernels and RNNs). The superior performance of RNTK compared to other kernels, including NTK, can be explained by the internal recurrent mechanism present in RNTK, allowing time-series adapted sample comparison. In addition, RNTK also outperforms RNN and GRU. As the datasets we consider are relative small in size, finite RNNs and GRUs that typically require large amount of data to succeed do not perform well in our setting. An interesting future direction would be to compare RNTK to RNN/GRU on larger datasets.
\begin{figure}[t]
\centering
\begin{minipage}{0.02\textwidth}
\rotatebox{90}{\;\;\;\;\;\; {\small SNR}}
\end{minipage}
\begin{minipage}{0.23\textwidth}
\centering
\subfloat[Sinusoidal signal]{\includegraphics[width=\linewidth]{./figures/anew.eps} \label{fig4a} }\\
{\small $T_{\rm var}$}
\end{minipage}\hfil
\begin{minipage}{0.23\textwidth}
\centering
\subfloat[Sinusoidal signal]{\includegraphics[width=\linewidth]{./figures/bnew.eps} \label{fig4b}}\\
{\small $\sigma_n$}
\end{minipage}\hfil
\begin{minipage}{0.23\textwidth}
\centering
\subfloat[Google stock value]{\includegraphics[width=\linewidth]{./figures/cnew.eps} \label{fig4c}}\\
{\small $T_{\rm var}$}
\end{minipage}
\begin{minipage}{0.23\textwidth}
\centering
\subfloat[Google stock value]{\includegraphics[width=\linewidth]{./figures/dnew.eps} \label{fig4d}}\\
{\small $N_{\rm train}$}
\end{minipage}
\caption{\small
Performance of the RNTK on
the synthetic sinusoid and real-world Google stock price data sets compared to three other kernels.
We vary the input lengths (a,c), the input noise level (b), and training set size (d).
We compute the average SNR by repeating each experiment 1000 times.
The RNTK clearly outperforms all of the other kernels under consideration.
Figure~4b suggests that the RNTK performs better when input noise level is low demonstrating one case where time recurrence from RNTK might be sub-optimal as it collects and accumulate the high noise from each time step as opposed to other kernels treating each independently.
}
\label{fig:differentlength}
\end{figure}
{\bf Time Series Regression.}~
We now validate the performance of the RNTK on time series inputs of {\it different} lengths on both synthetic data and real data. For both scenarios, the target is to predict the next time-step observation of the randomly extracted windows of different length using kernel ridge regression.
We compare the RNTK to other kernels, the RBF and polynomial kernels and the NTK. We also compare our results with a data independent predictor that requires no training, that is simply to predict the next time step with previous time step (PTS).
For the synthetic data experiment, we simulate 1000 samples of one period of a sinusoid and add white Gaussian noise with default $\sigma_n = 0.05$.
From this fixed data, we extract training set size $N_{\rm train} = 20$ segments of uniform random lengths in the range of $[ T_{\rm fixed}, T_{\rm fixed} + T_{\rm var}]$ with $T_{\rm fixed} = 10$.
We use standard kernel ridge regression for this task. The test set is comprised of $N_{\rm test} = 5000$ obtained from other randomly extracted segments, again of varying lengths.
For the real data, we use $975$ days of the Google stock value in the years 2014--2018.
As in the simulated signal setup above, we extract $N_{\rm train}$ segments of different lengths from the first 700 days and test on the $N_{\rm test}$ segments from days 701 to 975. Details of the experiment are available in Appendix \ref{exp:reg}.
We report the predicted signal-to-noise ratio (SNR) for both datasets in Figures \ref{fig4a} and \ref{fig4c} for various values of $T_{\rm var}$.
We vary the noise level and training set size for fixed $T_{\rm var} = 10$ in Figures \ref{fig4b} and \ref{fig4d}.
As we see from Figures~\ref{fig4a} and \ref{fig4c}, the RNTK offers substantial performance gains compared to the other kernels, due to its ability to naturally deal with variable length inputs.
Moreover, the performance gap increases with the amount of length variation of the inputs $T_{\rm var}$.
Figure~\ref{fig4d} demonstrates that, unlike the other methods, the RNTK maintains its performance even when the training set is small.
Finally, Figure~\ref{fig4c} demonstrates that the impact of noise in the data on the regression performance
is roughly the same for all models but becomes more important for RNTK with a large $\sigma_n$; this might be attributed to the recurrent structure of the model allowing for a time propagation and amplification of the noise for very low SNR.
These experiments demonstrate the distinctive advantages of the RNTK over classical kernels, and NTKs for input data sequences of varying lengths.
In the case of PTS, we expect the predictor to outperform kernel methods when learning from the training samples is hard, due to noise in the data or small training size which can lead to over fitting. In Figure~\ref{fig4a} RNTK and Polynomial kernels outperforms PTS for all values of $T_{\rm var}$, but for larger $T_{\rm var}$, NTK and RBF under perform PTS due to the increasing detrimental effect of zero padding. For the Google stock value, we see a superior performance of PTS with respect to all other kernel methods due to the nature of those data heavily relying on close past data.
However, RNTK is able to reduce the effect of over-fitting, and provide the closest results to PTS among all kernel methods we employed, with increasing performance as the number of training samples increase.
\vspace*{-2mm}
\section{Conclusions}
\vspace*{-2mm}
In this paper, we have derived the RNTK based on the architecture of a simple RNN.
We have proved that, at initialization, after training, and without weight sharing, any simple RNN converges to the same RNTK. This convergence provides new insights into the behavior of infinite-width RNNs, including how they process different-length inputs, their training dynamics, and the sensitivity of their output at every time step to different nonlinearities and initializations.
We have highlighted the RNTK's practical utility by demonstrating its superior performance on time series classification and regression compared to a range of classical kernels, the NTK, and trained RNNs. There are many avenues for future research, including developing RNTKs for gated RNNs such as the LSTM~\cite{hochreiter1997long} and investigating which of our theoretical insights extend to finite RNNs.
\section*{Acknowledgments}
This work was supported by NSF grants CCF-1911094, IIS-1838177, and IIS-1730574; ONR grants N00014-18-12571, N00014-20-1-2787, and N00014-20-1-2534; AFOSR grant FA9550-18-1-0478; and a Vannevar Bush Faculty Fellowship, ONR grant N00014-18-1-2047.
| {'timestamp': '2021-06-16T02:07:52', 'yymm': '2006', 'arxiv_id': '2006.10246', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10246'} | arxiv |
\section{Introduction}
Imagine walking in the darkness. Purely based on the sense of self-motion, one can gain a sense of self-position by integrating the self motion - a process often referred to as path integration~\citep{Darwin1873,Etienne2004,hafting2005microstructure, fiete2008grid, mcnaughton2006path}. While the exact neural underpinning of path integration remains unclear, it has been hypothesized that the grid cells~\citep{hafting2005microstructure, fyhn2008grid, yartsev2011grid, killian2012map, jacobs2013direct, doeller2010evidence} in the mammalian medial entorhinal cortex (mEC) may be involved in this process~\citep{gil2018impaired, ridler2019impaired, horner2016grid}.
The grid cells are so named because individual neurons exhibit striking firing patterns that form hexagonal grids when the agent (such as a rat) navigates in a 2D open field ~\citep{Fyhn2004,hafting2005microstructure,Fuhs2006,burak2009accurate, sreenivasan2011grid, blair2007scale,Couey2013, de2009input,Pastoll2013,Agmon2020}.
The grid cells also interact with the place cells in the hippocampus~\citep{o1979review}. Unlike a grid cell that fires at the vertices of a lattice, a place cell often fires at a single (or a few) locations.
The purpose of this paper is to understand how the grid cells may perform path integration calculations. We study a general optimization-based representational model in which the 2D self-position is represented by a higher dimensional vector and the 2D self-motion is represented by a transformation of the vector. The vector representation can be considered position encoding or position embedding, where the elements of the vector may be interpreted as activities of a population of grid cells. The transformation can be realized by a recurrent network that acts on the vector. Our focus is to study the properties of the transformation.
Specifically, we identify two conditions for the transformation: a group representation condition and an isotropic scaling condition, under which we demonstrate that the local neighborhood around each self-position in the 2D physical space is embedded conformally as a 2D neighborhood around the vector representation of the self-position in the neural space.
We then investigate the simplest special case of the transformation, i.e., linear transformation, that forms a matrix Lie group of rotation, under which case we show that the isotropic scaling condition is connected to a special class of hexagonal grid patterns. Our numerical experiments demonstrate that our model learns clear hexagon grid patterns of multiple scales which share observed properties of the grid cells in the rodent brain, by optimizing a simple loss function. The learned model is also capable of accurate long distance path integration.
{\bf Contributions}. Our work contributes to understanding the grid cells from the perspective of representation learning. We conduct theoretical analysis of (1) general transformation for path integration by identifying two key conditions and a local conformal embedding property, (2) linear transformation by revealing the algebraic and geometric structure and connecting the isotropic scaling condition and a special class of hexagon grid patterns, and (3) integration of linear transformation model and linear basis expansion model via unitary group representation theory. Experimentally we learn clear hexagon grid patterns that are consistent with biological observations, and the learned model is capable of accurate path integration.
\section{General transformation}
\begin{wrapfigure}{r}{0.5\linewidth}
\centering
\begin{tabular}{cc}
\includegraphics[width=.44\linewidth]{./fig/s1_new} &
\includegraphics[width=.5\linewidth]{./fig/s2_new} \\
{\small (a) physical space} & {\small (b) neural space}
\end{tabular}
\caption{\small The local 2D polar system around self-position ${\bm{x}}$ in the 2D physical space (a) is embedded conformally as a 2D polar system around vector ${\bm{v}}({\bm{x}})$ in the $d$-dimensional neural space (b), with a scaling factor $s$ (so that $\delta r$ in the physical space becomes $s \delta r$ in the neural space while the angle $\theta$ is preserved).
}
\vspace{-.4cm}
\label{fig:g}
\end{wrapfigure}
\subsection{Position embedding}
Consider an agent (e.g., a rat) navigating within a 2D open field. Let ${\bm{x}} = ({x}_1, {x}_2)$ be the self-position of the agent. We assume that the self-position ${\bm{x}}$ in the 2D physical space is represented by the response activities of a population of $d$ neurons (e.g., $d = 200$), which form a vector ${\bm{v}}({\bm{x}}) = ({v}_i({\bm{x}}), i = 1, ..., d)^\top$ in the $d$-dimensional ``neural space'', with each element ${v}_i({\bm{x}})$ representing the firing rate of one neuron when the animal is at location ${\bm{x}}$.
${\bm{v}}({\bm{x}})$ can be called position encoding or position embedding. Collectively, $({\bm{v}}({\bm{x}}), \forall {\bm{x}})$ forms a {\em codebook} of ${\bm{x}} \in \mathbb{R}^2$, and $({\bm{v}}({\bm{x}}), \forall {\bm{x}})$ is a {\em 2D manifold} in the $d$-dimensional neural space, i.e., globally we embed $\mathbb{R}^2$ as a 2D manifold in the neural space. Locally, we identify two conditions under which the 2D local neighborhood around each ${\bm{x}}$ is embedded {\em conformally} as a 2D neighborhood around ${\bm{v}}({\bm{x}})$ with a scaling factor. See Fig. \ref{fig:g}. As shown in Section \ref{sect:hexagon}, the conformal embedding is connected to the hexagon grid patterns.
\subsection{Transformation and path integration}
At self-position ${\bm{x}}$, if the agent makes a self-motion $\Delta {\bm{x}} = (\Delta {x}_1, \Delta {x}_2)$, then it moves to ${\bm{x}} + \Delta {\bm{x}}$. Correspondingly, the vector representation ${\bm{v}}({\bm{x}})$ is transformed to ${\bm{v}}({\bm{x}}+\Delta {\bm{x}})$. The general form of the transformation can be formulated as:
\begin{eqnarray}
{\bm{v}}({\bm{x}} + \Delta {\bm{x}}) = F({\bm{v}}({\bm{x}}), \Delta {\bm{x}}). \label{eq:PI0}
\end{eqnarray}
The transformation $F(\cdot, \Delta {\bm{x}})$ can be considered a representation of $\Delta {\bm{x}}$, which forms a 2D additive group. We call Eq. (\ref{eq:PI0}) the {\em transformation model}. It can be implemented by a recurrent network to derive a path integration model: if the agent starts from ${\bm{x}}_0$, and makes a sequence of moves $(\Delta {\bm{x}}_t, t = 1, ..., T)$, then the vector is updated by ${\bm{v}}_{t} = F({\bm{v}}_{t-1}, \Delta {\bm{x}}_t)$, where ${\bm{v}}_0 = {\bm{v}}({\bm{x}}_0)$, and $t = 1, ..., T$.
\subsection{Group representation condition}
The solution to the transformation model (Eq. (\ref{eq:PI0})) should satisfy the following condition.
\begin{cond} \label{cond:1}
(Group representation condition) $({\bm{v}}({\bm{x}}), \forall {\bm{x}})$ and $(F(\cdot, \Delta {\bm{x}}), \forall \Delta {\bm{x}})$ form a representation of the 2D additive Euclidean group $\mathbb{R}^2$ in the sense that
\begin{eqnarray}
&&F({\bm{v}}({\bm{x}}), 0) = {\bm{v}}({\bm{x}}), \; \forall {\bm{x}}; \label{eq:attract} \\
&&F({\bm{v}}({\bm{x}}), \Delta {\bm{x}}_1 + \Delta {\bm{x}}_2) = F(F({\bm{v}}({\bm{x}}), \Delta {\bm{x}}_1), \Delta {\bm{x}}_2), \; \forall {\bm{x}}, \Delta {\bm{x}}_1, \Delta {\bm{x}}_2. \label{eq:gr}
\end{eqnarray}
\end{cond}
$(F(\cdot, \Delta {\bm{x}}), \forall \Delta {\bm{x}})$ is a Lie group of transformations acting on the codebook manifold $({\bm{v}}({\bm{x}}), \forall {\bm{x}})$.
The reason for (\ref{eq:attract}) is that if $\Delta {\bm{x}} = 0$, then $F(\cdot, 0)$ should be the identity transformation. Thus the codebook manifold $({\bm{v}}({\bm{x}}), \forall {\bm{x}})$ consists of fixed points of the transformation $F(\cdot, 0)$. If $F(\cdot, 0)$ is furthermore a contraction around $({\bm{v}}({\bm{x}}), \forall {\bm{x}})$, then $({\bm{v}}({\bm{x}}), \forall {\bm{x}})$ are the attractor points.
The reason for (\ref{eq:gr}) is that the agent can move in one step by $\Delta {\bm{x}}_1 + \Delta {\bm{x}}_2$, or first move by $\Delta {\bm{x}}_1$, and then move by $\Delta {\bm{x}}_2$. Both paths would end up at the same ${\bm{x}} + \Delta {\bm{x}}_1 + \Delta {\bm{x}}_2$, which is represented by the same ${\bm{v}}({\bm{x}}+\Delta {\bm{x}}_1 + \Delta {\bm{x}}_2)$.
The group representation condition is a necessary self-consistent condition for the transformation model (Eq. (\ref{eq:PI0})).
\subsection{Egocentric self-motion}
Self-motion $\Delta {\bm{x}}$ can also be parametrized egocentrically as $(\Delta r, \theta)$, where $\Delta r$ is the displacement along the direction $\theta \in [0, 2\pi]$, so that $\Delta {\bm{x}} = (\Delta {x}_1 = \Delta r \cos \theta, \Delta {x}_2 = \Delta r \sin \theta)$. The egocentric self-motion may be more biologically plausible where $\theta$ is encoded by head direction, and $\Delta r$ can be interpreted as the speed along direction $\theta$. The transformation model then becomes
\begin{eqnarray}
{\bm{v}}({\bm{x}} + \Delta {\bm{x}}) = F({\bm{v}}({\bm{x}}), \Delta r, \theta), \label{eq:PI2}
\end{eqnarray}
where we continue to use $F(\cdot)$ for the transformation (with slight abuse of notation). $(\Delta r, \theta)$ form a polar coordinate system around ${\bm{x}}$.
\subsection{Infinitesimal self-motion and directional derivative}
In this subsection, we derive the transformation model for infinitesimal self-motion. While we use $\Delta {\bm{x}}$ or $\Delta r$ to denote finite (non-infinitesimal) self-motion, we use $\delta {\bm{x}}$ or $\delta r$ to denote infinitesimal self-motion. At self-position ${\bm{x}}$, for an infinitesimal displacement $\delta r$ along direction $\theta$, $\delta {\bm{x}} = (\delta {x}_1 = \delta r \cos \theta, \delta {x}_2 = \delta r \sin \theta)$. See Fig. \ref{fig:g} (a) for an illustration. Given that $\delta r$ is infinitesimal, for any fixed $\theta$, a first order Taylor expansion of $F({\bm{v}}({\bm{x}}), \delta r, \theta)$ with respect to $\delta r$ gives us
\begin{align}
{\bm{v}}({\bm{x}} + \delta {\bm{x}}) &=F({\bm{v}}({\bm{x}}), \delta r, \theta) = F({\bm{v}}({\bm{x}}), 0, \theta) + F'({\bm{v}}({\bm{x}}), 0, \theta) \delta r + o(\delta r) \nonumber
\\&= {\bm{v}}({\bm{x}}) + f_\theta({\bm{v}}({\bm{x}})) \delta r + o(\delta r),
\label{eq:inf}
\end{align}
where $F({\bm{v}}({\bm{x}}), 0, \theta) = {\bm{v}}({\bm{x}})$ according to Condition \ref{cond:1}, and $f_\theta({\bm{v}}({\bm{x}})) \coloneqq F'({\bm{v}}({\bm{x}}), 0, \theta)$ is the first derivative of $F({\bm{v}}({\bm{x}}), \Delta r, \theta)$ with respect to $\Delta r$ at $\Delta r = 0$. $f_\theta({\bm{v}}({\bm{x}}))$ is the {\em directional derivative} of $F(\cdot)$ at self-position ${\bm{x}}$ and direction $\theta$.
For a fixed $\theta$, $(F(\cdot, \Delta r, \theta), \forall \Delta r)$ forms a one-parameter Lie group of transformations, and $f_\theta(\cdot)$ is the generator of its Lie algebra.
\subsection{Isotropic scaling condition}
With the directional derivative, we define the second condition as follows, which leads to locally conformal embedding and is connected to hexagon grid pattern.
\begin{cond} \label{cond:2}
(Isotropic scaling condition) For any fixed ${\bm{x}}$, $\|f_\theta({\bm{v}}({\bm{x}}))\|$ is constant over $\theta$.
\end{cond}
Let $f_0({\bm{v}}({\bm{x}}))$ denote $f_\theta({\bm{v}}({\bm{x}}))$ for $\theta = 0$, and $f_{\pi/2}({\bm{v}}({\bm{x}}))$ denote $f_\theta({\bm{v}}({\bm{x}}))$ for $\theta = \pi/2$. Then we have the following theorem:
\begin{theorem} \label{theorem:1}
Assume group representation condition \ref{cond:1} and isotropic scaling condition \ref{cond:2}. At any fixed ${\bm{x}}$, for the local motion $\delta {\bm{x}} = (\delta r \cos \theta, \delta r \sin \theta)$ around ${\bm{x}}$, let $\delta {\bm{v}} = {\bm{v}}({\bm{x}}+\delta {\bm{x}}) - {\bm{v}}({\bm{x}})$ be the change of vector and $s = \|f_\theta({\bm{v}}({\bm{x}}))\|$, then we have $\|\delta {\bm{v}}\| = s \|\delta {\bm{x}}\|$. Moreover,
\begin{align}
\delta {\bm{v}}
= f_\theta({\bm{v}}({\bm{x}})) \delta r + o(\delta r)= f_0({\bm{v}}({\bm{x}})) \delta r \cos \theta + f_{\pi/2}({\bm{v}}({\bm{x}})) \delta r \sin \theta + o(\delta r),
\end{align}
where $f_0({\bm{v}}({\bm{x}}))$ and $f_{\pi/2}({\bm{v}}({\bm{x}}))$ are two orthogonal basis vectors of equal norm $s$.
\end{theorem}
See Supplementary for a proof and Fig. \ref{fig:g}(b) for an illustration. Theorem \ref{theorem:1} indicates that the local 2D polar system around self-position ${\bm{x}}$ in the 2D physical space is embedded conformally as a 2D polar system around vector ${\bm{v}}({\bm{x}})$ in the $d$-dimensional neural space, with a scaling factor $s$ (our analysis is local for any fixed ${\bm{x}}$, and $s$ may depend on ${\bm{x}}$). Conformal embedding is a generalization of isometric embedding, where the metric can be changed by a scaling factor $s$. If $s$ is globally constant for all ${\bm{x}}$, then the intrinsic geometry of the codebook manifold $({\bm{v}}({\bm{x}}), \forall {\bm{x}})$ remains Euclidean, i.e., flat.
{\bf Why isotropic scaling and conformal embedding?} The neurons are intrinsically noisy. During path integration, the errors may accumulate in ${\bm{v}}$. Moreover, when inferring self-position from visual image, it is possible that ${\bm{v}}$ is inferred first with error, and then ${\bm{x}}$ is decoded from the inferred ${\bm{v}}$. Due to isotropic scaling and conformal embedding, locally we have $\|\delta {\bm{v}}\| = s \|\delta {\bm{x}}\|$, which guarantees that the $\ell_2$ error in ${\bm{v}}$ translates proportionally to the $\ell_2$ error in ${\bm{x}}$, so that there will not be adversarial perturbations in ${\bm{v}}({\bm{x}})$ that cause excessively big errors in ${\bm{x}}$. Specifically, we have the following theorem.
\begin{theorem} \label{theorem:a}
Assume the general transformation model (Eq. (\ref{eq:PI2})) and the isotropic scaling condition. For any fixed ${\bm{x}}$, let $s = \|f_\theta({\bm{v}}({\bm{x}}))\|$, which is independent of $\theta$. Suppose the neurons are noisy: ${\bm{v}} = {\bm{v}}({\bm{x}}) + {\bf \epsilon}$, where ${\bf \epsilon} \sim \mathcal{N}(0, \tau^2 {\bm{I}}_d)$ and $d$ is the dimensionality of ${\bm{v}}$. Suppose the agent infers its 2D position $\hat{{\bm{x}}}$ from ${\bm{v}}$ by $\hat{{\bm{x}}} = \arg\min_{{\bm{x}}'}\|{\bm{v}} - {\bm{v}}({\bm{x}}')\|^2$, i.e., ${\bm{v}}(\hat{{\bm{x}}})$ is the projection of ${\bm{v}}$ onto the 2D manifold formed by $({\bm{v}}({\bm{x}}'), \forall {\bm{x}}')$. Then we have
\begin{align}
\mathbb{E}\|\hat{{\bm{x}}} - {\bm{x}}\|^2 = 2 \tau^2/s^2.
\end{align}
\end{theorem}
See Supplementary for a proof.
{\bf Connection to continuous attractor neural network (CANN) defined on 2D torus}. The group representation condition and the isotropic scaling condition appear to be satisfied by the CANN models
\citep{amit1992modeling,burak2009accurate,Couey2013,Pastoll2013,Agmon2020} that are typically hand-designed on a 2D torus. See Supplementary for details.
\section{Linear transformation}
After studying the general transformation, we now investigate the linear transformation of ${\bm{v}}({\bm{x}})$, for the following reasons. (1) It is the simplest transformation for which we can derive explicit algebraic and geometric results. (2) It enables us to connect the isotropic scaling condition to a special class of hexagon grid patterns. (3) In Section \ref{sect:i}, we integrate it with the basis expansion model, which is also linear in ${\bm{v}}({\bm{x}})$, via unitary group representation theory.
For finite (non-infinitesimal) self-motion, the linear transformation model is:
\begin{eqnarray} \label{eqn:linear}
{\bm{v}}({\bm{x}} + \Delta {\bm{x}}) = F({\bm{v}}({\bm{x}}), \Delta {\bm{x}}) = {\bm{M}}(\Delta {\bm{x}}) {\bm{v}}({\bm{x}}),
\end{eqnarray}
where ${\bm{M}}(\Delta {\bm{x}})$ is a matrix. The group representation condition becomes ${\bm{M}}(\Delta {\bm{x}}_1 + \Delta {\bm{x}}_2) {\bm{v}}({\bm{x}}) = {\bm{M}}(\Delta {\bm{x}}_2) {\bm{M}}(\Delta {\bm{x}}_1) {\bm{v}}({\bm{x}})$, i.e., ${\bm{M}}(\Delta {\bm{x}})$ is a matrix representation of self-motion $\Delta {\bm{x}}$, and ${\bm{M}}(\Delta {\bm{x}})$ acts on the coding manifold $({\bm{v}}({\bm{x}}), \forall {\bm{x}})$). For egocentric parametrization of self-motion $(\Delta r, \theta)$, we can further write ${\bm{M}}(\Delta {\bm{x}}) = {\bm{M}}_\theta(\Delta r)$ for $\Delta {\bm{x}} = (\Delta r \cos \theta, \Delta r \sin \theta)$, and the linear model becomes ${\bm{v}}({\bm{x}} + \Delta {\bm{x}}) = F({\bm{v}}({\bm{x}}), \Delta r, \theta) = {\bm{M}}_\theta(\Delta r) {\bm{v}}({\bm{x}})$.
\subsection{Algebraic structure: matrix Lie algebra and Lie group} \label{sect:algebraic}
For the linear model (Eq. (\ref{eqn:linear})), the directional derivative is: $f_\theta({\bm{v}}({\bm{x}})) = F'({\bm{v}}({\bm{x}}), 0, \theta) = {\bm{M}}'_\theta(0) {\bm{v}}({\bm{x}}) = {\bm{B}}(\theta) {\bm{v}}({\bm{x}})$, where ${\bm{B}}(\theta) = {\bm{M}}'_\theta(0)$, which is the derivative of ${\bm{M}}_\theta(\Delta r)$ with respect to $\Delta r$ at $0$.
For infinitesimal self-motion, the transformation model in Eq. (\ref{eq:inf}) becomes
\begin{eqnarray}
{\bm{v}}({\bm{x}}+\delta {\bm{x}}) = ({\bm{I}} + {\bm{B}}(\theta) \delta r) {\bm{v}}({\bm{x}}) + o(\delta r), \label{eq:a1}
\end{eqnarray}
where ${\bm{I}}$ is the identity matrix. It can be considered a linear recurrent network where ${\bm{B}}(\theta)$ is the learnable weight matrix. We have the following theorem for the algebraic structure of the linear transformation.
\begin{theorem} \label{theorem:2}
Assume the linear transformation model so that for infinitesimal self-motion $(\delta r, \theta)$, the model is in the form of Eq. (\ref{eq:a1}), then for finite displacement $\Delta r$,
\begin{equation} \label{eq:linear2}
{\bm{v}}({\bm{x}} + \Delta {\bm{x}}) = {\bm{M}}_\theta(\Delta r) {\bm{v}}({\bm{x}}) = \exp({\bm{B}}(\theta) \Delta r) {\bm{v}}({\bm{x}}).
\end{equation}
\end{theorem}
\begin{proof}
We can divide $\Delta r$ into $N$ steps, so that $\delta r = \Delta r/N \rightarrow 0$ as $N \rightarrow \infty$, and
\begin{align} \label{eq:1}
{\bm{v}}({\bm{x}}+\Delta {\bm{x}}) &= ({\bm{I}} + {\bm{B}}(\theta) (\Delta r/N) + o(1/N))^N {\bm{v}}({\bm{x}})
\rightarrow \exp({\bm{B}}(\theta) \Delta r) {\bm{v}}({\bm{x}})
\end{align}
as $N \rightarrow \infty$. The matrix exponential map is defined by $\exp(A) = \sum_{n=0}^{\infty} A^{n}/n!$.
\end{proof}
The above math underlies the relationship between matrix Lie algebra and matrix Lie group in general~\citep{taylor2002lectures}. For a fixed $\theta$, the set of ${\bm{M}}_\theta(\Delta r) = \exp({\bm{B}}(\theta) \Delta r)$ for $\Delta r \in \mathbb{R}$ forms a {\em matrix Lie group}, which is both a group and a manifold. The tangent space of ${\bm{M}}_\theta(\Delta r)$ at identity ${\bm{I}}$ is called {\em matrix Lie algebra}. ${\bm{B}}(\theta)$ is the basis of this tangent space, and is often referred to as the {\em generator matrix}.
{\bf Path integration}. If the agent starts from ${\bm{x}}_0$, and make a sequence of moves $((\Delta r_t, \theta_t), t = 1, ..., T)$, then the vector representation of self-position is updated by
\begin{eqnarray}
{\bm{v}}_{t} = \exp({\bm{B}}(\theta_t) \Delta r_t) {\bm{v}}_{t-1}, \label{eq:PI}
\end{eqnarray}
where ${\bm{v}}_0 = {\bm{v}}({\bm{x}}_0)$, and $t = 1, ..., T$.
{\bf Approximation to exponential map}. For a finite but small $\Delta r$, $\exp({\bm{B}}(\theta) \Delta r)$ can be approximated by a second-order (or higher-order) Taylor expansion
\begin{eqnarray}
\exp({\bm{B}}(\theta)\Delta r) = {\bm{I}} + {\bm{B}}(\theta)\Delta r + {\bm{B}}(\theta)^2 \Delta r^2/2 + o(\Delta r^2). \label{eq:second}
\end{eqnarray}
\subsection{Geometric structure: rotation, periodicity, metic and error correction} \label{sect:r}
If we assume ${\bm{B}}(\theta) = - {\bm{B}}(\theta)^{\top}$, i.e., skew-symmetric, then ${\bm{I}} + {\bm{B}}(\theta) \delta r$ in Eq. (\ref{eq:a1}) is a rotation matrix operating on ${\bm{v}}({\bm{x}})$, due to the fact that $({\bm{I}} + {\bm{B}}(\theta) \delta r)({\bm{I}} + {\bm{B}}(\theta) \delta r)^{\top} = {\bm{I}} + O(\delta r^2)$. For finite $\Delta r$, $\exp({\bm{B}}(\theta) \Delta r)$ is also a rotation matrix, as it equals to the product of $N$ matrices ${\bm{I}} + {\bm{B}}(\theta) (\Delta r/N)$ (Eq. (\ref{eq:1})).
The geometric interpretation is that, if the agent moves along the direction $\theta$ in the physical space, the vector ${\bm{v}}({\bm{x}})$ is rotated by the matrix ${\bm{B}}(\theta)$ in the neural space, while the $\ell_2$ norm $\|{\bm{v}}({\bm{x}})\|^2$ remains fixed. We may interpret $\|{\bm{v}}({\bm{x}})\|^2 = \sum_{i=1}^{d} v_i({\bm{x}})^2$ as the total energy of grid cells.
See Fig. \ref{fig:g}(b).
The angle of rotation is given by $\|{\bm{B}}(\theta) {\bm{v}}({\bm{x}})\|\delta r / \|{\bm{v}}({\bm{x}})\|$, because $\|{\bm{B}}(\theta) {\bm{v}}({\bm{x}})\|\delta r$ is the arc length and $\|{\bm{v}}({\bm{x}})\|$ is the radius. If we further assume the isotropic scaling condition, which becomes that $\|f_\theta({\bm{v}}({\bm{x}}))\| = \|{\bm{B}}(\theta) {\bm{v}}({\bm{x}})\|$ is constant over $\theta$ for the linear model, then the angle of rotation can be written as $\mu \delta r$, where $\mu = \|{\bm{B}}(\theta) {\bm{v}}({\bm{x}})\|/\|{\bm{v}}({\bm{x}})\|$ is independent of $\theta$.
Geometrically, $\mu$ tells us how fast the vector rotates in the neural space as the agent moves in the physical space. In practice, $\mu$ can be much bigger than 1 for the learned model, thus the vector can rotate back to itself in a short distance, causing the periodic patterns in the elements of ${\bm{v}}({\bm{x}})$. $\mu$ captures the notion of metric.
For $\mu \gg 1$, the conformal embedding in Fig. \ref{fig:g} (b) {\bf magnifies} the local motion in Fig. \ref{fig:g} (a), and this enables error correction~\citep{sreenivasan2011grid}. More specifically, we have the following result, which is based on Theorem \ref{theorem:a}.
\begin{prop} \label{prop:a}
Assume the linear transformation model (Eq. (\ref{eq:a1})) and the isotropic scaling condition \ref{cond:2}. For any fixed ${\bm{x}}$, let $\mu = \|{\bm{B}}(\theta) {\bm{v}}({\bm{x}})\|/\|{\bm{v}}({\bm{x}})\|$. Suppose ${\bm{v}} = {\bm{v}}({\bm{x}}) + {\bf \epsilon}$, where ${\bf \epsilon} \sim \mathcal{N}(0, \tau^2 {\bm{I}}_d)$ and $\tau^2 = \alpha^2 (\|{\bm{v}}({\bm{x}})\|^2/d)$, so that $\alpha^2$ measures the variance of noise relative to the average magnitude of $(v_i({\bm{x}})^2, i = 1, ..., d)$. Suppose the agent infers its 2D position $\hat{{\bm{x}}}$ from ${\bm{v}}$ by $\hat{{\bm{x}}} = \arg\min_{{\bm{x}}'}\|{\bm{v}} - {\bm{v}}({\bm{x}}')\|^2$. Then we have
\begin{align}
\mathbb{E}\|\hat{{\bm{x}}} - {\bm{x}}\|^2 = 2 \alpha^2/(\mu^2 d).
\end{align}
\end{prop}
See Supplementary for a proof. By the above proposition, error correction of grid cells is due to two factors: (1) higher dimensionality $d$ of ${\bm{v}}({\bm{x}})$ for encoding 2D positions ${\bm{x}}$, and (2) a magnifying $\mu \gg 1$ (our analysis is local for any fixed ${\bm{x}}$, and $\mu$ may depend on ${\bm{x}}$).
\subsection{Hexagon grid patterns formed by mixing Fourier waves} \label{sect:hexagon}
In this subsection, we make connection between the isotropic scaling condition \ref{cond:2} and a special class of hexagon grid patterns created by linearly mixing three Fourier plane waves whose directions are $2\pi/3$ apart. We show such linear mixing satisfies the linear transformation model and the isotropic scaling condition.
\begin{theorem} \label{theorem:3}
Let ${\bm{e}}({\bm{x}}) = (\exp(i \langle {\bm{a}}_j,{\bm{x}}\rangle), j = 1, 2, 3)^\top$, where $({\bm{a}}_j, j = 1, 2, 3)$ are three 2D vectors of equal norm, and the angle between every pair of them is $2\pi/3$. Let ${\bm{v}}({\bm{x}}) = {\bm{U}} {\bm{e}}({\bm{x}})$, where ${\bm{U}}$ is an arbitrary unitary matrix. Let ${\bm{B}}(\theta) = {\bm{U}}^* {\bm{D}}(\theta) {\bm{U}}$, where ${\bm{D}}(\theta) = {\rm diag}(i \langle {\bm{a}}_j, {\bm{q}}(\theta)\rangle, j = 1, 2, 3)$, with ${\bm{q}}(\theta) = (\cos \theta, \sin \theta)^\top$. Then $({\bm{v}}({\bm{x}}), {\bm{B}}(\theta))$ satisfies the linear transformation model (Eq. (\ref{eq:a1})) and the isotropic scaling condition \ref{cond:2}. Moreover, ${\bm{B}}(\theta)$ is skew-symmetric.
\end{theorem}
See Supplementary for a proof. We would like to emphasize that the above theorem analyzes a special case solution to our linear transformation model, but our optimization-based learning method {\bf does not assume any superposition of Fourier basis functions} as in the theorem. Our experimental results are learned purely by optimizing a loss function based on the simple assumptions of our model with generic vectors and matrices.
We leave it to future work to theoretically prove that the isotropic scaling condition leads to hexagon grid patterns in either the general transformation model or the linear transformation model. The hexagon grid patterns are not limited to superpositions of three plane waves as in the above theorem.
\subsection{Modules} \label{sect:modules}
Biologically, it is well established that grid cells are organized in discrete modules~\citep{Barry2007experience,stensola2012entorhinal} or blocks. We thus partition the vector ${\bm{v}}({\bm{x}})$ into $K$ blocks, ${\bm{v}}({\bm{x}}) = ({\bm{v}}_{k}({\bm{x}}), k = 1, ..., K)$. Correspondingly the generator matrices ${\bm{B}}(\theta) = {\rm diag}({\bm{B}}_{k}(\theta), k = 1, ..., K)$ are block diagonal, so that each sub-vector ${\bm{v}}_{k}({\bm{x}})$ is rotated by a sub-matrix ${\bm{B}}_{k}(\theta)$. For the general transformation model, each sub-vector is transformed by a separate sub-network.
By the same argument as in Section \ref{sect:r}, let $\mu_k = \|{\bm{B}}_{k} {\bm{v}}_k({\bm{x}})\|/\|{\bm{v}}_k({\bm{x}})\|$, then $\mu_k$ is the metric of module $k$.
\section{Interaction with place cells}
\label{sect:i}
\subsection{Place cells}
For each ${\bm{v}}({\bm{x}})$, we need to uniquely decode ${\bm{x}}$ globally. This can be accomplished via interaction with place cells. Specifically, each place cell fires when the agent is at a specific position. Let $A({\bm{x}}, {\bm{x}}')$ be the response map of the place cell associated with position ${\bm{x}}'$. It measures the adjacency between ${\bm{x}}$ and ${\bm{x}}'$. A commonly used form of $A({\bm{x}}, {\bm{x}}')$ is the Gaussian adjacency kernel $A({\bm{x}}, {\bm{x}}') = \exp(-\|{\bm{x}}-{\bm{x}}'\|^2/(2\sigma^2))$. The set of Gaussian adjacency kernels serve as inputs to our optimization-based method to learn grid cells.
\subsection{Basis expansion}
\begin{wrapfigure}{r}{0.38\linewidth}
\centering
\vspace{-.3cm}
\includegraphics[width=.85\linewidth]{fig/2_new}
\caption{\small Illustration of basis expansion model $A({\bm{x}}, {\bm{x}}') = \sum_{i=1}^{d} u_{i,{\bm{x}}'} v_i({\bm{x}})$, where $v_i({\bm{x}})$ is the response map of $i$-th grid cell, shown at the bottom, which shows 5 different $i$. $A({\bm{x}}, {\bm{x}}')$ is the response map of place cell associated with ${\bm{x}}'$, shown at the top, which shows 3 different ${\bm{x}}'$. $u_{i, {\bm{x}}'}$ is the connection weight.}
\vspace{-1.3cm}
\label{fig:units1}
\end{wrapfigure}
A popular model that connects place cells and grid cells is the following basis expansion model (or PCA-based model)~\citep{dordek2016extracting}:
\begin{align}
A({\bm{x}}, {\bm{x}}') = \langle {\bm{v}}({\bm{x}}), {\bm{u}}({\bm{x}}')\rangle = \sum_{i=1}^{d} u_{i, {\bm{x}}'} v_i({\bm{x}}), \label{eq:b1}
\end{align}
where ${\bm{v}}({\bm{x}}) = (v_i({\bm{x}}), i = 1, ..., d)^\top$, and ${\bm{u}}({\bm{x}}') = (u_{i, {\bm{x}}'}, i = 1, ..., d)^\top$. Here $(v_i({\bm{x}}), i=1, ..., d)$ forms a set of $d$ basis functions (which are functions of ${\bm{x}}$) for expanding $A({\bm{x}}, {\bm{x}}')$ (which is a function of ${\bm{x}}$ for each place ${\bm{x}}'$), while ${\bm{u}}({\bm{x}}')$ is the read-out weight vector for place cell at ${\bm{x}}'$ and needs to be learned. See Fig. \ref{fig:units1} for an illustration.
Experimental results on biological brains have shown that the connections from grid cells to place cells are excitatory \citep{zhang2013optogenetic,Rowland2018}. We thus assume that $u_{i, {\bm{x}}'} \geq 0$ for all $i$ and ${\bm{x}}'$.
\subsection{From group representation to basis functions}
The vector representation ${\bm{v}}({\bm{x}})$ generated (or constrained) by the linear transformation model (Eq. (\ref{eqn:linear})) can serve as basis functions of the PCA-based basis expansion model (Eq. (\ref{eq:b1})), due to the fundamental theorems of Schur~\citep{zee2016group} and Peter-Weyl~\citep{taylor2002lectures}, which reveal the deep root of Fourier analysis and generalize it to general Lie groups. Specifically, if ${\bm{M}}(\Delta {\bm{x}})$ is an irreducible unitary representation of $\Delta {\bm{x}}$ that forms a compact Lie group, then the elements $\{M_{ij}(\Delta {\bm{x}})\}$ form a set of orthogonal basis functions of $\Delta {\bm{x}}$. Let ${\bm{v}}({\bm{x}}) = {\bm{M}}({\bm{x}}) {\bm{v}}(0)$ (where we choose the origin $0$ as the reference point). The elements of ${\bm{v}}({\bm{x}})$, i.e., $(v_i({\bm{x}}), i = 1, ..., d)$, are linear mixings of the basis functions $\{M_{ij}({\bm{x}})\}$, so that they themselves form a new set of basis functions that serve to expand $(A({\bm{x}}, {\bm{x}}'), \forall {\bm{x}}')$ that parametrizes the place cells. Thus group representation in our path integration model is a perfect match to the basis expansion model, in the sense that the basis functions are results of group representation.
The basis expansion model (or PCA-based model) (Eq. (\ref{eq:b1})) assumes that the basis functions are orthogonal, whereas in our work, {\bf we do not make the orthogonality assumption}. Interestingly, the learned transformation model generates basis functions that are close to being orthogonal automatically. See Supplementary for more detailed explanation and experimental results.
\subsection{Decoding and re-encoding}
For a neural response vector ${\bm{v}}$, such as ${\bm{v}}_t$ in Eq. (\ref{eq:PI}), the response of the place cell associated with location ${\bm{x}}'$ is $\langle {\bm{v}}, {\bm{u}}({\bm{x}}')\rangle$. We can decode the position $\hat{{\bm{x}}}$ by examining which place cell has the maximal response, i.e.,
\begin{eqnarray}
\hat{{\bm{x}}} = \arg\max_{{\bm{x}}'} \langle {\bm{v}}, {\bm{u}}({\bm{x}}')\rangle. \label{eq:decode}
\end{eqnarray}
After decoding $\hat{{\bm{x}}}$, we can re-encode ${\bm{v}} \leftarrow {\bm{v}}(\hat{{\bm{x}}})$ for error correction. Decoding and re-encoding can also be done by directly projecting ${\bm{v}}$ onto the manifold $({\bm{v}}({\bm{x}}), \forall {\bm{x}})$, which gives similar results. See Supplementary for more analysis and experimental results.
\section{Learning} \label{sect:learning}
We learn the model by optimizing a loss function defined based on three model assumptions discussed above: (1) the basis expansion model (Eq. (\ref{eq:b1})), (2) the linear transformation model (Eq. (\ref{eq:linear2})) and (3) the isotropic scaling condition \ref{cond:2}. The input is the set of adjacency kernels $A({\bm{x}}, {\bm{x}}'), \forall {\bm{x}}, {\bm{x}}'$. The unknown parameters to be learned are (1) $({\bm{v}}({\bm{x}}) = ({\bm{v}}_k({\bm{x}}), k = 1, ..., K), \forall {\bm{x}})$, (2) $({\bm{u}}({\bm{x}}'), \forall {\bm{x}}' )$ and (3) (${\bm{B}}(\theta), \forall \theta)$. We assume that there are $K$ modules or blocks and ${\bm{B}}(\theta)$ is skew-symmetric, so that ${\bm{B}}(\theta)$ are parametrized as block-diagonal matrices $({\bm{B}}_k(\theta), k = 1, ..., K), \forall \theta)$ and only the lower triangle parts of the matrices need to be learned. The loss function is defined as a weighted sum of simple $\ell_2$ loss terms constraining the three model assumptions: $L = L_0 + \lambda_1 L_1 + \lambda_2 L_2$, where
\begin{align}
L_0 &= \mathbb{E}_{{\bm{x}}, {\bm{x}}'}[A({\bm{x}}, {\bm{x}}') - \langle {\bm{v}}({\bm{x}}), {\bm{u}}({\bm{x}}')\rangle]^2, \; (\mbox{basis expansion}) \label{eq:L1}\\
L_1 &= \sum_{k=1}^{K} \mathbb{E}_{{\bm{x}}, \Delta {\bm{x}}} \|{\bm{v}}_k({\bm{x}}+\Delta {\bm{x}}) - \exp({\bm{B}}_k(\theta) \Delta r) {\bm{v}}_k({\bm{x}})\|^2, \label{eq:L2}\; (\mbox{transformation})\\
L_2 &= \sum_{k=1}^{K} \mathbb{E}_{{\bm{x}}, \theta, \Delta \theta} [\|{\bm{B}}_k(\theta + \Delta \theta) {\bm{v}}_k({\bm{x}})\| - \|{\bm{B}}_k(\theta) {\bm{v}}_k({\bm{x}})\| ]^2. \; (\mbox{isotropic scaling}) \label{eq:L3}
\end{align}
In $L_1$, $\Delta {\bm{x}} = (\Delta r \cos \theta, \Delta r \sin \theta)$. $\lambda_1$ and $\lambda_2$ are chosen so that the three loss terms are of similar magnitudes. $A({\bm{x}}, {\bm{x}}')$ are given as Gaussian adjacency kernels. For regularization, we add a penalty on $\|{\bm{u}}({\bm{x}}')\|^2$, and further assume ${\bm{u}}({\bm{x}}') \geq 0$ so that the connections from grid cells to place cells are excitatory \citep{zhang2013optogenetic,Rowland2018}. However, note that ${\bm{u}}({\bm{x}}') \geq 0$ is not necessary for the emergence of hexagon grid patterns as shown in the ablation studies.
Expectations in $L_0$, $L_1$ and $L_2$ are approximated by Monte Carlo samples. $L$ is minimized by {\em Adam}~\cite{kingma2014adam} optimizer.
See Supplementary for implementation details.
It is worth noting that, consistent with the experimental observations, we assume individual place field $A({\bm{x}}, {\bm{x}}')$ to exhibit a Gaussian shape, rather than a Mexican-hat pattern (with balanced excitatory center and inhibitory surround) as assumed in previous basis expansion models ~\citep{dordek2016extracting,sorscher2019unified} of grid cells.
\noindent{\bf ReLU non-linearity}. We also experiment with a non-linear transformation model where a ReLU activation is added. See Supplementary for details.
\section{Experiments} \label{sect:exp}
\begin{figure*}[ht]
\centering
\includegraphics[width=.99\linewidth]{./fig/unit2.png} \\
\caption{\small Hexagonal grid firing patterns emerge in the learned network. Every response map shows the firing pattern of one neuron (i.e, one element of ${\bm{v}}$) in the 2D environment. Every row shows the firing patterns of the neurons within the same block or module. }
\label{fig: units}
\end{figure*}
We conduct numerical experiments to learn the representations as described in Section \ref{sect:learning}. Specifically, we use a square environment with size $1$m $\times$ $1$m, which is discretized into a $40 \times 40$ lattice. For direction, we discretize the circle $[0, 2\pi]$ into 144 directions and use nearest neighbor linear interpolations for values in between. We use the second-order Taylor expansion (Eq. (\ref{eq:second})) to approximate the exponential map $\exp({\bm{B}}(\theta) \Delta r)$. The displacement $\Delta r$ are sampled within a small range, i.e., $\Delta r$ is smaller than $3$ grids on the lattice. For $A({\bm{x}}, {\bm{x}}')$, we use a Gaussian adjacency kernel with $\sigma = 0.07$. ${\bm{v}}({\bm{x}})$ is of $d = 192$ dimensions, which is partitioned into $K=16$ modules, each of which has $12$ cells.
\subsection{Hexagon grid patterns}
Fig. \ref{fig: units} shows the learned firing patterns of ${\bm{v}}({\bm{x}}) = (v_i({\bm{x}}), i = 1, ..., d)$ over the $40 \times 40$ lattice of ${\bm{x}}$. Every row shows the learned units belonging to the same block or module. Regular hexagon grid patterns emerge. Within each block or module, the scales and orientations are roughly the same, but with different phases or spatial shifts. For the learned ${\bm{B}}(\theta)$, each element shows regular sine/cosine tuning over $\theta$. See Supplementary for more learned patterns.
\begin{center} \begin{minipage}[c]{.4\textwidth}
\centering
\includegraphics[width=.9\linewidth]{fig/scale_hist}
\captionof{figure}{\small Multi-modal distribution of grid scales of the learned model grid cells. The scale ratios closely match the real data~\citep{stensola2012entorhinal}. }
\label{fig: profile}
\end{minipage}
\hspace{4mm}
\begin{minipage}[c]{.53\textwidth}
\centering
\captionof{table}{\small Summary of gridness scores of the patterns learned from different models. To determine valid grid cells, we apply the same threshold of gridness score as in \cite{banino2018vector}, i.e., gridness score > 0.37. For our model, we run 5 trials and report the average and standard deviation.}
\footnotesize
\begin{tabular}{lcc}
\toprule
Model & Gridness score ($\uparrow$) & \% of grid cells \\
\midrule
\cite{banino2018vector} (LSTM) & 0.18 & 25.20 \\
\cite{sorscher2019unified} (RNN) & 0.48 & 56.10 \\
Ours & {\bf 0.90} $\pm$ 0.044 & {\bf 73.10} $\pm$ 1.33 \\
\bottomrule
\end{tabular}
\label{tabl:gridness}
\end{minipage}
\end{center}
We further investigate the characteristics of the learned firing patterns of ${\bm{v}}({\bm{x}})$ using measures adopted from the literature of grid cells. Specifically, the hexagonal regularity, scale and orientation of grid-like patterns are quantified using the gridness score, grid scale and grid orientation~\citep{langston2010development,sargolini2006conjunctive}, which are determined by taking a circular sample of the autocorrelogram of the response map. Table~\ref{tabl:gridness} summarizes the results of gridness scores and comparisons with other optimization-based approaches~\citep{banino2018vector,sorscher2019unified}. We apply the same threshold to determine whether a learned neuron can be considered a grid cell as in \cite{banino2018vector} (i.e., gridness score > 0.37). For our model, $73.10\%$ of the learned neurons exhibit significant hexagonal periodicity in terms of the gridness score. Fig. \ref{fig: profile} shows the histogram of grid scales of the learned grid cell neurons (mean $0.33$, range $0.21$ to $0.49$), which follows a multi-modal distribution. The ratio between neighboring modes are roughly $1.52$ and $1.51$, which closely matches the theoretical predictions~\citep{Wei2015,stemmler2015connecting} and also the empirical results from rodent grid cells~\citep{stensola2012entorhinal}. Collectively, these results reveal striking, quantitative correspondence between the properties of our model neurons and those of the grid cells in the brain.
{\bf Connection to continuous attractor neural network (CANN) defined on 2D torus}. The fact that the learned response maps of each module are shifted versions of a common hexagon periodic pattern implies that the learned codebook manifold forms a 2D torus, and as the agent moves, the responses of the grid cells undergo a cyclic permutation. This is consistent with the CANN models hand-crafted on 2D torus. See Supplementary for a detailed discussion.
{\bf Ablation studies}. We conduct ablation studies to examine whether certain model assumptions are empirically important for the emergence of hexagon grid patterns. The conclusions are highlighted as follows: (1) The loss term $L_2$ (Eq. (\ref{eq:L3})) constraining the isotropic scaling condition is necessary for learning hexagon grid patterns. (2) The constraint ${\bm{u}}({\bm{x}}') \geq 0$ is not necessary for learning hexagon patterns, but the activations can be either excitatory or inhibitory without the constraint. (3) The skew-symmetric assumption on ${\bm{B}}(\theta)$ is not important for learning hexagon grid pattern. (4) Hexagon patterns always emerge regardless of the choice of block size and number of blocks. (5) Multiple blocks or modules are necessary for the emergence of hexagon grid patterns of multiple scales. See Fig. \ref{fig:ablation} for several learned patterns and Supplementary for the full studies.
\begin{figure}[h]
\centering
\begin{tabular}{ccc}
\includegraphics[width=.21\linewidth]{./fig/units/noloss2_small} &
\includegraphics[width=.21\linewidth]{./fig/units/u_nonnegative_small} &
\includegraphics[width=.21\linewidth]{./fig/units/skew_symmetric_small} \\
{\small (a) without $L_2$} & {\small (b) without ${\bm{u}}({\bm{x}}') \geq 0$} & {\footnotesize (c) without skew-symmetry}
\end{tabular}
\caption{\small Learned response maps in ablation studies where a certain model assumption is removed. (a) Remove the loss term $L_2$. (b) Remove the assumption ${\bm{u}}({\bm{x}}') \geq 0$. (c) Remove the skew-symmetric assumption on ${\bm{B}}(\theta)$.
}
\label{fig:ablation}
\end{figure}
\subsection{Path integration}
We then examine the ability of the learned model on performing multi-step path integration, which can be accomplished by recurrently updating ${\bm{v}}_t$ (Eq. (\ref{eq:PI})) and decoding ${\bm{v}}_t$ to ${\bm{x}}_t$ for $t=1, ..., T$ (Eq. (\ref{eq:decode})). Re-encoding ${\bm{v}}_t \leftarrow {\bm{v}}({\bm{x}}_t)$ after decoding is adopted. Fig. \ref{fig: path}(a) shows an example trajectory of accurate path integration for number of time steps $T=30$. As shown in Fig. \ref{fig: path}(b), with re-encoding, the path integration error remains close to zero over a duration of $500$ time steps ($ < 0.01$ cm, averaged over 1,000 episodes), even if the model is trained with the single-time-step transformation model (Eq. (\ref{eq:L2})). Without re-encoding, the error goes slight higher but still remains small (ranging from $0.0$ to $4.2$ cm, mean $1.9$ cm in the 1m $\times$ 1m environment). Fig. \ref{fig: path}(c) summarizes the path integration performance by fixing the number of blocks and altering the block size. The performance of path integration would be improved as the block size becomes larger, i.e., with more neurons in each module. When block size is larger than $16$, path integration is very accurate for the time steps tested.
{\bf Error correction}. See Supplementary for numerical experiments on error correction, which show that the learn model is still capable of path integration when we apply Gaussian white noise errors or Bernoulli drop-out errors to ${\bm{v}}_t$.
\begin{figure}[h]
\centering
\includegraphics[width=.99\linewidth]{./fig/path_all.png}
\caption{\small The learned model can perform accurate path integration. (a) Black: example trajectory. Red: inferred trajectory. (b) Path integration error over number of time steps, for procedures with re-encoding and without re-encoding. (c) Path integration error with fixed number of blocks and different block sizes, for 50 and 100 time steps. The error band in (b) and error bar in (c) are standard deviations computed over 1,000 episodes. }
\label{fig: path}
\end{figure}
\subsection{Additional experiments on path planning and egocentric vision}
We also conduct additional experiments on path planning and egocentric vision with our model. Path planning can be accomplished by steepest ascent on the adjacency to the target position. For egocentric vision, we learn an extra generator network that generates the visual image given the position encoding formed by the grid cells. See Supplementary for details.
\section{Related work}
Our work is related to several lines of previous research on modeling grid cells. First, RNN models have been used to model grid cells and path integration. The traditional approach uses
simulation-based models with hand-crafted connectivity, known as continuous attractor neural network (CANN)~\citep{amit1992modeling,burak2009accurate,Couey2013,Pastoll2013,Agmon2020}.
On the other hand, more recently two pioneering papers~\citep{cueva2018emergence,banino2018vector} developed optimization-based RNN approaches to learn the path integration model and discovered that grid-like response patterns can emerge in the optimized networks. These results are further substantiated in~\citep{sorscher2019unified,Cueva2020}.
Our work analyzes the properties of the general recurrent model for path integration, and these properties seem to be satisfied by the hand-crafted CANN models. Our method belongs to the scheme of optimization-based approaches, and the learned response maps share similar properties as assumed by the CANN models.
Second, our work differs from the PCA-based basis expansion models~\citep{dordek2016extracting,sorscher2019unified,stachenfeld2017hippocampus} in that, unlike PCA, we make
no assumption about the orthogonality between the basis functions, and the basis functions are generated by the transformation model.
Furthermore, in previous basis expansion models ~\citep{dordek2016extracting,sorscher2019unified}, place fields with Mexican-hat patterns (with balanced excitatory center and inhibitory surround) had to be assumed in order to obtain hexagonal grid firing patterns. However, experimentally measured place fields in biological brains were instead well characterized by Gaussian functions. Crucially, in our model, hexagonal grids emerge from learning with Gaussian place fields, and there is no need to assume any additional surround mechanisms or difference of Gaussians kernels.
In another related paper, \citep{gao2018learning} proposed matrix representation of 2D self-motion, while our work analyzes general transformations. Our investigation of the special case of linear transformation model reveals the matrix Lie group and the matrix Lie algebra of rotation group. Our work also connects the linear transformation model to the basis expansion model via unitary group representation theory.
\section{Conclusion} \label{sect:conclusion}
This paper analyzes the recurrent model for path integration calculations by grid cells. We identify a group representation condition and an isotropic scaling condition that give rise to locally conformal embedding of the self-motion. We study a linear prototype model that reveals the matrix Lie group of rotation, and explore the connection between the isotropic scaling condition and hexagon grid patterns. In addition to these theoretical investigations, our numerical experiments demonstrate that our model can learn hexagon grid patterns for the response maps of grid cells, and the learned model is capable of accurate long distance path integration.
In this work, the numerical experiments are mostly limited to the linear transformation model, with the exception of an experiment with ReLU non-linearity. We will conduct experiments on the other non-linear transformation models, especially the forms assumed by the hand-crafted continuous attractor neural networks. Moreover, we assume that the agent navigates within a square open-field environment without obstacles or rewards. It is worthwhile to explore more complicated environments, including 3D environment.
\begin{ack}
The work was supported by NSF DMS-2015577, ONR MURI project N00014-16-1-2007, DARPA XAI project N66001-17-2-4029, and XSEDE grant ASC170063. We thank Yaxuan Zhu from UCLA Department of Statistics for his help with experiments on egocentric vision. We thank Dr. Wenhao Zhang for sharing his knowledge and insights on continuous attractor neural networks. We thank Sirui Xie for discussions. We thank the three reviewers for their constructive comments.
\end{ack}
\bibliographystyle{ieee_fullname}
| {'timestamp': '2021-11-04T01:12:20', 'yymm': '2006', 'arxiv_id': '2006.10259', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10259'} | arxiv |
\section{Choice of Text Similarity Measure}
\label{appendix:rouge}
\input{tables/rouge.tex}
\section{Search2Wiki Clone Detection}
\label{web2wiki_clone}
In WikiSum \citep{wikisum}, to detect whether a source document, $d$, is a clone of a Wikipedia article, $a$, the maximum recall of unigrams between each section of $a$ and $d$ is computed as follows:
\[
r(d, a) = \max_{s \in sections(a)} \frac{|unigrams(d) \cap unigrams(s)|}{|unigrams(s)|} \]
A clone is detected if $r(d, a)>0.5$. While this approach detects and filters most of the clones, we observed many near-clone documents left undetected in the WikiSum dataset. Most of these near-clones are documents that copy small parts of the Wikipedia article rather than the whole article or a whole section. To filter these near-clones more effectively and make the dataset more abstractive, we extended the equation above to a maximum recall of $n$-grams between each section of $a$ and $d$ as follows:
\[
r(d, a, n) = \max_{s \in sections(a)} \frac{|n-grams(d) \cap n-grams(s)|}{|n-grams(s)|} \]
We experimented with different values of $n$. A near-clone is detected in Search2Wiki if $r(d, a, 6)>0.2$.
\section{Model Dimensions}
\label{model_dims}
\input{tables/dims.tex}
\section{Introduction}
Text summarization is a language generation task that seeks to output concise and informative content given possibly multiple input documents.
Abstractive summarization aims to summarize text beyond solely copying text segments (usually whole sentences), using novel words and phrases to be more concise, comprehensive, or achieve a certain style.
Neural abstractive summarization \citep{Rush2015ANA, Nallapati_2016} is a data-driven summarization approach that trains sequence-to-sequence \citep{sutskever2014sequence} models on large numbers of document-summary pairs, and have demonstrated promising results \citep{pointer_generator, bertsum, bottomup, unilm} on summarizing relatively short texts where the input documents typically contain up to 500-1000 document tokens and up to 100-200 summary tokens (a few sentences or a paragraph).
Despite progress in relatively short-form settings, the development of long-form neural abstractive summarization (LF-NAS) was constrained due to the lack of large-scale long-form datasets.
Recently, there has been increasing interest in collecting such datasets for single-document (SDS),
including for scientific articles from arXiv/PubMed \citep{arxiv}, and multi-document summarization (MDS) \citep{wikisum},
although the challenge remains of developing model architectures that can cope with that increased
data scale, in particular sequence length.
Prior work on LF-NAS typically divided the task into two separate stages, mainly the result of memory and computation constraints associated with processing
long input sequences with RNN \citep{Hochreiter:1997:LSM:1246443.1246450,chung2014empirical} or Transformer models \citep{transformer}.
The first, extractive stage selects a small fraction of the input text
for the second abstractive stage, which
typically relies on some flavor of sequence-to-sequence model
to process extracted inputs into summaries.
In this work, we systematically study single models for LF-NAS trained jointly with weak supervision for extractive layers and with regular supervision for abstractive layers.
To use a single approach for both SDS and MDS we break input documents into sequences of snippets
(Section~\ref{sec:snippet})
and consider three general categories of modeling approach: the first truncates inputs to leading snippets (Section \ref{sec:trunc}); the second, compressive-abstractive, compresses all snippets into a
fixed-length representation that is used as input to the abstractive attention layers (Section \ref{sec:ca});
the third, extractive-abstractive, encodes each snippet independently,
then sparsely selects snippets when applying abstractive attention layers (Section \ref{sec:ea}).
The sparse selection is performed by a scorer sub-network and gating function.
The scorer is weakly supervised by proxy extractive labels automatically calculated from input snippets and gold summaries similar to \citet{Nallapati_summarunner}.
The abstractive attention layers employ full encoder-decoder attention on the resulting input representations
along with self-attention, which is supervised using the abstractive summaries.
During training, the extractive and abstractive losses are
added together and optimized.
We propose the Segment-wise Extractive-Abstractive Long-form model (Section \ref{sec:seal}), or \emph{SEAL}, that generalizes and improves the extractive-abstractive approach by augmenting the
scorer inputs with previously decoded tokens for each segment, allowing the model to dynamically select input
snippets during decoding. Although interpretability was not our goal, as a nice side-effect the model shows the link between selected
input snippets and decoded segments, resulting in better interpretability than
soft attention models.
We are able to apply our models to very long input documents and achieve state-of-the-art results with the SEAL model
on the arXiv/PubMed datasets. To further demonstrate the advantage of the SEAL model over other approaches,
we collected a massive, new dataset, \emph{Search2Wiki}, which we use to generate full Wikipedia pages from top search results, with up to 100,000 input tokens.
\section{Related Work}
Sequence-to-sequence has become a dominant paradigm in abstractive summarization using encoder-decoder architectures
based on RNNs and more recently Transformer \citep{transformer}. Transformers have shown to be more effective at
incorporating long-term dependencies \citep{wikisum,gpt2} than RNNs but have issues
scaling, running into computation and memory limitations
quickly beyond 1000 sequence tokens ($O(n^2)$ in sequence length $n$). One option is to simply truncate sequences, but
depending on the task, may drop important information.
Another option is to factor the summarization problem into extractive and abstractive stages.
The Extract-Abstract framework has received increased attention recently \citep{wikisum,li-etal-2018-guiding,gehrmann-etal-2018-bottom, tlm,heirachical_transformer} as a natural way to reduce the input size for abstractive sequence-to-sequence models. In past work
the abstractive model was trained separately from the extractive stage.
\citet{chen-bansal-2018-fast} trained extractor and abstractor sub-modules separately then used REINFORCE \citep{reinforce}
to fine-tune the non-differentiable extractive selection end-to-end. However,
the REINFORCE slows training down significantly and is not scalable for our setting.
\citet{amplayo2019informative} proposed encoding documents using an encoder derived from a pre-trained
autoencoder followed by a pooling layer before processing with a separately trained decoder,
which they call Condense-Abstract.
Our proposed SEAL model and baseline models loosely fit in the Extract-Abstract or Condense-Abstract frameworks, except
they are trained jointly in a single model end-to-end and without pre-training.
For unconditional language modeling,
\citet{child2019sparsetransformer} investigated scaling Transformer by using sparse attention, reducing
complexity to $O(n \sqrt[p]{n})$; \citet{kitaev2020reformer} replaced dot-product attention by one that uses locality-sensitive hashing, changing its complexity to $O(nlog(n))$; \citet{roy2020efficient} endowed self-attention with a sparse routing module based on online k-means while reducing its complexity to $O(n^{1.5})$; while \citet{Dai_2019,grave2016improving} cache state across
attention frames to incorporate longer context.
Pointer-networks \citep{pointer_networks} are supervised to copy input tokens to the output, whereas
in our extractor/scorer it is supervised to provide input to the subsequent abstractor layers.
\citet{shazeer2017outrageously,Gross_2017} used a gating network to save computation in very large
networks; our scorer/gate mechanism also saves computation and memory by restricting attention to small subsets of the input data.
In our model, the extraction can be interpreted similarly to hard attention, which restricts
what the downstream model layers (decoder) see. Hard attention has been designed
into sequence models previously
to increase the interpretability of predictions \citet{lei-etal-2016-rationalizing}.
Pre-training sequence-to-sequence models using massive external data using a self-supervised objective as in \citet{2019t5, song2019mass, unilm, zhang2019pegasus}
has lead to improvements in downstream summarization tasks, although this line of work is orthogonal to our focus on scaling the Transformer to long inputs.
Thus we train from randomly initialized weights.
\citet{sauper-barzilay-2009-automatically} generated Wikipedia extractively
from search results for a few categories. \citet{wikisum} augmented search results
with cited references and generated articles (focusing on lead section) abstractively
with sequence-to-sequence architectures. Our work differs from the latter
by focusing on generating full articles and using only search results, although many more (75 vs 10).
\section{Models}
\begin{figure}[tbh]
\centering
\includegraphics[width=0.8\textwidth]{figs/seals2.pdf}
\caption{Model architectures. $E_\theta$, $D_\phi$, $S_\psi$, $S_\psi^*$ are encoder, decoder and scorers that contains trainable parameters $\theta$, $\phi$, $\psi$. $G$ is the gating function that selects and concatenates top scored snippet representations up to a certain maximum length. $x_{i}$ are inputs snippet IDs (each $x_i$ is a sequence of IDs),
$x'_{i}$ are encoded/compressed representations of input snippets. $y_\tau$, $y_{t<\tau}$, $y_{seg_j}$ are current decode IDs, all previous decode IDs, and previous decode IDs in segment j.
In this figure, there are in total 7 inputs snippets and decoders always attend up to 3 input representations, the SEAL model is decoding the third segment.
}
\label{fig:arch}
\end{figure}
\begin{figure}[tbh]
\centering
\includegraphics[trim=0 15 0 0, clip, width=0.3\textwidth]{figs/loss.pdf}
\caption{Losses and how gradients flow. The Left side are Trunc and CA model. The right side are EA model and SEAL model. $l_a$ and $l_e$ are abstractive and extractive loss, red arrows are gradients.
}
\label{fig:loss}
\end{figure}
In this section, we discuss architectures (Fig.~\ref{fig:arch}), losses (Fig.~\ref{fig:loss}) and attention maps (Fig.~\ref{fig:attention}) of three general approaches and our proposed method to deal with LF-NAS: \textbf{truncated input} (Section \ref{sec:trunc}), \textbf{compressive-abstractive} (Section \ref{sec:ca}), \textbf{extractive-abstractive} (Section \ref{sec:ea}) and \textbf{SEAL} (Section \ref{sec:seal}), our proposed more general form of extractive-abstractive model.
We encode the text using sub-word tokenization similar to \citep{wu2016googles} with a vocabulary size of $32,776$.
Each model generates an output sequence IDs $y_\tau$ from a sequence of input snippets IDs $\{x_i\}$ (Section~\ref{sec:snippet}).
A snippet is defined as a continuous text-span, such as one or few sentences or a paragraph.
All our models' components are based on Transformer \cite{transformer}.
A Transformer encoder maps an input sequence of tokens to a sequence of high-dimensional vectors in $\reals^d$ using self-attention and feed-forward layers.
A Transformer decoder auto-regressively (by self-attention) generates an output sequence of tokens
while attending to this input representation (by encoder-decoder cross attention).
\subsection{Unified Approach for Single and Multi-Document Summarization}
\label{sec:snippet}
To unify our approach to SDS and MDS, we break a input document or a list of documents into snippets with the following criteria:
(1) concatenate tokens in continuous sentences until reaching a \emph{maximum snippet length}, $L_{snpt}$. This helps to reduce the percentage of paddings (empty tokens) in each snippet for better compute efficiency;
(2) in the unlikely case of a single sentence exceeding the maximum length, truncate that sentence;
(3) ensure that snippets do not span across document boundaries;
(4) order by their natural order of appearances within each document. In MDS, they are ordered by the order in the data (Section ~\ref{sec:data/wiki});
(5) stop adding snippets when their number reaches \emph{maximum snippets}, $N_{snpt}$.
\begin{figure*}[tbh]
\centering
\includegraphics[trim=100 70 150 20,
clip,width=0.7\textwidth]{figs/attention.pdf}
\caption{Illustration of encoder self-attention and encoder-decoder attention maps for four models considered. $x_{i}$ are inputs snippets (encoders' inputs),
$x'_{i}$ are encoded/compressed representations (encoders' outputs, decoders' inputs) that correspond to input snippets. $ys_j$ are decode segments (decoder's outputs) representing parts of the long decode sequence. Encoder self-attentions from $x_{i}$ to $x'_{i}$ are colored in blue and encoder-decoder attentions from $x'_{i}$ to $ys_{j}$ are colored in red. Note each square represents a sequence of tokens in a input snippet or a decode segment, not a single token.
}
\label{fig:attention}
\end{figure*}
\subsection{Truncated Input Model (Trunc)}
\label{sec:trunc}
One limitation of a standard Transformer model is it does not scale well to longer inputs
due to the $O(n^2)$ complexity of encoder self-attention to input length.
We truncate the input sequences as in \citet{wikisum} to a \emph{maximum input length}, $L_{input}$, only including the leading few snippets, Fig.~\ref{fig:arch}(a).
We refer this model as \emph{Trunc}.
\begin{equation*}
p(y_\tau) = D_{\phi}(y_{t < \tau}, E_{\theta}(\{x_i\}))
\label{eq:trunc}
\end{equation*}
Encoder $E_\theta$ and decoder $D_\phi$, parameterized by $\theta$ and $\phi$ respectively.
As shown in Fig.~\ref{fig:loss}(a), the Trunc model is trained using the standard teacher-forcing and cross-entropy loss over all generated tokens $l_a =\nolinebreak \sum_{y\tau}^{T}\hat{y_\tau} log(p(y_\tau))/T$. $\hat{y_\tau}$ is the target decode sequence and $T$ is the length of decode.
The few snippets have full self-attention among themselves and the decoder has full attention over the snippets, Fig.~\ref{fig:attention}(a).
\subsection{Compressive-Abstractive (CA) Model}
\label{sec:ca}
The second approach, \emph{compressive-abstractive}, encodes and compresses continuous snippets into shorter representations,
and concatenates all representations as the decoder input, Fig.~\ref{fig:arch}(b).
\begin{equation*}
p(y_\tau) = D_{\phi}(y_{t < \tau}, \{C_{\theta}(x_i)\})
\label{eq:ca}
\end{equation*}
where $C_\theta$ is the Transformer encoder that also compresses the input snippets. The CA model is trained with a similar loss $l_a$ as the Trunc model, Fig.~\ref{fig:loss}(a).
\citet{amplayo2019informative} pooled each input representation $\mathbf{x}^{l \times d}$ into a single vector $\mathbf{x}^{d}$ ($l$ is the sequence length and $d$ is the representation dimension) whereas we
compress a snippet group into a short sequence of vectors $\mathbf{x}^{c \times d}$ for richer representation ($c$ is the compressed size).
A \emph{snippet group} is a block of continuous $k$ snippets for SDS or all snippets within the same document for MDS.
The compression is implemented by concatenating learnable vectors to Transformer encoders' inputs \cite{compression} and retrieving the processed vectors as compressed representations.
As shown in Fig.~\ref{fig:attention}(b), the compressed representation is derived from full self attention to snippets within the compression group, and the decoder has full attention to all compressed representations.
\subsection{Extractive-Abstractive (EA) Model}
\label{sec:ea}
The third approach, \emph{extractive-abstractive}, first encodes each input snippet separately with $E_\theta$,
assigns scores to encoded snippets with scorer $S_\psi$ (a modified Transformer encoder),
then selects encoded snippets by scores through gating function $G$. The decoder attends to sequences selected by $G$, Fig.~\ref{fig:arch}(c).
\begin{equation*}
p(y_\tau) = D_{\phi}(y_{t < \tau}, G(\{E_{\theta}(x_i)\},S_{\psi}(\{E_{\theta}(x_i)\}))
\label{eq:ea}
\end{equation*}
Each input snippet only has encoder self-attention to itself,
the decoder has attention to selected snippets through the gating function, Fig.~\ref{fig:attention}(c).
The \textbf{scorer $S_\psi$} utilizes a Transformer encoder to map a list of input snippets representations $\{\mathbf{x}_i^{l \times d} \}_n$ to a list of scores $\{s_i\}_n$ ($l$ is the sequence length, $d$ is the representation dimension and $n$ is the number of snippets). It consists of a attention-pooling layer, Transformer encoder, and a feed-forward layer. The attention-pooling layer \citet{wang-etal-2017-gated} reduces snippets representations from $\{\mathbf{x}_i^{l\times d}\}_n$ to $\{\mathbf{x}_i^{d}\}_n$. The Transformer encoder process the concatenation of pooled snippets $\mathbf{x}^{n\times d}$ for contextual representation across snippets. The feed-forward layer assigns a scores $s_i$ for each contextual snippets representation $\mathbf{x}_i^{d}$.
In MDS, we assign a document id to each snippet, and add learnable document embedding to the pooled snippet representation.
After each snippet is assigned a score by the scorer, we apply a \textbf{gating function}, $G$, to select snippets based on their scores. It is implemented in the following way: (1) sort the snippets by their predicted scores; (2) concatenate each snippet representation until their total length reaches a limit. We refer to this length limit as \emph{maximum extractive length}, $L_{ext}$. Note concatenation is done by matrix multiplication of the sorting mask (an one-hot matrix mapping inputs positions to sorted concatenated positions) and encoded snippets, thus gradients can back-propagate through the gating function to the encoder.
The encoder $E_\theta$, scorer $S_\psi$ and decoder $D_\phi$ are \textbf{jointly trained} with two losses, $l_a$ and $l_e$. The \textbf{abstractive loss $l_a$} is the same as Trunc and CA model (Section \ref{sec:trunc}).
The \textbf{extractive loss $l_e$} provides supervision for the scorer and encoder to assign higher scores to better snippets for the decoder to attend to.
During training, we calculate text similarities between gold summary and input snippets as weakly supervised proxy labels $\{l_i\}_n$, and minimize the $l2$ distance between model predicted scores and proxy labels, $l_e = \sum_i^n (s_i - l_i)^2/n$.
We minimize the sum of the two losses $l_a$ and $l_e$ during training as shown in Fig.~\ref{fig:loss}(b). The $l_a$ loss back-propagates to $D_\phi$ and $E_\theta$ through $G$, while the $l_e$ loss back-propagates to $S_\psi$ and $E_\theta$. This differs from two-stage models \citep{tlm, heirachical_transformer} where the extractive and abstractive stages use different encoders and trained separately.
\subsection{Segment-wise Extractive-Abstractive Long-form (SEAL) Model}
\label{sec:seal}
The SEAL model encodes snippets in the same way as the EA model. On the decoder side, the model divides the process into non-overlapping segments, each with size \emph{segment length}, $L_{seg}$, Fig.~\ref{fig:arch}(d). Different snippets are selected for the decoder to attend to at each decode segment.
\begin{equation*}
p(y_\tau) = D_{\phi}(y_{t < \tau}, G(\{E_{\theta}(x_i)\},S_{\psi}^*(\{E_{\theta}(x_i)\}, y_{t < seg(\tau)}))
\label{eq:sea}
\end{equation*}
where $seg(\tau) = floordiv(\tau, s) \times s$ is current decoding step $\tau$'s
segment (with size $s$) starting index.
The inputs to the scorer $S_\psi^*$ are all encoded snippets $\{E(x_i)\}$ (unchanged) and prior decode segments $y_{t < seg(\tau)}$ (changed at the start of each decode segment).
The gating function $G$ selects subsets of snippets based on $S_\psi^*$ assigned scores at each segment.
This model has the same self-attention mask as the EA model and an encoder-decoder attention that dynamically changes between decode segments as shown in Fig.~\ref{fig:attention}(d). The dynamic selection of snippets allows more efficient usage of attention memory, more targeted proxy labels (Section~\ref{sec:exp}), and improved interpretability (Section~\ref{sec:interp}).
At the start of each decode segment, the encoder $E_\theta$ encodes the tokens of each $k$ previous segment $\{\mathbf{y}_{seg_{j}}^s\}_k$ into representations $\{\mathbf{y}_{seg_{j}}^{s\times d}\}_k$ (k is the number of previous decode segments).
The \textbf{segment-wise scorer} consists of an attention-pooling layer and a transformer encoder.
The attention-pooling layer pools $\{\mathbf{y}_{seg_{j}}^{s\times d}\}_k$ and concatenates them to $\mathbf{y}^{d\times k}$.
The transformer encoder $S_\psi^*$ not only processes the pooled input snippets $\mathbf{x}^{n\times d}$ (by self-attention) same as in the EA model, but also attends to $\mathbf{y}^{d\times k}$ (by encoder-decoder cross attention) such that the scorer is aware of what has been decoded. (Refer to “attention\_layer” in BERT Tensorflow library\footnote{https://github.com/google-research/bert/blob/master/modeling.py}, the “from\_tensor” is pooled snippet representations, the “to\_tensor” is pooled previous decode segments.)
Training the SEAL model is similar to the EA model, Fig.~\ref{fig:loss}(b), except: (1) The number of supervised labels increases from $n$ to $n \times m$, where $n$ is the number of input snippets and $m$ is the number of decode segments. The proxy labels are calculated as similarities between each gold summary segment and input snippet. Thus, the extractive loss is $l_e = \sum_i^n\sum_j^m (s_{ij} - l_{ij})^2 / mn$. (2) Decoding segments are trained in parallel while attending to different inputs snippets.
The SEAL model is a more general version of the EA and Trunc models.
When $L_{seg}=L_{dec}$, the SEAL model reduces to an EA model. When $L_{ext}=L_{input}$, the EA model reduces to a Trunc model.
\section{Datasets}
\label{sec:data/wiki}
\input{tables/datasets.tex}
Several existing datasets are suitable as benchmarks for LF-NAS (statistics in Table.~\ref{tab:data}).
\citet{arxiv} collected scientific publications from arXiv and PubMed and used articles' bodies to generate abstracts.
To visualize selections by the SEAL model,
we use a popular (relatively) short summarization dataset CNN/DailyMail\cite{cnndailymail}, non-anonymized version as in \citet{pointer_generator}, for ease of presentation. It contains newspaper articles paired with bullet point summaries.
\citet{wikisum} approached generating the lead section of English Wikipedia article as multi-document summarization from reference documents (Wikipedia references and web search results) and introduced the WikiSum dataset.
To demonstrate the performance of our models on much longer input and target sequences we created a similar LF-NAS dataset named \emph{Search2Wiki}. The dataset consists of full English Wikipedia articles as the target summaries and a collection of search result documents about the topic as input documents. The main differences are: 1) the input uses the top 75 search result documents compared to the top 10 in WikuSum. This is important to demonstrate the effectiveness of our proposed models on longer input sequences; 2) We drop Wikipedia references which could vary a lot per page. It allows generating pages for entities not currently in Wikipedia; 3) To make the dataset more abstractive, we apply a stronger filtering of Wiki-clone documents retrieved from search, please refer to Appendix ~\ref{web2wiki_clone} for more details.
The order of documents presented to model is by their search relevance in descending order.
\section{Experiments and Results}
\label{sec:exp}
\paragraph{Experimental details}
Our Transformer block \citep{transformer} has hidden size $d_{model}=512$, feed forward size $d_{ff}=512$ and attention heads $h=8$.
We set number of Transformer layers to 2 in encoder, 1 in scorer, and 6 in decoder, making the total number of parameters $223M$ for the SEAL model (Trunc, CA and EA model have similar number of parameters).
All models are trained with adafactor ~\citep{shazeer2018adafactor} optimizer, batch size of 256, dropout rate of 0.1,
learning rate of 0.01 with square root decay. We train the models until perplexity stopped decreasing on dev set (200k steps for arXiv, PubMed and 400k steps for Search2Wiki).
In order to have a clear comparison between models, all our models are decoded with greedy decoding.
\begin{figure}[tbh]
\centering
\begin{subfigure}[t]{0.39\textwidth}
\includegraphics[trim=50 0 50 50,clip,width=\linewidth]{figs/input_tokens_curve.pdf}
\end{subfigure}
\hfill
\begin{subfigure}[t]{0.59\textwidth}
\includegraphics[trim=150 0 100 0,clip,width=\textwidth]{figs/seals_grid.pdf}
\end{subfigure}
\caption{On the arXiv dataset,
(a) Trunc models trained on different maximum input length, $L_{input}$.
(b) EA models trained on different maximum extractive length, $L_{ext}$.
(c) Effect of segment length $L_{seg}$ and maximum extractive length $L_{ext}$ for SEAL model on the arXiv dataset.
\label{fig:input_len}
}
\end{figure}
\paragraph{Amount of input context} We show that the amount of input context the decoder attends to is important for LF-NAS. We limited the amount of input context to the Trunc model to $L_{input}$ to 256, 512, 1024 and 2048 tokens on the arXiv dataset. The performance of the model increases significantly as the length grows, Fig.~\ref{fig:input_len}(a), suggesting longer input context is crucial for LF-NAS. We observe similar trends on other LF-NAS datasets which is consistent with \citep{wikisum}.
\paragraph{Input Snippets Selection} We show that the required amount of context the decoder attends to greatly reduces when better snippets are selected.
We trained EA models with maximum extractive length $L_{ext}$ (Section~\ref{sec:ea}), of 256, 512, 1024 and 2048 tokens on the arXiv dataset.
With same number of tokens, the EA model achieves much better results compared to the Trunc model and plateaus at 1024 tokens,
Fig.~\ref{fig:input_len}(B).
\paragraph{Methods of Creating Proxy Extractive Labels} We investigated methods to automatically create proxy labels based on multiple text similarity measures including ROUGE-1 or ROUGE-2 \citep{rouge} precision/recall/F1 scores, and whether to create the labels sequentially as in \citet{nallapati2016summarunner}.
Appendix~\ref{appendix:rouge} shows that specific choice of labeling method doesn't make large differences. For simplicity, we chose non-sequential ROUGE-2-F in all of our models.
\paragraph{Segment Length and Extractive Length} For the SEAL model,
when the segment length $L_{seg}$ is large, the decoder effectively attends to less context.
On the other hand, when $L_{seg}$ is as small as a few words, the similarity labels become very spurious and are not meaningful to guide extraction. Fig.~\ref{fig:input_len}(C) shows that larger maximum extractive lengths $L_{ext}$ are always better and 64-128 is the optimal segment length for the arXiv datasets.
Therefore in all other experiments, we set the segment length to one-eighth of maximum decode length, $L_{seg} =L_{dec}/8$. Values of $L_{dec}$, can be found in Appendix~\ref{model_dims} on different dataset.
\input{tables/ours.tex}
\paragraph{Comparison between Our Models and Other Works} We compare Trunc, CA, EA and SEAL models on arXiv, PubMed and Search2Wiki datasets in Table ~\ref{tab:models}.
The inputs to Trunc models are leading snippets on arXiv, PubMed datasets and top snippets ranked by tf-idf on Search2Wiki dataset,
similar to \citet{wikisum}. The inputs are concatenated and truncated to the first 1024 tokens.
Between our models, the CA and EA models have similar performance and consistently outperform the Trunc model on all datasets. The SEAL model performs better
than Trunc, CA and EA on long output datasets.
On Search2Wiki, which has larger number of training examples and longer input sequences, the advantage of the SEAL model is more obvious.
Prior work on LF-NAS typically truncates the input or target in some way.
Truncating the targets\citep{arxiv, tlm} changes the nature of the problem, usually making it easier, and leading to higher evaluation metrics.
In this work, we ensure that the model's maximum input $L_{input}$ and decode $L_{dec}$ lengths (Appendix~\ref{model_dims}) exceed the 95\% percentile of the corresponding data distribution (Table~\ref{tab:data}), so that we closely tackle the intended summarization problem defined by the dataset.
The SEAL model has better performances comparing to previous state-of-the-art extractive \citep{xiao2019extractive} and abstractive \citep{tlm, arxiv} approaches on LF-NAS.
\section{Interpretability}
\label{sec:interp}
\input{figs/cnn_dailymail.tex}
The SEAL model provides a natural way to inspect what input sequence the decoder is likely using when generating a particular segment of the summary. In this section, we show how this enhances interpretability on an example from the CNN/DailyMail dataset (for ease of presentation), Fig~\ref{fig:interp}. In the Appendix we show more examples on long SDS and MDS datasets.
On CNN/DailyMail dataset, we find a SEAL model with ($L_{seg}=16$, $L_{snpt}=64$, $L_{ext}=256$, $N_{snpt}=16$) achieves R1/R2 of 39.3/16.5 which is on par with a Trunc model of 1024 input length.
When generating the first decode segment, the model attended to two snippets and copied from the summary-like lead sentence.
The second segment finishes the first sentence while continuously attending to the lead snippet, and begins a second sentence rephrasing three other snippets. The final segment writes a new sentence combining multiple snippets.
\section{Conclusion}
In this work, we studied and compared different LF-NAS models. We showed that models' performance heavily depends on seeing longer sequences from the input, and sparsely selecting better content relieves this requirement.
We proposed the SEAL model, which encodes input snippets separately and dynamically selects sparse input snippets to attend to when generating different segments of the summary. The SEAL model achieves state-of-the-art results on existing LF-NAS datasets including arXiv, PubMed and outperform baseline models on our new, much longer dataset Search2Wiki.
\section*{Broader Impact}
This work may bring more attention to long document summarization research and spur new applications. If successful, producers of summaries from long/multiple documents may benefit from higher productivity due to less manual work, while consumers may benefit from reduced information overload.
A failure case of such a system is that it may generate text that is unfaithful to the source material, i.e. factually inaccurate, a risk that must be taken into account when deploying. The models biases present in the training data may also be reflected in the model output.
\begin{ack}
We thank David Grangier for feedback and reviewing the manuscript and Ben Goodrich for helping with earlier iterations of the models.
\end{ack}
| {'timestamp': '2020-06-19T02:06:28', 'yymm': '2006', 'arxiv_id': '2006.10213', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10213'} | arxiv |
\section{Introduction}\label{sec:introduction}}
\IEEEPARstart{I}{mage} and video synthesis receives a rapidly increasing amount of attention in Computer Vision and Deep Learning research, as "synthetic" data appear more and more realistic, as well as especially promising for real-world applications. Video editing, film dubbing, social media content creation, teleconference and virtual assistance are some indicative examples. However, generating artificial human faces indistinguishable from real ones is a very challenging task, particularly when it comes to video data. Adding the extra dimension of time, might give rise to the so-called problem of temporal incoherence. As the uncanny valley effect suggests, people are extremely perceptible in unnatural facial and head movements, thus even small discontinuities can expose a synthetic video.
Over the past years, various methods that target human faces have emerged, taking advantage of different modalities, such as audio \cite{Suwajanakorn2017, X2Face} and video \cite{face2face, deepvideoportraits, koujan_reenactnet} to drive synthesis and dictate the movements of the generated subject. Facial reenactment is a widely-studied approach \cite{thies2015realtime, face2face, DeferredNeuralRendering}, which aims to transfer the facial expressions from a source to a target subject, by conditioning the generative process on the driving video of the source. In most cases \cite{face2face, DeferredNeuralRendering}, this is done by modifying the deformations solely within the internal facial region of the target identity and placing the manipulated face back to the original target frames, using an image interpolation method. Given that face reenactment systems offer no control over the target's head pose and eye gaze, there might be cases where the person's expressions do not match with the overall head movement and therefore seem unnatural. Even so, face reenactment can be very useful for specific applications, such as video dubbing \cite{Garrido2015}, which aims to alter the mouth motion of the target actor to match the audio track spoken by the dubber.
A more holistic approach on reenactment involves generating all pixels within frames, including the upper body, hair and background of the target identity. In contrast to video manipulation techniques, such as face reenactment, full head reenactment methods \cite{deepvideoportraits, fewshot} aim to transfer the entire head motion from a source identity to a target one, along with the eye blinking and gaze, providing complete control over the target subject. Most head reenactment approaches fall into two categories: a) Warping-based methods \cite{Liu2001, Garrido2014, X2Face}, which are mainly learning-based and do not involve computing priors such as facial landmarks or 3D face models, b) object-specific methods \cite{face2face, deepvideoportraits, fewshot, vid2vid}, which assume knowledge (e.g. 3D reconstruction, 68 landmarks) of the source and target faces. On the one hand, warping-based methods usually suffer from distortions in the face and background \cite{X2Face}. On the other hand, object-specific methods relying on facial keypoints are affected from the so-called identity preservation problem. As keypoints encapsulate identity attributes of the source (e.g, head geometry), the more the identity of the source diverges from that of the target, the more distorted the head shape of the generated subject might appear. On the contrary, 3D morphable models (3DMMs) \cite{koujan2018combining, booth20183d} have proven to be a reliable means of decoupling expression and identity from each other. \textit{Deep Video Portraits (DVP)} \cite{deepvideoportraits} is a full head reenactment system that capitalises on 3DMMs and utilises a neural network to translate 3D face reconstructions to realistic frames. Nonetheless, \textit{DVP}, as a purely image-based model, does not take into account temporal dependencies between frames.
Our recently proposed \textit{Head2Head} \cite{Koujan2020head2head} model overcomes the aforementioned limitations, as it combines the benefits of conditioning synthesis on 3D facial shapes with the advantages of a sequential, video-based, neural renderer. In this paper, we extend the work of \textit{Head2Head} in the following directions:
\begin{itemize}
\item We prevail over the limitations of the 3D reconstruction stage of \textit{Head2Head} by designing a novel \textbf{DenseFaceReg} network for the robust and fast estimation of semantic facial images based on 3D facial geometry. Our semantic facial images, referred to as \textbf{Normalised Mean Face Coordinates (NMFC)} images, capture pose, expression and identity information of the subject from the 3D facial mesh and are used to condition video synthesis.
\item We propose a simple yet fast method for detecting the eye gaze, based on 68 facial landmarks. When combined with 3D Facial Recovery and Video Rendering Network, our system can operate in nearly real-time speeds.
\item We conduct an extensive set of experiments, including user, automated and ablation studies. Our results reveal the significance of video-based modeling
\item We make our code and dataset publicly available\footnote{\url{https://github.com/michaildoukas/head2head}}.
\end{itemize}
\section{Related Work}
\subsection{3D Face Reconstruction}
\label{subsec: 3Dreconst}
Recovering the 3D geometry of human faces from monocular images is a challenging problem that has attracted much attention due to its major role in many applications, ranging from facial reenactment, performance capture and tracking \cite{Koujan_2020_CVPR}, facial expression recognition \cite{Koujan2020FER, Giannakakis2020}, etc. Owing to their pose and illumination invariance, 3D facial data constitute an indispensable geometrical description of faces for various facial image processing systems. The Computer Vision field is rich in approaches targeting this problem under different assumptions and constraints. Some of these attempts \cite{barron2014shape, smith2008facial}, named \textit{Shape from Shading}, approximate the image formation process and make simplified assumptions about the lighting and illumination models leading to the formation of the image, while others, known as \textit{Structure from Motion (SfM)}, benefit from the geometric constraints in multiple images of the same object to solve the problem \cite{garg2013dense, grasshof2017projective}. One common approach for addressing this task are the \textit{3D Morphable Models (3DMMs)} of the human face. 3DMMs are linear statistical models that have been used substantially since the pioneering work of Blanz and Vetter \cite{blanz1999morphable}, with many extensions \cite{koujan2018combining, booth20183d, faggian20083d}. With the rise of deep neural networks, nonlinear face models have been proposed to recover the 3D geometry and appearance of human faces from images or videos using \textit{deep Convolutional Neural Networks (CNNs)} \cite{tran2019towards, tewari2018self, tran2018nonlinear, tewari2019fml}. For a very recent and comprehensive review of the state-of-the-art methods on monocular 3D face reconstruction and the open challenges of 3DMMs, we refer the readers to \cite{zollhofer2018state, egger20193d}.
In this work, we employ 3DMMs and a 3D shape regression network for: 1) estimating the 3D geometry of faces appearing in videos, and 2) utilising the estimated 3D geometrical information for driving our Deep Video Rendering Neural Network.
\begin{figure*}[t!]
\centering
\includegraphics[scale=1.1]{head2head_figure.pdf}
\caption{Our Head2Head++ pipeline for head reenactment. First, the facial region of interest is extracted from both the source and target original videos. Next, 3D Facial Recovery is performed. The average identity parameters ($\bar{\mat{s}}^i$) of the target, along with the expression ($\mat{s}_t^e$) and camera ($\mat{p}_t$) parameters of the source for each time-step $t$, are passed to the NMFC renderer, which produces the NMFC video. At the same time, the eye landmarks of the source are used to detect the pupils and sketch the eyes video, which represents eyes movements. Finally, the combined NMFC and eyes video is given as conditional input to the Video Rendering Network, which computes the generated video (reenactment result). The Video Rendering Network is a person specific model, as it is trained using footage of the target person. During training, the source video coincides with the target video, enabling us to perform self-reenactment and get access to ground truth data.}
\label{fig:fig1}
\end{figure*}
\subsection{Facial Synthesis and Re-targeting}
\label{subsec: animation}
Various deep architectures have been proposed for the image and video synthesis tasks with the aid of Recurrent Neural Networks (RNNs), Variation Auto-encoders (VAE) \cite{kulkarni2015deep}, Gaussian mixture VAE \cite{wang2018every}, Hierarchical VAE \cite{goyal2017nonparametric}, Generative Adversarial Networks (GANs) \cite{ganGoodfellow} and VAE-GAN \cite{Andres}.
Traditional methods of reenactment, transfer the facial expressions either with 2D warping techniques \cite{Liu2001, Garrido2014}, or by utilizing 3D face models \cite{ thies2015realtime, face2face, DeferredNeuralRendering}. These methods do not provide complete control over the generated video, as they manipulate only the interior of the face. Recently, there has been a substantial effort in the direction of both expression and pose transfer \cite{headon, elor2017bringingPortraits, X2Face, fewshot, deepvideoportraits}. One of the first approaches, \textit{X2Face} \cite{X2Face}, designs an embedding and a set of auto-encoders. \textit{X2face} follows a warping-based approach that causes deformations in the generated heads and inconsistent upper-body motions. Wang et al. \cite{vid2vid} propose \textit{vid2vid}, a GAN-based spatio-temporal approach for the video-to-video synthesis, relying on a Temporal Discriminator for improving the temporal quality of the synthesised videos
~In a follow-up work, Wang et al. \cite{wang2019fewshotvid2vid} extend their approach with an attention mechanism, making it trainable in a few-shot manner and leading to better generalisation performance.
Both \cite{vid2vid} and \cite{wang2019fewshotvid2vid} can perform reenactment with face sketches drawn from landmarks, leading to a target identity preservation problem. Moreover,. the synthesised mouth regions do not look very realistic.
Zakharov et al. \cite{fewshot} propose a few-shot, image-based adversarial learning approach, as their network learns to generate unseen target identities even from a single image. Nonetheless, their neural network relies on landmarks, causing an identity distortion of the target.
Siarohin et al.~\cite{siarohin2019animating} animate objects via a deep motion transfer framework. Given a single image and a driving sequence, their method estimates a dense motion field appearing in the sequence and transfers it to the target image while preserving its appearance. When used for facial reenactment, the faces synthesised by this approach suffer from head distortions and non-naturalistic mouth and teeth areas. To tackle this issue, the authors extended their work \cite{Siarohin_2019_NeurIPS} to account for complex motions with a first-order motion model and an occlusion-aware Generator. Although this extension considerably improved the results on various tasks, synthesised faces still exhibited visual artifacts appearing as expression-dependent continuous scale changes. This can be attributed to the estimated 2D dense motion field that does not fully describe the actual intricate 3D facial motion.
As far as we are aware, \textit{DVP} \cite{deepvideoportraits} is the only learning-based head reenactment system, prior to our work, that uses 3D facial information to condition video synthesis. Their image-based model requires a long video footage of the target person, while training a new model for each target takes many hours. Moreover, generated mouths look unnatural, since the 3D reconstruction method they adopt does not encode the inner-mouth region or the teeth.
Unlike other studies, our approach employs efficiently the 3D geometry and conditions frame generation on a compact and meaningful representation in the image space derived from 3D facial reconstruction. When combined with our novel video-based neural rendering stage, the result is a faithful and photo-realistic full head video reenactment, indistinguishable from real videos. Additionally, we focus specifically on the mouth area and improve its visual quality by designing a dedicated discriminator.
\section{Methodology}
Our \textit{Head2Head++} framework proposes a solution for the largely ill-posed full head reenactment problem. Our method is capable of transferring the time-varying head attributes (pose, expression, eye gaze) and mainly consists of two subsequent modules: a) \textbf{3D Facial Recovery} (Sec.~ \ref{subsec: 3Dtracking}), and b) a \textbf{Video Rendering Network} (Sec. \ref{subsec:videorenderer}). Our video rendering network capitalises on a carefully designed GAN-based framework. Please refer to Fig. \ref{fig:fig1} for an overview of our \textit{Head2Head++} pipeline.
\subsection{3D Facial Recovery}
\label{subsec: 3Dtracking}
We aim to generate a reliable estimation of the facial 3D geometry, capturing the temporal dynamics, while separating the identity and expression contributions of the pictured subject in each frame. We utilise this separability to effectively disentangle the human head characteristics in a transferable and photo-realistic way between different videos. Towards that aim, we benefit from the prior knowledge in our problem space and harness the power of 3DMMs \cite{blanz1999morphable} for reconstructing the faces that appear in the input monocular sequences. Given a sequence of $T$ frames $\mathcal{F}_{1:T}= \{f_t \mid {t=1,\dots,T}\}$, the 3D reconstruction stage produces two sets of parameters: 1) shape parameters $\mathcal{S}=\{\mat{s}_t \mid \mat{s}_t \in {\rm I\!R}^{n_i+n_e}, t=1,...,T\}$, and 2) camera parameters $\mathcal{P}=\{\mat{p}_t \mid \mat{p}_t \in {\rm I\!R}^{6}, t=1,...,T\}$, depicting rotation, translation and orthographic scale.
\setlength\parindent{0pt}
\setlength{\parskip}{2pt}
\textbf{Shape representation.} Using 3DMMs, a 3D facial shape $\mathbf{x}_t=[x_1, y_1, z_1,..., x_N, y_N, z_N]^{\top} \in {\rm I\!R}^{3N}$ can be written mathematically as:
\begin{equation}
\label{eq:3DMM}
\mathbf{x}_t = \mathbf{x}(\mat{s}_t^i,\mat{s}_t^e)=\bar{\mathbf{x}}+\mathbf{U}_{id} \mat{s}_t^i+ \mathbf{U}_{exp} \mat{s}_t^e
\end{equation}
where $\mathbf{\bar{x}}\in {\rm I\!R}^{3N}$ is the mean shape of the morphable model, given by $\mathbf{\bar{x}}=\mathbf{\bar{x}}_{id}+\mathbf{\bar{x}}_{exp}$, with $\mathbf{\bar{x}}_{id}$ and $\mathbf{\bar{x}}_{exp}$ standing for the mean identity and expression of the model, respectively. $\mathbf{U}_{id} \in {\rm I\!R}^{3N\times n_i}$ is the identity orthonormal basis with $n_i$ principal components ($n_i\ll3N$), $\mathbf{U}_{exp} \in {\rm I\!R}^{3N\times n_e}$ is the expression orthonormal basis with the $n_e$ principal components ($n_e\ll3N$) and $\mat{s}_t^i \in {\rm I\!R}^{n_i}$, $\mat{s}_t^e \in {\rm I\!R}^{n_e}$ are the identity and expression parameters of the morphable model. We designate the joint identity and expression parameters at time-step $t$ by $\mat{s}_t=[\mat{s}_t^{i^{\top}}, \mat{s}_t^{e^{\top}]^{\top}}$. In the adopted model \eqref{eq:3DMM}, the 3D facial shape $\mathbf{x}$ is a function of both identity and expression coefficients ($\mathbf{x}(\mat{s}_t^i, \mat{s}_t^e)$), where expression variations are effectively represented as offsets from a given identity shape.
\textbf{Video-based 3D reconstruction.} The video fitting approach followed in \textit{Head2Head} \cite{Koujan2020head2head} to estimate the 3D facial geometry is based on a set of sparse landmarks extracted from the entire input sequence. This method has three main drawbacks: 1) the fidelity of the 3D reconstruction relies heavily on the accuracy of extracted landmarks which are also sparse (68 in total), 2) it might require a large number of frames with enough reconstruction cues (various rotations) to produce good accuracy, 3) it makes a quite strong assumption in the initialisation stage about the rigidity of the face to estimate the camera parameters. To overcome these limitations, we propose to perform the 3D facial reconstruction in this work by training a deep CNN, we call \textbf{DenseFaceReg}, the purpose thereof is to produce a dense 3D facial mesh from a single RGB frame. We use a thousand annotated videos from the \textbf{Face3DVid} dataset of Koujan et al. \cite{Koujan_2020_CVPR} to train this network in a supervised manner. The adopted loss function during training is:
\begin{equation}
\label{eq:3DFaceMehsReg}
\begin{split}
\mathcal{L}(\Phi)= \sum\limits_{i=1}^{N}|| \mathbf{v}_{i}^{GT}-\mathbf{v}_{i}||^2.
\end{split}
\end{equation}
Equation (\ref{eq:3DFaceMehsReg}) penalises the deviation of each vertex from the corresponding ground-truth vertex ($\mathbf{v}_i=[x, y, z]^{\top}$). We use the camera parameters provided with the \textbf{Face3DVid} dataset to project the 3D ground-truth mesh, so that our \textbf{DenseFaceReg} produces 3D vertices (dense landmarks) directly in the image space.
We use the dense 3D vertices ($\sim$5K) estimated by our trained \textbf{DenseFaceReg} on each video frame to: 1) estimate the camera parameters, 2) generate the 3DMM identity and expression coefficients by projecting the dense shape onto the 3DMM bases. For all our experiments in this work, we use the same 3DMMs utilised in \cite{Koujan2020head2head}.
The analysis-by-synthesis approach, which is used by many state-of-the-art approaches \cite{deepvideoportraits, face2face}, estimates a lot of parameters (e.g. illumination, reflectance, shape, etc) and solves a highly ill-posed problem for fitting 3DMMs to images. On the contrary, our facial reconstruction stage is a fast CNN-based approach (6ms test runtime) trained on a large number of in-the-wild videos. The facial representation extracted with our method is informative enough to synthesise photo-realistic and temporally smooth videos, eliminating the need for more elaborate and slower 3D facial reconstruction techniques.
\subsection{Facial Semantic Representation - NMFC Rendering}
Our video rendering network receives as input a facial semantic representation of the target subject, with the head pose and facial expression guided by the source frames. This representation disentangles identity from expression, allowing us to train our video rendering network on a specific target person. During test, we are able to transfer the expression and pose of any source, with different head characteristics, to the target. Given the recovered identity and expression parameters (facial shape) $\mat{s}_t=[\mat{s}_t^{i^{\top}}, \mat{s}_t^{e^{\top}]^{\top}}$ and camera parameters $\mat{p}_t$, at frame $t$, we rasterize the 3D shape, producing a visibility mask ($\mathbf{M} \in {\rm I\!R}^{W\times H}$) in the image space. Each pixel of $\mathbf{M}$, stores the index of the corresponding visible triangle on the 3D face seen from this pixel. Thereafter, we store the normalised x-y-z coordinates of the centre of this triangle in the $\mathbf{NMFC} \in {\rm I\!R}^{W\times H \times3}$ image, which is the facial semantic representation that is utilised as conditional input to the video rendering network. Equation (\ref{eq: NMFC}) details this process.
\begin{equation}
\label{eq: NMFC}
\mathbf{NMFC}_t= \mathcal{E}(\mathcal{R}(\mat{x}_t(\mat{s}_t^i, \mat{s}_t^e), \mat{p}_t), \bar{\mat{x}}),
\end{equation}
where $\mathcal{R}$ is the rasterizer, $\mathcal{E}$ is the encoding function and $\bar{\mat{x}}$ is the normalised version of the 3DMM mean face (see (\ref{eq:3DMM})), so that the x-y-z coordinates of this face belong in $[0, 1]$. The NMFC image generation relies not only on the 3D reconstructed face and camera parameters of the current frame but also on an always-fixed normalised mean face ($\bar{\mathbf{x}}$) of the employed 3DMM. The (x, y, z) coordinates of the normalised mean face are used as constant colors to texture the 3D face of the current input frame $f_{t}$. The NMFC image of a frame $f_{t}$ is generated then by rendering the corresponding textured 3D mesh. Since we texture any reconstructed 3D mesh with always a fixed set of distinctive colors, the same semantic point, say the tip of the nose, in any NMFC image (regardless of the subject and the target video) will always have the same color. This is why we refer to NMFCs as semantic images. The main advantage of using NMFCs over a UV 2D parameterisation is that it proved experimentally to be easier for the video renderer to learn the mapping to the output RGB images, since both the NMFCs and the output are in the same space. Additionally, this representation is more compact and easy-to-interpret by our video rendering network, since it associates well with the corresponding RGB frame to be generated, pixel by pixel, and, subsequently, leads to a realistic and novel video synthesis. Note that during test time, the expression coefficients $\mat{s}_t^e$ and camera parameters $\mat{p}_t$ are estimated from the source video at frame $t$, while the identity coefficients $\mat{s}^i$ are the average identity parameters estimated using all frames of the target video (see Fig. \ref{fig:fig1}).
\subsection{Eye Pupils Detection}
We choose a real-time operating method for the extraction of the eye movements from the source frames, which does not require fitting an eye model \cite{Wood2017}, but is based on 68 facial landmarks \cite{dlib09}. Given the subset of landmark points $\mat L^{eye} \in {\rm I\!R}^{6 \times 2}$ that correspond to the left or right eye, we estimate one more landmark $\mat l^{pupil} \in {\rm I\!R}^{2}$, which corresponds to the eye pupil. The eye pupil is obtained as the centre of mass within the set of pixels $\mat \Omega$ that are bounded by the polygon formed with the eye landmarks $\mat L^{eye}$ by computing a weighted sum, using the inverse intensity of pixels in $\mat \Omega$ as weights. Following \cite{Saragih2011}, we are based on the assumption that eye pupils are the "darker" areas within the eye region in terms of pixel intensity. Mathematically, the eye centre of mass is given as
\begin{equation}
\mat l^{pupil} = \dfrac{\sum_{\mat p \in \mat \Omega} I(\mat p) \mat p}{\sum_{\mat p \in \mat \Omega} I(\mat p)},
\end{equation}
where $I(\mat p)$ is the inverse intensity of pixel $\mat p$ in the source frame. In this way, $\mat l^{pupil}$ corresponds to the center of "darker" pixels within the eye region.
Once the eyes and pupils landmarks are estimated, we create the eyes video $\mat E_{1:T}$, which is a sequence of $T$ RGB frames of size $256 \times 256 \times 3$. An example of these frames is shown in Fig. 1. We connect the eye landmarks with white edges to create an outline of each eye. Then, two red circles are drawn on the same plane, using as centres the eye pupil coordinates of each eye, in order to indicate eye gaze.
\subsection{Deep Video Rendering Neural Network}
\label{subsec:videorenderer}
Our carefully-designed video rendering network receives as conditional input two sequences of images, namely: the NMFC video $\mathbf{NMFC}_{1:T}$ and the corresponding eye video $\mathbf{E}_{1:T}$, collectively as $\mat{X}_{1:T} \equiv \{ \mat X_t = (\mathbf{NMFC}_t, \mathbf{E}_t) \}_{t=1,\dots,T}$, with $\mat X_t \in {\rm I\!R}^{H \times W \times 6}$. With this input, the video rendering network yields a highly realistic and temporally coherent output video $\tilde{\mat Y}_{1:T}$ picturing the target actor mimicking exactly the same expressions, head pose and eyes reflected in $\mat{X}_{1:T}$. While training, we follow a self reenactment setting where the source and target videos are the same footage. In this way, the reenacted video in the output should be a replication of the RGB training target video $\mat{Y}_{1:T}$, which serves as ground truth. Our video rendering network is trained within a GAN-based structure with: 1) a Generator $G$, which is the video rendering network itself, 2) an Image Discriminator $D_I$, 3) a multi-scale Dynamics Discriminator $D_D$ enforcing the temporal coherence and realism of the produced facial performance, and 4) a dedicated Mouth Discriminator $D_M$, which further improves the visual quality of the mouth area.
\textbf{Generator $G$.} To successfully synthesise smooth and convincing temporal facial performances, we condition the synthesis of the $t$-th frame $\tilde{\mat Y}_t$ not only on the conditional input $\mat X_t$, but also on the previous inputs $\mat X_{t-1}$ and $\mat X_{t-2}$, as well as the previously generated frames $\tilde{\mat Y}_{t-1}$ and $\tilde{\mat Y}_{t-2}$, thus:
\begin{equation}
\tilde{\mat Y}_{t} = G(\mat{X}_{t-2:t}, \tilde{\mat{Y}}_{t-2:t-1}).
\end{equation}
The Generator is applied sequentially, producing the output frames one after the other, until the entire output sequence has been created. Similar to \textit{Head2Head} \cite{Koujan2020head2head}, the Generator consists of two identical encoders, operating in parallel, as well as a decoder. The first encoder receives the concatenated NMFC and eye images $\mat{X}_{t-2:t}$, while the second is given the two previously generated frames $\tilde{\mat{Y}}_{t-2:t-1}$. The two extracted feature maps are first added and then passed through the decoder, which brings the output $\tilde{\mat Y}_{t}$ in a normalised [-1,+1] range, using a $\tanh$ activation function.
\textbf{Image Discriminator $D_I$ and Mouth Discriminator $D_M$.} Both of these networks aim at telling real and synthesised frames apart, and are used only during training. At time-step $t$, the Image Discriminator $D_I$ processes the real pair $(\mat X_{t}, \mat Y_{t})$ and the fake one $(\mat X_{t}, \tilde{\mat Y}_{t})$.
Concurrently, the corresponding mouth regions $(\mat X_{t}^m, \mat Y_{t}^m)$ and $(\mat X_{t}^m, \tilde{\mat Y}_{t}^m)$ are cropped and sent to the Mouth Discriminator $D_M$.
\textbf{Dynamics Discriminator $D_D$.} With the aim of learning complex facial dynamics in mind, we further equip our GAN framework with a Dynamics Discriminator $D_D$. During training, $D_D$ receives a set of three consecutive real frames $\mat{Y}_{t:t+2}$ or fake frames $\tilde{\mat Y}_{t:t+2}$. They are passed to $D_D$ after being associated with the optical flow $\mat{W}_{1:T-1}$, computed from the real frames (training video $\mat{Y}_{1:T}$ of target subject). Following this, the Generator is encouraged to create fake frames showing the same flow (dynamics) as the corresponding real ones. The Dynamics Discriminator learns to differentiate between the real $(\mat{W}_{t:t+1}, \mat{Y}_{t:t+2})$ and fake $(\mat{W}_{t:t+1}, \tilde{\mat Y}_{t:t+2})$ pairs. In practice, we employ a multiple-scale Dynamics Discriminator, which operates in three different temporal scales. The first scale receives frame sequences in the original frame rate. Then, the two extra scales are formed by sub-sampling the frames by a factor of two for each scale.
\textbf{Objective function:} In order to train our Generator to synthesise samples as real as possible, we formulate an adversarial loss. More specifically, we use LSGAN \cite{lsgan} with labels $a=c=1$ for fake samples and label $b=0$ for real ones, resulting in the following adversarial objective for the Generator:
\begin{equation}
\begin{split}
& \mathcal{L}_{adv}^G = \dfrac{1}{2} {\rm I\!E}_{t}[(D_D(\mat{W}_{t:t+1}, \tilde{\mat{Y}}_{t:t+2}) - 1)^2] \\
& + \dfrac{1}{2} {\rm I\!E}_{t}[(D_I(\mat X_{t}, \tilde{\mat Y}_{t}) - 1)^2 + (D_M(\mat X_{t}^{m}, \tilde{\mat Y}_{t'}^{m}) - 1)^2].
\end{split}
\label{eq:1}
\end{equation}
We add two more losses in the learning objective function of the Generator: 1) a VGG loss $\mathcal{L}_{vgg}^G$ and 2) a feature matching loss $\mathcal{L}_{feat}^G$, first proposed in the work of Xu et al. \cite{xu2017learning}. Our feature matching loss term is based on the activations of both the Image and Dynamics Discriminators. Given a ground-truth frame $\mat Y_t$ and the synthesised frame $\tilde{\mat Y}_t$, we use the VGG network \cite{vgg} to extract visual features in different layers for both frames and compute the VGG loss as in \cite{pix2pixHD} and \cite{vid2vid}.
Likewise, the feature matching loss is computed by extracting features with the two Discriminators $D_I$ and $D_D$ and computing the $\ell_1$ distance of these features for a fake frame $\tilde{\mat Y}_t$ and the corresponding ground truth $\mat Y_t$. For the computation of the overall feature matching loss, we compute a loss term $\mathcal{L}_{feat}^{G-D_I}$ using features extracted by $D_I$, as well as another loss term $\mathcal{L}_{feat}^{G-D_D}$, using the dynamics discriminator $D_I$ and then we add them: $\mathcal{L}_{feat}^G = \mathcal{L}_{feat}^{G-D_I} + \mathcal{L}_{feat}^{G-D_D}$. The total objective for $G$ is given by:
\begin{equation}
\mathcal{L}^G = \mathcal{L}_{adv}^G + \lambda_{vgg} \mathcal{L}_{vgg}^G + \lambda_{feat}\mathcal{L}_{feat}^G
\end{equation}
To achieve a balance between the loss terms above, we set $\lambda_{vgg} = \lambda_{feat} = 10$. The Image, Mouth and Dynamics Discriminators are optimised under their corresponding adversarial objective functions (see Supplementary Material).
\textbf{Facial dynamics.} One key factor to consider while designing the Dynamics Discriminator is how it could learn the complex realistic facial muscular interactions observed in monocular videos of facial performances. As discussed and validated experimentally in \cite{Koujan_2020_CVPR}, off-the-shelf state-of-the-art optical flow methods solve this problem without any prior knowledge, since they target any moving objects in the scene. When applied to faces captured in the wild, the estimated flow does not reflect faithfully the non-rigid and composite facial deformations. To tackle this, we employ a state-of-the-art network, termed as FlowNet2, for the optical flow estimation \cite{flownet2}. The authors of \cite{flownet2} trained this network on publicly available images after rendering them with synthesised chairs modified by various affine transformations. Starting from the pretrained models of \cite{flownet2}, we fine-tune their network on the 4DFAB dataset \cite{cheng20184dfab}. This dataset has dynamic high-resolution 4D videos of subjects eliciting spontaneous and posed facial behaviours. Our fine-tuned FlowNet2 network is therefore utilised to estimate the optical flow matrix $\mat{W}$ referred to in equation \ref{eq:1}.
\section{Experiments}
\subsection{Dataset and Implementation Details}
We train and test \textit{Head2Head++} on a newly collected video dataset, which we make publicly available, consisting of eight different individuals. Each individual is depicted in one video, which is at least 10 minutes long and presents the target in diverse head poses and facial expressions. First, we apply face detection on each video, as a pre-processing step. We utilise \cite{mtcnn} to obtain a bounding box per frame, and then we compute the average bounding box throughout frames. We extract the facial ROI of $256 \times 256$ pixels for each frame, according to this fixed bounding box. This way, the background remains as stable and unchanged as possible, from the beginning of the video until the end. Finally, the frames of each subject are split into a training and a test set. Please refer to the Supplementary Material for more details on the dataset.
We base our Generator's architecture on our previous work \cite{Koujan2020head2head}. All discriminators have the same architecture, adopted by \textit{pip2pixHD} \cite{pix2pixHD}.
We train a separate person- and video-specific Video Rendering Network for each one of the eight target identities. Each trained model at the end is dedicated for the target video used during training and does not generalise to synthesise the same target person under different cloths and backgrounds (only video specific). Given a target video footage of 10 minutes, extracting the eyes and NMFC conditional input sequences and training, the GAN framework requires around 20 hours. Networks are optimised with Adam \cite{adam}, for 40 epochs with an initial learning rate $\eta = 2 \cdot 10^4$, $\beta_1 = 0.5, \beta_2 = 0.999$, on a single NVIDIA GeForce RTX2080 Ti. During test time, our \textit{Head2Head++} pipeline performs head reenactment from web-camera captures in nearly real-time speeds (18 fps).
\subsection{Supported Reenactment Methods}
\label{subsec:reenmethods}
As already mentioned, we have chosen to use 3DMMs
for the retrieval of 3D facial shapes from the source and target videos in order to address the target identity preservation problem, allowing us to disentangle expression from identity seamlessly.
Therefore, \emph{Head2Head++} can be used both for full head reenactment and simple facial reenactment, depending on which set of camera parameters (target or source) are used during the creation of the conditional NMFC sequence.
\begin{figure}[t!]
\includegraphics[trim=10 0 0 0, width=3.5in]{head_reenactment.pdf}
\caption{Head reenactment aims at transferring the expressions, pose and eye movements from the driving sequence to the target identity.}
\label{fig2}
\end{figure}
\begin{figure}[t!]
\includegraphics[trim=24 0 0 0, width=3.5in]{self_reenactment.pdf}
\caption{Self reenactment is used for evaluating the performance of models. Here, the source identity coincides with the target one. We display Average Pixel Distance (APD) and Masked Average Pixel Distance (MAPD) between the generated and ground truth frames, in the form of RGB heatmaps. Please refer to Sec.~\ref{subsec:reenmethods} for more details on those metrics.}
\label{fig3}
\end{figure}
\textbf{Head Reenactmenent.} This is the main functionality of our method and arguably the most challenging, since it involves transferring the complete head motion from any driving video to the desired target subject. A head reenactment example is demonstrated in Fig. \ref{fig2}. Given the driving sequence (Johnson), our method synthesises a highly photo-realistic and temporally coherent video of the targeted identity (Trump).
\textbf{Face Reenactmenent.} Instead of transferring all head movements from the source video, we can simply pass the facial expressions to the target identity. This is done by utilizing the original camera parameters, estimated from the target training sequence. In this case, we use the original eye landmarks extracted from the training sequence to drive synthesis. The advantage of face reenactment is that our Generator has encountered the same head poses and positions during training, which is beneficial when it comes to synthesising the hair, background and upper body areas, where no conditional information is available in the input. Although prior works have mainly used it as a manipulation method \cite{face2face, DeferredNeuralRendering}, we perform face reenactment by generating all pixels within frames, not only a masked area of the face.
\textbf{Self Reenactmenent.} During self reenactment, the source identity coincides with the target one. This is extremely useful for training and evaluating our model, since we are given access to the ground truth frames. Note that the driving sequences used during test have not been seen during training, since they belong to the test data split. Fig. \ref{fig3} shows a self reenactment experiment. Ideally, the generated frames should be identical with the source ones. For the evaluation of the reconstructive ability of models in the experiments that follow, we use metrics such as the average pixel distance (APD) or masked average pixel distance (MAPD) between the synthesised and ground truth frames. In Sec.~\ref{subsec:metrics}, we provide more details on APD and MAPD.
\subsection{Quantitative Evaluation Metrics}
\label{subsec:metrics}
We evaluate the performance of our system both qualitatively and quantitatively. Most experiments were performed under self reenactment. That is, given a set of test frames $\mat Y^{(i)}$ for each target identity $i$ in the dataset, we generated the corresponding synthetic frames $\tilde{\mat Y}^{(i)}$ and used $\mat Y^{(i)}$ as ground truth. We assessed our method's reconstructive ability, target identity preservation, pose and expression transferability as well as the photorealism of generated frames, using the metrics below:
\textbf{Average Pixel Distance (APD):} is computed as the average L2-distance of RGB values across all spatial locations and frames, between the ground truth and generated data.
\textbf{Masked Average Pixel Distance (MAPD):} similar to APD, it tests the reconstructive performance. A mask computed from NMFC frames is used to constrain the metric on the facial area, where conditional information is available.
\textbf{Distance between Average Identities (DAI):} after performing 3D face reconstruction on $\mat Y^{(i)}$ and $\tilde{\mat Y}^{(i)}$ sequences, we compute the average identity coefficients for each sequence, and then the L1-distance between those average identities.
\textbf{Average Expression Distance (AED):} after reconstructing the fake and ground truth sequences, we measure the average L1-distance between the expression coefficients across frames.
\textbf{Average Rotation Distance (ARD)}: this metric is used to measure pose transferability. Using the estimated camera parameters from the generated and ground videos, we compute the Euler angles that correspond to head poses. Then, the average Euler angles discrepancy across sequences is determined in terms of degrees.
\textbf{Fréchet Inception Distance (FID):} this is a widely used metric for evaluating the visual quality of individual frames, originally proposed in \cite{NIPS2017_7240}. We use \cite{Deng_2019_CVPR} as a feature extractor and we report the mean FID throughout the experiments.
\textbf{Maximum Mean Discrepancy (MMD$^2$):} is a very useful metric for measuring the discrepancy between real and fake frames \cite{mmd}.
\subsection{Ablation Study}
\begin{figure}[t!]
\centering
\includegraphics[width=3.5in]{macron_noMD.pdf}
\caption{Significance of Mouth Discriminator. Please zoom in for details.}
\label{fig:fig5}
\end{figure}
\begin{figure}[t!]
\centering
\includegraphics[width=3.5in]{noeyes.pdf}
\caption{Significance of conditioning on the eyes. The blinking of the source is successfully transferred to the target when using eye landmarks to condition synthesis. On the contrary, conditioning solely on NMFC frames is not sufficient for transferring eye gaze and blinking.}
\label{fig:fig4}
\end{figure}
We conducted an ablation study, in order to assess the significance of several "key" components of our \textit{Head2Head++} system. First, we evaluate numerically the contribution of the two reconstructive loss terms, namely the feature matching and VGG loss. As can be seen in the first two rows of Table \ref{table1}, all metrics demonstrate the contribution of these loss terms on the quality of the generated samples.
The next row of the table validates
the importance of a sequential Generator, as opposed to its non-sequential variation (``w/o seq.~$G$''). The results indicate that considering previously generated frames in the Generator has a very positive effect on the visual quality of samples. Finally, the majority of metrics show that removing the Dynamics Discriminator (``w/o $D_D$'') might slightly improve the quality of frames, when seen as individual images. We believe this is due to the fact that the proposed metrics analyse solely the spatial content of frames and do not evaluate temporal information. Removing $D_D$ network would actually reduce the temporal stability and coherence of videos. Such behaviour is more apparent in areas where no conditional information is available (e.g. hair, background, upper body). In order to understand better the significance of the Dynamics Discriminator in the visual plausibility of the output video, please refer to our Supplementary Video.
\begin{table}[!t]
\renewcommand{\arraystretch}{1.3}
\caption{Ablation study results under the self reenactment setting, averaged across all eight target identities in our dataset. For all metrics, lower values indicate better quality or performance. Bold and underlined values correspond to the best and the second-best
value of each metric, respectively.}
\label{table1}
\centering
\begin{tabular}{|c|c|c|c|c|c|c|}
\hline
& & & & & $\times 10^2$ & $\times 10^5$ \\
\textbf{Variations} & APD & MAPD & AED & ARD & FID & MMD$^2$ \\
\hline
\hline
w/o $\mathcal{L}_{feat}^G$ & 17.62 & 16.70 & 0.627 & $0.539^\circ$ & 6.98 & 13.23 \\
\hline
w/o $\mathcal{L}_{vgg}^G$ & 15.74 & 13.95 & 0.514 & $0.452^\circ$ & 5.40 & 9.42 \\
\hline
w/o seq. $G$ & 15.71 &13.63 & 0.486 & $0.436^\circ$ & 4.98 & 9.06 \\
\hline
w/o $D_D$ & \underline{15.09} & \textbf{13.03} & \textbf{0.456} & $\textbf{0.408}^\circ$ & \textbf{3.95} & \textbf{5.57} \\
\hline
\textbf{\textit{Full model}} & \textbf{14.82} & \underline{13.06} & \underline{0.467} & $\underline{0.412}^\circ$ & \underline{4.15} & \underline{6.50} \\
\hline
\end{tabular}
\end{table}
\begin{table}[h]
\parbox{.45\linewidth}{
\centering
\caption{Ablation study of the effect of Mouth Discriminator $D_M$ and conditioning on the eyes in \textit{Head2Head++}.}
\label{tab:EvalMouthEye}
\begin{tabular}{|c|c|c|}
\hline
\textbf{Variations} & APD & AELD \\
\hline
\hline
w/o $D_M$ & 13.43 & - \\
\hline
w/o Eyes input & - & 1.52 \\
\hline
\textbf{\textit{Full model}} & \textbf{12.32} & \textbf{1.06} \\
\hline
\end{tabular}
}
\hfill
\parbox{.45\linewidth}{
\centering
\caption{Ablation study of the effect of Sequential Generator and Dynamics Discriminator in \textit{Head2Head++}.}
\label{tab:EvalDynamics}
\begin{tabular}{|c|c|}
\hline
\textbf{Variations} & FVD \\
\hline
\hline
w/o seq. $G$ & 74.42 \\
\hline
w/o $D_D$ & 66.48 \\
\hline
\textbf{\textit{Full model}} & \textbf{57.46} \\
\hline
\end{tabular}
}
\end{table}
Arguably, the eyes and the mouth, are the facial areas that might be the first to expose the "fakeness" of a synthetic video. In Fig. \ref{fig:fig5}, we illustrate the importance of the dedicated Mouth Discriminator, initially proposed in \cite{Koujan2020head2head}. As can be seen in the second row of Fig. \ref{fig:fig5}, when the Mouth Discriminator is not included in GAN training, teeth details make the generated video appear less realistic, as opposed to the results in the first row, where the Generator was supervised by $D_M$ network. Fig. \ref{fig:fig4} demonstrates the significance of conditioning the Generator on the eyes input sequence. Given that NMFCs do not adequately reflect eye gaze and blinking, conditioning solely on the NMFC input sequence does not provide substantial information to the Generator, for transferring the eye movements of the source to the target. Additionally, we quantitatively evaluate the significance of the mouth discriminator and the eye gaze conditioning. Table \ref{tab:EvalMouthEye} presents the numeric measures obtained when assessing their effect. In the second column of Table \ref{tab:EvalMouthEye}, we report the \textbf{average pixel distance (APD)} within the\textbf{ mouth area} under self-reenactment, between the generated and ground truth regions of interest, for all eight identities in our dataset. As can be seen, the numeric results agree with the qualitative ones, in Fig. 4. In the third column of Table \ref{tab:EvalMouthEye}, we assess the importance of \textbf{conditioning the Generator on the Eyes input} (Eyes Video sketch shown in Fig. 1). For that, we use the landmarker to extract eye landmarks, both from the ground truth and synthetic frames, created under self-reenactment. Then, we compute the \textbf{average eye landmarks $L2$-distance (AELD)}, between real and generated frames, across all eight identities and report the results in the Table \ref{tab:EvalMouthEye}. We observe that conditioning on the eyes helps to synthesise faces that better follow the eye movement and gaze appearing in the source video.
Lastly, in order to evaluate the importance of the Dynamics Discriminator $D_D$ on the temporal consistency of generated frames, we use the Fréchet Video Distance (FVD) \cite{fvd}. We also provide the FVD score for the non-sequential variation of Head2Head++ (w/o seq. $G$). The results of Table \ref{tab:EvalDynamics} indicate that our full model with a sequential Generator trained alongside a Dynamics Discriminator outperforms both variations by a significant margin.
\subsection{Effect of Training Video Length}
Fig. \ref{fig:fig13} displays the influence of training footage duration on the generative performance of the the Video Rendering Network. For that experiment, we trained five separate models per target identity. Each model was trained on frame sequences of different length: one, two, four, eight, up to sixteen thousand frames. We found that FID and MMD$^2$ scores, which indicate visual quality, are the metrics affected the most by the number of training frames. Furthermore, it is visible that there is still room for improvement in the performance of our Video Rendering Network, provided that even longer training videos are available. However, this would require additional footage with enough head pose variability, which in practice does not scale linearly with the number of training frames available.
\begin{figure}[t!]
\centering
\includegraphics[width=3.5in]{video_length.pdf}
\caption{Significance of training video length. We show the same image generated with a GAN trained on 1K, 2K, 4K, 8K and 16K frames, as well as the ground truth (last image).}
\label{fig:fig7}
\end{figure}
\begin{figure}[h!]
\centering
\pgfplotsset{every tick label/.append style={font=\huge \boldmath}}
\pgfplotsset{xlabel style={align=center}}
\subfloat[]{
\begin{tikzpicture}[scale=0.34]
\begin{axis}[
xlabel={\Huge number of frames \\ \Huge (in thousands)},
xmin=0, xmax=17,
ymin=10, ymax=30,
xtick={1,2,4,8,16},
ytick={14,24},
ymajorgrids=true,
legend pos=north east,
grid style=dashed,
]
\addplot[
color=blue,
mark=*,
]
coordinates {
(1,24.27)(2,22.29)(4,21.97)(8,20.57)(16,17.16)
};
\addplot[
color=red,
mark=*,
]
coordinates {
(1,21.99)(2,19.80)(4,18.95)(8,18.35)(16,14.03)
};
\legend{\Huge APD, \Huge MAPD}
\end{axis}
\end{tikzpicture}
}
\subfloat[]{
\begin{tikzpicture}[scale=0.34]
\begin{axis}[
xlabel={\Huge number of frames \\ \Huge (in thousands)},
xmin=0, xmax=17,
ymin=0.3, ymax=1.4,
xtick={1,2,4,8,16},
ytick={0.4,1.1},
ymajorgrids=true,
legend pos=north east,
grid style=dashed,
]
\addplot[
color=blue,
mark=*,
]
coordinates {
(1,0.838)(2,0.682)(4,0.579)(8,0.513)(16,0.453)
};
\addplot[
color=red,
mark=*,
]
coordinates {
(1,1.060)(2,0.772)(4,0.601)(8,0.572)(16,0.461)
};
\legend{\Huge AED, \Huge ARD}
\end{axis}
\end{tikzpicture}
}
\subfloat[]{
\begin{tikzpicture}[scale=0.34]
\begin{axis}[
xlabel={\Huge number of frames \\ \Huge (in thousands)},
xmin=0, xmax=17,
ymin=0, ymax=45,
xtick={1,2,4,8,16},
ytick={4,32.2},
ymajorgrids=true,
legend pos=north east,
grid style=dashed,
]
\addplot[
color=blue,
mark=*,
]
coordinates {
(1,15.19)(2,9.75)(4,6.64)(8,5.17)(16,3.94)
};
\addplot[
color=red,
mark=*,
]
coordinates {
(1,32.26)(2,17.39)(4,10.85)(8,7.57)(16,4.62)
};
\legend{\Huge FID, \Huge MMD$\mathbf{^2}$}
\end{axis}
\end{tikzpicture}
}
\caption{The effect of the number of training frames on the quality of generated frames. All metrics were computed for the subset of four target identities (Macron, Sanchez, Trump, Von Der Leyen).}
\label{fig:fig13}
\end{figure}
In Fig. \ref{fig:fig7}, we demonstrate the impact of training video length on the visual quality of synthetic frames. We observe visually that as the number of available training frames increases, artifacts become less severe and eventually disappear. This behaviour comes in agreement with the decrease of evaluation metrics, shown in Fig. \ref{fig:fig13}.
\begin{figure}[t!]
\centering
\includegraphics[width=3.5in]{finetuning.pdf}
\caption{The effect of pre-training the Video Rendering Network on Face Forensics++ dataset. The importance of pre-training is very prominent when a limited number of training frames (1K, 2K) is available.}
\label{fig:fig8}
\end{figure}
\subsection{Pre-training on Face Forensics++ Dataset}
We further explore how the generative performance of the Video Rendering Network can be improved in the case of limited video footage, for instance when training sequences are less than four thousand frames (about 2.5 minutes). To that end, we pre-trained \textit{Head2Head++} on the large-scale \textit{Face Forensics++} dataset \cite{roessler2019faceforensicspp}, containing 1000 different identities. At this stage, the Generator learned to create a ``average identity'', since there is no mechanism to dictate which identity to be synthesised over this multi-person dataset. As a next step, we fine-tuned eight person-specific models, one for each target identity in our dataset, using a subset of their available footage (1K, 2K or 4K frames). In Table \ref{table3}, we report a quantitative evaluation with and without pre-training on \cite{roessler2019faceforensicspp} data. As suggested by the results, pre-training on \textit{Face Forensics++} data appears advantageous, especially for shorter sequences (1K or 2K frames). This could be explained if we consider pre-training as a head start for the GAN, where the Generator is already capable of creating a realistic ``average identity'' and then it remains to learn a specific one. The same trend can be seen in Fig. \ref{fig:fig8}. Especially for a training footage of 1K or 2K frames, the quality of generated frames is clearly inferior in comparison with samples created with pre-training.
\begin{table}[t!]
\renewcommand{\arraystretch}{1.3}
\caption{Effect of pre-training GAN on Face Forensics++ dataset, when training video footage is limited, namely less than 4K frames. All metrics are averaged across all eight target identities in our dataset. For all metrics, lower values indicate better quality or performance.}
\label{table3}
\centering
\begin{tabular}{|c|c|c|c|c|c|c|}
\hline
\textbf{Number of} & & & & & $\times 10^2$ & $\times 10^5$ \\
\textbf{train frames} & APD & MAPD & AED & ARD & FID & MMD$^2$ \\
\hline
\hline
1K & 22.62 & 20.32 & 0.844 & $0.955^\circ$ & 16.01 & 39.59 \\
\hline
w/ pre-train & \textbf{21.95} & \textbf{19.02} & \textbf{0.575} & $\textbf{0.562}^\circ$ & \textbf{15.93} & 39.76 \\
\hline
\hline
2K & 20.41 & 18.27 & 0.719 & $0.737^\circ$ & 11.04 & 24.83 \\
\hline
w/ pre-train & \textbf{20.17} & \textbf{17.84} & \textbf{0.526} & $\textbf{0.516}^\circ$ & 11.22 & 24.93 \\
\hline
\hline
4K & 18.87 & 17.46 & 0.610 & $0.577^\circ$ & 7.41 & 15.08 \\
\hline
w/ pre-train & 18.90 & \textbf{16.71} & \textbf{0.483} & $\textbf{0.453}^\circ$ & 7.80 & 15.63 \\
\hline
\end{tabular}
\end{table}
\subsection{Comparison with the State of the Art}
We compare our \textit{Head2Head++} system with the image-based method of \textit{DVP} \cite{deepvideoportraits} and video-based \textit{Head2Head} \cite{Koujan2020head2head}. This is done by performing a full head reenactment experiment on the same source and target video footage. First, we trained our method and \textit{Head2Head} on the target sequence, which was kindly provided by the authors of \cite{deepvideoportraits}, and then we used the same source to drive synthesis. In Fig. \ref{fig:fig9} we display some examples, in which our method outperforms \textit{DVP} in terms of head pose and expression transferability.
\begin{figure}[t!]
\centering
\includegraphics[width=3.5in]{vsDVP.pdf}
\caption{Comparison of our method with \textit{DVP}. In many cases our method outperforms \textit{DVP}, especially in terms of head pose transferability.}
\label{fig:fig9}
\end{figure}
\begin{table}[t!]
\renewcommand{\arraystretch}{1.3}
\caption{Quantitative comparison with \textit{DVP} and \textit{Head2Head} under full head reenactment. For all metrics, lower is better.}
\label{table4}
\centering
\begin{tabular}{|c|c|c|c|c|c|c|}
\hline
& & & & $\times 10^2$ & $\times 10^5$ & \\
\textbf{Method} & AED & ARD & DAI & FID & MMD$^2$ & AELD \\
\hline
\textit{DVP} & 2.089 & $2.54^\circ$ & 23.01 & 15.94 & 61.32 & 0.85 \\
\hline
\textit{Head2Head} & \textbf{1.426} & $\textbf{0.70}^\circ$ & 9.56 & 39.35 & 186.11 & 0.72 \\
\hline
\textbf{\textit{Ours}} & 1.509 & $0.83^\circ$ & \textbf{8.86} & \textbf{12.42} & \textbf{39.15} & \textbf{0.71} \\
\hline
\end{tabular}
\end{table}
For a quantitative comparison of the three methods, we performed 3D face reconstruction on the two synthetic videos and computed the average expression distance (AED) and average rotation distance (ARD) across frames, between the source video and the three generated videos. Then, we applied 3D face reconstruction on the target video and computed the distance between the average identities extracted from this real and each one of the three fake sequences. Finally, we used the FID and MMD$^2$ scores as a photo-realism metric, both computed between the fake videos and a set of frames from the target's original footage. For the eye region, where significant visual improvements have been made over \textit{Head2Head}, we computed the average eye landmarks $L2$-distance (AELD), between source and generated videos.
The results presented in Table \ref{table4} suggest that our method outperforms DVP on every single metric and \textit{Head2Head} in several. More specifically, data samples produced by \textit{Head2Head++} exhibit significantly lower FID and MMD$^2$ scores, when compared to these created by \textit{Head2Head++}. This can be explained by the fact that the network (ArcFace \cite{Deng_2019_CVPR}) we employ to extract facial features for FID and MMD$^2$ is very sensitive to the shape of the eyes and thus imperfections and inconsistencies in the eyes region generated by \textit{Head2Head} are reflected in both photo-realism metrics. Considering the AELD metric, the difference between the two methods is very small, which can be justified by the fact that the eye tracker used in \textit{Head2Head} is quite reliable and the video mostly frontal, therefore differences with \textit{Head2Head++} can be better understood in terms of photo-realism. In Fig. \ref{fig:fig10}, we show that our new eye motion extraction method results in more reliable eye synthesis, compared to \textit{Head2Head} \cite{Koujan2020head2head}, in terms of photo-realism and eye shape. We observe that the eye regions generated by \textit{Head2Head} seem unnatural, while \textit{Head2Head++} has successfully rendered photo-realistic eyes.
The AED, ARD and DAI metric values obtained for \textit{Head2Head} seem to be slightly better than \textit{Head2Head++}. We attribute these results to the fact that \textit{Head2Head} is equipped with a video-based 3D reconstruction approach that relies on all video frames to generate the 3D faces, taking a few minutes compared to few milliseconds in the case of \textit{Head2Head++}. Nonetheless, we strongly believe that performing 3D face recovery in nearly real-time outweighs the small disadvantage we noticed in terms of facial expression accuracy.
\begin{figure}[t!]
\centering
\includegraphics[width=3.5in]{vsHead2Head.pdf}
\caption{Comparison of our \textit{Head2Head++} method with \textit{Head2Head} \cite{Koujan2020head2head} on eye region synthesis. We synthesise more photo-realistic eyes in comparison to \cite{Koujan2020head2head}. Please refer to the supplementary video for more examples.}
\label{fig:fig10}
\end{figure}
\begin{table}[t!]
\renewcommand{\arraystretch}{1.3}
\caption{Quantitative comparison with \textit{X2Face} and \textit{FOMM}, using all eight target identities in our dataset, under self reenactment.}
\label{table5}
\centering
\begin{tabular}{|c|c|c|c|}
\hline
\textbf{Method} & APD & FID ($\times 10^2$) & MMD$^2$ ($\times 10^5$) \\
\hline
\textit{X2Face} \cite{X2Face} & 30.54 & 63.3 & 253.2 \\
\hline
\textit{FOMM} \cite{Siarohin_2019_NeurIPS} & 22.43 & 24.6 & 90.3 \\
\hline
\textbf{\textit{Ours}} & 14.82 & 4.2 & 6.5 \\
\hline
\end{tabular}
\end{table}
We further compare our method with the warping-based \textit{X2Face} method \cite{X2Face} as well as the one-shot, image-based \textit{First Order Motion Model for Image Animation (FOMM)} \cite{Siarohin_2019_NeurIPS} system. As suggested visually in Fig. \ref{fig:fig11} and the quantitative results in Table \ref{table5}, \textit{Head2Head++} outperforms both few-shot methods by a large margin. Such a discrepancy can be explained by the fact that we train an individual person-specific model for each target identity, instead of relying on a few image samples of the subject. On the other hand, methods such as first order motion model capitalise on a single image to generate the target person, which results in the inherent ambiguity when the desired head pose is very different from the one displayed on that single reference image. Unavoidably, this makes the identity preservation problem more prominent in one-shot models.
In order to demonstrate the significance of the NMFC representation, we conducted a head reenactment experiment conditioning on landmarks. To that end, we trained \textit{vid2vid} \cite{vid2vid} on the task of landmark-to-RGB video translation. We demonstrate the results in Fig. \ref{fig:fig12}. As can be seen, the facial shape of the source has been transferred along with the pose and expression to the generated target.
\begin{figure}[t!]
\centering
\includegraphics[width=3.5in]{vsOneShot.pdf}
\caption{Comparison with \textit{X2Face} and \textit{FOMM}. Our method exhibits better photo-realism. In many cases, the results of \textit{X2Face} appear distorted, while \textit{FOMM}'s performance drops significantly for poses distant from the one provided in the target image.}
\label{fig:fig11}
\end{figure}
\begin{figure}[t!]
\centering
\includegraphics[width=3.5in]{vsvid2vid.pdf}
\caption{Comparison with \textit{vid2vid} conditioned on facial landmarks. Here, the identity preservation problem of landmarks is evident, as the head geometry of the source is reflected on the generated target.}
\label{fig:fig12}
\end{figure}
\begin{figure}[t!]
\centering
\subfloat[]{\includegraphics[width=1.75in]{figures/2.png}
\label{fig:fig14a}}
\subfloat[]{\includegraphics[width=1.75in]{figures/1.png}
\label{fig:fig14b}}
\caption{User study results. (a) The predictive performance of participants against random selection (Binomial distribution on $n=15$ independent Bernoulli trials with success probability $p=1/3$). (b) The fake detection accuracy of participants on each triplet of video samples.}
\label{fig:fig14}
\end{figure}
\subsection{Automated Study}
The progress recently made by generative deep learning methods is so impressive to the extent that manipulated videos (deepfakes) by such approaches are indistinguishable from the real ones. Consequently, a new research topic has emerged to tackle the detection of what is commonly known as `deepfakes'. A recent attempt in that direction is the \textit{Face Forensics++} \cite{roessler2019faceforensicspp}. The authors of \cite{roessler2019faceforensicspp} collected a dataset of 1000 YouTube videos and manipulated them with graphics-based \cite{face2face, Marek2019} and learning-based \cite{torzdf2019, DeferredNeuralRendering}, facial reenactment methods. With this dataset, a CNN was trained to outrank the performance of human observers in detecting manipulated videos. Such a network was trained on $1.8$ million facially manipulated frames and reached a very high detection accuracy on the test split of their dataset (around $99 \%$). We use their pre-trained best-performing network and fine-tune it on around 14K frames synthesised from eight different subjects by our \textit{Head2Head++} approach and another 14K frames synthesised by \textit{Head2Head}. While fine-tunning, we set the learning-rate to 0.0001 and batch-size to 32. Adam optimiser \cite{adam} was also used with the default parameters. We then test the fine-tuned network on 3.2K frames generated by \textit{Head2Head++} and \textit{Head2Head} methods (1.6K frames each) and not seen during training. The trained network reports an accuracy of $76\%$ vs $80.2\%$ of fake frames detection for \textit{Head2Head++} and \textit{Head2Head}, respectively. This indicates that the fine-tuned forgery detection network finds it easier to spot fake frames generated by Head2Head compared to Head2Head++. Moreover, the same network performs way better (around $99 \%$) in detecting fake frames synthesised by any of the four head-reenactment methods tested in \cite{roessler2019faceforensicspp}.
Thanks to our carefully designed \textit{Head2Head++} framework, the trained forgery detection network finds it harder to identify our fake frames, which can be attributed to the increased realism of our results.
\subsection{User Study}
We further evaluate the photo-realism of our generated videos, by conducting a user study. For that, we synthesised five videos of 75 frames (3 seconds) each, using different reenactment methods (head, face and self reenactment). Then, we coupled each fake video with two real ones, with the same duration and same target identity, forming triplets of videos. Next, we asked 50 participants on MTurk to detect the fake sample of each triplet. We presented the video triplet to the participants, allowing them to watch them only once.
Our recorded results indicate a human fake detection accuracy of $43.1 \%$, which demonstrates the strong photo-realism of samples created by our \textit{Head2Head++} system. In Fig. \ref{fig:fig14a}, we show the relative frequency of participants on the number of fake videos that were successfully detected. As can be seen, the majority managed to spot between 4 and 8 out of the 15 synthetic samples we displayed. The comparison of our statistics with a Binomial distribution (red curve) indicates that user study participants performed slightly better than random selection. Nonetheless, a significant percentage of them, around $18\%$, managed to detect 9 or more fake samples. Finally, Fig. \ref{fig:fig14b} displays the predictive accuracy of participants on each video triplet. It is evident that self reenactment samples were indistinguishable from real ones, with just $32.8 \%$ predictive accuracy. Videos generated under face and head reenactment were identified a little more successfully, with an accuracy of $47.2\%$ and $49.2\%$ respectively.
\section{Conclusion and Future Work}
We proposed \textit{Head2Head++}, a pipeline consisting of a novel 3D facial reconstruction system and a Video Rendering Network, able to perform full head reenactment from a source to a target identity. Our new 3D face recovery and eye tracking methods allow our system to operate in nearly real-time speeds. The extensive set of experiments we performed demonstrated the generative abilities of our system, as well as the significance of its components. Furthermore, qualitative and quantitative comparisons suggest that \textit{Head2Head++} outperforms other state-of-the-art methods, in terms of photo-realism, expression and pose transferability, as well as target identity preservation. For future work, we aim to make the network trainable in a few-shot manner, reducing the training time and eliminating the need for learning a different model per person. Additionally, we plan to transfer the facial expressions from the source in a way that preserves the target's speaking style.
\ifCLASSOPTIONcaptionsoff
\newpage
\fi
\bibliographystyle{IEEEtran}
| {'timestamp': '2021-09-29T02:21:55', 'yymm': '2006', 'arxiv_id': '2006.10199', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10199'} | arxiv |
\section{Introduction}\label{sec:intro}
\input{1_intro}
\section{Related Work}\label{sec:related}
\input{2_related}
\section{Topology Update with the TearingNet}\label{sec:tearing}
\input{3_tearing}
\section{The TearingNet Architecture}\label{sec:arch}
\input{4_arch}
\section{Experimentation}\label{sec:results}
\input{5_results}
\vspace{-2pt}
\section{Conclusion}\label{sec:conclude}
\vspace{-5pt}
\input{6_conclude}
{\small
\bibliographystyle{ieee_fullname}
\subsection{Overview}
A block diagram of the TearingNet is shown in Figure~\ref{fig:gcae}.
The Encoder network (referred to as E-Net, ``E'' in Figure~\ref{fig:gcae}) first generates a latent representation $\vect{c}$ from an input 3D point cloud.
It is then passed to the TearingNet decoder, which consists of two sub-networks.
On top of the FoldingNet~\cite{yang2018foldingnet} decoder, referred to as \emph{Folding network} (F-Net) hereinafter, a novel \emph{Tearing network} (T-Net) is proposed to couple with the F-Net by a feedback loop.
Given a codeword $\vect{c}$, the TearingNet decoder runs the F-Net and the T-Net (``F'' and ``T'' in Figure~\ref{fig:gcae}) iteratively.
In a nutshell, the F-Net takes as input a certain topology (represented by ${\widehat{\vect{U}}}$) and ``embeds'' it to a 3D point cloud $\widehat{\vect{X}}$, then the T-Net considers $\widehat{\vect{X}}$ to ``correct'' the topology with a feedback connection.
\begin{figure}
\centering
\includegraphics[width=0.9\columnwidth]{figures/gcae.pdf}
\caption{\small Block diagram of the TearingNet/GCAE, featured by the interaction between the F-Net and the T-Net. ``E'', ``F'', ``T'' represent the E-Net, F-Net and T-Net, respectively.}
\label{fig:gcae}
\end{figure}
For an input 3D point cloud ${\vect{X}}=\{{\vect{x}}_i\}_{i=1}^{n}$ composed of $n$ points ${\vect{x}}_i = (x_i, y_i, z_i)$, the encoder first generates a vector ${\vect{c}}\in\ensuremath{\mathbb{R}}^d$.
As an auxiliary input, a 2D point set $\vect{U}=\{\vect{u}_i\}_{i=1}^m$ samples $m$ points ${\vect{u}}_i = (u_i, v_i)$ on a 2D region.
Similar to FoldingNet~\cite{yang2018foldingnet}, it contains regularly sampled 2D-grid locations in the square region $[-1,1]\times[-1,1]$ (the points in Figure~\ref{fig:demo}\red{b-i} and Figure~\ref{fig:demo}\red{b-iii}).
This point set $\vect{U}$ brings in a \emph{primitive} shape for reconstruction, which embodies a \emph{genus zero} topology.
For convenience, the 2D point set is also referred to as \emph{2D grid} in the sequel.
With the 2D grid $\widehat{\vect{U}}$ (or $\vect{U}$ at the first iteration), the Folding network maps each of its 2D point $\widehat{\vect{u}}_i$ to a 3D coordinate $\widehat{\vect{x}}_i$, aiming at reconstructing a 3D point cloud $\widehat{\vect{X}}$ following the topology of $\widehat{\vect{U}}$.
The Tearing network especially takes $\widehat{\vect{X}}$ and modifies each 2D point in $\widehat{\vect{U}}$ individually, leading to a new 2D grid representing an updated topology ({\it e.g.}, Figure~\ref{fig:demo}\red{b-ii} and Figure~\ref{fig:demo}\red{b-iv}).
Hence, the Folding network and the Tearing network interact with each other for high-quality reconstructions.
\subsection{Tearing as Breaking Graph Edges}\label{ssec:graph_tearing}
With the Tearing network that ``stretches'' the 2D grid, the overall TearingNet still admits a continuous mapping from the 2D space to 3D.
It appears to be \emph{conflict} with the notion of tearing, which implies introducing discontinuities.
We fill this gap by viewing tearing as collectively breaking graph edges that connect neighboring points on the 2D grid.
\textbf{2D grid as a local graph}:
The 2D grid $\vect{U}$ in our work (as well as FoldingNet~\cite{yang2018foldingnet} and AtlasNet~\cite{groueix2018papier}) essentially approximates a simple Riemannian manifold---a genus zero square patch, denoted as $\mathcal{M}$---with $m$ points regularly sampled on it.
From \cite{hein2007graph,ting2010analysis}, {\it etc.}, to represent/approximate a Riemannian manifold (in the continuous domain) with its sampled points (in the discrete domain) means to construct a \emph{local graph} connecting the nearby points.
In other words, the set $\vect{U}$ implies a primitive graph (denoted as $\mathcal{G}$) associated with the manifold $\mathcal{M}$.
This graph $\mathcal{G}$, according to \cite{hein2007graph}, have $m$ vertices, with each represents one point in $\vect{U}$.
For any two points $\vect{u}_i$ and $\vect{u}_j$ from $\vect{U}$, the graph weight between them is given by a truncated Gaussian kernel:
\begin{equation}\label{eq:graph}
w_{ij} = \left\{ {\begin{array}{*{20}{l}}
{\exp \left( { - \frac{\displaystyle{{{\left\| {{{\bf{u}}_i} - {{\bf{u}}_j}} \right\|}_2^2}}}{\displaystyle{2\epsilon{^2}}}} \right)} & {\mbox{if} ~~ {\left\| {{{\bf{u}}_i} - {{\bf{u}}_j}} \right\|}_2 \le r,}\\
0&{{\rm{otherwise,}}}
\end{array}} \right.
\end{equation}
where $\epsilon>0$ is a parameter controlling the sensitivity of the graph weight, and $r>0$ is a threshold.
Hence, the primitive graph $\mathcal{G}$ is an $r$-neighborhood graph, {\it i.e.}, there is no edge between two points with a distance greater than $r$.
\textbf{Graph tearing}:
Suppose the 2D grid $\mathbf{U}$ has $N^2$ points with a dimension $N\times N$.
According to \cite{hein2006uniform,hein2007graph}, as $r$ in Eq.~\eqref{eq:graph} becomes smaller and $N$ becomes larger ({\it i.e.}, 2D grid $\mathbf{U}$ sampling $\cal M$ gets denser), the graph $\mathcal{G}$ better approximates $\mathcal{M}$.
Given a certain dimension $N$, we also let $r$ be small, which takes a value just equal to or slightly larger than $2/N$---the horizontal/vertical spacing of neighboring points.\footnote{An even smaller $r$ results in the trivial case which no graph edges exist.}
Then from Eq.~\eqref{eq:graph}, each point $\vect{u}_i$ has four edges connecting to its neighbors---the top, left, bottom, and right points---on the 2D grid $\vect{U}$.
Hence, before feeding to the Tearing network, $\mathcal{G}$ defaults back to a simple \emph{2D grid graph}, {\it e.g.}, Figure\,\ref{fig:demo}\red{b-i}.
Running the Tearing network updates the 2D grid $\vect{U}$ as well as the graph.
Particularly, a 2D point ${\bf u}_i$ is moved to another location $\widehat{\vect{u}}_i$.
Thus, for any two neighboring points in the 2D grid that are pulled apart by the Tearing network, the graph edge between them is naturally \emph{broken}, resulting in an updated graph (denoted at $\widehat{\mathcal{G}}$).
In our proposal, the breakings of all the edges collectively achieve \emph{tearing in the graph domain} and update the underlying topology:
\begin{enumerate}[(i)]
\item When localized edges within the 2D grid are removed by the Tearing network, a gap/seam is introduced to the graph topology. This is to reconstruct a target point cloud with holes ({\it i.e.}, its genus number $g>0$), see Figure\,\ref{fig:demo}\red{c-ii}.
\item When all the edges connecting two groups of points in the 2D grid are removed by the Tearing network, the graph is \emph{torn} apart into disconnected sub-graphs. This benefits the reconstruction when the two groups correspond to two distinct objects. Hence, a point cloud with multiple objects ({\it i.e.}, its zeroth Betti number $b_0>1$) is reconstructed, see Figure\,\ref{fig:demo}\red{c-iv}.
\end{enumerate}
Note that in practice, both of these two cases may happen on the same point cloud.
\textbf{Torn graph as a free mesh}:
The torn graph $\widehat{\mathcal{G}}$---as a side output---naturally represents a mesh over the reconstructed point cloud.
In fact, each elementary square on the 2D grid corresponds to a quadrilateral face of the 3D mesh, where a face is pruned if it has any edges removed by the Tearing network.
Then the remaining faces together constitute a 3D mesh. See Figure~\ref{fig:mesh_a} for an example.
The torn graph also enables us to resample the input 3D point cloud by resampling 2D points in manifold $\mathcal{M}$ while avoiding the ``ghost'' 3D points between different objects or within object holes.
This is achieved by removing outliers sampled on the pruned faces (Figure~\ref{fig:mesh_b}).
In contrast, it is inevitable for the simple FoldingNet to introduce undesired points in the resampled point cloud (Figure~\ref{fig:mesh_c}).
\begin{figure}
\centering \scriptsize
\subfloat{\includegraphics[width=.25\columnwidth]{figures/mesh/torus_pc_mesh.png}}\hspace{10pt}
\subfloat{\includegraphics[width=.25\columnwidth]{figures/mesh/torus_tear_resamp.png}}\hspace{10pt}
\subfloat{\includegraphics[width=.25\columnwidth]{figures/mesh/torus_fold_resamp.png}}\\\vspace{-10pt}
\setcounter{subfigure}{0}
\subfloat[Induced mesh]{\includegraphics[width=.25\columnwidth]{figures/mesh/camo5_pc_mesh.png}\label{fig:mesh_a}}\hspace{10pt}
\subfloat[TearingNet]{\includegraphics[width=.25\columnwidth]{figures/mesh/camo5_tear_resamp.png}\label{fig:mesh_b}}\hspace{10pt}
\subfloat[FoldingNet]{\includegraphics[width=.25\columnwidth]{figures/mesh/camo5_fold_resamp.png}\label{fig:mesh_c}}
\vspace{3pt}
\caption{The torn graphs induce 3D meshes (a) and bring better resampled point clouds (b) than that of the FoldingNet (c). Each row in this figure is associated to an example in Figure~\ref{fig:demo}.}
\label{fig:mesh}
\end{figure}
\subsection{Graph-Conditioned AutoEncoder}
The insights of graph tearing motivate us to generalize the architecture of Figure\,\ref{fig:gcae} and call it a \emph{Graph-Conditioned AutoEncoder} (GCAE), which we believe useful for processing data where topology matters, {\it e.g.}, image, video, or any graph signals.
It promotes an explicit way to \emph{discover} and \emph{utilize} topology within an autoencoder.
Particularly, it is equipped with a graph $\widehat{\mathcal{G}}$ whose topology evolves by iterating F-Net and T-Net.
F-Net \emph{embeds} the graph to a reconstruction; while T-Net attempts to \emph{decodes} a graph (in a residual form) from a reconstruction, which may tear a graph into patches or with holes to achieve desired reconstructions.
\subsection{Unrolling the TearingNet}
As a concrete example, Figure~\ref{fig:overall} shows an \emph{unrolled} version of the TearingNet where a T-Net is wedged into two iterations of F-Net.
We adopt the PointNet architecture~\cite{qi2017pointnet} as our encoder due to its flexibility (as discussed in Section~\ref{sec:related}): it has the potential to generate topology-friendly representations given it is trained properly.
With the latent code $\vect{c}$ (a $512$-dimension vector in our work) and the initial point set $\vect{U}^{(0)}$ (the regular 2D grid) as inputs, the TearingNet decoder (in Figure~\ref{fig:overall}) runs F-Net, T-Net and F-Net sequentially.
Specifically, an input point $\vect{u}^{(0)}_i\in {\vect{U}}^{(0)}$ is mapped to a 3D point $\vect{x}^{(2)}_i$:
\begin{equation}\label{eq:tearing}
\begin{split}
&\vect{x}^{(1)}_i = F\left(\vect{u}^{(0)}_i; \vect{c}\right)\hspace{5pt}\\
\rightarrow\hspace{5pt}&\vect{u}^{(1)}_i = T\left(\vect{u}^{(0)}_i, \vect{x}^{(1)}_i;\vect{c}\right)+{\vect{u}^{(0)}_i}\hspace{5pt}\\
\rightarrow\hspace{5pt}&\vect{x}^{(2)}_i = F\left(\vect{u}^{(1)}_i;\vect{c}\right),
\end{split}
\end{equation}
where $F$ and $T$ denote the \emph{point-wise} networks of F-Net and the T-Net, respectively.
We see that, the F-Net first endeavors a trial folding to produce a preliminary 3D point cloud ${\vect{X}}^{(1)}$.
The T-Net takes ${\vect{X}}^{(1)}$ and generates the 2D point set ${\vect{U}}^{(1)}$.
It is then supplied to the second iteration of F-Net for an improved 3D point cloud ${\vect{X}}^{(2)}$.
With the updated 2D point set ${\vect{U}}^{(1)}$ and the second Folding network output ${\vect{X}}^{(2)}$, one may optionally append a \emph{graph filtering} module at the end to further enhance the reconstruction.
Note that all reconstructions ${\vect{X}}^{(\cdot)}$ contain $m$ points, the same as that of the 2D pointsets ${\vect{U}}^{(\cdot)}$.
By iterating the F-Net twice (as Figure~\ref{fig:overall}), the TearingNet achieves a good tradeoff between computation and reconstruction quality.
Hence, we focus on this configuration for experimentation.
\subsection{The Tearing Network}
As a core ingredient, the Tearing network (or T-Net) is introduced to explicitly learn the topology by tearing the primitive graph, which boosts the reconstruction accuracy, and ultimately enhances the representability of the codeword.
In our design, the Tearing network learns point-wise modifications to the 2D point set ${\vect{U}}^{(0)}$ and computes ${\vect{U}}^{(1)}$ with a residual connection~\cite{he2016deep}, see Figure~\ref{fig:overall}.
The 2D points are then moved around like flocks depending on the topology chart they belong to.
Similar to PointNet~\cite{qi2017pointnet} and the Folding network~\cite{yang2018foldingnet}, the Tearing network consists of shared point-wise MLP layers.
Its architecture, as well as its model scale, are similar to that of the Folding network.
Given the 2D coordinate $\vect{u}_i^{(0)}\in\mathbb{R}^2$, it is first concatenated with the associated 3D coordinate $ \vect{x}_i^{(1)}\in\mathbb{R}^3$ as well as the codeword $\vect{c}\in\mathbb{R}^{512}$, to form a $517$-dimensional vector.
This vector is then fed to the point-wise network $T$ with two stages of MLP layers, and produces a translation vector on the 2D plane.
The detailed architecture of the Tearing network is provided in the supplementary material.
To demonstrate the effectiveness of the Tearing network, we train the whole TearingNet to over-fit the \emph{Torus} dataset introduced in \cite{chen2019deep} which contains 300 torus-shape point clouds with genus number ranging from 1 to 3.
Figure~\ref{fig:demo}\red{c-i} and Figure~\ref{fig:demo}\red{c-ii} show a genus-3 torus before and after the T-Net respectively, where we see that the 2D grid is ``torn'' with holes to accommodate the topology of the input torus.
\subsection{Graph Filtering for Enhancement}
Equipped with the torn graph, we propose an optional graph filter appended at the end of the TearingNet (see Figure~\ref{fig:overall}) to improve the reconstruction point cloud~\cite{chen2019deep}.
We first compute the unnormalized graph Laplacian matrix ${\bf L}\in\mathbb{R}^{m\times m}$ of the graph $\widehat{\cal G}$.
Then we run the following graph filter~\cite{shuman2013emerging} to obtain the final output $\vect{X}^{(3)}$:
\begin{equation}\label{eq:graph_filter}
\vect{X}^{(3)} = (\vect{I} - \lambda {\bf L})\cdot\vect{X}^{(2)}
\end{equation}
where the point clouds $\vect{X}^{(\cdot)}$ are viewed as $m\times3$ matrices and the filtering parameter $\lambda=0.5$.
For better filtering, we incorporate the second folding output $\vect{X}^{(2)}$ when computing the edge weights---we let $\vect{p}_i=\left[{\vect{u}^{(1)}_i}^{\rm T}\hspace{5pt}{\vect{x}^{(2)}_i}^{\rm T}\right]^{\rm T}$, and compute ${{\left\| {{{\bf{p}}_i} - {{\bf{p}}_j}} \right\|}_2^2}$ instead of ${{\left\| {{{\bf{u}}_i} - {{\bf{u}}_j}} \right\|}_2^2}$ in Eq.~\eqref{eq:graph}.
Additionally, rather than thresholding with distance $r$, we equivalently remove an edge if its weight is too smaller ({\it i.e.}, less than $10^{-12}$).
We see that our graph filter is a lightweight and differentiable signal processing module for enhancement with little overhead.
Thus, it is included in the end-to-end training of the unrolled TearingNet.
\subsection{Training of the TearingNet}
Instead of training the entire TearingNet directly, we first pre-train the Encoder network (E-Net) and the Folding network (F-Net).
They are trained together under the FoldingNet~\cite{yang2018foldingnet} autoencoder architecture without the Tearing network.
After that, we load the pre-trained E-Net and F-Net then train the overall TearingNet autoencoder as shown in Figure~\ref{fig:overall}.
This step specifically lets the Tearing network learn to tear the 2D grid/primitive graph and update the topology.
In this step, a smaller learning rate is adopted.
Details of the training strategy are provided in the supplementary material.
Similar to \cite{chen20203d,yang2018foldingnet}, we train the overall TearingNet (and other methods) with the \emph{augmented Chamfer distance}.
Given an original and a reconstructed point clouds being $\vect{X}$ and $\widehat{\vect{X}}$, respectively, the augmented Chamfer distance is written as:
\vspace{-5pt}
\begin{equation}\label{eq:chamfer}
\vspace{-3pt}
d_{\vect{X}, \widehat{\vect{X}}}\hspace{-1pt}=\hspace{-1pt}\max\hspace{-1pt}\left \{\hspace{-1pt}\frac{1}{n}\hspace{-3pt}\sum_{\vect{x} \in \vect{X}}\hspace{-2pt}\min_{ \widehat{\vect{x}} \in \widehat{\vect{X}}} \left\| \vect{x}\hspace{-1pt} -\hspace{-1pt} \widehat{\vect{x}} \right\|_2\hspace{-1pt},\hspace{-1pt}\frac{1}{m}\hspace{-3pt}\sum_{ \widehat{\vect{x}} \in \widehat{\vect{X}}} \hspace{-2pt}\min_{\vect{x} \in \vect{X}} \left\| \vect{x}\hspace{-1pt} -\hspace{-1pt} \widehat{\vect{x}} \right\|_2\hspace{-1pt}\right \}.
\end{equation}
Eq.~\eqref{eq:chamfer} essentially gives the Hausdorff distance between two point clouds \cite{bouaziz2016modern}.
As analyzed in \cite{chen20203d}, it is more robust to ill cases compared to the original Chamfer distance \cite{fan2017point}.
\subsection{Experimental Setup}
\textbf{Datasets}:
We verify our work with both single- and multi-object point cloud datasets, with a focus on the latter ones.
Particularly, we adopt ShapeNet~\cite{chang2015shapenet} and Torus~\cite{chen2019deep} datasets to experiment with the single-object scenarios; while we collect objects from off-the-shelf point cloud datasets to synthesize multi-object point cloud datasets.
To assemble a point cloud with $k$ objects, a $K\times K$ square-shaped ``playground'' with $K^2$ grids is defined to host objects.
Then randomly picked $k \le K^2$ objects are normalized and randomly placed on the grids of the playground.
We first generate multi-object datasets with objects from KITTI 3D Object Detection~\cite{geiger2012we}.
In total, $10165$ objects from KITTI with labels \texttt{Pedestrian}, \texttt{Cyclist}, \texttt{Car}, \texttt{Van} and \texttt{Truck} are ``cropped'' using annotated bounding boxes.
Four datasets are created with playground dimensions $K\in\{3,4,5,6\}$, and the resulting KITTI multi-object datasets are called KIMO-$K$ respectively.
Each KIMO-$K$ dataset is composed of $K\times 10000$ and $K\times 2000$ point clouds for training and testing, where each point cloud has up to $K^2$ objects.
All generated point clouds have $2048$ points, and each object in a point cloud occupies roughly the same number of points.
The KIMO-$K$ datasets are challenging, since they are composed of real LiDAR scans that are sparse and incomplete ({\it e.g.}, ground-truths of the ``K'' rows in Table~\ref{tab:visual}).
For better visualization, we similarly generate datasets that we call CAD model multi-object (CAMO) which are composed of point clouds sampled from CAD models in ModelNet40~\cite{wu20153d} and ShapeNet~\cite{chang2015shapenet}.
More details are discussed in the supplementary material.
\textbf{Implementation details}:
The 2D grid $\vect{U}$ is defined to be $45\times 45$, and the codeword $\vect{c}$ to be $512$-dimension.
Adam optimizer~\cite{kingma2014adam} is applied for training with a batch size $32$.
The constant $\epsilon$ in \eqref{eq:graph} is set to be 0.02.
We pre-train E-Net and F-Net for $640$ epochs with a learning rate of $2\times 10^{-4}$, then train TearingNet end-to-end for another $480$ epochs with a smaller learning rate $10^{-6}$.
Isolated points with no edges are removed from the reconstructions.
Our experiments are implemented with the PyTorch framework \cite{paszke2017automatic}.
\textbf{Benchmarks}:
We compare the TearingNet with several methods: (i)~LatentGAN~\cite{achlioptas2018learning} composed of the fully-connected layers, which exploits a much larger model than ours; (ii)~AtlasNet~\cite{groueix2018papier} with $3$ patches which has the same model size as ours; (iii)~FoldingNet~\cite{yang2018foldingnet}, and its extension, (iv) Cascaded F-Net, with two FoldingNets cascaded as $F_2(F_1(\vect{u};\vect{c}); \vect{c})$.
Its model size is similar to ours.
Note that besides (i), the other methods all reconstruct point clouds via deforming 2D primitive(s).
We also consider several variants of the TearingNet for shape reconstruction: i)~TearingNet$_\textrm{TF}$: instead of having a trial folding first, this configuration runs a T-Net directly for topology update without considering $\vect{X}^{(1)}$; ii)~TearingNet$_{\overline{\textrm{GF}}}$ which excludes the graph filtering at the end; iii)~TearingNet$_{3}$ which augments the TearingNet by iterating three times, {\it i.e.}, as $F\hspace{-3pt}\rightarrow\hspace{-3pt}T\hspace{-3pt}\rightarrow\hspace{-3pt}F\hspace{-3pt}\rightarrow\hspace{-3pt}T\hspace{-3pt}\rightarrow\hspace{-3pt}F$.
It is trained via loading the weights from a pre-trained TearingNet followed by a finetuning.
\def0.35{0.35}
\def0.13{0.13}
\def0.17{0.17}
\def0.5{0.5}
\def1pt{1pt}
\begin{table*}[htbp]
\centering\scriptsize
\caption{\small Visual comparisons of point cloud reconstructions. Points are colored according to their indices. S:~ShapeNet; T:~Torus; C:~CAMO-5; K:~KIMO-5. Objects in the red boxes are zoomed in and shown in the blue boxes.}
\begin{tabular}{c||c|c|c|c|c}
\hline
& Ground-truth & AtlasNet & FoldingNet & TearingNet & Torn Grid \\
\hline
\hline
S &
\begin{minipage}[c]{0.35\columnwidth}\center
\vspace{1pt}\includegraphics[width=0.5\columnwidth]{figures/results/sn55_pc_gt.png}\hspace{3pt}\includegraphics[width=0.3\columnwidth]{figures/results/sn55_pc_gt_zoom.png}\vspace{1pt}
\end{minipage}
&
\begin{minipage}[c]{0.35\columnwidth}\center
\vspace{1pt}\includegraphics[width=0.5\columnwidth]{figures/results/sn55_pc_atlasnet.png}\hspace{3pt}\includegraphics[width=0.3\columnwidth]{figures/results/sn55_pc_atlasnet_zoom.png}\vspace{1pt}
\end{minipage}
&
\begin{minipage}[c]{0.35\columnwidth}\center
\vspace{1pt}\includegraphics[width=0.5\columnwidth]{figures/results/sn55_pc_foldingnet.png}\hspace{3pt}\includegraphics[width=0.3\columnwidth]{figures/results/sn55_pc_foldingnet_zoom.png}\vspace{1pt}
\end{minipage}
&
\begin{minipage}[c]{0.35\columnwidth}\center
\vspace{1pt}\includegraphics[width=0.5\columnwidth]{figures/results/sn55_pc_tearingnet.png}\hspace{3pt}\includegraphics[width=0.3\columnwidth]{figures/results/sn55_pc_tearingnet_zoom.png}\vspace{1pt}
\end{minipage}
&
\begin{minipage}[c]{0.13\columnwidth}\center
\vspace{1pt}\includegraphics[width=1\columnwidth]{figures/results/sn55_grid.png}
\end{minipage}
\\
\hline
T &
\begin{minipage}[c]{0.35\columnwidth}\center
\vspace{1pt}\includegraphics[width=0.5\columnwidth]{figures/results/torus_pc_gt.png}\includegraphics[width=0.3\columnwidth]{figures/results/torus_pc_gt_zoom.png}\vspace{1pt}
\end{minipage}
&
\begin{minipage}[c]{0.35\columnwidth}\center
\vspace{1pt}\includegraphics[width=0.5\columnwidth]{figures/results/torus_pc_atlasnet.png}\includegraphics[width=0.3\columnwidth]{figures/results/torus_pc_atlasnet_zoom.png}\vspace{1pt}
\end{minipage}
&
\begin{minipage}[c]{0.35\columnwidth}\center
\vspace{1pt}\includegraphics[width=0.5\columnwidth]{figures/results/torus_pc_foldingnet.png}\includegraphics[width=0.3\columnwidth]{figures/results/torus_pc_foldingnet_zoom.png}\vspace{1pt}
\end{minipage}
&
\begin{minipage}[c]{0.35\columnwidth}\center
\vspace{1pt}\includegraphics[width=0.5\columnwidth]{figures/results/torus_pc_tearingnet.png}\includegraphics[width=0.3\columnwidth]{figures/results/torus_pc_tearingnet_zoom.png}\vspace{1pt}
\end{minipage}
&
\begin{minipage}[c]{0.13\columnwidth}\center
\vspace{1pt}\includegraphics[width=1\columnwidth]{figures/results/torus_grid.png}
\end{minipage}
\\
\hline
\multirow{6}[2]{*}{C} &
\begin{minipage}[c]{0.35\columnwidth}\center
\vspace{1pt}\includegraphics[width=1\columnwidth]{figures/results/camo5_pc_gt.png}\vspace{1pt}
\end{minipage}
&
\begin{minipage}[c]{0.35\columnwidth}\center
\vspace{1pt}\includegraphics[width=1\columnwidth]{figures/results/camo5_pc_atlasnet.png}\vspace{1pt}
\end{minipage}
&
\begin{minipage}[c]{0.35\columnwidth}\center
\vspace{1pt}\includegraphics[width=1\columnwidth]{figures/results/camo5_pc_foldingnet.png}\vspace{1pt}
\end{minipage}
&
\begin{minipage}[c]{0.35\columnwidth}\center
\vspace{1pt}\includegraphics[width=1\columnwidth]{figures/results/camo5_pc_tearingnet.png}\vspace{1pt}
\end{minipage}
& \multirow{2}[2]{*}{
\begin{minipage}[c]{0.13\columnwidth}\center
\vspace{7pt}\vspace{1pt}\includegraphics[width=1\columnwidth]{figures/results/camo5_grid.png}
\end{minipage}
} \\ &
\begin{minipage}[c]{0.17\columnwidth}\center
\vspace{1pt}\includegraphics[width=1\columnwidth]{figures/results/camo5_pc_gt_zoom.png}\vspace{1pt}
\end{minipage}
&
\begin{minipage}[c]{0.17\columnwidth}\center
\vspace{1pt}\includegraphics[width=1\columnwidth]{figures/results/camo5_pc_atlasnet_zoom.png}\vspace{1pt}
\end{minipage}
&
\begin{minipage}[c]{0.17\columnwidth}\center
\vspace{1pt}\includegraphics[width=1\columnwidth]{figures/results/camo5_pc_foldingnet_zoom.png}\vspace{1pt}
\end{minipage}
&
\begin{minipage}[c]{0.17\columnwidth}\center
\vspace{1pt}\includegraphics[width=1\columnwidth]{figures/results/camo5_pc_tearingnet_zoom.png}\vspace{1pt}
\end{minipage}
& \\
\hline
\multirow{13}[4]{*}{K} &
\begin{minipage}[c]{0.35\columnwidth}\center
\vspace{1pt}\includegraphics[width=1\columnwidth]{figures/results/kimo5_1_pc_gt.png}\vspace{1pt}
\end{minipage}
&
\begin{minipage}[c]{0.35\columnwidth}\center
\vspace{1pt}\includegraphics[width=1\columnwidth]{figures/results/kimo5_1_pc_atlasnet.png}\vspace{1pt}
\end{minipage}
&
\begin{minipage}[c]{0.35\columnwidth}\center
\vspace{1pt}\includegraphics[width=1\columnwidth]{figures/results/kimo5_1_pc_foldingnet.png}\vspace{1pt}
\end{minipage}
&
\begin{minipage}[c]{0.35\columnwidth}\center
\vspace{1pt}\includegraphics[width=1\columnwidth]{figures/results/kimo5_1_pc_tearingnet.png}\vspace{1pt}
\end{minipage}
& \multirow{2}[2]{*}{
\begin{minipage}[c]{0.13\columnwidth}\center
\vspace{2pt}\vspace{1pt}\includegraphics[width=1\columnwidth]{figures/results/kimo5_1_grid.png}
\end{minipage}
} \\ &
\begin{minipage}[c]{0.17\columnwidth}\center
\vspace{1pt}\includegraphics[width=1\columnwidth]{figures/results/kimo5_1_pc_gt_zoom.png}\vspace{1pt}
\end{minipage}
&
\begin{minipage}[c]{0.17\columnwidth}\center
\vspace{1pt}\includegraphics[width=1\columnwidth]{figures/results/kimo5_1_pc_atlasnet_zoom.png}\vspace{1pt}
\end{minipage}
&
\begin{minipage}[c]{0.17\columnwidth}\center
\vspace{1pt}\includegraphics[width=1\columnwidth]{figures/results/kimo5_1_pc_foldingnet_zoom.png}\vspace{1pt}
\end{minipage}
&
\begin{minipage}[c]{0.17\columnwidth}\center
\vspace{1pt}\includegraphics[width=1\columnwidth]{figures/results/kimo5_1_pc_tearingnet_zoom.png}\vspace{1pt}
\end{minipage}
& \\
\cline{2-6} &
\begin{minipage}[c]{0.35\columnwidth}\center
\vspace{1pt}\includegraphics[width=1\columnwidth]{figures/results/kimo5_2_pc_gt.png}\vspace{1pt}
\end{minipage}
&
\begin{minipage}[c]{0.35\columnwidth}\center
\vspace{1pt}\includegraphics[width=1\columnwidth]{figures/results/kimo5_2_pc_atlasnet.png}\vspace{1pt}
\end{minipage}
&
\begin{minipage}[c]{0.35\columnwidth}\center
\vspace{1pt}\includegraphics[width=1\columnwidth]{figures/results/kimo5_2_pc_foldingnet.png}\vspace{1pt}
\end{minipage}
&
\begin{minipage}[c]{0.35\columnwidth}\center
\vspace{1pt}\includegraphics[width=1\columnwidth]{figures/results/kimo5_2_pc_tearingnet.png}\vspace{1pt}
\end{minipage}
& \multirow{2}[2]{*}{
\begin{minipage}[c]{0.13\columnwidth}\center
\vspace{1pt}\includegraphics[width=1\columnwidth]{figures/results/kimo5_2_grid.png}
\end{minipage}
} \\ &
\begin{minipage}[c]{0.17\columnwidth}\center
\vspace{1pt}\includegraphics[width=1\columnwidth]{figures/results/kimo5_2_pc_gt_zoom.png}\vspace{1pt}
\end{minipage}
&
\begin{minipage}[c]{0.17\columnwidth}\center
\vspace{1pt}\includegraphics[width=1\columnwidth]{figures/results/kimo5_2_pc_atlasnet_zoom.png}\vspace{1pt}
\end{minipage}
&
\begin{minipage}[c]{0.17\columnwidth}\center
\vspace{1pt}\includegraphics[width=1\columnwidth]{figures/results/kimo5_2_pc_foldingnet_zoom.png}\vspace{1pt}
\end{minipage}
&
\begin{minipage}[c]{0.17\columnwidth}\center
\vspace{1pt}\includegraphics[width=1\columnwidth]{figures/results/kimo5_2_pc_tearingnet_zoom.png}\vspace{1pt}
\end{minipage}
& \\
\hline
\end{tabular}%
\label{tab:visual}%
\end{table*}%
\begin{table*}[htbp]
\centering\scriptsize
\caption{\small Evaluation of 3D point cloud reconstruction, in terms of both CD and EMD.}
\begin{tabular}{c||cc|cccc||cc|cccc}
\hline
Metrics & \multicolumn{6}{c||}{CD ($\times 10^{-2}$)} & \multicolumn{6}{c}{EMD}\\
\hline
Datasets & ShapeNet & Torus & KI.-3 & KI.-4 & KI.-5 & KI.-6 & ShapeNet & Torus & KI.-3 & KI.-4 & KI.-5 & KI.-6 \\
\hline
\hline
LatentGAN & 2.85 & 2.45 & 7.10 & 11.64 & 17.18 & 19.21 & 0.218 & 0.202 & 1.982 & 3.231 & 3.773 & 4.721 \\
AtlasNet & 2.72 & 2.41 & \textbf{4.50} & 6.76 & 9.59 & 11.63 & \textbf{0.163} & \textbf{0.146} & 1.333 & 2.811 & 3.173 & 4.440 \\
FoldingNet & 2.75 & 1.90 & \textbf{4.72} & 6.57 & 9.01 & 11.06 & 0.372 & 0.191 & 1.748 & 2.864 & 3.056 & 4.569 \\
Cascaded F-Net & 2.69 & 1.95 & 4.77 & 6.67 & 9.13 & 10.94 & 0.207 & 0.196 & 1.533 & 2.381 & 2.944 & 4.189 \\
\hline
TearingNet$_{\textrm{TF}}$ & 2.59 & 1.84 & 5.05 & 6.58 & 8.55 & 10.86 & 0.206 & 0.163 & 1.055 & 1.787 & 2.565 & 3.476 \\
TearingNet$_{\overline{\textrm{GF}}}$ & 2.56 & 1.74 & 4.92 & 6.45 & 8.29 & 10.29 & 0.172 & 0.170 & 0.958 & 1.441 & 1.879 & 2.648 \\
TearingNet (Ours) & \textbf{2.54} & \textbf{1.72} & 4.78 & \textbf{6.43} & \textbf{8.29} & \textbf{10.23} & 0.174 & 0.156 & \textbf{0.940} & \textbf{1.438} & \textbf{1.872} & \textbf{2.614} \\
TearingNet$_{\text{3}}$ (Ours) & \textbf{2.53} & \textbf{1.73} & 4.74 & \textbf{6.42} & \textbf{8.24} & \textbf{10.15} & \textbf{0.169} & \textbf{0.143} & \textbf{0.941} & \textbf{1.361} & \textbf{1.867} & \textbf{2.315} \\
\hline
\end{tabular}%
\label{tab:rec_kimo}%
\vspace{-10pt}
\end{table*}%
\subsection{Performance Comparison}\label{ssec:comp}
\textbf{Reconstruction}: We first evaluate the reconstruction quality of the proposed TearingNet.
Table~\ref{tab:visual} visualizes some reconstructed point clouds from several datasets.
Compared to the TearingNet, FoldingNet leaves more ``ghost'' points outside object surfaces, while AtlasNet results in unbalanced point distributions.
In contrast, TearingNet produces point clouds that look \emph{clean} and \emph{orderly}, with appearances close to the inputs.
The 2D-grids (last column of Table~\ref{tab:visual}) are torn apart to accommodate the corresponding 3D topologies.
It demonstrates how object topologies are \emph{discovered} and \emph{utilized} via the TearingNet architecture.
We report the augmented Chamfer Distance (referred to as CD) and the Earth Mover's Distance (EMD) \cite{fan2017point} of the competing methods in Table~\ref{tab:rec_kimo}.
For both metrics, a smaller number indicates more accurate reconstruction.
In general, our TearingNet and TearingNet$_3$ outperform the benchmarks, which is even more obvious in terms of EMD.
As the topology complexity grows from KIMO-3 to KIMO-6, our method outperforms the competitors more significantly.
By comparing our TearingNet to TearingNet$_{\textrm{TF}}$, we see the effectiveness of inserting a Folding network before the Tearing network.
That is because, with the first trial folding result, the Tearing network can better capture the discrepancy between a genus zero topology and the ground-truth topology via back-propagation.
From Table~\ref{tab:rec_kimo}, we also see that, begin with the TearingNet$_{\overline{\textrm{GF}}}$, by first incorporating the graph filter (TearingNet), then further iterating the T-Net and the F-Net (TearingNet$_3$), reconstruction qualities continues to improve.
We observe similar results on the CAMO datasets.
We also experimented with recent methods AtlasNetV2~\cite{deprelle2019learning} and 3D Point Capsule Network~\cite{zhao20193d} and observe good performance on single-object datasets.
On ShapeNet, AtlasNetV2 has even achieved a lowest CD of $2.48\times 10^{-2}$.
However, both methods fail to converge on our multi-object datasets.
We conjecture that is because both of them are over-optimized for single-object cases, {\it e.g.}, AtlasNetV2 specifically learns the elementary structure of objects.
Hence, the diversified scene configurations in our multi-object datasets ``confuse'' these two methods.
{\bf Object counting}:
In a multi-object scene, adding objects yields a more complex topology.
From the multi-object examples in Table~\ref{tab:visual}, we see that the number of torn patches in a 2D-grid approximately equals the number of objects in a scene.
It implies that the latent codewords from TearingNet are \emph{aware of the geometric topology}.
To further affirm their representativeness of topologies, we next try to ``count'' the object number directly from the codewords.
In practice, counting is a critical task in applications such as traffic jam detection and crowd analysis \cite{lempitsky2010learning,onoro2016towards}.
In this task, the TearingNet and other benchmarks trained from the reconstruction experiment are carried over.
We again use the challenging KIMO datasets to experiment with this use case.
As a preparation, we feed the test dataset to the PointNet encoder to collect codewords.
Next, we employ 4-fold cross-validation to train/test an SVM classifier: codewords are equally divided into 4 folds, then \emph{only one} of the four is used to train the SVM together with their count labels while the other three are reserved for counting test.
SVM is selected for the test as it would not modify the feature space learned by autoencoders.
Consequently, this setting overall requires a small number of labels, because our feature (codeword) learning is achieved in an \emph{unsupervised} manner, while the counting task is learned in a \emph{weakly supervised} manner.
The counting performance is measured by mean absolute error (MAE) between the predicted counting and the ground-truth counting~\cite{zhang2015cross}.
As shown in the upper-half of Table~\ref{tab:cnt_det}, TearingNet and TearingNet$_3$ consistently produce the smallest MAEs.
For example, on KIMO-4, TearingNet brings down MAE by more than 40\% comparing to FoldingNet/AtlasNet, showing its strong capability in representing scene topologies.
We further inspect the feature space learned by the TearingNet to understand how it is linked to the topology.
We first collect the TearingNet codewords of the KIMO-3 dataset and visualize them using t-SNE, as shown in Figure~\ref{fig:tsne_cluster}.
Here the points are colored based on their corresponding counting labels.
Note that for the $3\times 3$ playground in KIMO-3, there are 9 and 36 combinations when placing 1 and 2 objects, respectively.
Correspondingly, 9 and 36 clusters could be observed in the t-SNE figure.
And as there is only 1 possible combination to arrange 9 objects, all points representing 9 objects aggregate to a single cluster.
\begin{table}[t]
\centering\scriptsize
\caption{\small Evaluation of object counting and object detection.}
\begin{tabular}{ c||c|cccc}
\hline
\multirow{2}[3]{*}{Tasks} & \multirow{2}[3]{*}{Methods} & \multicolumn{4}{c}{Datasets} \\
\cline{3-6} & & KI.-3 & KI.-4 & KI.-5 & KI.-6 \\
\hline
\hline
\multicolumn{1}{c||}{\multirow{8}[3]{*}{
\begin{minipage}[t]{0.17\columnwidth}
\hspace{9pt}Counting\\
(MAE,\,$\times 10^{-1}$)
\end{minipage}
}} & LatentGAN & 0.671 & 8.439 & 14.079 & 14.523 \\
& AtlasNet & 0.125 & 2.908 & 6.727 & 8.569 \\
& FoldingNet & 0.204 & 3.031 & 6.340 & 8.527 \\
& Cascaded F-Net & 0.270 & 3.207 & 7.104 & 9.792 \\
\cline{2-6} & TearingNet$_{\textrm{TF}}$ & 0.127 & 2.207 & 5.716 & 8.346 \bigstrut[t]\\
& TearingNet$_{\overline{\textrm{GF}}}$ & 0.123 & 1.805 & 5.105 & 8.044 \\
& \hspace{-2pt}TearingNet\,(Ours)\hspace{-2pt} & \textbf{0.123} & \textbf{1.721} & \textbf{5.079} & \textbf{8.026} \\
& \hspace{-5pt}TearingNet$_3$\,(Ours)\hspace{-5pt} & \textbf{0.121} & \textbf{1.740} & \textbf{5.050} & \textbf{7.992} \\
\hline
\hline
\multicolumn{1}{c||}{\multirow{8}[3]{*}{
\begin{minipage}[t]{0.17\columnwidth}
\hspace{5pt}Detection\\
(Accuracy, \%)
\end{minipage}
}} & LatentGAN & \textbf{93.53} & 63.78 & 65.65 & 78.80 \\
& AtlasNet & 88.84 & 73.79 & 73.58 & 83.53 \\
& FoldingNet & 92.71 & 80.12 & 77.10 & 82.92 \\
& Cascaded F-Net & 89.78 & 76.36 & 76.84 & 82.63 \\
\cline{2-6} & TearingNet$_{\textrm{TF}}$ & 93.33 & 82.83 & 78.43 & 83.74 \bigstrut[t]\\
& TearingNet$_{\overline{\textrm{GF}}}$ & 93.44 & 83.42 & 79.70 & 84.55 \\
& \hspace{-2pt}TearingNet\,(Ours)\hspace{-2pt} & 93.42 & \textbf{83.42} & \textbf{79.74} & \textbf{84.55} \\
& \hspace{-5pt}TearingNet$_3$\,(Ours)\hspace{-5pt} & \textbf{93.46} & \textbf{83.44} & \textbf{79.72} & \textbf{86.52} \\
\hline
\end{tabular}%
\label{tab:cnt_det}%
\vspace{-14pt}
\end{table}%
Finally, the appearance of the t-SNE diagram exhibits a \emph{tree} structure.
When inspecting one cluster of a larger counting ({\it e.g.}, 9, 8, {\it etc.}), it is always surrounded by several smaller counting clusters ({\it e.g.}, 8, 7, {\it etc.}).
This observation is actually due to a recursive encapsulation from counting 1 to 9 where counting 9 stays at the center.
If we compute an average Euclidean distance $d_k$ from all codewords of counting $k$ to the mean codeword of counting 9, we observe that $d_k$ approximately linearly increases as object counting $k$ decreases (see Figure~\ref{fig:tsne_distance}, where the distances are normalized to $[0,1]$, the error bars are also shown).
It implies that the codewords distribute in a layered manner with respect to counting ({\it i.e.}, topology) and they are \emph{topology-aware}.
\begin{figure}[t]
\centering\scriptsize
\subfloat[t-SNE visualization]{
\includegraphics[width=.35\columnwidth]{figures/tsne/tsne.pdf}\hspace{3pt}
\includegraphics[width=.1\columnwidth]{figures/tsne/label.pdf}\label{fig:tsne_cluster}}\hspace{12pt}
\subfloat[$d_k$ vs. object count $k$]{\includegraphics[width=.35\columnwidth]{figures/tsne/dist.pdf}\label{fig:tsne_distance}}
\caption{\small Analyzing the feature space of the TearingNet.}
\label{fig:tsne}
\vspace{-10pt}
\end{figure}
{\bf Object detection}:
Having revealed the superiority of our proposal in point reconstruction and topology understanding, we finally devised a last experiment to demonstrate such superiority in low/mid-level tasks can be transferred to high-level understanding tasks.
Specially, we consider the pedestrian detection task which is critical under an autonomous driving scenario~\cite{dollar2009pedestrian}.
Similar to object counting, we train binary SVM classifiers and evaluate their performance using a $4$-fold cross-validation strategy.
Again, one fold is applied for training and the rest for testing.
Detection accuracy is collected in the bottom-half of Table~\ref{tab:cnt_det}.
Note that KIMO-3 is the easiest dataset as it contains the least combination possibilities, and thus the simple LatentGAN already provides good accuracy.
Compared to the other benchmarks, both TearingNet and TearingNet$_3$ perform comparable on KIMO-3 and significantly better on KIMO-4, -5, and -6.
Moreover, for KIMO-4, TearingNet surpasses AtlasNet and FoldingNet by about 10\% and 3\%, respectively.
| {'timestamp': '2021-09-07T02:12:08', 'yymm': '2006', 'arxiv_id': '2006.10187', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10187'} | arxiv |
\section{Discussion}
\paragraph{Related work.}
\citet{pmlr-v118-fjelde20a} develop a software package (Bijector.jl) for bijective transformation of variables, that works independent of the computational framework. As a demonstration, they use normalizing flows to relax the mean-field assumption; they add coupling layers on top of a learnable diagonal Gaussian. However, the aim of our work is different--we examine the efficacy of normalizing flows and their combinations with recent inference ideas, for automating black-box VI.
\paragraph{General comments.} We choose ELBO/IW-ELBO to compare different VI methods. Several works have reported an empirical correlation between the ELBO improvements with improvements in test-likelihoods (see \citep[Appendix, Table 3, 4, and 5]{maddison2017filtering}; \citep[Figure 4]{Chen_Tao_Zhang_Henao_Duke_2018}; \citep[Figure 4]{Mishkin_Kunstner_Nielsen_Schmidt_Khan_2018}.) and accuracy of posterior moments (see \citep[Figure 6]{domke2018importance}; \citep[Figure 7, and Figure 9 to 22]{Domke2019DivideAC}).) We expect our methods to follow similar correlations for ELBO improvements.
In our initial experiments, the performance correlated well with the number of flow layers and the number of hidden units; however, we do not aim to find the best possible flow. We use a reasonably generic real-NVP flow that allows for efficient forward and inverse; efficient inverse affords for the use of STL/DReG gradient. The use of better flow variants and optimal architectures can hopefully improve on our work.
\paragraph{Computations costs.} Trade-offs exist between the improvement in performance and the computational costs we are prepared to entertain. With more computing resources, better performance is possible.
A comprehensive step-search scheme can be done in parallel. Adding Laplace Initialization requires one to solve a maximization problem beforehand. Adding Importance Weighting training, with a fixed ``Oracle budget'' for querying $\log p$, may seem to be relatively inexpensive; however, the posterior inference scales linearly in $M$.
Normalizing flows require more memory and computation. The parameters for full rank Gaussian scale quadratically in the number of dimensions and scale linearly for coupling-based models we consider; flows involve large constants and are expectedly slower for lower-dimensional models. Further, using the DReG or STL calculation comes at an additional cost for normalizing flows due to a second pass of $T_{\phi}^{-1}$ (see \Cref{sec:nf} for details.)
\paragraph{Conclusions.} This paper provides clear empirical evidence that systematically combining recent advances can achieve a robust inference scheme. Using step-search instead of ADVI's heuristic step selection and using normalizing flows instead of full-rank Gaussian is immensely helpful; the STL/DReG gradient consistently outperforms other available options; using Importance Weighted sampling is an almost always beneficial post-hoc step. Under the fixed sample budget, we did not find Importance Weighted training and Laplace's initialization to be consistently helpful. We hope that lessons from our work can help both researchers and practitioners.
\section*{Broader Impact}
Mechanistic modeling of natural phenomenons is a fundamental quest for modern scientists, and probabilistic models are a potent tool in such expeditions. However, automatically inferring hidden variables in these models is a challenge to date. Our approach and observations can prove instrumental for researchers in various fields--epidemiologists, ecologists, political scientists, social scientists, experimental psychologists, and others. While some other inference methods may perform better for a particular model, our ideas provide a formidable baseline.
Our framework combines several ideas--for a practitioner, this can make diagnosing the source of sub-optimality tricky. While it is possible to conduct comprehensive searches for hyper-parameters, the ability to do so hinges on access to adequate computation resources.
\begin{ack}
This material is based upon work supported by the National Science Foundation under Grant No. 1908577.
\end{ack}
\section{Full Method Description}
\label{sec:full_method_description}
\subsection*{ADVI Baseline}
\begin{wrapfigure}{r}{.5\textwidth}
\centering
\vspace{-10mm}
\begin{small}
\begin{center}
\centerline{\includegraphics[height=\linewidth]{figure/Advances_in_BBVI_modified.png}}
\end{center}
\end{small}
\vspace{-22mm}
\end{wrapfigure}
Uses a full-rank Gaussian initialized to standard normal and optimizes with closed-form entropy gradient from \Cref{eq:justin-elbo-grad}; uses ADVI step-scheme for updates (see \Cref{sec:advi-implementation} for more details). Importance-weighted sampling is not used; importance-weighted training is not used (optimized standard ELBO).
\subsection*{Method (0)}
Uses a full-rank Gaussian initialized to standard normal and optimizes with closed-form entropy gradient from \Cref{eq:justin-elbo-grad}; uses our comprehensive step-size search for updates (see \Cref{sec:step-size-comp-search} for more details). Importance-weighted sampling is not used; importance-weighted training is not used.
\subsection*{Method (1)}
Uses a full-rank Gaussian initialized to standard normal and optimizes with the STL from \Cref{eq:entropy-gradients}; uses our comprehensive step-size search for updates. Importance-weighted sampling is not used; importance-weighted training is not used.
\subsection*{Method (2)}
Uses a full-rank Gaussian and initializes with LI method from \Cref{sec:initialization}; optimizes with the STL from \Cref{eq:entropy-gradients} and uses our comprehensive step-size search for updates. Importance-weighted sampling is not used; importance-weighted training is not used.
\subsection*{Method (3a)}
Uses a full-rank Gaussian initialized to standard normal and optimizes with the STL gradient from \Cref{eq:entropy-gradients}; uses our comprehensive step-size search for updates. Importance-weighted sampling is used with $M = 10$; importance-weighted training is not used.
\subsection*{Method (3b)}
Uses a full-rank Gaussian initialized to standard normal and uses importance-weighted training with M = 10; optimizes with the DReG from \Cref{eq:dreg-estimator} and uses our comprehensive step-size search for updates. Importance-weighted training is used with M = 10 (optimizes IW-ELBO with M = 10).
\subsection*{Method (4a)}
Uses a real-NVP normalizing flow (see \Cref{sec:architecural-detials} for architectural and initialization details) as $q_{\phi}$; optimizes with the ``full'' gradient from \Cref{eq:entropy-gradients} and uses our comprehensive step-size search for updates. Importance-weighted sampling is not used; importance-weighted training is not used.
\subsection*{Method (4b)}
Uses a real-NVP normalizing flow and optimizes with the STL gradient from \Cref{eq:entropy-gradients}; uses our comprehensive step-size search for updates. Importance-weighted sampling is not used; importance-weighted training is not used.
\subsection*{Method (4c)}
Uses a real-NVP normalizing flow and optimizes with the STL gradient from \Cref{eq:entropy-gradients}; uses our comprehensive step-size search for updates. Importance-weighted sampling is used with M = 10; importance-weighted training is not used.
\subsection*{Method (4d)}
Uses a real-NVP normalizing flow and uses importance-weighted training with M = 10; optimizes with the DReG gradient from \Cref{eq:dreg-estimator} and uses our comprehensive step-size search for updates. Importance-weighted training is used with M = 10.
\section{Extended results}
\label{sec:extended results}
\subsection{Diagonal vs Full-rank Gaussian VI}
In this section, we compare the performance of Gaussian VI with full-rank covariance against diagonal covariance.
While it is well known that full-rank covariance Gaussian distribution are more expressive, a clear experimental evidence for this is notably missing from the literature--we supplement this by experimenting with three methods from our path-study: Method (0), Method (1), and Method (3a). In \Cref{fig:diag-vs-fullrank for g}, it is easy to observe that using full-rank Gaussian improves performance by 1 nats or more on at least half of the models across the methods. When using Importance Weighted sampling--Method (3a)-- full-rank covariance Gaussians almost always improves the performance.
\begin{figure*}[h]
\begin{subfigure}{0.33\linewidth}
\centering
\includegraphics[page = 1, width=\linewidth]{figure/diag_pairwise_comparisons.pdf}
\end{subfigure}
\begin{subfigure}{0.33\linewidth}
\centering
\includegraphics[page = 2, width=\linewidth]{figure/diag_pairwise_comparisons.pdf}
\end{subfigure}
\begin{subfigure}{0.33\linewidth}
\centering
\includegraphics[page = 3, width=\linewidth]{figure/diag_pairwise_comparisons.pdf}
\end{subfigure}
\caption{Full-rank vs. Diagonal: \footnotesize{\inlinelist{\protect \item Method (0): closed-form entropy w/ step search, \protect \item Method (1): we replace closed-form entropy with STL gradient, and \protect \item Method (3a): we add Importance Weighted Sampling to STL gradient. In all the methods, using full-rank Gaussian improves the performance by at least 1 nats on more than half of the models. }}}
\label{fig:diag-vs-fullrank for g}
\end{figure*}
\subsection{Different gradient for Gaussian VI}
There are three choices of gradients for the Gaussian family. First, as Gaussians have a closed-form entropy, we can use the gradient from \Cref{eq:justin-elbo-grad}; this is the gradient that ADVI uses. Second, we can alternatively use the middle gradient from \Cref{eq:entropy-gradients}. Third, we can drop the score-function term and use the STL estimator (third term in \Cref{eq:entropy-gradients}). In \Cref{fig:stl-vi-H estimators for g}, the first panel compares the performance of using STL against the ADVI implementation (ADVI step-scheme and gradient). In the second panel, we compare the performance with the closed-form estimator optimized using our comprehensive step-search. Finally, we compare against the middle gradient in \Cref{eq:entropy-gradients}. In all the alternatives, STL rarely hurts and adds significant value to several models.
\begin{figure*}[h]
\begin{subfigure}{0.33\linewidth}
\centering
\includegraphics[page = 12, width=\linewidth]{figure/new_pairwise_comparisons.pdf}
\end{subfigure}
\begin{subfigure}{0.33\linewidth}
\centering
\includegraphics[page = 14, width=\linewidth]{figure/new_pairwise_comparisons.pdf}
\end{subfigure}
\begin{subfigure}{0.33\linewidth}
\centering
\includegraphics[page = 13, width=\linewidth]{figure/new_pairwise_comparisons.pdf}
\end{subfigure}
\caption{\footnotesize{\inlinelist{\protect \item STL against ADVI; STL improves the performance by 1 nat or more on almost 30\% of the models. \protect \item Next, we replace the ADVI step-size scheme with our comprehensive step search. STL improves the performance on 20\% of the models by 1 nat or more. \protect \item We also compare against the middle gradient from \Cref{eq:entropy-gradients} and find that STL provides an improvement of 1 nat or more on almost 10\% of the models. In all the alternatives, STL rarely hurts.}}}
\label{fig:stl-vi-H estimators for g}
\end{figure*}
\subsection{IW-training with DReG}
We compare IW-training with and without DReG estimator on different possibilities and find that it consistently improved the performance. In \Cref{fig:iw-training-dreg-iwae-g-nf}, we first compare the performance with the standard IW-ELBO gradient for Gaussian families. In the second comparison, we add Laplace Initialization to both methods, IW-ELBO gradient and DReG gradient. In the final comparison, we compare DReG with regular IW-ELBO gradient for normalizing flows. Across all comparisons, DReG improves the performance and rarely hurts.
\begin{figure*}[h]
\begin{subfigure}{0.33\linewidth}
\centering
\includegraphics[page = 9, width=\linewidth]{figure/new_pairwise_comparisons.pdf}
\end{subfigure}
\begin{subfigure}{0.33\linewidth}
\centering
\includegraphics[page = 10, width=\linewidth]{figure/new_pairwise_comparisons.pdf}
\end{subfigure}
\begin{subfigure}{0.33\linewidth}
\centering
\includegraphics[page = 11, width=\linewidth]{figure/new_pairwise_comparisons.pdf}
\end{subfigure}
\caption{\footnotesize{\inlinelist{\protect \item DReG improves the performance significantly by 1 nat on almost 30\% of the models for Gaussians when initialized with standard normal \protect \item On adding LI to the previous model, DReG adds 1 nat to around 20\% of the models \protect \item Adding DReG to IW-training of flows also helps. We observe significant improvement of 1 nat or more for almost 30\% of the models}}}
\label{fig:iw-training-dreg-iwae-g-nf}
\end{figure*}
\begin{wrapfigure}{r}{0.35\textwidth}
\centering
\vspace{-16mm}
\begin{small}
\begin{center}
\centerline{\includegraphics[page = 6, height=\linewidth]{figure/new_pairwise_comparisons.pdf}}
\caption{\footnotesize{Adding LI to Gaussian VI is neither consistently helpful nor consistently harmful.}}
\label{fig:laplace-neutral}
\end{center}
\end{small}
\vspace{-26mm}
\end{wrapfigure}
\subsection{Path Study - full results}
\label{sec:extended-path-study}
We conduct a path-study to accumulate all the useful combinations of our analysis. \Cref{fig:path-study-extended} presents the study for three independent trials. The high variation is due to the ADVI; on 10 models out of 30, ADVI diverges in at-least one trial for our implementation. If an optimization diverges, we set the improvement as zero, that is, we count the model in favor of the baseline (see \Cref{tab:advi-unstable} for values).
\begin{figure*}[!ht]
\begin{subfigure}{\linewidth}
\centering
\includegraphics[page = 1, width=0.6\linewidth]{figure/new_figure_2_ccdf.pdf}
\end{subfigure}
\bigskip{}
\begin{subfigure}{\linewidth}
\centering
\includegraphics[page = 3, width=0.6\linewidth]{figure/new_figure_2_ccdf.pdf}
\end{subfigure}
\bigskip
\begin{subfigure}{\linewidth}
\centering
\includegraphics[page = 5, width=0.6\linewidth]{figure/new_figure_2_ccdf.pdf}
\end{subfigure}
\caption{\footnotesize{Across the trials: Method (1) that uses STL gradient improves over ADVI by 1 nat or more for at least 20\% of the models. Method (3a) adds the IW-sampling to (1) and improves by a nat or more on at least 30\% of the models. Method (4a) uses flow with the naive gradient estimator and achieves performance similar to (3a). Method (4b) adds the STL gradient to (4a) and improves on at least 40\% of the models by 1 nat or more. Method (4c) adds IW-sampling to (4b) and improves by 1 nat on a minimum of 50\% of the models. All our methods use comprehensive step-search and use M = 10 wherever IW-sampling is applied.}}
\label{fig:path-study-extended}
\end{figure*}
\subsection{Ablation Study - full results}
\label{sec:extended-ablation-study}
We conduct an ablation-study to analyze each component of the best performing method. \Cref{fig:ablation-study-extended} presents the study for three independent trials.
\begin{figure*}[!ht]
\begin{subfigure}{\linewidth}
\centering
\includegraphics[page = 1, width=0.6\linewidth]{figure/new_ablation_ccdf_extended.pdf}
\end{subfigure}
\bigskip
\begin{subfigure}{\linewidth}
\centering
\includegraphics[page = 3, width=0.6\linewidth]{figure/new_ablation_ccdf_extended.pdf}
\end{subfigure}
\bigskip
\begin{subfigure}{\linewidth}
\centering
\includegraphics[page = 5, width=0.6\linewidth]{figure/new_ablation_ccdf_extended.pdf}
\end{subfigure}
\caption{\footnotesize{Across the trials: ablating STL observes the least decay in performance while ablating flows causes the most decrease. The effect of ablating IW-sampling lies somewhere in the middle of these two. All approaches are trained with comprehensive step-search and use M=10 wherever importance weighted sampling is used.}}
\label{fig:ablation-study-extended}
\end{figure*}
\subsection{Laplace Initialization}
\Cref{fig:laplace-neutral} compares the results of using Laplace initialization (LI) against not using it (we omitted this comparison from the main text for brevity). While there is a significant improvement on a minority of models, similar fraction observe a significant decay.
\section{Interfacing using auto-diff packages}
\label{sec:auto-diff-models}
To interface with Stan models, we must define a new ``primitive" function in Autograd that corresponds to $\log p(x,z)$ as a function of $z$. In addtion, this also requires computing $\log p(x,z)$ itself as well as the gradient-vector product $a^\top \nabla_z \log p(z,x)$ for any vector $a$. This is easily done since PyStan interface allows access to $\log p(z,x)$ and the gradient $\nabla_z \log p(z,x)$ for any model defined in Stan. This approach has the disadvantage that high-order gradients are not possible. Similar strategies could be used with other automatic differentiation packages.
\section{ADVI}
\paragraph{Step-size scheme}
\label{sec:advi-step-scheme}
ADVI uses a novel step-size sequence inspired by adaptive step-size gradient schemes \cite{duchi2011adaptive, ranganath2013adaptive, kingma2014adam}. The update at iteration $i$ is
\begin{align}
\phi^{(i+1)} = \phi^{(i)} - \rho^{(i)} \odot g^{(i)},
\end{align}
where $g^{(i)}$ is the stochastic gradient in the $i$-th iteration, $\rho^{(i)}$ is a vector of step-sizes (one per coordinate of $\phi$) and $\odot$ denotes elementwise multiplication. To determine the stepsizes, a vector $s^{(i)}$ is initialized to $s^{(1)}=(g^{(1)})^2$ and maintained recursively as
\begin{align}
s^{(i)} = \alpha (g^{(i)})^{2} + (1-\alpha) s^{(i-1)}, \label{eq:advi-gradient-mem}.
\end{align}
Then, the stepsizes are chosen as
\begin{align}
\rho^{(i)} = \frac{\eta }{ i^{1/2 + \epsilon} \times \left( \tau + \sqrt{s^{(i)}}\right)}, \label{eq:advi-eta-step-size}
\end{align}
where the square root and division are element-wise. Here $\eta>0$ is the scale of the step-size, \dollarit{i^{1/2 + \epsilon}} decays the step over time, and the $s^{(i)}$ adapts the curvature of the ELBO. $\tau=1$ and $\epsilon=10^{-16}$ are stabilizing constants.
\paragraph{Implementation details}
\label{sec:advi-implementation}
ADVI step-scheme search for $\eta$ from \Cref{eq:advi-eta-step-size} over the range \dollarit{\{0.01, 0.1, 1, 10, 100\}} to best adapt to the size of the problem. We use 200 optimization iterations for each of these choices and then use a fresh batch of 500 samples for each step in the range to calculate final ELBO values. The step with highest final ELBO is selected as the adapted step-size; with the adapted $\eta$ we optimize for 30,0000 iterations where, at each iteration we use $100$ total \dollarit{\log p} evaluation(same as our other experiments).
We also implement the relative-tolerance convergence criterion implemented in PyStan to detect early convergence(we use a tolerance of 0.001). Also, following the original work, we use the closed form of entropy of \dollarit{q_{\phi}} for the ADVI training objective. We make an honest attempt to the best of our abilities to re-implement the ADVI and in our preliminary experiments found that the performance matched the PyStan version for the same hyper-parameter settings. We found that the performance of ADVI was highly variable; out of the three independent trials, 9 models diverged in at least one trial. Replacing ADVI step-scheme with our comprehensive step-search saw no divergence for the closed-form entropy case that uses Adam optimizer.
\section{Implementation details for real-NVP}
\label{sec:architecural-detials}
\paragraph{Architectural details:}
We use a real-NVP flow with 10 coupling layers for all our experiments. We define each coupling layer to be comprised of two transitions, where a single transition corresponds to affine transformation of one part of the latent variables. For example, if the input variable for the \dollarit{k^{th}} layer is \dollarit{z^{(k)}}, then first transition is defined as
\begin{align}
z_{1:d} &= z^{(k)}_{1:d}\nonumber\\
z_{d+1:D} &= z^{(k)}_{d+1:D} \odot \exp\big(s^{a}_{k}(z^{(k)}_{1:d})\big) + t^{a}_{k}(z^{(k)}_{1:d})).
\label{eq:rnvp-appendix}
\end{align}
where, super-script \dollarit{a} denotes first transition and sub-script \dollarit{k} denotes the \dollarit{k^{th}} layer. For the next transition, the \dollarit{z_{d+1:D}} part is kept unchanged and \dollarit{z_{1:d}} is affine transformed in a similar fashion to obtain the layer output \dollarit{z^{(k+1)}}(this time using \dollarit{s^{b}_{k} (z^{(k)}_{d+1:D}) } and \dollarit{t^{b}_{k} (z^{(k)}_{d+1:D}) } ). This is also referred to as the alternating first half binary mask.
Both, scale(\dollarit{s}) and translation(\dollarit{t}) functions are parameterized by the same fully connected neural network(FNN). More specifically, for first transition in above example, a single FNN takes \dollarit{z^{(k)}_{1:d}} as input and outputs both \dollarit{s^{a}_{k}(z^{(k)}_{1:d})} and \dollarit{t^{a}_{k}(z^{(k)}_{1:d})}. Thus, the skeleton of the FNN, in terms of the size of the layers, is as \dollarit{[d, H,H, 2(D-d)]} where, \dollarit{H} denotes the size of the two hidden layers ($H$=32 for all our experiments).
The hidden layers of FNN use a leaky rectified linear unit with slope = 0.01, while the output layer uses a hyperbolic tangent for \dollarit{s} and remains linear for \dollarit{t}.
\paragraph{Parameter Initialization:}
We initialize the parameters of the neural networks from normal distribution $\mathcal{N}(0, 0.001^{2})$. We deliberately make this choice as it corresponds to an approximate standard normal initialization for the overall normalizing flow density. To see this, first note that the output from the initialized neural networks will approximately be 0 vectors. Now, consider the affine transformation of real-NVP: at each iteration, we scale by the exponent of $s$ and offset by $t$. Thus, the overall effect is an identity transform. As the base-distribution is fixed to a standard normal, this gives as an approximate standard normal initialization.
\paragraph{Number of Parameters:}
For each transition, assuming \dollarit{d = D/2}, the parameters of the FNN can be calculated as \dollarit{ \frac{1}{2}DH + H^{2} + HD + D + 2H} where \dollarit{D} is the number latent dimensions in the model, and \dollarit{H} is the size of the two hidden layers. The first three components in the calculation corresponds to weight matrix, and the latter two take into account the bias parameters. With T coupling layers, each comprising of \dollarit{2} transitions, the overall parameter size is given by \dollarit{2T(\frac{3}{2}DH + H^{2} + D + 2H)}. We use $T$=10 and $H$=32, while $D$ depends on the problem.
\paragraph{Scaling to higher dimension models:} Real NVP based architectures scale better to higher dimensional problems as compared to Gaussians. The parameters in Gaussian scale as \dollarit{\mathcal{O}(D^{2})} while they scale linearly \dollarit{\mathcal{O}(D)} for real-NVP, if we fix other parameters(\dollarit{T} and \dollarit{H}). However, for lower dimensional problem the number of parameters for real-NVP is more.
\section{Selection of Best model}
\label{sec:select-best-model}
We choose the model that achieves best average-objective, averaged over the entire optimization trace. This is different from, perhaps a more natural, final value based selection rule where one evaluates on a smaller batch of fresh samples; smaller compared to number of samples used for final metric evaluation. We found average objective to be more reliable indicator of the performance in practice. In our preliminary experiments, models selected from the maximum average-objective out-performed the ones selected based on the maximum final value; the comparison was based on the final metric value evaluated using a fresh batch of 10,000 samples.
\section{Full list of models}
We present the complete list of models used in our analysis~\Cref{tab:full-model-list}. The descriptions in the table have been manually extracted, see Stan-example model repository \citep{stanmodels} for more details.
\begin{table}[!ht]
\caption{\label{tab:full-model-list} This table presents attributes of all the models from the Stan model library \citep{stanmodels,StanDevelopmentTeam2018} that have been used in this analysis. The attribute are $|z| = \text{\# of latent dimensions}, \,n = \text{\# of data points},\text{ and } r = \frac{\text{\# of latent dimensions}}{\text{\# of data points}} $}
\begin{center}
\begin{small}
\resizebox{0.8\linewidth}{!}{
\begin{tabularx}{\linewidth}{rlrrrX}
\toprule
Id & Model name & $|z|$ & $n$ & $r$ & Model Description \\
\midrule
1 & lsat & 1006 & 818 & 1.2298 & One-parameter Rasch model for LSAT student response \\
2 & Mh & 388 & 385 & 1.0078 & Heterogeneity model for closed population size estimation from capture-recapture data with individual effects \\
3 & test\_simplex & 3 & 10 & 0.3000 & Simplex estimator \\
4 & endo3 & 184 & 626 & 0.2939 & Conditional inference model for case-control study on endometrial cancer \\
5 & gp\_predict & 265 & 989 & 0.2679 & Model for predicting out-of-sample observations by fitting hyperparams of a latent variable Gaussian process with exponentiated quadratic kernel and Gaussian likelihood \\
6 & Mth & 394 & 1935 & 0.2036 & Combined model for for closed population size estimation with both, time and individual effects \\
7 & oxford & 244 & 1226 & 0.1990 & A mixture model for the log odds ratio to analyze Oxford childhood cancer data \\
8 & cjs\_mnl & 22 & 132 & 0.1667 & CJS model for capture-recapture problem with multinomial likelihood \\
9 & hepatitis & 218 & 1596 & 0.1366 & Normal hierarchical model with measurement error in Hb titre in children post Hepatitis vaccination \\
10 & normal\_multi & 100 & 826 & 0.1211 & Basic Multi-variate estimators for normal and student-t distributions \\
11 & hiv\_chr & 173 & 1476 & 0.1172 & Multi-level linear model with varying slope and intercept for Zinc diet experiment on HIV positive children \\
12 & electric\_1c\_chr & 116 & 1248 & 0.0929 & Multi-level linear model with varying intercept and slope for the effect of exposure to television show, The Electric Company \\
13 & electric\_1a\_chr & 112 & 1248 & 0.0897 & Multi-level linear model with group level factors for the effect of exposure to television show, The Electric Company \\
14 & electric\_chr & 100 & 1248 & 0.0801 & Multi-level linear model with varying intercept for the effect of exposure to television show, The Electric Company \\
15 & radon\_vary\_si\_chr & 175 & 4595 & 0.0381 & Multi-level linear model with group level predictors to estimate radon levels. \\
16 & lda & 33 & 1157 & 0.0285 & Latent Dirichlet Allocation \\
17 & radon\_redundant\_chr & 88 & 4595 & 0.0192 & Multi-level linear model with varying intercept and redundant parameterization and the Choo-Hoffman parametrization \\
18 & naive\_bayes & 39 & 4124 & 0.0095 & Naive Bayes classifier \\
19 & mesquite\_volume & 3 & 322 & 0.0093 & Linear model with one transformed predictor and log transformation to measure the yield of mesquite bushes \\
20 & cjs\_t\_t & 22 & 3960 & 0.0056 & CJS model for capture-recapture problem with parameter identifiability \\
21 & irt\_multilevel & 503 & 90671 & 0.0055 & Item response theory multi-level logistic model \\
22 & irt & 501 & 90941 & 0.0055 & Item response theory 2-p logistic model \\
23 & congress & 4 & 1029 & 0.0039 & Linear model to predict the 1988 election from 1986 election \\
24 & dogs & 3 & 775 & 0.0039 & Multi-level logistic regression model for behavioral learning experiment on dogs \\
25 & Dynocc & 29 & 7500 & 0.0039 & Dynamic (multi-season) site-occupancy Hidden Markov Model \\
26 & multi\_logit & 32 & 9842 & 0.0033 & Multinomial logistic regression \\
27 & electric\_one\_pred & 3 & 1248 & 0.0024 & Lin. model with one predictor \\
28 & election88 & 55 & 104094 & 0.0005 & Multi-level logistic regression model with group level predictors to predict Republican candidate in 1988 elections \\
29 & wells & 2 & 15100 & 0.0001 & Generalized linear model with logit link function and one predictor to predict shift to a safer well in Bangladesh \\
30 & wells\_dist & 2 & 15100 & 0.0001 & Generalized linear model with logit link function and one predictor to predict shift to a safer well in Bangladesh \\
\bottomrule
\end{tabularx}
}
\end{small}
\end{center}
\end{table}
\section{Complete Table of results}
\label{sec:complete-results}
\begin{landscape}
\thispagestyle{empty}
\input{appendix/ADVI_results}
\end{landscape}
\begin{landscape}
\thispagestyle{empty}
\input{appendix/Gaussian_closed_form_results}
\end{landscape}
\begin{landscape}
\thispagestyle{empty}
\input{appendix/Gaussian_without_STL_results}
\end{landscape}
\begin{landscape}
\thispagestyle{empty}
\input{appendix/Gaussian_with_STL_results}
\end{landscape}
\begin{landscape}
\thispagestyle{empty}
\input{appendix/Gaussian_IWVI_results}
\end{landscape}
\begin{landscape}
\thispagestyle{empty}
\input{appendix/NF_VI_results}
\end{landscape}
\begin{landscape}
\thispagestyle{empty}
\input{appendix/NF_IWVI_results}
\end{landscape}
\begin{landscape}
\thispagestyle{empty}
\input{appendix/diag_results}
\end{landscape}
\section{Complete table for per iteration training times}
\label{sec:complete-time-tables}
For completeness, we include the per iterations training times of all the VI methods we experiment with. However, these training times should be read into with caution. We interface with Pystan and Autograd for our work; this creates an extra overhead with can dominate the run-times when the models are expensive to evaluate. Further, each training instance is run on a single CPU core.
\begin{landscape}
\thispagestyle{empty}
\input{appendix/ADVI_results_time}
\end{landscape}
\begin{landscape}
\thispagestyle{empty}
\input{appendix/Gaussian_closed_form_results_time}
\end{landscape}
\begin{landscape}
\thispagestyle{empty}
\input{appendix/Gaussian_without_STL_results_time}
\end{landscape}
\begin{landscape}
\thispagestyle{empty}
\input{appendix/Gaussian_with_STL_results_time}
\end{landscape}
\begin{landscape}
\thispagestyle{empty}
\input{appendix/Gaussian_IWVI_results_time}
\end{landscape}
\begin{landscape}
\thispagestyle{empty}
\input{appendix/NF_VI_results_time}
\end{landscape}
\begin{landscape}
\thispagestyle{empty}
\input{appendix/NF_IWVI_results_time}
\end{landscape}
\begin{landscape}
\thispagestyle{empty}
\input{appendix/diag_results_time}
\end{landscape}
\section{Problem Setup}
Directly computing the posterior is typically intractable; VI searches for the closest approximation of $p(\vectorize{z}|x)$ within a parameterized family $q_{\phi}(\vectorize{z})$ by maximizing the ELBO ~\citep{saul1996mean}
\begin{align}
\mathcal{L}(\phi) &= \mathbb{E}_{q_{\phi}(z)} \left[ \log p(z, x) - \log q_\phi(z) \right] = \log p(x) - \mathbb{KL}[q_{\phi}(z)\| p(z|x)]. \label{eq:elbo
\end{align}
Since KL-divergence is non-negative, $\mathcal{L}(\phi)$ lower-bounds $\log p(x)$ for all $\phi$. Moreover, when \dollarit{p} is fixed, optimizing $\mathcal{L}(\phi)$ is equivalent to minimizing the KL-divergence between $q_\phi(z)$ and $p(\vectorize{z}|x)$.
Exploiting the observations above, there are two basic uses of VI. The first is to \emph{learn} the parameters $\theta$ of a model $p_\theta(\vectorize{z},x)$ from examples of $x$. In this case, VI is used to provide a tractable objective that lower-bounds the exact likelihood. This is the basis of variational auto-encoders \citep{kingma2013auto, rezende2014stochastic} and their relatives. The second use of VI is to \emph{infer} the posterior $p(\vectorize{z}|x)$ of a fixed model. This is the setting of black-box VI \citep{ranganath2014black}, the focus of this paper.
\subsection{Rules of engagement}
This paper studies many black-box VI methods. Each method is optimized using its own objective to produce an approximate posterior $q_\phi(z)$. During optimization, all methods have the same computational budget, measured as 100 "oracle evaluations" of the $\log p$ per iteration, and are optimized for $30,000$ iterations. Then, 10,000 fresh samples are drawn from $q_\phi$ to evaluate either the ELBO in \Cref{eq:elbo} or the importance-weighted ELBO in \Cref{eq:iwelbo}, depending on the method. In either case, this gives a lower-bound on $\log p(x)$ (or equivalently an upper-bound on the KL-divergence \citep{domke2018importance}). Applying importance-weighting can be seen as an \emph{algorithmic component}, not just a "metric" since it gives a different approximation of the posterior \citep{Domke2019DivideAC}.
We evaluate each method using a benchmark of 30 models from the Stan Model library~\citep{stanmodels,StanDevelopmentTeam2018}. To remove any ambiguity, a standalone description of each method compared is given in \Cref{sec:full_method_description}.
Visualizing results across many models and inference schemes is a challenge. Simple ideas like scatterplots fail because there are many inference schemes and huge differences in $\log p(x)$ across models. Instead, we study results using "empirical complementary CDF plots". Two inference methods are compared by computing, for each model $i \in \{1,\cdots,30\}$, the difference $\Delta_i$ between the lower-bounds produced by the two methods. The idea is to plot, for each value of $\Delta$, the fraction of values $\Delta_i$ that are $\Delta$ or higher. This shows how often a given inference method improves on another by a given magnitude $\Delta$.
We start from a simple ADVI baseline model and consider changes in a single algorithmic component one by one in \Cref{fig:step-size-cdf,fig:init-cdf,fig:iw_sampling,fig:iw_training,fig:nf,fig:nf-stl,fig:nf-IW-sampling,fig:nf-iw-training}. Next, we compare the full "path" of beneficial components to ADVI in \Cref{fig:path-study-outline-combined}. Finally, we perform an ablation study removing individual algorithmic components from the final best system in \Cref{fig:ablation-study}. We conduct three independent trials for all of our experiments. For space, the path and ablation study show only a single trial in the main text, with others in the supplement. We also conduct additional experiments in \Cref{sec:extended results} including comparisons between diagonal and full-rank Gaussian VI and more comparisons of different gradient estimators.
\section{Experiments}
\label{sec:experiments}
\input{experiments/details_of_setup}
\input{experiments/path_study}
\subsection{Ablation Study}
We analyze the performance of the ``best'' variational approach by taking away each of it's components individually. \Cref{fig:ablation-study} presents the ablation study for an independent trial (see \Cref{fig:ablation-study-extended} in supplement for full results).
Across the trials, each component is complementary--they add to the other and the combination performs the best.
\subsection{Monte Carlo Objectives}
\label{sec:fam-iw}
VI tries to approximate $p(z|x)$ with $q_\phi(z)$. If the approximation is inexact, Monte Carlo methods can often improve it. \citet{burda2015importance} introduced the "importance-weighted" ELBO (IW-ELBO) to use in place of the conventional ELBO when training a latent-variable model. This is
\begin{wrapfigure}{r}{0.35\textwidth}
\centering
\vspace{2mm}
\begin{small}
\begin{center}
\centerline{\includegraphics[page = 2, height=\linewidth]{figure/new_pairwise_comparisons.pdf}}
\caption{\footnotesize{IW-sampling greatly improves the results of Gaussian VI.}}
\label{fig:iw_sampling}
\end{center}
\end{small}
\vspace{-12mm}
\end{wrapfigure}
\begin{align}
\medmath{\mathcal{L}_{M}(\phi)} &= \medmath{\E_{q_\phi (z_1)\cdots q_\phi(z_M) } \left [ \log \frac{1}{M}\sum_{m=1}^{M} \frac{p(x,z_{m})}{q_\phi(z_{m})} \right] \leq \log p(x)}.\label{eq:iwelbo}
\end{align}
Here, \dollarit{z_1 \hdots z_M} are iid samples from \dollarit{q_{\phi}(z)}. This reduces to the standard ELBO when $M=1$. The IW-ELBO increases with \dollarit{M} and approaches $\log p(x)$ asymptotically.
The IW-ELBO is a measure of the accuracy of self-normalized importance sampling on $p$ using $q_\phi$ as a proposal distribution. Define $q_{M,\phi}$ to be the distribution that results from drawing $M$ samples from $q_\phi$ and then selecting one in proportion to the self-normalized importance weights $p(z_m,x)/q(z_m)$. Then, $\mathcal{L}_M$ is a relaxation of the ELBO defined between $q_{M,\phi}$ and the target $p$ \citep{bachman2015training, cremer2017reinterpreting, naesseth2017variational}. Alternatively, $\mathcal{L}_M$ can be seen as a traditional ELBO between distributions that {\em augment} $q_{M,\phi}$ and $p$ \cite{domke2018importance}.
For posterior approximation, importance weighting can be applied in two ways.
\begin{enumerate}[leftmargin=15pt, itemsep=3pt]
\item {\bf Importance-weighted sampling}. For {\em any} distribution, importance-weighting can be applied at test time to improve the quality of the posterior approximation. We know this because $\mathcal{L}_M(\phi) \geq \mathcal{L}(\phi)$ and thus $\mathbb{KL}[q_{M,\phi}(z)\| p(z|x)] \leq \mathbb{KL}[q_{\phi}(z)\| p(z|x)]$ \citep{domke2018importance}. This should not be seen as a metric for evaluating $\phi$. Rather, it is an algorithmic component of inference, since it yields \emph{different samples} that are actually closer to the posterior \citep{Domke2019DivideAC}.
\item {\bf Importance-weighted training}. To find the parameters $\phi$, one can optimize the IW-ELBO. The idea is that if one intends to perform importance-weighted sampling, this directly optimizes for parameters $\phi$ that will perform well at this task. That is, optimizing the IW-ELBO implicitly makes $q_{M,\phi}(z)$ close to $p(z|x)$.
\end{enumerate}
\Cref{fig:iw_sampling} shows the results of adding importance-weighted sampling to the previous model, with $M=10$. This produces a significant benefit of 1 nat or more on 30\% of models and never hurts. This also comes at a minimal computational cost since there is no modification of the training procedure. Considerations in importance-weighted training are a bit subtle and discussed next.
\subsection{Importance-weighted training}
\label{sec:iw-training}
\begin{wrapfigure}[15]{r}{0.35\textwidth}
\centering
\vspace{-6mm}
\begin{small}
\begin{center}
\centerline{\includegraphics[page = 7, height=\linewidth]{figure/new_pairwise_comparisons.pdf}}
\caption{\footnotesize{Adding IW-training to IW-sampling offers no clear advantage with Gaussians.}}
\label{fig:iw_training}
\end{center}
\end{small}
\vspace{-20mm}
\end{wrapfigure}
Optimizing \Cref{eq:iwelbo} requires a gradient estimator. The most obvious estimator is
\begin{align}
\medmath{\nabla \mathcal{L}_M(\phi)} &= \medmath{\E_{q_\epsilon (\epsilon_1)\cdots q_\epsilon(\epsilon_M) } \sum_{m=1}^M \hat{w}_m \nabla_\phi \log\frac{p(z_{\phi}(\epsilon_m),x))}{q_\phi(z_{\phi}(\epsilon_m))}} \label{eq:iw-elbo-grad},
\end{align}
where $\hat{w}_m = \frac{w_m }{\sum_{l=1}^M w_l}$ for \dollarit{w_m = \frac{p\left(x,z_{\phi}(\epsilon_m) \right)}{q_{\phi} \left( z_{\phi}(\epsilon_m)\right)}}. However, \citet{rainforth2018tighter} point out that the signal-to-noise-ratio of this gradient estimator scales as \dollarit{1/\sqrt{M}}, suggesting optimization will struggle when $M$ is large. To circumvent this problem, \citet{tucker2018doubly} introduced the "doubly reparameterized gradient estimator" (DReG), which does not suffer from the same issue. This is based on the representation of
\begin{align}
\medmath{\nabla \mathcal{L}_M(\phi)} & = \medmath{\E_{q_\epsilon (\epsilon_1)\cdots q_\epsilon(\epsilon_M) } \sum_{m=1}^{M} (\hat{w}_m)^{2} \nabla_\phi \log\frac{p(z_{\phi}(\epsilon_m),x))}{q_\theta(z_{\phi}(\epsilon_m))} \Bigg\vert_{\theta=\phi}}.\label{eq:dreg-estimator}
\end{align}
Intuitively, the idea is that since $\theta$ is $\phi$ "held constant" under differentiation, the variance is reduced. The difference of the above two estimators is analogous to the difference of the two estimators of the entropy gradient in \Cref{eq:entropy-gradients}.
We found the DReG out-performed the estimator from \Cref{eq:iw-elbo-grad}; using it added 1 nat of improvement to almost 30\% of the models (see~\Cref{fig:iw-training-dreg-iwae-g-nf}, supplement). However, the benefits are not consistent when compared to IW-sampling alone. \Cref{fig:iw_training} shows the performance {\em decays} on around 20\% of models. Thus, when keeping evaluations of $\log p$ fixed at our budget, better performance results from training the regular ELBO with the STL estimator and then using IW-sampling only.
\subsection{Normalizing Flows}
\label{sec:nf}
\begin{wrapfigure}{r}{0.35\textwidth}
\centering
\vspace{-6.5mm}
\begin{center}
\centerline{\includegraphics[page = 3, width=\linewidth]{figure/new_pairwise_comparisons.pdf}}
\caption{\footnotesize{Substituting flows for Gaussians improves half of the models by 1 nat or more.}}
\label{fig:nf}
\end{center}
\vspace{-14mm}
\end{wrapfigure}
Normalizing flows construct a flexible class of densities by applying a sequence of invertible transformations to a simple base density. \citet{rezende2015variational} first introduced normalizing flows in the specific context of approximating distributions for VI; they have since been studied in a much more general context (e.g., for density estimation \citep{dinh2016density, kingma2018glow, durkan2019neural}).
The main idea is to transform a base density \dollarit{q_\epsilon(\epsilon)} using a diffeomorphism $T_\phi$. The variable \dollarit{z = T_\phi(\epsilon)} has the distribution
\begin{align}
q_\phi(z) &= q_\epsilon(\epsilon) |\det \nabla T_\phi(\epsilon)|^{-1} \label{eq:nf}\\
&= q_\epsilon(T^{-1}_\phi(z)) |\det \nabla {T^{-1}_\phi}(z)|. \label{eq:nf-inverse}
\end{align}
Typically, $T$ is chosen as a sequence of transforms, each of which is parameterized by a neural network. These transforms are designed so that the determinant of the Jacobian $\vert \det \nabla T_\phi(\epsilon)\vert$ can be computed efficiently.
We use real-NVP--a coupling-based flow \citep{dinh2016density} with 10 successive transformations, each determined by a fully-connected network with 2 hidden layers each with 32 hidden units (see \Cref{sec:architecural-detials} for full details). \Cref{fig:nf} shows the results of using normalizing flows instead of Gaussians on the benchmark. Since there is no closed-form entropy, these results estimate it using the middle estimator from \Cref{eq:entropy-gradients}. This yields a significant improvement of 1 nat or more on around half of models.
\begin{wrapfigure}[17]{r}{0.35\textwidth}
\centering
\vspace{-3mm}
\includegraphics[page = 4, height=\linewidth]{figure/new_pairwise_comparisons.pdf}
\caption{\footnotesize{Using the STL estimator for flows (instead of the ``full'' estimator) is typically helpful and gives huge improvements on a minority of models.}}
\label{fig:nf-stl}
\vspace{-8mm}
\end{wrapfigure}
Depending on the gradient estimator used, the inverse of $T_\phi$ may or may not be needed. This issue is somewhat subtle. In general, to evaluate the density $q_\phi$ at an arbitrary point requires computing the inverse $T^{-1}_\phi$ which may be inefficient \citep{huang2018neural, chen2019residual}. While the ELBO in \Cref{eq:elbo} requires evaluating the density $\log q_\phi$ it is only done on a point sampled from $q_\phi$. This means this can be done using only $T_\phi$--by first sampling $\epsilon$ and then transforming to $z$ there is no need to explicitly compute an inverse. Similarly, if one is to estimate the gradient of the entropy using the "full" estimator (middle equation in \Cref{eq:entropy-gradients}), only $T_\phi$ is needed. However, the estimator that drops the score term (right equation in \Cref{eq:entropy-gradients}) is typically lower variance. The natural way to do this is to first sample from $q_\phi$, and then, in a second {\em independent} step, evaluate the sample at parameters $\theta=\phi$ that are held constant under differentiation. In this second step, the sample is treated as an arbitrary point so that derivatives will only flow to the sampling part of the algorithm. This requires the inverse $T^{-1}_\phi$.
With real-NVP flows, both the forward and reverse transform are efficient, so the second estimator from \Cref{eq:entropy-gradients} can be used. \Cref{fig:nf-stl} compares the results of substituting this estimator instead. In many cases, the results are much the same. However, in a significant minority of models, the new estimator yields enormous improvements.
\section{Enriched Variational Families}
\label{sec:enriched}
\input{families/iwvi_section}
\input{families/nf_section}
\input{families/nf_iw_section}
\subsection{Importance Weighting with Normalizing Flows}
\label{sec:fam-nf-iw}
\begin{wrapfigure}{r}{0.35\textwidth}
\centering
\vspace{-5mm}
\includegraphics[page = 5, height=\linewidth]{figure/new_pairwise_comparisons.pdf}
\caption{\footnotesize{Adding IW-sampling to normalizing flows can significantly improve some of the models and never hurts.}}
\label{fig:nf-IW-sampling}
\vspace{-6mm}
\end{wrapfigure}
Importance weighting and normalizing flows can be applied together. The ideas in \Cref{sec:fam-iw} are not specific to Gaussian densities. In the first experiment, we take the same optimization scheme used above, and apply importance weighted sampling only (with no change to the optimization procedure). As shown in \Cref{fig:nf-IW-sampling}, this change never hurts, provides small improvments for most models, and provides large improvements on a minority of models. Since this again comes at a minimal cost (extra work is only needed in the sampling stage) it is very worthwhile.
One can also explicitly optimize the IW-ELBO. \Cref{fig:nf-iw-training} demonstrates that adding IW-training provides large benefits on a few models but hurts performance by 1 nat or more for almost 10\% of the cases. These observations mirror the effect observed for Gaussians in \Cref{fig:iw_training}.
We now arrive at our best method: train normalizing flows with a regular ELBO objective using the lower-variance STL gradient and then add importance sampling only during inference. This is easily the go-to black-box VI strategy when we fix a budget for $\log p$ evaluations.
\section{Introduction}
\label{sec:intro}
We consider the problem of automatic posterior inference. A scientist or expert creates a model $p(\vectorize{z}, x)$ for latent variables $z$ and observed variables $x$. For example, $z$ might be population-level preferences for a political candidate in each district in a country, while $x$ is an observed set of polls. Then, we wish to approximate the posterior $p(\vectorize{z}|x)$, i.e., determine what the observed data say about the latent variables under the specified model.
The ultimate aim of automatic inference is that a domain expert can create a model and get answers without manually tinkering with inference details.
In practice, one often resorts to approximate inference. Markov chain Monte Carlo (MCMC) methods are widely applicable and are asymptotically exact, but sometimes slow. Variational inference (VI) approximates the posterior within a tractable family. This can be much faster but is not asymptotically exact. Recent developments led to ``black-box VI'' methods that, like MCMC, apply to a broad class of models \citep{ranganath2014black, hoffman2013stochastic, blei2017variational}.
However, to date, black-box VI is not widely adopted for posterior inference. Moreover, there have been several advances that are relevant to black-box VI, but have been little evaluated in that context. One such advance is normalizing flows, which define flexible densities through a composition of invertible transformations \citep{rezende2015variational, papamakarios2019normalizing}. Surprisingly, normalizing flows have seen almost no investigation for black-box VI; instead, they have been used either to directly learn a density \citep{dinh2014nice, dinh2016density, papamakarios2017masked, kingma2018glow} or to bound the likelihood of a deep latent variable model $p_\theta(x) = \int p_\theta(\vectorize{z}, x) d\vectorize{z}$ \citep{rezende2015variational, kingma2016improved, durkan2019neural}. In both cases, there is no mechanistic model and little or no focus on posterior queries.
Another major direction is the development of tighter variational objectives that integrate Monte Carlo techniques such as importance weighting \citep{burda2015importance, naesseth2017variational, maddison2017filtering}. These were also initially designed to support learning of deep latent variable models. However, further developments have shown that they can also be viewed as enriching the variational family \citep{bachman2015training,cremer2017reinterpreting,domke2018importance,Domke2019DivideAC}. Still, little is known about the practical performance of these techniques on real models. Further, importance weighting can be used in two ways. First, importance weighted \emph{sampling} can be used at inference time to obtain better approximate samples, regardless of how the approximate distribution was created. Second, importance weighting \emph{training} can be used during optimization to tighten an objective reflecting how well such a sampling scheme will work. There is little evidence in the literature about these.
It is essential for many users that black-box VI be \emph{fully automatic}. This brings up numerous practical issues, such as initialization, step-size schedules, and the choice of gradient estimator. There have been few attempts to address this \citep{kucukelbir2017automatic} and several basic questions remain unanswered: Do recent techniques to enrich variational families such as normalizing flows and variational Monte Carlo methods improve accuracy on mechanistic models? Which of these is more important? Can optimization be made robust enough to work with these techniques ``out of the box'' on real models?
\begin{figure*}[t]
\begin{subfigure}{0.65\linewidth}
\centering
\includegraphics[page = 1, width=\linewidth]{figure/new_figure_2_ccdf.pdf}
\end{subfigure}
\begin{subfigure}{0.35\linewidth}
\centering
\includegraphics[height=1.225\linewidth]{figure/Advances_in_BBVI_modified.png}
\end{subfigure}
\caption{\small{\textbf{(Left) Path study}: Empirical complementary-CDF for performance improvement over ADVI. \textbf{(Right) Relationship of methods}: Solid lines show modifications that improve performance (included on the left) dotted lines show modifications with unclear benefits (not shown on the left).}}
\label{fig:path-study-outline-combined}
\end{figure*}
The basic hypothesis of this paper is that automatic black-box VI can be best achieved through a thoughtful integration of many different algorithmic components. We carefully measure the impact of these components on 30 real models from the Stan model library \citep{stanmodels,StanDevelopmentTeam2018}. Our primary finding is that a combination of techniques to improve optimization robustness and enrich variational families collectively yield remarkable improvements in the accuracy of black-box VI. More concretely, we make the following observations.
\begin{itemize}[leftmargin=15pt, itemsep=3pt]
\item A prior step-size scheme often leads to suboptimal results. Using a comprehensive search over step-sizes is far more reliable (\Cref{fig:step-size-cdf}).
\item When using a Gaussian variational distribution, it is consistently helpful to use the sticking the landing" (STL) gradient estimator \citep{roeder2017sticking} that drops the “score term” from the evidence lower bound (ELBO) (\Cref{fig:init-cdf}).
\item Importance-weighted sampling can be used as a post hoc method to improve the posterior found by \emph{any} inference method. This consistently improves results at minimal cost (\Cref{fig:iw_sampling,fig:nf-IW-sampling})
\item Importance-weighted training introduces a trade-off between computational complexity and quality. The benefits are not consistent in our experiments (\Cref{fig:iw_training,fig:nf-iw-training}).
\item Real-NVP \citep{dinh2016density} (evaluated for the first time for black-box VI) gives excellent performance. Due to high nonlinearity, one might expect that fully-automatic optimization would be a challenge. However, when combined with our step-size scheme, it consistently delivers strong results without user-intervention (\Cref{fig:nf,fig:nf-stl,fig:nf-IW-sampling}).
\item When using a normalizing flow variational distribution, the STL estimator is again helpful (\Cref{fig:nf-stl}). However, this uses an inverse transform, which is not efficient with all flows (\Cref{sec:nf}).
\item The doubly-reparameterized estimator \citep{tucker2018doubly} consistently improves convergence when applied to importance weighted training (\Cref{fig:iw-training-dreg-iwae-g-nf} in appendix). However, as above, the overall value of importance-weighted training is unclear.
\end{itemize}
Our final method combines importance sampling, normalizing flows, a highly robust step-size scheme and the STL gradient estimator, to improve the performance by one nat or more on at least 60\% of the models when compared to Automatic Differentiation Variational Inference (ADVI) (see performance of Method (4c) in \Cref{fig:path-study-outline-combined}). We believe this strategy represents the state-of-the-art for fully-automatic black-box VI for posterior inference.
\section{Optimization in BBVI}
\label{sec:optimization}
Most uses of black-box VI make optimization choices on a model-specific basis. A notable exception to this is the ADVI \cite{kucukelbir2017automatic}, which we use as our baseline.
ADVI is integrated into Stan, a state-of-the-art probabilistic programming framework for defining statistical models with latent variables \citep{carpenter2017stan}. This makes ADVI one of the most widely available black-box VI algorithms.
There are four key ideas: (1) to automatically transform the support of constrained random variables to an unconstrained space (2) to approximate the resulting unconstrained posterior with a Gaussian variational distribution, (3) to estimate the gradient of the ELBO using the reparameterization trick and (4) to do stochastic optimization with a fully-automated step-size procedure.
In all cases, we use the idea of transformation to unconstrained domain unchanged (1). In the rest of this section, we consider modifications to optimization ideas (3,4). In the next section, we consider generalization beyond Gaussians (2).
\input{optimization/step_size}
\subsection{Gradient Estimation}
Most black-box VI methods are based on the reparameterization trick. Suppose that $q_\epsilon$ is a fixed distribution and $z_{\phi}(\epsilon)$ a function such that if $\epsilon \sim q_\epsilon$ then $z_{\phi}(\epsilon) \sim q_\phi$. Then, if $H(\phi)$ is the entropy of $q_\phi$, the gradient of \Cref{eq:elbo} can be written as
\begin{align}
\nabla_{\phi}\mathcal{L}(\phi) &= \E_{q_\epsilon (\epsilon)} \left [\nabla_{\phi} \log p(z_{\phi}(\epsilon), x) \right] + \nabla_{\phi} H(\phi). \label{eq:justin-elbo-grad}
\end{align}
The gradient can be estimated by drawing a single $\epsilon$ (or a minibatch). In some cases (e.g., Gaussians) $H$ is computed in closed form, so the above equation can be used unchanged; this is estimator used in ADVI. Alternatively, $\nabla H$ can also be estimated using the reparameterization trick, using either of
\begin{align}
\nabla_{\phi} H(\phi) = \E_{q_\epsilon (\epsilon)} \underbrace{\nabla_{\phi} \log q_\phi(z_{\phi}(\epsilon))}_\text{"Full" estimator} = \E_{q_\epsilon (\epsilon)} \underbrace{\left (\nabla_{\phi} \log q_\theta(z_{\phi}(\epsilon)) \right)_{\theta=\phi}}_{\text{"STL" estimator}}. \label{eq:entropy-gradients}
\end{align}
The second option, known as STL estimator \citep{roeder2017sticking}, "holds $\phi$ constant" under the gradient. This is valid since $\E_{q_\phi(z)} \nabla_\phi \log q_\phi(z) = 0$.
\begin{wrapfigure}{r}{0.35\textwidth}
\centering
\vspace{-6.5mm}
\begin{small}
\begin{center}
\centerline{\includegraphics[page = 15, height=\linewidth]{figure/new_pairwise_comparisons.pdf}}
\caption{\footnotesize{Adding STL to Gaussian VI is consistently helpful across the models and hurts only in minority of cases.}}
\label{fig:init-cdf}
\end{center}
\end{small}
\vspace{-16mm}
\end{wrapfigure}
\Cref{fig:init-cdf} compares the results of the STL estimator to a closed-form entropy. The STL estimator is usually preferred. We give a more comprehensive comparison of estimators in \Cref{fig:stl-vi-H estimators for g} (supplement).
\input{optimization/initialization}
\subsection{ADVI step size search}
ADVI uses a novel decreasing step-size scheme based on a base step-size $\eta$ (we review this in \Cref{sec:advi-step-scheme}). In short, for each \dollarit{\eta \in \{0.01, 0.1, 1, 10, 100\}}, optimization is run for a small number of iterations, and the value that provides the highest final ELBO value when estimated on a fresh batch of samples is used. We use a batch of fresh 500 samples after 200 iterations. It is not clear to what degree results after a small number of iterations can give a realistic picture of how optimization will look after a large number of iterations. To test this, we propose a straightforward alternative that simply runs different steps more exhaustively.
\subsection{Comprehensive step search}
\label{sec:step-size-comp-search}
\begin{wrapfigure}{r}{0.35\textwidth}
\centering
\vspace{-8mm}
\begin{small}
¸\begin{center}
\centerline{\includegraphics[page = 1, height=\linewidth]{figure/new_pairwise_comparisons.pdf}}
\caption{\footnotesize{Using comprehensive step-size search provides significant gain of 1 nat on almost 20\% of the models (high variability is due to ADVI).}}
\label{fig:step-size-cdf}
\end{center}
\end{small}
\vspace{-8mm}
\end{wrapfigure}
We perform optimization using Adam \citep{kingma2014adam}, and we comprehensively search for the Adam step-size \dollarit{\eta} in the range $\frac{0.1}{D}[1, {B^{-1}}, {B^{-2}}, {B^{-3}}, {B^{-4}} ],$ where $D$ is the number of latent dimensions of the model and $B$ is a decay constant; we use $B=4$. For each step size in this range, we optimize for a fixed number of iterations while keeping the step size constant. The number of iterations is constrained only by the sampling/computational budget of a user; we use 30,000 iterations for each step-size choice.
Finally, we select the parameters from the step size that led to the best average-objective, averaged over the entire optimization trace. We found this to be a more robust indicator of performance than estimating the final ELBO using a smaller batch of fresh samples (see \Cref{sec:select-best-model} for discussion).
\Cref{fig:step-size-cdf} shows that the comprehensive search provides a significant improvement of 10 nats or more on a small fraction of the models (both schemes in the figure use the closed-form entropy estimator from \Cref{eq:justin-elbo-grad}).
\subsection{Intialization}
\label{sec:initialization}
Initialization can have a major influence on convergence. ADVI initializes to a standard Gaussian. A natural alternative for Gaussian or Elliptical variational distributions is to use Laplace's method to initialize parameters \cite{domke2018importance, Domke2019DivideAC}.
This method uses black-box optimization to find $\hat{z}$ to maximize $\log p(z, x)$, computes the hessian of $\log p$ at $\hat{z}$ and then sets $q_\phi(z)$ to be the Gaussian whose log-density matches the local curvature of $\log p(\hat{z}, x)$.
While Laplace's method is intuitive, it could conceivably be harmful, e.g. by providing an initialization that leads to a worse local optima.
To the best of our knowledge, there are no existing studies of these initialization schemes. \Cref{fig:laplace-neutral} (supplement) uses the previous comprehensive step search and compares the results of adding Laplace's initialization (LI).
A similar fraction of models are helped and harmed by the change.
| {'timestamp': '2020-10-27T01:06:37', 'yymm': '2006', 'arxiv_id': '2006.10343', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10343'} | arxiv |
\section{To mention}
\section{Introduction}
\label{sec:intro}
The term Active Learning describes the field of selecting samples from a given pool of data in order to subsequently train a Machine Learning algorithm with. This can be done for two major reasons: Firstly, deciding which subset of collected data will be annotated in order to create training and validation set for a supervised Machine Learning task. While it can be comparatively easy and inexpensive to record and gather sensor data and ever decreasing cost makes it affordable to possibly neglect storage expenses, reliable ground truth annotation still requires manual labour and is therefore the crucial factor. In industrial application of Machine Learning to various tasks, budget and time constraints play a significant role and performance can depend on choosing the best $n$ samples to train on.
Secondly, one could think of using Active Learning methods as a form of regularization. While increasing the number of available training samples is in general regarded as helpful, certain factors can lead to an impaired performance when doing so. The more objects in a recognition task are standardized, the more redundant information is potentially added to the dataset with each new sample, which can result in worsened generalization. Active Learning methods can also be applied to sanitize a dataset from falsely labelled samples, as a suitable strategy will not pick samples with a conspicuous difference between label and prediction.
However, despite the great potential of Active Learning it also bears significant risks. If applied in an incorrect way it could lead to a sub-optimal sample selection, and, in the worst case, rendering the complete Machine Learning task unsuccessful. In order to point out how to avoid these pitfalls, we examine a set of known Active Learning query strategies, as well as some extensions of our own, and their performance on various different image classification datasets. We then view their performance under different aspects including changing hyperparameters, influence of falsely labelled data and the replaceability of varying CNN architectures. Eventually we regard the performance of the same strategies when applied to a problem of hierarchical classifiers. Our main contributions are:\\
1.) A robustness investigation of state-of-the-art Active Learning strategies with respect to the impact of falsely labelled data, hyperparameters and the impact of changing the classifier model during the selection phase. 2.) An extension of the Active Learning method based on Entropy computation using the Simpson Diversity. 3.) Theoretical insights and experimental results for Active Learning on Hierarchical Neural Networks.
\section{Related Work}
\label{sec:relWork}
An overview of methods from the pre Deep Learning area can be found in the very comprehensive review of \cite{settles_10}. Many approaches originating from that time (e.g. Uncertainty sampling, Margin based sampling, Entropy Sampling, ...) have been later adapted to neural networks. Additional examples for this include the approach of \cite{roy-mccallum_01}, who applied a Monte Carlo method to compute an estimated error reduction that can be used for sample selection as well as clustering approaches like those described in \cite{nguyen-smeulders_04} and \cite{dasgupta-hsu_08}.
\cite{wang-etal_17} and \cite{rottmann-etal_18} propose a semi-supervised approach. They use Active Learning to query samples which the network has not yet understood and use label propagation to also utilize well understood samples with "pseudo-labels".
In the field of supervised learning, \cite{korattikara-etal_15} used a Bayes approach to distil a Monte Carlo approximation of the posterior predictive density for sample selection. In the theoretical work of \cite{kabkab-etal_16}, Active Learning was rephrased as a convex optimisation problem and the balancing of the selection of samples with high diversity and those that are very representative for a subset are discussed.
Unlike many other methods, the core-set approach of \cite{sener-savarese_18} does not use the output layer of a network for Active Learning. Instead they solve a relaxed $k$-centres problem to minimize the maximal distance to the closest cluster centre for each sample in a space that is spanned by the neurons of a hidden layer of a network. As discussed later, this approach has a very high independence of the actual classes of a network, which can be helpful when dealing with hierarchical networks \cite{weyers-etal_18} for example.
\cite{gal-etal_17} introduced the concept of live-dropout to Active Learning. The idea is to approximate the behaviour of an ensemble of Bayesian estimators by activating dropout during inference and multiple forward passes. They furthermore developed an Active Learning framework which is able to use this and other deep Bayesian methods. In the same line of thought, \cite{ducoffe-precioso_17} investigated live dropout and Query-by-committee methods.
However, \cite{beluch-etal_18} used ensembles of CNNs with identical architectures but different weight initiations to show that ensembles work better than "ensemble approximation methods" like the above mentioned MC dropout of \cite{gal-etal_17} or approaches based on geometric distributions like \cite{sener-savarese_18}.
Some recent approaches also utilize "meta" knowledge for Active Learning. \cite{fang-etal_17} introduced "Policy based Active Learning". There, reinforcement learning is used for stream based Active Learning in a language processing setting. This is very similar to the approach of \cite{bachman-etal_17} who proposed "Learning Algorithms for Active Learning". They also used Reinforcement Learning to jointly learn a data representation, an item selection heuristic and a method for constructing prediction functions from labelled training sets.
\cite{heilbron-etal_18} reuse knowledge from previously annotated datasets to improve the Active Learning performance.
\section{Methods}
\label{methods}
In the following we review existing methods from the field of pool-based Active Learning and propose a suggestion of our own. Given a classification model $\theta$ and a dataset $\mathcal{D}$, consisting of a feature and label pair $\langle x\in X, y\in Y \rangle$, such an algorithm has the following structure:
\begin{algorithm}[H]
\SetKwData{Left}{left}\SetKwData{This}{this}\SetKwData{Up}{up}
\SetKwFunction{Union}{Union}\SetKwFunction{FindCompress}{FindCompress}
\SetKwInOut{Input}{Input}\SetKwInOut{Output}{Output}
\Input{$\mathcal{L} \subset \mathcal{D} = \lbrace\langle x, y \rangle\rbrace$ : Labelled set,\\
$\mathcal{U} = \mathcal{D}\, \backslash \, \mathcal{L} = \lbrace\langle x, ? \rangle\rbrace$ : Unlabelled set, \\
$\theta$ : Classification model, \\
$\phi$: Active Learning query function \\ }
\While{$\vert\mathcal{U} \vert \, > 0 \; \wedge $ no stopping criterion}{
$\theta$ = $train(\mathcal{L})$\;
\For{\bf{all} $\langle x, ?\rangle \in \mathcal{U}$}{
Compute Active Learning metric $\phi(x)$ under $\theta$\;
}
Choose $x^\star$ with highest magnitude of $\phi(x^\star)$ \;
Annotate $y^\star$\;
$\mathcal{L} \leftarrow \mathcal{L} \cup \lbrace \langle x^\star, y^\star\rangle \rbrace$\;
$\mathcal{U} \leftarrow \mathcal{U} \setminus \lbrace \langle x^\star, y^\star \rangle \rbrace$\;
}
\caption{Pool-Based Active Learning.}
\end{algorithm}
Considering a large dataset, one can query numerous samples at once. This set of the chosen samples is denoted by $\mathcal{B} \subset U$ \cite{kabkab-etal_16}.
We take a closer look at uncertainty sampling, a strategy that selects samples the classifier is uncertain about. In this context uncertainty means a low confidence for the predicted class that is given by $\hat{y} = \argmax_y \, P_\theta(y|x)$. We consider three commonly used uncertainty measures:
\begin{enumerate}
\item[(a)] \textit{Least Confident:} $x^\star_{LC} = \argmax_x \, (1 - P_\theta(\hat{y} |x))$
\item[(b)] \textit{Margin:} $x^\star_M = \argmin_x \, (P_\theta(\hat{y}_1|x) - P_\theta(\hat{y}_2|x))$
\item[(c)] \textit{Entropy:} $x^\star_H = \argmax_x \left( - \sum_{i}\, P_\theta(y_i | x) \log P_\theta(y_i | x)\right)$
\end{enumerate}
(a): Considering only one class label, the sample $x^\star_{LC}$ with the least confident label prediction is selected. (b): Margin sampling includes information about the second most certain prediction. The algorithm queries the sample $x^\star_M $ with the smallest difference between the two most probable class labels. (c): For multi class tasks, it is relevant to consider all label confidences. For each sample every class probability is weighted with its information content and summed up. The algorithm queries the sample with the highest entropy $x^\star_H $ \cite{settles_10}.
For the following experiments we implement eight query strategies.\\
Based on Least Confident (a):
\vspace{-0.2cm}
\begin{description}\itemsep-3pt
\item[Naive Certainty (NC) Low:] Select $n$ samples with the minimal maximal activation in classifier logits. Since basing the decision only on the one highest activated neuron is a very straightforward approach, we call this family of strategies the "Naive" methods.
\item[NC Range:] Select $n$ samples within a certain range of the classifier logits' activation (e.g. $[0.1, 0.9]$).
\item[NC Diversity:] Select $n$ samples with the minimal maximal activation in classifier logits and additionally prevent that similar samples are chosen by calculating the diversity of the samples below the threshold compared to those already included in the training set.
\item[NC Balanced:] Select $n$ samples with the minimal maximal activation in classifier logits and balance the class distribution using the reciprocal value of the classification confusion matrix obtained with the previous training set. Terminates if one class contains no more samples to be drawn.
\end{description}
Based on Margin (b):
\vspace{-0.2cm}
\begin{description}\itemsep-3pt
\item[Margin:] Select $n$ samples with the smallest difference of the two highest firing logits.
\end{description}
Based on Entropy (c):
\vspace{-0.2cm}
\begin{description}\itemsep-3pt
\item[Entropy High:] Select $n$ samples with the highest entropy.
\item[Sum of Squared Logits (SOSL):] Select $n$ samples with the highest Simpson diversity index $D = 1 - \sum_i (l_i)^2$ \cite{simpson} (cf. \ref{subsec:SOSL}).
\end{description}
\textbf{Core Set Greedy:} A similarity measure in the embedding space. Creates a core set by approximating the
problem of distributing $k$-centres in $n$ points, such that the minimal distance of all points to the nearest centre is maximized. Select $n$ samples for which the minimum distance to all samples which are already part of the training set is maximized (cf. \cite{sener-savarese_18}).
\subsection{Sum of Squared Logits (SOSL) Method}
\label{subsec:SOSL}
In Active Learning, we require a measure of how sure the classifier is that its class decision during inference is accurate. One possibility for such an accuracy-of-inference measure is to analyze the distribution of logits. Within the trained model of the classifier, the logits can be interpreted as probabilities that the inferred sample belongs to the class associated of the respective logit. If the logits are strongly biased in favour of a certain class, it is very likely that the given sample belongs to the class corresponding to the strongest logit. On the contrary, if the logits do not show a clear preference for a certain class, there is a high risk that taking the class of the strongest logit results in a false prediction. In other words, to which degree the distribution of logits tends towards peaks rather than an equipartition indicates how accurate the inference is going to be.
In previous literature, the Shannon entropy \cite{shannon} has been frequently used as a measure of how peaked or equipartitioned a distribution is. A valid strategy for Active Learning could then be to sort out those samples, for which the Shannon entropy $H = - \sum_i l_i \log(l_i)$, with $l_i$ being the values of the logits, is particularly high. However, a shortcoming of this approach is that it does not adequately account for the situation when the the distribution of logits is admittedly strongly peaked, but with peaks on more than one class logit. Such a situation can easily arise in samples, when they belong to classes showing similarities and the classifier's model does not yet feature a clear decision boundary between them. In such a case, the distribution of logits is still far away from an equipartition, resulting in a relatively low value for the Shannon entropy $H$. Thus, although labelling these samples would be particularly valuable for fleshing out the decision boundary and allowing the classifier to better separate between classes, they would not be added to Active Learning training set.
To overcome these shortcomings of the Shannon entropy $H$ as a measure for characterizing the distribution of logits $l_i$, we propose to use the Simpson diversity index $D = 1 - \sum_i (l_i)^2$ \cite{simpson} instead. The closer the distribution $l_i$ is to an equipartition, the larger $D$ becomes. If the $l_i$ shows a strong peak at a certain $i$, $D$ is close to zero. Finally, if the $l_i$ are strongly peaked among several classes, $D$ will have a small-to-moderate value between zero and one. The latter property of $D$ in particular allows to select those samples for labelling, for which the classifier can narrow the class decision down to a few classes, among which it is still unsure. The Active Learning strategy is then to select in each iteration the $n$ samples with highest $D$.
\section{Experiments and Results}
We conduct a series of experiments with the query strategies presented in section \ref{methods} on six different datasets for image classification (cf. Table \ref{tab:datasets}). These consist of the well-known digit classification set MNIST \cite{mnist} and the thereof inspired dataset of the Latin alphabet CoMNIST \cite{comnist} and clothing classification Fashion-MNIST \cite{fmnist}, as well as general object classification CIFAR-10 \cite{cifar} and the house number collection SVHN \cite{svhn}. We furthermore evaluate strategies on a private dataset of $33$ different classes of traffic signs (TSR) represented through small grey scale images.
\begin{table}[h!]
\centering
\begin{adjustbox}{max width=\textwidth}
\begin{tabular}{l|cccccc}
& CIFAR-10 & CoMNIST & Fashion-MNIST & MNIST & SVHN & TSR \\ \hline \hline
Classes & $10$ & $26$ & $10$ & $10$ & $10$ & $33$ \\
Image Size & $32\times32$ & $32\times32$ & $28\times28$ & $28\times28$ & $32\times32$ & $34\times34$ \\
Channels & $3$ & $1$ & $1$ & $1$ & $3$ & $1$ \\
Training Samples & $50\,000$ & $9\,918$ & $60\,000$ & $60\,000$ & $73\,257$ & $265\,774$ \\
Validation Samples & $10\,000$ & $1\,300$ & $10\,000$ & $10\,000$ & $26\,032$ & $66\,443$ \\
\end{tabular}
\end{adjustbox}
\caption{Characteristics of the datasets used for the experiments.}
\label{tab:datasets}
\end{table}
\begin{figure}[H
\begin{center}
\begin{tabular}{cr@{}cr@{}
\includegraphics[clip, trim=0.5cm 0.65cm 1.65cm 1.4cm,
page=1,width=.375\textwidth]{images/fMNIST_full_result_std_REWORKED} & \hspace{0.0cm}
\includegraphics[clip, trim=0.5cm 0.65cm 1.65cm 1.4cm,
page=1,width=.375\textwidth]{images/TSR_full_result_std_REWORKED} \\
\includegraphics[clip, trim=0.5cm 0.35cm 1.65cm 1.4cm,
page=1,width=.375\textwidth]{images/MNIST_full_result_std_REWORKED} & \hspace{0.0cm}
\includegraphics[clip, trim=0.5cm 0.35cm 1.65cm 1.4cm,
page=1,width=.375\textwidth]{images/CIFAR10_full_result_std_REWORKED
\vspace{-0.2cm}
\end{tabular}
\end{center}
\caption{Classification accuracy over training set size for all strategies on Fashion-MNIST (top left), TSR (top right), MNIST (bottom left) and CIFAR10 (bottom right). The plotted value is the median of five runs and the shaded area denotes one standard deviation.}
\label{fig:generalperformance}
\end{figure}
\subsection{General Performance}
\label{subsec:general}
Before we analyse the robustness of the presented query strategies, we compare their general performance on the datasets presented above. For each dataset we use a distinct plain feed-forward CNN. Only for CIFAR-10 we use an implementation of ResNet50 \cite{resnet}. As we are not aiming to find the best architecture for a certain problem but to identify the most promising samples, we choose the number of layers and channels according to the approximate complexity of the task and select learning rates and batch sizes in commonly used ranges.
For all of these experiments, we start with a training set of $100$ samples per class of the particular dataset. We train the CNN for up to $1000$ epochs with an early stopping of $200$. For this purpose we split $10\%$ of the training set into an additional "development set". It is not used for training but to validate classification over the course of the training. This is done to obviate an overfitting-like bias with the use of early stopping. Of course the validation accuracy is then determined on the original test set of the respective dataset, using the best network weights acquired during training according to the development set accuracy.
This network is also the one used to then select new samples to be added to the training set utilizing the query strategies. With each iteration we increase the number of samples in the training set by $20\%$. In all cases we conduct five repetitions per strategy and dataset for statistical significance. To reduce the computational burden,
we iteratively draw new samples until we have reached approximately a third of the full size of the respective training set.
Figure \ref{fig:generalperformance} illustrates the results of the evaluation of all query strategies.
Nearly all findings show a benefit of Active Learning methods and at least some of the query strategies are either hitting the baseline, or are close to it, around the $30\%$ mark. For CIFAR-10 however, this is not true. None of the methods show any profit for this dataset and are in line with the random sample selection, resulting in a nearly perfectly linear increase in accuracy. This does not come as a surprise, as CIFAR-10 has very diverse representations of its classes and seems to contain no redundant information.
\begin{figure
\begin{center}
\begin{tabular}{c@{}c@{}
\hspace{-0.5cm}
\includegraphics[clip, trim=0.3cm 0.8cm 0.2cm 0.9cm, page=1,width=.55\textwidth]{images/mnist_learningrates} & \hspace{-0.55cm}
\includegraphics[clip, trim=0.3cm 0.8cm 0.2cm 0.9cm, page=1,width=.55\textwidth]{images/mnist_batchsize} \\
\end{tabular}
\end{center}
\caption{Changes in learning rate (left) and batch size (right) for various Active Learning strategies on MNIST. The plotted value is the median of five runs.}
\label{fig:hyperparams}
\end{figure}
\subsection{Changing Hyperparameters and Falsely Labelled Data}
\label{subsec:hyperparams}
As hyperparameter optimisation is very important in fine-tuning the performance of Machine Learning algorithms, we analyse how much changes in these parameters influence the usability of the Active Learning methods shown.\\
Figure \ref{fig:hyperparams} shows the effect of altering the learning rate over two magnitudes and the batch size up to a factor of $16$, for experiments on MNIST. All methods behave very robustly and do not show to be influenced by these alterations.
Since it can be expected that human annotation, especially in large scale labelling of sensor data, is never perfectly accurate, it is interesting to investigate how this might interfere with the applicability of Active Learning. In Figure \ref{fig:errors} (left) we show results for an experiment where we purposely introduced false labels into the Fashion-MNIST training set. It can clearly be seen, that methods relying on a diversity criterion (NC Diversity, Core Set) suffer the most, since their selection process prevents similar samples from being chosen and therefore it can be harder to correct the negative impact that the selection of a wrongly labelled sample would have. Please note that these strategies also show the highest sensitivity to changes in dropout (cf. Figure \ref{fig:errors} right).
\subsection{Replaceability of Classifiers}
\label{subsec:classifiers}
In the application of Machine Learning, especially in product context, successive refinement of the algorithm is very common. A CNN architecture might be adjusted several times over the course of development or a production process, to optimise the performance or to adapt to changes in the dataset or external restrictions like computational resources. We investigate how the usability of Active Learning might be influenced, if data selection is done by a different network than the one eventually targeted for classification performance. For this purpose we implemented three CNNs, referred to as $Min$, $Med$ and $Max$ in the following, of different capacity to iteratively select samples from Fashion-MNIST with the query strategies as described above. We then perform a cross-training, where every network is trained with the selections of the others and its own. To ensure comparability, we use the same initial dataset of $100$ samples per class for all classifiers and repeat calculations five times.
\begin{figure
\begin{center}
\begin{tabular}{c@{}c@{}}
\hspace{-0.5cm}
\includegraphics[clip, trim=0.3cm 0.8cm 0.2cm 0.9cm, page=1,width=.55\textwidth]{images/fmnist_error} & \hspace{-0.55cm}
\includegraphics[clip, trim=0.3cm 0.8cm 0.2cm 0.9cm, page=1,width=.55\textwidth]{images/mnist_dropout} \\
\end{tabular}
\end{center}
\caption{Active Learning strategy results for various synthetic labelling error rates on Fashion-MNIST (left) and different dropout regularization rates on MNIST (right). The plotted value is the median of five runs.}
\label{fig:errors}
\end{figure}
Figure \ref{fig:cross} shows the results for selected strategies.
Apart from information about the replaceability of classifiers, these results can show how the classifier capacity itself influences the applicability of Active Learning strategies. For the example of NC Balanced we can note a bias for the own selection performing best with the $Max$ and $Min$ classifier, while the medium-sized one shows indifference. The "weaker" the network gets, the better the performance of the random selection becomes. For the SOSL, this becomes even more clear. While the selection of the $Max$ classifier is still definitely the best for itself, the smaller networks show the best performance with the randomized set. The results with Entropy High are very similar, but the gaps become even more obvious. $Max$ now shows a very clear preference for the own selection compared to any other and the performance of the Active Learning strategy selection on the $Min$ network is now more than three percentage points behind random.
\begin{figure}[H]
\begin{center}
\begin{tabular}{c@{}c@{}c@{}
\hspace{-0.7cm}
\hspace{0.15cm}
\includegraphics[clip, trim=0.3cm 0.15cm 1.6cm 1.4cm, width=0.335\textwidth]{images/cross_entropy_high_FINAL} & \hspace{0.25cm}
\includegraphics[clip, trim=1.8cm 0.15cm 1.6cm 1.4cm, width=0.3\textwidth]{images/cross_nc_balanced_FINAL_nolegend} & \hspace{0.25cm}
\includegraphics[clip, trim=1.8cm 0.15cm 1.6cm 1.4cm, width=0.3\textwidth]{images/cross_simpson_FINAL_nolegend}
\end{tabular}
\end{center}
\caption{Results (mean of five runs) of cross training of different classifiers, Max (solid line), Med (dashed), Min (dotted), with the sample selection of the other networks and its own (blue, green, red), compared against a random selection (black), for the strategies Entropy High (left), NC Balanced (mid) and SOSL (right). Evaluations are made after 3, 5, 10 and 15 Iterations of querying new samples, except for NC Balanced which already terminated before the 15th iteration.}
\label{fig:cross}
\end{figure}
\subsection{Hierarchical Classifiers}
\label{subsec:hierarchical}
To complete our Active Learning robustness study, we examine a neural network structure different from the straightforward CNNs in the preceding sections.
Hierarchical or cascaded classifiers do not use a single label per sample but a whole label tree (cf. \cite{weyers-etal_18}). Consequently, label vectors consist of one of the three following options per class: "1, 0 or not applicable" and each sample belongs to exactly one class per hierarchy level. Furthermore, during the learning phase each class is treated independent of all others. If we have an $n$-class classification problem, $n$ "1-vs-all classifiers" are trained.
This renders all Active Learning strategies which rely on quantifying the uncertainty of the logits useless. All of them (e.g. Naive Certainty, Margin) implicitly rely on the assumption that labels with two possible states are used. As the neurons that belong to classes marked as "not applicable" are not considered during backpropagation (cf. \cite{weyers-etal_18}) they can take arbitrarily high values and thus confuse the mentioned Active Learning methods.
As can be seen in Figure \ref{fig:cascade} this can even result in worse performance than random sampling. However, we can show, that methods, which work in the embeddings space (like the Core Set method), are not effected and thus are also employable for hierarchical neural networks.
\subsubsection{Used Dataset}
\label{subsubsec:dataset}
In all experiments with the hierarchical classifier we use a private dataset that consists of 12 classes which depict different poses of a human hand (e.g. "One finger", "Two fingers", "Fist Thumb Left", etc.). We use a training set of $670\,000$, a development set of $75\,000$ and a test set containing $8\,000$ grey scale images of size $22\times46$.
\begin{figure}[t
\centering
\includegraphics[page=1, clip, trim=0.5cm 0.3cm 0.5cm 1.0cm, width=0.55\textwidth]{images/gesture_FINAL}
\caption{Classification accuracy over training set size for different Active Learning methods on hierarchical classifier for hand gesture classification. The plotted value is the median of ten runs and the shaded area denotes one standard deviation.}
\label{fig:cascade}
\end{figure}
As depicted in Figure \ref{fig:gesture_structure}, we use three levels of hierarchy: 1.) "Hand"/"No hand", 2.) Class, 3.) Subclass. A sample of "Fist Thumb Left" e.g. would have the labels "Hand + "Fist Thumb" + "Fist Thumb Left". Especially the neurons of the subclasses often have the label "not applicable" as each subclass belongs to only one class.
\begin{figure}[t
\begin{center}
\includegraphics[width=0.9\textwidth]{images/gestures_wider}
\end{center}
\caption{Hierarchical labels for hand gesture recognition. Blue boxes denote the $12$ classes.}
\label{fig:gesture_structure}
\end{figure}
\section{Conclusion}
We have presented a study on the robustness of Active Learning. While we show that even plain methods can bring a notable profit in different image classification applications, we emphasise, that prior knowledge about the data and the Machine Learning algorithm in use is essential for successful application. As seen in \ref{subsec:general}, methods that work well on a number of datasets might suddenly fail on a different one and certain data collections might be inherently unsuitable for this kind of active data selection. Although many changes in hyperparameters and erroneous labels might not influence the performance of particular strategies on one hand (cf. \ref{subsec:hyperparams}), classifier changes on the other can by all means (cf. \ref{subsec:classifiers}). Critical alterations in the way a Machine Learning tasks is tackled, like switching from a straightforward to a hierarchical classifier (cf. \ref{subsec:hierarchical}), can turn the all previous findings upside down. \\
These findings underline, that Active Learning can be a helpful tool in data science, but has to be used with knowledge about the targeted utilisation. We aim to continue our endeavours in this field and expand the considerations to segmentation problems and ways to automatically provide assessment on promising combinations of data, Machine Learning algorithms and Active Learning strategies, to avoid possible pitfalls like the ones presented in this work.
\label{sect:bib}
\bibliographystyle{plain}
| {'timestamp': '2020-06-19T02:11:46', 'yymm': '2006', 'arxiv_id': '2006.10370', 'language': 'en', 'url': 'https://arxiv.org/abs/2006.10370'} | arxiv |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.